diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java index c8f84796b9..f9015ec48d 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexReader.java @@ -696,6 +696,7 @@ public class BinaryMapIndexReader { private void readMapIndex(MapIndex index, boolean onlyInitEncodingRules) throws IOException { int defaultId = 1; int oldLimit; + int encodingRulesSize = 0; while (true) { int t = codedIS.readTag(); int tag = WireFormat.getTagFieldNumber(t); @@ -712,10 +713,14 @@ public class BinaryMapIndexReader { break; case OsmandOdb.OsmAndMapIndex.RULES_FIELD_NUMBER : if (onlyInitEncodingRules) { + if(encodingRulesSize == 0) { + encodingRulesSize = codedIS.getTotalBytesRead(); + } int len = codedIS.readInt32(); oldLimit = codedIS.pushLimit(len); readMapEncodingRule(index, defaultId++); codedIS.popLimit(oldLimit); + index.encodingRulesSizeBytes = (codedIS.getTotalBytesRead() - encodingRulesSize); } else { skipUnknownField(t); } @@ -1829,10 +1834,13 @@ public class BinaryMapIndexReader { public int onewayReverseAttribute = -1; public TIntHashSet positiveLayers = new TIntHashSet(2); public TIntHashSet negativeLayers = new TIntHashSet(2); + public int encodingRulesSizeBytes; // to speed up comparision private MapIndex referenceMapIndex; + + public Integer getRule(String t, String v) { Map m = encodingRules.get(t); if (m != null) { diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapRouteReaderAdapter.java b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapRouteReaderAdapter.java index c98ec6396f..8431df7244 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapRouteReaderAdapter.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapRouteReaderAdapter.java @@ -292,6 +292,7 @@ public class BinaryMapRouteReaderAdapter { public static class RouteRegion extends BinaryIndexPart { public int regionsRead; public List routeEncodingRules = new ArrayList(); + public int routeEncodingRulesBytes = 0; public Map decodingRules = null; List subregions = new ArrayList(); List basesubregions = new ArrayList(); @@ -614,6 +615,7 @@ public class BinaryMapRouteReaderAdapter { protected void readRouteIndex(RouteRegion region) throws IOException { int routeEncodingRule = 1; + int routeEncodingRulesSize = 0; while(true){ int t = codedIS.readTag(); int tag = WireFormat.getTagFieldNumber(t); @@ -626,10 +628,13 @@ public class BinaryMapRouteReaderAdapter { break; case OsmandOdb.OsmAndRoutingIndex.RULES_FIELD_NUMBER: { int len = codedIS.readInt32(); + if(routeEncodingRulesSize == 0) { + routeEncodingRulesSize = codedIS.getTotalBytesRead(); + } int oldLimit = codedIS.pushLimit(len); readRouteEncodingRule(region, routeEncodingRule++); - codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); codedIS.popLimit(oldLimit); + region.routeEncodingRulesBytes = codedIS.getTotalBytesRead() - routeEncodingRulesSize; } break; case OsmandOdb.OsmAndRoutingIndex.ROOTBOXES_FIELD_NUMBER : case OsmandOdb.OsmAndRoutingIndex.BASEMAPBOXES_FIELD_NUMBER :{