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

View file

@ -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<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) {
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;