@Override public HintsMap put(String key, Object str) { super.put(key, str); return this; }
public HintsMap setWeighting(String w) { if (w != null) super.put("weighting", w); return this; }
public HintsMap setVehicle(String v) { if (v != null) super.put("vehicle", v); return this; } }
@Override public CmdArgs put(String key, Object str) { super.put(key, str); return this; } }
public Builder hints(PMap hints) { this.opts.hints.put(hints); return this; }
public PMap(String propertiesString) { // five chosen as arbitrary initial capacity this.map = new HashMap<>(5); for (String s : propertiesString.split("\\|")) { s = s.trim(); int index = s.indexOf("="); if (index < 0) continue; put(s.substring(0, index), s.substring(index + 1)); } }
PMap merge(Map<String, String> map) { for (Map.Entry<String, String> e : map.entrySet()) { if (Helper.isEmpty(e.getKey())) continue; put(e.getKey(), e.getValue()); } return this; }
public GraphHopperStorageForDataFlagEncoderTest() { properties = new PMap(); properties.put("store_height", true); properties.put("store_weight", true); properties.put("store_width", false); encoder = new DataFlagEncoder(properties); encodingManager = new EncodingManager(Arrays.asList(encoder), 8); }
public DataFlagEncoderTest() { properties = new PMap(); properties.put("store_height", true); properties.put("store_weight", true); properties.put("store_width", true); encoder = new DataFlagEncoder(properties); encodingManager = new EncodingManager(Arrays.asList(encoder), 8); motorVehicleInt = encoder.getAccessType("motor_vehicle"); }
throw new IllegalArgumentException("No path found - maximum number of nodes exceeded: " + maxVisitedNodesForRequest); response.getHints().put("visited_nodes.sum", visitedNodes); response.getHints().put("visited_nodes.average", visitedNodes); if (discoveredSolutions.isEmpty()) { response.addError(new RuntimeException("No route found"));
@Override public List<Path> calcPaths(QueryGraph queryGraph, RoutingAlgorithmFactory algoFactory, AlgorithmOptions algoOpts) { pathList = new ArrayList<>(queryResults.size() - 1); AvoidEdgesWeighting avoidPathWeighting = new AvoidEdgesWeighting(algoOpts.getWeighting()); avoidPathWeighting.setEdgePenaltyFactor(5); algoOpts = AlgorithmOptions.start(algoOpts). algorithm(Parameters.Algorithms.ASTAR_BI). weighting(avoidPathWeighting).build(); algoOpts.getHints().put(Algorithms.AStarBi.EPSILON, 2); long visitedNodesSum = 0L; QueryResult start = queryResults.get(0); for (int qrIndex = 1; qrIndex < queryResults.size(); qrIndex++) { RoutingAlgorithm algo = algoFactory.createAlgo(queryGraph, algoOpts); // instead getClosestNode (which might be a virtual one and introducing unnecessary tails of the route) // use next tower node -> getBaseNode or getAdjNode // Later: remove potential route tail QueryResult startQR = queryResults.get(qrIndex - 1); int startNode = (startQR == start) ? startQR.getClosestNode() : startQR.getClosestEdge().getBaseNode(); QueryResult endQR = queryResults.get(qrIndex); int endNode = (endQR == start) ? endQR.getClosestNode() : endQR.getClosestEdge().getBaseNode(); Path path = algo.calcPath(startNode, endNode); visitedNodesSum += algo.getVisitedNodes(); pathList.add(path); // it is important to avoid previously visited nodes for future paths avoidPathWeighting.addEdges(path.calcEdges()); } ghResponse.getHints().put("visited_nodes.sum", visitedNodesSum); ghResponse.getHints().put("visited_nodes.average", (float) visitedNodesSum / (queryResults.size() - 1)); return pathList; }
private RoutingAlgorithm createCHAlgo(GraphHopperStorage graph, CHGraph chGraph, boolean withSOD, AlgorithmOptions algorithmOptions) { PrepareContractionHierarchies ch = new PrepareContractionHierarchies( chGraph, algorithmOptions.getWeighting(), TraversalMode.NODE_BASED); if (!withSOD) { algorithmOptions.getHints().put("stall_on_demand", false); } return ch.createAlgo(chGraph, algorithmOptions); } }
astarbiOpts.getHints().put(ASTAR_BI + ".approximation", "BeelineSimplification"); AlgorithmOptions dijkstrabiOpts = AlgorithmOptions.start(defaultOpts).algorithm(DIJKSTRA_BI).build(); prepare.add(new AlgoHelperEntry(ghStorage, astarbiOpts, idx, "astarbi|beeline|" + addStr + weighting));
@Test public void testWeightWrongHeading() { Weighting instance = new FastestWeighting(encoder, new PMap(). put(Parameters.Routing.HEADING_PENALTY, "100")); VirtualEdgeIteratorState virtEdge = new VirtualEdgeIteratorState(0, 1, 1, 2, 10, encoder.setProperties(10, true, true), "test", Helper.createPointList(51, 0, 51, 1)); double time = instance.calcWeight(virtEdge, false, 0); virtEdge.setUnfavored(true); // heading penalty on edge assertEquals(time + 100, instance.calcWeight(virtEdge, false, 0), 1e-8); // only after setting it virtEdge.setUnfavored(true); assertEquals(time + 100, instance.calcWeight(virtEdge, true, 0), 1e-8); // but not after releasing it virtEdge.setUnfavored(false); assertEquals(time, instance.calcWeight(virtEdge, true, 0), 1e-8); // test default penalty virtEdge.setUnfavored(true); instance = new FastestWeighting(encoder); assertEquals(time + Routing.DEFAULT_HEADING_PENALTY, instance.calcWeight(virtEdge, false, 0), 1e-8); }
opts.getHints().put("lm.recalc_count", 50); RoutingAlgorithm biDirAlgoWithLandmarks = prepare.getDecoratedAlgorithm(graph, new AStarBidirection(graph, weighting, tm), opts);
@Override public HintsMap put(String key, Object str) { super.put(key, str); return this; }
public HintsMap setWeighting(String w) { if (w != null) super.put("weighting", w); return this; }
@Override public HintsMap put(String key, Object str) { super.put(key, str); return this; }