From 7854ee01dd2d390405bc267e8a3b0ffcdea070d6 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 Conflicts: OsmAnd-java/src/main/java/net/osmand/data/TransportStop.java --- .../java/net/osmand/data/TransportStop.java | 21 ++++++++++++++----- .../main/java/net/osmand/util/Algorithms.java | 1 + 2 files changed, 17 insertions(+), 5 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 52aac20d2a..eb552d4d6d 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/TransportStop.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/TransportStop.java @@ -20,10 +20,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() { @@ -39,14 +47,12 @@ public class TransportStop extends MapObject { } public void setRoutesIds(long[] routesIds) { + // CHECK route ids are sorted (used later) this.routesIds = routesIds; } - public void addRouteId(long routeId) { - routesIds = Algorithms.addToArrayL(routesIds, routeId, true); - } - public boolean hasRoute(long routeId) { + // make assumption that ids are sorted return routesIds != null && Arrays.binarySearch(routesIds, routeId) >= 0; } @@ -66,6 +72,11 @@ public class TransportStop extends MapObject { this.deletedRoutesIds = deletedRoutesIds; } + public void addRouteId(long routeId) { + // make assumption that ids are sorted + routesIds = Algorithms.addToArrayL(routesIds, routeId, true); + } + public void addDeletedRouteId(long routeId) { deletedRoutesIds = Algorithms.addToArrayL(deletedRoutesIds, routeId, true); } 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; }