From 6b57c14326c27e9514031126e382e2ca1b14242f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 10 Oct 2012 00:11:21 +0200 Subject: [PATCH] Introduce base map route layer to check/test different routing mechanisms --- .../net/osmand/router/JUnitRouteTest.java | 2 + .../src/net/osmand/NativeLibrary.java | 8 +- .../osmand/binary/BinaryMapIndexReader.java | 5 +- .../binary/BinaryMapRouteReaderAdapter.java | 43 +- .../osmand/binary/CachedOsmandIndexes.java | 32 +- .../src/net/osmand/binary/OsmandIndex.java | 668 ++---------- .../src/net/osmand/binary/OsmandOdb.java | 355 ++++--- .../preparation/BinaryMapIndexWriter.java | 9 +- .../osmand/data/preparation/IndexCreator.java | 36 +- .../data/preparation/IndexRouteCreator.java | 997 ++++++++++++++++-- .../preparation/IndexVectorMapCreator.java | 2 +- .../src/net/osmand/osm/MapRoutingTypes.java | 78 +- .../src/net/osmand/osm/MapUtils.java | 23 + .../src/net/osmand/render/default.render.xml | 43 +- .../net/osmand/router/BinaryRoutePlanner.java | 36 +- .../src/net/osmand/router/RoutingContext.java | 9 +- .../src/net/osmand/router/routing.xml | 2 +- .../src/net/osmand/swing/MapRouterLayer.java | 68 +- DataExtractionOSM/src/osmand_index.proto | 2 + DataExtractionOSM/src/osmand_odb.proto | 5 +- .../extrasettings/OsmandExtraSettings.java | 13 - Osmand-kernel/expat/Android.mk | 1 + Osmand-kernel/osmand/src/binaryRead.cpp | 383 +++++-- Osmand-kernel/osmand/src/binaryRead.h | 13 +- Osmand-kernel/osmand/src/common.h | 2 + Osmand-kernel/osmand/src/java_renderRules.h | 1 + Osmand-kernel/osmand/src/java_wrap.cpp | 8 +- .../osmand/src/proto/osmand_index.pb.h | 56 +- .../osmand/src/proto/osmand_odb.pb.h | 306 +++--- Osmand-kernel/osmand/src/renderRules.cpp | 1 + Osmand-kernel/osmand/src/rendering.cpp | 4 +- Osmand-kernel/osmand/src/textdraw.cpp | 171 +-- 32 files changed, 2079 insertions(+), 1303 deletions(-) diff --git a/DataExtractionOSM/src-tests/net/osmand/router/JUnitRouteTest.java b/DataExtractionOSM/src-tests/net/osmand/router/JUnitRouteTest.java index b84ad80ebf..cf8ab7bc8a 100644 --- a/DataExtractionOSM/src-tests/net/osmand/router/JUnitRouteTest.java +++ b/DataExtractionOSM/src-tests/net/osmand/router/JUnitRouteTest.java @@ -24,6 +24,8 @@ public class JUnitRouteTest { static BinaryMapIndexReader[] rs; static NativeSwingRendering lib; + + @Before public void setupFiles() throws IOException { if(rs != null){ diff --git a/DataExtractionOSM/src/net/osmand/NativeLibrary.java b/DataExtractionOSM/src/net/osmand/NativeLibrary.java index b153c17620..be9c61d1a7 100644 --- a/DataExtractionOSM/src/net/osmand/NativeLibrary.java +++ b/DataExtractionOSM/src/net/osmand/NativeLibrary.java @@ -69,7 +69,11 @@ public class NativeLibrary { */ public NativeSearchResult searchObjectsForRendering(int sleft, int sright, int stop, int sbottom, int zoom, RenderingRuleSearchRequest request, boolean skipDuplicates, Object objectWithInterruptedField, String msgIfNothingFound) { - return new NativeSearchResult(searchNativeObjectsForRendering(sleft, sright, stop, sbottom, zoom, request, skipDuplicates, + int renderRouteDataFile = 0; + if(request.searchRenderingAttribute("showRoadMapsAttribute")){ + renderRouteDataFile = request.getIntPropertyValue(request.ALL.R_ATTR_INT_VALUE); + } + return new NativeSearchResult(searchNativeObjectsForRendering(sleft, sright, stop, sbottom, zoom, request, skipDuplicates, renderRouteDataFile, objectWithInterruptedField, msgIfNothingFound)); } @@ -127,6 +131,6 @@ public class NativeLibrary { boolean isTransparent, RenderingRuleSearchRequest render, boolean encodePng); protected static native long searchNativeObjectsForRendering(int sleft, int sright, int stop, int sbottom, int zoom, - RenderingRuleSearchRequest request, boolean skipDuplicates, Object objectWithInterruptedField, String msgIfNothingFound); + RenderingRuleSearchRequest request, boolean skipDuplicates, int renderRouteDataFile, Object objectWithInterruptedField, String msgIfNothingFound); } diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java index 41e477d49f..e529e69fa0 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java @@ -1959,9 +1959,6 @@ public class BinaryMapIndexReader { })); } - public void initRouteRegionsIfNeeded(SearchRequest req) throws IOException { - routeAdapter.initRouteTypesIfNeeded(req); - } public List searchRouteIndexTree(SearchRequest req, List list) throws IOException { req.numberOfVisitedObjects = 0; @@ -1969,7 +1966,7 @@ public class BinaryMapIndexReader { req.numberOfAcceptedSubtrees = 0; req.numberOfReadSubtrees = 0; if(routeAdapter != null){ - initRouteRegionsIfNeeded(req); + routeAdapter.initRouteTypesIfNeeded(req, list); return routeAdapter.searchRouteRegionTree(req, list, new ArrayList()); } return Collections.emptyList(); diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapRouteReaderAdapter.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapRouteReaderAdapter.java index 18209d40ff..9653846091 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapRouteReaderAdapter.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapRouteReaderAdapter.java @@ -158,6 +158,7 @@ public class BinaryMapRouteReaderAdapter { public int regionsRead; List subregions = new ArrayList(); + List basesubregions = new ArrayList(); List routeEncodingRules = new ArrayList(); int nameTypeRule = -1; int refTypeRule = -1; @@ -181,6 +182,10 @@ public class BinaryMapRouteReaderAdapter { public List getSubregions(){ return subregions; } + + public List getBaseSubregions(){ + return basesubregions; + } public double getLeftLongitude() { double l = 180; @@ -299,19 +304,28 @@ public class BinaryMapRouteReaderAdapter { codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); codedIS.popLimit(oldLimit); } break; - case OsmandOdb.OsmAndRoutingIndex.ROOTBOXES_FIELD_NUMBER : { + case OsmandOdb.OsmAndRoutingIndex.ROOTBOXES_FIELD_NUMBER : + case OsmandOdb.OsmAndRoutingIndex.BASEMAPBOXES_FIELD_NUMBER :{ RouteSubregion subregion = new RouteSubregion(region); subregion.length = readInt(); subregion.filePointer = codedIS.getTotalBytesRead(); int oldLimit = codedIS.pushLimit(subregion.length); readRouteTree(subregion, null, 0, true); - region.getSubregions().add(subregion); + if(tag == OsmandOdb.OsmAndRoutingIndex.ROOTBOXES_FIELD_NUMBER) { + region.subregions.add(subregion); + } else { + region.basesubregions.add(subregion); + } codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); codedIS.popLimit(oldLimit); - + break; + } + case OsmandOdb.OsmAndRoutingIndex.BLOCKS_FIELD_NUMBER : { // Finish reading file! codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); - } break; + break; + } + default: skipUnknownField(t); @@ -616,20 +630,13 @@ public class BinaryMapRouteReaderAdapter { } } - public void initRouteTypesIfNeeded(SearchRequest req) throws IOException{ - for(RouteRegion r: map.getRoutingIndexes() ) { - if (r.routeEncodingRules.isEmpty()) { - boolean intersect = false; - for (RouteSubregion rs : r.subregions) { - if (req.intersects(rs.left, rs.top, rs.right, rs.bottom)) { - intersect = true; - break; - } - } - if(intersect) { - codedIS.seek(r.filePointer); - int oldLimit = codedIS.pushLimit(r.length); - readRouteIndex(r); + public void initRouteTypesIfNeeded(SearchRequest req, List list) throws IOException { + for (RouteSubregion rs : list) { + if (req.intersects(rs.left, rs.top, rs.right, rs.bottom)) { + if (rs.routeReg.routeEncodingRules.isEmpty()) { + codedIS.seek(rs.routeReg.filePointer); + int oldLimit = codedIS.pushLimit(rs.routeReg.length); + readRouteIndex(rs.routeReg); codedIS.popLimit(oldLimit); } } diff --git a/DataExtractionOSM/src/net/osmand/binary/CachedOsmandIndexes.java b/DataExtractionOSM/src/net/osmand/binary/CachedOsmandIndexes.java index 4d7df93adc..38f90dac07 100644 --- a/DataExtractionOSM/src/net/osmand/binary/CachedOsmandIndexes.java +++ b/DataExtractionOSM/src/net/osmand/binary/CachedOsmandIndexes.java @@ -140,15 +140,10 @@ public class CachedOsmandIndexes { routing.setName(index.getName()); } for(RouteSubregion sub : index.getSubregions()) { - OsmandIndex.RoutingSubregion.Builder rpart = OsmandIndex.RoutingSubregion.newBuilder(); - rpart.setSize(sub.length); - rpart.setOffset(sub.filePointer); - rpart.setLeft(sub.left); - rpart.setRight(sub.right); - rpart.setTop(sub.top); - rpart.setBottom(sub.bottom); - rpart.setShifToData(sub.shiftToData); - routing.addSubregions(rpart); + addRouteSubregion(routing, sub, false); + } + for(RouteSubregion sub : index.getBaseSubregions()) { + addRouteSubregion(routing, sub, true); } fileIndex.addRoutingIndex(routing); } @@ -156,6 +151,19 @@ public class CachedOsmandIndexes { storedIndexBuilder.addFileIndex(fileIndex); } + + private void addRouteSubregion(RoutingPart.Builder routing, RouteSubregion sub, boolean base) { + OsmandIndex.RoutingSubregion.Builder rpart = OsmandIndex.RoutingSubregion.newBuilder(); + rpart.setSize(sub.length); + rpart.setOffset(sub.filePointer); + rpart.setLeft(sub.left); + rpart.setRight(sub.right); + rpart.setTop(sub.top); + rpart.setBasemap(base); + rpart.setBottom(sub.bottom); + rpart.setShifToData(sub.shiftToData); + routing.addSubregions(rpart); + } public BinaryMapIndexReader getReader(File f) throws IOException { RandomAccessFile mf = new RandomAccessFile(f, "r"); @@ -276,7 +284,11 @@ public class CachedOsmandIndexes { sub.top = mr.getTop(); sub.bottom = mr.getBottom(); sub.shiftToData = mr.getShifToData(); - mi.subregions.add(sub); + if(mr.getBasemap()) { + mi.basesubregions.add(sub); + } else { + mi.subregions.add(sub); + } } reader.routingIndexes.add(mi); reader.indexes.add(mi); diff --git a/DataExtractionOSM/src/net/osmand/binary/OsmandIndex.java b/DataExtractionOSM/src/net/osmand/binary/OsmandIndex.java index 98aa258495..cec2633676 100644 --- a/DataExtractionOSM/src/net/osmand/binary/OsmandIndex.java +++ b/DataExtractionOSM/src/net/osmand/binary/OsmandIndex.java @@ -6,10 +6,10 @@ package net.osmand.binary; public final class OsmandIndex { private OsmandIndex() {} public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { + com.google.protobuf.ExtensionRegistryLite registry) { } public static final class OsmAndStoredIndex extends - com.google.protobuf.GeneratedMessage { + com.google.protobuf.GeneratedMessageLite { // Use OsmAndStoredIndex.newBuilder() to construct. private OsmAndStoredIndex() { initFields(); @@ -26,17 +26,6 @@ public final class OsmandIndex { return defaultInstance; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return net.osmand.binary.OsmandIndex.internal_static_OsmAndStoredIndex_descriptor; - } - - @Override - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return net.osmand.binary.OsmandIndex.internal_static_OsmAndStoredIndex_fieldAccessorTable; - } - // required uint32 version = 1; public static final int VERSION_FIELD_NUMBER = 1; private boolean hasVersion; @@ -88,7 +77,6 @@ public final class OsmandIndex { if (hasDateCreated()) { output.writeInt64(18, getDateCreated()); } - getUnknownFields().writeTo(output); } private int memoizedSerializedSize = -1; @@ -110,7 +98,6 @@ public final class OsmandIndex { size += com.google.protobuf.CodedOutputStream .computeInt64Size(18, getDateCreated()); } - size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; } @@ -192,7 +179,8 @@ public final class OsmandIndex { public Builder toBuilder() { return newBuilder(this); } public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { + com.google.protobuf.GeneratedMessageLite.Builder< + net.osmand.binary.OsmandIndex.OsmAndStoredIndex, Builder> { private net.osmand.binary.OsmandIndex.OsmAndStoredIndex result; // Construct using net.osmand.binary.OsmandIndex.OsmAndStoredIndex.newBuilder() @@ -224,12 +212,6 @@ public final class OsmandIndex { return create().mergeFrom(result); } - @Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return net.osmand.binary.OsmandIndex.OsmAndStoredIndex.getDescriptor(); - } - @Override public net.osmand.binary.OsmandIndex.OsmAndStoredIndex getDefaultInstanceForType() { return net.osmand.binary.OsmandIndex.OsmAndStoredIndex.getDefaultInstance(); @@ -272,16 +254,7 @@ public final class OsmandIndex { } @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof net.osmand.binary.OsmandIndex.OsmAndStoredIndex) { - return mergeFrom((net.osmand.binary.OsmandIndex.OsmAndStoredIndex)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(net.osmand.binary.OsmandIndex.OsmAndStoredIndex other) { + public Builder mergeFrom(net.osmand.binary.OsmandIndex.OsmAndStoredIndex other) { if (other == net.osmand.binary.OsmandIndex.OsmAndStoredIndex.getDefaultInstance()) return this; if (other.hasVersion()) { setVersion(other.getVersion()); @@ -295,7 +268,6 @@ public final class OsmandIndex { } result.fileIndex_.addAll(other.fileIndex_); } - this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -304,19 +276,13 @@ public final class OsmandIndex { 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()); + if (!parseUnknownField(input, extensionRegistry, tag)) { return this; } break; @@ -440,7 +406,7 @@ public final class OsmandIndex { } public static final class FileIndex extends - com.google.protobuf.GeneratedMessage { + com.google.protobuf.GeneratedMessageLite { // Use FileIndex.newBuilder() to construct. private FileIndex() { initFields(); @@ -457,17 +423,6 @@ public final class OsmandIndex { return defaultInstance; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return net.osmand.binary.OsmandIndex.internal_static_FileIndex_descriptor; - } - - @Override - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return net.osmand.binary.OsmandIndex.internal_static_FileIndex_fieldAccessorTable; - } - // required int64 size = 1; public static final int SIZE_FIELD_NUMBER = 1; private boolean hasSize; @@ -613,7 +568,6 @@ public final class OsmandIndex { for (net.osmand.binary.OsmandIndex.RoutingPart element : getRoutingIndexList()) { output.writeMessage(12, element); } - getUnknownFields().writeTo(output); } private int memoizedSerializedSize = -1; @@ -659,7 +613,6 @@ public final class OsmandIndex { size += com.google.protobuf.CodedOutputStream .computeMessageSize(12, element); } - size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; } @@ -741,7 +694,8 @@ public final class OsmandIndex { public Builder toBuilder() { return newBuilder(this); } public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { + com.google.protobuf.GeneratedMessageLite.Builder< + net.osmand.binary.OsmandIndex.FileIndex, Builder> { private net.osmand.binary.OsmandIndex.FileIndex result; // Construct using net.osmand.binary.OsmandIndex.FileIndex.newBuilder() @@ -773,12 +727,6 @@ public final class OsmandIndex { return create().mergeFrom(result); } - @Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return net.osmand.binary.OsmandIndex.FileIndex.getDescriptor(); - } - @Override public net.osmand.binary.OsmandIndex.FileIndex getDefaultInstanceForType() { return net.osmand.binary.OsmandIndex.FileIndex.getDefaultInstance(); @@ -837,16 +785,7 @@ public final class OsmandIndex { } @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof net.osmand.binary.OsmandIndex.FileIndex) { - return mergeFrom((net.osmand.binary.OsmandIndex.FileIndex)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(net.osmand.binary.OsmandIndex.FileIndex other) { + public Builder mergeFrom(net.osmand.binary.OsmandIndex.FileIndex other) { if (other == net.osmand.binary.OsmandIndex.FileIndex.getDefaultInstance()) return this; if (other.hasSize()) { setSize(other.getSize()); @@ -890,7 +829,6 @@ public final class OsmandIndex { } result.routingIndex_.addAll(other.routingIndex_); } - this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -899,19 +837,13 @@ public final class OsmandIndex { 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()); + if (!parseUnknownField(input, extensionRegistry, tag)) { return this; } break; @@ -1310,7 +1242,7 @@ public final class OsmandIndex { } public static final class AddressPart extends - com.google.protobuf.GeneratedMessage { + com.google.protobuf.GeneratedMessageLite { // Use AddressPart.newBuilder() to construct. private AddressPart() { initFields(); @@ -1327,17 +1259,6 @@ public final class OsmandIndex { return defaultInstance; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return net.osmand.binary.OsmandIndex.internal_static_AddressPart_descriptor; - } - - @Override - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return net.osmand.binary.OsmandIndex.internal_static_AddressPart_fieldAccessorTable; - } - // required int64 size = 1; public static final int SIZE_FIELD_NUMBER = 1; private boolean hasSize; @@ -1419,7 +1340,6 @@ public final class OsmandIndex { for (net.osmand.binary.OsmandIndex.CityBlock element : getCitiesList()) { output.writeMessage(8, element); } - getUnknownFields().writeTo(output); } private int memoizedSerializedSize = -1; @@ -1453,7 +1373,6 @@ public final class OsmandIndex { size += com.google.protobuf.CodedOutputStream .computeMessageSize(8, element); } - size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; } @@ -1535,7 +1454,8 @@ public final class OsmandIndex { public Builder toBuilder() { return newBuilder(this); } public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { + com.google.protobuf.GeneratedMessageLite.Builder< + net.osmand.binary.OsmandIndex.AddressPart, Builder> { private net.osmand.binary.OsmandIndex.AddressPart result; // Construct using net.osmand.binary.OsmandIndex.AddressPart.newBuilder() @@ -1567,12 +1487,6 @@ public final class OsmandIndex { return create().mergeFrom(result); } - @Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return net.osmand.binary.OsmandIndex.AddressPart.getDescriptor(); - } - @Override public net.osmand.binary.OsmandIndex.AddressPart getDefaultInstanceForType() { return net.osmand.binary.OsmandIndex.AddressPart.getDefaultInstance(); @@ -1615,16 +1529,7 @@ public final class OsmandIndex { } @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof net.osmand.binary.OsmandIndex.AddressPart) { - return mergeFrom((net.osmand.binary.OsmandIndex.AddressPart)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(net.osmand.binary.OsmandIndex.AddressPart other) { + public Builder mergeFrom(net.osmand.binary.OsmandIndex.AddressPart other) { if (other == net.osmand.binary.OsmandIndex.AddressPart.getDefaultInstance()) return this; if (other.hasSize()) { setSize(other.getSize()); @@ -1647,7 +1552,6 @@ public final class OsmandIndex { } result.cities_.addAll(other.cities_); } - this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -1656,19 +1560,13 @@ public final class OsmandIndex { 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()); + if (!parseUnknownField(input, extensionRegistry, tag)) { return this; } break; @@ -1864,7 +1762,7 @@ public final class OsmandIndex { } public static final class CityBlock extends - com.google.protobuf.GeneratedMessage { + com.google.protobuf.GeneratedMessageLite { // Use CityBlock.newBuilder() to construct. private CityBlock() { initFields(); @@ -1881,17 +1779,6 @@ public final class OsmandIndex { return defaultInstance; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return net.osmand.binary.OsmandIndex.internal_static_CityBlock_descriptor; - } - - @Override - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return net.osmand.binary.OsmandIndex.internal_static_CityBlock_fieldAccessorTable; - } - // required int64 size = 1; public static final int SIZE_FIELD_NUMBER = 1; private boolean hasSize; @@ -1936,7 +1823,6 @@ public final class OsmandIndex { if (hasType()) { output.writeInt32(3, getType()); } - getUnknownFields().writeTo(output); } private int memoizedSerializedSize = -1; @@ -1958,7 +1844,6 @@ public final class OsmandIndex { size += com.google.protobuf.CodedOutputStream .computeInt32Size(3, getType()); } - size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; } @@ -2040,7 +1925,8 @@ public final class OsmandIndex { public Builder toBuilder() { return newBuilder(this); } public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { + com.google.protobuf.GeneratedMessageLite.Builder< + net.osmand.binary.OsmandIndex.CityBlock, Builder> { private net.osmand.binary.OsmandIndex.CityBlock result; // Construct using net.osmand.binary.OsmandIndex.CityBlock.newBuilder() @@ -2072,12 +1958,6 @@ public final class OsmandIndex { return create().mergeFrom(result); } - @Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return net.osmand.binary.OsmandIndex.CityBlock.getDescriptor(); - } - @Override public net.osmand.binary.OsmandIndex.CityBlock getDefaultInstanceForType() { return net.osmand.binary.OsmandIndex.CityBlock.getDefaultInstance(); @@ -2116,16 +1996,7 @@ public final class OsmandIndex { } @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof net.osmand.binary.OsmandIndex.CityBlock) { - return mergeFrom((net.osmand.binary.OsmandIndex.CityBlock)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(net.osmand.binary.OsmandIndex.CityBlock other) { + public Builder mergeFrom(net.osmand.binary.OsmandIndex.CityBlock other) { if (other == net.osmand.binary.OsmandIndex.CityBlock.getDefaultInstance()) return this; if (other.hasSize()) { setSize(other.getSize()); @@ -2136,7 +2007,6 @@ public final class OsmandIndex { if (other.hasType()) { setType(other.getType()); } - this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -2145,19 +2015,13 @@ public final class OsmandIndex { 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()); + if (!parseUnknownField(input, extensionRegistry, tag)) { return this; } break; @@ -2246,7 +2110,7 @@ public final class OsmandIndex { } public static final class PoiPart extends - com.google.protobuf.GeneratedMessage { + com.google.protobuf.GeneratedMessageLite { // Use PoiPart.newBuilder() to construct. private PoiPart() { initFields(); @@ -2263,17 +2127,6 @@ public final class OsmandIndex { return defaultInstance; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return net.osmand.binary.OsmandIndex.internal_static_PoiPart_descriptor; - } - - @Override - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return net.osmand.binary.OsmandIndex.internal_static_PoiPart_fieldAccessorTable; - } - // required int64 size = 1; public static final int SIZE_FIELD_NUMBER = 1; private boolean hasSize; @@ -2361,7 +2214,6 @@ public final class OsmandIndex { if (hasBottom()) { output.writeInt32(7, getBottom()); } - getUnknownFields().writeTo(output); } private int memoizedSerializedSize = -1; @@ -2399,7 +2251,6 @@ public final class OsmandIndex { size += com.google.protobuf.CodedOutputStream .computeInt32Size(7, getBottom()); } - size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; } @@ -2481,7 +2332,8 @@ public final class OsmandIndex { public Builder toBuilder() { return newBuilder(this); } public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { + com.google.protobuf.GeneratedMessageLite.Builder< + net.osmand.binary.OsmandIndex.PoiPart, Builder> { private net.osmand.binary.OsmandIndex.PoiPart result; // Construct using net.osmand.binary.OsmandIndex.PoiPart.newBuilder() @@ -2513,12 +2365,6 @@ public final class OsmandIndex { return create().mergeFrom(result); } - @Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return net.osmand.binary.OsmandIndex.PoiPart.getDescriptor(); - } - @Override public net.osmand.binary.OsmandIndex.PoiPart getDefaultInstanceForType() { return net.osmand.binary.OsmandIndex.PoiPart.getDefaultInstance(); @@ -2557,16 +2403,7 @@ public final class OsmandIndex { } @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof net.osmand.binary.OsmandIndex.PoiPart) { - return mergeFrom((net.osmand.binary.OsmandIndex.PoiPart)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(net.osmand.binary.OsmandIndex.PoiPart other) { + public Builder mergeFrom(net.osmand.binary.OsmandIndex.PoiPart other) { if (other == net.osmand.binary.OsmandIndex.PoiPart.getDefaultInstance()) return this; if (other.hasSize()) { setSize(other.getSize()); @@ -2589,7 +2426,6 @@ public final class OsmandIndex { if (other.hasBottom()) { setBottom(other.getBottom()); } - this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -2598,19 +2434,13 @@ public final class OsmandIndex { 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()); + if (!parseUnknownField(input, extensionRegistry, tag)) { return this; } break; @@ -2790,7 +2620,7 @@ public final class OsmandIndex { } public static final class MapLevel extends - com.google.protobuf.GeneratedMessage { + com.google.protobuf.GeneratedMessageLite { // Use MapLevel.newBuilder() to construct. private MapLevel() { initFields(); @@ -2807,17 +2637,6 @@ public final class OsmandIndex { return defaultInstance; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return net.osmand.binary.OsmandIndex.internal_static_MapLevel_descriptor; - } - - @Override - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return net.osmand.binary.OsmandIndex.internal_static_MapLevel_fieldAccessorTable; - } - // required int64 size = 1; public static final int SIZE_FIELD_NUMBER = 1; private boolean hasSize; @@ -2915,7 +2734,6 @@ public final class OsmandIndex { if (hasMaxzoom()) { output.writeInt32(9, getMaxzoom()); } - getUnknownFields().writeTo(output); } private int memoizedSerializedSize = -1; @@ -2957,7 +2775,6 @@ public final class OsmandIndex { size += com.google.protobuf.CodedOutputStream .computeInt32Size(9, getMaxzoom()); } - size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; } @@ -3039,7 +2856,8 @@ public final class OsmandIndex { public Builder toBuilder() { return newBuilder(this); } public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { + com.google.protobuf.GeneratedMessageLite.Builder< + net.osmand.binary.OsmandIndex.MapLevel, Builder> { private net.osmand.binary.OsmandIndex.MapLevel result; // Construct using net.osmand.binary.OsmandIndex.MapLevel.newBuilder() @@ -3071,12 +2889,6 @@ public final class OsmandIndex { return create().mergeFrom(result); } - @Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return net.osmand.binary.OsmandIndex.MapLevel.getDescriptor(); - } - @Override public net.osmand.binary.OsmandIndex.MapLevel getDefaultInstanceForType() { return net.osmand.binary.OsmandIndex.MapLevel.getDefaultInstance(); @@ -3115,16 +2927,7 @@ public final class OsmandIndex { } @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof net.osmand.binary.OsmandIndex.MapLevel) { - return mergeFrom((net.osmand.binary.OsmandIndex.MapLevel)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(net.osmand.binary.OsmandIndex.MapLevel other) { + public Builder mergeFrom(net.osmand.binary.OsmandIndex.MapLevel other) { if (other == net.osmand.binary.OsmandIndex.MapLevel.getDefaultInstance()) return this; if (other.hasSize()) { setSize(other.getSize()); @@ -3150,7 +2953,6 @@ public final class OsmandIndex { if (other.hasMaxzoom()) { setMaxzoom(other.getMaxzoom()); } - this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -3159,19 +2961,13 @@ public final class OsmandIndex { 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()); + if (!parseUnknownField(input, extensionRegistry, tag)) { return this; } break; @@ -3370,7 +3166,7 @@ public final class OsmandIndex { } public static final class MapPart extends - com.google.protobuf.GeneratedMessage { + com.google.protobuf.GeneratedMessageLite { // Use MapPart.newBuilder() to construct. private MapPart() { initFields(); @@ -3387,17 +3183,6 @@ public final class OsmandIndex { return defaultInstance; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return net.osmand.binary.OsmandIndex.internal_static_MapPart_descriptor; - } - - @Override - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return net.osmand.binary.OsmandIndex.internal_static_MapPart_fieldAccessorTable; - } - // required int64 size = 1; public static final int SIZE_FIELD_NUMBER = 1; private boolean hasSize; @@ -3459,7 +3244,6 @@ public final class OsmandIndex { for (net.osmand.binary.OsmandIndex.MapLevel element : getLevelsList()) { output.writeMessage(5, element); } - getUnknownFields().writeTo(output); } private int memoizedSerializedSize = -1; @@ -3485,7 +3269,6 @@ public final class OsmandIndex { size += com.google.protobuf.CodedOutputStream .computeMessageSize(5, element); } - size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; } @@ -3567,7 +3350,8 @@ public final class OsmandIndex { public Builder toBuilder() { return newBuilder(this); } public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { + com.google.protobuf.GeneratedMessageLite.Builder< + net.osmand.binary.OsmandIndex.MapPart, Builder> { private net.osmand.binary.OsmandIndex.MapPart result; // Construct using net.osmand.binary.OsmandIndex.MapPart.newBuilder() @@ -3599,12 +3383,6 @@ public final class OsmandIndex { return create().mergeFrom(result); } - @Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return net.osmand.binary.OsmandIndex.MapPart.getDescriptor(); - } - @Override public net.osmand.binary.OsmandIndex.MapPart getDefaultInstanceForType() { return net.osmand.binary.OsmandIndex.MapPart.getDefaultInstance(); @@ -3647,16 +3425,7 @@ public final class OsmandIndex { } @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof net.osmand.binary.OsmandIndex.MapPart) { - return mergeFrom((net.osmand.binary.OsmandIndex.MapPart)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(net.osmand.binary.OsmandIndex.MapPart other) { + public Builder mergeFrom(net.osmand.binary.OsmandIndex.MapPart other) { if (other == net.osmand.binary.OsmandIndex.MapPart.getDefaultInstance()) return this; if (other.hasSize()) { setSize(other.getSize()); @@ -3673,7 +3442,6 @@ public final class OsmandIndex { } result.levels_.addAll(other.levels_); } - this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -3682,19 +3450,13 @@ public final class OsmandIndex { 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()); + if (!parseUnknownField(input, extensionRegistry, tag)) { return this; } break; @@ -3843,7 +3605,7 @@ public final class OsmandIndex { } public static final class RoutingSubregion extends - com.google.protobuf.GeneratedMessage { + com.google.protobuf.GeneratedMessageLite { // Use RoutingSubregion.newBuilder() to construct. private RoutingSubregion() { initFields(); @@ -3860,17 +3622,6 @@ public final class OsmandIndex { return defaultInstance; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return net.osmand.binary.OsmandIndex.internal_static_RoutingSubregion_descriptor; - } - - @Override - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return net.osmand.binary.OsmandIndex.internal_static_RoutingSubregion_fieldAccessorTable; - } - // required int64 size = 1; public static final int SIZE_FIELD_NUMBER = 1; private boolean hasSize; @@ -3885,6 +3636,13 @@ public final class OsmandIndex { public boolean hasOffset() { return hasOffset; } public long getOffset() { return offset_; } + // required bool basemap = 3; + public static final int BASEMAP_FIELD_NUMBER = 3; + private boolean hasBasemap; + private boolean basemap_ = false; + public boolean hasBasemap() { return hasBasemap; } + public boolean getBasemap() { return basemap_; } + // required int32 left = 4; public static final int LEFT_FIELD_NUMBER = 4; private boolean hasLeft; @@ -3926,6 +3684,7 @@ public final class OsmandIndex { public final boolean isInitialized() { if (!hasSize) return false; if (!hasOffset) return false; + if (!hasBasemap) return false; if (!hasLeft) return false; if (!hasRight) return false; if (!hasTop) return false; @@ -3944,6 +3703,9 @@ public final class OsmandIndex { if (hasOffset()) { output.writeInt64(2, getOffset()); } + if (hasBasemap()) { + output.writeBool(3, getBasemap()); + } if (hasLeft()) { output.writeInt32(4, getLeft()); } @@ -3959,7 +3721,6 @@ public final class OsmandIndex { if (hasShifToData()) { output.writeUInt32(8, getShifToData()); } - getUnknownFields().writeTo(output); } private int memoizedSerializedSize = -1; @@ -3977,6 +3738,10 @@ public final class OsmandIndex { size += com.google.protobuf.CodedOutputStream .computeInt64Size(2, getOffset()); } + if (hasBasemap()) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(3, getBasemap()); + } if (hasLeft()) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(4, getLeft()); @@ -3997,7 +3762,6 @@ public final class OsmandIndex { size += com.google.protobuf.CodedOutputStream .computeUInt32Size(8, getShifToData()); } - size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; } @@ -4079,7 +3843,8 @@ public final class OsmandIndex { public Builder toBuilder() { return newBuilder(this); } public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { + com.google.protobuf.GeneratedMessageLite.Builder< + net.osmand.binary.OsmandIndex.RoutingSubregion, Builder> { private net.osmand.binary.OsmandIndex.RoutingSubregion result; // Construct using net.osmand.binary.OsmandIndex.RoutingSubregion.newBuilder() @@ -4111,12 +3876,6 @@ public final class OsmandIndex { return create().mergeFrom(result); } - @Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return net.osmand.binary.OsmandIndex.RoutingSubregion.getDescriptor(); - } - @Override public net.osmand.binary.OsmandIndex.RoutingSubregion getDefaultInstanceForType() { return net.osmand.binary.OsmandIndex.RoutingSubregion.getDefaultInstance(); @@ -4155,16 +3914,7 @@ public final class OsmandIndex { } @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof net.osmand.binary.OsmandIndex.RoutingSubregion) { - return mergeFrom((net.osmand.binary.OsmandIndex.RoutingSubregion)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(net.osmand.binary.OsmandIndex.RoutingSubregion other) { + public Builder mergeFrom(net.osmand.binary.OsmandIndex.RoutingSubregion other) { if (other == net.osmand.binary.OsmandIndex.RoutingSubregion.getDefaultInstance()) return this; if (other.hasSize()) { setSize(other.getSize()); @@ -4172,6 +3922,9 @@ public final class OsmandIndex { if (other.hasOffset()) { setOffset(other.getOffset()); } + if (other.hasBasemap()) { + setBasemap(other.getBasemap()); + } if (other.hasLeft()) { setLeft(other.getLeft()); } @@ -4187,7 +3940,6 @@ public final class OsmandIndex { if (other.hasShifToData()) { setShifToData(other.getShifToData()); } - this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -4196,19 +3948,13 @@ public final class OsmandIndex { 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()); + if (!parseUnknownField(input, extensionRegistry, tag)) { return this; } break; @@ -4221,6 +3967,10 @@ public final class OsmandIndex { setOffset(input.readInt64()); break; } + case 24: { + setBasemap(input.readBool()); + break; + } case 32: { setLeft(input.readInt32()); break; @@ -4282,6 +4032,24 @@ public final class OsmandIndex { return this; } + // required bool basemap = 3; + public boolean hasBasemap() { + return result.hasBasemap(); + } + public boolean getBasemap() { + return result.getBasemap(); + } + public Builder setBasemap(boolean value) { + result.hasBasemap = true; + result.basemap_ = value; + return this; + } + public Builder clearBasemap() { + result.hasBasemap = false; + result.basemap_ = false; + return this; + } + // required int32 left = 4; public boolean hasLeft() { return result.hasLeft(); @@ -4385,7 +4153,7 @@ public final class OsmandIndex { } public static final class RoutingPart extends - com.google.protobuf.GeneratedMessage { + com.google.protobuf.GeneratedMessageLite { // Use RoutingPart.newBuilder() to construct. private RoutingPart() { initFields(); @@ -4402,17 +4170,6 @@ public final class OsmandIndex { return defaultInstance; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return net.osmand.binary.OsmandIndex.internal_static_RoutingPart_descriptor; - } - - @Override - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return net.osmand.binary.OsmandIndex.internal_static_RoutingPart_fieldAccessorTable; - } - // required int64 size = 1; public static final int SIZE_FIELD_NUMBER = 1; private boolean hasSize; @@ -4474,7 +4231,6 @@ public final class OsmandIndex { for (net.osmand.binary.OsmandIndex.RoutingSubregion element : getSubregionsList()) { output.writeMessage(5, element); } - getUnknownFields().writeTo(output); } private int memoizedSerializedSize = -1; @@ -4500,7 +4256,6 @@ public final class OsmandIndex { size += com.google.protobuf.CodedOutputStream .computeMessageSize(5, element); } - size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; } @@ -4582,7 +4337,8 @@ public final class OsmandIndex { public Builder toBuilder() { return newBuilder(this); } public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { + com.google.protobuf.GeneratedMessageLite.Builder< + net.osmand.binary.OsmandIndex.RoutingPart, Builder> { private net.osmand.binary.OsmandIndex.RoutingPart result; // Construct using net.osmand.binary.OsmandIndex.RoutingPart.newBuilder() @@ -4614,12 +4370,6 @@ public final class OsmandIndex { return create().mergeFrom(result); } - @Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return net.osmand.binary.OsmandIndex.RoutingPart.getDescriptor(); - } - @Override public net.osmand.binary.OsmandIndex.RoutingPart getDefaultInstanceForType() { return net.osmand.binary.OsmandIndex.RoutingPart.getDefaultInstance(); @@ -4662,16 +4412,7 @@ public final class OsmandIndex { } @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof net.osmand.binary.OsmandIndex.RoutingPart) { - return mergeFrom((net.osmand.binary.OsmandIndex.RoutingPart)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(net.osmand.binary.OsmandIndex.RoutingPart other) { + public Builder mergeFrom(net.osmand.binary.OsmandIndex.RoutingPart other) { if (other == net.osmand.binary.OsmandIndex.RoutingPart.getDefaultInstance()) return this; if (other.hasSize()) { setSize(other.getSize()); @@ -4688,7 +4429,6 @@ public final class OsmandIndex { } result.subregions_.addAll(other.subregions_); } - this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -4697,19 +4437,13 @@ public final class OsmandIndex { 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()); + if (!parseUnknownField(input, extensionRegistry, tag)) { return this; } break; @@ -4858,7 +4592,7 @@ public final class OsmandIndex { } public static final class TransportPart extends - com.google.protobuf.GeneratedMessage { + com.google.protobuf.GeneratedMessageLite { // Use TransportPart.newBuilder() to construct. private TransportPart() { initFields(); @@ -4875,17 +4609,6 @@ public final class OsmandIndex { return defaultInstance; } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return net.osmand.binary.OsmandIndex.internal_static_TransportPart_descriptor; - } - - @Override - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return net.osmand.binary.OsmandIndex.internal_static_TransportPart_fieldAccessorTable; - } - // required int64 size = 1; public static final int SIZE_FIELD_NUMBER = 1; private boolean hasSize; @@ -5009,7 +4732,6 @@ public final class OsmandIndex { if (hasStopsTableLength()) { output.writeUInt32(11, getStopsTableLength()); } - getUnknownFields().writeTo(output); } private int memoizedSerializedSize = -1; @@ -5063,7 +4785,6 @@ public final class OsmandIndex { size += com.google.protobuf.CodedOutputStream .computeUInt32Size(11, getStopsTableLength()); } - size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; } @@ -5145,7 +4866,8 @@ public final class OsmandIndex { public Builder toBuilder() { return newBuilder(this); } public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { + com.google.protobuf.GeneratedMessageLite.Builder< + net.osmand.binary.OsmandIndex.TransportPart, Builder> { private net.osmand.binary.OsmandIndex.TransportPart result; // Construct using net.osmand.binary.OsmandIndex.TransportPart.newBuilder() @@ -5177,12 +4899,6 @@ public final class OsmandIndex { return create().mergeFrom(result); } - @Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return net.osmand.binary.OsmandIndex.TransportPart.getDescriptor(); - } - @Override public net.osmand.binary.OsmandIndex.TransportPart getDefaultInstanceForType() { return net.osmand.binary.OsmandIndex.TransportPart.getDefaultInstance(); @@ -5221,16 +4937,7 @@ public final class OsmandIndex { } @Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof net.osmand.binary.OsmandIndex.TransportPart) { - return mergeFrom((net.osmand.binary.OsmandIndex.TransportPart)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(net.osmand.binary.OsmandIndex.TransportPart other) { + public Builder mergeFrom(net.osmand.binary.OsmandIndex.TransportPart other) { if (other == net.osmand.binary.OsmandIndex.TransportPart.getDefaultInstance()) return this; if (other.hasSize()) { setSize(other.getSize()); @@ -5265,7 +4972,6 @@ public final class OsmandIndex { if (other.hasStopsTableLength()) { setStopsTableLength(other.getStopsTableLength()); } - this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -5274,19 +4980,13 @@ public final class OsmandIndex { 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()); + if (!parseUnknownField(input, extensionRegistry, tag)) { return this; } break; @@ -5553,194 +5253,8 @@ public final class OsmandIndex { // @@protoc_insertion_point(class_scope:TransportPart) } - private static com.google.protobuf.Descriptors.Descriptor - internal_static_OsmAndStoredIndex_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_OsmAndStoredIndex_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_FileIndex_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_FileIndex_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_AddressPart_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_AddressPart_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_CityBlock_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_CityBlock_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_PoiPart_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_PoiPart_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_MapLevel_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_MapLevel_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_MapPart_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_MapPart_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_RoutingSubregion_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_RoutingSubregion_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_RoutingPart_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_RoutingPart_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_TransportPart_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_TransportPart_fieldAccessorTable; - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; static { - java.lang.String[] descriptorData = { - "\n(DataExtractionOSM/src/osmand_index.pro" + - "to\"X\n\021OsmAndStoredIndex\022\017\n\007version\030\001 \002(\r" + - "\022\023\n\013dateCreated\030\022 \002(\003\022\035\n\tfileIndex\030\007 \003(\013" + - "2\n.FileIndex\"\372\001\n\tFileIndex\022\014\n\004size\030\001 \002(\003" + - "\022\024\n\014dateModified\030\002 \002(\003\022\020\n\010fileName\030\003 \002(\t" + - "\022\017\n\007version\030\004 \002(\005\022\"\n\014addressIndex\030\010 \003(\0132" + - "\014.AddressPart\022&\n\016transportIndex\030\t \003(\0132\016." + - "TransportPart\022\032\n\010poiIndex\030\n \003(\0132\010.PoiPar" + - "t\022\032\n\010mapIndex\030\013 \003(\0132\010.MapPart\022\"\n\014routing" + - "Index\030\014 \003(\0132\014.RoutingPart\"~\n\013AddressPart", - "\022\014\n\004size\030\001 \002(\003\022\016\n\006offset\030\002 \002(\003\022\014\n\004name\030\003" + - " \001(\t\022\016\n\006nameEn\030\004 \001(\t\022\027\n\017indexNameOffset\030" + - "\005 \001(\005\022\032\n\006cities\030\010 \003(\0132\n.CityBlock\"7\n\tCit" + - "yBlock\022\014\n\004size\030\001 \002(\003\022\016\n\006offset\030\002 \002(\003\022\014\n\004" + - "type\030\003 \002(\005\"o\n\007PoiPart\022\014\n\004size\030\001 \002(\003\022\016\n\006o" + - "ffset\030\002 \002(\003\022\014\n\004name\030\003 \001(\t\022\014\n\004left\030\004 \002(\005\022" + - "\r\n\005right\030\005 \002(\005\022\013\n\003top\030\006 \002(\005\022\016\n\006bottom\030\007 " + - "\002(\005\"\204\001\n\010MapLevel\022\014\n\004size\030\001 \002(\003\022\016\n\006offset" + - "\030\002 \002(\003\022\014\n\004left\030\004 \002(\005\022\r\n\005right\030\005 \002(\005\022\013\n\003t" + - "op\030\006 \002(\005\022\016\n\006bottom\030\007 \002(\005\022\017\n\007minzoom\030\010 \001(", - "\005\022\017\n\007maxzoom\030\t \001(\005\"P\n\007MapPart\022\014\n\004size\030\001 " + - "\002(\003\022\016\n\006offset\030\002 \002(\003\022\014\n\004name\030\003 \001(\t\022\031\n\006lev" + - "els\030\005 \003(\0132\t.MapLevel\"~\n\020RoutingSubregion" + - "\022\014\n\004size\030\001 \002(\003\022\016\n\006offset\030\002 \002(\003\022\014\n\004left\030\004" + - " \002(\005\022\r\n\005right\030\005 \002(\005\022\013\n\003top\030\006 \002(\005\022\016\n\006bott" + - "om\030\007 \002(\005\022\022\n\nshifToData\030\010 \002(\r\"`\n\013RoutingP" + - "art\022\014\n\004size\030\001 \002(\003\022\016\n\006offset\030\002 \002(\003\022\014\n\004nam" + - "e\030\003 \001(\t\022%\n\nsubregions\030\005 \003(\0132\021.RoutingSub" + - "region\"\337\001\n\rTransportPart\022\014\n\004size\030\001 \002(\003\022\016" + - "\n\006offset\030\002 \002(\003\022\014\n\004name\030\003 \001(\t\022\014\n\004left\030\004 \001", - "(\005\022\r\n\005right\030\005 \001(\005\022\013\n\003top\030\006 \001(\005\022\016\n\006bottom" + - "\030\007 \001(\005\022\031\n\021stringTableOffset\030\010 \001(\r\022\031\n\021str" + - "ingTableLength\030\t \001(\r\022\030\n\020stopsTableOffset" + - "\030\n \001(\r\022\030\n\020stopsTableLength\030\013 \001(\rB\023\n\021net." + - "osmand.binary" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - @Override - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - internal_static_OsmAndStoredIndex_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_OsmAndStoredIndex_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_OsmAndStoredIndex_descriptor, - new java.lang.String[] { "Version", "DateCreated", "FileIndex", }, - net.osmand.binary.OsmandIndex.OsmAndStoredIndex.class, - net.osmand.binary.OsmandIndex.OsmAndStoredIndex.Builder.class); - internal_static_FileIndex_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_FileIndex_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_FileIndex_descriptor, - new java.lang.String[] { "Size", "DateModified", "FileName", "Version", "AddressIndex", "TransportIndex", "PoiIndex", "MapIndex", "RoutingIndex", }, - net.osmand.binary.OsmandIndex.FileIndex.class, - net.osmand.binary.OsmandIndex.FileIndex.Builder.class); - internal_static_AddressPart_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_AddressPart_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_AddressPart_descriptor, - new java.lang.String[] { "Size", "Offset", "Name", "NameEn", "IndexNameOffset", "Cities", }, - net.osmand.binary.OsmandIndex.AddressPart.class, - net.osmand.binary.OsmandIndex.AddressPart.Builder.class); - internal_static_CityBlock_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_CityBlock_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_CityBlock_descriptor, - new java.lang.String[] { "Size", "Offset", "Type", }, - net.osmand.binary.OsmandIndex.CityBlock.class, - net.osmand.binary.OsmandIndex.CityBlock.Builder.class); - internal_static_PoiPart_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_PoiPart_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_PoiPart_descriptor, - new java.lang.String[] { "Size", "Offset", "Name", "Left", "Right", "Top", "Bottom", }, - net.osmand.binary.OsmandIndex.PoiPart.class, - net.osmand.binary.OsmandIndex.PoiPart.Builder.class); - internal_static_MapLevel_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_MapLevel_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_MapLevel_descriptor, - new java.lang.String[] { "Size", "Offset", "Left", "Right", "Top", "Bottom", "Minzoom", "Maxzoom", }, - net.osmand.binary.OsmandIndex.MapLevel.class, - net.osmand.binary.OsmandIndex.MapLevel.Builder.class); - internal_static_MapPart_descriptor = - getDescriptor().getMessageTypes().get(6); - internal_static_MapPart_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_MapPart_descriptor, - new java.lang.String[] { "Size", "Offset", "Name", "Levels", }, - net.osmand.binary.OsmandIndex.MapPart.class, - net.osmand.binary.OsmandIndex.MapPart.Builder.class); - internal_static_RoutingSubregion_descriptor = - getDescriptor().getMessageTypes().get(7); - internal_static_RoutingSubregion_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_RoutingSubregion_descriptor, - new java.lang.String[] { "Size", "Offset", "Left", "Right", "Top", "Bottom", "ShifToData", }, - net.osmand.binary.OsmandIndex.RoutingSubregion.class, - net.osmand.binary.OsmandIndex.RoutingSubregion.Builder.class); - internal_static_RoutingPart_descriptor = - getDescriptor().getMessageTypes().get(8); - internal_static_RoutingPart_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_RoutingPart_descriptor, - new java.lang.String[] { "Size", "Offset", "Name", "Subregions", }, - net.osmand.binary.OsmandIndex.RoutingPart.class, - net.osmand.binary.OsmandIndex.RoutingPart.Builder.class); - internal_static_TransportPart_descriptor = - getDescriptor().getMessageTypes().get(9); - internal_static_TransportPart_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_TransportPart_descriptor, - new java.lang.String[] { "Size", "Offset", "Name", "Left", "Right", "Top", "Bottom", "StringTableOffset", "StringTableLength", "StopsTableOffset", "StopsTableLength", }, - net.osmand.binary.OsmandIndex.TransportPart.class, - net.osmand.binary.OsmandIndex.TransportPart.Builder.class); - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); } public static void internalForceInit() {} diff --git a/DataExtractionOSM/src/net/osmand/binary/OsmandOdb.java b/DataExtractionOSM/src/net/osmand/binary/OsmandOdb.java index 29e7f4004d..c11cc0d497 100644 --- a/DataExtractionOSM/src/net/osmand/binary/OsmandOdb.java +++ b/DataExtractionOSM/src/net/osmand/binary/OsmandOdb.java @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: src/osmand_odb.proto +// source: DataExtractionOSM/src/osmand_odb.proto package net.osmand.binary; @@ -20994,6 +20994,18 @@ public final class OsmandOdb { return rootBoxes_.get(index); } + // repeated .OsmAndRoutingIndex.RouteDataBox basemapBoxes = 4; + public static final int BASEMAPBOXES_FIELD_NUMBER = 4; + private java.util.List basemapBoxes_ = + java.util.Collections.emptyList(); + public java.util.List getBasemapBoxesList() { + return basemapBoxes_; + } + public int getBasemapBoxesCount() { return basemapBoxes_.size(); } + public net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox getBasemapBoxes(int index) { + return basemapBoxes_.get(index); + } + // repeated .OsmAndRoutingIndex.RouteDataBlock blocks = 5; public static final int BLOCKS_FIELD_NUMBER = 5; private java.util.List blocks_ = @@ -21017,6 +21029,9 @@ public final class OsmandOdb { for (net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox element : getRootBoxesList()) { if (!element.isInitialized()) return false; } + for (net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox element : getBasemapBoxesList()) { + if (!element.isInitialized()) return false; + } for (net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock element : getBlocksList()) { if (!element.isInitialized()) return false; } @@ -21036,6 +21051,9 @@ public final class OsmandOdb { for (net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox element : getRootBoxesList()) { output.writeMessage(3, element); } + for (net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox element : getBasemapBoxesList()) { + output.writeMessage(4, element); + } for (net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock element : getBlocksList()) { output.writeMessage(5, element); } @@ -21061,6 +21079,10 @@ public final class OsmandOdb { size += com.google.protobuf.CodedOutputStream .computeMessageSize(3, element); } + for (net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox element : getBasemapBoxesList()) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, element); + } for (net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock element : getBlocksList()) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(5, element); @@ -21225,6 +21247,10 @@ public final class OsmandOdb { result.rootBoxes_ = java.util.Collections.unmodifiableList(result.rootBoxes_); } + if (result.basemapBoxes_ != java.util.Collections.EMPTY_LIST) { + result.basemapBoxes_ = + java.util.Collections.unmodifiableList(result.basemapBoxes_); + } if (result.blocks_ != java.util.Collections.EMPTY_LIST) { result.blocks_ = java.util.Collections.unmodifiableList(result.blocks_); @@ -21261,6 +21287,12 @@ public final class OsmandOdb { } result.rootBoxes_.addAll(other.rootBoxes_); } + if (!other.basemapBoxes_.isEmpty()) { + if (result.basemapBoxes_.isEmpty()) { + result.basemapBoxes_ = new java.util.ArrayList(); + } + result.basemapBoxes_.addAll(other.basemapBoxes_); + } if (!other.blocks_.isEmpty()) { if (result.blocks_.isEmpty()) { result.blocks_ = new java.util.ArrayList(); @@ -21309,6 +21341,12 @@ public final class OsmandOdb { addRootBoxes(subBuilder.buildPartial()); break; } + case 34: { + net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox.Builder subBuilder = net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox.newBuilder(); + input.readMessage(subBuilder, extensionRegistry); + addBasemapBoxes(subBuilder.buildPartial()); + break; + } case 42: { net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock.Builder subBuilder = net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock.newBuilder(); input.readMessage(subBuilder, extensionRegistry); @@ -21443,6 +21481,57 @@ public final class OsmandOdb { return this; } + // repeated .OsmAndRoutingIndex.RouteDataBox basemapBoxes = 4; + public java.util.List getBasemapBoxesList() { + return java.util.Collections.unmodifiableList(result.basemapBoxes_); + } + public int getBasemapBoxesCount() { + return result.getBasemapBoxesCount(); + } + public net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox getBasemapBoxes(int index) { + return result.getBasemapBoxes(index); + } + public Builder setBasemapBoxes(int index, net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox value) { + if (value == null) { + throw new NullPointerException(); + } + result.basemapBoxes_.set(index, value); + return this; + } + public Builder setBasemapBoxes(int index, net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox.Builder builderForValue) { + result.basemapBoxes_.set(index, builderForValue.build()); + return this; + } + public Builder addBasemapBoxes(net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox value) { + if (value == null) { + throw new NullPointerException(); + } + if (result.basemapBoxes_.isEmpty()) { + result.basemapBoxes_ = new java.util.ArrayList(); + } + result.basemapBoxes_.add(value); + return this; + } + public Builder addBasemapBoxes(net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox.Builder builderForValue) { + if (result.basemapBoxes_.isEmpty()) { + result.basemapBoxes_ = new java.util.ArrayList(); + } + result.basemapBoxes_.add(builderForValue.build()); + return this; + } + public Builder addAllBasemapBoxes( + java.lang.Iterable values) { + if (result.basemapBoxes_.isEmpty()) { + result.basemapBoxes_ = new java.util.ArrayList(); + } + super.addAll(values, result.basemapBoxes_); + return this; + } + public Builder clearBasemapBoxes() { + result.basemapBoxes_ = java.util.Collections.emptyList(); + return this; + } + // repeated .OsmAndRoutingIndex.RouteDataBlock blocks = 5; public java.util.List getBlocksList() { return java.util.Collections.unmodifiableList(result.blocks_); @@ -21725,136 +21814,138 @@ public final class OsmandOdb { descriptor; static { java.lang.String[] descriptorData = { - "\n\024src/osmand_odb.proto\"\232\002\n\017OsmAndStructu" + - "re\022\017\n\007version\030\001 \002(\r\022\023\n\013dateCreated\030\022 \002(\003" + - "\022)\n\014addressIndex\030\007 \003(\0132\023.OsmAndAddressIn" + - "dex\022-\n\016transportIndex\030\004 \003(\0132\025.OsmAndTran" + - "sportIndex\022!\n\010poiIndex\030\010 \003(\0132\017.OsmAndPoi" + - "Index\022!\n\010mapIndex\030\006 \003(\0132\017.OsmAndMapIndex" + - "\022)\n\014routingIndex\030\t \003(\0132\023.OsmAndRoutingIn" + - "dex\022\026\n\016versionConfirm\030 \002(\r\"I\n\rOsmAndTil" + - "eBox\022\014\n\004left\030\001 \002(\r\022\r\n\005right\030\002 \002(\r\022\013\n\003top" + - "\030\003 \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\tsubt" + - "ables\030\005 \003(\0132\023.IndexedStringTable\"\250\004\n\016Osm" + - "AndMapIndex\022\014\n\004name\030\002 \002(\t\022.\n\005rules\030\004 \003(\013" + - "2\037.OsmAndMapIndex.MapEncodingRule\022,\n\006lev" + - "els\030\005 \003(\0132\034.OsmAndMapIndex.MapRootLevel\032" + - "X\n\017MapEncodingRule\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\004t" + - "ype\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\005ri", - "ght\030\004 \002(\005\022\013\n\003top\030\005 \002(\005\022\016\n\006bottom\030\006 \002(\005\022)" + - "\n\005boxes\030\007 \003(\0132\032.OsmAndMapIndex.MapDataBo" + - "x\022\035\n\006blocks\030\017 \003(\0132\r.MapDataBlock\032\230\001\n\nMap" + - "DataBox\022\014\n\004left\030\001 \002(\021\022\r\n\005right\030\002 \002(\021\022\013\n\003" + - "top\030\003 \002(\021\022\016\n\006bottom\030\004 \002(\021\022\026\n\016shiftToMapD" + - "ata\030\005 \001(\007\022\r\n\005ocean\030\006 \001(\010\022)\n\005boxes\030\007 \003(\0132" + - "\032.OsmAndMapIndex.MapDataBox\"`\n\014MapDataBl" + - "ock\022\016\n\006baseId\030\n \001(\004\022\035\n\013dataObjects\030\014 \003(\013" + - "2\010.MapData\022!\n\013stringTable\030\017 \001(\0132\014.String" + - "Table\"\266\001\n\007MapData\022\023\n\013coordinates\030\001 \001(\014\022\027", - "\n\017areaCoordinates\030\002 \001(\014\022\037\n\027polygonInnerC" + - "oordinates\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\013rasterBytes\030\017 \001(\014\"\222\002\n\022OsmAn" + - "dAddressIndex\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.Ci" + - "tiesIndex\022.\n\tnameIndex\030\007 \001(\0132\033.OsmAndAdd" + - "ressNameIndexData\032X\n\013CitiesIndex\022\014\n\004type" + - "\030\002 \002(\r\022\032\n\006cities\030\005 \003(\0132\n.CityIndex\022\037\n\006bl", - "ocks\030\007 \003(\0132\017.CityBlockIndex\"\301\001\n\032OsmAndAd" + - "dressNameIndexData\022\"\n\005table\030\004 \002(\0132\023.Inde" + - "xedStringTable\022>\n\004atom\030\007 \003(\01320.OsmAndAdd" + - "ressNameIndexData.AddressNameIndexData\032?" + - "\n\024AddressNameIndexData\022\'\n\004atom\030\004 \003(\0132\031.A" + - "ddressNameIndexDataAtom\"v\n\030AddressNameIn" + - "dexDataAtom\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\t" + - "city_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\016CityB" + - "lockIndex\022\030\n\020shiftToCityIndex\030\004 \001(\007\022!\n\tb" + - "uildings\030\n \003(\0132\016.BuildingIndex\022\035\n\007street" + - "s\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(\013" + - "2\023.StreetIntersection\"_\n\022StreetIntersect" + - "ion\022\014\n\004name\030\002 \002(\t\022\017\n\007name_en\030\003 \001(\t\022\024\n\014in", - "tersectedX\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_e" + - "n\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\016Tran" + - "sportRoute\022\n\n\002id\030\001 \002(\004\022\014\n\004type\030\003 \001(\r\022\020\n\010" + - "operator\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\013", - "directStops\030\017 \003(\0132\023.TransportRouteStop\022)" + - "\n\014reverseStops\030\020 \003(\0132\023.TransportRouteSto" + - "p\"W\n\022TransportRouteStop\022\n\n\002id\030\001 \002(\022\022\n\n\002d" + - "x\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021\022\014\n\004name\030\006 \002(\r\022\017\n\007nam" + - "e_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\022Trans" + - "portStopsTree\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\010subtr" + - "ees\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\006" + - "routes\030\003 \001(\0132\020.TransportRoutes\022\"\n\005stops\030" + - "\006 \001(\0132\023.TransportStopsTree\022!\n\013stringTabl" + - "e\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.Osm" + - "AndTileBox\022-\n\017categoriesTable\030\003 \003(\0132\024.Os" + - "mAndCategoryTable\022&\n\tnameIndex\030\004 \001(\0132\023.O" + - "smAndPoiNameIndex\022\034\n\005boxes\030\006 \003(\0132\r.OsmAn" + - "dPoiBox\022\"\n\007poiData\030\t \003(\0132\021.OsmAndPoiBoxD", - "ata\"\270\001\n\022OsmAndPoiNameIndex\022\"\n\005table\030\003 \002(" + - "\0132\023.IndexedStringTable\0228\n\004data\030\005 \003(\0132*.O" + - "smAndPoiNameIndex.OsmAndPoiNameIndexData" + - "\032D\n\026OsmAndPoiNameIndexData\022*\n\005atoms\030\003 \003(" + - "\0132\033.OsmAndPoiNameIndexDataAtom\"Q\n\032OsmAnd" + - "PoiNameIndexDataAtom\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\023Osm" + - "AndCategoryTable\022\020\n\010category\030\001 \002(\t\022\025\n\rsu" + - "bcategories\030\003 \003(\t\"\227\001\n\014OsmAndPoiBox\022\014\n\004zo" + - "om\030\001 \002(\r\022\014\n\004left\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022(\n\nc", - "ategories\030\004 \001(\0132\024.OsmAndPoiCategories\022\037\n" + - "\010subBoxes\030\n \003(\0132\r.OsmAndPoiBox\022\023\n\013shiftT" + - "oData\030\016 \001(\007\")\n\023OsmAndPoiCategories\022\022\n\nca" + - "tegories\030\003 \003(\r\"^\n\020OsmAndPoiBoxData\022\014\n\004zo" + - "om\030\001 \001(\r\022\t\n\001x\030\002 \001(\r\022\t\n\001y\030\003 \001(\r\022&\n\007poiDat" + - "a\030\005 \003(\0132\025.OsmAndPoiBoxDataAtom\"\255\001\n\024OsmAn" + - "dPoiBoxDataAtom\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\006nam" + - "eEn\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(\t\"\032\n\007IdTable\022\017\n\007routeId\030\001 \003(\022\"F\n\017Re" + - "strictionData\022\014\n\004type\030\001 \002(\005\022\014\n\004from\030\002 \002(" + - "\005\022\n\n\002to\030\003 \002(\005\022\013\n\003via\030\004 \001(\005\"d\n\tRouteData\022" + - "\016\n\006points\030\001 \002(\014\022\022\n\npointTypes\030\004 \001(\014\022\r\n\005t" + - "ypes\030\007 \002(\014\022\017\n\007routeId\030\014 \002(\005\022\023\n\013stringNam" + - "es\030\016 \001(\014\"\251\004\n\022OsmAndRoutingIndex\022\014\n\004name\030" + - "\001 \002(\t\0224\n\005rules\030\002 \003(\0132%.OsmAndRoutingInde" + - "x.RouteEncodingRule\0223\n\trootBoxes\030\003 \003(\0132 " + - ".OsmAndRoutingIndex.RouteDataBox\0222\n\006bloc" + - "ks\030\005 \003(\0132\".OsmAndRoutingIndex.RouteDataB", - "lock\032;\n\021RouteEncodingRule\022\013\n\003tag\030\003 \002(\t\022\r" + - "\n\005value\030\005 \002(\t\022\n\n\002id\030\007 \001(\r\032\216\001\n\014RouteDataB" + - "ox\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\023\n\013shiftToData\030\005 \001(" + - "\007\022/\n\005boxes\030\007 \003(\0132 .OsmAndRoutingIndex.Ro" + - "uteDataBox\032\227\001\n\016RouteDataBlock\022\031\n\007idTable" + - "\030\005 \001(\0132\010.IdTable\022!\n\013stringTable\030\010 \001(\0132\014." + - "StringTable\022\037\n\013dataObjects\030\006 \003(\0132\n.Route" + - "Data\022&\n\014restrictions\030\007 \003(\0132\020.Restriction" + - "DataB\023\n\021net.osmand.binary" + "\n&DataExtractionOSM/src/osmand_odb.proto" + + "\"\232\002\n\017OsmAndStructure\022\017\n\007version\030\001 \002(\r\022\023\n" + + "\013dateCreated\030\022 \002(\003\022)\n\014addressIndex\030\007 \003(\013" + + "2\023.OsmAndAddressIndex\022-\n\016transportIndex\030" + + "\004 \003(\0132\025.OsmAndTransportIndex\022!\n\010poiIndex" + + "\030\010 \003(\0132\017.OsmAndPoiIndex\022!\n\010mapIndex\030\006 \003(" + + "\0132\017.OsmAndMapIndex\022)\n\014routingIndex\030\t \003(\013" + + "2\023.OsmAndRoutingIndex\022\026\n\016versionConfirm\030" + + " \002(\r\"I\n\rOsmAndTileBox\022\014\n\004left\030\001 \002(\r\022\r\n\005" + + "right\030\002 \002(\r\022\013\n\003top\030\003 \002(\r\022\016\n\006bottom\030\004 \002(\r", + "\"\030\n\013StringTable\022\t\n\001s\030\001 \003(\t\"f\n\022IndexedStr" + + "ingTable\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\tsubtables\030\005 \003(\0132\023.IndexedS" + + "tringTable\"\250\004\n\016OsmAndMapIndex\022\014\n\004name\030\002 " + + "\002(\t\022.\n\005rules\030\004 \003(\0132\037.OsmAndMapIndex.MapE" + + "ncodingRule\022,\n\006levels\030\005 \003(\0132\034.OsmAndMapI" + + "ndex.MapRootLevel\032X\n\017MapEncodingRule\022\013\n\003" + + "tag\030\003 \002(\t\022\r\n\005value\030\005 \001(\t\022\n\n\002id\030\007 \001(\r\022\017\n\007" + + "minZoom\030\t \001(\r\022\014\n\004type\030\n \001(\r\032\264\001\n\014MapRootL" + + "evel\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\005boxes\030\007 \003(\0132\032.OsmAnd" + + "MapIndex.MapDataBox\022\035\n\006blocks\030\017 \003(\0132\r.Ma" + + "pDataBlock\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.MapDa" + + "taBox\"`\n\014MapDataBlock\022\016\n\006baseId\030\n \001(\004\022\035\n" + + "\013dataObjects\030\014 \003(\0132\010.MapData\022!\n\013stringTa" + + "ble\030\017 \001(\0132\014.StringTable\"\266\001\n\007MapData\022\023\n\013c", + "oordinates\030\001 \001(\014\022\027\n\017areaCoordinates\030\002 \001(" + + "\014\022\037\n\027polygonInnerCoordinates\030\004 \003(\014\022\027\n\017ad" + + "ditionalTypes\030\006 \001(\014\022\r\n\005types\030\007 \002(\014\022\023\n\013st" + + "ringNames\030\n \001(\014\022\n\n\002id\030\014 \002(\022\022\023\n\013rasterByt" + + "es\030\017 \001(\014\"\222\002\n\022OsmAndAddressIndex\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.Osm" + + "AndAddressIndex.CitiesIndex\022.\n\tnameIndex" + + "\030\007 \001(\0132\033.OsmAndAddressNameIndexData\032X\n\013C" + + "itiesIndex\022\014\n\004type\030\002 \002(\r\022\032\n\006cities\030\005 \003(\013", + "2\n.CityIndex\022\037\n\006blocks\030\007 \003(\0132\017.CityBlock" + + "Index\"\301\001\n\032OsmAndAddressNameIndexData\022\"\n\005" + + "table\030\004 \002(\0132\023.IndexedStringTable\022>\n\004atom" + + "\030\007 \003(\01320.OsmAndAddressNameIndexData.Addr" + + "essNameIndexData\032?\n\024AddressNameIndexData" + + "\022\'\n\004atom\030\004 \003(\0132\031.AddressNameIndexDataAto" + + "m\"v\n\030AddressNameIndexDataAtom\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\014shi" + + "ftToIndex\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\004nam", + "e\030\002 \002(\t\022\017\n\007name_en\030\003 \001(\t\022\n\n\002id\030\004 \001(\004\022\t\n\001" + + "x\030\005 \002(\r\022\t\n\001y\030\006 \002(\r\022\035\n\025shiftToCityBlockIn" + + "dex\030\n \001(\007\"l\n\016CityBlockIndex\022\030\n\020shiftToCi" + + "tyIndex\030\004 \001(\007\022!\n\tbuildings\030\n \003(\0132\016.Build" + + "ingIndex\022\035\n\007streets\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\ri" + + "ntersections\030\005 \003(\0132\023.StreetIntersection\"" + + "_\n\022StreetIntersection\022\014\n\004name\030\002 \002(\t\022\017\n\007n", + "ame_en\030\003 \001(\t\022\024\n\014intersectedX\030\004 \002(\021\022\024\n\014in" + + "tersectedY\030\005 \002(\021\"\262\001\n\rBuildingIndex\022\014\n\004na" + + "me\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\002y" + + "2\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.Trans" + + "portRoute\"\317\001\n\016TransportRoute\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\010", + "distance\030\010 \001(\r\022(\n\013directStops\030\017 \003(\0132\023.Tr" + + "ansportRouteStop\022)\n\014reverseStops\030\020 \003(\0132\023" + + ".TransportRouteStop\"W\n\022TransportRouteSto" + + "p\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\rTranspor" + + "tStop\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\006rout" + + "es\030\020 \003(\r\"\244\001\n\022TransportStopsTree\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\006bot" + + "tom\030\004 \002(\021\022%\n\010subtrees\030\007 \003(\0132\023.TransportS", + "topsTree\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.Transpo" + + "rtRoutes\022\"\n\005stops\030\006 \001(\0132\023.TransportStops" + + "Tree\022!\n\013stringTable\030\t \002(\0132\014.StringTable\"" + + "\333\001\n\016OsmAndPoiIndex\022\014\n\004name\030\001 \002(\t\022\"\n\nboun" + + "daries\030\002 \002(\0132\016.OsmAndTileBox\022-\n\017categori" + + "esTable\030\003 \003(\0132\024.OsmAndCategoryTable\022&\n\tn" + + "ameIndex\030\004 \001(\0132\023.OsmAndPoiNameIndex\022\034\n\005b" + + "oxes\030\006 \003(\0132\r.OsmAndPoiBox\022\"\n\007poiData\030\t \003", + "(\0132\021.OsmAndPoiBoxData\"\270\001\n\022OsmAndPoiNameI" + + "ndex\022\"\n\005table\030\003 \002(\0132\023.IndexedStringTable" + + "\0228\n\004data\030\005 \003(\0132*.OsmAndPoiNameIndex.OsmA" + + "ndPoiNameIndexData\032D\n\026OsmAndPoiNameIndex" + + "Data\022*\n\005atoms\030\003 \003(\0132\033.OsmAndPoiNameIndex" + + "DataAtom\"Q\n\032OsmAndPoiNameIndexDataAtom\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\007sh" + + "iftTo\030\016 \001(\007\">\n\023OsmAndCategoryTable\022\020\n\010ca" + + "tegory\030\001 \002(\t\022\025\n\rsubcategories\030\003 \003(\t\"\227\001\n\014" + + "OsmAndPoiBox\022\014\n\004zoom\030\001 \002(\r\022\014\n\004left\030\002 \002(\021", + "\022\013\n\003top\030\003 \002(\021\022(\n\ncategories\030\004 \001(\0132\024.OsmA" + + "ndPoiCategories\022\037\n\010subBoxes\030\n \003(\0132\r.OsmA" + + "ndPoiBox\022\023\n\013shiftToData\030\016 \001(\007\")\n\023OsmAndP" + + "oiCategories\022\022\n\ncategories\030\003 \003(\r\"^\n\020OsmA" + + "ndPoiBoxData\022\014\n\004zoom\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.OsmAndPoiBox" + + "DataAtom\"\255\001\n\024OsmAndPoiBoxDataAtom\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\006nameEn\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\005p", + "hone\030\014 \001(\t\022\014\n\004note\030\r \001(\t\"\032\n\007IdTable\022\017\n\007r" + + "outeId\030\001 \003(\022\"F\n\017RestrictionData\022\014\n\004type\030" + + "\001 \002(\005\022\014\n\004from\030\002 \002(\005\022\n\n\002to\030\003 \002(\005\022\013\n\003via\030\004" + + " \001(\005\"d\n\tRouteData\022\016\n\006points\030\001 \002(\014\022\022\n\npoi" + + "ntTypes\030\004 \001(\014\022\r\n\005types\030\007 \002(\014\022\017\n\007routeId\030" + + "\014 \002(\005\022\023\n\013stringNames\030\016 \001(\014\"\341\004\n\022OsmAndRou" + + "tingIndex\022\014\n\004name\030\001 \002(\t\0224\n\005rules\030\002 \003(\0132%" + + ".OsmAndRoutingIndex.RouteEncodingRule\0223\n" + + "\trootBoxes\030\003 \003(\0132 .OsmAndRoutingIndex.Ro" + + "uteDataBox\0226\n\014basemapBoxes\030\004 \003(\0132 .OsmAn", + "dRoutingIndex.RouteDataBox\0222\n\006blocks\030\005 \003" + + "(\0132\".OsmAndRoutingIndex.RouteDataBlock\032;" + + "\n\021RouteEncodingRule\022\013\n\003tag\030\003 \002(\t\022\r\n\005valu" + + "e\030\005 \002(\t\022\n\n\002id\030\007 \001(\r\032\216\001\n\014RouteDataBox\022\014\n\004" + + "left\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\023\n\013shiftToData\030\005 \001(\007\022/\n\005b" + + "oxes\030\007 \003(\0132 .OsmAndRoutingIndex.RouteDat" + + "aBox\032\227\001\n\016RouteDataBlock\022\031\n\007idTable\030\005 \001(\013" + + "2\010.IdTable\022!\n\013stringTable\030\010 \001(\0132\014.String" + + "Table\022\037\n\013dataObjects\030\006 \003(\0132\n.RouteData\022&", + "\n\014restrictions\030\007 \003(\0132\020.RestrictionDataB\023" + + "\n\021net.osmand.binary" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -22171,7 +22262,7 @@ public final class OsmandOdb { internal_static_OsmAndRoutingIndex_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_OsmAndRoutingIndex_descriptor, - new java.lang.String[] { "Name", "Rules", "RootBoxes", "Blocks", }, + new java.lang.String[] { "Name", "Rules", "RootBoxes", "BasemapBoxes", "Blocks", }, net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.class, net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.Builder.class); internal_static_OsmAndRoutingIndex_RouteEncodingRule_descriptor = diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java b/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java index aab0133c4a..1cb50a8c5b 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java @@ -310,10 +310,15 @@ public class BinaryMapIndexWriter { } } - public BinaryFileReference startRouteTreeElement(int leftX, int rightX, int topY, int bottomY, boolean containsObjects) throws IOException { + public BinaryFileReference startRouteTreeElement(int leftX, int rightX, int topY, int bottomY, boolean containsObjects, + boolean basemap) throws IOException { checkPeekState(ROUTE_TREE, ROUTE_INDEX_INIT); if (state.peek() == ROUTE_INDEX_INIT) { - codedOutStream.writeTag(OsmAndRoutingIndex.ROOTBOXES_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED); + if(basemap) { + codedOutStream.writeTag(OsmAndRoutingIndex.BASEMAPBOXES_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED); + } else { + codedOutStream.writeTag(OsmAndRoutingIndex.ROOTBOXES_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED); + } } else { codedOutStream.writeTag(RouteDataBox.BOXES_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED); } diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java index 53429c3895..85a235fac7 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java @@ -597,10 +597,17 @@ public class IndexCreator { }); // 3.4 combine all low level ways and simplify them - if (indexMap) { + if (indexMap || indexRouting) { progress.setGeneralProgress("[90 / 100]"); - progress.startTask(Messages.getString("IndexCreator.INDEX_LO_LEVEL_WAYS"), indexMapCreator.getLowLevelWays()); - indexMapCreator.processingLowLevelWays(progress); + if(indexMap) { + progress.startTask(Messages.getString("IndexCreator.INDEX_LO_LEVEL_WAYS"), indexMapCreator.getLowLevelWays()); + indexMapCreator.processingLowLevelWays(progress); + } + if(indexRouting) { + progress.startTask(Messages.getString("IndexCreator.INDEX_LO_LEVEL_WAYS"), -1); + indexRouteCreator.processingLowLevelWays(progress); + } + } // 3.5 update all postal codes from relations @@ -734,26 +741,31 @@ public class IndexCreator { public static void main(String[] args) throws IOException, SAXException, SQLException, InterruptedException { long time = System.currentTimeMillis(); IndexCreator creator = new IndexCreator(new File("/home/victor/projects/OsmAnd/data/osm-gen/")); //$NON-NLS-1$ - creator.setIndexMap(true); - creator.setIndexAddress(true); - creator.setIndexPOI(true); - creator.setIndexTransport(true); +// creator.setIndexMap(true); +// creator.setIndexAddress(true); +// creator.setIndexPOI(true); +// creator.setInde xTransport(true); creator.setIndexRouting(true); // creator.deleteDatabaseIndexes = false; // creator.recreateOnlyBinaryFile = true; -// creator.deleteOsmDB = false; + creator.deleteOsmDB = false; creator.setZoomWaySmothness(2); MapRenderingTypes rt = MapRenderingTypes.getDefault(); MapZooms zooms = MapZooms.getDefault(); // MapZooms.parseZooms("15-"); - creator.setNodesDBFile(new File("/home/victor/projects/OsmAnd/data/osm-gen/nodes.tmp.odb")); - creator.generateIndexes(new File("/home/victor/projects/OsmAnd/temp/map.osm"), -// creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/osm-maps/luxembourg.osm.pbf"), -// creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/osm-maps/RU-SPE.osm.bz2"), + +// String file = "/home/victor/projects/OsmAnd/temp/map.osm"; + String file = "/home/victor/projects/OsmAnd/temp/belarus.osm.pbf"; +// String file = "/home/victor/projects/OsmAnd/temp/picardie.osm.pbf"; + int st = file.lastIndexOf('/'); + int e = file.indexOf('.', st); + creator.setNodesDBFile(new File("/home/victor/projects/OsmAnd/data/osm-gen/"+file.substring(st, e) + ".tmp.odb")); + creator.generateIndexes(new File(file), new ConsoleProgressImplementation(1), null, zooms, rt, log); + // BASEMAP generation // zooms = MapZooms.parseZooms("1-2;3;4-5;6-7;8-9;10-"); // creator.setMapFileName("World_basemap_2.obf"); diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexRouteCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexRouteCreator.java index f221469e3b..1a1cca90d3 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexRouteCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexRouteCreator.java @@ -1,8 +1,13 @@ package net.osmand.data.preparation; +import gnu.trove.TIntCollection; +import gnu.trove.iterator.TIntIterator; import gnu.trove.list.array.TIntArrayList; import gnu.trove.list.array.TLongArrayList; +import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.map.hash.TLongObjectHashMap; +import gnu.trove.set.hash.TIntHashSet; +import gnu.trove.set.hash.TLongHashSet; import java.io.ByteArrayOutputStream; import java.io.File; @@ -13,21 +18,32 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; import net.osmand.Algoritms; +import net.osmand.IProgress; import net.osmand.binary.OsmandOdb.IdTable; import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock; import net.osmand.binary.OsmandOdb.RestrictionData; import net.osmand.binary.OsmandOdb.RestrictionData.Builder; import net.osmand.binary.OsmandOdb.RouteData; +import net.osmand.data.MapAlgorithms; import net.osmand.data.preparation.BinaryMapIndexWriter.RoutePointToWrite; import net.osmand.osm.Entity; import net.osmand.osm.Entity.EntityId; import net.osmand.osm.Entity.EntityType; +import net.osmand.osm.LatLon; import net.osmand.osm.MapRenderingTypes; import net.osmand.osm.MapRoutingTypes; import net.osmand.osm.MapRoutingTypes.MapRouteType; @@ -53,19 +69,25 @@ public class IndexRouteCreator extends AbstractIndexPartCreator { private Connection mapConnection; private final Log logMapDataWarn; private final static boolean WRITE_POINT_ID = false; - private final static boolean WRITE_TEXT_TAGS = true; + private final static int CLUSTER_ZOOM = 15; private RTree routeTree = null; + private RTree baserouteTree = null; private MapRoutingTypes routeTypes; + private final static float DOUGLAS_PEUKER_DISTANCE = 15; + private TLongObjectHashMap highwayRestrictions = new TLongObjectHashMap(); // local purpose to speed up processing cache allocation TIntArrayList outTypes = new TIntArrayList(); TLongObjectHashMap pointTypes = new TLongObjectHashMap(); - Map names = new HashMap(); + Map names = new HashMap(); + + TLongObjectHashMap generalClusters = new TLongObjectHashMap(); private PreparedStatement mapRouteInsertStat; + private PreparedStatement basemapRouteInsertStat; public IndexRouteCreator(Log logMapDataWarn) { @@ -73,6 +95,159 @@ public class IndexRouteCreator extends AbstractIndexPartCreator { this.routeTypes = new MapRoutingTypes(); } + /*private*/ static class GeneralizedCluster { + public final int x; + public final int y; + public final int zoom; + + public GeneralizedCluster(int x, int y, int z){ + this.x = x; + this.y = y; + this.zoom = z; + } + + public final Set ways = new HashSet(); + // either LinkedList or GeneralizedWay + public final TLongObjectHashMap map = new TLongObjectHashMap(); + + public void replaceWayFromLocation(GeneralizedWay delete, int ind, GeneralizedWay toReplace){ + ways.remove(delete); + long loc = delete.getLocation(ind); + Object o = map.get(loc); + if(o instanceof GeneralizedWay){ + if(delete == o) { + map.put(loc, toReplace); + } else if(toReplace != o){ + addWay(toReplace, loc); + } + } else if(o instanceof LinkedList){ + ((LinkedList) o).remove(delete); + if(!((LinkedList) o).contains(toReplace)){ + ((LinkedList) o).add(toReplace); + } + } else { + map.put(loc, toReplace); + } + } + + public void removeWayFromLocation(GeneralizedWay delete, int ind){ + removeWayFromLocation(delete, ind, false); + } + public void removeWayFromLocation(GeneralizedWay delete, int ind, boolean deleteAll) { + long loc = delete.getLocation(ind); + boolean ex = false; + if (!deleteAll) { + for (int t = 0; t < delete.size(); t++) { + if (t != ind && map.containsKey(delete.getLocation(t))) { + ex = true; + break; + } + } + } + if (!ex || deleteAll) { + ways.remove(delete); + } + + Object o = map.get(loc); + if (o instanceof GeneralizedWay) { + if (delete == o) { + map.remove(loc); + } + } else if (o instanceof LinkedList) { + ((LinkedList) o).remove(delete); + if (((LinkedList) o).size() == 1) { + map.put(loc, ((LinkedList) o).iterator().next()); + } else if (((LinkedList) o).size() == 0) { + map.remove(loc); + } + } + } + + public void addWayFromLocation(GeneralizedWay w, int i) { + ways.add(w); + long loc = w.getLocation(i); + addWay(w, loc); + } + + private void addWay(GeneralizedWay w, long loc) { + + if (map.containsKey(loc)) { + Object o = map.get(loc); + if (o instanceof LinkedList) { + if(!((LinkedList) o).contains(w)){ + ((LinkedList) o).add(w); + } + } else if(o != w){ + LinkedList list = new LinkedList(); + list.add((GeneralizedWay) o); + list.add(w); + map.put(loc, list); + } + } else { + map.put(loc, w); + } + } + } + private static class GeneralizedWay { + private long id; + private int mainType; + private TIntHashSet addtypes = new TIntHashSet(); + private TIntArrayList px = new TIntArrayList(); + private TIntArrayList py = new TIntArrayList(); + + // TLongObjectHashMap pointTypes = new TLongObjectHashMap(); + private Map names = new HashMap(); + public GeneralizedWay(long id) { + this.id = id; + } + + public double getDistance() { + double dx = 0; + for (int i = 1; i < px.size(); i++) { + dx += MapUtils.getDistance(MapUtils.get31LatitudeY(py.get(i - 1)), MapUtils.get31LongitudeX(px.get(i - 1)), + MapUtils.get31LatitudeY(py.get(i)), MapUtils.get31LongitudeX(px.get(i))); + } + return dx; + } + + public long getLocation(int ind) { + return getBaseId(px.get(ind), py.get(ind)); + } + + public int size(){ + return px.size(); + } + + // Gives route direction of EAST degrees from NORTH ]-PI, PI] + public double directionRoute(int startPoint, boolean plus) { + float dist = 5; + int x = this.px.get(startPoint); + int y = this.py.get(startPoint); + int nx = startPoint; + int px = x; + int py = y; + double total = 0; + do { + if (plus) { + nx++; + if (nx >= size()) { + break; + } + } else { + nx--; + if (nx < 0) { + break; + } + } + px = this.px.get(nx); + py = this.py.get(nx); + // translate into meters + total += Math.abs(px - x) * 0.011d + Math.abs(py - y) * 0.01863d; + } while (total < dist); + return -Math.atan2( x - px, y - py ); + } + } + public void indexRelations(Entity e, OsmDbAccessorContext ctx) throws SQLException { indexHighwayRestrictions(e, ctx); } @@ -86,78 +261,137 @@ public class IndexRouteCreator extends AbstractIndexPartCreator { // Load point with tags! ctx.loadEntityWay(e); routeTypes.encodePointTypes(e, pointTypes); - boolean init = false; - int minX = Integer.MAX_VALUE; - int maxX = 0; - int minY = Integer.MAX_VALUE; - int maxY = 0; - - ByteArrayOutputStream bcoordinates = new ByteArrayOutputStream(); - ByteArrayOutputStream bpointIds = new ByteArrayOutputStream(); - ByteArrayOutputStream bpointTypes = new ByteArrayOutputStream(); - ByteArrayOutputStream btypes = new ByteArrayOutputStream(); - - try { - for (int j = 0; j < outTypes.size(); j++) { - Algoritms.writeSmallInt(btypes, outTypes.get(j)); - } - - for (Node n : e.getNodes()) { - if (n != null) { - // write id - Algoritms.writeLongInt(bpointIds, n.getId()); - // write point type - TIntArrayList types = pointTypes.get(n.getId()); - if (types != null) { - for (int j = 0; j < types.size(); j++) { - Algoritms.writeSmallInt(bpointTypes, types.get(j)); - } - } - Algoritms.writeSmallInt(bpointTypes, 0); - // write coordinates - int y = MapUtils.get31TileNumberY(n.getLatitude()); - int x = MapUtils.get31TileNumberX(n.getLongitude()); - minX = Math.min(minX, x); - maxX = Math.max(maxX, x); - minY = Math.min(minY, y); - maxY = Math.max(maxY, y); - init = true; - Algoritms.writeInt(bcoordinates, x); - Algoritms.writeInt(bcoordinates, y); - } - } - - } catch (IOException est) { - throw new IllegalStateException(est); - } - if (init) { - // conn.prepareStatement("insert into route_objects(id, types, pointTypes, pointIds, pointCoordinates, name) values(?, ?, ?, ?, ?, ?, ?)"); - mapRouteInsertStat.setLong(1, e.getId()); - mapRouteInsertStat.setBytes(2, btypes.toByteArray()); - mapRouteInsertStat.setBytes(3, bpointTypes.toByteArray()); - mapRouteInsertStat.setBytes(4, bpointIds.toByteArray()); - mapRouteInsertStat.setBytes(5, bcoordinates.toByteArray()); - if(WRITE_TEXT_TAGS) { - mapRouteInsertStat.setString(6, encodeNames(names)); - } else { - mapRouteInsertStat.setString(6, ""); - } - - addBatch(mapRouteInsertStat, false); - try { - routeTree.insert(new LeafElement(new Rect(minX, minY, maxX, maxY), e.getId())); - } catch (RTreeInsertException e1) { - throw new IllegalArgumentException(e1); - } catch (IllegalValueException e1) { - throw new IllegalArgumentException(e1); - } - } - + addWayToIndex(e.getId(), e.getNodes(), mapRouteInsertStat, routeTree); + generalizeWay(e); } } } + private void addWayToIndex(long id, List nodes, PreparedStatement insertStat, RTree rTree) throws SQLException { + boolean init = false; + int minX = Integer.MAX_VALUE; + int maxX = 0; + int minY = Integer.MAX_VALUE; + int maxY = 0; + + + ByteArrayOutputStream bcoordinates = new ByteArrayOutputStream(); + ByteArrayOutputStream bpointIds = new ByteArrayOutputStream(); + ByteArrayOutputStream bpointTypes = new ByteArrayOutputStream(); + ByteArrayOutputStream btypes = new ByteArrayOutputStream(); + + try { + for (int j = 0; j < outTypes.size(); j++) { + Algoritms.writeSmallInt(btypes, outTypes.get(j)); + } + + for (Node n : nodes) { + if (n != null) { + // write id + Algoritms.writeLongInt(bpointIds, n.getId()); + // write point type + TIntArrayList types = pointTypes.get(n.getId()); + if (types != null) { + for (int j = 0; j < types.size(); j++) { + Algoritms.writeSmallInt(bpointTypes, types.get(j)); + } + } + Algoritms.writeSmallInt(bpointTypes, 0); + // write coordinates + int y = MapUtils.get31TileNumberY(n.getLatitude()); + int x = MapUtils.get31TileNumberX(n.getLongitude()); + minX = Math.min(minX, x); + maxX = Math.max(maxX, x); + minY = Math.min(minY, y); + maxY = Math.max(maxY, y); + init = true; + Algoritms.writeInt(bcoordinates, x); + Algoritms.writeInt(bcoordinates, y); + } + } + + } catch (IOException est) { + throw new IllegalStateException(est); + } + if (init) { + // conn.prepareStatement("insert into route_objects(id, types, pointTypes, pointIds, pointCoordinates, name) values(?, ?, ?, ?, ?, ?, ?)"); + insertStat.setLong(1, id); + insertStat.setBytes(2, btypes.toByteArray()); + insertStat.setBytes(3, bpointTypes.toByteArray()); + insertStat.setBytes(4, bpointIds.toByteArray()); + insertStat.setBytes(5, bcoordinates.toByteArray()); + insertStat.setString(6, encodeNames(names)); + + addBatch(insertStat, false); + try { + rTree.insert(new LeafElement(new Rect(minX, minY, maxX, maxY), id)); + } catch (RTreeInsertException e1) { + throw new IllegalArgumentException(e1); + } catch (IllegalValueException e1) { + throw new IllegalArgumentException(e1); + } + } + } + + private static long getBaseId(int x31, int y31) { + long x = x31; + long y = y31; + return (x << 31) + y; + } + + private GeneralizedCluster getCluster(GeneralizedWay gw, int ind, GeneralizedCluster helper) { + int x31 = gw.px.get(ind); + int y31 = gw.py.get(ind); + int xc = x31 >> (31 - CLUSTER_ZOOM); + int yc = y31 >> (31 - CLUSTER_ZOOM); + if(helper != null && helper.x == xc && + helper.y == yc) { + return helper; + } + long l = (((long)xc) << (CLUSTER_ZOOM+1)) + yc; + if(!generalClusters.containsKey(l)) { + generalClusters.put(l, new GeneralizedCluster(xc, yc, CLUSTER_ZOOM)); + } + return generalClusters.get(l); + } + + + public void generalizeWay(Way e) throws SQLException { + if (!routeTypes.encodeBaseEntity(e, outTypes, names) || e.getNodes().size() < 2) { + return; + } + List ns = e.getNodes(); + + GeneralizedWay w = new GeneralizedWay(e.getId()); + TIntArrayList px = w.px; + TIntArrayList py = w.py; + GeneralizedCluster cluster = null; + for (Node n : ns) { + if (n != null) { + int x31 = MapUtils.get31TileNumberX(n.getLongitude()); + int y31 = MapUtils.get31TileNumberY(n.getLatitude()); + px.add(x31); + py.add(y31); + } + } + if(w.size() < 2) { + return; + } + for (int i = 0; i < w.size(); i++) { + GeneralizedCluster ncluster = getCluster(w, i, cluster); + if (ncluster != cluster) { + cluster = ncluster; + } + ncluster.addWayFromLocation(w, i); + } + int mt = getMainType(outTypes); // routeTypes.getTypeByInternalId(mt) + outTypes.remove(mt); + w.mainType = mt; + w.addtypes.addAll(outTypes); + w.names.putAll(names); + } + private static final char SPECIAL_CHAR = ((char) 0x60000); protected String encodeNames(Map tempNames) { @@ -204,39 +438,54 @@ public class IndexRouteCreator extends AbstractIndexPartCreator { return r; } + private static final String TABLE_ROUTE = "route_objects"; + private static final String TABLE_BASEROUTE = "baseroute_objects"; + private static final String CREATETABLE = "(id bigint primary key, " + + "types binary, pointTypes binary, pointIds binary, pointCoordinates binary, name varchar(4096))"; + private static final String CREATE_IND = "_ind on route_objects (id)"; + private static final String SELECT_STAT = "SELECT types, pointTypes, pointIds, pointCoordinates, name FROM " +TABLE_ROUTE+" WHERE id = ?"; + private static final String SELECT_BASE_STAT = "SELECT types, pointTypes, pointIds, pointCoordinates, name FROM "+TABLE_BASEROUTE+" WHERE id = ?"; + private static final String INSERT_STAT = "(id, types, pointTypes, pointIds, pointCoordinates, name) values(?, ?, ?, ?, ?, ?)"; + public void createDatabaseStructure(Connection mapConnection, DBDialect dialect, String rtreeMapIndexNonPackFileName) throws SQLException, IOException { this.mapConnection = mapConnection; Statement stat = mapConnection.createStatement(); - stat.executeUpdate(CREATETABLE); - stat.executeUpdate(CREATE_IND); + stat.executeUpdate("create table " +TABLE_ROUTE + CREATETABLE); + stat.executeUpdate("create table " +TABLE_BASEROUTE + CREATETABLE); + stat.executeUpdate("create index " +TABLE_ROUTE + CREATE_IND); + stat.executeUpdate("create index " +TABLE_BASEROUTE + CREATE_IND); stat.close(); - mapRouteInsertStat = createStatementRouteObjInsert(mapConnection); + mapRouteInsertStat = createStatementRouteObjInsert(mapConnection, false); + basemapRouteInsertStat = createStatementRouteObjInsert(mapConnection, true); try { routeTree = new RTree(rtreeMapIndexNonPackFileName); + baserouteTree = new RTree(rtreeMapIndexNonPackFileName+"b"); } catch (RTreeException e) { throw new IOException(e); } pStatements.put(mapRouteInsertStat, 0); + pStatements.put(basemapRouteInsertStat, 0); } - private static final String CREATETABLE = "create table route_objects (id bigint primary key, " - + "types binary, pointTypes binary, pointIds binary, pointCoordinates binary, name varchar(4096))"; - private static final String CREATE_IND = "create index route_objects_ind on route_objects (id)"; - private static final String SELECT_STAT = "SELECT types, pointTypes, pointIds, pointCoordinates, name FROM route_objects WHERE id = ?"; - private static final String INSERT_STAT = "insert into route_objects(id, types, pointTypes, pointIds, pointCoordinates, name) values(?, ?, ?, ?, ?, ?)"; + - - private PreparedStatement createStatementRouteObjInsert(Connection conn) throws SQLException { - return conn.prepareStatement(INSERT_STAT); + private PreparedStatement createStatementRouteObjInsert(Connection conn, boolean basemap) throws SQLException { + return conn.prepareStatement("insert into " + ( basemap ? TABLE_BASEROUTE : TABLE_ROUTE) + INSERT_STAT); } public void commitAndCloseFiles(String rTreeMapIndexNonPackFileName, String rTreeMapIndexPackFileName, boolean deleteDatabaseIndexes) throws IOException, SQLException { - // delete map rtree files - if (routeTree != null) { - RandomAccessFile file = routeTree.getFileHdr().getFile(); + deleteRouteTreeFiles(rTreeMapIndexNonPackFileName, rTreeMapIndexPackFileName, deleteDatabaseIndexes, routeTree); + deleteRouteTreeFiles(rTreeMapIndexNonPackFileName+"b", rTreeMapIndexPackFileName+"b", deleteDatabaseIndexes, baserouteTree); + closeAllPreparedStatements(); + } + + private void deleteRouteTreeFiles(String rTreeMapIndexNonPackFileName, String rTreeMapIndexPackFileName, boolean deleteDatabaseIndexes, + RTree rte) throws IOException { + if (rte != null) { + RandomAccessFile file = rte.getFileHdr().getFile(); file.close(); if (rTreeMapIndexNonPackFileName != null) { File f = new File(rTreeMapIndexNonPackFileName); @@ -251,7 +500,6 @@ public class IndexRouteCreator extends AbstractIndexPartCreator { } } } - closeAllPreparedStatements(); } @@ -296,36 +544,31 @@ public class IndexRouteCreator extends AbstractIndexPartCreator { public void createRTreeFiles(String rTreeRouteIndexPackFileName) throws RTreeException { routeTree = new RTree(rTreeRouteIndexPackFileName); + baserouteTree = new RTree(rTreeRouteIndexPackFileName+"b"); } public void packRtreeFiles(String rTreeRouteIndexNonPackFileName, String rTreeRouteIndexPackFileName) throws IOException { routeTree = packRtreeFile(routeTree, rTreeRouteIndexNonPackFileName, rTreeRouteIndexPackFileName); - + baserouteTree = packRtreeFile(baserouteTree, rTreeRouteIndexNonPackFileName+"b", rTreeRouteIndexPackFileName+"b"); } public void writeBinaryRouteIndex(BinaryMapIndexWriter writer, String regionName) throws IOException, SQLException { closePreparedStatements(mapRouteInsertStat); + closePreparedStatements(basemapRouteInsertStat); mapConnection.commit(); + try { writer.startWriteRouteIndex(regionName); // write map encoding rules writer.writeRouteEncodingRules(routeTypes.getEncodingRuleTypes()); - - PreparedStatement selectData = mapConnection.prepareStatement(SELECT_STAT); - // write map levels and map index - TLongObjectHashMap treeHeader = new TLongObjectHashMap(); - long rootIndex = routeTree.getFileHdr().getRootIndex(); - rtree.Node root = routeTree.getReadNode(rootIndex); - Rect rootBounds = calcBounds(root); - if (rootBounds != null) { - writeBinaryRouteTree(root, rootBounds, routeTree, writer, treeHeader); - writeBinaryMapBlock(root, rootBounds, routeTree, writer, selectData, treeHeader, new LinkedHashMap(), - new LinkedHashMap()); - } - - selectData.close(); - + TLongObjectHashMap route = writeBinaryRouteIndexHeader(writer, + routeTree, false); + TLongObjectHashMap base = writeBinaryRouteIndexHeader(writer, + baserouteTree, true); + writeBinaryRouteIndexBlocks(writer, routeTree, false, route); + writeBinaryRouteIndexBlocks(writer, baserouteTree, true, base); + writer.endWriteRouteIndex(); writer.flush(); } catch (RTreeException e) { @@ -333,6 +576,545 @@ public class IndexRouteCreator extends AbstractIndexPartCreator { } } + private Node convertBaseToNode(long s) { + long x = s >> 31; + long y = s - (x << 31); + return new Node(MapUtils.get31LatitudeY((int) y), + MapUtils.get31LongitudeX((int) x), -1); + } + + private String baseOrderValues[] = new String[] { "trunk", "motorway", "ferry", "primary", "secondary", "tertiary", "residential", + "road", "cycleway", "living_street" }; + + private int getBaseOrderForType(int intType) { + if (intType == -1) { + return Integer.MAX_VALUE; + } + MapRouteType rt = routeTypes.getTypeByInternalId(intType); + int i = 0; + for (; i < baseOrderValues.length; i++) { + if (rt.getValue().startsWith(baseOrderValues[i])) { + return i; + } + } + return i; + } + + private int getMainType(TIntCollection types){ + if(types.isEmpty()){ + return -1; + } + TIntIterator tit = types./*keySet().*/iterator(); + int main = tit.next(); + while(tit.hasNext()){ + int rt = tit.next(); + if(getBaseOrderForType(rt) < getBaseOrderForType(main)) { + main = rt; + } + } + return main; + } + + public void getAdjacentRoads(GeneralizedCluster gcluster, GeneralizedWay gw, int i, Collection collection){ + gcluster = getCluster(gw, i, gcluster); + Object o = gcluster.map.get(gw.getLocation(i)); + if (o instanceof LinkedList) { + Iterator it = ((LinkedList) o).iterator(); + while (it.hasNext()) { + GeneralizedWay next = (GeneralizedWay) it.next(); + if (next.id != gw.id) { + collection.add(next); + } + } + } + } + + public int countAdjacentRoads(GeneralizedCluster gcluster, GeneralizedWay gw, int i){ + gcluster = getCluster(gw, i, gcluster); + Object o = gcluster.map.get(gw.getLocation(i)); + if (o instanceof LinkedList) { + Iterator it = ((LinkedList) o).iterator(); + int cnt = 0; + while (it.hasNext()) { + GeneralizedWay next = (GeneralizedWay) it.next(); + if (next.id != gw.id ) { + cnt++; + } + } + return cnt; + } else if(o instanceof GeneralizedWay) { + if(gw.id != ((GeneralizedWay)o).id){ + return 1; + } + } + return 0; + } + + + + public void processingLowLevelWays(IProgress progress) { + pointTypes.clear(); + Collection clusters = + new ArrayList(generalClusters.valueCollection()); + // 1. roundabouts + //BUGGY + processRoundabouts(clusters); + + // 2. way combination based + for(GeneralizedCluster cluster : clusters) { + ArrayList copy = new ArrayList(cluster.ways); + for(GeneralizedWay gw : copy) { + // already deleted + if(!cluster.ways.contains(gw)){ + continue; + } + attachWays(gw, true); + attachWays(gw, false); + } + } + + + // 3. Douglas peuker simplifications + douglasPeukerSimplificationStep(clusters); + + // 4. remove line duplication + removeSmall2RoadsConnectors(clusters); + + + // 5. write to db + TLongHashSet ids = new TLongHashSet(); + for (GeneralizedCluster cluster : clusters) { + for (GeneralizedWay gw : cluster.ways) { + if(ids.contains(gw.id)) { + continue; + } + ids.add(gw.id); + names.clear(); + Iterator> its = gw.names.entrySet().iterator(); + while (its.hasNext()) { + Entry e = its.next(); + if (e.getValue() != null) { + names.put(e.getKey(), e.getValue()); + } + } + ArrayList nodes = new ArrayList(); + if(gw.size() == 0) { + System.err.println(gw.id + " empty ? "); + continue; + } + Node prev = convertBaseToNode(gw.getLocation(0)); + nodes.add(prev); + for (int i = 0; i < gw.size(); i++) { + Node c = convertBaseToNode(gw.getLocation(i)); + prev = c; + nodes.add(c); + } + outTypes.clear(); + outTypes.add(gw.mainType); + outTypes.addAll(gw.addtypes); + try { + addWayToIndex(gw.id, nodes, basemapRouteInsertStat, baserouteTree); + } catch (SQLException e) { + throw new IllegalStateException(e); + } + } + } + } + + + + + private static double scalarMultiplication(double xA, double yA, double xB, double yB, double xC, double yC) { + // Scalar multiplication between (AB, AC) + double multiple = (xB - xA) * (xC - xA) + (yB- yA) * (yC -yA); + return multiple; + } + + public static LatLon getProjection(float y31, float x31, float fromy31, float fromx31, float toy31, float tox31) { + // not very accurate computation on sphere but for distances < 1000m it is ok + float mDist = (fromy31 - toy31) * (fromy31 - toy31) + (fromx31 - tox31) * (fromx31 - tox31); + float projection = (float) scalarMultiplication(fromy31, fromx31, toy31, tox31, y31, x31); + float prlat; + float prlon; + if (projection < 0) { + prlat = fromy31; + prlon = fromx31; + } else if (projection >= mDist) { + prlat = toy31; + prlon = tox31; + } else { + prlat = fromy31 + (toy31 - fromy31) * (projection / mDist); + prlon = fromx31 + (tox31 - fromx31) * (projection / mDist); + } + return new LatLon(prlat, prlon); + } + + private void simplifyDouglasPeucker(GeneralizedWay gw, float epsilon, Collection ints, int start, int end){ + double dmax = -1; + int index = -1; + for (int i = start + 1; i <= end - 1; i++) { + double d = orthogonalDistance(gw, start, end, gw.px.get(i), gw.py.get(i), false); + if (d > dmax) { + dmax = d; + index = i; + } + } + if(dmax >= epsilon){ + simplifyDouglasPeucker(gw, epsilon, ints, start, index); + simplifyDouglasPeucker(gw, epsilon, ints, index, end); + } else { + ints.add(end); + } + } + + private double orthogonalDistance(GeneralizedWay gn, int st, int end, int px, int py, boolean returnNanIfNoProjection){ + float fromy31 = gn.py.get(st); + float fromx31 = gn.px.get(st); + float toy31 = gn.py.get(end); + float tox31 = gn.px.get(end); + float mDist = (fromy31 - toy31) * (fromy31 - toy31) + (fromx31 - tox31) * (fromx31 - tox31); + float projection = (float) scalarMultiplication(fromy31, fromx31, toy31, tox31, py, px); + if (returnNanIfNoProjection && (projection < 0 || projection > mDist)) { + return Double.NaN; + } +// float projy31 = fromy31 + (toy31 - fromy31) * (projection / mDist); +// float projx31 = fromx31 + (tox31 - fromx31) * (projection / mDist); + double A = MapUtils.convert31XToMeters(px, fromx31); + double B = MapUtils.convert31YToMeters(py, fromy31); + double C = MapUtils.convert31XToMeters(tox31, fromx31); + double D = MapUtils.convert31YToMeters(toy31, fromy31); + return Math.abs(A * D - C * B) / Math.sqrt(C * C + D * D); + + } + + private void douglasPeukerSimplificationStep(Collection clusters){ + for(GeneralizedCluster cluster : clusters) { + ArrayList copy = new ArrayList(cluster.ways); + for(GeneralizedWay gw : copy) { + Set res = new HashSet(); + simplifyDouglasPeucker(gw, DOUGLAS_PEUKER_DISTANCE, res, 0, gw.size() - 1); + + int ind = 1; + int len = gw.size() - 1; + for(int j = 1; j < len; j++) { + if(!res.contains(j) && countAdjacentRoads(cluster, gw, ind) == 0) { + GeneralizedCluster gcluster = getCluster(gw, ind, cluster); + gcluster.removeWayFromLocation(gw, ind); + gw.px.removeAt(ind); + gw.py.removeAt(ind); + } else { + ind++; + } + } + } + } + } + + private int checkDistanceToLine(GeneralizedWay line, int start, boolean directionPlus, + int px, int py, double distThreshold) { + int j = start; + int next = directionPlus ? j + 1 : j - 1; + while (next >= 0 && next < line.size()) { + double od = orthogonalDistance(line, j, next, px, py, false); + if (od < distThreshold) { + return j; + } + j = next; + next = directionPlus ? j + 1 : j - 1; + } + return -1; + } + + private void removeLineDuplication(Collection clusters) { + for(GeneralizedCluster cluster : clusters) { + ArrayList copy = new ArrayList(cluster.ways); + for(GeneralizedWay gw : copy) { + // already deleted + if(!cluster.ways.contains(gw)){ + continue; + } + if(gw.size() > 2) { + float p = DOUGLAS_PEUKER_DISTANCE / 3; + for (GeneralizedWay gn : copy) { + int kmin = checkDistanceToLine(gn, 0, true, gw.px.get(0), + gw.py.get(0), p); + int knext = kmin; + boolean dir = true; + if(kmin >= 0) { + knext = checkDistanceToLine(gn, kmin, dir, gw.px.get(1), + gw.py.get(1), p); + if(knext < 0) { + dir = false; + knext = checkDistanceToLine(gn, kmin, dir, gw.px.get(1), + gw.py.get(1), p); + } + } + if(knext > 0){ + int prevk = kmin; + while (gw.size() > 1) { + prevk = checkDistanceToLine(gn, prevk, dir, gw.px.get(1), + gw.py.get(1), p); + if(prevk < 0){ + break; + } + removePointFromWayAndReplace(cluster, gw, 1, gn.px.get(prevk), gn.py.get(prevk)); + } + removePointFromWayAndReplace(cluster, gw, 0, gn.px.get(kmin), gn.py.get(kmin)); + break; + } + } + } + } + } + } + + + private void removePointFromWayAndReplace(GeneralizedCluster cluster, GeneralizedWay gw, int i, int x31, int y31) { + GeneralizedCluster gcluster = getCluster(gw, i, cluster); + Object o = gcluster.map.get(gw.getLocation(i)); + if (o instanceof LinkedList) { + Iterator it = ((LinkedList) o).iterator(); + while (it.hasNext()) { + GeneralizedWay next = (GeneralizedWay) it.next(); + replacePointWithAnotherPoint(gcluster, gw, x31, y31, i, next); + } + } else if (o instanceof GeneralizedWay) { + replacePointWithAnotherPoint(gcluster, gw, x31, y31, i, (GeneralizedWay) o); + } + gcluster.removeWayFromLocation(gw, i); + gw.px.removeAt(i); + gw.py.removeAt(i); + } + + + private void processRoundabouts(Collection clusters) { + for(GeneralizedCluster cluster : clusters) { + ArrayList copy = new ArrayList(cluster.ways); + for (GeneralizedWay gw : copy) { + // roundabout + GeneralizedCluster gcluster = cluster; + if (gw.getLocation(gw.size() - 1) == gw.getLocation(0) && cluster.ways.contains(gw)) { + removeWayAndSubstituteWithPoint(gw, gcluster); + } + } + } + } + + + + private void removeSmall2RoadsConnectors(Collection clusters) { + for(GeneralizedCluster cluster : clusters) { + ArrayList copy = new ArrayList(cluster.ways); + for (GeneralizedWay gw : copy) { + // roundabout + if (gw.getDistance() < 500) { + LinkedHashSet ll = new LinkedHashSet(); + for (int i = 0; i < gw.size(); i++) { + getAdjacentRoads(cluster, gw, i, ll); + } + if(ll.size() <= 1) { + removeGeneratedWay(gw, cluster); + } else if(ll.size() >= 2){ + boolean intersect = true; + while(ll.size() > 1 && intersect) { + Iterator it = ll.iterator(); + GeneralizedWay first = it.next(); + it.remove(); + + intersect = false; + LinkedHashSet ls = new LinkedHashSet(); + for(int j = 0; j< first.size(); j++) { + getAdjacentRoads(cluster, first, j, ls); + if(ls.containsAll(ll)) { + intersect = true; + break; + } + } + } + if(intersect) { + removeGeneratedWay(gw, cluster); + } + } + } + } + } + } + + + private void removeGeneratedWay(GeneralizedWay gw, GeneralizedCluster gcluster) { + for (int i = 0; i < gw.size(); i++) { + gcluster = getCluster(gw, i, gcluster); + gcluster.removeWayFromLocation(gw, i, true); + } + } + + + private void removeWayAndSubstituteWithPoint(GeneralizedWay gw, GeneralizedCluster gcluster) { + // calculate center location + long pxc = 0; + long pyc = 0; + for (int i = 0; i < gw.size(); i++) { + pxc += gw.px.get(i); + pyc += gw.py.get(i); + } + pxc /= gw.size(); + pyc /= gw.size(); + + // attach additional point to other roads + for (int i = 0; i < gw.size(); i++) { + gcluster = getCluster(gw, i, gcluster); + Object o = gcluster.map.get(gw.getLocation(i)); + // something attachedpxc + if (o instanceof LinkedList) { + Iterator it = ((LinkedList)o).iterator(); + while(it.hasNext()) { + GeneralizedWay next = (GeneralizedWay) it.next(); + replacePointWithAnotherPoint(gcluster, gw, (int) pxc, (int) pyc, i, next); + } + } else if (o instanceof GeneralizedWay) { + replacePointWithAnotherPoint(gcluster, gw, (int) pxc, (int) pyc, i, (GeneralizedWay) o); + } + } + // remove roundabout + removeGeneratedWay(gw, gcluster); + } + + private void replacePointWithAnotherPoint(GeneralizedCluster gcluster, GeneralizedWay gw, int pxc, int pyc, int i, GeneralizedWay next) { + if (next.id != gw.id) { + for (int j = 0; j < next.size(); j++) { + if (next.getLocation(j) == gw.getLocation(i)) { + if (j == next.size() - 1) { + next.px.add(pxc); + next.py.add(pyc); + gcluster = getCluster(next, next.size() - 1, gcluster); + gcluster.addWayFromLocation(next, next.size() - 1); + } else { + next.px.insert(j, pxc); + next.py.insert(j, pyc); + gcluster = getCluster(next, j, gcluster); + gcluster.addWayFromLocation(next, j); + } + break; + } + } + } + } + + private boolean compareRefs(GeneralizedWay gw, GeneralizedWay gn){ + String rf = gw.names.get(routeTypes.getRefRuleType()); + String rf2 = gn.names.get(routeTypes.getRefRuleType()); + if(rf != null && rf2 != null && !rf.equals(rf2)){ + return false; + } + return true; + } + + @SuppressWarnings("unchecked") + private GeneralizedWay selectBestWay(GeneralizedCluster cluster, GeneralizedWay gw, int ind) { + long loc = gw.getLocation(ind); + Object o = cluster.map.get(loc); + GeneralizedWay res = null; + if (o instanceof GeneralizedWay) { + if (o != gw) { + GeneralizedWay m = (GeneralizedWay) o; + if (m.id != gw.id && m.mainType == gw.mainType && compareRefs(gw, m)) { + return m; + } + + } + } else if (o instanceof LinkedList) { + LinkedList l = (LinkedList) o; + double bestDiff = Math.PI / 2; + for (GeneralizedWay m : l) { + if (m.id != gw.id && m.mainType == gw.mainType && compareRefs(gw, m)) { + double init = gw.directionRoute(ind, ind == 0); + double dir; + if (m.getLocation(0) == loc) { + dir = m.directionRoute(0, true); + } else if (m.getLocation(m.size() - 1) == loc) { + dir = m.directionRoute(m.size() - 1, false); + } else { + return null; + } + double angleDiff = Math.abs(MapUtils.alignAngleDifference(Math.PI + dir - init)); + if (angleDiff < bestDiff) { + bestDiff = angleDiff; + res = m; + } + } + } + } + return res; + } + + + private void attachWays(GeneralizedWay gw, boolean first) { + GeneralizedCluster cluster = null; + while(true) { + int ind = first? 0 : gw.size() - 1; + cluster = getCluster(gw, ind, cluster); + GeneralizedWay prev = selectBestWay(cluster, gw, ind); + if(prev == null) { + break; + } + for (int i = 0; i < prev.size(); i++) { + cluster = getCluster(prev, i, cluster); + cluster.replaceWayFromLocation(prev, i, gw); + } + gw.addtypes.addAll(prev.addtypes); + gw.names.putAll(prev.names); + TIntArrayList ax = first? prev.px : gw.px; + TIntArrayList ay = first? prev.py : gw.py; + TIntArrayList bx = !first? prev.px : gw.px; + TIntArrayList by = !first? prev.py : gw.py; + if(first) { + if(gw.getLocation(0) == prev.getLocation(0)) { + ax.reverse(); + ay.reverse(); + } + } else { + if(gw.getLocation(ind) == prev.getLocation(prev.size() - 1)) { + bx.reverse(); + by.reverse(); + } + } + bx.removeAt(0); + by.removeAt(0); + ax.addAll(bx); + ay.addAll(by); + gw.px = ax; + gw.py = ay; + } + } + + + private void writeBinaryRouteIndexBlocks(BinaryMapIndexWriter writer, RTree rte, boolean basemap, + TLongObjectHashMap treeHeader) throws IOException, SQLException, RTreeException { + + // write map levels and map index + long rootIndex = rte.getFileHdr().getRootIndex(); + rtree.Node root = rte.getReadNode(rootIndex); + Rect rootBounds = calcBounds(root); + if (rootBounds != null) { + PreparedStatement selectData = mapConnection.prepareStatement(basemap ? SELECT_BASE_STAT : SELECT_STAT); + writeBinaryMapBlock(root, rootBounds, rte, writer, selectData, treeHeader, new LinkedHashMap(), + new LinkedHashMap()); + selectData.close(); + } + } + + private TLongObjectHashMap writeBinaryRouteIndexHeader(BinaryMapIndexWriter writer, + RTree rte, boolean basemap) throws IOException, SQLException, RTreeException { + // write map levels and map index + TLongObjectHashMap treeHeader = new TLongObjectHashMap(); + long rootIndex = rte.getFileHdr().getRootIndex(); + rtree.Node root = rte.getReadNode(rootIndex); + Rect rootBounds = calcBounds(root); + if (rootBounds != null) { + writeBinaryRouteTree(root, rootBounds, rte, writer, treeHeader, basemap); + } + return treeHeader; + } private int registerId(TLongArrayList ids, long id) { for (int i = 0; i < ids.size(); i++) { @@ -344,7 +1126,7 @@ public class IndexRouteCreator extends AbstractIndexPartCreator { return ids.size() - 1; } - public void writeBinaryMapBlock(rtree.Node parent, Rect parentBounds, RTree r, BinaryMapIndexWriter writer, PreparedStatement selectData, + private 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(); @@ -445,7 +1227,8 @@ public class IndexRouteCreator extends AbstractIndexPartCreator { } } - public void writeBinaryRouteTree(rtree.Node parent, Rect re, RTree r, BinaryMapIndexWriter writer, TLongObjectHashMap bounds) + private void writeBinaryRouteTree(rtree.Node parent, Rect re, RTree r, BinaryMapIndexWriter writer, + TLongObjectHashMap bounds, boolean basemap) throws IOException, RTreeException { Element[] e = parent.getAllElements(); boolean containsLeaf = false; @@ -454,16 +1237,20 @@ public class IndexRouteCreator extends AbstractIndexPartCreator { containsLeaf = true; } } - BinaryFileReference ref = writer.startRouteTreeElement(re.getMinX(), re.getMaxX(), re.getMinY(), re.getMaxY(), containsLeaf); + BinaryFileReference ref = writer.startRouteTreeElement(re.getMinX(), re.getMaxX(), re.getMinY(), re.getMaxY(), containsLeaf, + basemap); if (ref != null) { bounds.put(parent.getNodeIndex(), ref); } for (int i = 0; i < parent.getTotalElements(); i++) { if (e[i].getElementType() != rtree.Node.LEAF_NODE) { rtree.Node chNode = r.getReadNode(((NonLeafElement) e[i]).getPtr()); - writeBinaryRouteTree(chNode, e[i].getRect(), r, writer, bounds); + writeBinaryRouteTree(chNode, e[i].getRect(), r, writer, bounds, basemap); } } writer.endRouteTreeElement(); - } + } + + + } diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java index 76870b884e..76dc37bce8 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java @@ -382,7 +382,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { } - private static boolean checkForSmallAreas(List nodes, int zoom, int minz, int maxz) { + public static boolean checkForSmallAreas(List nodes, int zoom, int minz, int maxz) { int minX = Integer.MAX_VALUE; int maxX = Integer.MIN_VALUE; int minY = Integer.MAX_VALUE; diff --git a/DataExtractionOSM/src/net/osmand/osm/MapRoutingTypes.java b/DataExtractionOSM/src/net/osmand/osm/MapRoutingTypes.java index 7d0ea63979..3ecea8ab10 100644 --- a/DataExtractionOSM/src/net/osmand/osm/MapRoutingTypes.java +++ b/DataExtractionOSM/src/net/osmand/osm/MapRoutingTypes.java @@ -11,12 +11,16 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import net.osmand.osm.MapRoutingTypes.MapRouteType; + public class MapRoutingTypes { private static Set TAGS_TO_SAVE = new HashSet(); private static Set TAGS_TO_ACCEPT = new HashSet(); private static Set TAGS_TEXT = new HashSet(); + private static Set BASE_TAGS_TEXT = new HashSet(); + private static Set BASE_TAGS_TO_SAVE = new HashSet(); private static char TAG_DELIMETER = '/'; //$NON-NLS-1$ static { TAGS_TO_ACCEPT.add("highway"); @@ -24,6 +28,12 @@ public class MapRoutingTypes { TAGS_TO_ACCEPT.add("cycleway"); TAGS_TO_ACCEPT.add("route"); + BASE_TAGS_TEXT.add("int_ref"); + BASE_TAGS_TEXT.add("ref"); + + BASE_TAGS_TO_SAVE.add("toll"); + BASE_TAGS_TO_SAVE.add("maxspeed"); + // TEXT tags TAGS_TEXT.add("int_ref"); TAGS_TEXT.add("ref"); @@ -75,7 +85,9 @@ public class MapRoutingTypes { } private Map types = new LinkedHashMap(); - private List listTypes = new ArrayList(); + private List listTypes = new ArrayList(); + private MapRouteType refRuleType; + private MapRouteType nameRuleType; public static String constructRuleKey(String tag, String val) { if(val == null || val.length() == 0){ @@ -100,6 +112,15 @@ public class MapRoutingTypes { return null; } + public MapRouteType getRefRuleType() { + return refRuleType; + } + + + public MapRouteType getNameRuleType() { + return nameRuleType; + } + private boolean contains(Set s, String tag, String value) { if(s.contains(tag) || s.contains(tag + TAG_DELIMETER + value)){ return true; @@ -137,6 +158,45 @@ public class MapRoutingTypes { return true; } + public boolean encodeBaseEntity(Way et, TIntArrayList outTypes, Map names){ + Way e = (Way) et; + boolean init = false; + for(Entry es : e.getTags().entrySet()) { + String tag = es.getKey(); + String value = es.getValue(); + if (contains(TAGS_TO_ACCEPT, tag, value)) { + if(value.startsWith("trunk") || value.startsWith("motorway") + || value.startsWith("primary") || value.startsWith("secondary") + || value.startsWith("tertiary") + ) { + init = true; + break; + } + } + } + if(!init) { + return false; + } + outTypes.clear(); + names.clear(); + for(Entry es : e.getTags().entrySet()) { + String tag = es.getKey(); + String value = converBooleanValue(es.getValue()); + if(BASE_TAGS_TEXT.contains(tag)) { + names.put(registerRule(tag, null), value); + } + // do not use links in base map + if(value.endsWith("_link")){ + value = value.substring(0, value.length() - 5); + } + if(contains(TAGS_TO_ACCEPT, tag, value) || + contains(BASE_TAGS_TO_SAVE, tag, value)) { + outTypes.add(registerRule(tag, value).id); + } + } + return true; + } + private String converBooleanValue(String value){ if(value.equals("true")) { return "yes"; @@ -178,6 +238,12 @@ public class MapRoutingTypes { rt.value = val; types.put(id, rt); listTypes.add(rt); + if(tag.equals("ref")){ + refRuleType = rt; + } + if(tag.equals("name")){ + nameRuleType = rt; + } } MapRouteType type = types.get(id); type.freq ++; @@ -215,9 +281,17 @@ public class MapRoutingTypes { this.targetId = targetId; } + @Override + public String toString() { + if (value == null) { + return "'" + tag + "'"; + } + return tag + "='" + value + "'"; + } + } public List getEncodingRuleTypes() { return listTypes; } -} +} \ No newline at end of file diff --git a/DataExtractionOSM/src/net/osmand/osm/MapUtils.java b/DataExtractionOSM/src/net/osmand/osm/MapUtils.java index 61cb747eec..f8c671cbd2 100644 --- a/DataExtractionOSM/src/net/osmand/osm/MapUtils.java +++ b/DataExtractionOSM/src/net/osmand/osm/MapUtils.java @@ -471,6 +471,29 @@ public class MapUtils { } + + public static double squareDist31TileMetric(int x1, int y1, int x2, int y2) { + // translate into meters + double dy = convert31YToMeters(y1, y2); + double dx = convert31XToMeters(x1, x2); + return dx * dx + dy * dy; + } + public static double convert31YToMeters(float y1, float y2) { + // translate into meters + return (y1 - y2) * 0.01863d; + } + + public static double convert31XToMeters(float x1, float x2) { + // translate into meters + return (x1 - x2) * 0.011d; + } + + + public static double calculateProjection31TileMetric(int xA, int yA, int xB, int yB, int xC, int yC) { + // Scalar multiplication between (AB, AC) + double multiple = convert31XToMeters(xB, xA) * convert31XToMeters(xC, xA) + convert31YToMeters(yB, yA) * convert31YToMeters(yC, yA); + return multiple; + } } diff --git a/DataExtractionOSM/src/net/osmand/render/default.render.xml b/DataExtractionOSM/src/net/osmand/render/default.render.xml index b46b7d647b..a45d503032 100644 --- a/DataExtractionOSM/src/net/osmand/render/default.render.xml +++ b/DataExtractionOSM/src/net/osmand/render/default.render.xml @@ -20,19 +20,28 @@ type="string" possibleValues="default,car,bicycle,pedestrian"/> + + + + + + + + - + @@ -80,6 +89,7 @@ --> + - + - + - + - + - + - + - + - + - + - + - @@ -1072,7 +1081,7 @@ - + @@ -1084,7 +1093,7 @@ - + @@ -1097,7 +1106,8 @@ - + + @@ -1140,7 +1150,8 @@ - + + diff --git a/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java b/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java index c8006921ec..38643d54e1 100644 --- a/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java +++ b/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java @@ -34,8 +34,8 @@ public class BinaryRoutePlanner { private static double squareRootDist(int x1, int y1, int x2, int y2) { // translate into meters - double dy = convert31YToMeters(y1, y2); - double dx = convert31XToMeters(x1, x2); + double dy = MapUtils.convert31YToMeters(y1, y2); + double dx = MapUtils.convert31XToMeters(x1, x2); return Math.sqrt(dx * dx + dy * dy); // return measuredDist(x1, y1, x2, y2); } @@ -45,30 +45,6 @@ public class BinaryRoutePlanner { MapUtils.get31LatitudeY(y2), MapUtils.get31LongitudeX(x2)); } - private static double squareDist(int x1, int y1, int x2, int y2) { - // translate into meters - double dy = convert31YToMeters(y1, y2); - double dx = convert31XToMeters(x1, x2); - return dx * dx + dy * dy; - } - - private static double convert31YToMeters(int y1, int y2) { - // translate into meters - return (y1 - y2) * 0.01863d; - } - - private static double convert31XToMeters(int x1, int x2) { - // translate into meters - return (x1 - x2) * 0.011d; - } - - - private static double calculateProjection(int xA, int yA, int xB, int yB, int xC, int yC) { - // Scalar multiplication between (AB, AC) - double multiple = convert31XToMeters(xB, xA) * convert31XToMeters(xC, xA) + convert31YToMeters(yB, yA) * convert31YToMeters(yC, yA); - return multiple; - } - public RouteSegment findRouteSegment(double lat, double lon, RoutingContext ctx) throws IOException { @@ -93,7 +69,7 @@ public class BinaryRoutePlanner { r.getPoint31YTile(j - 1)); int prx = r.getPoint31XTile(j); int pry = r.getPoint31YTile(j); - double projection = calculateProjection(r.getPoint31XTile(j - 1), r.getPoint31YTile(j - 1), r.getPoint31XTile(j), + double projection = MapUtils. calculateProjection31TileMetric(r.getPoint31XTile(j - 1), r.getPoint31YTile(j - 1), r.getPoint31XTile(j), r.getPoint31YTile(j), px, py); if (projection < 0) { prx = r.getPoint31XTile(j - 1); @@ -107,7 +83,7 @@ public class BinaryRoutePlanner { pry = (int) (r.getPoint31YTile(j - 1) + (r.getPoint31YTile(j) - r.getPoint31YTile(j - 1)) * (projection / (mDist * mDist))); } - double currentsDist = squareDist(prx, pry, px, py); + double currentsDist = MapUtils. squareDist31TileMetric(prx, pry, px, py); if (road == null || currentsDist < sdist) { RouteDataObject ro = new RouteDataObject(r); road = new RouteSegment(ro, j); @@ -992,6 +968,10 @@ public class BinaryRoutePlanner { StringBuilder additional = new StringBuilder(); additional.append("time = \"").append(res.getSegmentTime()).append("\" "); additional.append("name = \"").append(name).append("\" "); +// float ms = res.getObject().getMaximumSpeed(); +// if(ms > 0) { +// additional.append("maxspeed = \"").append(ms * 3.6f).append("\" "); +// } additional.append("distance = \"").append(res.getDistance()).append("\" "); if (res.getTurnType() != null) { additional.append("turn = \"").append(res.getTurnType()).append("\" "); diff --git a/DataExtractionOSM/src/net/osmand/router/RoutingContext.java b/DataExtractionOSM/src/net/osmand/router/RoutingContext.java index e855166aa0..b10d51d11d 100644 --- a/DataExtractionOSM/src/net/osmand/router/RoutingContext.java +++ b/DataExtractionOSM/src/net/osmand/router/RoutingContext.java @@ -34,6 +34,8 @@ import org.apache.commons.logging.Log; public class RoutingContext { public static final boolean SHOW_GC_SIZE = false; + public boolean USE_BASEMAP = false; + private final static Log log = LogUtil.getLog(RoutingContext.class); public static final int OPTION_NO_LOAD = 0; public static final int OPTION_SMART_LOAD = 1; @@ -119,7 +121,9 @@ public class RoutingContext { List rr = mr.getRoutingIndexes(); List subregions = new ArrayList(); for (RouteRegion r : rr) { - for (RouteSubregion rs : r.getSubregions()) { + List subregs = USE_BASEMAP ? r.getBaseSubregions() : + r.getSubregions(); + for (RouteSubregion rs : subregs) { subregions.add(new RouteSubregion(rs)); } this.reverseMap.put(r, mr); @@ -127,7 +131,6 @@ public class RoutingContext { this.map.put(mr, subregions); } this.config = config; -// this.nativeLib = null; this.nativeLib = nativeLibrary; } @@ -618,7 +621,9 @@ public class RoutingContext { return original; } // Native use case + long nanoTime = System.nanoTime(); RouteDataObject[] res = ctx.nativeLib.getDataObjects(searchResult, x31, y31); + ctx.timeToLoad += (System.nanoTime() - nanoTime); if (res != null) { for (RouteDataObject ro : res) { RouteDataObject toCmp = excludeDuplications.get(ro.id); diff --git a/DataExtractionOSM/src/net/osmand/router/routing.xml b/DataExtractionOSM/src/net/osmand/router/routing.xml index 111496d812..0485095025 100644 --- a/DataExtractionOSM/src/net/osmand/router/routing.xml +++ b/DataExtractionOSM/src/net/osmand/router/routing.xml @@ -10,7 +10,7 @@ - + diff --git a/DataExtractionOSM/src/net/osmand/swing/MapRouterLayer.java b/DataExtractionOSM/src/net/osmand/swing/MapRouterLayer.java index da25b0a0e3..0d3b362268 100644 --- a/DataExtractionOSM/src/net/osmand/swing/MapRouterLayer.java +++ b/DataExtractionOSM/src/net/osmand/swing/MapRouterLayer.java @@ -171,23 +171,22 @@ public class MapRouterLayer implements MapPanelLayer { @Override public void actionPerformed(ActionEvent e) { - new Thread() { - @Override - public void run() { - List ways = selfRoute(startRoute, endRoute, intermediates, null); - if (ways != null) { - DataTileManager points = new DataTileManager(); - points.setZoom(11); - for (Way w : ways) { - LatLon n = w.getLatLon(); - points.registerObject(n.getLatitude(), n.getLongitude(), w); - } - map.setPoints(points); - } - } - }.start(); + previousRoute = null; + calcRoute(false); } }; + menu.add(selfRoute); + + Action selfBaseRoute = new AbstractAction("Calculate OsmAnd base route") { + private static final long serialVersionUID = 8049785829806139142L; + + @Override + public void actionPerformed(ActionEvent e) { + previousRoute = null; + calcRoute(true); + } + }; + menu.add(selfBaseRoute); Action recalculate = new AbstractAction("Recalculate OsmAnd route") { private static final long serialVersionUID = 507156107455281238L; @@ -200,25 +199,11 @@ public class MapRouterLayer implements MapPanelLayer { @Override public void actionPerformed(ActionEvent e) { - new Thread() { - @Override - public void run() { - List ways = selfRoute(startRoute, endRoute, intermediates, previousRoute); - if (ways != null) { - DataTileManager points = new DataTileManager(); - points.setZoom(11); - for (Way w : ways) { - LatLon n = w.getLatLon(); - points.registerObject(n.getLatitude(), n.getLongitude(), w); - } - map.setPoints(points); - } - } - }.start(); + calcRoute(false); } }; - menu.add(selfRoute); + menu.add(recalculate); Action route_YOURS = new AbstractAction("Calculate YOURS route") { private static final long serialVersionUID = 507156107455281238L; @@ -304,6 +289,24 @@ public class MapRouterLayer implements MapPanelLayer { } + private void calcRoute(final boolean useBasemap) { + new Thread() { + @Override + public void run() { + List ways = selfRoute(startRoute, endRoute, intermediates, previousRoute, useBasemap); + if (ways != null) { + DataTileManager points = new DataTileManager(); + points.setZoom(11); + for (Way w : ways) { + LatLon n = w.getLatLon(); + points.registerObject(n.getLatitude(), n.getLongitude(), w); + } + map.setPoints(points); + } + } + }.start(); + } + public static List route_YOURS(LatLon start, LatLon end){ List res = new ArrayList(); long time = System.currentTimeMillis(); @@ -563,7 +566,7 @@ public class MapRouterLayer implements MapPanelLayer { return res; } - public List selfRoute(LatLon start, LatLon end, List intermediates, List previousRoute) { + public List selfRoute(LatLon start, LatLon end, List intermediates, List previousRoute, boolean useBasemap) { List res = new ArrayList(); long time = System.currentTimeMillis(); List files = new ArrayList(); @@ -615,6 +618,7 @@ public class MapRouterLayer implements MapPanelLayer { // config.NUMBER_OF_DESIRABLE_TILES_IN_MEMORY = 300; // config.ZOOM_TO_LOAD_TILES = 14; RoutingContext ctx = new RoutingContext(config, NativeSwingRendering.getDefaultFromSettings(), rs); + ctx.USE_BASEMAP = useBasemap; ctx.previouslyCalculatedRoute = previousRoute; log.info("Use " + config.routerName + "mode for routing"); diff --git a/DataExtractionOSM/src/osmand_index.proto b/DataExtractionOSM/src/osmand_index.proto index 3c87bbdecf..aa244f80b0 100644 --- a/DataExtractionOSM/src/osmand_index.proto +++ b/DataExtractionOSM/src/osmand_index.proto @@ -75,12 +75,14 @@ message MapPart { message RoutingSubregion { required int64 size = 1; required int64 offset = 2; + required bool basemap= 3; required int32 left = 4; required int32 right = 5; required int32 top = 6; required int32 bottom = 7; required uint32 shifToData = 8; + } diff --git a/DataExtractionOSM/src/osmand_odb.proto b/DataExtractionOSM/src/osmand_odb.proto index 03966cbd40..626fee2c72 100644 --- a/DataExtractionOSM/src/osmand_odb.proto +++ b/DataExtractionOSM/src/osmand_odb.proto @@ -3,7 +3,7 @@ option java_package = "net.osmand.binary"; //protoc --java_out=DataExtractionOSM/src DataExtractionOSM/src/osmand_odb.proto // C++ # cd OsmAnd -// # protoc --proto_path=../DataExtractionOSM/src --cpp_out=jni/osmand/proto ../DataExtractionOSM/src/osmand_odb.proto +// # protoc --proto_path=../DataExtractionOSM/src --cpp_out=../Osmand-kernel/osmand/src/proto/ ../DataExtractionOSM/src/osmand_odb.proto // // STORAGE LAYER: Storing primitives. @@ -508,6 +508,9 @@ message OsmAndRoutingIndex { // encoded as fixed32 length delimited repeated RouteDataBox rootBoxes = 3; + // encoded as fixed32 length delimited + repeated RouteDataBox basemapBoxes = 4; + repeated RouteDataBlock blocks = 5; message RouteDataBox { // for root box is absolute coordinates diff --git a/OsmAnd/src/net/osmand/plus/extrasettings/OsmandExtraSettings.java b/OsmAnd/src/net/osmand/plus/extrasettings/OsmandExtraSettings.java index a2c637db04..02a7cb599c 100644 --- a/OsmAnd/src/net/osmand/plus/extrasettings/OsmandExtraSettings.java +++ b/OsmAnd/src/net/osmand/plus/extrasettings/OsmandExtraSettings.java @@ -118,19 +118,6 @@ public class OsmandExtraSettings extends OsmandPlugin { } }); - // FIXME delete strings from this code -// final MapInfoControlRegInfo fluorescent = mapInfoControls.registerAppearanceWidget(R.drawable.widget_fluorescent_routes, R.string.map_widget_fluorescent, -// "fluorescent", view.getSettings().FLUORESCENT_OVERLAYS); -// fluorescent.setStateChangeListener(new Runnable() { -// @Override -// public void run() { -// view.getSettings().FLUORESCENT_OVERLAYS.set(!view.getSettings().FLUORESCENT_OVERLAYS.get()); -// view.refreshMap(); -// } -// }); - - -// final CommonPreference posPref = view.getSettings().POSITION_ON_MAP; // final MapInfoControlRegInfo posMap = mapInfoControls.registerAppearanceWidget(R.drawable.widget_position_marker, R.string.position_on_map, // "position_on_map", textSizePref); // posMap.setStateChangeListener(new Runnable() { diff --git a/Osmand-kernel/expat/Android.mk b/Osmand-kernel/expat/Android.mk index 5b62cf3909..7d927b98ef 100755 --- a/Osmand-kernel/expat/Android.mk +++ b/Osmand-kernel/expat/Android.mk @@ -11,6 +11,7 @@ LOCAL_MODULE := expat_static_neon LOCAL_ARM_NEON := true endif + ifneq ($(OSMAND_USE_PREBUILT),true) include $(BUILD_STATIC_LIBRARY) diff --git a/Osmand-kernel/osmand/src/binaryRead.cpp b/Osmand-kernel/osmand/src/binaryRead.cpp index 1e857086e8..29d0d2a1eb 100644 --- a/Osmand-kernel/osmand/src/binaryRead.cpp +++ b/Osmand-kernel/osmand/src/binaryRead.cpp @@ -19,10 +19,18 @@ using google::protobuf::io::FileInputStream; using google::protobuf::internal::WireFormatLite; //using namespace google::protobuf::internal; - +static int zoomForBaseRouteRendering = 14; std::map< std::string, BinaryMapFile* > openFiles; OsmAndStoredIndex* cache = NULL; +void searchRouteSubRegion(int fileInd, std::vector& list, RoutingIndex* routingIndex, RouteSubregion* sub); +void searchRouteRegion(CodedInputStream* input, SearchQuery* q, RoutingIndex* ind, std::vector& subregions, + std::vector& toLoad); +bool readRouteTreeData(CodedInputStream* input, RouteSubregion* s, std::vector& dataObjects, + RoutingIndex* routingIndex); + +bool sortRouteRegions (const RouteSubregion& i,const RouteSubregion& j) { return (i.mapDataBlockReadRaw(buf, 4)) { @@ -329,7 +337,9 @@ bool readRoutingIndex(CodedInputStream* input, RoutingIndex* routingIndex) { input->PopLimit(oldLimit); break; } - case OsmAndRoutingIndex::kRootBoxesFieldNumber: { + case OsmAndRoutingIndex::kRootBoxesFieldNumber: + case OsmAndRoutingIndex::kBasemapBoxesFieldNumber:{ + bool basemap = WireFormatLite::GetTagFieldNumber(tag) == OsmAndRoutingIndex::kBasemapBoxesFieldNumber; RouteSubregion subregion; readInt(input, &subregion.length); subregion.filePointer = input->getTotalBytesRead(); @@ -337,7 +347,16 @@ bool readRoutingIndex(CodedInputStream* input, RoutingIndex* routingIndex) { readRouteTree(input, &subregion, NULL, 0, true); input->PopLimit(oldLimit); input->Seek(subregion.filePointer + subregion.length); - routingIndex->subregions.push_back(subregion); + if(basemap) { + osmand_log_print(LOG_INFO, "route basemap %d %s",subregion.filePointer, routingIndex->name.c_str() ); + routingIndex->basesubregions.push_back(subregion); + } else { + osmand_log_print(LOG_INFO, "route map %d %s",subregion.filePointer, routingIndex->name.c_str() ); + routingIndex->subregions.push_back(subregion); + } + break; + } + case OsmAndRoutingIndex::kBlocksFieldNumber: { // Finish reading input->Seek(routingIndex->filePointer + routingIndex->length); break; @@ -438,15 +457,15 @@ bool initMapStructure(CodedInputStream* input, BinaryMapFile* file) { break; } case OsmAndStructure::kRoutingIndexFieldNumber: { - RoutingIndex routingIndex; - readInt(input, &routingIndex.length); - routingIndex.filePointer = input->getTotalBytesRead(); - int oldLimit = input->PushLimit(routingIndex.length); - readRoutingIndex(input, &routingIndex); + RoutingIndex* routingIndex = new RoutingIndex; + readInt(input, &routingIndex->length); + routingIndex->filePointer = input->getTotalBytesRead(); + int oldLimit = input->PushLimit(routingIndex->length); + readRoutingIndex(input, routingIndex); input->PopLimit(oldLimit); - input->Seek(routingIndex.filePointer + routingIndex.length); + input->Seek(routingIndex->filePointer + routingIndex->length); file->routingIndexes.push_back(routingIndex); - file->indexes.push_back(&file->routingIndexes.back()); + file->indexes.push_back(file->routingIndexes.back()); break; } case OsmAndStructure::kVersionConfirmFieldNumber: { @@ -882,11 +901,191 @@ void searchMapData(CodedInputStream* input, MapRoot* root, MapIndex* ind, Search } +void convertRouteDataObjecToMapObjects(SearchQuery* q, std::vector& list, std::vector& tempResult, + bool skipDuplicates, UNORDERED(set)& ids) { + std::vector::iterator rIterator = list.begin(); + tempResult.reserve((size_t) (list.size() + tempResult.size())); + for (; rIterator != list.end(); rIterator++) { + RouteDataObject* r = (*rIterator); + if(r == NULL) { + continue; + } + if (skipDuplicates && r->id > 0) { + if (ids.find(r->id) != ids.end()) { + continue; + } + ids.insert(r->id); + } + // convert route data object to map data object + MapDataObject* obj = new MapDataObject; + bool add = true; + std::vector::iterator typeIt = r->types.begin(); + for (; typeIt != r->types.end(); typeIt++) { + uint32_t k = (*typeIt); + if (k < r->region->decodingRules.size()) { + tag_value t = r->region->decodingRules[k]; + if (t.first == "highway" || t.first == "route" || t.first == "railway" || t.first == "aeroway" + || t.first == "aerialway") { + obj->types.push_back(t); +// if (q->zoom < 15 && t.second != "motorway" && t.second != "primary" && t.second != "secondary" +// && t.second != "tertiary" && t.second != "ferry" && t.second != "trunk") { +// add = false; +// } + } else { + obj->additionalTypes.push_back(t); + } + } + + } + if (add) { + for (uint32_t s = 0; s < r->pointsX.size(); s++) { + obj->points.push_back(std::pair(r->pointsX[s], r->pointsY[s])); + } + obj->id = r->id; + UNORDERED(map)::iterator nameIterator = r->names.begin(); + for (; nameIterator != r->names.end(); nameIterator++) { + obj->objectNames[r->region->decodingRules[nameIterator->first].first] = nameIterator->second; + } + obj->area = false; + tempResult.push_back(obj); + } else { + delete obj; + } + delete r; + } +} + +void checkAndInitRouteRegionRules(int fileInd, RoutingIndex* routingIndex){ + // init decoding rules + if (routingIndex->decodingRules.size() == 0) { + routingIndex->subregions.clear(); + lseek(fileInd, 0, SEEK_SET); + FileInputStream input(fileInd); + input.SetCloseOnDelete(false); + CodedInputStream cis(&input); + cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 2); + + cis.Seek(routingIndex->filePointer); + uint32_t old = cis.PushLimit(routingIndex->length); + readRoutingIndex(&cis, routingIndex); + cis.PopLimit(old); + } +} -ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates, std::string msgNothingFound) { +void readRouteDataAsMapObjects(SearchQuery* q, BinaryMapFile* file, std::vector& tempResult, + bool skipDuplicates, UNORDERED(set)& ids) { + + for (std::vector::iterator routeIndex = file->routingIndexes.begin(); + routeIndex != file->routingIndexes.end(); routeIndex++) { + if (q->publisher->isCancelled()) { + break; + } + bool contains = false; + std::vector subs = + q->zoom <= zoomForBaseRouteRendering ? (*routeIndex)->basesubregions : (*routeIndex)->subregions; + for (std::vector::iterator subreg = subs.begin(); subreg != subs.end(); subreg++) { + if (subreg->right >= q->left && q->right >= subreg->left && subreg->bottom >= q->top + && q->bottom >= subreg->top) { + osmand_log_print(LOG_INFO, "Search route map %s", (*routeIndex)->name.c_str()); + contains = true; + } + } + osmand_log_print(LOG_INFO, "Search map %s %d", (*routeIndex)->name.c_str(), subs.size()); + if (contains) { + vector found; + lseek(file->fd, 0, SEEK_SET); + FileInputStream input(file->fd); + input.SetCloseOnDelete(false); + CodedInputStream cis(&input); + cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 1); + cis.Seek((*routeIndex)->filePointer); + uint32_t old = cis.PushLimit((*routeIndex)->length); + searchRouteRegion(&cis, q, *routeIndex, subs, found); + cis.PopLimit(old); + + checkAndInitRouteRegionRules(file->fd, (*routeIndex)); + osmand_log_print(LOG_INFO, "Search map %s %d", (*routeIndex)->name.c_str(), found.size()); + sort(found.begin(), found.end(), sortRouteRegions); + { + lseek(file->fd, 0, SEEK_SET); + FileInputStream input(file->fd); + input.SetCloseOnDelete(false); + CodedInputStream cis(&input); + cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 2); + for (std::vector::iterator sub = found.begin(); sub != found.end();sub++) { + std::vector list; + cis.Seek(sub->filePointer + sub->mapDataBlock); + uint32_t length; + cis.ReadVarint32(&length); + uint32_t old = cis.PushLimit(length); + readRouteTreeData(&cis, &(*sub), list, *routeIndex); + cis.PopLimit(old); + convertRouteDataObjecToMapObjects(q, list, tempResult, skipDuplicates, ids); + } + } + } + } + } + +void readMapObjects(SearchQuery* q, BinaryMapFile* file) { + for (std::vector::iterator mapIndex = file->mapIndexes.begin(); mapIndex != file->mapIndexes.end(); + mapIndex++) { + for (std::vector::iterator mapLevel = mapIndex->levels.begin(); mapLevel != mapIndex->levels.end(); + mapLevel++) { + if (q->publisher->isCancelled()) { + break; + } + + if (mapLevel->minZoom <= q->zoom && mapLevel->maxZoom >= q->zoom) { + if (mapLevel->right >= q->left && q->right >= mapLevel->left && mapLevel->bottom >= q->top + && q->bottom >= mapLevel->top) { + // osmand_log_print(LOG_INFO, "Search map %s", mapIndex->name.c_str()); + // lazy initializing rules + if (mapIndex->decodingRules.size() == 0) { + lseek(file->fd, 0, SEEK_SET); + FileInputStream input(file->fd); + input.SetCloseOnDelete(false); + CodedInputStream cis(&input); + cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 1); + cis.Seek(mapIndex->filePointer); + int oldLimit = cis.PushLimit(mapIndex->length); + readMapIndex(&cis, &(*mapIndex), true); + cis.PopLimit(oldLimit); + } + // lazy initializing subtrees + if (mapLevel->bounds.size() == 0) { + lseek(file->fd, 0, SEEK_SET); + FileInputStream input(file->fd); + input.SetCloseOnDelete(false); + CodedInputStream cis(&input); + cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 1); + cis.Seek(mapLevel->filePointer); + int oldLimit = cis.PushLimit(mapLevel->length); + readMapLevel(&cis, &(*mapLevel), true); + cis.PopLimit(oldLimit); + } + lseek(file->fd, 0, SEEK_SET); + FileInputStream input(file->fd); + input.SetCloseOnDelete(false); + CodedInputStream cis(&input); + cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 2); + searchMapData(&cis, &(*mapLevel), &(*mapIndex), q); + } + } + } + } + +} + +ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates, int renderRouteDataFile, std::string msgNothingFound) { map::iterator i = openFiles.begin(); UNORDERED(set) ids; + if(skipDuplicates){ + // override it for now + // TODO skip duplicates doesn't work correctly with basemap ? + skipDuplicates = false; + } int count = 0; std::vector basemapResult; std::vector tempResult; @@ -900,59 +1099,14 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates, q->req->clearState(); } q->publisher->result.clear(); - for (std::vector::iterator mapIndex = file->mapIndexes.begin(); mapIndex != file->mapIndexes.end(); - mapIndex++) { - for (std::vector::iterator mapLevel = mapIndex->levels.begin(); mapLevel != mapIndex->levels.end(); - mapLevel++) { - if (q->publisher->isCancelled()) { - break; - } - basemapExists |= file->isBasemap(); - if (mapLevel->minZoom <= q->zoom && mapLevel->maxZoom >= q->zoom) { - if (mapLevel->right >= q->left && q->right >= mapLevel->left && mapLevel->bottom >= q->top - && q->bottom >= mapLevel->top) { - osmand_log_print(LOG_INFO, "Search map %s", mapIndex->name.c_str()); - // lazy initializing rules - if (mapIndex->decodingRules.size() == 0) { - lseek(file->fd, 0, SEEK_SET); - FileInputStream input(file->fd); - input.SetCloseOnDelete(false); - CodedInputStream cis(&input); - cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 1); - cis.Seek(mapIndex->filePointer); - int oldLimit = cis.PushLimit(mapIndex->length); - readMapIndex(&cis, &(*mapIndex), true); - cis.PopLimit(oldLimit); - } - // lazy initializing subtrees - if (mapLevel->bounds.size() == 0) { - lseek(file->fd, 0, SEEK_SET); - FileInputStream input(file->fd); - input.SetCloseOnDelete(false); - CodedInputStream cis(&input); - cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 1); - cis.Seek(mapLevel->filePointer); - int oldLimit = cis.PushLimit(mapLevel->length); - readMapLevel(&cis, &(*mapLevel), true); - cis.PopLimit(oldLimit); - } - lseek(file->fd, 0, SEEK_SET); - FileInputStream input(file->fd); - input.SetCloseOnDelete(false); - CodedInputStream cis(&input); - cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 2); - searchMapData(&cis, &(*mapLevel), &(*mapIndex), q); - } - } - } - } + basemapExists |= file->isBasemap(); + readMapObjects(q, file); if (!q->publisher->isCancelled()) { std::vector::iterator r = q->publisher->result.begin(); tempResult.reserve((size_t)(q->publisher->result.size() + tempResult.size())); for (; r != q->publisher->result.end(); r++) { - // TODO skip duplicates doesn't work correctly with basemap (id < 0?) - if (skipDuplicates && (*r)->id > 0 && false) { + if (skipDuplicates && (*r)->id > 0 ) { if (ids.find((*r)->id) != ids.end()) { continue; } @@ -971,13 +1125,31 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates, if (i->second->isBasemap()) { basemapResult.push_back(*r); } else { - tempResult.push_back(*r); + if(renderRouteDataFile != 1){ + tempResult.push_back(*r); + renderRouteDataFile = -1; + } else { + delete *r; + } } } } } } + if (renderRouteDataFile >= 0) { + i = openFiles.begin(); + for (; i != openFiles.end() && !q->publisher->isCancelled(); i++) { + BinaryMapFile* file = i->second; + if (q->req != NULL) { + q->req->clearState(); + } + q->publisher->result.clear(); + readRouteDataAsMapObjects(q, file, tempResult, skipDuplicates, ids); + } + osmand_log_print(LOG_INFO, "Route objects %d", tempResult.size()); + } + // sort results/ analyze coastlines and publish back to publisher if (q->publisher->isCancelled()) { deleteObjects(coastLines); @@ -1031,7 +1203,7 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates, o->objectNames["name"] = msgNothingFound; tempResult.push_back(o); } - if (q->zoom <= BASEMAP_ZOOM || emptyData) { + if (q->zoom <= BASEMAP_ZOOM || emptyData || renderRouteDataFile >= 0) { tempResult.insert(tempResult.end(), basemapResult.begin(), basemapResult.end()); } else { deleteObjects(basemapResult); @@ -1048,20 +1220,20 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates, void searchRouteRegion(CodedInputStream* input, SearchQuery* q, RoutingIndex* ind, std::vector& subregions, - std::vector& toLoad, BinaryMapFile* file) { + std::vector& toLoad) { for (std::vector::iterator subreg = subregions.begin(); subreg != subregions.end(); subreg++) { if (subreg->right >= q->left && q->right >= subreg->left && subreg->bottom >= q->top && q->bottom >= subreg->top) { - if(subreg->subregions.empty()){ - bool contains = subreg->right <= q->right && q->left <= subreg->left && subreg->top <= q->top + if(subreg->subregions.empty() && subreg->mapDataBlock == 0){ + bool contains = subreg->right <= q->right && subreg->left >= q->left && subreg->top <= q->top && subreg->bottom >= q->bottom; input->Seek(subreg->filePointer); uint32_t old = input->PushLimit(subreg->length); - readRouteTree(input, &(*subreg), NULL, contains? -1 : 1, false); + readRouteTree(input, &(*subreg), NULL, -1/*contains? -1 : 1*/, false); input->PopLimit(old); } - searchRouteRegion(input, q, ind, subreg->subregions, toLoad, file); + searchRouteRegion(input, q, ind, subreg->subregions, toLoad); if(subreg->mapDataBlock != 0) { toLoad.push_back(*subreg); } @@ -1168,7 +1340,7 @@ bool readRouteDataObject(CodedInputStream* input, uint32_t left, uint32_t top, R const static int RESTRICTION_SHIFT = 3; const static int RESTRICTION_MASK = 7; -bool readRouteTreeData(CodedInputStream* input, RouteSubregion* s, std::vector& dataObjects) { +bool readRouteTreeData(CodedInputStream* input, RouteSubregion* s, std::vector& dataObjects, RoutingIndex* routingIndex) { int tag; std::vector idTables; UNORDERED(map) > restrictions; @@ -1185,6 +1357,7 @@ bool readRouteTreeData(CodedInputStream* input, RouteSubregion* s, std::vectorid ) { dataObjects.resize((uint32_t) obj->id + 1, NULL); } + obj->region = routingIndex; dataObjects[obj->id] = obj; input->PopLimit(oldLimit); break; @@ -1314,62 +1487,49 @@ bool readRouteTreeData(CodedInputStream* input, RouteSubregion* s, std::vector& list, RoutingIndex* rs, RouteSubregion* sub){ +void searchRouteSubRegion(int fileInd, std::vector& list, RoutingIndex* routingIndex, RouteSubregion* sub){ + + checkAndInitRouteRegionRules(fileInd, routingIndex); + + // could be simplified but it will be concurrency with init block + lseek(fileInd, 0, SEEK_SET); + FileInputStream input(fileInd); + input.SetCloseOnDelete(false); + CodedInputStream cis(&input); + cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 2); + + cis.Seek(sub->filePointer + sub->mapDataBlock); + uint32_t length; + cis.ReadVarint32(&length); + uint32_t old = cis.PushLimit(length); + readRouteTreeData(&cis, &(*sub), list, routingIndex); + cis.PopLimit(old); +} + +void searchRouteDataForSubRegion(SearchQuery* q, std::vector& list, RoutingIndex* rs, RouteSubregion* sub){ map::iterator i = openFiles.begin(); UNORDERED(set) ids; - int count = 0; bool basemapExists = false; for (; i != openFiles.end() && !q->publisher->isCancelled(); i++) { BinaryMapFile* file = i->second; - for (std::vector::iterator routingIndex = file->routingIndexes.begin(); + for (std::vector::iterator routingIndex = file->routingIndexes.begin(); routingIndex != file->routingIndexes.end(); routingIndex++) { if (q->publisher->isCancelled()) { break; } - if(rs != NULL && (rs->name != routingIndex->name || rs->filePointer != routingIndex->filePointer)){ + if(rs != NULL && (rs->name != (*routingIndex)->name || rs->filePointer != (*routingIndex)->filePointer)){ continue; } - - // init decoding rules - if (routingIndex->decodingRules.size() == 0) { - routingIndex->subregions.clear(); - lseek(file->routefd, 0, SEEK_SET); - FileInputStream input(file->routefd); - input.SetCloseOnDelete(false); - CodedInputStream cis(&input); - cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 2); - - cis.Seek(routingIndex->filePointer); - uint32_t old = cis.PushLimit(routingIndex->length); - readRoutingIndex(&cis, &(*routingIndex)); - cis.PopLimit(old); - } - - // could be simplified but it will be concurrency with init block - lseek(file->routefd, 0, SEEK_SET); - FileInputStream input(file->routefd); - input.SetCloseOnDelete(false); - CodedInputStream cis(&input); - cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 2); - - -// cis.Seek(sub->filePointer); -// uint32_t old = cis.PushLimit(sub->length); -// readRouteTree(&cis, &(*sub), NULL, 0, true); -// cis.PopLimit(old); - cis.Seek(sub->filePointer + sub->mapDataBlock); - uint32_t length; - cis.ReadVarint32(&length); - uint32_t old = cis.PushLimit(length); - readRouteTreeData(&cis, &(*sub), list); - cis.PopLimit(old); + searchRouteSubRegion(file->routefd, list, (*routingIndex), sub); + return; } } } + + bool closeBinaryMapFile(std::string inputName) { std::map::iterator iterator; if ((iterator = openFiles.find(inputName)) != openFiles.end()) { @@ -1493,11 +1653,14 @@ BinaryMapFile* initBinaryMapFile(std::string inputName) { mr.mapDataBlock = ml.shiftodata(); mr.filePointer = ml.offset(); mr.length = ml.size(); - osmand_log_print(LOG_DEBUG, "Native file init subregion %d %d %d ", mr.filePointer, mr.length, mr.mapDataBlock); - mi.subregions.push_back(mr); + if (ml.basemap()) { + mi.basesubregions.push_back(mr); + } else { + mi.subregions.push_back(mr); + } } - mapFile->routingIndexes.push_back(mi); - mapFile->indexes.push_back(&mapFile->routingIndexes.back()); + mapFile->routingIndexes.push_back(new RoutingIndex(mi)); + mapFile->indexes.push_back(mapFile->routingIndexes.back()); } osmand_log_print(LOG_DEBUG, "Native file initialized from cache %s", inputName.c_str()); } else { diff --git a/Osmand-kernel/osmand/src/binaryRead.h b/Osmand-kernel/osmand/src/binaryRead.h index 12d814c915..68aebef608 100644 --- a/Osmand-kernel/osmand/src/binaryRead.h +++ b/Osmand-kernel/osmand/src/binaryRead.h @@ -78,8 +78,10 @@ struct BinaryPartIndex { }; struct RoutingIndex : BinaryPartIndex { - UNORDERED(map)< int, tag_value > decodingRules; +// UNORDERED(map)< uint32_t, tag_value > decodingRules; + vector< tag_value > decodingRules; std::vector subregions; + std::vector basesubregions; RoutingIndex() : BinaryPartIndex(ROUTING_INDEX) { } @@ -87,6 +89,9 @@ struct RoutingIndex : BinaryPartIndex { tag_value pair = tag_value(tag, val); // DEFINE hash //encodingRules[pair] = id; + while(decodingRules.size() < id + 1){ + decodingRules.push_back(pair); + } decodingRules[id] = pair; } }; @@ -175,7 +180,7 @@ struct BinaryMapFile { uint32_t version; uint64_t dateCreated; std::vector mapIndexes; - std::vector routingIndexes; + std::vector routingIndexes; std::vector indexes; int fd; int routefd; @@ -247,9 +252,9 @@ struct SearchQuery { } }; -void searchRouteRegion(SearchQuery* q, std::vector& list, RoutingIndex* rs, RouteSubregion* sub); +void searchRouteDataForSubRegion(SearchQuery* q, std::vector& list, RoutingIndex* rs, RouteSubregion* sub); -ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates, std::string msgNothingFound); +ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates, int renderRouteDataFile, std::string msgNothingFound); BinaryMapFile* initBinaryMapFile(std::string inputName); diff --git a/Osmand-kernel/osmand/src/common.h b/Osmand-kernel/osmand/src/common.h index 1231f47e9d..0afa2e737e 100644 --- a/Osmand-kernel/osmand/src/common.h +++ b/Osmand-kernel/osmand/src/common.h @@ -47,6 +47,8 @@ # define UNORDERED_NAMESPACE std # define UNORDERED_map unordered_map # define UNORDERED_set unordered_set +//# define UNORDERED_map map +//# define UNORDERED_set set #endif #define UNORDERED(cls) UNORDERED_NAMESPACE::UNORDERED_##cls diff --git a/Osmand-kernel/osmand/src/java_renderRules.h b/Osmand-kernel/osmand/src/java_renderRules.h index 2006ee9da8..87306a4065 100644 --- a/Osmand-kernel/osmand/src/java_renderRules.h +++ b/Osmand-kernel/osmand/src/java_renderRules.h @@ -145,6 +145,7 @@ void initProperties(JNIEnv* env, RenderingRulesStorage* st, jobject javaStorage) } + void initRules(JNIEnv* env, RenderingRulesStorage* st, jobject javaStorage) { for (int i = 1; i < RenderingRulesStorage::SIZE_STATES; i++) { jobjectArray rules = (jobjectArray) env->CallObjectMethod(javaStorage, RenderingRulesStorage_getRules, i); diff --git a/Osmand-kernel/osmand/src/java_wrap.cpp b/Osmand-kernel/osmand/src/java_wrap.cpp index 1e3693880f..11e64ae03a 100644 --- a/Osmand-kernel/osmand/src/java_wrap.cpp +++ b/Osmand-kernel/osmand/src/java_wrap.cpp @@ -12,6 +12,7 @@ #include "binaryRead.h" #include "rendering.h" + JavaVM* globalJVM = NULL; void loadJniRenderingContext(JNIEnv* env); void loadJniRenderingRules(JNIEnv* env); @@ -106,7 +107,8 @@ RenderingRuleSearchRequest* initSearchRequest(JNIEnv* env, jobject renderingRule extern "C" JNIEXPORT jlong JNICALL Java_net_osmand_NativeLibrary_searchNativeObjectsForRendering(JNIEnv* ienv, jobject obj, jint sleft, jint sright, jint stop, jint sbottom, jint zoom, - jobject renderingRuleSearchRequest, bool skipDuplicates, jobject objInterrupted, jstring msgNothingFound) { + jobject renderingRuleSearchRequest, bool skipDuplicates, int renderRouteDataFile, + jobject objInterrupted, jstring msgNothingFound) { RenderingRuleSearchRequest* req = initSearchRequest(ienv, renderingRuleSearchRequest); jfieldID interruptedField = 0; if(objInterrupted != NULL) { @@ -120,7 +122,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_net_osmand_NativeLibrary_searchNativeObj q.zoom = zoom; - ResultPublisher* res = searchObjectsForRendering(&q, skipDuplicates, getString(ienv, msgNothingFound)); + ResultPublisher* res = searchObjectsForRendering(&q, skipDuplicates, renderRouteDataFile, getString(ienv, msgNothingFound)); delete req; return (jlong) j; } @@ -604,7 +606,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_NativeLibrary_loadRoutingDa sub.mapDataBlock= ienv->GetIntField(subreg, jfield_RouteSubregion_shiftToData); std::vector result; SearchQuery q; - searchRouteRegion(&q, result, &ind, &sub); + searchRouteDataForSubRegion(&q, result, &ind, &sub); if (loadObjects) { diff --git a/Osmand-kernel/osmand/src/proto/osmand_index.pb.h b/Osmand-kernel/osmand/src/proto/osmand_index.pb.h index 6669d1bc73..9daee90189 100644 --- a/Osmand-kernel/osmand/src/proto/osmand_index.pb.h +++ b/Osmand-kernel/osmand/src/proto/osmand_index.pb.h @@ -962,6 +962,13 @@ class RoutingSubregion : public ::google::protobuf::MessageLite { inline ::google::protobuf::int64 offset() const; inline void set_offset(::google::protobuf::int64 value); + // required bool basemap = 3; + inline bool has_basemap() const; + inline void clear_basemap(); + static const int kBasemapFieldNumber = 3; + inline bool basemap() const; + inline void set_basemap(bool value); + // required int32 left = 4; inline bool has_left() const; inline void clear_left(); @@ -1003,6 +1010,7 @@ class RoutingSubregion : public ::google::protobuf::MessageLite { ::google::protobuf::int64 size_; ::google::protobuf::int64 offset_; + bool basemap_; ::google::protobuf::int32 left_; ::google::protobuf::int32 right_; ::google::protobuf::int32 top_; @@ -1012,7 +1020,7 @@ class RoutingSubregion : public ::google::protobuf::MessageLite { friend void protobuf_AssignDesc_osmand_5findex_2eproto(); friend void protobuf_ShutdownFile_osmand_5findex_2eproto(); - ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; + ::google::protobuf::uint32 _has_bits_[(8 + 31) / 32]; // WHY DOES & HAVE LOWER PRECEDENCE THAN != !? inline bool _has_bit(int index) const { @@ -2208,83 +2216,99 @@ inline void RoutingSubregion::set_offset(::google::protobuf::int64 value) { offset_ = value; } +// required bool basemap = 3; +inline bool RoutingSubregion::has_basemap() const { + return _has_bit(2); +} +inline void RoutingSubregion::clear_basemap() { + basemap_ = false; + _clear_bit(2); +} +inline bool RoutingSubregion::basemap() const { + return basemap_; +} +inline void RoutingSubregion::set_basemap(bool value) { + _set_bit(2); + basemap_ = value; +} + // required int32 left = 4; inline bool RoutingSubregion::has_left() const { - return _has_bit(2); + return _has_bit(3); } inline void RoutingSubregion::clear_left() { left_ = 0; - _clear_bit(2); + _clear_bit(3); } inline ::google::protobuf::int32 RoutingSubregion::left() const { return left_; } inline void RoutingSubregion::set_left(::google::protobuf::int32 value) { - _set_bit(2); + _set_bit(3); left_ = value; } // required int32 right = 5; inline bool RoutingSubregion::has_right() const { - return _has_bit(3); + return _has_bit(4); } inline void RoutingSubregion::clear_right() { right_ = 0; - _clear_bit(3); + _clear_bit(4); } inline ::google::protobuf::int32 RoutingSubregion::right() const { return right_; } inline void RoutingSubregion::set_right(::google::protobuf::int32 value) { - _set_bit(3); + _set_bit(4); right_ = value; } // required int32 top = 6; inline bool RoutingSubregion::has_top() const { - return _has_bit(4); + return _has_bit(5); } inline void RoutingSubregion::clear_top() { top_ = 0; - _clear_bit(4); + _clear_bit(5); } inline ::google::protobuf::int32 RoutingSubregion::top() const { return top_; } inline void RoutingSubregion::set_top(::google::protobuf::int32 value) { - _set_bit(4); + _set_bit(5); top_ = value; } // required int32 bottom = 7; inline bool RoutingSubregion::has_bottom() const { - return _has_bit(5); + return _has_bit(6); } inline void RoutingSubregion::clear_bottom() { bottom_ = 0; - _clear_bit(5); + _clear_bit(6); } inline ::google::protobuf::int32 RoutingSubregion::bottom() const { return bottom_; } inline void RoutingSubregion::set_bottom(::google::protobuf::int32 value) { - _set_bit(5); + _set_bit(6); bottom_ = value; } // required uint32 shifToData = 8; inline bool RoutingSubregion::has_shiftodata() const { - return _has_bit(6); + return _has_bit(7); } inline void RoutingSubregion::clear_shiftodata() { shiftodata_ = 0u; - _clear_bit(6); + _clear_bit(7); } inline ::google::protobuf::uint32 RoutingSubregion::shiftodata() const { return shiftodata_; } inline void RoutingSubregion::set_shiftodata(::google::protobuf::uint32 value) { - _set_bit(6); + _set_bit(7); shiftodata_ = value; } diff --git a/Osmand-kernel/osmand/src/proto/osmand_odb.pb.h b/Osmand-kernel/osmand/src/proto/osmand_odb.pb.h index 11541aa1a1..8aea38f3cd 100644 --- a/Osmand-kernel/osmand/src/proto/osmand_odb.pb.h +++ b/Osmand-kernel/osmand/src/proto/osmand_odb.pb.h @@ -1,8 +1,8 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: src/osmand_odb.proto +// source: osmand_odb.proto -#ifndef PROTOBUF_src_2fosmand_5fodb_2eproto__INCLUDED -#define PROTOBUF_src_2fosmand_5fodb_2eproto__INCLUDED +#ifndef PROTOBUF_osmand_5fodb_2eproto__INCLUDED +#define PROTOBUF_osmand_5fodb_2eproto__INCLUDED #include @@ -26,9 +26,9 @@ // @@protoc_insertion_point(includes) // Internal implementation detail -- do not call these. -void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); -void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); -void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); +void protobuf_AddDesc_osmand_5fodb_2eproto(); +void protobuf_AssignDesc_osmand_5fodb_2eproto(); +void protobuf_ShutdownFile_osmand_5fodb_2eproto(); class OsmAndStructure; class OsmAndTileBox; @@ -223,9 +223,9 @@ class OsmAndStructure : public ::google::protobuf::Message { ::google::protobuf::RepeatedPtrField< ::OsmAndMapIndex > mapindex_; ::google::protobuf::RepeatedPtrField< ::OsmAndRoutingIndex > routingindex_; ::google::protobuf::uint32 versionconfirm_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(8 + 31) / 32]; @@ -336,9 +336,9 @@ class OsmAndTileBox : public ::google::protobuf::Message { ::google::protobuf::uint32 right_; ::google::protobuf::uint32 top_; ::google::protobuf::uint32 bottom_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; @@ -434,9 +434,9 @@ class StringTable : public ::google::protobuf::Message { mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::std::string> s_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; @@ -570,9 +570,9 @@ class IndexedStringTable : public ::google::protobuf::Message { ::google::protobuf::RepeatedPtrField< ::std::string> key_; ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > val_; ::google::protobuf::RepeatedPtrField< ::IndexedStringTable > subtables_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; @@ -699,9 +699,9 @@ class OsmAndMapIndex_MapEncodingRule : public ::google::protobuf::Message { ::google::protobuf::uint32 id_; ::google::protobuf::uint32 minzoom_; ::google::protobuf::uint32 type_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; @@ -854,9 +854,9 @@ class OsmAndMapIndex_MapRootLevel : public ::google::protobuf::Message { ::google::protobuf::int32 bottom_; ::google::protobuf::RepeatedPtrField< ::OsmAndMapIndex_MapDataBox > boxes_; ::google::protobuf::RepeatedPtrField< ::MapDataBlock > blocks_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(8 + 31) / 32]; @@ -996,9 +996,9 @@ class OsmAndMapIndex_MapDataBox : public ::google::protobuf::Message { ::google::protobuf::uint32 shifttomapdata_; bool ocean_; ::google::protobuf::RepeatedPtrField< ::OsmAndMapIndex_MapDataBox > boxes_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; @@ -1119,9 +1119,9 @@ class OsmAndMapIndex : public ::google::protobuf::Message { static const ::std::string _default_name_; ::google::protobuf::RepeatedPtrField< ::OsmAndMapIndex_MapEncodingRule > rules_; ::google::protobuf::RepeatedPtrField< ::OsmAndMapIndex_MapRootLevel > levels_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; @@ -1229,9 +1229,9 @@ class MapDataBlock : public ::google::protobuf::Message { ::google::protobuf::uint64 baseid_; ::google::protobuf::RepeatedPtrField< ::MapData > dataobjects_; ::StringTable* stringtable_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; @@ -1407,9 +1407,9 @@ class MapData : public ::google::protobuf::Message { ::google::protobuf::int64 id_; ::std::string* rasterbytes_; static const ::std::string _default_rasterbytes_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(8 + 31) / 32]; @@ -1522,9 +1522,9 @@ class OsmAndAddressIndex_CitiesIndex : public ::google::protobuf::Message { ::google::protobuf::uint32 type_; ::google::protobuf::RepeatedPtrField< ::CityIndex > cities_; ::google::protobuf::RepeatedPtrField< ::CityBlockIndex > blocks_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; @@ -1658,9 +1658,9 @@ class OsmAndAddressIndex : public ::google::protobuf::Message { ::OsmAndTileBox* boundaries_; ::google::protobuf::RepeatedPtrField< ::OsmAndAddressIndex_CitiesIndex > cities_; ::OsmAndAddressNameIndexData* nameindex_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; @@ -1752,9 +1752,9 @@ class OsmAndAddressNameIndexData_AddressNameIndexData : public ::google::protobu mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::AddressNameIndexDataAtom > atom_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; @@ -1856,9 +1856,9 @@ class OsmAndAddressNameIndexData : public ::google::protobuf::Message { ::IndexedStringTable* table_; ::google::protobuf::RepeatedPtrField< ::OsmAndAddressNameIndexData_AddressNameIndexData > atom_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; @@ -1995,9 +1995,9 @@ class AddressNameIndexDataAtom : public ::google::protobuf::Message { ::google::protobuf::uint32 type_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > shifttoindex_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > shifttocityindex_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; @@ -2140,9 +2140,9 @@ class CityIndex : public ::google::protobuf::Message { ::google::protobuf::uint32 x_; ::google::protobuf::uint32 y_; ::google::protobuf::uint32 shifttocityblockindex_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; @@ -2255,9 +2255,9 @@ class CityBlockIndex : public ::google::protobuf::Message { ::google::protobuf::uint32 shifttocityindex_; ::google::protobuf::RepeatedPtrField< ::BuildingIndex > buildings_; ::google::protobuf::RepeatedPtrField< ::StreetIndex > streets_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; @@ -2410,9 +2410,9 @@ class StreetIndex : public ::google::protobuf::Message { ::google::protobuf::uint64 id_; ::google::protobuf::RepeatedPtrField< ::BuildingIndex > buildings_; ::google::protobuf::RepeatedPtrField< ::StreetIntersection > intersections_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; @@ -2531,9 +2531,9 @@ class StreetIntersection : public ::google::protobuf::Message { static const ::std::string _default_name_en_; ::google::protobuf::int32 intersectedx_; ::google::protobuf::int32 intersectedy_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; @@ -2720,9 +2720,9 @@ class BuildingIndex : public ::google::protobuf::Message { ::google::protobuf::uint64 id_; ::std::string* postcode_; static const ::std::string _default_postcode_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(11 + 31) / 32]; @@ -2814,9 +2814,9 @@ class TransportRoutes : public ::google::protobuf::Message { mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::TransportRoute > routes_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; @@ -2981,9 +2981,9 @@ class TransportRoute : public ::google::protobuf::Message { ::google::protobuf::uint32 distance_; ::google::protobuf::RepeatedPtrField< ::TransportRouteStop > directstops_; ::google::protobuf::RepeatedPtrField< ::TransportRouteStop > reversestops_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(9 + 31) / 32]; @@ -3102,9 +3102,9 @@ class TransportRouteStop : public ::google::protobuf::Message { ::google::protobuf::int32 dy_; ::google::protobuf::uint32 name_; ::google::protobuf::uint32 name_en_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; @@ -3236,9 +3236,9 @@ class TransportStop : public ::google::protobuf::Message { ::google::protobuf::uint32 name_; ::google::protobuf::uint32 name_en_; ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > routes_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(6 + 31) / 32]; @@ -3383,9 +3383,9 @@ class TransportStopsTree : public ::google::protobuf::Message { ::google::protobuf::RepeatedPtrField< ::TransportStopsTree > subtrees_; ::google::protobuf::RepeatedPtrField< ::TransportStop > leafs_; ::google::protobuf::uint64 baseid_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; @@ -3500,9 +3500,9 @@ class OsmAndTransportIndex : public ::google::protobuf::Message { ::TransportRoutes* routes_; ::TransportStopsTree* stops_; ::StringTable* stringtable_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; @@ -3648,9 +3648,9 @@ class OsmAndPoiIndex : public ::google::protobuf::Message { ::OsmAndPoiNameIndex* nameindex_; ::google::protobuf::RepeatedPtrField< ::OsmAndPoiBox > boxes_; ::google::protobuf::RepeatedPtrField< ::OsmAndPoiBoxData > poidata_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(6 + 31) / 32]; @@ -3742,9 +3742,9 @@ class OsmAndPoiNameIndex_OsmAndPoiNameIndexData : public ::google::protobuf::Mes mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::OsmAndPoiNameIndexDataAtom > atoms_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; @@ -3846,9 +3846,9 @@ class OsmAndPoiNameIndex : public ::google::protobuf::Message { ::IndexedStringTable* table_; ::google::protobuf::RepeatedPtrField< ::OsmAndPoiNameIndex_OsmAndPoiNameIndexData > data_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; @@ -3959,9 +3959,9 @@ class OsmAndPoiNameIndexDataAtom : public ::google::protobuf::Message { ::google::protobuf::uint32 x_; ::google::protobuf::uint32 y_; ::google::protobuf::uint32 shiftto_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; @@ -4069,9 +4069,9 @@ class OsmAndCategoryTable : public ::google::protobuf::Message { ::std::string* category_; static const ::std::string _default_category_; ::google::protobuf::RepeatedPtrField< ::std::string> subcategories_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; @@ -4203,9 +4203,9 @@ class OsmAndPoiBox : public ::google::protobuf::Message { ::OsmAndPoiCategories* categories_; ::google::protobuf::RepeatedPtrField< ::OsmAndPoiBox > subboxes_; ::google::protobuf::uint32 shifttodata_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(6 + 31) / 32]; @@ -4297,9 +4297,9 @@ class OsmAndPoiCategories : public ::google::protobuf::Message { mutable int _cached_size_; ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > categories_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; @@ -4415,9 +4415,9 @@ class OsmAndPoiBoxData : public ::google::protobuf::Message { ::google::protobuf::uint32 x_; ::google::protobuf::uint32 y_; ::google::protobuf::RepeatedPtrField< ::OsmAndPoiBoxDataAtom > poidata_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; @@ -4605,9 +4605,9 @@ class OsmAndPoiBoxDataAtom : public ::google::protobuf::Message { static const ::std::string _default_phone_; ::std::string* note_; static const ::std::string _default_note_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(10 + 31) / 32]; @@ -4699,9 +4699,9 @@ class IdTable : public ::google::protobuf::Message { mutable int _cached_size_; ::google::protobuf::RepeatedField< ::google::protobuf::int64 > routeid_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; @@ -4812,9 +4812,9 @@ class RestrictionData : public ::google::protobuf::Message { ::google::protobuf::int32 from_; ::google::protobuf::int32 to_; ::google::protobuf::int32 via_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; @@ -4949,9 +4949,9 @@ class RouteData : public ::google::protobuf::Message { ::google::protobuf::int32 routeid_; ::std::string* stringnames_; static const ::std::string _default_stringnames_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; @@ -5062,9 +5062,9 @@ class OsmAndRoutingIndex_RouteEncodingRule : public ::google::protobuf::Message ::std::string* value_; static const ::std::string _default_value_; ::google::protobuf::uint32 id_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; @@ -5196,9 +5196,9 @@ class OsmAndRoutingIndex_RouteDataBox : public ::google::protobuf::Message { ::google::protobuf::int32 bottom_; ::google::protobuf::uint32 shifttodata_; ::google::protobuf::RepeatedPtrField< ::OsmAndRoutingIndex_RouteDataBox > boxes_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(6 + 31) / 32]; @@ -5319,9 +5319,9 @@ class OsmAndRoutingIndex_RouteDataBlock : public ::google::protobuf::Message { ::StringTable* stringtable_; ::google::protobuf::RepeatedPtrField< ::RouteData > dataobjects_; ::google::protobuf::RepeatedPtrField< ::RestrictionData > restrictions_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; @@ -5433,6 +5433,18 @@ class OsmAndRoutingIndex : public ::google::protobuf::Message { inline ::google::protobuf::RepeatedPtrField< ::OsmAndRoutingIndex_RouteDataBox >* mutable_rootboxes(); + // repeated .OsmAndRoutingIndex.RouteDataBox basemapBoxes = 4; + inline int basemapboxes_size() const; + inline void clear_basemapboxes(); + static const int kBasemapBoxesFieldNumber = 4; + inline const ::OsmAndRoutingIndex_RouteDataBox& basemapboxes(int index) const; + inline ::OsmAndRoutingIndex_RouteDataBox* mutable_basemapboxes(int index); + inline ::OsmAndRoutingIndex_RouteDataBox* add_basemapboxes(); + inline const ::google::protobuf::RepeatedPtrField< ::OsmAndRoutingIndex_RouteDataBox >& + basemapboxes() const; + inline ::google::protobuf::RepeatedPtrField< ::OsmAndRoutingIndex_RouteDataBox >* + mutable_basemapboxes(); + // repeated .OsmAndRoutingIndex.RouteDataBlock blocks = 5; inline int blocks_size() const; inline void clear_blocks(); @@ -5454,12 +5466,13 @@ class OsmAndRoutingIndex : public ::google::protobuf::Message { static const ::std::string _default_name_; ::google::protobuf::RepeatedPtrField< ::OsmAndRoutingIndex_RouteEncodingRule > rules_; ::google::protobuf::RepeatedPtrField< ::OsmAndRoutingIndex_RouteDataBox > rootboxes_; + ::google::protobuf::RepeatedPtrField< ::OsmAndRoutingIndex_RouteDataBox > basemapboxes_; ::google::protobuf::RepeatedPtrField< ::OsmAndRoutingIndex_RouteDataBlock > blocks_; - friend void protobuf_AddDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_AssignDesc_src_2fosmand_5fodb_2eproto(); - friend void protobuf_ShutdownFile_src_2fosmand_5fodb_2eproto(); + friend void protobuf_AddDesc_osmand_5fodb_2eproto(); + friend void protobuf_AssignDesc_osmand_5fodb_2eproto(); + friend void protobuf_ShutdownFile_osmand_5fodb_2eproto(); - ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; + ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; // WHY DOES & HAVE LOWER PRECEDENCE THAN != !? inline bool _has_bit(int index) const { @@ -10356,6 +10369,31 @@ OsmAndRoutingIndex::mutable_rootboxes() { return &rootboxes_; } +// repeated .OsmAndRoutingIndex.RouteDataBox basemapBoxes = 4; +inline int OsmAndRoutingIndex::basemapboxes_size() const { + return basemapboxes_.size(); +} +inline void OsmAndRoutingIndex::clear_basemapboxes() { + basemapboxes_.Clear(); +} +inline const ::OsmAndRoutingIndex_RouteDataBox& OsmAndRoutingIndex::basemapboxes(int index) const { + return basemapboxes_.Get(index); +} +inline ::OsmAndRoutingIndex_RouteDataBox* OsmAndRoutingIndex::mutable_basemapboxes(int index) { + return basemapboxes_.Mutable(index); +} +inline ::OsmAndRoutingIndex_RouteDataBox* OsmAndRoutingIndex::add_basemapboxes() { + return basemapboxes_.Add(); +} +inline const ::google::protobuf::RepeatedPtrField< ::OsmAndRoutingIndex_RouteDataBox >& +OsmAndRoutingIndex::basemapboxes() const { + return basemapboxes_; +} +inline ::google::protobuf::RepeatedPtrField< ::OsmAndRoutingIndex_RouteDataBox >* +OsmAndRoutingIndex::mutable_basemapboxes() { + return &basemapboxes_; +} + // repeated .OsmAndRoutingIndex.RouteDataBlock blocks = 5; inline int OsmAndRoutingIndex::blocks_size() const { return blocks_.size(); @@ -10395,4 +10433,4 @@ namespace protobuf { // @@protoc_insertion_point(global_scope) -#endif // PROTOBUF_src_2fosmand_5fodb_2eproto__INCLUDED +#endif // PROTOBUF_osmand_5fodb_2eproto__INCLUDED diff --git a/Osmand-kernel/osmand/src/renderRules.cpp b/Osmand-kernel/osmand/src/renderRules.cpp index 44a6f593ff..8a45f174dd 100644 --- a/Osmand-kernel/osmand/src/renderRules.cpp +++ b/Osmand-kernel/osmand/src/renderRules.cpp @@ -502,6 +502,7 @@ void RenderingRuleSearchRequest::setStringFilter(RenderingRuleProperty* p, std:: values[p->id] = storage->getDictionaryValue(filter); } } + void RenderingRuleSearchRequest::setIntFilter(RenderingRuleProperty* p, int filter) { if (p != NULL) { // assert p->input; diff --git a/Osmand-kernel/osmand/src/rendering.cpp b/Osmand-kernel/osmand/src/rendering.cpp index 1e0ad7e221..859190db77 100644 --- a/Osmand-kernel/osmand/src/rendering.cpp +++ b/Osmand-kernel/osmand/src/rendering.cpp @@ -28,7 +28,6 @@ #include "rendering.h" - struct MapDataObjectPrimitive { MapDataObject* obj; int typeInd; @@ -36,6 +35,8 @@ struct MapDataObjectPrimitive { int objectType; }; + + const int MAX_V = 32; void calcPoint(std::pair c, RenderingContext* rc) { @@ -234,7 +235,6 @@ void renderText(MapDataObject* obj, RenderingRuleSearchRequest* req, RenderingCo rc->textToDraw.push_back(info); } } - it++; } diff --git a/Osmand-kernel/osmand/src/textdraw.cpp b/Osmand-kernel/osmand/src/textdraw.cpp index 13a11633ab..6d2172de9f 100644 --- a/Osmand-kernel/osmand/src/textdraw.cpp +++ b/Osmand-kernel/osmand/src/textdraw.cpp @@ -114,6 +114,13 @@ private: } }; +inline float sqr(float a){ + return a*a; +} + +inline float absFloat(float a){ + return a > 0 ? a : -a; +} void fillTextProperties(TextDrawInfo* info, RenderingRuleSearchRequest* render, float cx, float cy) { @@ -217,19 +224,7 @@ bool calculatePathToRotate(RenderingContext* rc, TextDrawInfo* p) { int len = p->path->countPoints(); SkPoint points[len]; p->path->getPoints(points, len); - if (!p->drawOnPath) { - // simply calculate rotation of path used for shields - float px = 0; - float py = 0; - for (int i = 1; i < len; i++) { - px += points[i].fX - points[i - 1].fX; - py += points[i].fY - points[i - 1].fY; - } - if (px != 0 || py != 0) { - p->pathRotate = atan2(py, px); - } - return true; - } + bool inverse = false; float roadLength = 0; @@ -293,66 +288,98 @@ bool calculatePathToRotate(RenderingContext* rc, TextDrawInfo* p) { } while(ch); } } - // shrink path to display more text - if (startInd > 0 || endInd < len) { - // find subpath - SkPath* path = new SkPath; - for (int i = startInd; i < endInd; i++) { - if (i == startInd) { - path->moveTo(points[i].fX, points[i].fY); - } else { - path->lineTo(points[i].fX, points[i].fY); + + if (!p->drawOnPath) { + int middle = startInd + 1 + (endInd - startInd - 1) / 2; + + float px = 0; + float py = 0; + for (i = startInd; i < endInd; i++) { + px += points[i].fX ; + py += points[i].fY; + } + px /= (endInd - startInd); + py /= (endInd - startInd); + float cx = 0; + float cy = 0; + float cd = -1; + for (i = startInd + 1; i < endInd; i++) { + float fd = sqr(px - points[i].fX) + sqr(py - points[i].fY); + if (cd < 0 || fd < cd) { + cx = points[i].fX; + cy = points[i].fY; + cd = fd; } } - if (p->path != NULL) { - delete p->path; - } - p->path = path; - } - // calculate vector of the road (px, py) to proper rotate it - float px = 0; - float py = 0; - for (i = startInd + 1; i < endInd; i++) { - px += points[i].fX - points[i - 1].fX; - py += points[i].fY - points[i - 1].fY; - } - float scale = 0.5f; - float plen = sqrt(px * px + py * py); - // vector ox,oy orthogonal to px,py to measure height - float ox = -py; - float oy = px; - if(plen > 0) { - float rot = atan2(py, px); - if (rot < 0) rot += M_PI * 2; - if (rot > M_PI_2 && rot < 3 * M_PI_2) { - rot += M_PI; - inverse = true; - ox = -ox; - oy = -oy; - } - p->pathRotate = rot; - ox *= (p->bounds.height() / plen) / 2; - oy *= (p->bounds.height() / plen) / 2; - } + p->centerX = cx; + p->centerY = cy; + p->pathRotate = atan2(py, px); + p->vOffset += p->textSize / 2 - 1; + p->hOffset = 0; + } else { + // shrink path to display more text - p->centerX = points[startInd].fX + scale * px + ox; - p->centerY = points[startInd].fY + scale * py + oy; - p->vOffset += p->textSize / 2 - 1; - p->hOffset = 0; - - if (inverse) { - SkPath* path = new SkPath; - for (int i = endInd - 1; i >= startInd; i--) { - if (i == (int)(endInd - 1)) { - path->moveTo(points[i].fX, points[i].fY); - } else { - path->lineTo(points[i].fX, points[i].fY); + if (startInd > 0 || endInd < len) { + // find subpath + SkPath* path = new SkPath; + for (int i = startInd; i < endInd; i++) { + if (i == startInd) { + path->moveTo(points[i].fX, points[i].fY); + } else { + path->lineTo(points[i].fX, points[i].fY); + } } + if (p->path != NULL) { + delete p->path; + } + p->path = path; } - if (p->path != NULL) { - delete p->path; + // calculate vector of the road (px, py) to proper rotate it + float px = 0; + float py = 0; + for (i = startInd + 1; i < endInd; i++) { + px += points[i].fX - points[i - 1].fX; + py += points[i].fY - points[i - 1].fY; + } + float scale = 0.5f; + float plen = sqrt(px * px + py * py); + // vector ox,oy orthogonal to px,py to measure height + float ox = -py; + float oy = px; + if (plen > 0 ) { + float rot = atan2(py, px); + if (rot < 0) + rot += M_PI * 2; + if (rot > M_PI_2 && rot < 3 * M_PI_2) { + rot += M_PI; + inverse = true; + ox = -ox; + oy = -oy; + } + p->pathRotate = rot; + ox *= (p->bounds.height() / plen) / 2; + oy *= (p->bounds.height() / plen) / 2; + } + + p->centerX = points[startInd].fX + scale * px + ox; + p->centerY = points[startInd].fY + scale * py + oy; + p->vOffset += p->textSize / 2 - 1; + p->hOffset = 0; + + if (inverse) { + SkPath* path = new SkPath; + for (int i = endInd - 1; i >= startInd; i--) { + if (i == (int) (endInd - 1)) { + path->moveTo(points[i].fX, points[i].fY); + } else { + path->lineTo(points[i].fX, points[i].fY); + } + } + if (p->path != NULL) { + delete p->path; + } + p->path = path; } - p->path = path; } return true; } @@ -372,13 +399,6 @@ void drawTestBox(SkCanvas* cv, SkRect* r, float rot, SkPaint* paintIcon, std::st cv->restore(); } -inline float sqr(float a){ - return a*a; -} - -inline float absFloat(float a){ - return a > 0 ? a : -a; -} bool intersects(SkRect tRect, float tRot, TextDrawInfo* s) { @@ -496,8 +516,7 @@ void drawTextOverCanvas(RenderingContext* rc, SkCanvas* cv) { // 1. Sort text using text order std::sort(rc->textToDraw.begin(), rc->textToDraw.end(), textOrder); - uint32_t size = rc->textToDraw.size(); - for (uint32_t i = 0; i < size; i++) { + for (uint32_t i = 0; i < rc->textToDraw.size(); i++) { TextDrawInfo* text = rc->textToDraw.at(i); if (text->text.length() > 0) { // sest text size before finding intersection (it is used there)