From ad196afd4d3f861223c65cc2fe27ba6c979db1ff Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 11 Apr 2017 20:57:34 +0200 Subject: [PATCH] Fix test --- OsmAnd-java/src/net/osmand/router/GeneralRouter.java | 8 ++++++++ .../src/net/osmand/router/RoutePlannerFrontEnd.java | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/OsmAnd-java/src/net/osmand/router/GeneralRouter.java b/OsmAnd-java/src/net/osmand/router/GeneralRouter.java index 7df7a70a6f..fd83138b14 100644 --- a/OsmAnd-java/src/net/osmand/router/GeneralRouter.java +++ b/OsmAnd-java/src/net/osmand/router/GeneralRouter.java @@ -57,6 +57,7 @@ public class GeneralRouter implements VehicleRouter { private float maxDefaultSpeed = 10; private TLongHashSet impassableRoads; + private GeneralRouterProfile profile; public enum RouteDataObjectAttribute { @@ -97,6 +98,7 @@ public class GeneralRouter implements VehicleRouter { } public GeneralRouter(GeneralRouterProfile profile, Map attributes) { + this.profile = profile; this.attributes = new LinkedHashMap(); Iterator> e = attributes.entrySet().iterator(); while(e.hasNext()){ @@ -115,6 +117,7 @@ public class GeneralRouter implements VehicleRouter { } public GeneralRouter(GeneralRouter parent, Map params) { + this.profile = parent.profile; this.attributes = new LinkedHashMap(); Iterator> e = parent.attributes.entrySet().iterator(); while (e.hasNext()) { @@ -140,6 +143,11 @@ public class GeneralRouter implements VehicleRouter { } } + + public GeneralRouterProfile getProfile() { + return profile; + } + public Map getParameters() { return parameters; diff --git a/OsmAnd-java/src/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/net/osmand/router/RoutePlannerFrontEnd.java index 530ba88637..1e1cfe709b 100644 --- a/OsmAnd-java/src/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/net/osmand/router/RoutePlannerFrontEnd.java @@ -115,7 +115,10 @@ public class RoutePlannerFrontEnd { boolean res = false; GeneralRouter router = (GeneralRouter) ctx.getRouter(); if (router != null && !router.isAllowPrivate()) { - ctx.setRouter(new GeneralRouter(GeneralRouterProfile.CAR, new LinkedHashMap())); + ctx.unloadAllData(); + LinkedHashMap mp = new LinkedHashMap(); + mp.put(GeneralRouter.ALLOW_PRIVATE, "true"); + ctx.setRouter(new GeneralRouter(router.getProfile(), mp)); for (LatLon latLon : points) { RouteSegmentPoint rp = findRouteSegment(latLon.getLatitude(), latLon.getLongitude(), ctx, null); if (rp != null && rp.road != null) { @@ -125,6 +128,7 @@ public class RoutePlannerFrontEnd { } } } + ctx.unloadAllData(); ctx.setRouter(router); } return res;