} else { logger.info(logStr + ", alternatives: " + ghResponse.getAll().size() + ", distance0: " + ghResponse.getBest().getDistance() + ", weight0: " + ghResponse.getBest().getRouteWeight() + ", time0: " + Math.round(ghResponse.getBest().getTime() / 60000f) + "min"
if (!warmup) { visitedNodesSum.addAndGet(rsp.getHints().getLong("visited_nodes.sum", 0)); long dist = (long) arsp.getDistance(); distSum.addAndGet(dist);
protected void onPostExecute(PathWrapper resp) { if (!resp.hasErrors()) { log("from:" + fromLat + "," + fromLon + " to:" + toLat + "," + toLon + " found path with distance:" + resp.getDistance() / 1000f + ", nodes:" + resp.getPoints().getSize() + ", time:" + time + " " + resp.getDebugInfo()); logUser("the route is " + (int) (resp.getDistance() / 100) / 10f + "km long, time:" + resp.getTime() / 60000f + "min, debug:" + time); pathLayer = createPathLayer(resp); mapView.map().layers().add(pathLayer); mapView.map().updateMap(true); } else { logUser("Error:" + resp.getErrors()); } shortestPathRunning = false; } }.execute();
if (Math.abs(rsp.getDistance() - tmpDist) > 2) { errors.add(algoEntry + " path.getDistance was " + rsp.getDistance() + "\t pointList.calcDistance was " + tmpDist + "\t (expected points " + oneRun.getLocs() + ", expected distance " + oneRun.getDistance() + ") " + queryList); if (Math.abs(rsp.getDistance() - oneRun.getDistance()) > 2) { errors.add(algoEntry + " returns path not matching the expected distance of " + oneRun.getDistance() + "\t Returned was " + rsp.getDistance() + "\t (expected points " + oneRun.getLocs() + ", was " + pointList.getSize() + ") " + queryList); errors.add(algoEntry + " returns path not matching the expected points of " + oneRun.getLocs() + "\t Returned was " + pointList.getSize() + "\t (expected distance " + oneRun.getDistance() + ", was " + rsp.getDistance() + ") " + queryList);
for (PathWrapper ar : ghRsp.getAll()) { ObjectNode jsonPath = jsonPathList.addObject(); jsonPath.put("distance", Helper.round(ar.getDistance(), 3)); jsonPath.put("weight", Helper.round6(ar.getRouteWeight())); jsonPath.put("time", ar.getTime());
+ " distance:" + lmRsp.getBest().getDistance() + ", original: " + originalRsp.getBest().getDistance() + " time:" + round2(lmRsp.getBest().getTime() / 1000) + ", original: " + round2(originalRsp.getBest().getTime() / 1000) + " points:" + lmRsp.getBest().getPoints().size() + ", original: " + originalRsp.getBest().getPoints().size();
+ " distance:" + noSodRsp.getBest().getDistance() + ", original: " + sodRsp.getBest().getDistance() + " time:" + round2(noSodRsp.getBest().getTime() / 1000) + ", original: " + round2(sodRsp.getBest().getTime() / 1000) + " points:" + noSodRsp.getBest().getPoints().size() + ", original: " + sodRsp.getBest().getPoints().size();
@Test public void testLoad() { GraphHopperStorage graph = new GraphBuilder(encodingManager).create(); initGraph(graph); // do further changes: NodeAccess na = graph.getNodeAccess(); na.setNode(4, 41.9, 10.2); graph.edge(1, 2, 10, false); graph.edge(0, 4, 40, true); graph.edge(4, 3, 40, true); GraphHopper instance = new GraphHopper(). setStoreOnFlush(false). setEncodingManager(encodingManager).setCHEnabled(false). loadGraph(graph); // 3 -> 0 GHResponse rsp = instance.route(new GHRequest(42, 10.4, 42, 10)); assertFalse(rsp.hasErrors()); PathWrapper arsp = rsp.getBest(); assertEquals(80, arsp.getDistance(), 1e-6); PointList points = arsp.getPoints(); assertEquals(42, points.getLatitude(0), 1e-5); assertEquals(10.4, points.getLongitude(0), 1e-5); assertEquals(41.9, points.getLatitude(1), 1e-5); assertEquals(10.2, points.getLongitude(1), 1e-5); assertEquals(3, points.getSize()); instance.close(); }
public RoutingResult getRouteBetween(NavigationPosition from, NavigationPosition to, TravelMode travelMode) { initializeHopper(); long start = currentTimeMillis(); try { GHRequest request = new GHRequest(from.getLatitude(), from.getLongitude(), to.getLatitude(), to.getLongitude()); request.setVehicle(travelMode.getName().toUpperCase()); GHResponse response = hopper.route(request); if(response.hasErrors()) { String errors = printArrayToDialogString(response.getErrors().toArray(), false); log.severe(format("Error while routing between %s and %s: %s", from, to, errors)); throw new RuntimeException(errors); } PathWrapper best = response.getBest(); return new RoutingResult(asPositions(best.getPoints()), new DistanceAndTime(best.getDistance(), best.getTime() / 1000), true); } finally { long end = currentTimeMillis(); log.info("GraphHopper: routing from " + from + " to " + to + " took " + (end - start) + " milliseconds"); } }
errors.add(algoEntry + " response contains errors. Expected distance: " + rsp.getDistance() + ", expected points: " + oneRun + ". " + queryList + ", errors:" + rsp.getErrors()); return this; if (Math.abs(rsp.getDistance() - tmpDist) > 2) errors.add(algoEntry + " path.getDistance was " + rsp.getDistance() + "\t pointList.calcDistance was " + tmpDist + "\t (expected points " + oneRun.getLocs() + ", expected distance " + oneRun.getDistance() + ") " + queryList); if (Math.abs(rsp.getDistance() - oneRun.getDistance()) > 2) + "\t Returned was " + rsp.getDistance() + "\t (expected points " + oneRun.getLocs() + ", was " + pointList.getSize() + ") " + queryList); + ", was " + rsp.getDistance() + ") " + queryList);
if (Math.abs(rsp.getDistance() - tmpDist) > 2) { errors.add(algoEntry + " path.getDistance was " + rsp.getDistance() + "\t pointList.calcDistance was " + tmpDist + "\t (expected points " + oneRun.getLocs() + ", expected distance " + oneRun.getDistance() + ") " + queryList); if (Math.abs(rsp.getDistance() - oneRun.getDistance()) > 2) { errors.add(algoEntry + " returns path not matching the expected distance of " + oneRun.getDistance() + "\t Returned was " + rsp.getDistance() + "\t (expected points " + oneRun.getLocs() + ", was " + pointList.getSize() + ") " + queryList); errors.add(algoEntry + " returns path not matching the expected points of " + oneRun.getLocs() + "\t Returned was " + pointList.getSize() + "\t (expected distance " + oneRun.getDistance() + ", was " + rsp.getDistance() + ") " + queryList);
if (Math.abs(rsp.getDistance() - tmpDist) > 2) { errors.add(algoEntry + " path.getDistance was " + rsp.getDistance() + "\t pointList.calcDistance was " + tmpDist + "\t (expected points " + oneRun.getLocs() + ", expected distance " + oneRun.getDistance() + ") " + queryList); if (Math.abs(rsp.getDistance() - oneRun.getDistance()) > 2) { errors.add(algoEntry + " returns path not matching the expected distance of " + oneRun.getDistance() + "\t Returned was " + rsp.getDistance() + "\t (expected points " + oneRun.getLocs() + ", was " + pointList.getSize() + ") " + queryList); errors.add(algoEntry + " returns path not matching the expected points of " + oneRun.getLocs() + "\t Returned was " + pointList.getSize() + "\t (expected distance " + oneRun.getDistance() + ", was " + rsp.getDistance() + ") " + queryList);
for (PathWrapper ar : ghRsp.getAll()) { ObjectNode jsonPath = jsonPathList.addObject(); jsonPath.put("distance", Helper.round(ar.getDistance(), 3)); jsonPath.put("weight", Helper.round6(ar.getRouteWeight())); jsonPath.put("time", ar.getTime());