public class DistanceCalcEarth extends Object implements DistanceCalc
Modifier and Type | Field and Description |
---|---|
static double |
C
Circumference of the earth
|
static double |
KM_MILE |
static double |
METERS_PER_DEGREE |
static double |
R
mean radius of the earth
|
static double |
R_EQ
Radius of the earth at equator
|
Constructor and Description |
---|
DistanceCalcEarth() |
Modifier and Type | Method and Description |
---|---|
double |
calcCircumference(double lat)
Circumference of the earth at different latitudes (breitengrad)
|
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) |
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 fromHeight,
double toLat,
double toLon,
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 fromLat,
double fromLon,
double toLat,
double toLon)
Calculates in normalized meter
|
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
|
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
|
double |
calcNormalizedEdgeDistanceNew(double r_lat_deg,
double r_lon_deg,
double a_lat_deg,
double a_lon_deg,
double b_lat_deg,
double b_lon_deg,
boolean reduceToSegment)
New edge distance calculation where no validEdgeDistance check would be necessary
|
BBox |
createBBox(double lat,
double lon,
double radiusInMeter) |
protected boolean |
hasElevationDiff(double a,
double b) |
boolean |
isCrossBoundary(double lon1,
double lon2) |
boolean |
isDateLineCrossOver(double lon1,
double lon2) |
GHPoint |
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).
|
String |
toString() |
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).
|
public static final double R
public static final double R_EQ
public static final double C
public static final double KM_MILE
public static final double METERS_PER_DEGREE
public double calcDist(double fromLat, double fromLon, double toLat, double toLon)
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
calcDist
in interface DistanceCalc
public double calcDist3D(double fromLat, double fromLon, double fromHeight, double toLat, double toLon, double toHeight)
calcDist3D
in interface DistanceCalc
public double calcDenormalizedDist(double normedDist)
DistanceCalc
calcDenormalizedDist
in interface DistanceCalc
public double calcNormalizedDist(double dist)
calcNormalizedDist
in interface DistanceCalc
public double calcNormalizedDist(double fromLat, double fromLon, double toLat, double toLon)
DistanceCalc
calcNormalizedDist
in interface DistanceCalc
public double calcCircumference(double lat)
calcCircumference
in interface DistanceCalc
public boolean isDateLineCrossOver(double lon1, double lon2)
public BBox createBBox(double lat, double lon, double radiusInMeter)
createBBox
in interface DistanceCalc
public 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)
DistanceCalc
calcNormalizedEdgeDistance
in interface DistanceCalc
public 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)
DistanceCalc
calcNormalizedEdgeDistance3D
in interface DistanceCalc
public double calcNormalizedEdgeDistanceNew(double r_lat_deg, double r_lon_deg, double a_lat_deg, double a_lon_deg, double b_lat_deg, double b_lon_deg, boolean reduceToSegment)
public 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)
calcCrossingPointToEdge
in interface DistanceCalc
public 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)
DistanceCalc
case 1 (including ): r . a-------b
case 2: r . a-------b
validEdgeDistance
in interface DistanceCalc
public GHPoint projectCoordinate(double latInDeg, double lonInDeg, double distanceInMeter, double headingClockwiseFromNorth)
DistanceCalc
projectCoordinate
in interface DistanceCalc
public boolean isCrossBoundary(double lon1, double lon2)
isCrossBoundary
in interface DistanceCalc
protected boolean hasElevationDiff(double a, double b)
Copyright © 2012–2020. All rights reserved.