From a885de61ec353b88864667b85a6f491825426f31 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 30 Jul 2016 13:14:41 +0200 Subject: [PATCH 1/2] update transport routes --- .../osmand/binary/BinaryMapIndexReader.java | 23 +- .../BinaryMapTransportReaderAdapter.java | 42 +- .../src/net/osmand/binary/OsmandOdb.java | 508 ++++++++---------- .../src/net/osmand/data/TransportRoute.java | 80 +-- .../plus/mapcontextmenu/MapContextMenu.java | 3 + .../controllers/TransportRouteController.java | 1 + .../resources/TransportIndexRepository.java | 59 -- .../TransportIndexRepositoryBinary.java | 93 ---- .../plus/views/TransportStopsLayer.java | 49 +- 9 files changed, 267 insertions(+), 591 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryMapIndexReader.java b/OsmAnd-java/src/net/osmand/binary/BinaryMapIndexReader.java index e477de876d..44466146c1 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryMapIndexReader.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryMapIndexReader.java @@ -473,28 +473,7 @@ public class BinaryMapIndexReader { return result; } - /** - * Transport public methods - */ - public List getTransportRouteDescriptions(TransportStop stop) throws IOException { - TransportIndex ind = getTransportIndex(stop.getFileOffset()); - if (ind == null) { - return null; - } - List list = new ArrayList(); - TIntObjectHashMap stringTable = new TIntObjectHashMap(); - for (int filePointer : stop.getReferencesToRoutes()) { - TransportRoute tr = transportAdapter.getTransportRoute(filePointer, stringTable, true); - if (tr != null) { - list.add(tr); - } - } - transportAdapter.initializeStringTable(ind, stringTable); - for (TransportRoute route : list) { - transportAdapter.initializeNames(true, route, stringTable); - } - return list; - } + public boolean transportStopBelongsTo(TransportStop s) { return getTransportIndex(s.getFileOffset()) != null; diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryMapTransportReaderAdapter.java b/OsmAnd-java/src/net/osmand/binary/BinaryMapTransportReaderAdapter.java index 3af2f2f44f..a7cb761bfa 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryMapTransportReaderAdapter.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryMapTransportReaderAdapter.java @@ -4,9 +4,7 @@ import gnu.trove.list.array.TIntArrayList; import gnu.trove.map.hash.TIntObjectHashMap; import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import net.osmand.binary.BinaryMapIndexReader.SearchRequest; import net.osmand.data.TransportStop; @@ -248,9 +246,6 @@ public class BinaryMapTransportReaderAdapter { long rid = 0; int rx = 0; int ry = 0; - long did = 0; - int dx = 0; - int dy = 0; while(!end){ int t = codedIS.readTag(); int tag = WireFormat.getTagFieldNumber(t); @@ -279,11 +274,7 @@ public class BinaryMapTransportReaderAdapter { case OsmandOdb.TransportRoute.OPERATOR_FIELD_NUMBER: dataObject.setOperator(regStr(stringTable)); //$NON-NLS-1$ break; - case OsmandOdb.TransportRoute.DIRECTGEOMETRY_FIELD_NUMBER: - case OsmandOdb.TransportRoute.REVERSEGEOMETRY_FIELD_NUMBER: - case OsmandOdb.TransportRoute.SHAREDGEOMETRY_FIELD_NUMBER: - int dir = tag == OsmandOdb.TransportRoute.SHAREDGEOMETRY_FIELD_NUMBER ? 0 : ( - tag == OsmandOdb.TransportRoute.DIRECTGEOMETRY_FIELD_NUMBER ? 1 : -1); + case OsmandOdb.TransportRoute.GEOMETRY_FIELD_NUMBER: int sizeL = codedIS.readRawVarint32(); int pold = codedIS.pushLimit(sizeL); int px = 0; @@ -294,7 +285,7 @@ public class BinaryMapTransportReaderAdapter { int ddy = (codedIS.readSInt32() << BinaryMapIndexReader.SHIFT_COORDINATES); if(ddx == 0 && ddy == 0) { if(w.getNodes().size() > 0) { - dataObject.addWay(w, dir); + dataObject.addWay(w); } w = new Way(-1); } else { @@ -306,11 +297,14 @@ public class BinaryMapTransportReaderAdapter { } } if(w.getNodes().size() > 0) { - dataObject.addWay(w, dir ); + dataObject.addWay(w); } codedIS.popLimit(pold); break; - case OsmandOdb.TransportRoute.REVERSESTOPS_FIELD_NUMBER: + // deprecated +// case OsmandOdb.TransportRoute.REVERSESTOPS_FIELD_NUMBER: +// break; + case OsmandOdb.TransportRoute.DIRECTSTOPS_FIELD_NUMBER: if(onlyDescription){ end = true; codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); @@ -318,22 +312,7 @@ public class BinaryMapTransportReaderAdapter { } int length = codedIS.readRawVarint32(); int olds = codedIS.pushLimit(length); - TransportStop stop = readTransportRouteStop(dx, dy, did, stringTable); - dataObject.getBackwardStops().add(stop); - did = stop.getId(); - dx = (int) MapUtils.getTileNumberX(BinaryMapIndexReader.TRANSPORT_STOP_ZOOM, stop.getLocation().getLongitude()); - dy = (int) MapUtils.getTileNumberY(BinaryMapIndexReader.TRANSPORT_STOP_ZOOM, stop.getLocation().getLatitude()); - codedIS.popLimit(olds); - break; - case OsmandOdb.TransportRoute.DIRECTSTOPS_FIELD_NUMBER: - if(onlyDescription){ - end = true; - codedIS.skipRawBytes(codedIS.getBytesUntilLimit()); - break; - } - length = codedIS.readRawVarint32(); - olds = codedIS.pushLimit(length); - stop = readTransportRouteStop(rx, ry, rid, stringTable); + TransportStop stop = readTransportRouteStop(rx, ry, rid, stringTable); dataObject.getForwardStops().add(stop); rid = stop.getId(); rx = (int) MapUtils.getTileNumberX(BinaryMapIndexReader.TRANSPORT_STOP_ZOOM, stop.getLocation().getLongitude()); @@ -400,9 +379,8 @@ public class BinaryMapTransportReaderAdapter { if(dataObject.getType().length() > 0){ dataObject.setType(stringTable.get(dataObject.getType().charAt(0))); } - for (int i = 0; i < 2 && !onlyDescription; i++) { - List stops = i == 0 ? dataObject.getForwardStops() : dataObject.getBackwardStops(); - for (TransportStop s : stops) { + if (!onlyDescription) { + for (TransportStop s : dataObject.getForwardStops()) { initializeNames(stringTable, s); } } diff --git a/OsmAnd-java/src/net/osmand/binary/OsmandOdb.java b/OsmAnd-java/src/net/osmand/binary/OsmandOdb.java index 08b657a046..f28ac6be64 100644 --- a/OsmAnd-java/src/net/osmand/binary/OsmandOdb.java +++ b/OsmAnd-java/src/net/osmand/binary/OsmandOdb.java @@ -29373,31 +29373,51 @@ public final class OsmandOdb { // repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+     * deprecated (not used any more)
+     * 
*/ java.util.List getReverseStopsList(); /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+     * deprecated (not used any more)
+     * 
*/ net.osmand.binary.OsmandOdb.TransportRouteStop getReverseStops(int index); /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+     * deprecated (not used any more)
+     * 
*/ int getReverseStopsCount(); /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+     * deprecated (not used any more)
+     * 
*/ java.util.List getReverseStopsOrBuilderList(); /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+     * deprecated (not used any more)
+     * 
*/ net.osmand.binary.OsmandOdb.TransportRouteStopOrBuilder getReverseStopsOrBuilder( int index); - // optional bytes directGeometry = 17; + // optional bytes geometry = 17; /** - * optional bytes directGeometry = 17; + * optional bytes geometry = 17; * *
      * array of delta x,y sint32 (CodedIinputStream) >> 5 (precision 31 >> 5)
@@ -29406,9 +29426,9 @@ public final class OsmandOdb {
      * 0, 0 split geometry (for not connected segments)
      * 
*/ - boolean hasDirectGeometry(); + boolean hasGeometry(); /** - * optional bytes directGeometry = 17; + * optional bytes geometry = 17; * *
      * array of delta x,y sint32 (CodedIinputStream) >> 5 (precision 31 >> 5)
@@ -29417,27 +29437,7 @@ public final class OsmandOdb {
      * 0, 0 split geometry (for not connected segments)
      * 
*/ - com.google.protobuf.ByteString getDirectGeometry(); - - // optional bytes reverseGeometry = 18; - /** - * optional bytes reverseGeometry = 18; - */ - boolean hasReverseGeometry(); - /** - * optional bytes reverseGeometry = 18; - */ - com.google.protobuf.ByteString getReverseGeometry(); - - // optional bytes sharedGeometry = 19; - /** - * optional bytes sharedGeometry = 19; - */ - boolean hasSharedGeometry(); - /** - * optional bytes sharedGeometry = 19; - */ - com.google.protobuf.ByteString getSharedGeometry(); + com.google.protobuf.ByteString getGeometry(); } /** * Protobuf type {@code OsmAnd.OBF.TransportRoute} @@ -29543,17 +29543,7 @@ public final class OsmandOdb { } case 138: { bitField0_ |= 0x00000080; - directGeometry_ = input.readBytes(); - break; - } - case 146: { - bitField0_ |= 0x00000100; - reverseGeometry_ = input.readBytes(); - break; - } - case 154: { - bitField0_ |= 0x00000200; - sharedGeometry_ = input.readBytes(); + geometry_ = input.readBytes(); break; } } @@ -29822,12 +29812,20 @@ public final class OsmandOdb { private java.util.List reverseStops_; /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+     * deprecated (not used any more)
+     * 
*/ public java.util.List getReverseStopsList() { return reverseStops_; } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+     * deprecated (not used any more)
+     * 
*/ public java.util.List getReverseStopsOrBuilderList() { @@ -29835,29 +29833,41 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+     * deprecated (not used any more)
+     * 
*/ public int getReverseStopsCount() { return reverseStops_.size(); } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+     * deprecated (not used any more)
+     * 
*/ public net.osmand.binary.OsmandOdb.TransportRouteStop getReverseStops(int index) { return reverseStops_.get(index); } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+     * deprecated (not used any more)
+     * 
*/ public net.osmand.binary.OsmandOdb.TransportRouteStopOrBuilder getReverseStopsOrBuilder( int index) { return reverseStops_.get(index); } - // optional bytes directGeometry = 17; - public static final int DIRECTGEOMETRY_FIELD_NUMBER = 17; - private com.google.protobuf.ByteString directGeometry_; + // optional bytes geometry = 17; + public static final int GEOMETRY_FIELD_NUMBER = 17; + private com.google.protobuf.ByteString geometry_; /** - * optional bytes directGeometry = 17; + * optional bytes geometry = 17; * *
      * array of delta x,y sint32 (CodedIinputStream) >> 5 (precision 31 >> 5)
@@ -29866,11 +29876,11 @@ public final class OsmandOdb {
      * 0, 0 split geometry (for not connected segments)
      * 
*/ - public boolean hasDirectGeometry() { + public boolean hasGeometry() { return ((bitField0_ & 0x00000080) == 0x00000080); } /** - * optional bytes directGeometry = 17; + * optional bytes geometry = 17; * *
      * array of delta x,y sint32 (CodedIinputStream) >> 5 (precision 31 >> 5)
@@ -29879,40 +29889,8 @@ public final class OsmandOdb {
      * 0, 0 split geometry (for not connected segments)
      * 
*/ - public com.google.protobuf.ByteString getDirectGeometry() { - return directGeometry_; - } - - // optional bytes reverseGeometry = 18; - public static final int REVERSEGEOMETRY_FIELD_NUMBER = 18; - private com.google.protobuf.ByteString reverseGeometry_; - /** - * optional bytes reverseGeometry = 18; - */ - public boolean hasReverseGeometry() { - return ((bitField0_ & 0x00000100) == 0x00000100); - } - /** - * optional bytes reverseGeometry = 18; - */ - public com.google.protobuf.ByteString getReverseGeometry() { - return reverseGeometry_; - } - - // optional bytes sharedGeometry = 19; - public static final int SHAREDGEOMETRY_FIELD_NUMBER = 19; - private com.google.protobuf.ByteString sharedGeometry_; - /** - * optional bytes sharedGeometry = 19; - */ - public boolean hasSharedGeometry() { - return ((bitField0_ & 0x00000200) == 0x00000200); - } - /** - * optional bytes sharedGeometry = 19; - */ - public com.google.protobuf.ByteString getSharedGeometry() { - return sharedGeometry_; + public com.google.protobuf.ByteString getGeometry() { + return geometry_; } private void initFields() { @@ -29925,9 +29903,7 @@ public final class OsmandOdb { distance_ = 0; directStops_ = java.util.Collections.emptyList(); reverseStops_ = java.util.Collections.emptyList(); - directGeometry_ = com.google.protobuf.ByteString.EMPTY; - reverseGeometry_ = com.google.protobuf.ByteString.EMPTY; - sharedGeometry_ = com.google.protobuf.ByteString.EMPTY; + geometry_ = com.google.protobuf.ByteString.EMPTY; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -29985,13 +29961,7 @@ public final class OsmandOdb { output.writeMessage(16, reverseStops_.get(i)); } if (((bitField0_ & 0x00000080) == 0x00000080)) { - output.writeBytes(17, directGeometry_); - } - if (((bitField0_ & 0x00000100) == 0x00000100)) { - output.writeBytes(18, reverseGeometry_); - } - if (((bitField0_ & 0x00000200) == 0x00000200)) { - output.writeBytes(19, sharedGeometry_); + output.writeBytes(17, geometry_); } getUnknownFields().writeTo(output); } @@ -30040,15 +30010,7 @@ public final class OsmandOdb { } if (((bitField0_ & 0x00000080) == 0x00000080)) { size += com.google.protobuf.CodedOutputStream - .computeBytesSize(17, directGeometry_); - } - if (((bitField0_ & 0x00000100) == 0x00000100)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(18, reverseGeometry_); - } - if (((bitField0_ & 0x00000200) == 0x00000200)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(19, sharedGeometry_); + .computeBytesSize(17, geometry_); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -30194,12 +30156,8 @@ public final class OsmandOdb { } else { reverseStopsBuilder_.clear(); } - directGeometry_ = com.google.protobuf.ByteString.EMPTY; + geometry_ = com.google.protobuf.ByteString.EMPTY; bitField0_ = (bitField0_ & ~0x00000200); - reverseGeometry_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000400); - sharedGeometry_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000800); return this; } @@ -30277,15 +30235,7 @@ public final class OsmandOdb { if (((from_bitField0_ & 0x00000200) == 0x00000200)) { to_bitField0_ |= 0x00000080; } - result.directGeometry_ = directGeometry_; - if (((from_bitField0_ & 0x00000400) == 0x00000400)) { - to_bitField0_ |= 0x00000100; - } - result.reverseGeometry_ = reverseGeometry_; - if (((from_bitField0_ & 0x00000800) == 0x00000800)) { - to_bitField0_ |= 0x00000200; - } - result.sharedGeometry_ = sharedGeometry_; + result.geometry_ = geometry_; result.bitField0_ = to_bitField0_; onBuilt(); return result; @@ -30377,14 +30327,8 @@ public final class OsmandOdb { } } } - if (other.hasDirectGeometry()) { - setDirectGeometry(other.getDirectGeometry()); - } - if (other.hasReverseGeometry()) { - setReverseGeometry(other.getReverseGeometry()); - } - if (other.hasSharedGeometry()) { - setSharedGeometry(other.getSharedGeometry()); + if (other.hasGeometry()) { + setGeometry(other.getGeometry()); } this.mergeUnknownFields(other.getUnknownFields()); return this; @@ -31036,6 +30980,10 @@ public final class OsmandOdb { /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public java.util.List getReverseStopsList() { if (reverseStopsBuilder_ == null) { @@ -31046,6 +30994,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public int getReverseStopsCount() { if (reverseStopsBuilder_ == null) { @@ -31056,6 +31008,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public net.osmand.binary.OsmandOdb.TransportRouteStop getReverseStops(int index) { if (reverseStopsBuilder_ == null) { @@ -31066,6 +31022,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public Builder setReverseStops( int index, net.osmand.binary.OsmandOdb.TransportRouteStop value) { @@ -31083,6 +31043,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public Builder setReverseStops( int index, net.osmand.binary.OsmandOdb.TransportRouteStop.Builder builderForValue) { @@ -31097,6 +31061,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public Builder addReverseStops(net.osmand.binary.OsmandOdb.TransportRouteStop value) { if (reverseStopsBuilder_ == null) { @@ -31113,6 +31081,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public Builder addReverseStops( int index, net.osmand.binary.OsmandOdb.TransportRouteStop value) { @@ -31130,6 +31102,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public Builder addReverseStops( net.osmand.binary.OsmandOdb.TransportRouteStop.Builder builderForValue) { @@ -31144,6 +31120,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public Builder addReverseStops( int index, net.osmand.binary.OsmandOdb.TransportRouteStop.Builder builderForValue) { @@ -31158,6 +31138,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public Builder addAllReverseStops( java.lang.Iterable values) { @@ -31172,6 +31156,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public Builder clearReverseStops() { if (reverseStopsBuilder_ == null) { @@ -31185,6 +31173,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public Builder removeReverseStops(int index) { if (reverseStopsBuilder_ == null) { @@ -31198,6 +31190,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public net.osmand.binary.OsmandOdb.TransportRouteStop.Builder getReverseStopsBuilder( int index) { @@ -31205,6 +31201,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public net.osmand.binary.OsmandOdb.TransportRouteStopOrBuilder getReverseStopsOrBuilder( int index) { @@ -31215,6 +31215,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public java.util.List getReverseStopsOrBuilderList() { @@ -31226,6 +31230,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public net.osmand.binary.OsmandOdb.TransportRouteStop.Builder addReverseStopsBuilder() { return getReverseStopsFieldBuilder().addBuilder( @@ -31233,6 +31241,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public net.osmand.binary.OsmandOdb.TransportRouteStop.Builder addReverseStopsBuilder( int index) { @@ -31241,6 +31253,10 @@ public final class OsmandOdb { } /** * repeated .OsmAnd.OBF.TransportRouteStop reverseStops = 16; + * + *
+       * deprecated (not used any more)
+       * 
*/ public java.util.List getReverseStopsBuilderList() { @@ -31261,10 +31277,10 @@ public final class OsmandOdb { return reverseStopsBuilder_; } - // optional bytes directGeometry = 17; - private com.google.protobuf.ByteString directGeometry_ = com.google.protobuf.ByteString.EMPTY; + // optional bytes geometry = 17; + private com.google.protobuf.ByteString geometry_ = com.google.protobuf.ByteString.EMPTY; /** - * optional bytes directGeometry = 17; + * optional bytes geometry = 17; * *
        * array of delta x,y sint32 (CodedIinputStream) >> 5 (precision 31 >> 5)
@@ -31273,11 +31289,11 @@ public final class OsmandOdb {
        * 0, 0 split geometry (for not connected segments)
        * 
*/ - public boolean hasDirectGeometry() { + public boolean hasGeometry() { return ((bitField0_ & 0x00000200) == 0x00000200); } /** - * optional bytes directGeometry = 17; + * optional bytes geometry = 17; * *
        * array of delta x,y sint32 (CodedIinputStream) >> 5 (precision 31 >> 5)
@@ -31286,11 +31302,11 @@ public final class OsmandOdb {
        * 0, 0 split geometry (for not connected segments)
        * 
*/ - public com.google.protobuf.ByteString getDirectGeometry() { - return directGeometry_; + public com.google.protobuf.ByteString getGeometry() { + return geometry_; } /** - * optional bytes directGeometry = 17; + * optional bytes geometry = 17; * *
        * array of delta x,y sint32 (CodedIinputStream) >> 5 (precision 31 >> 5)
@@ -31299,17 +31315,17 @@ public final class OsmandOdb {
        * 0, 0 split geometry (for not connected segments)
        * 
*/ - public Builder setDirectGeometry(com.google.protobuf.ByteString value) { + public Builder setGeometry(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } bitField0_ |= 0x00000200; - directGeometry_ = value; + geometry_ = value; onChanged(); return this; } /** - * optional bytes directGeometry = 17; + * optional bytes geometry = 17; * *
        * array of delta x,y sint32 (CodedIinputStream) >> 5 (precision 31 >> 5)
@@ -31318,81 +31334,9 @@ public final class OsmandOdb {
        * 0, 0 split geometry (for not connected segments)
        * 
*/ - public Builder clearDirectGeometry() { + public Builder clearGeometry() { bitField0_ = (bitField0_ & ~0x00000200); - directGeometry_ = getDefaultInstance().getDirectGeometry(); - onChanged(); - return this; - } - - // optional bytes reverseGeometry = 18; - private com.google.protobuf.ByteString reverseGeometry_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes reverseGeometry = 18; - */ - public boolean hasReverseGeometry() { - return ((bitField0_ & 0x00000400) == 0x00000400); - } - /** - * optional bytes reverseGeometry = 18; - */ - public com.google.protobuf.ByteString getReverseGeometry() { - return reverseGeometry_; - } - /** - * optional bytes reverseGeometry = 18; - */ - public Builder setReverseGeometry(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000400; - reverseGeometry_ = value; - onChanged(); - return this; - } - /** - * optional bytes reverseGeometry = 18; - */ - public Builder clearReverseGeometry() { - bitField0_ = (bitField0_ & ~0x00000400); - reverseGeometry_ = getDefaultInstance().getReverseGeometry(); - onChanged(); - return this; - } - - // optional bytes sharedGeometry = 19; - private com.google.protobuf.ByteString sharedGeometry_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes sharedGeometry = 19; - */ - public boolean hasSharedGeometry() { - return ((bitField0_ & 0x00000800) == 0x00000800); - } - /** - * optional bytes sharedGeometry = 19; - */ - public com.google.protobuf.ByteString getSharedGeometry() { - return sharedGeometry_; - } - /** - * optional bytes sharedGeometry = 19; - */ - public Builder setSharedGeometry(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000800; - sharedGeometry_ = value; - onChanged(); - return this; - } - /** - * optional bytes sharedGeometry = 19; - */ - public Builder clearSharedGeometry() { - bitField0_ = (bitField0_ & ~0x00000800); - sharedGeometry_ = getDefaultInstance().getSharedGeometry(); + geometry_ = getDefaultInstance().getGeometry(); onChanged(); return this; } @@ -57996,90 +57940,88 @@ public final class OsmandOdb { " \003(\t\022\030\n\020attributeTagIds2\030\021 \003(\r\022\030\n\020attrib" + "uteValues2\030\022 \003(\t\"=\n\017TransportRoutes\022*\n\006r" + "outes\030\006 \003(\0132\032.OsmAnd.OBF.TransportRoute\"" + - "\256\002\n\016TransportRoute\022\n\n\002id\030\001 \002(\004\022\014\n\004type\030\003" + + "\367\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\004n" + "ame\030\006 \001(\r\022\017\n\007name_en\030\007 \001(\r\022\020\n\010distance\030\010" + " \001(\r\0223\n\013directStops\030\017 \003(\0132\036.OsmAnd.OBF.T" + "ransportRouteStop\0224\n\014reverseStops\030\020 \003(\0132", - "\036.OsmAnd.OBF.TransportRouteStop\022\026\n\016direc" + - "tGeometry\030\021 \001(\014\022\027\n\017reverseGeometry\030\022 \001(\014" + - "\022\026\n\016sharedGeometry\030\023 \001(\014\"W\n\022TransportRou" + - "teStop\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\rTra" + - "nsportStop\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\"\272\001\n\022TransportStopsTree\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\0220\n\010subtrees\030\007 \003(\0132\036.OsmAn", - "d.OBF.TransportStopsTree\022(\n\005leafs\030\010 \003(\0132" + - "\031.OsmAnd.OBF.TransportStop\022\016\n\006baseId\030\020 \001" + - "(\004\"\256\001\n\024OsmAndTransportIndex\022\014\n\004name\030\001 \001(" + - "\t\022+\n\006routes\030\003 \001(\0132\033.OsmAnd.OBF.Transport" + - "Routes\022-\n\005stops\030\006 \001(\0132\036.OsmAnd.OBF.Trans" + - "portStopsTree\022,\n\013stringTable\030\t \002(\0132\027.Osm" + - "And.OBF.StringTable\"\312\002\n\016OsmAndPoiIndex\022\014" + - "\n\004name\030\001 \002(\t\022-\n\nboundaries\030\002 \002(\0132\031.OsmAn" + - "d.OBF.OsmAndTileBox\0228\n\017categoriesTable\030\003" + - " \003(\0132\037.OsmAnd.OBF.OsmAndCategoryTable\0221\n", - "\tnameIndex\030\004 \001(\0132\036.OsmAnd.OBF.OsmAndPoiN" + - "ameIndex\0226\n\rsubtypesTable\030\005 \001(\0132\037.OsmAnd" + - ".OBF.OsmAndSubtypesTable\022\'\n\005boxes\030\006 \003(\0132" + - "\030.OsmAnd.OBF.OsmAndPoiBox\022-\n\007poiData\030\t \003" + - "(\0132\034.OsmAnd.OBF.OsmAndPoiBoxData\"\331\001\n\022Osm" + - "AndPoiNameIndex\022-\n\005table\030\003 \002(\0132\036.OsmAnd." + - "OBF.IndexedStringTable\022C\n\004data\030\005 \003(\01325.O" + - "smAnd.OBF.OsmAndPoiNameIndex.OsmAndPoiNa" + - "meIndexData\032O\n\026OsmAndPoiNameIndexData\0225\n" + - "\005atoms\030\003 \003(\0132&.OsmAnd.OBF.OsmAndPoiNameI", - "ndexDataAtom\"Q\n\032OsmAndPoiNameIndexDataAt" + - "om\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\023OsmAndCategoryTable\022\020" + - "\n\010category\030\001 \002(\t\022\025\n\rsubcategories\030\003 \003(\t\"" + - "E\n\023OsmAndSubtypesTable\022.\n\010subtypes\030\004 \003(\013" + - "2\034.OsmAnd.OBF.OsmAndPoiSubtype\"\205\001\n\020OsmAn" + - "dPoiSubtype\022\014\n\004name\030\001 \002(\t\022\017\n\007tagname\030\002 \001" + - "(\t\022\016\n\006isText\030\003 \002(\010\022\021\n\tfrequency\030\005 \001(\r\022\031\n" + - "\021subtypeValuesSize\030\006 \001(\r\022\024\n\014subtypeValue" + - "\030\010 \003(\t\"\255\001\n\014OsmAndPoiBox\022\014\n\004zoom\030\001 \002(\r\022\014\n", - "\004left\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\0223\n\ncategories\030\004" + - " \001(\0132\037.OsmAnd.OBF.OsmAndPoiCategories\022*\n" + - "\010subBoxes\030\n \003(\0132\030.OsmAnd.OBF.OsmAndPoiBo" + - "x\022\023\n\013shiftToData\030\016 \001(\007\"@\n\023OsmAndPoiCateg" + - "ories\022\022\n\ncategories\030\003 \003(\r\022\025\n\rsubcategori" + - "es\030\005 \003(\r\"i\n\020OsmAndPoiBoxData\022\014\n\004zoom\030\001 \001" + - "(\r\022\t\n\001x\030\002 \001(\r\022\t\n\001y\030\003 \001(\r\0221\n\007poiData\030\005 \003(" + - "\0132 .OsmAnd.OBF.OsmAndPoiBoxDataAtom\"\360\001\n\024" + - "OsmAndPoiBoxDataAtom\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\025\n\rsubcategorie", - "s\030\005 \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\005phone\030\014 \001(\t\022\014\n\004note\030\r \001(\t\022\026\n\016te" + - "xtCategories\030\016 \003(\r\022\022\n\ntextValues\030\017 \003(\t\"\032" + - "\n\007IdTable\022\017\n\007routeId\030\001 \003(\022\"F\n\017Restrictio" + - "nData\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\"x\n\tRouteData\022\016\n\006point" + - "s\030\001 \002(\014\022\022\n\npointTypes\030\004 \001(\014\022\022\n\npointName" + - "s\030\005 \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\"\304\005\n\022OsmAndRoutingIn", - "dex\022\014\n\004name\030\001 \002(\t\022?\n\005rules\030\002 \003(\01320.OsmAn" + - "d.OBF.OsmAndRoutingIndex.RouteEncodingRu" + - "le\022>\n\trootBoxes\030\003 \003(\0132+.OsmAnd.OBF.OsmAn" + - "dRoutingIndex.RouteDataBox\022A\n\014basemapBox" + - "es\030\004 \003(\0132+.OsmAnd.OBF.OsmAndRoutingIndex" + - ".RouteDataBox\022=\n\006blocks\030\005 \003(\0132-.OsmAnd.O" + - "BF.OsmAndRoutingIndex.RouteDataBlock\032;\n\021" + - "RouteEncodingRule\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\231\001\n\014RouteDataBox\022\014\n\004le" + - "ft\030\001 \002(\021\022\r\n\005right\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022\016\n\006", - "bottom\030\004 \002(\021\022\023\n\013shiftToData\030\005 \001(\007\022:\n\005box" + - "es\030\007 \003(\0132+.OsmAnd.OBF.OsmAndRoutingIndex" + - ".RouteDataBox\032\303\001\n\016RouteDataBlock\022$\n\007idTa" + - "ble\030\005 \001(\0132\023.OsmAnd.OBF.IdTable\022*\n\013dataOb" + - "jects\030\006 \003(\0132\025.OsmAnd.OBF.RouteData\0221\n\014re" + - "strictions\030\007 \003(\0132\033.OsmAnd.OBF.Restrictio" + - "nData\022,\n\013stringTable\030\010 \001(\0132\027.OsmAnd.OBF." + - "StringTableB\036\n\021net.osmand.binaryB\tOsmand" + - "Odb" + "\036.OsmAnd.OBF.TransportRouteStop\022\020\n\010geome" + + "try\030\021 \001(\014\"W\n\022TransportRouteStop\022\n\n\002id\030\001 " + + "\002(\022\022\n\n\002dx\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021\022\014\n\004name\030\006 \002(" + + "\r\022\017\n\007name_en\030\007 \001(\r\"b\n\rTransportStop\022\n\n\002d" + + "x\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\"\272" + + "\001\n\022TransportStopsTree\022\014\n\004left\030\001 \002(\021\022\r\n\005r" + + "ight\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022\016\n\006bottom\030\004 \002(\021\022" + + "0\n\010subtrees\030\007 \003(\0132\036.OsmAnd.OBF.Transport" + + "StopsTree\022(\n\005leafs\030\010 \003(\0132\031.OsmAnd.OBF.Tr", + "ansportStop\022\016\n\006baseId\030\020 \001(\004\"\256\001\n\024OsmAndTr" + + "ansportIndex\022\014\n\004name\030\001 \001(\t\022+\n\006routes\030\003 \001" + + "(\0132\033.OsmAnd.OBF.TransportRoutes\022-\n\005stops" + + "\030\006 \001(\0132\036.OsmAnd.OBF.TransportStopsTree\022," + + "\n\013stringTable\030\t \002(\0132\027.OsmAnd.OBF.StringT" + + "able\"\312\002\n\016OsmAndPoiIndex\022\014\n\004name\030\001 \002(\t\022-\n" + + "\nboundaries\030\002 \002(\0132\031.OsmAnd.OBF.OsmAndTil" + + "eBox\0228\n\017categoriesTable\030\003 \003(\0132\037.OsmAnd.O" + + "BF.OsmAndCategoryTable\0221\n\tnameIndex\030\004 \001(" + + "\0132\036.OsmAnd.OBF.OsmAndPoiNameIndex\0226\n\rsub", + "typesTable\030\005 \001(\0132\037.OsmAnd.OBF.OsmAndSubt" + + "ypesTable\022\'\n\005boxes\030\006 \003(\0132\030.OsmAnd.OBF.Os" + + "mAndPoiBox\022-\n\007poiData\030\t \003(\0132\034.OsmAnd.OBF" + + ".OsmAndPoiBoxData\"\331\001\n\022OsmAndPoiNameIndex" + + "\022-\n\005table\030\003 \002(\0132\036.OsmAnd.OBF.IndexedStri" + + "ngTable\022C\n\004data\030\005 \003(\01325.OsmAnd.OBF.OsmAn" + + "dPoiNameIndex.OsmAndPoiNameIndexData\032O\n\026" + + "OsmAndPoiNameIndexData\0225\n\005atoms\030\003 \003(\0132&." + + "OsmAnd.OBF.OsmAndPoiNameIndexDataAtom\"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\007shiftTo\030\016 \001(\007" + + "\">\n\023OsmAndCategoryTable\022\020\n\010category\030\001 \002(" + + "\t\022\025\n\rsubcategories\030\003 \003(\t\"E\n\023OsmAndSubtyp" + + "esTable\022.\n\010subtypes\030\004 \003(\0132\034.OsmAnd.OBF.O" + + "smAndPoiSubtype\"\205\001\n\020OsmAndPoiSubtype\022\014\n\004" + + "name\030\001 \002(\t\022\017\n\007tagname\030\002 \001(\t\022\016\n\006isText\030\003 " + + "\002(\010\022\021\n\tfrequency\030\005 \001(\r\022\031\n\021subtypeValuesS" + + "ize\030\006 \001(\r\022\024\n\014subtypeValue\030\010 \003(\t\"\255\001\n\014OsmA" + + "ndPoiBox\022\014\n\004zoom\030\001 \002(\r\022\014\n\004left\030\002 \002(\021\022\013\n\003" + + "top\030\003 \002(\021\0223\n\ncategories\030\004 \001(\0132\037.OsmAnd.O", + "BF.OsmAndPoiCategories\022*\n\010subBoxes\030\n \003(\013" + + "2\030.OsmAnd.OBF.OsmAndPoiBox\022\023\n\013shiftToDat" + + "a\030\016 \001(\007\"@\n\023OsmAndPoiCategories\022\022\n\ncatego" + + "ries\030\003 \003(\r\022\025\n\rsubcategories\030\005 \003(\r\"i\n\020Osm" + + "AndPoiBoxData\022\014\n\004zoom\030\001 \001(\r\022\t\n\001x\030\002 \001(\r\022\t" + + "\n\001y\030\003 \001(\r\0221\n\007poiData\030\005 \003(\0132 .OsmAnd.OBF." + + "OsmAndPoiBoxDataAtom\"\360\001\n\024OsmAndPoiBoxDat" + + "aAtom\022\n\n\002dx\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021\022\022\n\ncategor" + + "ies\030\004 \003(\r\022\025\n\rsubcategories\030\005 \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\014op", + "eningHours\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\022\026\n\016textCategories\030\016 " + + "\003(\r\022\022\n\ntextValues\030\017 \003(\t\"\032\n\007IdTable\022\017\n\007ro" + + "uteId\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\"x\n\tRouteData\022\016\n\006points\030\001 \002(\014\022\022\n\npoin" + + "tTypes\030\004 \001(\014\022\022\n\npointNames\030\005 \001(\014\022\r\n\005type" + + "s\030\007 \002(\014\022\017\n\007routeId\030\014 \002(\005\022\023\n\013stringNames\030" + + "\016 \001(\014\"\304\005\n\022OsmAndRoutingIndex\022\014\n\004name\030\001 \002" + + "(\t\022?\n\005rules\030\002 \003(\01320.OsmAnd.OBF.OsmAndRou", + "tingIndex.RouteEncodingRule\022>\n\trootBoxes" + + "\030\003 \003(\0132+.OsmAnd.OBF.OsmAndRoutingIndex.R" + + "outeDataBox\022A\n\014basemapBoxes\030\004 \003(\0132+.OsmA" + + "nd.OBF.OsmAndRoutingIndex.RouteDataBox\022=" + + "\n\006blocks\030\005 \003(\0132-.OsmAnd.OBF.OsmAndRoutin" + + "gIndex.RouteDataBlock\032;\n\021RouteEncodingRu" + + "le\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\231\001\n\014RouteDataBox\022\014\n\004left\030\001 \002(\021\022\r\n\005rig" + + "ht\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+.OsmA", + "nd.OBF.OsmAndRoutingIndex.RouteDataBox\032\303" + + "\001\n\016RouteDataBlock\022$\n\007idTable\030\005 \001(\0132\023.Osm" + + "And.OBF.IdTable\022*\n\013dataObjects\030\006 \003(\0132\025.O" + + "smAnd.OBF.RouteData\0221\n\014restrictions\030\007 \003(" + + "\0132\033.OsmAnd.OBF.RestrictionData\022,\n\013string" + + "Table\030\010 \001(\0132\027.OsmAnd.OBF.StringTableB\036\n\021" + + "net.osmand.binaryB\tOsmandOdb" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -58217,7 +58159,7 @@ public final class OsmandOdb { internal_static_OsmAnd_OBF_TransportRoute_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_OsmAnd_OBF_TransportRoute_descriptor, - new java.lang.String[] { "Id", "Type", "Operator", "Ref", "Name", "NameEn", "Distance", "DirectStops", "ReverseStops", "DirectGeometry", "ReverseGeometry", "SharedGeometry", }); + new java.lang.String[] { "Id", "Type", "Operator", "Ref", "Name", "NameEn", "Distance", "DirectStops", "ReverseStops", "Geometry", }); internal_static_OsmAnd_OBF_TransportRouteStop_descriptor = getDescriptor().getMessageTypes().get(17); internal_static_OsmAnd_OBF_TransportRouteStop_fieldAccessorTable = new diff --git a/OsmAnd-java/src/net/osmand/data/TransportRoute.java b/OsmAnd-java/src/net/osmand/data/TransportRoute.java index 21a02315dd..fba6544fad 100644 --- a/OsmAnd-java/src/net/osmand/data/TransportRoute.java +++ b/OsmAnd-java/src/net/osmand/data/TransportRoute.java @@ -1,7 +1,6 @@ package net.osmand.data; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import net.osmand.osm.edit.Way; @@ -9,16 +8,11 @@ import net.osmand.util.MapUtils; public class TransportRoute extends MapObject { private List forwardStops = new ArrayList(); - private List backwardStops = new ArrayList(); private String ref; private String operator; private String type; private Integer dist = null; private List forwardWays; - private List forwardAggWays; - private List backwardWays; - private List backwardAggWays; - private List sharedWays; public TransportRoute(){ } @@ -27,69 +21,17 @@ public class TransportRoute extends MapObject { return forwardStops; } - public List getBackwardStops() { - return backwardStops; - } - - public List getAggregateForwardWays() { - if(forwardAggWays != null){ - return forwardAggWays; - } - forwardAggWays = new ArrayList<>(); - if(forwardWays != null) { - forwardAggWays.addAll(forwardWays); - } - if(sharedWays != null) { - forwardAggWays.addAll(sharedWays); - } - return forwardAggWays; - } - - public List getAggregateBackwardWays() { - if (backwardAggWays != null) { - return backwardAggWays; - } - backwardAggWays = new ArrayList<>(); - if (backwardWays != null) { - backwardAggWays.addAll(backwardWays); - } - if (sharedWays != null) { - backwardAggWays.addAll(sharedWays); - } - return backwardAggWays; - } - - public List getSharedWays() { - return sharedWays; - } - public List getForwardWays() { return forwardWays; } - public List getBackwardWays() { - return backwardWays; - } - public void addWay(Way w, int direction){ - if(direction > 0) { - if(forwardWays == null) { - forwardWays = new ArrayList<>(); - } - forwardWays.add(w); - } - if(direction < 0) { - if(backwardWays == null) { - backwardWays = new ArrayList<>(); - } - backwardWays.add(w); - } - if(direction == 0) { - if(sharedWays == null) { - sharedWays = new ArrayList<>(); - } - sharedWays.add(w); + public void addWay(Way w) { + if (forwardWays == null) { + forwardWays = new ArrayList<>(); } + forwardWays.add(w); + } public String getRef() { @@ -127,15 +69,11 @@ public class TransportRoute extends MapObject { this.dist = dist; } - public int getAvgBothDistance(){ + public int getAvgBothDistance() { int d = 0; - int bSsize = backwardStops.size(); - int fSsize = forwardStops.size(); - for(int i=1; i< bSsize; i++){ - d += MapUtils.getDistance(backwardStops.get(i-1).getLocation(), backwardStops.get(i).getLocation()); - } - for(int i=1; i< fSsize; i++){ - d += MapUtils.getDistance(forwardStops.get(i-1).getLocation(), forwardStops.get(i).getLocation()); + int fSsize = forwardStops.size(); + for (int i = 1; i < fSsize; i++) { + d += MapUtils.getDistance(forwardStops.get(i - 1).getLocation(), forwardStops.get(i).getLocation()); } return d; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 3bbd59b0a5..22dd98e7ce 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -344,6 +344,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL if (object instanceof MapMarker) { mapActivity.getMyApplication().getMapMarkersHelper().removeListener(this); } + if(menuController != null) { + menuController.onClose(); + } if (this.object != null) { clearSelectedObject(this.object); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index a69b674931..7356066ff6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -61,6 +61,7 @@ public class TransportRouteController extends MenuController { return false; } + @Override public boolean buttonsVisible() { return false; diff --git a/OsmAnd/src/net/osmand/plus/resources/TransportIndexRepository.java b/OsmAnd/src/net/osmand/plus/resources/TransportIndexRepository.java index a4eec127cb..a2b5ea2122 100644 --- a/OsmAnd/src/net/osmand/plus/resources/TransportIndexRepository.java +++ b/OsmAnd/src/net/osmand/plus/resources/TransportIndexRepository.java @@ -4,7 +4,6 @@ import java.util.Collection; import java.util.List; import net.osmand.ResultMatcher; -import net.osmand.data.LatLon; import net.osmand.data.TransportRoute; import net.osmand.data.TransportStop; @@ -20,65 +19,7 @@ public interface TransportIndexRepository { int limit, List stops, ResultMatcher matcher); public Collection getRouteForStop(TransportStop stop); - - public List searchTransportRouteStops(double latitude, double longitude, LatLon locationToGo, int zoom); public void close(); - public static class RouteInfoLocation { - private TransportStop start; - private TransportStop stop; - private TransportRoute route; - private int stopNumbers; - private int distToLocation; - private boolean direction; - - public TransportStop getStart() { - return start; - } - - public TransportRoute getRoute() { - return route; - } - - public boolean getDirection(){ - return direction; - } - - public void setDirection(boolean direction) { - this.direction = direction; - } - - public int getDistToLocation() { - return distToLocation; - } - - public void setStart(TransportStop start) { - this.start = start; - } - - public TransportStop getStop() { - return stop; - } - - public int getStopNumbers() { - return stopNumbers; - } - - public void setStopNumbers(int stopNumbers) { - this.stopNumbers = stopNumbers; - } - - public void setStop(TransportStop stop) { - this.stop = stop; - } - - public void setRoute(TransportRoute route) { - this.route = route; - } - - public void setDistToLocation(int distToLocation) { - this.distToLocation = distToLocation; - } - } } diff --git a/OsmAnd/src/net/osmand/plus/resources/TransportIndexRepositoryBinary.java b/OsmAnd/src/net/osmand/plus/resources/TransportIndexRepositoryBinary.java index 8da790ef19..a671b80a42 100644 --- a/OsmAnd/src/net/osmand/plus/resources/TransportIndexRepositoryBinary.java +++ b/OsmAnd/src/net/osmand/plus/resources/TransportIndexRepositoryBinary.java @@ -69,99 +69,6 @@ public class TransportIndexRepositoryBinary implements TransportIndexRepository return Collections.emptyList(); } - - @Override - public List searchTransportRouteStops(double latitude, double longitude, LatLon locationToGo, int zoom) { - long now = System.currentTimeMillis(); - final LatLon loc = new LatLon(latitude, longitude); - double tileNumberX = MapUtils.getTileNumberX(zoom, longitude); - double tileNumberY = MapUtils.getTileNumberY(zoom, latitude); - double topLatitude = MapUtils.getLatitudeFromTile(zoom, tileNumberY - 0.5); - double bottomLatitude = MapUtils.getLatitudeFromTile(zoom, tileNumberY + 0.5); - double leftLongitude = MapUtils.getLongitudeFromTile(zoom, tileNumberX - 0.5); - double rightLongitude = MapUtils.getLongitudeFromTile(zoom, tileNumberX + 0.5); - SearchRequest req = BinaryMapIndexReader.buildSearchTransportRequest(MapUtils.get31TileNumberX(leftLongitude), - MapUtils.get31TileNumberX(rightLongitude), MapUtils.get31TileNumberY(topLatitude), MapUtils - .get31TileNumberY(bottomLatitude), -1, null); - List listRoutes = new ArrayList(); - try { - List stops = file.searchTransportIndex(req); - - TIntObjectHashMap stopsToProcess = new TIntObjectHashMap(); - for (TransportStop s : stops) { - for (int ref : s.getReferencesToRoutes()) { - TransportStop exist = stopsToProcess.get(ref); - if (exist == null || MapUtils.getDistance(loc, s.getLocation()) < MapUtils.getDistance(loc, exist.getLocation())) { - stopsToProcess.put(ref, s); - } - } - } - TIntObjectHashMap transportRoutes = file.getTransportRoutes(stopsToProcess.keys()); - for (int ref : stopsToProcess.keys()) { - TransportRoute route = transportRoutes.get(ref); - TransportStop s = stopsToProcess.get(ref); - for (int i = 0; i < 2; i++) { - boolean direction = i == 0; - List stps = direction ? route.getForwardStops() : route.getBackwardStops(); - // load only part - - while (!stps.isEmpty() && (stps.get(0).getId().longValue() != s.getId().longValue())) { - stps.remove(0); - } - if (!stps.isEmpty()) { - RouteInfoLocation r = new RouteInfoLocation(); - r.setRoute(route); - r.setStart(stps.get(0)); - r.setDirection(direction); - if (locationToGo != null) { - int distToLoc = Integer.MAX_VALUE; - for (TransportStop st : stps) { - double ndist = MapUtils.getDistance(locationToGo, st.getLocation()); - if (ndist < distToLoc) { - distToLoc = (int) ndist; - r.setStop(st); - r.setDistToLocation(distToLoc); - } - } - - } - listRoutes.add(r); - } - } - } - if (log.isDebugEnabled()) { - log.debug(String.format("Search for routes done in %s ms found %s.", //$NON-NLS-1$ - System.currentTimeMillis() - now, listRoutes.size())); - } - - if (locationToGo != null) { - Collections.sort(listRoutes, new Comparator() { - @Override - public int compare(RouteInfoLocation object1, RouteInfoLocation object2) { - int x = (int) (MapUtils.getDistance(loc, object1.getStart().getLocation()) + object1.getDistToLocation()); - int y = (int) (MapUtils.getDistance(loc, object2.getStart().getLocation()) + object2.getDistToLocation()); - return x - y; - } - - }); - } else { - Collections.sort(listRoutes, new Comparator() { - @Override - public int compare(RouteInfoLocation object1, RouteInfoLocation object2) { - return Double.compare(MapUtils.getDistance(loc, object1.getStart().getLocation()), MapUtils.getDistance(loc, - object2.getStart().getLocation())); - } - - }); - } - } catch (IOException e) { - log.error("Disk error", e); //$NON-NLS-1$ - } - return listRoutes; - - } - - @Override public boolean acceptTransportStop(TransportStop stop) { return file.transportStopBelongsTo(stop); diff --git a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java index 6b2abc2813..bf0c8dd50a 100644 --- a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java @@ -1,17 +1,13 @@ package net.osmand.plus.views; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.Path; -import android.graphics.PointF; -import android.util.DisplayMetrics; -import android.view.WindowManager; -import net.osmand.Location; +import gnu.trove.list.array.TIntArrayList; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + import net.osmand.ResultMatcher; -import net.osmand.data.Amenity; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; @@ -22,13 +18,15 @@ import net.osmand.data.TransportStop; import net.osmand.osm.edit.Node; import net.osmand.osm.edit.Way; import net.osmand.plus.R; -import net.osmand.plus.poi.PoiUIFilter; -import gnu.trove.list.array.TIntArrayList; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.PointF; +import android.util.DisplayMetrics; +import android.view.WindowManager; public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider { private static final int startZoom = 12; @@ -170,19 +168,8 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); try { path.reset(); - List ws = route.getAggregateForwardWays(); - for (Way w : ws) { - TIntArrayList tx = new TIntArrayList(); - TIntArrayList ty = new TIntArrayList(); - for (int i = 0; i < w.getNodes().size(); i++) { - Node o = w.getNodes().get(i); - int x = (int) tb.getPixXFromLatLon(o.getLatitude(), o.getLongitude()); - int y = (int) tb.getPixYFromLatLon(o.getLatitude(), o.getLongitude()); - tx.add(x); - ty.add(y); - } - calculatePath(tb, tx, ty, path); - } + List ws = route.getForwardWays(); + if (ws != null) attrs.drawPath(canvas, path); } finally { canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); From 05e104bc4b3e84d0ef5a66705512171f2666267f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 30 Jul 2016 13:19:22 +0200 Subject: [PATCH 2/2] update transport routes --- OsmAnd/res/values/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 47da14ea4c..559fb559a9 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -18,6 +18,7 @@ \u2022 New very powerful free text search\n\n \u2022 Much improved audio over Bluetooth\n\n \u2022 Improved route guidance, voice prompting, and turn lane indication\n\n + \u2022 Improved transport layer\n\n \u2022 Added more locales and now support regional locales\n\n \u2022 Many other improvements and bug fixes\n\n and moreā€¦