@Test void travel_time_should_be_distance_divided_by_speed() { AirDistanceRouter router = new AirDistanceRouter(); Coordinates from = Coordinates.valueOf(0, 0); Coordinates to = Coordinates.valueOf(3, 4); long travelTimeMillis = router.travelTimeMillis(from, to); assertThat(travelTimeMillis).isEqualTo((long) (5 * AirDistanceRouter.KILOMETERS_PER_DEGREE / AirDistanceRouter.TRAVEL_SPEED_KPH * AirDistanceRouter.MILLIS_IN_ONE_HOUR)); }
@Override public long travelTimeMillis(Coordinates from, Coordinates to) { BigDecimal latDiff = to.latitude().subtract(from.latitude()); BigDecimal lngDiff = to.longitude().subtract(from.longitude()); double distanceKilometers = Math.sqrt(latDiff.pow(2).add(lngDiff.pow(2)).doubleValue()) * KILOMETERS_PER_DEGREE; return (long) Math.floor(distanceKilometers / TRAVEL_SPEED_KPH * MILLIS_IN_ONE_HOUR); }
AirDistanceRouter implements Router, DistanceCalculator, Region { @Override public long travelTimeMillis(Coordinates from, Coordinates to) { BigDecimal latDiff = to.latitude().subtract(from.latitude()); BigDecimal lngDiff = to.longitude().subtract(from.longitude()); double distanceKilometers = Math.sqrt(latDiff.pow(2).add(lngDiff.pow(2)).doubleValue()) * KILOMETERS_PER_DEGREE; return (long) Math.floor(distanceKilometers / TRAVEL_SPEED_KPH * MILLIS_IN_ONE_HOUR); } }
AirDistanceRouter implements Router, DistanceCalculator, Region { @Override public long travelTimeMillis(Coordinates from, Coordinates to) { BigDecimal latDiff = to.latitude().subtract(from.latitude()); BigDecimal lngDiff = to.longitude().subtract(from.longitude()); double distanceKilometers = Math.sqrt(latDiff.pow(2).add(lngDiff.pow(2)).doubleValue()) * KILOMETERS_PER_DEGREE; return (long) Math.floor(distanceKilometers / TRAVEL_SPEED_KPH * MILLIS_IN_ONE_HOUR); }  }
AirDistanceRouter implements Router, DistanceCalculator, Region { @Override public long travelTimeMillis(Coordinates from, Coordinates to) { BigDecimal latDiff = to.latitude().subtract(from.latitude()); BigDecimal lngDiff = to.longitude().subtract(from.longitude()); double distanceKilometers = Math.sqrt(latDiff.pow(2).add(lngDiff.pow(2)).doubleValue()) * KILOMETERS_PER_DEGREE; return (long) Math.floor(distanceKilometers / TRAVEL_SPEED_KPH * MILLIS_IN_ONE_HOUR); }  @Override long travelTimeMillis(Coordinates from, Coordinates to); @Override List<Coordinates> getPath(Coordinates from, Coordinates to); @Override BoundingBox getBounds(); }
AirDistanceRouter implements Router, DistanceCalculator, Region { @Override public long travelTimeMillis(Coordinates from, Coordinates to) { BigDecimal latDiff = to.latitude().subtract(from.latitude()); BigDecimal lngDiff = to.longitude().subtract(from.longitude()); double distanceKilometers = Math.sqrt(latDiff.pow(2).add(lngDiff.pow(2)).doubleValue()) * KILOMETERS_PER_DEGREE; return (long) Math.floor(distanceKilometers / TRAVEL_SPEED_KPH * MILLIS_IN_ONE_HOUR); }  @Override long travelTimeMillis(Coordinates from, Coordinates to); @Override List<Coordinates> getPath(Coordinates from, Coordinates to); @Override BoundingBox getBounds();  }