From 8a2a0a2d0830950d30290934375d0c31387c26a9 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 18 Mar 2012 22:08:47 +0100 Subject: [PATCH] Fix map parser --- .../google/protobuf/CodedInputStreamRAF.java | 1 - .../src/net/osmand/ToDoConstants.java | 7 +- .../net/osmand/binary/BinaryInspector.java | 87 +- .../osmand/binary/BinaryMapDataObject.java | 40 +- .../osmand/binary/BinaryMapIndexReader.java | 485 +++++++---- .../src/net/osmand/binary/OsmandOdb.java | 806 ++++++------------ .../preparation/BinaryMapIndexWriter.java | 40 +- .../osmand/data/preparation/IndexCreator.java | 2 +- .../preparation/IndexVectorMapCreator.java | 67 +- .../impl/ConsoleProgressImplementation.java | 2 +- .../src/net/osmand/osm/MapRenderingTypes.java | 45 +- .../src/net/osmand/osm/rendering_types.xml | 2 +- DataExtractionOSM/src/osmand_odb.proto | 20 +- 13 files changed, 776 insertions(+), 828 deletions(-) diff --git a/DataExtractionOSM/src/com/google/protobuf/CodedInputStreamRAF.java b/DataExtractionOSM/src/com/google/protobuf/CodedInputStreamRAF.java index 5db9d48e2d..bd507b0a61 100644 --- a/DataExtractionOSM/src/com/google/protobuf/CodedInputStreamRAF.java +++ b/DataExtractionOSM/src/com/google/protobuf/CodedInputStreamRAF.java @@ -76,7 +76,6 @@ public final class CodedInputStreamRAF { lastTag = readRawVarint32(); if (WireFormat.getTagFieldNumber(lastTag) == 0) { - System.out.println(getTotalBytesRead()); // If we actually read zero (or any tag number corresponding to field // number zero), that's not a valid tag. throw InvalidProtocolBufferException.invalidTag(); diff --git a/DataExtractionOSM/src/net/osmand/ToDoConstants.java b/DataExtractionOSM/src/net/osmand/ToDoConstants.java index 84fe61bcb0..d18a09ddce 100644 --- a/DataExtractionOSM/src/net/osmand/ToDoConstants.java +++ b/DataExtractionOSM/src/net/osmand/ToDoConstants.java @@ -9,11 +9,14 @@ public class ToDoConstants { // Index + // Map QuadTree (skip small areas!!!) // POI index exclude building hno from categories!!! - // slightly changed POI (check it)! // Routing index - // Identify coastline areas and pure ocean areas + // Identify coastline areas and pure ocean areas !!! + + // Polish UI with new builiding style + // Test images in the map // TODO diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryInspector.java b/DataExtractionOSM/src/net/osmand/binary/BinaryInspector.java index b25b5673b9..09f984ce13 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryInspector.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryInspector.java @@ -2,6 +2,7 @@ package net.osmand.binary; import gnu.trove.list.array.TIntArrayList; +import gnu.trove.map.hash.TIntObjectHashMap; import java.io.File; import java.io.FileOutputStream; @@ -23,6 +24,7 @@ import net.osmand.binary.BinaryMapIndexReader.MapRoot; import net.osmand.binary.BinaryMapIndexReader.SearchFilter; import net.osmand.binary.BinaryMapIndexReader.SearchPoiTypeFilter; import net.osmand.binary.BinaryMapIndexReader.SearchRequest; +import net.osmand.binary.BinaryMapIndexReader.TagValuePair; import net.osmand.binary.BinaryMapPoiReaderAdapter.PoiRegion; import net.osmand.binary.BinaryMapTransportReaderAdapter.TransportIndex; import net.osmand.data.Amenity; @@ -31,7 +33,6 @@ import net.osmand.data.Building; import net.osmand.data.City; import net.osmand.data.MapObject; import net.osmand.data.Street; -import net.osmand.osm.MapRenderingTypes; import net.osmand.osm.MapUtils; import com.google.protobuf.CodedOutputStream; @@ -49,7 +50,7 @@ public class BinaryInspector { // inspector(new String[]{"-v","C:\\Users\\tpd\\osmand\\Housenumbers.obf"}); //inspector(new String[]{"/home/victor/projects/OsmAnd/data/osm-gen/saved/Belarus-newzooms-new-rt.obf"}); // inspector(new String[]{"/home/victor/projects/OsmAnd/download/spain/Spain_europe_1_small.obf"}); - inspector(new String[]{"-vpoi", "/home/victor/projects/OsmAnd/data/osm-gen/Luxembourg.obf"}); + inspector(new String[]{/*"-vmap", */"/home/victor/projects/OsmAnd/data/osm-gen/Luxembourg.obf"}); // test case extract parts @@ -386,18 +387,7 @@ public class BinaryInspector { } - private static void formatTags(BinaryMapDataObject o, StringBuilder b){ - for (int i = 0; i < o.getTypes().length; i++) { - if (i > 0) { - b.append(", "); - } - b.append(o.getTagValue(i).tag + "=" + o.getTagValue(i).value); - if ((o.getTypes()[i] & 3) == MapRenderingTypes.MULTY_POLYGON_TYPE) { - b.append("(multipolygon)"); - } - } - - } + public static void printFileInformation(File file, VerboseInfo verbose) throws IOException { RandomAccessFile r = new RandomAccessFile(file.getAbsolutePath(), "r"); @@ -507,19 +497,66 @@ public class BinaryInspector { }, new ResultMatcher() { @Override - public boolean publish(BinaryMapDataObject object) { - boolean way = object.getPointsLength() > 1; + public boolean publish(BinaryMapDataObject obj) { b.setLength(0); - b.append(way ? "Way " : "Point "); - if(object.getName() != null){ - b.append(object.getName()); + boolean multipolygon = obj.getPolygonInnerCoordinates() != null && obj.getPolygonInnerCoordinates().length > 0; + if(multipolygon ) { + b.append("Multipolygon"); + } else { + b.append(obj.area? "Area" : (obj.getPointsLength() > 1? "Way" : "Point")); } - b.append(" ").append((object.getId() >> 1)).append(" "); - formatTags(object, b); - b.append(" "); - for (int i = 0; i < object.getPointsLength(); i++) { - b.append(" "); - formatPoint(object, i, b); + int[] types = obj.getTypes(); + b.append(" types ["); + for(int j = 0; j 0) { + b.append(", "); + } + TagValuePair pair = obj.getMapIndex().decodeType(types[j]); + if(pair == null) { + throw new NullPointerException("Type " + types[j] + "was not found"); + } + b.append(pair.toSimpleString()+"("+types[j]+")"); + } + b.append("]"); + if(obj.getAdditionalTypes() != null){ + b.append(" add_types ["); + for(int j = 0; j 0) { + b.append(", "); + } + TagValuePair pair = obj.getMapIndex().decodeType(obj.getAdditionalTypes()[j]); + if(pair == null) { + throw new NullPointerException("Type " + obj.getAdditionalTypes()[j] + "was not found"); + } + b.append(pair.toSimpleString()+"("+obj.getAdditionalTypes()[j]+")"); + + } + b.append("]"); + } + TIntObjectHashMap names = obj.getObjectNames(); + if(names != null && !names.isEmpty()) { + b.append(" Names ["); + int[] keys = names.keys(); + for(int j = 0; j 0) { + b.append(", "); + } + TagValuePair pair = obj.getMapIndex().decodeType(keys[j]); + if(pair == null) { + throw new NullPointerException("Type " + keys[j] + "was not found"); + } + b.append(pair.toSimpleString()+"("+keys[j]+")"); + b.append(" - ").append(names.get(keys[j])); + } + b.append("]"); + } + + b.append(" id ").append((obj.getId() >> 1)); + b.append(" lat/lon : "); + for(int i=0; i objectNames = null; protected long id = 0; - protected String name; - protected MapIndex mapIndex = null; public BinaryMapDataObject(){ } - protected void setStringId(int stringId) { - this.stringId = stringId; - } - - protected void setCoordinates(int[] coordinates) { this.coordinates = coordinates; } - protected int getStringId() { - return stringId; + public String getName(){ + if(objectNames == null){ + return null; + } + return objectNames.get(mapIndex.nameEncodingType); } - public void setName(String name) { - this.name = name; + public TIntObjectHashMap getObjectNames() { + return objectNames; } - public String getName() { - return name; + public int[][] getPolygonInnerCoordinates() { + return polygonInnerCoordinates; } public int[] getTypes(){ return types; } + public int[] getAdditionalTypes() { + return additionalTypes; + } + + public boolean isArea() { + return area; + } + + public void setArea(boolean area) { + this.area = area; + } + public TagValuePair getTagValue(int indType){ if(mapIndex == null){ return null; diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java index 2c72d13ab3..d03a8b6be6 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java @@ -1,7 +1,6 @@ package net.osmand.binary; import gnu.trove.list.array.TIntArrayList; -import gnu.trove.list.array.TLongArrayList; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; @@ -24,13 +23,12 @@ import net.osmand.Algoritms; import net.osmand.CollatorStringMatcher; import net.osmand.LogUtil; import net.osmand.ResultMatcher; -import net.osmand.StringMatcher; import net.osmand.CollatorStringMatcher.StringMatcherMode; import net.osmand.binary.BinaryMapAddressReaderAdapter.AddressRegion; import net.osmand.binary.BinaryMapAddressReaderAdapter.CitiesBlock; -import net.osmand.binary.BinaryMapIndexReader.SearchRequest; import net.osmand.binary.BinaryMapPoiReaderAdapter.PoiRegion; import net.osmand.binary.BinaryMapTransportReaderAdapter.TransportIndex; +import net.osmand.binary.OsmandOdb.MapDataBlock; import net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBox; import net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapEncodingRule; import net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapRootLevel; @@ -43,8 +41,6 @@ import net.osmand.data.Street; import net.osmand.data.TransportRoute; import net.osmand.data.TransportStop; import net.osmand.osm.LatLon; -import net.osmand.osm.MapRenderingTypes; -import net.osmand.osm.MapRenderingTypes.MapRulType; import net.osmand.osm.MapUtils; import org.apache.commons.logging.Log; @@ -524,9 +520,11 @@ public class BinaryMapIndexReader { */ private void readMapIndex(MapIndex index) throws IOException { + int defaultId = 1; while(true){ int t = codedIS.readTag(); int tag = WireFormat.getTagFieldNumber(t); + switch (tag) { case 0: // encoding rules are required! @@ -540,7 +538,7 @@ public class BinaryMapIndexReader { case OsmandOdb.OsmAndMapIndex.RULES_FIELD_NUMBER : int len = codedIS.readInt32(); int oldLimit = codedIS.pushLimit(len); - readMapEncodingRule(index); + readMapEncodingRule(index, defaultId++); codedIS.popLimit(oldLimit); break; case OsmandOdb.OsmAndMapIndex.LEVELS_FIELD_NUMBER : @@ -566,16 +564,18 @@ public class BinaryMapIndexReader { index.encodingRules.put(tag, new LinkedHashMap()); } index.encodingRules.get(tag).put(val, id); + if("name".equals(tag)){ + index.nameEncodingType = id; + } if(!index.decodingRules.containsKey(id)){ - index.decodingRules.put(id, new TagValuePair(tag, val)); + index.decodingRules.put(id, new TagValuePair(tag, val, type)); } } - private void readMapEncodingRule(MapIndex index) throws IOException { + private void readMapEncodingRule(MapIndex index, int id) throws IOException { int type = 0; String tags = null; String val = null; - int id = 0; while(true){ int t = codedIS.readTag(); int tag = WireFormat.getTagFieldNumber(t); @@ -691,6 +691,7 @@ public class BinaryMapIndexReader { req.numberOfAcceptedObjects = 0; req.numberOfAcceptedSubtrees = 0; req.numberOfReadSubtrees = 0; + List foundSubtrees = new ArrayList(); for (MapIndex mapIndex : mapIndexes) { for (MapRoot index : mapIndex.getRoots()) { if (index.minZoom <= req.zoom && index.maxZoom >= req.zoom) { @@ -712,12 +713,31 @@ public class BinaryMapIndexReader { } codedIS.seek(tree.filePointer); int oldLimit = codedIS.pushLimit(tree.length); - searchMapTreeBounds(index.left, index.right, index.top, index.bottom, req, mapIndex); + searchMapTreeBounds(tree, index, req, foundSubtrees); codedIS.popLimit(oldLimit); } + + Collections.sort(foundSubtrees, new Comparator() { + @Override + public int compare(MapTree o1, MapTree o2) { + return o1.mapDataBlock < o2.mapDataBlock ? -1 : (o1.mapDataBlock == o2.mapDataBlock ? 0 : 1); + } + }); + for(MapTree tree : foundSubtrees) { + if(!req.isCancelled()){ + codedIS.seek(tree.mapDataBlock); + int length = codedIS.readRawVarint32(); + int oldLimit = codedIS.pushLimit(length); + readMapDataBlocks(req, tree, mapIndex); + codedIS.popLimit(oldLimit); + } + } + foundSubtrees.clear(); } + } } + log.info("Search is done. Visit " + req.numberOfVisitedObjects + " objects. Read " + req.numberOfAcceptedObjects + " objects."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ log.info("Read " + req.numberOfReadSubtrees + " subtrees. Go through " + req.numberOfAcceptedSubtrees + " subtrees."); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ return req.getSearchResults(); @@ -725,17 +745,78 @@ public class BinaryMapIndexReader { - - protected void searchMapTreeBounds(int pleft, int pright, int ptop, int pbottom, - SearchRequest req, MapIndex root) throws IOException { - int init = 0; - int lastIndexResult = -1; - int cright = 0; - int cleft = 0; - int ctop = 0; - int cbottom = 0; - req.numberOfReadSubtrees++; + protected void readMapDataBlocks(SearchRequest req, MapTree tree, MapIndex root) throws IOException { List tempResults = null; + long baseId = 0; + while (true) { + if (req.isCancelled()) { + return; + } + int t = codedIS.readTag(); + int tag = WireFormat.getTagFieldNumber(t); + switch (tag) { + case 0: + if(tempResults != null) { + for(BinaryMapDataObject obj : tempResults) { + req.publish(obj); + } + } + return; + case MapDataBlock.BASEID_FIELD_NUMBER: + baseId = codedIS.readUInt64(); + break; +// case MapDataBlock.RASTERTYPE_FIELD_NUMBER: +// // not used now +// codedIS.readUInt32(); +// break; +// case MapDataBlock.RASTERIMAGE_FIELD_NUMBER: +// // not used now +// codedIS.readBytes(); +// break; + case MapDataBlock.DATAOBJECTS_FIELD_NUMBER: + int length = codedIS.readRawVarint32(); + int oldLimit = codedIS.pushLimit(length); + BinaryMapDataObject mapObject = readMapDataObject(tree, req, root); + if (mapObject != null) { + mapObject.setId(mapObject.getId() + baseId); + if (tempResults == null) { + tempResults = new ArrayList(); + } + tempResults.add(mapObject); + } + codedIS.popLimit(oldLimit); + break; + case MapDataBlock.STRINGTABLE_FIELD_NUMBER: + length = codedIS.readRawVarint32(); + oldLimit = codedIS.pushLimit(length); + if (tempResults != null) { + List stringTable = readStringTable(); + for (int i = 0; i < tempResults.size(); i++) { + BinaryMapDataObject rs = tempResults.get(i); + if (rs.objectNames != null) { + int[] keys = rs.objectNames.keys(); + for (int j = 0; j < keys.length; j++) { + rs.objectNames.put(keys[j], stringTable.get(rs.objectNames.get(keys[j]).charAt(0))); + } + } + } + } else { + codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); + } + codedIS.popLimit(oldLimit); + break; + default: + skipUnknownField(t); + break; + } + } + + } + + protected void searchMapTreeBounds(MapTree current, MapTree parent, + SearchRequest req, List foundSubtrees) throws IOException { + int init = 0; + req.numberOfReadSubtrees++; while(true){ if(req.isCancelled()){ return; @@ -745,7 +826,7 @@ public class BinaryMapIndexReader { if(init == 0xf){ init = 0; // coordinates are init - if(cright < req.left || cleft > req.right || ctop > req.bottom || cbottom < req.top){ + if(current.right < req.left || current.left > req.right || current.top > req.bottom || current.bottom < req.top){ return; } else { req.numberOfAcceptedSubtrees++; @@ -753,85 +834,43 @@ public class BinaryMapIndexReader { } switch (tag) { case 0: - if (tempResults != null) { - for (int i = 0; i < tempResults.size(); i++) { - req.publish(tempResults.get(i)); - } - } return; case MapDataBox.BOTTOM_FIELD_NUMBER : - cbottom = codedIS.readSInt32() + pbottom; + current.bottom = codedIS.readSInt32() + parent.bottom; init |= 1; break; case MapDataBox.LEFT_FIELD_NUMBER : - cleft = codedIS.readSInt32() + pleft; + current.left = codedIS.readSInt32() + parent.left; init |= 2; break; case MapDataBox.RIGHT_FIELD_NUMBER : - cright = codedIS.readSInt32() + pright; + current.right = codedIS.readSInt32() + parent.right; init |= 4; break; case MapDataBox.TOP_FIELD_NUMBER : - ctop = codedIS.readSInt32() + ptop; + current.top = codedIS.readSInt32() + parent.top; init |= 8; break; - case MapDataBox.LEAFS_FIELD_NUMBER : - int length = codedIS.readRawVarint32(); - int oldLimit = codedIS.pushLimit(length); - if(lastIndexResult == -1){ - lastIndexResult = req.searchResults.size(); - } - BinaryMapDataObject mapObject = readMapDataObject(cleft, cright, ctop, cbottom, req, root); - if(mapObject != null){ - if(tempResults == null){ - tempResults = new ArrayList(); - } - tempResults.add(mapObject); - } - codedIS.popLimit(oldLimit); + case MapDataBox.SHIFTTOMAPDATA_FIELD_NUMBER : + req.numberOfAcceptedSubtrees ++; + current.mapDataBlock = readInt() + current.filePointer; + foundSubtrees.add(current); + break; + case MapDataBox.OCEAN_FIELD_NUMBER : + current.ocean = codedIS.readBool(); break; case MapDataBox.BOXES_FIELD_NUMBER : - // left, ... already initialized - length = readInt(); - int filePointer = codedIS.getTotalBytesRead(); - oldLimit = codedIS.pushLimit(length); - searchMapTreeBounds(cleft, cright, ctop, cbottom, req, root); + // left, ... already initialized + MapTree child = new MapTree(); + child.length = readInt(); + child.filePointer = codedIS.getTotalBytesRead(); + int oldLimit = codedIS.pushLimit(child.length); + if(current.ocean){ + child.ocean = true; + } + searchMapTreeBounds(child, current, req, foundSubtrees); codedIS.popLimit(oldLimit); - codedIS.seek(filePointer + length); - if(lastIndexResult >= 0){ - throw new IllegalStateException(); - } - break; - case OsmandOdb.MapTree.BASEID_FIELD_NUMBER : - case OsmandOdb.MapTree.OLDBASEID_FIELD_NUMBER : - long baseId = codedIS.readUInt64(); - if (tempResults != null) { - for (int i = 0; i < tempResults.size(); i++) { - BinaryMapDataObject rs = tempResults.get(i); - rs.id += baseId; - if (rs.restrictions != null) { - for (int j = 0; j < rs.restrictions.length; j++) { - rs.restrictions[j] += baseId; - } - } - } - } - break; - case OsmandOdb.MapTree.STRINGTABLE_FIELD_NUMBER : - case OsmandOdb.MapTree.OLDSTRINGTABLE_FIELD_NUMBER : - length = codedIS.readRawVarint32(); - oldLimit = codedIS.pushLimit(length); - List stringTable = readStringTable(); - codedIS.popLimit(oldLimit); - - if (tempResults != null) { - for (int i = 0; i < tempResults.size(); i++) { - BinaryMapDataObject rs = tempResults.get(i); - if (rs.stringId != -1) { - rs.name = stringTable.get(rs.stringId); - } - } - } + codedIS.seek(child.filePointer + child.length); break; default: skipUnknownField(t); @@ -841,17 +880,18 @@ public class BinaryMapIndexReader { } private int MASK_TO_READ = ~((1 << SHIFT_COORDINATES) - 1); - private BinaryMapDataObject readMapDataObject(int left, int right, int top, int bottom, SearchRequest req, + private BinaryMapDataObject readMapDataObject(MapTree tree , SearchRequest req, MapIndex root) throws IOException { int tag = WireFormat.getTagFieldNumber(codedIS.readTag()); - if(OsmandOdb.MapData.COORDINATES_FIELD_NUMBER != tag) { + boolean area = OsmandOdb.MapData.AREACOORDINATES_FIELD_NUMBER == tag; + if(!area && OsmandOdb.MapData.COORDINATES_FIELD_NUMBER != tag) { throw new IllegalArgumentException(); } req.cacheCoordinates.clear(); int size = codedIS.readRawVarint32(); int old = codedIS.pushLimit(size); - int px = left & MASK_TO_READ; - int py = top & MASK_TO_READ; + int px = tree.left & MASK_TO_READ; + int py = tree.top & MASK_TO_READ; boolean contains = false; int minX = Integer.MAX_VALUE; int maxX = 0; @@ -887,53 +927,108 @@ public class BinaryMapIndexReader { return null; } - // READ types - tag = WireFormat.getTagFieldNumber(codedIS.readTag()); - if(OsmandOdb.MapData.TYPES_FIELD_NUMBER != tag) { - throw new IllegalArgumentException(); - } - req.cacheTypes.clear(); - int sizeL = codedIS.readRawVarint32(); - byte[] types = codedIS.readRawBytes(sizeL); - for(int i=0; i innercoordinates = null; + TIntArrayList additionalTypes = null; + TIntObjectHashMap stringNames = null; + long id = 0; - - if(!accept){ - codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); - return null; - } - - req.numberOfAcceptedObjects++; - - BinaryMapDataObject dataObject = new BinaryMapDataObject(); - dataObject.coordinates = req.cacheCoordinates.toArray(); - dataObject.types = req.cacheTypes.toArray(); - dataObject.mapIndex = root; - - while(true){ + boolean loop = true; + while (loop) { int t = codedIS.readTag(); tag = WireFormat.getTagFieldNumber(t); switch (tag) { case 0: - return dataObject; - case OsmandOdb.MapData.ID_FIELD_NUMBER : - dataObject.id = codedIS.readSInt64(); + loop = false; break; - case OsmandOdb.MapData.STRINGID_FIELD_NUMBER : - dataObject.stringId = codedIS.readUInt32(); + case OsmandOdb.MapData.POLYGONINNERCOORDINATES_FIELD_NUMBER: + if (innercoordinates == null) { + innercoordinates = new ArrayList(); + } + TIntArrayList polygon = new TIntArrayList(); + innercoordinates.add(polygon); + px = tree.left & MASK_TO_READ; + py = tree.top & MASK_TO_READ; + size = codedIS.readRawVarint32(); + old = codedIS.pushLimit(size); + while (codedIS.getBytesUntilLimit() > 0) { + int x = (codedIS.readSInt32() << SHIFT_COORDINATES) + px; + int y = (codedIS.readSInt32() << SHIFT_COORDINATES) + py; + polygon.add(x); + polygon.add(y); + px = x; + py = y; + } + codedIS.popLimit(old); + break; + case OsmandOdb.MapData.ADDITIONALTYPES_FIELD_NUMBER: + additionalTypes = new TIntArrayList(); + int sizeL = codedIS.readRawVarint32(); + old = codedIS.pushLimit(sizeL); + while (codedIS.getBytesUntilLimit() > 0) { + additionalTypes.add(codedIS.readRawVarint32()); + } + codedIS.popLimit(old); + break; + case OsmandOdb.MapData.TYPES_FIELD_NUMBER: + req.cacheTypes.clear(); + sizeL = codedIS.readRawVarint32(); + old = codedIS.pushLimit(sizeL); + while (codedIS.getBytesUntilLimit() > 0) { + req.cacheTypes.add(codedIS.readRawVarint32()); + } + codedIS.popLimit(old); + boolean accept = true; + if (req.searchFilter != null) { + accept = req.searchFilter.accept(req.cacheTypes, root); + } + if (!accept) { + codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); + return null; + } + req.numberOfAcceptedObjects++; + break; + case OsmandOdb.MapData.ID_FIELD_NUMBER: + id = codedIS.readSInt64(); + break; + case OsmandOdb.MapData.STRINGNAMES_FIELD_NUMBER: + stringNames = new TIntObjectHashMap(); + sizeL = codedIS.readRawVarint32(); + old = codedIS.pushLimit(sizeL); + while (codedIS.getBytesUntilLimit() > 0) { + int stag = codedIS.readRawVarint32(); + int pId = codedIS.readRawVarint32(); + stringNames.put(stag, ((char)pId)+""); + } + codedIS.popLimit(old); break; default: skipUnknownField(t); break; } } + BinaryMapDataObject dataObject = new BinaryMapDataObject(); + dataObject.area = area; + dataObject.coordinates = req.cacheCoordinates.toArray(); + dataObject.objectNames = stringNames; + if (innercoordinates == null) { + dataObject.polygonInnerCoordinates = new int[0][0]; + } else { + dataObject.polygonInnerCoordinates = new int[innercoordinates.size()][]; + for (int i = 0; i < innercoordinates.size(); i++) { + dataObject.polygonInnerCoordinates[i] = innercoordinates.get(i).toArray(); + } + } + dataObject.types = req.cacheTypes.toArray(); + if (additionalTypes != null) { + dataObject.additionalTypes = additionalTypes.toArray(); + } else { + dataObject.additionalTypes = new int[0]; + } + dataObject.id = id; + dataObject.mapIndex = root; + return dataObject; } public List searchAddressDataByName(SearchRequest req) throws IOException { @@ -1217,15 +1312,17 @@ public class BinaryMapIndexReader { public static class MapIndex extends BinaryIndexPart { List roots = new ArrayList(); + Map> encodingRules = new LinkedHashMap>(); TIntObjectMap decodingRules = new TIntObjectHashMap(); + int nameEncodingType = 0; public List getRoots() { return roots; } - public TagValuePair decodeType(int type, int subtype){ - return decodingRules.get(((subtype << 5) | type)); + public TagValuePair decodeType(int type){ + return decodingRules.get(type); } } @@ -1234,11 +1331,7 @@ public class BinaryMapIndexReader { public String tag; public String value; public int additionalAttribute; - public TagValuePair(String tag, String value) { - super(); - this.tag = tag; - this.value = value; - } + public TagValuePair(String tag, String value, int additionalAttribute) { super(); @@ -1246,6 +1339,10 @@ public class BinaryMapIndexReader { this.value = value; this.additionalAttribute = additionalAttribute; } + + public boolean isAdditional(){ + return additionalAttribute % 2 == 1; + } @Override public int hashCode() { @@ -1257,6 +1354,13 @@ public class BinaryMapIndexReader { return result; } + public String toSimpleString(){ + if(value == null){ + return tag; + } + return tag+"-"+value; + } + @Override public String toString() { return "TagValuePair : " + tag + " - " + value; @@ -1289,22 +1393,33 @@ public class BinaryMapIndexReader { } - public static class MapRoot extends BinaryIndexPart { + public static class MapRoot extends MapTree { int minZoom = 0; int maxZoom = 0; - int left = 0; - int right = 0; - int top = 0; - int bottom = 0; + public int getMinZoom() { return minZoom; } - public int getMaxZoom() { return maxZoom; } + private List trees = null; + } + + private static class MapTree { + int filePointer = 0; + int length = 0; + + long mapDataBlock = 0; + boolean ocean = false; + + int left = 0; + int right = 0; + int top = 0; + int bottom = 0; + public int getLeft() { return left; } @@ -1318,31 +1433,25 @@ public class BinaryMapIndexReader { return bottom; } - private List trees = null; - } - - private static class MapTree { - int filePointer = 0; - int length = 0; - - long mapDataBlock = 0; - - int left = 0; - int right = 0; - int top = 0; - int bottom = 0; + public int getLength() { + return length; + } + public int getFilePointer() { + return filePointer; + } } - private static boolean testMapSearch = false; + private static boolean testMapSearch = true; private static boolean testAddressSearch = false; private static boolean testPoiSearch = false; private static boolean testTransportSearch = false; private static int sleft = MapUtils.get31TileNumberX(6.3); - private static int sright = MapUtils.get31TileNumberX(6.5); - private static int stop = MapUtils.get31TileNumberY(49.8); - private static int sbottom = MapUtils.get31TileNumberY(49.3); + private static int sright = MapUtils.get31TileNumberX(6.4); + private static int stop = MapUtils.get31TileNumberY(49.5); + private static int sbottom = MapUtils.get31TileNumberY(49.4); + private static int szoom = 15; private static void println(String s){ System.out.println(s); @@ -1567,11 +1676,75 @@ public class BinaryMapIndexReader { println(reader.mapIndexes.get(0).encodingRules + ""); println("SEARCH " + sleft + " " + sright + " " + stop + " " + sbottom); - for (BinaryMapDataObject obj : reader.searchMapIndex(buildSearchRequest(sleft, sright, stop, sbottom, 8, null))) { - if (obj.getName() != null) { - println(" " + obj.getName()); + reader.searchMapIndex(buildSearchRequest(sleft, sright, stop, sbottom, szoom, null, new ResultMatcher() { + + @Override + public boolean publish(BinaryMapDataObject obj) { + + StringBuilder b = new StringBuilder(); + b.append(obj.area? "Area" : (obj.getPointsLength() > 1? "Way" : "Point")); + int[] types = obj.getTypes(); + b.append(" types ["); + for(int j = 0; j 0) { + b.append(", "); + } + TagValuePair pair = obj.getMapIndex().decodeType(types[j]); + if(pair == null) { + throw new NullPointerException("Type " + types[j] + "was not found"); + } + b.append(pair.toSimpleString()+"("+types[j]+")"); + } + b.append("]"); + if(obj.getAdditionalTypes() != null){ + b.append(" add_types ["); + for(int j = 0; j 0) { + b.append(", "); + } + TagValuePair pair = obj.getMapIndex().decodeType(obj.getAdditionalTypes()[j]); + if(pair == null) { + throw new NullPointerException("Type " + obj.getAdditionalTypes()[j] + "was not found"); + } + b.append(pair.toSimpleString()+"("+obj.getAdditionalTypes()[j]+")"); + + } + b.append("]"); + } + TIntObjectHashMap names = obj.getObjectNames(); + if(names != null && !names.isEmpty()) { + b.append(" Names ["); + int[] keys = names.keys(); + for(int j = 0; j 0) { + b.append(", "); + } + TagValuePair pair = obj.getMapIndex().decodeType(keys[j]); + if(pair == null) { + throw new NullPointerException("Type " + keys[j] + "was not found"); + } + b.append(pair.toSimpleString()+"("+keys[j]+")"); + b.append(" - ").append(names.get(keys[j])); + } + b.append("]"); + } + + b.append(" id ").append((obj.getId() >> 1)); + b.append(" lat/lon : "); + for(int i=0; i blocks_ = + // repeated .MapDataBlock blocks = 15; + public static final int BLOCKS_FIELD_NUMBER = 15; + private java.util.List blocks_ = java.util.Collections.emptyList(); - public java.util.List getBlocksList() { + public java.util.List getBlocksList() { return blocks_; } public int getBlocksCount() { return blocks_.size(); } - public net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks getBlocks(int index) { + public net.osmand.binary.OsmandOdb.MapDataBlock getBlocks(int index) { return blocks_.get(index); } @@ -2655,7 +2655,7 @@ public final class OsmandOdb { for (net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBox element : getBoxesList()) { if (!element.isInitialized()) return false; } - for (net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks element : getBlocksList()) { + for (net.osmand.binary.OsmandOdb.MapDataBlock element : getBlocksList()) { if (!element.isInitialized()) return false; } return true; @@ -2686,8 +2686,8 @@ public final class OsmandOdb { for (net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBox element : getBoxesList()) { output.writeMessage(7, element); } - for (net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks element : getBlocksList()) { - output.writeMessage(8, element); + for (net.osmand.binary.OsmandOdb.MapDataBlock element : getBlocksList()) { + output.writeMessage(15, element); } getUnknownFields().writeTo(output); } @@ -2727,9 +2727,9 @@ public final class OsmandOdb { size += com.google.protobuf.CodedOutputStream .computeMessageSize(7, element); } - for (net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks element : getBlocksList()) { + for (net.osmand.binary.OsmandOdb.MapDataBlock element : getBlocksList()) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(8, element); + .computeMessageSize(15, element); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -2934,7 +2934,7 @@ public final class OsmandOdb { } if (!other.blocks_.isEmpty()) { if (result.blocks_.isEmpty()) { - result.blocks_ = new java.util.ArrayList(); + result.blocks_ = new java.util.ArrayList(); } result.blocks_.addAll(other.blocks_); } @@ -2994,8 +2994,8 @@ public final class OsmandOdb { addBoxes(subBuilder.buildPartial()); break; } - case 66: { - net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks.Builder subBuilder = net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks.newBuilder(); + case 122: { + net.osmand.binary.OsmandOdb.MapDataBlock.Builder subBuilder = net.osmand.binary.OsmandOdb.MapDataBlock.newBuilder(); input.readMessage(subBuilder, extensionRegistry); addBlocks(subBuilder.buildPartial()); break; @@ -3164,48 +3164,48 @@ public final class OsmandOdb { return this; } - // repeated .OsmAndMapIndex.MapDataBlocks blocks = 8; - public java.util.List getBlocksList() { + // repeated .MapDataBlock blocks = 15; + public java.util.List getBlocksList() { return java.util.Collections.unmodifiableList(result.blocks_); } public int getBlocksCount() { return result.getBlocksCount(); } - public net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks getBlocks(int index) { + public net.osmand.binary.OsmandOdb.MapDataBlock getBlocks(int index) { return result.getBlocks(index); } - public Builder setBlocks(int index, net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks value) { + public Builder setBlocks(int index, net.osmand.binary.OsmandOdb.MapDataBlock value) { if (value == null) { throw new NullPointerException(); } result.blocks_.set(index, value); return this; } - public Builder setBlocks(int index, net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks.Builder builderForValue) { + public Builder setBlocks(int index, net.osmand.binary.OsmandOdb.MapDataBlock.Builder builderForValue) { result.blocks_.set(index, builderForValue.build()); return this; } - public Builder addBlocks(net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks value) { + public Builder addBlocks(net.osmand.binary.OsmandOdb.MapDataBlock value) { if (value == null) { throw new NullPointerException(); } if (result.blocks_.isEmpty()) { - result.blocks_ = new java.util.ArrayList(); + result.blocks_ = new java.util.ArrayList(); } result.blocks_.add(value); return this; } - public Builder addBlocks(net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks.Builder builderForValue) { + public Builder addBlocks(net.osmand.binary.OsmandOdb.MapDataBlock.Builder builderForValue) { if (result.blocks_.isEmpty()) { - result.blocks_ = new java.util.ArrayList(); + result.blocks_ = new java.util.ArrayList(); } result.blocks_.add(builderForValue.build()); return this; } public Builder addAllBlocks( - java.lang.Iterable values) { + java.lang.Iterable values) { if (result.blocks_.isEmpty()) { - result.blocks_ = new java.util.ArrayList(); + result.blocks_ = new java.util.ArrayList(); } super.addAll(values, result.blocks_); return this; @@ -3227,357 +3227,6 @@ public final class OsmandOdb { // @@protoc_insertion_point(class_scope:OsmAndMapIndex.MapRootLevel) } - public static final class MapDataBlocks extends - com.google.protobuf.GeneratedMessage { - // Use MapDataBlocks.newBuilder() to construct. - private MapDataBlocks() { - initFields(); - } - private MapDataBlocks(boolean noInit) {} - - private static final MapDataBlocks defaultInstance; - public static MapDataBlocks getDefaultInstance() { - return defaultInstance; - } - - @Override - public MapDataBlocks getDefaultInstanceForType() { - return defaultInstance; - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return net.osmand.binary.OsmandOdb.internal_static_OsmAndMapIndex_MapDataBlocks_descriptor; - } - - @Override - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return net.osmand.binary.OsmandOdb.internal_static_OsmAndMapIndex_MapDataBlocks_fieldAccessorTable; - } - - // repeated .MapDataBlock block = 6; - public static final int BLOCK_FIELD_NUMBER = 6; - private java.util.List block_ = - java.util.Collections.emptyList(); - public java.util.List getBlockList() { - return block_; - } - public int getBlockCount() { return block_.size(); } - public net.osmand.binary.OsmandOdb.MapDataBlock getBlock(int index) { - return block_.get(index); - } - - private void initFields() { - } - @Override - public final boolean isInitialized() { - for (net.osmand.binary.OsmandOdb.MapDataBlock element : getBlockList()) { - if (!element.isInitialized()) return false; - } - return true; - } - - @Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - for (net.osmand.binary.OsmandOdb.MapDataBlock element : getBlockList()) { - output.writeMessage(6, element); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - @Override - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - for (net.osmand.binary.OsmandOdb.MapDataBlock element : getBlockList()) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(6, element); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - public static net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks parseFrom(java.io.InputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - public static net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input, extensionRegistry)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - - public static Builder newBuilder() { return Builder.create(); } - @Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks prototype) { - return newBuilder().mergeFrom(prototype); - } - @Override - public Builder toBuilder() { return newBuilder(this); } - - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { - private net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks result; - - // Construct using net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks.newBuilder() - private Builder() {} - - private static Builder create() { - Builder builder = new Builder(); - builder.result = new net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks(); - return builder; - } - - @Override - protected net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks internalGetResult() { - return result; - } - - @Override - public Builder clear() { - if (result == null) { - throw new IllegalStateException( - "Cannot call clear() after build()."); - } - result = new net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks(); - return this; - } - - @Override - public Builder clone() { - return create().mergeFrom(result); - } - - @Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks.getDescriptor(); - } - - @Override - public net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks getDefaultInstanceForType() { - return net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks.getDefaultInstance(); - } - - @Override - public boolean isInitialized() { - return result.isInitialized(); - } - @Override - public net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks build() { - if (result != null && !isInitialized()) { - throw newUninitializedMessageException(result); - } - return buildPartial(); - } - - private net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks buildParsed() - throws com.google.protobuf.InvalidProtocolBufferException { - if (!isInitialized()) { - throw newUninitializedMessageException( - result).asInvalidProtocolBufferException(); - } - return buildPartial(); - } - - @Override - public net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks buildPartial() { - if (result == null) { - throw new IllegalStateException( - "build() has already been called on this Builder."); - } - if (result.block_ != java.util.Collections.EMPTY_LIST) { - result.block_ = - java.util.Collections.unmodifiableList(result.block_); - } - net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks returnMe = result; - result = null; - return returnMe; - } - - @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks) { - return mergeFrom((net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks other) { - if (other == net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks.getDefaultInstance()) return this; - if (!other.block_.isEmpty()) { - if (result.block_.isEmpty()) { - result.block_ = new java.util.ArrayList(); - } - result.block_.addAll(other.block_); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - @Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder( - this.getUnknownFields()); - while (true) { - int tag = input.readTag(); - switch (tag) { - case 0: - this.setUnknownFields(unknownFields.build()); - return this; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - this.setUnknownFields(unknownFields.build()); - return this; - } - break; - } - case 50: { - net.osmand.binary.OsmandOdb.MapDataBlock.Builder subBuilder = net.osmand.binary.OsmandOdb.MapDataBlock.newBuilder(); - input.readMessage(subBuilder, extensionRegistry); - addBlock(subBuilder.buildPartial()); - break; - } - } - } - } - - - // repeated .MapDataBlock block = 6; - public java.util.List getBlockList() { - return java.util.Collections.unmodifiableList(result.block_); - } - public int getBlockCount() { - return result.getBlockCount(); - } - public net.osmand.binary.OsmandOdb.MapDataBlock getBlock(int index) { - return result.getBlock(index); - } - public Builder setBlock(int index, net.osmand.binary.OsmandOdb.MapDataBlock value) { - if (value == null) { - throw new NullPointerException(); - } - result.block_.set(index, value); - return this; - } - public Builder setBlock(int index, net.osmand.binary.OsmandOdb.MapDataBlock.Builder builderForValue) { - result.block_.set(index, builderForValue.build()); - return this; - } - public Builder addBlock(net.osmand.binary.OsmandOdb.MapDataBlock value) { - if (value == null) { - throw new NullPointerException(); - } - if (result.block_.isEmpty()) { - result.block_ = new java.util.ArrayList(); - } - result.block_.add(value); - return this; - } - public Builder addBlock(net.osmand.binary.OsmandOdb.MapDataBlock.Builder builderForValue) { - if (result.block_.isEmpty()) { - result.block_ = new java.util.ArrayList(); - } - result.block_.add(builderForValue.build()); - return this; - } - public Builder addAllBlock( - java.lang.Iterable values) { - if (result.block_.isEmpty()) { - result.block_ = new java.util.ArrayList(); - } - super.addAll(values, result.block_); - return this; - } - public Builder clearBlock() { - result.block_ = java.util.Collections.emptyList(); - return this; - } - - // @@protoc_insertion_point(builder_scope:OsmAndMapIndex.MapDataBlocks) - } - - static { - defaultInstance = new MapDataBlocks(true); - net.osmand.binary.OsmandOdb.internalForceInit(); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:OsmAndMapIndex.MapDataBlocks) - } - public static final class MapDataBox extends com.google.protobuf.GeneratedMessage { // Use MapDataBox.newBuilder() to construct. @@ -4669,20 +4318,6 @@ public final class OsmandOdb { return dataObjects_.get(index); } - // optional uint32 rasterType = 13; - public static final int RASTERTYPE_FIELD_NUMBER = 13; - private boolean hasRasterType; - private int rasterType_ = 0; - public boolean hasRasterType() { return hasRasterType; } - public int getRasterType() { return rasterType_; } - - // optional bytes rasterImage = 14; - public static final int RASTERIMAGE_FIELD_NUMBER = 14; - private boolean hasRasterImage; - private com.google.protobuf.ByteString rasterImage_ = com.google.protobuf.ByteString.EMPTY; - public boolean hasRasterImage() { return hasRasterImage; } - public com.google.protobuf.ByteString getRasterImage() { return rasterImage_; } - // optional .StringTable stringTable = 15; public static final int STRINGTABLE_FIELD_NUMBER = 15; private boolean hasStringTable; @@ -4711,12 +4346,6 @@ public final class OsmandOdb { for (net.osmand.binary.OsmandOdb.MapData element : getDataObjectsList()) { output.writeMessage(12, element); } - if (hasRasterType()) { - output.writeUInt32(13, getRasterType()); - } - if (hasRasterImage()) { - output.writeBytes(14, getRasterImage()); - } if (hasStringTable()) { output.writeMessage(15, getStringTable()); } @@ -4738,14 +4367,6 @@ public final class OsmandOdb { size += com.google.protobuf.CodedOutputStream .computeMessageSize(12, element); } - if (hasRasterType()) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(13, getRasterType()); - } - if (hasRasterImage()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(14, getRasterImage()); - } if (hasStringTable()) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(15, getStringTable()); @@ -4932,12 +4553,6 @@ public final class OsmandOdb { } result.dataObjects_.addAll(other.dataObjects_); } - if (other.hasRasterType()) { - setRasterType(other.getRasterType()); - } - if (other.hasRasterImage()) { - setRasterImage(other.getRasterImage()); - } if (other.hasStringTable()) { mergeStringTable(other.getStringTable()); } @@ -4977,14 +4592,6 @@ public final class OsmandOdb { addDataObjects(subBuilder.buildPartial()); break; } - case 104: { - setRasterType(input.readUInt32()); - break; - } - case 114: { - setRasterImage(input.readBytes()); - break; - } case 122: { net.osmand.binary.OsmandOdb.StringTable.Builder subBuilder = net.osmand.binary.OsmandOdb.StringTable.newBuilder(); if (hasStringTable()) { @@ -5068,45 +4675,6 @@ public final class OsmandOdb { return this; } - // optional uint32 rasterType = 13; - public boolean hasRasterType() { - return result.hasRasterType(); - } - public int getRasterType() { - return result.getRasterType(); - } - public Builder setRasterType(int value) { - result.hasRasterType = true; - result.rasterType_ = value; - return this; - } - public Builder clearRasterType() { - result.hasRasterType = false; - result.rasterType_ = 0; - return this; - } - - // optional bytes rasterImage = 14; - public boolean hasRasterImage() { - return result.hasRasterImage(); - } - public com.google.protobuf.ByteString getRasterImage() { - return result.getRasterImage(); - } - public Builder setRasterImage(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasRasterImage = true; - result.rasterImage_ = value; - return this; - } - public Builder clearRasterImage() { - result.hasRasterImage = false; - result.rasterImage_ = getDefaultInstance().getRasterImage(); - return this; - } - // optional .StringTable stringTable = 15; public boolean hasStringTable() { return result.hasStringTable(); @@ -5239,6 +4807,27 @@ public final class OsmandOdb { public boolean hasId() { return hasId; } public long getId() { return id_; } + // optional uint32 rasterTileX = 13; + public static final int RASTERTILEX_FIELD_NUMBER = 13; + private boolean hasRasterTileX; + private int rasterTileX_ = 0; + public boolean hasRasterTileX() { return hasRasterTileX; } + public int getRasterTileX() { return rasterTileX_; } + + // optional uint32 rasterTileY = 14; + public static final int RASTERTILEY_FIELD_NUMBER = 14; + private boolean hasRasterTileY; + private int rasterTileY_ = 0; + public boolean hasRasterTileY() { return hasRasterTileY; } + public int getRasterTileY() { return rasterTileY_; } + + // optional bytes rasterBytes = 15; + public static final int RASTERBYTES_FIELD_NUMBER = 15; + private boolean hasRasterBytes; + private com.google.protobuf.ByteString rasterBytes_ = com.google.protobuf.ByteString.EMPTY; + public boolean hasRasterBytes() { return hasRasterBytes; } + public com.google.protobuf.ByteString getRasterBytes() { return rasterBytes_; } + private void initFields() { } @Override @@ -5273,6 +4862,15 @@ public final class OsmandOdb { if (hasId()) { output.writeSInt64(12, getId()); } + if (hasRasterTileX()) { + output.writeUInt32(13, getRasterTileX()); + } + if (hasRasterTileY()) { + output.writeUInt32(14, getRasterTileY()); + } + if (hasRasterBytes()) { + output.writeBytes(15, getRasterBytes()); + } getUnknownFields().writeTo(output); } @@ -5316,6 +4914,18 @@ public final class OsmandOdb { size += com.google.protobuf.CodedOutputStream .computeSInt64Size(12, getId()); } + if (hasRasterTileX()) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(13, getRasterTileX()); + } + if (hasRasterTileY()) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(14, getRasterTileY()); + } + if (hasRasterBytes()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(15, getRasterBytes()); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -5513,6 +5123,15 @@ public final class OsmandOdb { if (other.hasId()) { setId(other.getId()); } + if (other.hasRasterTileX()) { + setRasterTileX(other.getRasterTileX()); + } + if (other.hasRasterTileY()) { + setRasterTileY(other.getRasterTileY()); + } + if (other.hasRasterBytes()) { + setRasterBytes(other.getRasterBytes()); + } this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -5567,6 +5186,18 @@ public final class OsmandOdb { setId(input.readSInt64()); break; } + case 104: { + setRasterTileX(input.readUInt32()); + break; + } + case 112: { + setRasterTileY(input.readUInt32()); + break; + } + case 122: { + setRasterBytes(input.readBytes()); + break; + } } } } @@ -5735,6 +5366,63 @@ public final class OsmandOdb { return this; } + // optional uint32 rasterTileX = 13; + public boolean hasRasterTileX() { + return result.hasRasterTileX(); + } + public int getRasterTileX() { + return result.getRasterTileX(); + } + public Builder setRasterTileX(int value) { + result.hasRasterTileX = true; + result.rasterTileX_ = value; + return this; + } + public Builder clearRasterTileX() { + result.hasRasterTileX = false; + result.rasterTileX_ = 0; + return this; + } + + // optional uint32 rasterTileY = 14; + public boolean hasRasterTileY() { + return result.hasRasterTileY(); + } + public int getRasterTileY() { + return result.getRasterTileY(); + } + public Builder setRasterTileY(int value) { + result.hasRasterTileY = true; + result.rasterTileY_ = value; + return this; + } + public Builder clearRasterTileY() { + result.hasRasterTileY = false; + result.rasterTileY_ = 0; + return this; + } + + // optional bytes rasterBytes = 15; + public boolean hasRasterBytes() { + return result.hasRasterBytes(); + } + public com.google.protobuf.ByteString getRasterBytes() { + return result.getRasterBytes(); + } + public Builder setRasterBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasRasterBytes = true; + result.rasterBytes_ = value; + return this; + } + public Builder clearRasterBytes() { + result.hasRasterBytes = false; + result.rasterBytes_ = getDefaultInstance().getRasterBytes(); + return this; + } + // @@protoc_insertion_point(builder_scope:MapData) } @@ -18529,11 +18217,6 @@ public final class OsmandOdb { private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_OsmAndMapIndex_MapRootLevel_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_OsmAndMapIndex_MapDataBlocks_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_OsmAndMapIndex_MapDataBlocks_fieldAccessorTable; private static com.google.protobuf.Descriptors.Descriptor internal_static_OsmAndMapIndex_MapDataBox_descriptor; private static @@ -18694,107 +18377,106 @@ public final class OsmandOdb { "\002(\r\022\016\n\006bottom\030\004 \002(\r\"\030\n\013StringTable\022\t\n\001s\030" + "\001 \003(\t\"f\n\022IndexedStringTable\022\016\n\006prefix\030\001 ", "\001(\t\022\013\n\003key\030\003 \003(\t\022\013\n\003val\030\004 \003(\007\022&\n\tsubtabl" + - "es\030\005 \003(\0132\023.IndexedStringTable\"\347\004\n\016OsmAnd" + + "es\030\005 \003(\0132\023.IndexedStringTable\"\250\004\n\016OsmAnd" + "MapIndex\022\014\n\004name\030\002 \002(\t\022.\n\005rules\030\004 \003(\0132\037." + "OsmAndMapIndex.MapEncodingRule\022,\n\006levels" + "\030\005 \003(\0132\034.OsmAndMapIndex.MapRootLevel\032X\n\017" + "MapEncodingRule\022\013\n\003tag\030\003 \002(\t\022\r\n\005value\030\005 " + "\001(\t\022\n\n\002id\030\007 \001(\r\022\017\n\007minZoom\030\t \001(\r\022\014\n\004type" + - "\030\n \001(\r\032\304\001\n\014MapRootLevel\022\017\n\007maxZoom\030\001 \002(\005" + + "\030\n \001(\r\032\264\001\n\014MapRootLevel\022\017\n\007maxZoom\030\001 \002(\005" + "\022\017\n\007minZoom\030\002 \002(\005\022\014\n\004left\030\003 \002(\005\022\r\n\005right" + "\030\004 \002(\005\022\013\n\003top\030\005 \002(\005\022\016\n\006bottom\030\006 \002(\005\022)\n\005b", - "oxes\030\007 \003(\0132\032.OsmAndMapIndex.MapDataBox\022-" + - "\n\006blocks\030\010 \003(\0132\035.OsmAndMapIndex.MapDataB" + - "locks\032-\n\rMapDataBlocks\022\034\n\005block\030\006 \003(\0132\r." + - "MapDataBlock\032\230\001\n\nMapDataBox\022\014\n\004left\030\001 \002(" + - "\021\022\r\n\005right\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022\016\n\006bottom\030" + - "\004 \002(\021\022\026\n\016shiftToMapData\030\005 \001(\007\022\r\n\005ocean\030\006" + - " \001(\010\022)\n\005boxes\030\007 \003(\0132\032.OsmAndMapIndex.Map" + - "DataBox\"\211\001\n\014MapDataBlock\022\016\n\006baseId\030\n \001(\004" + - "\022\035\n\013dataObjects\030\014 \003(\0132\010.MapData\022\022\n\nraste" + - "rType\030\r \001(\r\022\023\n\013rasterImage\030\016 \001(\014\022!\n\013stri", - "ngTable\030\017 \001(\0132\014.StringTable\"\241\001\n\007MapData\022" + - "\023\n\013coordinates\030\001 \001(\014\022\027\n\017areaCoordinates\030" + - "\002 \001(\014\022\037\n\027polygonInnerCoordinates\030\004 \003(\014\022\027" + - "\n\017additionalTypes\030\006 \001(\014\022\r\n\005types\030\007 \002(\014\022\023" + - "\n\013stringNames\030\n \001(\014\022\n\n\002id\030\014 \002(\022\"\222\002\n\022OsmA" + - "ndAddressIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_en\030" + - "\002 \001(\t\022\"\n\nboundaries\030\003 \001(\0132\016.OsmAndTileBo" + - "x\022/\n\006cities\030\006 \003(\0132\037.OsmAndAddressIndex.C" + - "itiesIndex\022.\n\tnameIndex\030\007 \001(\0132\033.OsmAndAd" + - "dressNameIndexData\032X\n\013CitiesIndex\022\014\n\004typ", - "e\030\002 \002(\r\022\032\n\006cities\030\005 \003(\0132\n.CityIndex\022\037\n\006b" + - "locks\030\007 \003(\0132\017.CityBlockIndex\"\301\001\n\032OsmAndA" + - "ddressNameIndexData\022\"\n\005table\030\004 \002(\0132\023.Ind" + - "exedStringTable\022>\n\004atom\030\007 \003(\01320.OsmAndAd" + - "dressNameIndexData.AddressNameIndexData\032" + - "?\n\024AddressNameIndexData\022\'\n\004atom\030\004 \003(\0132\031." + - "AddressNameIndexDataAtom\"v\n\030AddressNameI" + - "ndexDataAtom\022\014\n\004name\030\001 \001(\t\022\016\n\006nameEn\030\002 \001" + - "(\t\022\014\n\004type\030\003 \002(\r\022\024\n\014shiftToIndex\030\005 \003(\005\022\030" + - "\n\020shiftToCityIndex\030\006 \003(\005\"~\n\tCityIndex\022\021\n", - "\tcity_type\030\001 \001(\r\022\014\n\004name\030\002 \002(\t\022\017\n\007name_e" + - "n\030\003 \001(\t\022\n\n\002id\030\004 \001(\004\022\t\n\001x\030\005 \002(\r\022\t\n\001y\030\006 \002(" + - "\r\022\035\n\025shiftToCityBlockIndex\030\n \001(\007\"l\n\016City" + - "BlockIndex\022\030\n\020shiftToCityIndex\030\004 \001(\007\022!\n\t" + - "buildings\030\n \003(\0132\016.BuildingIndex\022\035\n\007stree" + - "ts\030\014 \003(\0132\014.StreetIndex\"\235\001\n\013StreetIndex\022\014" + - "\n\004name\030\001 \002(\t\022\017\n\007name_en\030\002 \001(\t\022\t\n\001x\030\003 \002(\021" + - "\022\t\n\001y\030\004 \002(\021\022\n\n\002id\030\006 \001(\004\022!\n\tbuildings\030\014 \003" + - "(\0132\016.BuildingIndex\022*\n\rintersections\030\005 \003(" + - "\0132\023.StreetIntersection\"_\n\022StreetIntersec", - "tion\022\014\n\004name\030\002 \002(\t\022\017\n\007name_en\030\003 \001(\t\022\024\n\014i" + - "ntersectedX\030\004 \002(\021\022\024\n\014intersectedY\030\005 \002(\021\"" + - "\262\001\n\rBuildingIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_" + - "en\030\002 \001(\t\022\r\n\005name2\030\003 \001(\t\022\020\n\010name_en2\030\004 \001(" + - "\t\022\025\n\rinterpolation\030\005 \001(\021\022\t\n\001x\030\007 \002(\021\022\t\n\001y" + - "\030\010 \002(\021\022\n\n\002x2\030\t \001(\021\022\n\n\002y2\030\n \001(\021\022\n\n\002id\030\r \001" + - "(\004\022\020\n\010postcode\030\016 \001(\t\"2\n\017TransportRoutes\022" + - "\037\n\006routes\030\006 \003(\0132\017.TransportRoute\"\317\001\n\016Tra" + - "nsportRoute\022\n\n\002id\030\001 \002(\004\022\014\n\004type\030\003 \001(\r\022\020\n" + - "\010operator\030\004 \001(\r\022\013\n\003ref\030\005 \001(\t\022\014\n\004name\030\006 \001", - "(\r\022\017\n\007name_en\030\007 \001(\r\022\020\n\010distance\030\010 \001(\r\022(\n" + - "\013directStops\030\017 \003(\0132\023.TransportRouteStop\022" + - ")\n\014reverseStops\030\020 \003(\0132\023.TransportRouteSt" + - "op\"W\n\022TransportRouteStop\022\n\n\002id\030\001 \002(\022\022\n\n\002" + - "dx\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021\022\014\n\004name\030\006 \002(\r\022\017\n\007na" + - "me_en\030\007 \001(\r\"b\n\rTransportStop\022\n\n\002dx\030\001 \002(\021" + - "\022\n\n\002dy\030\002 \002(\021\022\n\n\002id\030\005 \002(\022\022\014\n\004name\030\006 \002(\r\022\017" + - "\n\007name_en\030\007 \001(\r\022\016\n\006routes\030\020 \003(\r\"\244\001\n\022Tran" + - "sportStopsTree\022\014\n\004left\030\001 \002(\021\022\r\n\005right\030\002 " + - "\002(\021\022\013\n\003top\030\003 \002(\021\022\016\n\006bottom\030\004 \002(\021\022%\n\010subt", - "rees\030\007 \003(\0132\023.TransportStopsTree\022\035\n\005leafs" + - "\030\010 \003(\0132\016.TransportStop\022\016\n\006baseId\030\020 \001(\004\"\215" + - "\001\n\024OsmAndTransportIndex\022\014\n\004name\030\001 \001(\t\022 \n" + - "\006routes\030\003 \001(\0132\020.TransportRoutes\022\"\n\005stops" + - "\030\006 \001(\0132\023.TransportStopsTree\022!\n\013stringTab" + - "le\030\t \002(\0132\014.StringTable\"\333\001\n\016OsmAndPoiInde" + - "x\022\014\n\004name\030\001 \002(\t\022\"\n\nboundaries\030\002 \002(\0132\016.Os" + - "mAndTileBox\022-\n\017categoriesTable\030\003 \003(\0132\024.O" + - "smAndCategoryTable\022&\n\tnameIndex\030\004 \001(\0132\023." + - "OsmAndPoiNameIndex\022\034\n\005boxes\030\006 \003(\0132\r.OsmA", - "ndPoiBox\022\"\n\007poiData\030\t \003(\0132\021.OsmAndPoiBox" + - "Data\"\270\001\n\022OsmAndPoiNameIndex\022\"\n\005table\030\003 \002" + - "(\0132\023.IndexedStringTable\0228\n\004data\030\005 \003(\0132*." + - "OsmAndPoiNameIndex.OsmAndPoiNameIndexDat" + - "a\032D\n\026OsmAndPoiNameIndexData\022*\n\005atoms\030\003 \003" + - "(\0132\033.OsmAndPoiNameIndexDataAtom\"Q\n\032OsmAn" + - "dPoiNameIndexDataAtom\022\014\n\004zoom\030\002 \001(\r\022\t\n\001x" + - "\030\003 \001(\r\022\t\n\001y\030\004 \001(\r\022\017\n\007shiftTo\030\016 \001(\007\">\n\023Os" + - "mAndCategoryTable\022\020\n\010category\030\001 \002(\t\022\025\n\rs" + - "ubcategories\030\003 \003(\t\"\227\001\n\014OsmAndPoiBox\022\014\n\004z", - "oom\030\001 \002(\r\022\014\n\004left\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022(\n\n" + - "categories\030\004 \001(\0132\024.OsmAndPoiCategories\022\037" + - "\n\010subBoxes\030\n \003(\0132\r.OsmAndPoiBox\022\023\n\013shift" + - "ToData\030\016 \001(\007\")\n\023OsmAndPoiCategories\022\022\n\nc" + - "ategories\030\003 \003(\r\"^\n\020OsmAndPoiBoxData\022\014\n\004z" + - "oom\030\001 \001(\r\022\t\n\001x\030\002 \001(\r\022\t\n\001y\030\003 \001(\r\022&\n\007poiDa" + - "ta\030\005 \003(\0132\025.OsmAndPoiBoxDataAtom\"\255\001\n\024OsmA" + - "ndPoiBoxDataAtom\022\n\n\002dx\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021" + - "\022\022\n\ncategories\030\004 \003(\r\022\014\n\004name\030\006 \001(\t\022\016\n\006na" + - "meEn\030\007 \001(\t\022\n\n\002id\030\010 \001(\004\022\024\n\014openingHours\030\n", - " \001(\t\022\014\n\004site\030\013 \001(\t\022\r\n\005phone\030\014 \001(\t\022\014\n\004not" + - "e\030\r \001(\tB\023\n\021net.osmand.binary" + "oxes\030\007 \003(\0132\032.OsmAndMapIndex.MapDataBox\022\035" + + "\n\006blocks\030\017 \003(\0132\r.MapDataBlock\032\230\001\n\nMapDat" + + "aBox\022\014\n\004left\030\001 \002(\021\022\r\n\005right\030\002 \002(\021\022\013\n\003top" + + "\030\003 \002(\021\022\016\n\006bottom\030\004 \002(\021\022\026\n\016shiftToMapData" + + "\030\005 \001(\007\022\r\n\005ocean\030\006 \001(\010\022)\n\005boxes\030\007 \003(\0132\032.O" + + "smAndMapIndex.MapDataBox\"`\n\014MapDataBlock" + + "\022\016\n\006baseId\030\n \001(\004\022\035\n\013dataObjects\030\014 \003(\0132\010." + + "MapData\022!\n\013stringTable\030\017 \001(\0132\014.StringTab" + + "le\"\340\001\n\007MapData\022\023\n\013coordinates\030\001 \001(\014\022\027\n\017a" + + "reaCoordinates\030\002 \001(\014\022\037\n\027polygonInnerCoor", + "dinates\030\004 \003(\014\022\027\n\017additionalTypes\030\006 \001(\014\022\r" + + "\n\005types\030\007 \002(\014\022\023\n\013stringNames\030\n \001(\014\022\n\n\002id" + + "\030\014 \002(\022\022\023\n\013rasterTileX\030\r \001(\r\022\023\n\013rasterTil" + + "eY\030\016 \001(\r\022\023\n\013rasterBytes\030\017 \001(\014\"\222\002\n\022OsmAnd" + + "AddressIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_en\030\002 " + + "\001(\t\022\"\n\nboundaries\030\003 \001(\0132\016.OsmAndTileBox\022" + + "/\n\006cities\030\006 \003(\0132\037.OsmAndAddressIndex.Cit" + + "iesIndex\022.\n\tnameIndex\030\007 \001(\0132\033.OsmAndAddr" + + "essNameIndexData\032X\n\013CitiesIndex\022\014\n\004type\030" + + "\002 \002(\r\022\032\n\006cities\030\005 \003(\0132\n.CityIndex\022\037\n\006blo", + "cks\030\007 \003(\0132\017.CityBlockIndex\"\301\001\n\032OsmAndAdd" + + "ressNameIndexData\022\"\n\005table\030\004 \002(\0132\023.Index" + + "edStringTable\022>\n\004atom\030\007 \003(\01320.OsmAndAddr" + + "essNameIndexData.AddressNameIndexData\032?\n" + + "\024AddressNameIndexData\022\'\n\004atom\030\004 \003(\0132\031.Ad" + + "dressNameIndexDataAtom\"v\n\030AddressNameInd" + + "exDataAtom\022\014\n\004name\030\001 \001(\t\022\016\n\006nameEn\030\002 \001(\t" + + "\022\014\n\004type\030\003 \002(\r\022\024\n\014shiftToIndex\030\005 \003(\005\022\030\n\020" + + "shiftToCityIndex\030\006 \003(\005\"~\n\tCityIndex\022\021\n\tc" + + "ity_type\030\001 \001(\r\022\014\n\004name\030\002 \002(\t\022\017\n\007name_en\030", + "\003 \001(\t\022\n\n\002id\030\004 \001(\004\022\t\n\001x\030\005 \002(\r\022\t\n\001y\030\006 \002(\r\022" + + "\035\n\025shiftToCityBlockIndex\030\n \001(\007\"l\n\016CityBl" + + "ockIndex\022\030\n\020shiftToCityIndex\030\004 \001(\007\022!\n\tbu" + + "ildings\030\n \003(\0132\016.BuildingIndex\022\035\n\007streets" + + "\030\014 \003(\0132\014.StreetIndex\"\235\001\n\013StreetIndex\022\014\n\004" + + "name\030\001 \002(\t\022\017\n\007name_en\030\002 \001(\t\022\t\n\001x\030\003 \002(\021\022\t" + + "\n\001y\030\004 \002(\021\022\n\n\002id\030\006 \001(\004\022!\n\tbuildings\030\014 \003(\013" + + "2\016.BuildingIndex\022*\n\rintersections\030\005 \003(\0132" + + "\023.StreetIntersection\"_\n\022StreetIntersecti" + + "on\022\014\n\004name\030\002 \002(\t\022\017\n\007name_en\030\003 \001(\t\022\024\n\014int", + "ersectedX\030\004 \002(\021\022\024\n\014intersectedY\030\005 \002(\021\"\262\001" + + "\n\rBuildingIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_en" + + "\030\002 \001(\t\022\r\n\005name2\030\003 \001(\t\022\020\n\010name_en2\030\004 \001(\t\022" + + "\025\n\rinterpolation\030\005 \001(\021\022\t\n\001x\030\007 \002(\021\022\t\n\001y\030\010" + + " \002(\021\022\n\n\002x2\030\t \001(\021\022\n\n\002y2\030\n \001(\021\022\n\n\002id\030\r \001(\004" + + "\022\020\n\010postcode\030\016 \001(\t\"2\n\017TransportRoutes\022\037\n" + + "\006routes\030\006 \003(\0132\017.TransportRoute\"\317\001\n\016Trans" + + "portRoute\022\n\n\002id\030\001 \002(\004\022\014\n\004type\030\003 \001(\r\022\020\n\010o" + + "perator\030\004 \001(\r\022\013\n\003ref\030\005 \001(\t\022\014\n\004name\030\006 \001(\r" + + "\022\017\n\007name_en\030\007 \001(\r\022\020\n\010distance\030\010 \001(\r\022(\n\013d", + "irectStops\030\017 \003(\0132\023.TransportRouteStop\022)\n" + + "\014reverseStops\030\020 \003(\0132\023.TransportRouteStop" + + "\"W\n\022TransportRouteStop\022\n\n\002id\030\001 \002(\022\022\n\n\002dx" + + "\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021\022\014\n\004name\030\006 \002(\r\022\017\n\007name" + + "_en\030\007 \001(\r\"b\n\rTransportStop\022\n\n\002dx\030\001 \002(\021\022\n" + + "\n\002dy\030\002 \002(\021\022\n\n\002id\030\005 \002(\022\022\014\n\004name\030\006 \002(\r\022\017\n\007" + + "name_en\030\007 \001(\r\022\016\n\006routes\030\020 \003(\r\"\244\001\n\022Transp" + + "ortStopsTree\022\014\n\004left\030\001 \002(\021\022\r\n\005right\030\002 \002(" + + "\021\022\013\n\003top\030\003 \002(\021\022\016\n\006bottom\030\004 \002(\021\022%\n\010subtre" + + "es\030\007 \003(\0132\023.TransportStopsTree\022\035\n\005leafs\030\010", + " \003(\0132\016.TransportStop\022\016\n\006baseId\030\020 \001(\004\"\215\001\n" + + "\024OsmAndTransportIndex\022\014\n\004name\030\001 \001(\t\022 \n\006r" + + "outes\030\003 \001(\0132\020.TransportRoutes\022\"\n\005stops\030\006" + + " \001(\0132\023.TransportStopsTree\022!\n\013stringTable" + + "\030\t \002(\0132\014.StringTable\"\333\001\n\016OsmAndPoiIndex\022" + + "\014\n\004name\030\001 \002(\t\022\"\n\nboundaries\030\002 \002(\0132\016.OsmA" + + "ndTileBox\022-\n\017categoriesTable\030\003 \003(\0132\024.Osm" + + "AndCategoryTable\022&\n\tnameIndex\030\004 \001(\0132\023.Os" + + "mAndPoiNameIndex\022\034\n\005boxes\030\006 \003(\0132\r.OsmAnd" + + "PoiBox\022\"\n\007poiData\030\t \003(\0132\021.OsmAndPoiBoxDa", + "ta\"\270\001\n\022OsmAndPoiNameIndex\022\"\n\005table\030\003 \002(\013" + + "2\023.IndexedStringTable\0228\n\004data\030\005 \003(\0132*.Os" + + "mAndPoiNameIndex.OsmAndPoiNameIndexData\032" + + "D\n\026OsmAndPoiNameIndexData\022*\n\005atoms\030\003 \003(\013" + + "2\033.OsmAndPoiNameIndexDataAtom\"Q\n\032OsmAndP" + + "oiNameIndexDataAtom\022\014\n\004zoom\030\002 \001(\r\022\t\n\001x\030\003" + + " \001(\r\022\t\n\001y\030\004 \001(\r\022\017\n\007shiftTo\030\016 \001(\007\">\n\023OsmA" + + "ndCategoryTable\022\020\n\010category\030\001 \002(\t\022\025\n\rsub" + + "categories\030\003 \003(\t\"\227\001\n\014OsmAndPoiBox\022\014\n\004zoo" + + "m\030\001 \002(\r\022\014\n\004left\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022(\n\nca", + "tegories\030\004 \001(\0132\024.OsmAndPoiCategories\022\037\n\010" + + "subBoxes\030\n \003(\0132\r.OsmAndPoiBox\022\023\n\013shiftTo" + + "Data\030\016 \001(\007\")\n\023OsmAndPoiCategories\022\022\n\ncat" + + "egories\030\003 \003(\r\"^\n\020OsmAndPoiBoxData\022\014\n\004zoo" + + "m\030\001 \001(\r\022\t\n\001x\030\002 \001(\r\022\t\n\001y\030\003 \001(\r\022&\n\007poiData" + + "\030\005 \003(\0132\025.OsmAndPoiBoxDataAtom\"\255\001\n\024OsmAnd" + + "PoiBoxDataAtom\022\n\n\002dx\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021\022\022" + + "\n\ncategories\030\004 \003(\r\022\014\n\004name\030\006 \001(\t\022\016\n\006name" + + "En\030\007 \001(\t\022\n\n\002id\030\010 \001(\004\022\024\n\014openingHours\030\n \001" + + "(\t\022\014\n\004site\030\013 \001(\t\022\r\n\005phone\030\014 \001(\t\022\014\n\004note\030", + "\r \001(\tB\023\n\021net.osmand.binary" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -18858,16 +18540,8 @@ public final class OsmandOdb { new java.lang.String[] { "MaxZoom", "MinZoom", "Left", "Right", "Top", "Bottom", "Boxes", "Blocks", }, net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapRootLevel.class, net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapRootLevel.Builder.class); - internal_static_OsmAndMapIndex_MapDataBlocks_descriptor = - internal_static_OsmAndMapIndex_descriptor.getNestedTypes().get(2); - internal_static_OsmAndMapIndex_MapDataBlocks_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_OsmAndMapIndex_MapDataBlocks_descriptor, - new java.lang.String[] { "Block", }, - net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks.class, - net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBlocks.Builder.class); internal_static_OsmAndMapIndex_MapDataBox_descriptor = - internal_static_OsmAndMapIndex_descriptor.getNestedTypes().get(3); + internal_static_OsmAndMapIndex_descriptor.getNestedTypes().get(2); internal_static_OsmAndMapIndex_MapDataBox_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_OsmAndMapIndex_MapDataBox_descriptor, @@ -18879,7 +18553,7 @@ public final class OsmandOdb { internal_static_MapDataBlock_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_MapDataBlock_descriptor, - new java.lang.String[] { "BaseId", "DataObjects", "RasterType", "RasterImage", "StringTable", }, + new java.lang.String[] { "BaseId", "DataObjects", "StringTable", }, net.osmand.binary.OsmandOdb.MapDataBlock.class, net.osmand.binary.OsmandOdb.MapDataBlock.Builder.class); internal_static_MapData_descriptor = @@ -18887,7 +18561,7 @@ public final class OsmandOdb { internal_static_MapData_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_MapData_descriptor, - new java.lang.String[] { "Coordinates", "AreaCoordinates", "PolygonInnerCoordinates", "AdditionalTypes", "Types", "StringNames", "Id", }, + new java.lang.String[] { "Coordinates", "AreaCoordinates", "PolygonInnerCoordinates", "AdditionalTypes", "Types", "StringNames", "Id", "RasterTileX", "RasterTileY", "RasterBytes", }, net.osmand.binary.OsmandOdb.MapData.class, net.osmand.binary.OsmandOdb.MapData.Builder.class); internal_static_OsmAndAddressIndex_descriptor = diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java b/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java index e7e7684601..d0daa7c277 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java @@ -226,14 +226,14 @@ public class BinaryMapIndexWriter { Collections.sort(out, new Comparator() { @Override public int compare(MapRulType o1, MapRulType o2) { - return o1.getFreq() - o2.getFreq(); + return o2.getFreq() - o1.getFreq(); } }); for (int i = 0; i < out.size(); i++) { MapEncodingRule.Builder builder = OsmandOdb.OsmAndMapIndex.MapEncodingRule.newBuilder(); MapRulType rule = out.get(i); - rule.setTargetId(i); + rule.setTargetId(i + 1); builder.setTag(rule.getTag()); if (rule.getValue() != null) { @@ -242,8 +242,11 @@ public class BinaryMapIndexWriter { builder.setMinZoom(rule.getMinzoom()); if (rule.isAdditional()) { builder.setType(1); + } else if(rule.isOnlyNameRef()) { + builder.setType(2); } - codedOutStream.writeMessage(OsmandOdb.OsmAndMapIndex.RULES_FIELD_NUMBER, builder.build()); + MapEncodingRule rulet = builder.build(); + codedOutStream.writeMessage(OsmandOdb.OsmAndMapIndex.RULES_FIELD_NUMBER, rulet); } long newfp = getFilePointer(); System.out.println("RENDERING SCHEMA takes " + (newfp - fp)); @@ -297,6 +300,7 @@ public class BinaryMapIndexWriter { public void writeMapDataBlock(MapDataBlock.Builder builder, Map stringTable, BinaryFileReference ref) throws IOException { + checkPeekState(MAP_ROOT_LEVEL_INIT); StringTable.Builder bs = OsmandOdb.StringTable.newBuilder(); for (String s : stringTable.keySet()) { @@ -307,11 +311,14 @@ public class BinaryMapIndexWriter { int size = st.getSerializedSize(); STRING_TABLE_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapDataBlock.STRINGTABLE_FIELD_NUMBER) + CodedOutputStream.computeRawVarint32Size(size) + size; + + codedOutStream.writeTag(OsmAndMapIndex.MapRootLevel.BLOCKS_FIELD_NUMBER, FieldType.MESSAGE.getWireType()); + codedOutStream.flush(); ref.writeReference(raf, getFilePointer()); MapDataBlock block = builder.build(); MAP_DATA_SIZE += block.getSerializedSize(); - codedOutStream.writeMessage(OsmAndMapIndex.MapRootLevel.BLOCKS_FIELD_NUMBER, block); + codedOutStream.writeMessageNoTag(block); } /** @@ -336,8 +343,8 @@ public class BinaryMapIndexWriter { private TByteArrayList mapDataBuf = new TByteArrayList(); - public MapData writeMapData(long diffId, int pleft, int ptop, boolean area, byte[] coordinates, byte[] innerPolygonTypes, byte[] types, - byte[] additionalTypes, Map names, Map stringTable, MapDataBlock.Builder dataBlock) + public MapData writeMapData(long diffId, int pleft, int ptop, boolean area, byte[] coordinates, byte[] innerPolygonTypes, TIntArrayList typeUse, + TIntArrayList addtypeUse, Map names, Map stringTable, MapDataBlock.Builder dataBlock) throws IOException { MapData.Builder data = MapData.newBuilder(); @@ -391,14 +398,21 @@ public class BinaryMapIndexWriter { } } } - - data.setTypes(ByteString.copyFrom(types)); + + mapDataBuf.clear(); + for (int i = 0; i < typeUse.size() ; i++) { + writeRawVarint32(mapDataBuf, typeUse.get(i));; + } + data.setTypes(ByteString.copyFrom(mapDataBuf.toArray())); TYPES_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapData.TYPES_FIELD_NUMBER) - + CodedOutputStream.computeRawVarint32Size(types.length) + types.length; - if (additionalTypes != null && additionalTypes.length > 0) { - data.setAdditionalTypes(ByteString.copyFrom(additionalTypes)); - TYPES_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapData.ADDITIONALTYPES_FIELD_NUMBER) - + CodedOutputStream.computeRawVarint32Size(additionalTypes.length) + additionalTypes.length; + + CodedOutputStream.computeRawVarint32Size(mapDataBuf.size()) + mapDataBuf.size(); + if (addtypeUse != null && addtypeUse.size() > 0) { + mapDataBuf.clear(); + for (int i = 0; i < addtypeUse.size() ; i++) { + writeRawVarint32(mapDataBuf, addtypeUse.get(i));; + } + data.setAdditionalTypes(ByteString.copyFrom(mapDataBuf.toArray())); + TYPES_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapData.ADDITIONALTYPES_FIELD_NUMBER); } mapDataBuf.clear(); diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java index d8146b8ca9..16b03b74cc 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java @@ -625,7 +625,7 @@ public class IndexCreator { long time = System.currentTimeMillis(); IndexCreator creator = new IndexCreator(new File("/home/victor/projects/OsmAnd/data/osm-gen/")); //$NON-NLS-1$ - creator.setIndexMap(false); + creator.setIndexMap(true); creator.setIndexAddress(true); creator.setIndexPOI(true); creator.setIndexTransport(true); diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java index 7ba9fa8c81..81ae1bb8d9 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java @@ -320,17 +320,11 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { } } - private void parseAndSort(TIntArrayList ts, byte[] bs, byte[] bt) { + private void parseAndSort(TIntArrayList ts, byte[] bs) { ts.clear(); if (bs != null && bs.length > 0) { - for (int j = 0; j < bs.length; j += 4) { - ts.add(Algoritms.parseIntFromBytes(bs, j)); - } - } - - if (bt != null && bt.length > 0) { - for (int j = 0; j < bt.length; j += 4) { - ts.add(Algoritms.parseIntFromBytes(bt, j)); + for (int j = 0; j < bs.length; j += 2) { + ts.add(Algoritms.parseSmallIntFromBytes(bs, j)); } } ts.sort(); @@ -353,6 +347,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { TLongHashSet visitedWays = new TLongHashSet(); ArrayList list = new ArrayList(100); TIntArrayList temp = new TIntArrayList(); + TIntArrayList tempAdd = new TIntArrayList(); while (rs.next()) { if (lowLevelWays != -1) { progress.progress(1); @@ -370,7 +365,8 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { long endNode = rs.getLong(3); String name = rs.getString(5); - parseAndSort(typeUse, rs.getBytes(6), rs.getBytes(7)); + parseAndSort(typeUse, rs.getBytes(6)); + parseAndSort(addtypeUse, rs.getBytes(7)); loadNodes(rs.getBytes(4), list); ArrayList wayNodes = new ArrayList(list); @@ -385,8 +381,9 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { // search by exact name while (fs.next() && !combined) { if (!visitedWays.contains(fs.getLong(1))) { - parseAndSort(temp, rs.getBytes(6), rs.getBytes(7)); - if(temp.equals(namesUse)){ + parseAndSort(temp, rs.getBytes(6)); + parseAndSort(tempAdd, rs.getBytes(7)); + if(temp.equals(typeUse) && tempAdd.equals(addtypeUse)){ combined = true; long lid = fs.getLong(1); startNode = fs.getLong(2); @@ -416,8 +413,9 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { ResultSet fs = startStat.executeQuery(); while (fs.next() && !combined) { if (!visitedWays.contains(fs.getLong(1))) { - parseAndSort(temp, rs.getBytes(6), rs.getBytes(7)); - if (temp.equals(namesUse)) { + parseAndSort(temp, rs.getBytes(6)); + parseAndSort(tempAdd, rs.getBytes(7)); + if(temp.equals(typeUse) && tempAdd.equals(addtypeUse)){ combined = true; long lid = fs.getLong(1); if (!Algoritms.objectEquals(rs.getString(5), name)) { @@ -443,6 +441,11 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { boolean cycle = startNode == endNode; if (cycle) { skip = checkForSmallAreas(wNodes, zoom + Math.min(zoomWaySmothness / 2, 3), 3, 4); + } else { + // coastline + if(!typeUse.contains(renderingTypes.getCoastlineRuleType().getInternalId())) { + skip = checkForSmallAreas(wNodes, zoom + Math.min(zoomWaySmothness / 2, 3), 2, 8); + } } if (!skip) { List res = new ArrayList(); @@ -546,7 +549,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { .prepareStatement("SELECT area, coordinates, innerPolygons, types, additionalTypes, name FROM binary_map_objects WHERE id = ?"); // write map levels and map index - TLongObjectHashMap bounds = new TLongObjectHashMap(); + TLongObjectHashMap treeHeader = new TLongObjectHashMap(); for (int i = 0; i < mapZooms.size(); i++) { RTree rtree = mapTree[i]; long rootIndex = rtree.getFileHdr().getRootIndex(); @@ -555,9 +558,9 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { if (rootBounds != null) { writer.startWriteMapLevelIndex(mapZooms.getLevel(i).getMinZoom(), mapZooms.getLevel(i).getMaxZoom(), rootBounds.getMinX(), rootBounds.getMaxX(), rootBounds.getMinY(), rootBounds.getMaxY()); - writeBinaryMapTree(root, rootBounds, rtree, writer, bounds); + writeBinaryMapTree(root, rootBounds, rtree, writer, treeHeader); - writeBinaryMapBlock(root, rtree, writer, selectData, bounds, new LinkedHashMap(), + writeBinaryMapBlock(root, rootBounds, rtree, writer, selectData, treeHeader, new LinkedHashMap(), new LinkedHashMap()); writer.endWriteMapLevelIndex(); @@ -591,7 +594,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { StringBuilder b = new StringBuilder(); for (Map.Entry e : tempNames.entrySet()) { if (e.getValue() != null) { - b.append(SPECIAL_CHAR).append(e.getKey().getInternalId()).append(e.getValue()); + b.append(SPECIAL_CHAR).append((char)e.getKey().getInternalId()).append(e.getValue()); } } return b.toString(); @@ -601,7 +604,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { int i = name.indexOf(SPECIAL_CHAR); while (i != -1) { int n = name.indexOf(SPECIAL_CHAR, i + 2); - char ch = name.charAt(i + 1); + int ch = (short) name.charAt(i + 1); MapRulType rt = renderingTypes.getTypeByInternalId(ch); if (n == -1) { tempNames.put(rt, name.substring(i + 2)); @@ -612,7 +615,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { } } - public void writeBinaryMapBlock(rtree.Node parent, RTree r, BinaryMapIndexWriter writer, PreparedStatement selectData, + public void writeBinaryMapBlock(rtree.Node parent, Rect parentBounds, RTree r, BinaryMapIndexWriter writer, PreparedStatement selectData, TLongObjectHashMap bounds, Map tempStringTable, Map tempNames) throws IOException, RTreeException, SQLException { Element[] e = parent.getAllElements(); @@ -621,10 +624,10 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { BinaryFileReference ref = bounds.get(parent.getNodeIndex()); long baseId = 0; for (int i = 0; i < parent.getTotalElements(); i++) { - Rect re = e[i].getRect(); if (e[i].getElementType() == rtree.Node.LEAF_NODE) { long id = ((LeafElement) e[i]).getPtr(); selectData.setLong(1, id); + // selectData = mapConnection.prepareStatement("SELECT area, coordinates, innerPolygons, types, additionalTypes, name FROM binary_map_objects WHERE id = ?"); ResultSet rs = selectData.executeQuery(); if (rs.next()) { long cid = convertGeneratedIdToObfWrite(id); @@ -636,8 +639,24 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { } tempNames.clear(); decodeNames(rs.getString(6), tempNames); - MapData mapData = writer.writeMapData(cid - baseId, re.getMinX(), re.getMinY(), rs.getBoolean(1), rs.getBytes(2), rs.getBytes(3), - rs.getBytes(4), rs.getBytes(5), tempNames, tempStringTable, dataBlock); + byte[] types = rs.getBytes(4); + typeUse.clear(); + for (int j = 0; j < types.length; j += 2) { + int ids = Algoritms.parseSmallIntFromBytes(types, j); + typeUse.add(renderingTypes.getTypeByInternalId(ids).getTargetId()); + } + byte[] addTypes = rs.getBytes(5); + addtypeUse.clear(); + if (addTypes != null) { + for (int j = 0; j < addTypes.length; j += 2) { + int ids = Algoritms.parseSmallIntFromBytes(addTypes, j); + addtypeUse.add(renderingTypes.getTypeByInternalId(ids).getTargetId()); + } + } + + + MapData mapData = writer.writeMapData(cid - baseId, parentBounds.getMinX(), parentBounds.getMinY(), rs.getBoolean(1), rs.getBytes(2), rs.getBytes(3), + typeUse, addtypeUse, tempNames, tempStringTable, dataBlock); if(mapData != null) { dataBlock.addDataObjects(mapData); } @@ -653,7 +672,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { if (e[i].getElementType() != rtree.Node.LEAF_NODE) { long ptr = ((NonLeafElement) e[i]).getPtr(); rtree.Node ns = r.getReadNode(ptr); - writeBinaryMapBlock(ns, r, writer, selectData, bounds, tempStringTable, tempNames); + writeBinaryMapBlock(ns, e[i].getRect(), r, writer, selectData, bounds, tempStringTable, tempNames); } } } diff --git a/DataExtractionOSM/src/net/osmand/impl/ConsoleProgressImplementation.java b/DataExtractionOSM/src/net/osmand/impl/ConsoleProgressImplementation.java index 4f3ab85276..03898ab5d4 100644 --- a/DataExtractionOSM/src/net/osmand/impl/ConsoleProgressImplementation.java +++ b/DataExtractionOSM/src/net/osmand/impl/ConsoleProgressImplementation.java @@ -59,7 +59,7 @@ public class ConsoleProgressImplementation implements IProgress { this.lastPercentPrint = getCurrentPercent(); long now = System.currentTimeMillis(); if(now - lastTimePrinted >= deltaTimeToPrint || deltaTime < 0){ - log.debug(MessageFormat.format("Done {0} %.", getCurrentPercent())); //$NON-NLS-1$ + log.info(MessageFormat.format("Done {0} %.", getCurrentPercent())); //$NON-NLS-1$ lastTimePrinted = now; } diff --git a/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java b/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java index 73140fdc50..47f115a999 100644 --- a/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java +++ b/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java @@ -65,6 +65,7 @@ public class MapRenderingTypes { private Map amenityNameToType = null; private MapRulType nameRuleType; + private MapRulType coastlineRuleType; public MapRenderingTypes(String fileName){ this.resourceName = fileName; @@ -86,7 +87,8 @@ public class MapRenderingTypes { typeList.clear(); nameRuleType = new MapRulType(); nameRuleType.tag = "name"; - nameRuleType.additional = true; + nameRuleType.onlyNameRef = true; + nameRuleType.additional = false; registerRuleType("name", null, nameRuleType); init(); } @@ -97,19 +99,25 @@ public class MapRenderingTypes { return typeList.get(id); } - private void registerRuleType(String tag, String val, MapRulType rt){ - rt.id = types.size(); + private MapRulType registerRuleType(String tag, String val, MapRulType rt){ String keyVal = constructRuleKey(tag, val); + if("natural".equals(tag) && "coastline".equals(val)) { + coastlineRuleType = rt; + } if(types.containsKey(keyVal)){ - if(types.get(keyVal).nameCreated ) { + if(types.get(keyVal).onlyNameRef ) { rt.id = types.get(keyVal).id; types.put(keyVal, rt); + typeList.set(rt.id, rt); + return rt; } else { throw new RuntimeException("Duplicate " + keyVal); } } else { + rt.id = types.size(); types.put(keyVal, rt); typeList.add(rt); + return rt; } } @@ -117,6 +125,10 @@ public class MapRenderingTypes { return nameRuleType; } + public MapRulType getCoastlineRuleType() { + return coastlineRuleType; + } + // if type equals 0 no need to save that point public boolean encodeEntityWithType(Entity e, int zoom, TIntArrayList outTypes, @@ -148,10 +160,12 @@ public class MapRenderingTypes { } } - if (rType.additional) { - outaddTypes.add(rType.id); - } else { - outTypes.add(rType.id); + if (!rType.onlyNameRef) { + if (rType.additional) { + outaddTypes.add(rType.id); + } else { + outTypes.add(rType.id); + } } } } @@ -244,7 +258,6 @@ public class MapRenderingTypes { } long time = System.currentTimeMillis(); final SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); - types = new LinkedHashMap(); parser.parse(is, new DefaultHandler(){ String poiParentCategory = null; @@ -287,8 +300,8 @@ public class MapRenderingTypes { if(mt == null){ mt = new MapRulType(); mt.tag = names[i]; - mt.additional = true; - mt.nameCreated = true; + mt.onlyNameRef = true; + mt.additional = false; registerRuleType(names[i], null, mt); } rtype.names[i] = mt; @@ -418,7 +431,7 @@ public class MapRenderingTypes { int minzoom; boolean additional; MapRulType targetTagValue; - boolean nameCreated; + boolean onlyNameRef; // inner id private int id; @@ -473,6 +486,10 @@ public class MapRenderingTypes { return additional; } + public boolean isOnlyNameRef() { + return onlyNameRef; + } + public int getFreq() { return freq; } @@ -481,6 +498,10 @@ public class MapRenderingTypes { return ++freq; } + @Override + public String toString() { + return tag + " " + value; + } } // TODO Move to Routing Attributes and finalize diff --git a/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml b/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml index 379d165fa2..97b6276eda 100644 --- a/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml +++ b/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml @@ -206,7 +206,7 @@ - + diff --git a/DataExtractionOSM/src/osmand_odb.proto b/DataExtractionOSM/src/osmand_odb.proto index 68eeb0cc0f..17c995ae16 100644 --- a/DataExtractionOSM/src/osmand_odb.proto +++ b/DataExtractionOSM/src/osmand_odb.proto @@ -97,13 +97,7 @@ message OsmAndMapIndex { repeated MapDataBox boxes = 7; - repeated MapDataBlocks blocks = 8; - } - - message MapDataBlocks { - // based coordinates can be specified - // for an array of blocks - repeated MapDataBlock block = 6; + repeated MapDataBlock blocks = 15; } message MapDataBox { @@ -133,10 +127,6 @@ message MapDataBlock { // in future here can be optional raster tile repeated MapData dataObjects = 12; - optional uint32 rasterType = 13; - - optional bytes rasterImage = 14; - optional StringTable stringTable = 15; @@ -157,9 +147,15 @@ message MapData { required bytes types = 7; // repeated array > - optional bytes stringNames = 10; // in parent blocku + optional bytes stringNames = 10; // in parent block + required sint64 id = 12; // delta encoded + + optional uint32 rasterTileX = 13; + optional uint32 rasterTileY = 14; + optional bytes rasterBytes = 15; + }