Class DistanceUtils
Various distance calculations and constants. To the extent possible, a IDistanceCalculator, retrieved from DistCalc should be used in preference to calling these methods directly.
This code came from Apache Lucene, LUCENE-1387, which in turn came from "LocalLucene".
Inheritance
Inherited Members
Assembly: Spatial4n.dll
Syntax
public static class DistanceUtils
Fields
Name | Description |
---|---|
DEG_180_AS_RADS | |
DEG_225_AS_RADS | |
DEG_270_AS_RADS | |
DEG_45_AS_RADS | |
DEG_90_AS_RADS | |
DEG_TO_KM | Equivalent to Degrees2Dist(1, EARTH_MEAN_RADIUS_KM) |
DEGREES_TO_RADIANS | |
EARTH_EQUATORIAL_RADIUS_KM | |
EARTH_EQUATORIAL_RADIUS_MI | |
EARTH_MEAN_RADIUS_KM | The International Union of Geodesy and Geophysics says the Earth's mean radius in KM is: |
EARTH_MEAN_RADIUS_MI | |
KM_TO_DEG | |
KM_TO_MILES | |
MILES_TO_KM | |
RADIANS_TO_DEGREES | |
SIN_45_AS_RADS |
Methods
Name | Description |
---|---|
CalcBoxByDistFromPt_deltaLonDEG(Double, Double, Double) | The delta longitude of a point-distance. In other words, half the width of the bounding box of a circle. |
CalcBoxByDistFromPt_latHorizAxisDEG(Double, Double, Double) | The latitude of the horizontal axis (e.g. left-right line)
of a circle. The horizontal axis of a circle passes through its furthest
left-most and right-most edges. On a 2D plane, this result is always
|
CalcBoxByDistFromPtDEG(Double, Double, Double, SpatialContext, IRectangle) | Calculates the bounding box of a circle, as specified by its center point
and distance. |
CalcLonDegreesAtLat(Double, Double) | Calculates the degrees longitude distance at latitude Used to calculate a new expanded buffer distance to account for skewing effects for shapes that use the lat-lon space as a 2D plane instead of a sphere. The expanded buffer will be sure to cover the intended area, but the shape is still skewed and so it will cover a larger area. For latitude 0 (the equator) the result is the same buffer. At 60 (or -60) degrees, the result is twice the buffer, meaning that a shape at 60 degrees is twice as high as it is wide when projected onto a lat-lon plane even if in the real world it's equal all around. If the result added to abs(lat ) is >= 90 degrees, then skewing is
so severe that the caller should consider tossing the shape and
substituting a spherical cap instead.
|
Degrees2Dist(Double, Double) | Converts |
Dist2Degrees(Double, Double) | Converts a distance in the units of the radius to degrees (360 degrees are in a circle). A spherical earth model is assumed. |
Dist2Radians(Double, Double) | Converts a distance in the units of |
DistHaversineRAD(Double, Double, Double, Double) | |
DistLawOfCosinesRAD(Double, Double, Double, Double) | Calculates the distance between two lat/lng's using the Law of Cosines. Due to numeric conditioning errors, it is not as accurate as the Haversine formula for small distances. But with double precision, it isn't that bad -- allegedly 1 meter. The arguments and return value are in radians. |
DistSquaredCartesian(Double[], Double[]) | The square of the cartesian Distance. Not really a distance, but useful if all that matters is comparing the result to another one. |
DistVincentyRAD(Double, Double, Double, Double) | Calculates the great circle distance using the Vincenty Formula, simplified for a spherical model. This formula is accurate for any pair of points. The equation was taken from Wikipedia. The arguments are in radians, and the result is in radians. |
NormLatDEG(Double) | Puts in range -90 <= lat_deg <= 90. |
NormLonDEG(Double) | Puts in range -180 <= lon_deg <= +180. |
PointOnBearingRAD(Double, Double, Double, Double, SpatialContext, IPoint) | Given a start point (startLat, startLon) and a bearing on a sphere of radius sphereRadius, return the destination point. |
Radians2Dist(Double, Double) | Converts |
ToDegrees(Double) | Same as Java's |
ToRadians(Double) | Same as Java's |
VectorBoxCorner(Double[], Double[], Double, Boolean) | Return the coordinates of a vector that is the corner of a box (upper right or lower left), assuming a Rectangular coordinate system. Note, this does not apply for points on a sphere or ellipse (although it could be used as an approximation). |
VectorDistance(Double[], Double[], Double) | Calculate the p-norm (i.e. length) between two vectors |
VectorDistance(Double[], Double[], Double, Double) | Calculate the p-norm (i.e. length) between two vectors |