Add option to print basic road info
This commit is contained in:
parent
829787df47
commit
616f589e06
1 changed files with 49 additions and 15 deletions
|
@ -70,15 +70,15 @@ public class BinaryInspector {
|
||||||
// test cases show info
|
// test cases show info
|
||||||
if ("test".equals(args[0])) {
|
if ("test".equals(args[0])) {
|
||||||
in.inspector(new String[]{
|
in.inspector(new String[]{
|
||||||
"-vpoi",
|
// "-vpoi",
|
||||||
"-vmap", "-vmapobjects", // "-vmapcoordinates",
|
// "-vmap", "-vmapobjects", // "-vmapcoordinates",
|
||||||
"-vrouting",
|
"-vrouting",
|
||||||
"-vaddress", "-vcities","-vstreetgroups",
|
// "-vaddress", "-vcities","-vstreetgroups",
|
||||||
"-vstreets", "-vbuildings", "-vintersections",
|
// "-vstreets", "-vbuildings", "-vintersections",
|
||||||
"-lang=ru",
|
// "-lang=ru",
|
||||||
"-bbox=4.8486,52.3084,4.8747,52.2970",
|
// "-bbox=4.8486,52.3084,4.8747,52.2970",
|
||||||
// "-osm="+System.getProperty("maps.dir")+"/map.obf.osm"
|
"-osm="+System.getProperty("maps.dir")+"/map.obf.osm",
|
||||||
System.getProperty("maps.dir")+"/Netherlands_noord-holland_europe.obf"
|
System.getProperty("maps.dir")+"/Map.obf"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
in.inspector(args);
|
in.inspector(args);
|
||||||
|
@ -532,14 +532,38 @@ public class BinaryInspector {
|
||||||
MapUtils.get31TileNumberX(vInfo.lonright), MapUtils.get31TileNumberY(vInfo.lattop),
|
MapUtils.get31TileNumberX(vInfo.lonright), MapUtils.get31TileNumberY(vInfo.lattop),
|
||||||
MapUtils.get31TileNumberY(vInfo.latbottom), vInfo.getZoom(), null),
|
MapUtils.get31TileNumberY(vInfo.latbottom), vInfo.getZoom(), null),
|
||||||
p.getSubregions());
|
p.getSubregions());
|
||||||
|
if (vInfo.osm) {
|
||||||
|
printToFile("<?xml version='1.0' encoding='UTF-8'?>\n" +
|
||||||
|
"<osm version='0.6'>\n");
|
||||||
|
}
|
||||||
index.loadRouteIndexData(regions, new ResultMatcher<RouteDataObject>() {
|
index.loadRouteIndexData(regions, new ResultMatcher<RouteDataObject>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean publish(RouteDataObject obj) {
|
public boolean publish(RouteDataObject obj) {
|
||||||
mapObjectsCounter.value++;
|
mapObjectsCounter.value++;
|
||||||
|
if (vInfo.osm) {
|
||||||
|
b.setLength(0);
|
||||||
|
BinaryMapDataObject bobj = new BinaryMapDataObject();
|
||||||
|
bobj.setArea(false);
|
||||||
|
bobj.coordinates = new int[obj.pointsX.length * 2];
|
||||||
|
for(int i = 0; i < obj.pointsX.length; i++) {
|
||||||
|
bobj.coordinates[2*i] = obj.pointsX[i];
|
||||||
|
bobj.coordinates[2*i +1] = obj.pointsY[i];
|
||||||
|
}
|
||||||
|
bobj.types = obj.types;
|
||||||
|
bobj.setId(obj.getId() << 1);
|
||||||
|
bobj.objectNames = obj.getNames();
|
||||||
|
printOsmMapDetails(bobj, b, obj.region);
|
||||||
|
try {
|
||||||
|
printToFile(b.toString());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
b.setLength(0);
|
b.setLength(0);
|
||||||
b.append("Road ");
|
b.append("Road ");
|
||||||
b.append(obj.id);
|
b.append(obj.id);
|
||||||
b.append(" osmid ").append(obj.getId() >> (SHIFT_ID));
|
b.append(" osmid ").append(obj.getId() >> (SHIFT_ID));
|
||||||
|
|
||||||
for (int i = 0; i < obj.getTypes().length; i++) {
|
for (int i = 0; i < obj.getTypes().length; i++) {
|
||||||
RouteTypeRule rr = obj.region.quickGetEncodingRule(obj.getTypes()[i]);
|
RouteTypeRule rr = obj.region.quickGetEncodingRule(obj.getTypes()[i]);
|
||||||
b.append(" ").append(rr.getTag()).append("='").append(rr.getValue()).append("'");
|
b.append(" ").append(rr.getTag()).append("='").append(rr.getValue()).append("'");
|
||||||
|
@ -559,7 +583,7 @@ public class BinaryInspector {
|
||||||
int[] nametypes = obj.getPointNameTypes(i);
|
int[] nametypes = obj.getPointNameTypes(i);
|
||||||
int[] types = obj.getPointTypes(i);
|
int[] types = obj.getPointTypes(i);
|
||||||
if (types != null || names != null) {
|
if (types != null || names != null) {
|
||||||
b.append(" [ " + (i + 1) + ". ");
|
b.append("[" + (i + 1) + ". ");
|
||||||
if (names != null) {
|
if (names != null) {
|
||||||
for (int k = 0; k < names.length; k++) {
|
for (int k = 0; k < names.length; k++) {
|
||||||
RouteTypeRule rr = obj.region.quickGetEncodingRule(nametypes[k]);
|
RouteTypeRule rr = obj.region.quickGetEncodingRule(nametypes[k]);
|
||||||
|
@ -577,9 +601,10 @@ public class BinaryInspector {
|
||||||
float y = (float) MapUtils.get31LatitudeY(obj.getPoint31YTile(i));
|
float y = (float) MapUtils.get31LatitudeY(obj.getPoint31YTile(i));
|
||||||
b.append(y).append(" / ").append(x).append(" ");
|
b.append(y).append(" / ").append(x).append(" ");
|
||||||
}
|
}
|
||||||
|
b.append("]");
|
||||||
}
|
}
|
||||||
b.append("]");
|
|
||||||
}
|
}
|
||||||
|
b.append("]");
|
||||||
}
|
}
|
||||||
if (obj.restrictions != null) {
|
if (obj.restrictions != null) {
|
||||||
b.append(" restrictions [");
|
b.append(" restrictions [");
|
||||||
|
@ -610,6 +635,9 @@ public class BinaryInspector {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
println("\tTotal map objects: " + mapObjectsCounter.value);
|
println("\tTotal map objects: " + mapObjectsCounter.value);
|
||||||
|
if (vInfo.osm) {
|
||||||
|
printToFile("</osm >\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printAddressDetailedInfo(VerboseInfo verbose, BinaryMapIndexReader index, AddressRegion region) throws IOException {
|
private void printAddressDetailedInfo(VerboseInfo verbose, BinaryMapIndexReader index, AddressRegion region) throws IOException {
|
||||||
|
@ -858,7 +886,7 @@ public class BinaryInspector {
|
||||||
} else if (vInfo.vmapObjects) {
|
} else if (vInfo.vmapObjects) {
|
||||||
b.setLength(0);
|
b.setLength(0);
|
||||||
if (vInfo.osm) {
|
if (vInfo.osm) {
|
||||||
printOsmMapDetails(obj, b);
|
printOsmMapDetails(obj, b, null);
|
||||||
try {
|
try {
|
||||||
printToFile(b.toString());
|
printToFile(b.toString());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -965,13 +993,13 @@ public class BinaryInspector {
|
||||||
|
|
||||||
private static int OSM_ID = 1;
|
private static int OSM_ID = 1;
|
||||||
|
|
||||||
private void printOsmMapDetails(BinaryMapDataObject obj, StringBuilder b) {
|
private void printOsmMapDetails(BinaryMapDataObject obj, StringBuilder b, RouteRegion reg) {
|
||||||
boolean multipolygon = obj.getPolygonInnerCoordinates() != null && obj.getPolygonInnerCoordinates().length > 0;
|
boolean multipolygon = obj.getPolygonInnerCoordinates() != null && obj.getPolygonInnerCoordinates().length > 0;
|
||||||
boolean point = obj.getPointsLength() == 1;
|
boolean point = obj.getPointsLength() == 1;
|
||||||
StringBuilder tags = new StringBuilder();
|
StringBuilder tags = new StringBuilder();
|
||||||
int[] types = obj.getTypes();
|
int[] types = obj.getTypes();
|
||||||
for (int j = 0; j < types.length; j++) {
|
for (int j = 0; j < types.length; j++) {
|
||||||
TagValuePair pair = obj.getMapIndex().decodeType(types[j]);
|
TagValuePair pair = reg != null ? convert(reg.quickGetEncodingRule(types[j])): obj.getMapIndex().decodeType(types[j]);
|
||||||
if (pair == null) {
|
if (pair == null) {
|
||||||
throw new NullPointerException("Type " + types[j] + "was not found");
|
throw new NullPointerException("Type " + types[j] + "was not found");
|
||||||
}
|
}
|
||||||
|
@ -979,7 +1007,9 @@ public class BinaryInspector {
|
||||||
}
|
}
|
||||||
if (obj.getAdditionalTypes() != null && obj.getAdditionalTypes().length > 0) {
|
if (obj.getAdditionalTypes() != null && obj.getAdditionalTypes().length > 0) {
|
||||||
for (int j = 0; j < obj.getAdditionalTypes().length; j++) {
|
for (int j = 0; j < obj.getAdditionalTypes().length; j++) {
|
||||||
TagValuePair pair = obj.getMapIndex().decodeType(obj.getAdditionalTypes()[j]);
|
int addtype = obj.getAdditionalTypes()[j];
|
||||||
|
TagValuePair pair = reg != null ? convert(reg.quickGetEncodingRule(addtype)):
|
||||||
|
obj.getMapIndex().decodeType(addtype);
|
||||||
if (pair == null) {
|
if (pair == null) {
|
||||||
throw new NullPointerException("Type " + obj.getAdditionalTypes()[j] + "was not found");
|
throw new NullPointerException("Type " + obj.getAdditionalTypes()[j] + "was not found");
|
||||||
}
|
}
|
||||||
|
@ -990,7 +1020,7 @@ public class BinaryInspector {
|
||||||
if (names != null && !names.isEmpty()) {
|
if (names != null && !names.isEmpty()) {
|
||||||
int[] keys = names.keys();
|
int[] keys = names.keys();
|
||||||
for (int j = 0; j < keys.length; j++) {
|
for (int j = 0; j < keys.length; j++) {
|
||||||
TagValuePair pair = obj.getMapIndex().decodeType(keys[j]);
|
TagValuePair pair = reg != null ? convert(reg.quickGetEncodingRule(keys[j])): obj.getMapIndex().decodeType(keys[j]);
|
||||||
if (pair == null) {
|
if (pair == null) {
|
||||||
throw new NullPointerException("Type " + keys[j] + "was not found");
|
throw new NullPointerException("Type " + keys[j] + "was not found");
|
||||||
}
|
}
|
||||||
|
@ -1048,6 +1078,10 @@ public class BinaryInspector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TagValuePair convert(RouteTypeRule routeTypeRule) {
|
||||||
|
return new TagValuePair(routeTypeRule.getTag(), routeTypeRule.getValue(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
private long printWay(TLongArrayList ids, StringBuilder b, StringBuilder tags) {
|
private long printWay(TLongArrayList ids, StringBuilder b, StringBuilder tags) {
|
||||||
int id = OSM_ID++;
|
int id = OSM_ID++;
|
||||||
b.append("<way id = '" + id + "' version='1'>\n");
|
b.append("<way id = '" + id + "' version='1'>\n");
|
||||||
|
|
Loading…
Reference in a new issue