Package com.graphhopper.util
Interface DistanceCalc
- All Known Implementing Classes:
DistanceCalc3D
,DistanceCalcEarth
,DistanceCalcEuclidean
,DistancePlaneProjection
public interface DistanceCalc
Calculates the distance of two points or one point and an edge on earth via haversine formula.
Allows subclasses to implement less or more precise calculations.
See http://en.wikipedia.org/wiki/Haversine_formula
- Author:
- Peter Karich
-
Method Summary
Modifier and TypeMethodDescriptiondouble
calcCircumference
(double lat) calcCrossingPointToEdge
(double r_lat_deg, double r_lon_deg, double a_lat_deg, double a_lon_deg, double b_lat_deg, double b_lon_deg) double
calcDenormalizedDist
(double normedDist) Inverse to calcNormalizedDist.double
calcDist
(double fromLat, double fromLon, double toLat, double toLon) Calculates distance of (from, to) in meter.double
calcDist3D
(double fromLat, double fromLon, double fromEle, double toLat, double toLon, double toEle) Calculates 3d distance of (from, to) in meter.double
calcDistance
(PointList pointList) double
calcNormalizedDist
(double dist) Returns the specified length in normalized meter.double
calcNormalizedDist
(double fromLat, double fromLon, double toLat, double toLon) Calculates in normalized meterdouble
calcNormalizedEdgeDistance
(double r_lat_deg, double r_lon_deg, double a_lat_deg, double a_lon_deg, double b_lat_deg, double b_lon_deg) This method calculates the distance from r to edge (a, b) where the crossing point is cdouble
calcNormalizedEdgeDistance3D
(double r_lat_deg, double r_lon_deg, double r_ele_m, double a_lat_deg, double a_lon_deg, double a_ele_m, double b_lat_deg, double b_lon_deg, double b_ele_m) This method calculates the distance from r to edge (a, b) where the crossing point is c including elevationcreateBBox
(double lat, double lon, double radiusInMeter) intermediatePoint
(double f, double lat1, double lon1, double lat2, double lon2) This methods creates a point (lat, lon in degrees) a fraction of the distance along the path from (lat1, lon1) to (lat2, lon2).boolean
isCrossBoundary
(double lon1, double lon2) projectCoordinate
(double lat, double lon, double distanceInMeter, double headingClockwiseFromNorth) This methods creates a point (lat, lon in degrees) in a certain distance and direction from the specified point (lat, lon in degrees).boolean
validEdgeDistance
(double r_lat_deg, double r_lon_deg, double a_lat_deg, double a_lon_deg, double b_lat_deg, double b_lon_deg) This method decides for case 1: if we should use distance(r to edge) where r=(lat,lon) or case 2: min(distance(r to a), distance(r to b)) where edge=(a to b).
-
Method Details
-
createBBox
-
calcCircumference
double calcCircumference(double lat) -
calcDist
double calcDist(double fromLat, double fromLon, double toLat, double toLon) Calculates distance of (from, to) in meter. -
calcDist3D
double calcDist3D(double fromLat, double fromLon, double fromEle, double toLat, double toLon, double toEle) Calculates 3d distance of (from, to) in meter. -
calcNormalizedDist
double calcNormalizedDist(double dist) Returns the specified length in normalized meter. -
calcDenormalizedDist
double calcDenormalizedDist(double normedDist) Inverse to calcNormalizedDist. Returned the length in meter. -
calcNormalizedDist
double calcNormalizedDist(double fromLat, double fromLon, double toLat, double toLon) Calculates in normalized meter -
validEdgeDistance
boolean validEdgeDistance(double r_lat_deg, double r_lon_deg, double a_lat_deg, double a_lon_deg, double b_lat_deg, double b_lon_deg) This method decides for case 1: if we should use distance(r to edge) where r=(lat,lon) or case 2: min(distance(r to a), distance(r to b)) where edge=(a to b). Note that due to rounding errors it cannot properly detect if it is case 1 or 90°.case 1 (including ): r . a-------b
case 2: r . a-------b
- Returns:
- true for case 1 which is "on edge" or the special case of 90° to the edge
-
calcNormalizedEdgeDistance
double calcNormalizedEdgeDistance(double r_lat_deg, double r_lon_deg, double a_lat_deg, double a_lon_deg, double b_lat_deg, double b_lon_deg) This method calculates the distance from r to edge (a, b) where the crossing point is c- Returns:
- the distance in normalized meter
-
calcNormalizedEdgeDistance3D
double calcNormalizedEdgeDistance3D(double r_lat_deg, double r_lon_deg, double r_ele_m, double a_lat_deg, double a_lon_deg, double a_ele_m, double b_lat_deg, double b_lon_deg, double b_ele_m) This method calculates the distance from r to edge (a, b) where the crossing point is c including elevation- Returns:
- the distance in normalized meter
-
calcCrossingPointToEdge
GHPoint calcCrossingPointToEdge(double r_lat_deg, double r_lon_deg, double a_lat_deg, double a_lon_deg, double b_lat_deg, double b_lon_deg) - Returns:
- the crossing point c of the vertical line from r to line (a, b)
-
projectCoordinate
GHPoint projectCoordinate(double lat, double lon, double distanceInMeter, double headingClockwiseFromNorth) This methods creates a point (lat, lon in degrees) in a certain distance and direction from the specified point (lat, lon in degrees). The heading is measured clockwise from north in degrees. The distance is passed in meter. -
intermediatePoint
This methods creates a point (lat, lon in degrees) a fraction of the distance along the path from (lat1, lon1) to (lat2, lon2). -
isCrossBoundary
boolean isCrossBoundary(double lon1, double lon2) -
calcDistance
-