From b2fe95075568224b6a5fd81fa9f7f11035956970 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 27 Apr 2016 00:10:12 +0200 Subject: [PATCH] Fix osm live restrictions --- .../src/net/osmand/router/RoutingContext.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/router/RoutingContext.java b/OsmAnd-java/src/net/osmand/router/RoutingContext.java index cc33e2b9a9..840f321962 100644 --- a/OsmAnd-java/src/net/osmand/router/RoutingContext.java +++ b/OsmAnd-java/src/net/osmand/router/RoutingContext.java @@ -326,8 +326,12 @@ public class RoutingContext { if(excludeNotAllowed != null && !excludeNotAllowed.contains(ro.getId())) { ts.add(ro); } - } else if(excludeNotAllowed != null){ + } else if(excludeNotAllowed != null && ro.getId() > 0){ excludeNotAllowed.add(ro.getId()); + if(ts.excludedIds == null ){ + ts.excludedIds = new TLongHashSet(); + } + ts.excludedIds.add(ro.getId()); } } } @@ -506,10 +510,22 @@ public class RoutingContext { } List subregions = indexedSubregions.get(tileId); if (subregions != null) { - TLongHashSet duplicates = new TLongHashSet(); + boolean load = false; for (RoutingSubregionTile ts : subregions) { if (!ts.isLoaded()) { - loadSubregionTile(ts, loadOptions == OPTION_IN_MEMORY_LOAD, null, duplicates); + load = true; + } + } + if (load) { + TLongHashSet excludeIds = new TLongHashSet(); + for (RoutingSubregionTile ts : subregions) { + if (!ts.isLoaded()) { + loadSubregionTile(ts, loadOptions == OPTION_IN_MEMORY_LOAD, null, excludeIds); + } else { + if(ts.excludedIds != null) { + excludeIds.addAll(ts.excludedIds); + } + } } } } @@ -628,6 +644,7 @@ public class RoutingContext { private NativeRouteSearchResult searchResult = null; private int isLoaded = 0; private TLongObjectMap routes = null; + private TLongHashSet excludedIds = null; public RoutingSubregionTile(RouteSubregion subregion) { this.subregion = subregion; @@ -738,6 +755,7 @@ public class RoutingContext { } searchResult = null; routes = null; + excludedIds = null; } public void setLoadedNonNative(){