This commit is contained in:
Victor Shcherb 2017-04-11 20:57:34 +02:00
parent 82a74ff223
commit 197b49e794
2 changed files with 13 additions and 1 deletions

View file

@ -57,6 +57,7 @@ public class GeneralRouter implements VehicleRouter {
private float maxDefaultSpeed = 10; private float maxDefaultSpeed = 10;
private TLongHashSet impassableRoads; private TLongHashSet impassableRoads;
private GeneralRouterProfile profile;
public enum RouteDataObjectAttribute { public enum RouteDataObjectAttribute {
@ -97,6 +98,7 @@ public class GeneralRouter implements VehicleRouter {
} }
public GeneralRouter(GeneralRouterProfile profile, Map<String, String> attributes) { public GeneralRouter(GeneralRouterProfile profile, Map<String, String> attributes) {
this.profile = profile;
this.attributes = new LinkedHashMap<String, String>(); this.attributes = new LinkedHashMap<String, String>();
Iterator<Entry<String, String>> e = attributes.entrySet().iterator(); Iterator<Entry<String, String>> e = attributes.entrySet().iterator();
while(e.hasNext()){ while(e.hasNext()){
@ -115,6 +117,7 @@ public class GeneralRouter implements VehicleRouter {
} }
public GeneralRouter(GeneralRouter parent, Map<String, String> params) { public GeneralRouter(GeneralRouter parent, Map<String, String> params) {
this.profile = parent.profile;
this.attributes = new LinkedHashMap<String, String>(); this.attributes = new LinkedHashMap<String, String>();
Iterator<Entry<String, String>> e = parent.attributes.entrySet().iterator(); Iterator<Entry<String, String>> e = parent.attributes.entrySet().iterator();
while (e.hasNext()) { while (e.hasNext()) {
@ -141,6 +144,11 @@ public class GeneralRouter implements VehicleRouter {
} }
public GeneralRouterProfile getProfile() {
return profile;
}
public Map<String, RoutingParameter> getParameters() { public Map<String, RoutingParameter> getParameters() {
return parameters; return parameters;
} }

View file

@ -115,7 +115,10 @@ public class RoutePlannerFrontEnd {
boolean res = false; boolean res = false;
GeneralRouter router = (GeneralRouter) ctx.getRouter(); GeneralRouter router = (GeneralRouter) ctx.getRouter();
if (router != null && !router.isAllowPrivate()) { if (router != null && !router.isAllowPrivate()) {
ctx.setRouter(new GeneralRouter(GeneralRouterProfile.CAR, new LinkedHashMap<String, String>())); ctx.unloadAllData();
LinkedHashMap<String, String> mp = new LinkedHashMap<String, String>();
mp.put(GeneralRouter.ALLOW_PRIVATE, "true");
ctx.setRouter(new GeneralRouter(router.getProfile(), mp));
for (LatLon latLon : points) { for (LatLon latLon : points) {
RouteSegmentPoint rp = findRouteSegment(latLon.getLatitude(), latLon.getLongitude(), ctx, null); RouteSegmentPoint rp = findRouteSegment(latLon.getLatitude(), latLon.getLongitude(), ctx, null);
if (rp != null && rp.road != null) { if (rp != null && rp.road != null) {
@ -125,6 +128,7 @@ public class RoutePlannerFrontEnd {
} }
} }
} }
ctx.unloadAllData();
ctx.setRouter(router); ctx.setRouter(router);
} }
return res; return res;