Package com.graphhopper.util
Class DistanceCalcEuclidean
java.lang.Object
com.graphhopper.util.DistanceCalcEarth
com.graphhopper.util.DistanceCalcEuclidean
- All Implemented Interfaces:
DistanceCalc
Calculates the distance of two points or one point and an edge in euclidean space.
- Author:
- Peter Karich
-
Field Summary
Fields inherited from class com.graphhopper.util.DistanceCalcEarth
C, DIST_EARTH, KM_MILE, METERS_PER_DEGREE, R, R_EQ
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
calcCircumference
(double lat) Circumference of the earth at different latitudes (breitengrad)double
calcDenormalizedDist
(double normedDist) Inverse to calcNormalizedDist.double
calcDist
(double fromY, double fromX, double toY, double toX) Calculates distance of (from, to) in meter.double
calcDist3D
(double fromY, double fromX, double fromHeight, double toY, double toX, double toHeight) This implements a rather quick solution to calculate 3D distances on earth using euclidean geometry mixed with Haversine formula used for the on earth distance.double
calcNormalizedDist
(double dist) Returns the specified length in normalized meter.double
calcNormalizedDist
(double fromY, double fromX, double toY, double toX) Calculates in normalized meterdouble
calcNormalizedEdgeDistance
(double ry, double rx, double ay, double ax, double by, double bx) This method calculates the distance from r to edge (a, b) where the crossing point is cdouble
calcNormalizedEdgeDistance3D
(double ry, double rx, double rz, double ay, double ax, double az, double by, double bx, double bz) 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) boolean
isDateLineCrossOver
(double lon1, double lon2) projectCoordinate
(double latInDeg, double lonInDeg, 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).toString()
Methods inherited from class com.graphhopper.util.DistanceCalcEarth
calcCrossingPointToEdge, calcDistance, calcDistance, hasElevationDiff, validEdgeDistance
-
Constructor Details
-
DistanceCalcEuclidean
public DistanceCalcEuclidean()
-
-
Method Details
-
calcDist
public double calcDist(double fromY, double fromX, double toY, double toX) Description copied from class:DistanceCalcEarth
Calculates distance of (from, to) in meter.http://en.wikipedia.org/wiki/Haversine_formula a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2) c = 2.atan2(√a, √(1−a)) d = R.c
- Specified by:
calcDist
in interfaceDistanceCalc
- Overrides:
calcDist
in classDistanceCalcEarth
-
calcDist3D
public double calcDist3D(double fromY, double fromX, double fromHeight, double toY, double toX, double toHeight) Description copied from class:DistanceCalcEarth
This implements a rather quick solution to calculate 3D distances on earth using euclidean geometry mixed with Haversine formula used for the on earth distance. The haversine formula makes not so much sense as it is only important for large distances where then the rather smallish heights would becomes negligible.- Specified by:
calcDist3D
in interfaceDistanceCalc
- Overrides:
calcDist3D
in classDistanceCalcEarth
-
calcDenormalizedDist
public double calcDenormalizedDist(double normedDist) Description copied from interface:DistanceCalc
Inverse to calcNormalizedDist. Returned the length in meter.- Specified by:
calcDenormalizedDist
in interfaceDistanceCalc
- Overrides:
calcDenormalizedDist
in classDistanceCalcEarth
-
calcNormalizedDist
public double calcNormalizedDist(double dist) Returns the specified length in normalized meter.- Specified by:
calcNormalizedDist
in interfaceDistanceCalc
- Overrides:
calcNormalizedDist
in classDistanceCalcEarth
-
calcNormalizedDist
public double calcNormalizedDist(double fromY, double fromX, double toY, double toX) Calculates in normalized meter- Specified by:
calcNormalizedDist
in interfaceDistanceCalc
- Overrides:
calcNormalizedDist
in classDistanceCalcEarth
-
toString
- Overrides:
toString
in classDistanceCalcEarth
-
calcCircumference
public double calcCircumference(double lat) Description copied from class:DistanceCalcEarth
Circumference of the earth at different latitudes (breitengrad)- Specified by:
calcCircumference
in interfaceDistanceCalc
- Overrides:
calcCircumference
in classDistanceCalcEarth
-
isDateLineCrossOver
public boolean isDateLineCrossOver(double lon1, double lon2) - Overrides:
isDateLineCrossOver
in classDistanceCalcEarth
-
createBBox
- Specified by:
createBBox
in interfaceDistanceCalc
- Overrides:
createBBox
in classDistanceCalcEarth
-
projectCoordinate
public GHPoint projectCoordinate(double latInDeg, double lonInDeg, double distanceInMeter, double headingClockwiseFromNorth) Description copied from interface:DistanceCalc
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.- Specified by:
projectCoordinate
in interfaceDistanceCalc
- Overrides:
projectCoordinate
in classDistanceCalcEarth
-
intermediatePoint
Description copied from interface:DistanceCalc
This methods creates a point (lat, lon in degrees) a fraction of the distance along the path from (lat1, lon1) to (lat2, lon2).- Specified by:
intermediatePoint
in interfaceDistanceCalc
- Overrides:
intermediatePoint
in classDistanceCalcEarth
-
isCrossBoundary
public boolean isCrossBoundary(double lon1, double lon2) - Specified by:
isCrossBoundary
in interfaceDistanceCalc
- Overrides:
isCrossBoundary
in classDistanceCalcEarth
-
calcNormalizedEdgeDistance
public double calcNormalizedEdgeDistance(double ry, double rx, double ay, double ax, double by, double bx) Description copied from interface:DistanceCalc
This method calculates the distance from r to edge (a, b) where the crossing point is c- Specified by:
calcNormalizedEdgeDistance
in interfaceDistanceCalc
- Overrides:
calcNormalizedEdgeDistance
in classDistanceCalcEarth
- Returns:
- the distance in normalized meter
-
calcNormalizedEdgeDistance3D
public double calcNormalizedEdgeDistance3D(double ry, double rx, double rz, double ay, double ax, double az, double by, double bx, double bz) Description copied from interface:DistanceCalc
This method calculates the distance from r to edge (a, b) where the crossing point is c including elevation- Specified by:
calcNormalizedEdgeDistance3D
in interfaceDistanceCalc
- Overrides:
calcNormalizedEdgeDistance3D
in classDistanceCalcEarth
- Returns:
- the distance in normalized meter
-