diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java b/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java index e32cbfe44e..be94f3a629 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java @@ -58,11 +58,11 @@ public class BinaryInspector { if(args.length == 1 && "test".equals(args[0])) { in.inspector(new String[]{ //"-vpoi", -// "-vmap", "-vmapobjects", + "-vmap", "-vmapobjects", // "-vaddress", "-vcities", "-vstreets", "-vstreetgroups","-vbuildings", //"-zoom=16", //"-bbox=4,55,7,50", -// "/home/victor/projects/osmand/osm-gen/Map.obf" + "/home/victor/projects/osmand/osm-gen/Map.obf" // "/home/victor/projects/osmand/osm-gen/World_basemap_2_b.obf___" // "/home/victor/projects/osmand/osm-gen/World_basemap_2.obf__" }); @@ -652,19 +652,20 @@ public class BinaryInspector { b.append("]"); } TIntObjectHashMap names = obj.getObjectNames(); - if(names != null && !names.isEmpty()) { + TIntArrayList order = obj.getNamesOrder(); + if (names != null && !names.isEmpty()) { b.append(" Names ["); - int[] keys = names.keys(); - for(int j = 0; j 0) { + // int[] keys = names.keys(); + for (int j = 0; j < order.size(); j++) { + if (j > 0) { b.append(", "); } - TagValuePair pair = obj.getMapIndex().decodeType(keys[j]); - if(pair == null) { - throw new NullPointerException("Type " + keys[j] + "was not found"); + TagValuePair pair = obj.getMapIndex().decodeType(order.get(j)); + if (pair == null) { + throw new NullPointerException("Type " + order.get(j) + "was not found"); } - b.append(pair.toSimpleString()+"("+keys[j]+")"); - b.append(" - ").append(names.get(keys[j])); + b.append(pair.toSimpleString() + "(" + order.get(j) + ")"); + b.append(" - ").append(names.get(order.get(j))); } b.append("]"); } diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryMapDataObject.java b/OsmAnd-java/src/net/osmand/binary/BinaryMapDataObject.java index 20c90394c0..283424710c 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryMapDataObject.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryMapDataObject.java @@ -1,5 +1,6 @@ package net.osmand.binary; +import gnu.trove.list.array.TIntArrayList; import gnu.trove.map.hash.TIntObjectHashMap; import net.osmand.binary.BinaryMapIndexReader.MapIndex; import net.osmand.render.RenderingRulesStorage; @@ -13,6 +14,7 @@ public class BinaryMapDataObject { protected int objectType = RenderingRulesStorage.POINT_RULES; protected TIntObjectHashMap objectNames = null; + protected TIntArrayList namesOrder = null; protected long id = 0; protected MapIndex mapIndex = null; @@ -53,8 +55,10 @@ public class BinaryMapDataObject { public void putObjectName(int type, String name){ if(objectNames == null){ objectNames = new TIntObjectHashMap(); + namesOrder = new TIntArrayList(); } objectNames.put(type, name); + namesOrder.add(type); } public int[][] getPolygonInnerCoordinates() { @@ -141,6 +145,10 @@ public class BinaryMapDataObject { return 0; } + public TIntArrayList getNamesOrder() { + return namesOrder; + } + public MapIndex getMapIndex() { return mapIndex; } diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryMapIndexReader.java b/OsmAnd-java/src/net/osmand/binary/BinaryMapIndexReader.java index 8f898b60de..a253661ce1 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryMapIndexReader.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryMapIndexReader.java @@ -1079,6 +1079,7 @@ public class BinaryMapIndexReader { List innercoordinates = null; TIntArrayList additionalTypes = null; TIntObjectHashMap stringNames = null; + TIntArrayList stringOrder = null; long id = 0; boolean loop = true; @@ -1141,12 +1142,14 @@ public class BinaryMapIndexReader { break; case OsmandOdb.MapData.STRINGNAMES_FIELD_NUMBER: stringNames = new TIntObjectHashMap(); + stringOrder = new TIntArrayList(); sizeL = codedIS.readRawVarint32(); old = codedIS.pushLimit(sizeL); while (codedIS.getBytesUntilLimit() > 0) { int stag = codedIS.readRawVarint32(); int pId = codedIS.readRawVarint32(); stringNames.put(stag, ((char)pId)+""); + stringOrder.add(stag); } codedIS.popLimit(old); break; @@ -1166,6 +1169,7 @@ public class BinaryMapIndexReader { dataObject.area = area; dataObject.coordinates = req.cacheCoordinates.toArray(); dataObject.objectNames = stringNames; + dataObject.namesOrder = stringOrder; if (innercoordinates == null) { dataObject.polygonInnerCoordinates = new int[0][0]; } else { diff --git a/OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java b/OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java index 8f026a4790..e29e09146c 100644 --- a/OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java +++ b/OsmAnd-java/src/net/osmand/osm/MapRenderingTypes.java @@ -75,8 +75,10 @@ public class MapRenderingTypes { types = new LinkedHashMap(); typeList.clear(); nameRuleType = MapRulType.createText("name"); + nameRuleType.order = 40; registerRuleType(nameRuleType); nameEnRuleType = MapRulType.createText("name:en"); + nameEnRuleType.order = 45; registerRuleType(nameEnRuleType); init(); }