Index strings in proper order

This commit is contained in:
Victor Shcherb 2014-06-26 01:14:30 +02:00
parent 065b50da13
commit 68cd88c36d
4 changed files with 26 additions and 11 deletions

View file

@ -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<String> 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<keys.length; j++){
if(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("]");
}

View file

@ -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<String> 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<String>();
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;
}

View file

@ -1079,6 +1079,7 @@ public class BinaryMapIndexReader {
List<TIntArrayList> innercoordinates = null;
TIntArrayList additionalTypes = null;
TIntObjectHashMap<String> 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<String>();
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 {

View file

@ -75,8 +75,10 @@ public class MapRenderingTypes {
types = new LinkedHashMap<String, MapRulType>();
typeList.clear();
nameRuleType = MapRulType.createText("name");
nameRuleType.order = 40;
registerRuleType(nameRuleType);
nameEnRuleType = MapRulType.createText("name:en");
nameEnRuleType.order = 45;
registerRuleType(nameEnRuleType);
init();
}