From ac7cfffdd4aab64d35ad52e176ae513ea4958176 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 29 Jul 2019 15:36:38 +0200 Subject: [PATCH] Important changes for transport stop generation --- .../main/java/net/osmand/data/TransportStop.java | 14 ++++++++++++-- .../src/main/java/net/osmand/util/Algorithms.java | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/data/TransportStop.java b/OsmAnd-java/src/main/java/net/osmand/data/TransportStop.java index f2ad41586f..87b37ca029 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/TransportStop.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/TransportStop.java @@ -19,10 +19,18 @@ public class TransportStop extends MapObject { public int x31; public int y31; private List exits; + private List routes = null; private TransportStopAggregated transportStopAggregated; - public TransportStop() { + public TransportStop() {} + + public List getRoutes() { + return routes; + } + + public void setRoutes(List routes) { + this.routes = routes; } public int[] getReferencesToRoutes() { @@ -38,10 +46,12 @@ public class TransportStop extends MapObject { } public void setRoutesIds(long[] routesIds) { + // CHECK route ids are sorted (used later) this.routesIds = routesIds; } public boolean hasRoute(long routeId) { + // make assumption that ids are sorted return routesIds != null && Arrays.binarySearch(routesIds, routeId) >= 0; } @@ -62,6 +72,7 @@ public class TransportStop extends MapObject { } public void addRouteId(long routeId) { + // make assumption that ids are sorted routesIds = Algorithms.addToArrayL(routesIds, routeId, true); } @@ -69,7 +80,6 @@ public class TransportStop extends MapObject { deletedRoutesIds = Algorithms.addToArrayL(deletedRoutesIds, routeId, true); } - public boolean isRouteDeleted(long routeId) { return deletedRoutesIds != null && Arrays.binarySearch(deletedRoutesIds, routeId) >= 0; } diff --git a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java index d475676750..924c9e81d1 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java @@ -794,6 +794,7 @@ public class Algorithms { result = new long[array.length + 1]; System.arraycopy(array, 0, result, 0, array.length); result[result.length - 1] = value; + Arrays.sort(result); } return result; }