Index strings in proper order
This commit is contained in:
parent
065b50da13
commit
68cd88c36d
4 changed files with 26 additions and 11 deletions
|
@ -58,11 +58,11 @@ public class BinaryInspector {
|
||||||
if(args.length == 1 && "test".equals(args[0])) {
|
if(args.length == 1 && "test".equals(args[0])) {
|
||||||
in.inspector(new String[]{
|
in.inspector(new String[]{
|
||||||
//"-vpoi",
|
//"-vpoi",
|
||||||
// "-vmap", "-vmapobjects",
|
"-vmap", "-vmapobjects",
|
||||||
// "-vaddress", "-vcities", "-vstreets", "-vstreetgroups","-vbuildings",
|
// "-vaddress", "-vcities", "-vstreets", "-vstreetgroups","-vbuildings",
|
||||||
//"-zoom=16",
|
//"-zoom=16",
|
||||||
//"-bbox=4,55,7,50",
|
//"-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_b.obf___"
|
||||||
// "/home/victor/projects/osmand/osm-gen/World_basemap_2.obf__"
|
// "/home/victor/projects/osmand/osm-gen/World_basemap_2.obf__"
|
||||||
});
|
});
|
||||||
|
@ -652,19 +652,20 @@ public class BinaryInspector {
|
||||||
b.append("]");
|
b.append("]");
|
||||||
}
|
}
|
||||||
TIntObjectHashMap<String> names = obj.getObjectNames();
|
TIntObjectHashMap<String> names = obj.getObjectNames();
|
||||||
if(names != null && !names.isEmpty()) {
|
TIntArrayList order = obj.getNamesOrder();
|
||||||
|
if (names != null && !names.isEmpty()) {
|
||||||
b.append(" Names [");
|
b.append(" Names [");
|
||||||
int[] keys = names.keys();
|
// int[] keys = names.keys();
|
||||||
for(int j = 0; j<keys.length; j++){
|
for (int j = 0; j < order.size(); j++) {
|
||||||
if(j > 0) {
|
if (j > 0) {
|
||||||
b.append(", ");
|
b.append(", ");
|
||||||
}
|
}
|
||||||
TagValuePair pair = obj.getMapIndex().decodeType(keys[j]);
|
TagValuePair pair = obj.getMapIndex().decodeType(order.get(j));
|
||||||
if(pair == null) {
|
if (pair == null) {
|
||||||
throw new NullPointerException("Type " + keys[j] + "was not found");
|
throw new NullPointerException("Type " + order.get(j) + "was not found");
|
||||||
}
|
}
|
||||||
b.append(pair.toSimpleString()+"("+keys[j]+")");
|
b.append(pair.toSimpleString() + "(" + order.get(j) + ")");
|
||||||
b.append(" - ").append(names.get(keys[j]));
|
b.append(" - ").append(names.get(order.get(j)));
|
||||||
}
|
}
|
||||||
b.append("]");
|
b.append("]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.binary;
|
package net.osmand.binary;
|
||||||
|
|
||||||
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||||
import net.osmand.binary.BinaryMapIndexReader.MapIndex;
|
import net.osmand.binary.BinaryMapIndexReader.MapIndex;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
|
@ -13,6 +14,7 @@ public class BinaryMapDataObject {
|
||||||
protected int objectType = RenderingRulesStorage.POINT_RULES;
|
protected int objectType = RenderingRulesStorage.POINT_RULES;
|
||||||
|
|
||||||
protected TIntObjectHashMap<String> objectNames = null;
|
protected TIntObjectHashMap<String> objectNames = null;
|
||||||
|
protected TIntArrayList namesOrder = null;
|
||||||
protected long id = 0;
|
protected long id = 0;
|
||||||
|
|
||||||
protected MapIndex mapIndex = null;
|
protected MapIndex mapIndex = null;
|
||||||
|
@ -53,8 +55,10 @@ public class BinaryMapDataObject {
|
||||||
public void putObjectName(int type, String name){
|
public void putObjectName(int type, String name){
|
||||||
if(objectNames == null){
|
if(objectNames == null){
|
||||||
objectNames = new TIntObjectHashMap<String>();
|
objectNames = new TIntObjectHashMap<String>();
|
||||||
|
namesOrder = new TIntArrayList();
|
||||||
}
|
}
|
||||||
objectNames.put(type, name);
|
objectNames.put(type, name);
|
||||||
|
namesOrder.add(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[][] getPolygonInnerCoordinates() {
|
public int[][] getPolygonInnerCoordinates() {
|
||||||
|
@ -141,6 +145,10 @@ public class BinaryMapDataObject {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TIntArrayList getNamesOrder() {
|
||||||
|
return namesOrder;
|
||||||
|
}
|
||||||
|
|
||||||
public MapIndex getMapIndex() {
|
public MapIndex getMapIndex() {
|
||||||
return mapIndex;
|
return mapIndex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1079,6 +1079,7 @@ public class BinaryMapIndexReader {
|
||||||
List<TIntArrayList> innercoordinates = null;
|
List<TIntArrayList> innercoordinates = null;
|
||||||
TIntArrayList additionalTypes = null;
|
TIntArrayList additionalTypes = null;
|
||||||
TIntObjectHashMap<String> stringNames = null;
|
TIntObjectHashMap<String> stringNames = null;
|
||||||
|
TIntArrayList stringOrder = null;
|
||||||
long id = 0;
|
long id = 0;
|
||||||
|
|
||||||
boolean loop = true;
|
boolean loop = true;
|
||||||
|
@ -1141,12 +1142,14 @@ public class BinaryMapIndexReader {
|
||||||
break;
|
break;
|
||||||
case OsmandOdb.MapData.STRINGNAMES_FIELD_NUMBER:
|
case OsmandOdb.MapData.STRINGNAMES_FIELD_NUMBER:
|
||||||
stringNames = new TIntObjectHashMap<String>();
|
stringNames = new TIntObjectHashMap<String>();
|
||||||
|
stringOrder = new TIntArrayList();
|
||||||
sizeL = codedIS.readRawVarint32();
|
sizeL = codedIS.readRawVarint32();
|
||||||
old = codedIS.pushLimit(sizeL);
|
old = codedIS.pushLimit(sizeL);
|
||||||
while (codedIS.getBytesUntilLimit() > 0) {
|
while (codedIS.getBytesUntilLimit() > 0) {
|
||||||
int stag = codedIS.readRawVarint32();
|
int stag = codedIS.readRawVarint32();
|
||||||
int pId = codedIS.readRawVarint32();
|
int pId = codedIS.readRawVarint32();
|
||||||
stringNames.put(stag, ((char)pId)+"");
|
stringNames.put(stag, ((char)pId)+"");
|
||||||
|
stringOrder.add(stag);
|
||||||
}
|
}
|
||||||
codedIS.popLimit(old);
|
codedIS.popLimit(old);
|
||||||
break;
|
break;
|
||||||
|
@ -1166,6 +1169,7 @@ public class BinaryMapIndexReader {
|
||||||
dataObject.area = area;
|
dataObject.area = area;
|
||||||
dataObject.coordinates = req.cacheCoordinates.toArray();
|
dataObject.coordinates = req.cacheCoordinates.toArray();
|
||||||
dataObject.objectNames = stringNames;
|
dataObject.objectNames = stringNames;
|
||||||
|
dataObject.namesOrder = stringOrder;
|
||||||
if (innercoordinates == null) {
|
if (innercoordinates == null) {
|
||||||
dataObject.polygonInnerCoordinates = new int[0][0];
|
dataObject.polygonInnerCoordinates = new int[0][0];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -75,8 +75,10 @@ public class MapRenderingTypes {
|
||||||
types = new LinkedHashMap<String, MapRulType>();
|
types = new LinkedHashMap<String, MapRulType>();
|
||||||
typeList.clear();
|
typeList.clear();
|
||||||
nameRuleType = MapRulType.createText("name");
|
nameRuleType = MapRulType.createText("name");
|
||||||
|
nameRuleType.order = 40;
|
||||||
registerRuleType(nameRuleType);
|
registerRuleType(nameRuleType);
|
||||||
nameEnRuleType = MapRulType.createText("name:en");
|
nameEnRuleType = MapRulType.createText("name:en");
|
||||||
|
nameEnRuleType.order = 45;
|
||||||
registerRuleType(nameEnRuleType);
|
registerRuleType(nameEnRuleType);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue