@Test void getRoute_should_return_graphhopper_route() { whenRouteReturnResponse(); whenBestReturnPath(); when(pathWrapper.getPoints()).thenReturn(pointList); Coordinates coordinates1 = Coordinates.valueOf(1, 1); Coordinates coordinates2 = Coordinates.valueOf(Math.E, Math.PI); Coordinates coordinates3 = Coordinates.valueOf(0.1, 1.0 / 3.0); pointList.add(coordinates1.latitude().doubleValue(), coordinates1.longitude().doubleValue()); pointList.add(coordinates2.latitude().doubleValue(), coordinates2.longitude().doubleValue()); pointList.add(coordinates3.latitude().doubleValue(), coordinates3.longitude().doubleValue()); List<Coordinates> route = new GraphHopperRouter(graphHopper).getPath(from, to); assertThat(route).containsExactly( coordinates1, coordinates2, coordinates3); }
@Override public List<Coordinates> getPath(Coordinates from, Coordinates to) { GHRequest ghRequest = new GHRequest( from.latitude().doubleValue(), from.longitude().doubleValue(), to.latitude().doubleValue(), to.longitude().doubleValue()); PointList points = graphHopper.route(ghRequest).getBest().getPoints(); return StreamSupport.stream(points.spliterator(), false) .map(ghPoint3D -> Coordinates.valueOf(ghPoint3D.lat, ghPoint3D.lon)) .collect(toList()); }
GraphHopperRouter implements Router, DistanceCalculator, Region { @Override public List<Coordinates> getPath(Coordinates from, Coordinates to) { GHRequest ghRequest = new GHRequest( from.latitude().doubleValue(), from.longitude().doubleValue(), to.latitude().doubleValue(), to.longitude().doubleValue()); PointList points = graphHopper.route(ghRequest).getBest().getPoints(); return StreamSupport.stream(points.spliterator(), false) .map(ghPoint3D -> Coordinates.valueOf(ghPoint3D.lat, ghPoint3D.lon)) .collect(toList()); } }
GraphHopperRouter implements Router, DistanceCalculator, Region { @Override public List<Coordinates> getPath(Coordinates from, Coordinates to) { GHRequest ghRequest = new GHRequest( from.latitude().doubleValue(), from.longitude().doubleValue(), to.latitude().doubleValue(), to.longitude().doubleValue()); PointList points = graphHopper.route(ghRequest).getBest().getPoints(); return StreamSupport.stream(points.spliterator(), false) .map(ghPoint3D -> Coordinates.valueOf(ghPoint3D.lat, ghPoint3D.lon)) .collect(toList()); } @Autowired  GraphHopperRouter(GraphHopperOSM graphHopper); }
GraphHopperRouter implements Router, DistanceCalculator, Region { @Override public List<Coordinates> getPath(Coordinates from, Coordinates to) { GHRequest ghRequest = new GHRequest( from.latitude().doubleValue(), from.longitude().doubleValue(), to.latitude().doubleValue(), to.longitude().doubleValue()); PointList points = graphHopper.route(ghRequest).getBest().getPoints(); return StreamSupport.stream(points.spliterator(), false) .map(ghPoint3D -> Coordinates.valueOf(ghPoint3D.lat, ghPoint3D.lon)) .collect(toList()); } @Autowired  GraphHopperRouter(GraphHopperOSM graphHopper); @Override List<Coordinates> getPath(Coordinates from, Coordinates to); @Override long travelTimeMillis(Coordinates from, Coordinates to); @Override BoundingBox getBounds(); }
GraphHopperRouter implements Router, DistanceCalculator, Region { @Override public List<Coordinates> getPath(Coordinates from, Coordinates to) { GHRequest ghRequest = new GHRequest( from.latitude().doubleValue(), from.longitude().doubleValue(), to.latitude().doubleValue(), to.longitude().doubleValue()); PointList points = graphHopper.route(ghRequest).getBest().getPoints(); return StreamSupport.stream(points.spliterator(), false) .map(ghPoint3D -> Coordinates.valueOf(ghPoint3D.lat, ghPoint3D.lon)) .collect(toList()); } @Autowired  GraphHopperRouter(GraphHopperOSM graphHopper); @Override List<Coordinates> getPath(Coordinates from, Coordinates to); @Override long travelTimeMillis(Coordinates from, Coordinates to); @Override BoundingBox getBounds();  }