@Override public List<Path> calcPaths(QueryGraph queryGraph, RoutingAlgorithmFactory algoFactory, AlgorithmOptions algoOpts) { boolean withViaTurnPenalty = ghRequest.getHints().getBool(Routing.PASS_THROUGH, false); if (withViaTurnPenalty) throw new IllegalArgumentException("Alternative paths and " + PASS_THROUGH + " at the same time is currently not supported"); return super.calcPaths(queryGraph, algoFactory, algoOpts); }
@Override public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory defaultAlgoFactory, HintsMap map) { // for now do not allow mixing CH&LM #1082 boolean disableCH = map.getBool(Parameters.CH.DISABLE, false); boolean disableLM = map.getBool(Parameters.Landmark.DISABLE, false); if (!isEnabled() || disablingAllowed && disableLM || !disableCH) return defaultAlgoFactory; if (preparations.isEmpty()) throw new IllegalStateException("No preparations added to this decorator"); for (final PrepareLandmarks p : preparations) { if (p.getWeighting().matches(map)) return new LMRAFactory(p, defaultAlgoFactory); } // if the initial encoder&weighting has certain properties we could cross query it but for now avoid this return defaultAlgoFactory; }
@Override public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory defaultAlgoFactory, HintsMap map) { boolean disableCH = map.getBool(DISABLE, false); if (!isEnabled() || disablingAllowed && disableCH) return defaultAlgoFactory; if (preparations.isEmpty()) throw new IllegalStateException("No preparations added to this decorator"); if (map.getWeighting().isEmpty()) map.setWeighting(getDefaultWeighting()); String entriesStr = ""; for (PrepareContractionHierarchies p : preparations) { if (p.getWeighting().matches(map)) return p; entriesStr += p.getWeighting() + ", "; } throw new IllegalArgumentException("Cannot find CH RoutingAlgorithmFactory for weighting map " + map + " in entries " + entriesStr); }
@Override public GHResponse route(GHRequest request) { ResponseBody rspBody = null; try { Request okRequest = createRequest(request); rspBody = getClientForRequest(request).newCall(okRequest).execute().body(); JsonNode json = objectMapper.reader().readTree(rspBody.byteStream()); GHResponse res = new GHResponse(); res.addErrors(readErrors(json)); if (res.hasErrors()) return res; JsonNode paths = json.get("paths"); boolean tmpElevation = request.getHints().getBool("elevation", elevation); boolean tmpTurnDescription = request.getHints().getBool("turn_description", true); for (JsonNode path : paths) { PathWrapper altRsp = createPathWrapper(path, tmpElevation, tmpTurnDescription); res.add(altRsp); } return res; } catch (Exception ex) { throw new RuntimeException("Problem while fetching path " + request.getPoints() + ": " + ex.getMessage(), ex); } finally { Helper.close(rspBody); } }
private Request createRequest(GHRequest request) { boolean tmpInstructions = request.getHints().getBool("instructions", instructions); boolean tmpCalcPoints = request.getHints().getBool("calc_points", calcPoints); String tmpOptimize = request.getHints().get("optimize", optimize); boolean tmpElevation = request.getHints().getBool("elevation", elevation);
boolean debug = ghRequest.getHints().getBool("debug", false); if (debug) { logger.info("POST URL:" + postUrl + ", request:" + requestJson + ", response: " + postResponseStr);
TraversalMode tMode = TraversalMode.fromString(tModeStr); if (hints.has(Routing.EDGE_BASED)) tMode = hints.getBool(Routing.EDGE_BASED, false) ? TraversalMode.EDGE_BASED_2DIR : TraversalMode.NODE_BASED; boolean disableCH = hints.getBool(CH.DISABLE, false); if (!chFactoryDecorator.isDisablingAllowed() && disableCH) throw new IllegalArgumentException("Disabling CH not allowed on the server-side"); boolean disableLM = hints.getBool(Landmark.DISABLE, false); if (!lmFactoryDecorator.isDisablingAllowed() && disableLM) throw new IllegalArgumentException("Disabling LM not allowed on the server-side"); boolean forceCHHeading = hints.getBool(CH.FORCE_HEADING, false); if (!forceCHHeading && request.hasFavoredHeading(0)) throw new IllegalArgumentException("Heading is not (fully) supported for CHGraph. See issue #483"); boolean tmpEnableInstructions = hints.getBool(Routing.INSTRUCTIONS, enableInstructions); boolean tmpCalcPoints = hints.getBool(Routing.CALC_POINTS, calcPoints); double wayPointMaxDistance = hints.getDouble(Routing.WAY_POINT_MAX_DISTANCE, 1d);
@Override public List<Path> calcPaths(QueryGraph queryGraph, RoutingAlgorithmFactory algoFactory, AlgorithmOptions algoOpts) { long visitedNodesSum = 0L; boolean viaTurnPenalty = ghRequest.getHints().getBool(Routing.PASS_THROUGH, false); int pointCounts = ghRequest.getPoints().size(); pathList = new ArrayList<>(pointCounts - 1);
@Override public List<Path> calcPaths(QueryGraph queryGraph, RoutingAlgorithmFactory algoFactory, AlgorithmOptions algoOpts) { boolean withViaTurnPenalty = ghRequest.getHints().getBool(Routing.PASS_THROUGH, false); if (withViaTurnPenalty) throw new IllegalArgumentException("Alternative paths and " + PASS_THROUGH + " at the same time is currently not supported"); return super.calcPaths(queryGraph, algoFactory, algoOpts); }
@Override public List<Path> calcPaths( QueryGraph queryGraph, RoutingAlgorithmFactory algoFactory, AlgorithmOptions algoOpts ) { boolean withViaTurnPenalty = ghRequest.getHints().getBool(Routing.PASS_THROUGH, false); if (withViaTurnPenalty) throw new IllegalStateException("Alternative paths and a viaTurnPenalty at the same time is currently not supported"); return super.calcPaths(queryGraph, algoFactory, algoOpts); }
@Override public List<Path> calcPaths(QueryGraph queryGraph, RoutingAlgorithmFactory algoFactory, AlgorithmOptions algoOpts) { boolean withViaTurnPenalty = ghRequest.getHints().getBool(Routing.PASS_THROUGH, false); if (withViaTurnPenalty) throw new IllegalArgumentException("Alternative paths and " + PASS_THROUGH + " at the same time is currently not supported"); return super.calcPaths(queryGraph, algoFactory, algoOpts); }
@Override public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory defaultAlgoFactory, HintsMap map) { // for now do not allow mixing CH&LM #1082 boolean disableCH = map.getBool(Parameters.CH.DISABLE, false); boolean disableLM = map.getBool(Parameters.Landmark.DISABLE, false); if (!isEnabled() || disablingAllowed && disableLM || !disableCH) return defaultAlgoFactory; if (preparations.isEmpty()) throw new IllegalStateException("No preparations added to this decorator"); for (final PrepareLandmarks p : preparations) { if (p.getWeighting().matches(map)) return new LMRAFactory(p, defaultAlgoFactory); } // if the initial encoder&weighting has certain properties we could cross query it but for now avoid this return defaultAlgoFactory; }
@Override public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory defaultAlgoFactory, HintsMap map) { boolean forceFlexMode = map.getBool(DISABLE, false); if (!isEnabled() || disablingAllowed && forceFlexMode) return defaultAlgoFactory; if (preparations.isEmpty()) throw new IllegalStateException("No preparations added to this decorator"); for (final PrepareLandmarks p : preparations) { if (p.getWeighting().matches(map)) return new LMRAFactory(p, defaultAlgoFactory); } // if the initial encoder&weighting has certain properies we could cross query it but for now avoid this return defaultAlgoFactory; }
@Override public RoutingAlgorithmFactory getDecoratedAlgorithmFactory( RoutingAlgorithmFactory defaultAlgoFactory, HintsMap map ) { boolean forceFlexMode = map.getBool(DISABLE, false); if (!isEnabled() || forceFlexMode) return defaultAlgoFactory; if (preparations.isEmpty()) throw new IllegalStateException("No preparations added to this decorator"); if (map.getWeighting().isEmpty()) map.setWeighting(getDefaultWeighting()); for (PrepareContractionHierarchies p : preparations) { if (p.getWeighting().matches(map)) return p; } throw new IllegalArgumentException("Cannot find RoutingAlgorithmFactory for weighting map " + map); }
@Override public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory defaultAlgoFactory, HintsMap map) { boolean disableCH = map.getBool(DISABLE, false); if (!isEnabled() || disablingAllowed && disableCH) return defaultAlgoFactory; if (preparations.isEmpty()) throw new IllegalStateException("No preparations added to this decorator"); if (map.getWeighting().isEmpty()) map.setWeighting(getDefaultWeighting()); String entriesStr = ""; for (PrepareContractionHierarchies p : preparations) { if (p.getWeighting().matches(map)) return p; entriesStr += p.getWeighting() + ", "; } throw new IllegalArgumentException("Cannot find CH RoutingAlgorithmFactory for weighting map " + map + " in entries " + entriesStr); }
@Override public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory defaultAlgoFactory, HintsMap map) { boolean forceFlexMode = map.getBool(DISABLE, false); if (!isEnabled() || forceFlexMode) return defaultAlgoFactory; if (preparations.isEmpty()) throw new IllegalStateException("No preparations added to this decorator"); if (map.getWeighting().isEmpty()) map.setWeighting(getDefaultWeighting()); String entriesStr = ""; for (PrepareContractionHierarchies p : preparations) { if (p.getWeighting().matches(map)) return p; entriesStr += p.getWeighting() + ", "; } throw new IllegalArgumentException("Cannot find CH RoutingAlgorithmFactory for weighting map " + map + " in entries " + entriesStr); }
TraversalMode tMode = TraversalMode.fromString(tModeStr); if (hints.has(Routing.EDGE_BASED)) tMode = hints.getBool(Routing.EDGE_BASED, false) ? TraversalMode.EDGE_BASED_2DIR : TraversalMode.NODE_BASED; boolean disableCH = hints.getBool(CH.DISABLE, false); if (!chFactoryDecorator.isDisablingAllowed() && disableCH) throw new IllegalArgumentException("Disabling CH not allowed on the server-side"); boolean disableLM = hints.getBool(Landmark.DISABLE, false); if (!lmFactoryDecorator.isDisablingAllowed() && disableLM) throw new IllegalArgumentException("Disabling LM not allowed on the server-side"); boolean forceCHHeading = hints.getBool(CH.FORCE_HEADING, false); if (!forceCHHeading && request.hasFavoredHeading(0)) throw new IllegalArgumentException("Heading is not (fully) supported for CHGraph. See issue #483"); boolean tmpEnableInstructions = hints.getBool(Routing.INSTRUCTIONS, enableInstructions); boolean tmpCalcPoints = hints.getBool(Routing.CALC_POINTS, calcPoints); double wayPointMaxDistance = hints.getDouble(Routing.WAY_POINT_MAX_DISTANCE, 1d);
boolean viaTurnPenalty = ghRequest.getHints().getBool(Routing.PASS_THROUGH, false); int pointCounts = ghRequest.getPoints().size(); pathList = new ArrayList<>(pointCounts - 1);
@Override public List<Path> calcPaths(QueryGraph queryGraph, RoutingAlgorithmFactory algoFactory, AlgorithmOptions algoOpts) { long visitedNodesSum = 0L; boolean viaTurnPenalty = ghRequest.getHints().getBool(Routing.PASS_THROUGH, false); int pointCounts = ghRequest.getPoints().size(); pathList = new ArrayList<>(pointCounts - 1);
@Override public List<Path> calcPaths(QueryGraph queryGraph, RoutingAlgorithmFactory algoFactory, AlgorithmOptions algoOpts) { long visitedNodesSum = 0L; boolean viaTurnPenalty = ghRequest.getHints().getBool(Routing.PASS_THROUGH, false); int pointCounts = ghRequest.getPoints().size(); pathList = new ArrayList<>(pointCounts - 1);