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 TypeMethodDescriptiondoublecalcCircumference(double lat) Circumference of the earth at different latitudes (breitengrad)doublecalcDenormalizedDist(double normedDist) Inverse to calcNormalizedDist.doublecalcDist(double fromY, double fromX, double toY, double toX) Calculates distance of (from, to) in meter.doublecalcDist3D(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.doublecalcNormalizedDist(double dist) Returns the specified length in normalized meter.doublecalcNormalizedDist(double fromY, double fromX, double toY, double toX) Calculates in normalized meterdoublecalcNormalizedEdgeDistance(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 cdoublecalcNormalizedEdgeDistance3D(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).booleanisCrossBoundary(double lon1, double lon2) booleanisDateLineCrossOver(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:DistanceCalcEarthCalculates 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:
calcDistin interfaceDistanceCalc- Overrides:
calcDistin classDistanceCalcEarth
-
calcDist3D
public double calcDist3D(double fromY, double fromX, double fromHeight, double toY, double toX, double toHeight) Description copied from class:DistanceCalcEarthThis 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:
calcDist3Din interfaceDistanceCalc- Overrides:
calcDist3Din classDistanceCalcEarth
-
calcDenormalizedDist
public double calcDenormalizedDist(double normedDist) Description copied from interface:DistanceCalcInverse to calcNormalizedDist. Returned the length in meter.- Specified by:
calcDenormalizedDistin interfaceDistanceCalc- Overrides:
calcDenormalizedDistin classDistanceCalcEarth
-
calcNormalizedDist
public double calcNormalizedDist(double dist) Returns the specified length in normalized meter.- Specified by:
calcNormalizedDistin interfaceDistanceCalc- Overrides:
calcNormalizedDistin classDistanceCalcEarth
-
calcNormalizedDist
public double calcNormalizedDist(double fromY, double fromX, double toY, double toX) Calculates in normalized meter- Specified by:
calcNormalizedDistin interfaceDistanceCalc- Overrides:
calcNormalizedDistin classDistanceCalcEarth
-
toString
- Overrides:
toStringin classDistanceCalcEarth
-
calcCircumference
public double calcCircumference(double lat) Description copied from class:DistanceCalcEarthCircumference of the earth at different latitudes (breitengrad)- Specified by:
calcCircumferencein interfaceDistanceCalc- Overrides:
calcCircumferencein classDistanceCalcEarth
-
isDateLineCrossOver
public boolean isDateLineCrossOver(double lon1, double lon2) - Overrides:
isDateLineCrossOverin classDistanceCalcEarth
-
createBBox
- Specified by:
createBBoxin interfaceDistanceCalc- Overrides:
createBBoxin classDistanceCalcEarth
-
projectCoordinate
public GHPoint projectCoordinate(double latInDeg, double lonInDeg, double distanceInMeter, double headingClockwiseFromNorth) Description copied from interface:DistanceCalcThis 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:
projectCoordinatein interfaceDistanceCalc- Overrides:
projectCoordinatein classDistanceCalcEarth
-
intermediatePoint
Description copied from interface:DistanceCalcThis methods creates a point (lat, lon in degrees) a fraction of the distance along the path from (lat1, lon1) to (lat2, lon2).- Specified by:
intermediatePointin interfaceDistanceCalc- Overrides:
intermediatePointin classDistanceCalcEarth
-
isCrossBoundary
public boolean isCrossBoundary(double lon1, double lon2) - Specified by:
isCrossBoundaryin interfaceDistanceCalc- Overrides:
isCrossBoundaryin classDistanceCalcEarth
-
calcNormalizedEdgeDistance
public double calcNormalizedEdgeDistance(double ry, double rx, double ay, double ax, double by, double bx) Description copied from interface:DistanceCalcThis method calculates the distance from r to edge (a, b) where the crossing point is c- Specified by:
calcNormalizedEdgeDistancein interfaceDistanceCalc- Overrides:
calcNormalizedEdgeDistancein 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:DistanceCalcThis method calculates the distance from r to edge (a, b) where the crossing point is c including elevation- Specified by:
calcNormalizedEdgeDistance3Din interfaceDistanceCalc- Overrides:
calcNormalizedEdgeDistance3Din classDistanceCalcEarth- Returns:
- the distance in normalized meter
-