public PathSimplification(PathWrapper pathWrapper, DouglasPeucker douglasPeucker, boolean enableInstructions) { this.pointList = pathWrapper.getPoints(); listsToSimplify = new ArrayList<>(); if (enableInstructions) listsToSimplify.add(pathWrapper.getInstructions()); this.pathDetails = pathWrapper.getPathDetails(); for (String name : pathDetails.keySet()) { List<PathDetail> pathDetailList = pathDetails.get(name); // If the pointList only contains one point, PathDetails have to be empty because 1 point => 0 edges if (pathDetailList.isEmpty() && pointList.size() > 1) throw new IllegalStateException("PathDetails " + name + " must not be empty"); listsToSimplify.add(pathDetailList); } this.douglasPeucker = douglasPeucker; }
+ ", weight0: " + ghResponse.getBest().getRouteWeight() + ", time0: " + Math.round(ghResponse.getBest().getTime() / 60000f) + "min" + ", points0: " + ghResponse.getBest().getPoints().getSize() + ", debugInfo: " + ghResponse.getDebugInfo()); return writeGPX ?
return arsp.getPoints().getSize();
if (ar.getPoints().getSize() >= 2) { jsonPath.putPOJO("bbox", ar.calcBBox2D()); jsonPath.putPOJO("points", pointsEncoded ? encodePolyline(ar.getPoints(), enableElevation) : ar.getPoints().toLineString(enableElevation)); if (enableInstructions) { jsonPath.putPOJO("instructions", ar.getInstructions());
private PathLayer createPathLayer(PathWrapper response) { Style style = Style.builder() .fixed(true) .generalization(Style.GENERALIZATION_SMALL) .strokeColor(0x9900cc33) .strokeWidth(4 * getResources().getDisplayMetrics().density) .build(); PathLayer pathLayer = new PathLayer(mapView.map(), style); List<GeoPoint> geoPoints = new ArrayList<>(); PointList pointList = response.getPoints(); for (int i = 0; i < pointList.getSize(); i++) geoPoints.add(new GeoPoint(pointList.getLatitude(i), pointList.getLongitude(i))); pathLayer.setPoints(geoPoints); return pathLayer; }
+ " 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();
PointList pointList = rsp.getPoints(); double tmpDist = pointList.calcDistance(distCalc); if (Math.abs(rsp.getDistance() - tmpDist) > 2) {
+ " 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();
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();
@Test public void testDisconnected179() { GraphHopperStorage graph = new GraphBuilder(encodingManager).create(); initGraph(graph); GraphHopper instance = new GraphHopper(). setStoreOnFlush(false). setEncodingManager(encodingManager).setCHEnabled(false). loadGraph(graph); GHResponse rsp = instance.route(new GHRequest(42, 10, 42, 10.4)); assertTrue(rsp.hasErrors()); try { rsp.getBest().getPoints(); assertTrue(false); } catch (Exception ex) { } instance.close(); }
@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 PathSimplification(PathWrapper pathWrapper, DouglasPeucker douglasPeucker, boolean enableInstructions) { this.pointList = pathWrapper.getPoints(); listsToSimplify = new ArrayList<>(); if (enableInstructions) listsToSimplify.add(pathWrapper.getInstructions()); this.pathDetails = pathWrapper.getPathDetails(); for (String name : pathDetails.keySet()) { List<PathDetail> pathDetailList = pathDetails.get(name); // If the pointList only contains one point, PathDetails have to be empty because 1 point => 0 edges if (pathDetailList.isEmpty() && pointList.size() > 1) throw new IllegalStateException("PathDetails " + name + " must not be empty"); listsToSimplify.add(pathDetailList); } this.douglasPeucker = douglasPeucker; }
GHPoint prev = null; List<GPXEntry> mock = new ArrayList<>(); PointList points = r.getBest().getPoints();
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"); } }
if (ar.getPoints().getSize() >= 2) { jsonPath.putPOJO("bbox", ar.calcBBox2D()); jsonPath.putPOJO("points", pointsEncoded ? encodePolyline(ar.getPoints(), enableElevation) : ar.getPoints().toLineString(enableElevation)); if (enableInstructions) { jsonPath.putPOJO("instructions", ar.getInstructions());
PointList pointList = rsp.getPoints(); double tmpDist = pointList.calcDistance(distCalc); if (Math.abs(rsp.getDistance() - tmpDist) > 2) {
PointList pointList = rsp.getPoints(); double tmpDist = pointList.calcDistance(distCalc); if (Math.abs(rsp.getDistance() - tmpDist) > 2)
PointList pointList = rsp.getPoints(); double tmpDist = pointList.calcDistance(distCalc); if (Math.abs(rsp.getDistance() - tmpDist) > 2) {