1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

improve greate circle costs

This commit is contained in:
oblonski 2014-12-10 11:31:44 +01:00
parent b1fe1b32b6
commit 714bc9d4af

View file

@ -69,7 +69,7 @@ public class GreatCircleCosts extends AbstractForwardVehicleRoutingTransportCost
public double getTransportCost(String fromId, String toId, double time,Driver driver, Vehicle vehicle) { public double getTransportCost(String fromId, String toId, double time,Driver driver, Vehicle vehicle) {
double distance; double distance;
try { try {
distance = calculateDistance(fromId, toId); distance = getDistance(fromId, toId);
} catch (NullPointerException e) { } catch (NullPointerException e) {
throw new NullPointerException("cannot calculate euclidean distance. coordinates are missing. either add coordinates or use another transport-cost-calculator."); throw new NullPointerException("cannot calculate euclidean distance. coordinates are missing. either add coordinates or use another transport-cost-calculator.");
} }
@ -84,10 +84,10 @@ public class GreatCircleCosts extends AbstractForwardVehicleRoutingTransportCost
@Override @Override
public double getTransportTime(String fromId, String toId, double time, Driver driver, Vehicle vehicle) { public double getTransportTime(String fromId, String toId, double time, Driver driver, Vehicle vehicle) {
return calculateDistance(fromId, toId) / speed; return getDistance(fromId, toId) / speed;
} }
private double calculateDistance(String fromId, String toId) { public double getDistance(String fromId, String toId) {
Coordinate fromCoordinate = locations.getCoord(fromId); Coordinate fromCoordinate = locations.getCoord(fromId);
Coordinate toCoordinate = locations.getCoord(toId); Coordinate toCoordinate = locations.getCoord(toId);
return GreatCircleDistanceCalculator.calculateDistance(fromCoordinate, toCoordinate, distanceUnit) * detour; return GreatCircleDistanceCalculator.calculateDistance(fromCoordinate, toCoordinate, distanceUnit) * detour;