@Test void travel_time_should_return_graphhopper_time() { whenRouteReturnResponse(); whenBestReturnPath(); long travelTimeMillis = 135 * 60 * 60 * 1000; when(pathWrapper.getTime()).thenReturn(travelTimeMillis); assertThat(new GraphHopperRouter(graphHopper).travelTimeMillis(from, to)).isEqualTo(travelTimeMillis); }
@Override public long travelTimeMillis(Coordinates from, Coordinates to) { GHRequest ghRequest = new GHRequest( from.latitude().doubleValue(), from.longitude().doubleValue(), to.latitude().doubleValue(), to.longitude().doubleValue()); GHResponse ghResponse = graphHopper.route(ghRequest); if (ghResponse.hasErrors()) { throw new DistanceCalculationException("No route from " + from + " to " + to, ghResponse.getErrors().get(0)); } return ghResponse.getBest().getTime(); }
GraphHopperRouter implements Router, DistanceCalculator, Region { @Override public long travelTimeMillis(Coordinates from, Coordinates to) { GHRequest ghRequest = new GHRequest( from.latitude().doubleValue(), from.longitude().doubleValue(), to.latitude().doubleValue(), to.longitude().doubleValue()); GHResponse ghResponse = graphHopper.route(ghRequest); if (ghResponse.hasErrors()) { throw new DistanceCalculationException("No route from " + from + " to " + to, ghResponse.getErrors().get(0)); } return ghResponse.getBest().getTime(); } }
GraphHopperRouter implements Router, DistanceCalculator, Region { @Override public long travelTimeMillis(Coordinates from, Coordinates to) { GHRequest ghRequest = new GHRequest( from.latitude().doubleValue(), from.longitude().doubleValue(), to.latitude().doubleValue(), to.longitude().doubleValue()); GHResponse ghResponse = graphHopper.route(ghRequest); if (ghResponse.hasErrors()) { throw new DistanceCalculationException("No route from " + from + " to " + to, ghResponse.getErrors().get(0)); } return ghResponse.getBest().getTime(); } @Autowired  GraphHopperRouter(GraphHopperOSM graphHopper); }
GraphHopperRouter implements Router, DistanceCalculator, Region { @Override public long travelTimeMillis(Coordinates from, Coordinates to) { GHRequest ghRequest = new GHRequest( from.latitude().doubleValue(), from.longitude().doubleValue(), to.latitude().doubleValue(), to.longitude().doubleValue()); GHResponse ghResponse = graphHopper.route(ghRequest); if (ghResponse.hasErrors()) { throw new DistanceCalculationException("No route from " + from + " to " + to, ghResponse.getErrors().get(0)); } return ghResponse.getBest().getTime(); } @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 long travelTimeMillis(Coordinates from, Coordinates to) { GHRequest ghRequest = new GHRequest( from.latitude().doubleValue(), from.longitude().doubleValue(), to.latitude().doubleValue(), to.longitude().doubleValue()); GHResponse ghResponse = graphHopper.route(ghRequest); if (ghResponse.hasErrors()) { throw new DistanceCalculationException("No route from " + from + " to " + to, ghResponse.getErrors().get(0)); } return ghResponse.getBest().getTime(); } @Autowired  GraphHopperRouter(GraphHopperOSM graphHopper); @Override List<Coordinates> getPath(Coordinates from, Coordinates to); @Override long travelTimeMillis(Coordinates from, Coordinates to); @Override BoundingBox getBounds();  }