static void initHints(HintsMap m, MultivaluedMap<String, String> parameterMap) { for (Map.Entry<String, List<String>> e : parameterMap.entrySet()) { if (e.getValue().size() == 1) { m.put(e.getKey(), e.getValue().get(0)); } else { // Do nothing. // TODO: this is dangerous: I can only silently swallow // the forbidden multiparameter. If I comment-in the line below, // I get an exception, because "point" regularly occurs // multiple times. // I think either unknown parameters (hints) should be allowed // to be multiparameters, too, or we shouldn't use them for // known parameters either, _or_ known parameters // must be filtered before they come to this code point, // _or_ we stop passing unknown parameters alltogether.. // // throw new WebApplicationException(String.format("This query parameter (hint) is not allowed to occur multiple times: %s", e.getKey())); } } }
public MatrixResponse route(GHMRequest request) { if (!Helper.isEmpty(key)) { request.getHints().put(KEY, key); } return requester.route(request); } }
protected PathWrapper doInBackground(Void... v) { StopWatch sw = new StopWatch().start(); GHRequest req = new GHRequest(fromLat, fromLon, toLat, toLon). setAlgorithm(Algorithms.DIJKSTRA_BI); req.getHints(). put(Routing.INSTRUCTIONS, "false"); GHResponse resp = hopper.route(req); time = sw.stop().getSeconds(); return resp.getBest(); }
@Test public void testRoadAttributeRestriction() { EdgeIteratorState edge = graph.getEdgeIteratorState(0, 1); Weighting instance = new GenericWeighting(encoder, new HintsMap().put(GenericWeighting.HEIGHT_LIMIT, 4.0)); assertEquals(edgeWeight, instance.calcWeight(edge, false, EdgeIterator.NO_EDGE), 1e-8); instance = new GenericWeighting(encoder, new HintsMap().put(GenericWeighting.HEIGHT_LIMIT, 5.0)); assertEquals(Double.POSITIVE_INFINITY, instance.calcWeight(edge, false, EdgeIterator.NO_EDGE), 1e-8); }
req.getHints().put(Landmark.DISABLE, true); GHResponse originalRsp = hopper.route(req);
setVehicle(vehicle). setAlgorithm(DIJKSTRA_BI); noSodReq.getHints().put("stall_on_demand", false);
@Test public void testLookupAndCalcPaths_simpleSquareGraph() { Graph g = createSquareGraph(); // start at node 0 and head south, make sure the round trip is long enough to reach most southern node 6 GHPoint start = new GHPoint(1, -1); double heading = 180.0; int numPoints = 2; double roundTripDistance = 670000; GHRequest ghRequest = new GHRequest(Collections.singletonList(start), Collections.singletonList(heading)); ghRequest.getHints().put(Parameters.Algorithms.RoundTrip.POINTS, numPoints); ghRequest.getHints().put(Parameters.Algorithms.RoundTrip.DISTANCE, roundTripDistance); LocationIndex locationIndex = new LocationIndexTree(g, new RAMDirectory()).prepareIndex(); RoundTripRoutingTemplate routingTemplate = new RoundTripRoutingTemplate(ghRequest, new GHResponse(), locationIndex, 1); List<QueryResult> stagePoints = routingTemplate.lookup(ghRequest.getPoints(), carFE); assertEquals(3, stagePoints.size()); assertEquals(0, stagePoints.get(0).getClosestNode()); assertEquals(6, stagePoints.get(1).getClosestNode()); assertEquals(0, stagePoints.get(2).getClosestNode()); QueryGraph queryGraph = new QueryGraph(g); queryGraph.lookup(stagePoints); Weighting weighting = new FastestWeighting(carFE); List<Path> paths = routingTemplate.calcPaths( queryGraph, new RoutingAlgorithmFactorySimple(), new AlgorithmOptions(DIJKSTRA_BI, weighting, tMode)); // make sure the resulting paths are connected and form a round trip starting and ending at the start node 0 assertEquals(2, paths.size()); assertEquals(IntArrayList.from(new int[]{0, 7, 6, 5}), paths.get(0).calcNodes()); assertEquals(IntArrayList.from(new int[]{5, 4, 3, 2, 1, 0}), paths.get(1).calcNodes()); }
Weighting weighting = hopper.createWeighting(hints, encoder, hopper.getGraphHopperStorage()); HintsMap defaultHints = new HintsMap().put(Parameters.CH.DISABLE, true).put(Parameters.Landmark.DISABLE, true) .setVehicle(hints.getVehicle()).setWeighting(hints.getWeighting()); final HintsMap lmHints = new HintsMap(defaultHints).put(Parameters.Landmark.DISABLE, false); prepare.add(new AlgoHelperEntry(ghStorage, AlgorithmOptions.start(astarbiOpts).hints(lmHints).build(), idx, "astarbi|landmarks|" + weighting) { @Override final HintsMap chHints = new HintsMap(defaultHints).put(Parameters.CH.DISABLE, false); Weighting pickedWeighting = null; for (Weighting tmpWeighting : hopper.getCHFactoryDecorator().getWeightings()) {
@Test public void testDisabledRoadAttributes() { DataFlagEncoder simpleEncoder = new DataFlagEncoder(); EncodingManager simpleEncodingManager = new EncodingManager(simpleEncoder); Graph simpleGraph = new GraphBuilder(simpleEncodingManager).create(); ReaderWay way = new ReaderWay(27l); way.setTag("highway", "primary"); way.setTag("maxspeed", "10"); way.setTag("maxheight", "4.4"); // 0-1 simpleGraph.edge(0, 1, 1, true); AbstractRoutingAlgorithmTester.updateDistancesFor(simpleGraph, 0, 0.00, 0.00); AbstractRoutingAlgorithmTester.updateDistancesFor(simpleGraph, 1, 0.01, 0.01); simpleGraph.getEdgeIteratorState(0, 1).setFlags(simpleEncoder.handleWayTags(way, 1, 0)); Weighting instance = new GenericWeighting(simpleEncoder, new HintsMap().put(GenericWeighting.HEIGHT_LIMIT, 5.0)); EdgeIteratorState edge = simpleGraph.getEdgeIteratorState(0, 1); assertEquals(edgeWeight, instance.calcWeight(edge, false, EdgeIterator.NO_EDGE), 1e-8); } }
.traversalMode(graphHopper.getTraversalMode()) .maxVisitedNodes(maxVisitedNodes) .hints(new HintsMap().put("vehicle", vehicleStr)) .build(); MapMatching matching = new MapMatching(graphHopper, opts);
if (!blockedAreasFromRequest.isEmpty()) val += ";" + blockedAreasFromRequest; hintsMap.put(Parameters.Routing.BLOCK_AREA, val);