C# Class Spatial4n.Core.Distance.DistanceUtils

Show file Open project: synhershko/Spatial4n Class Usage Examples

Public Properties

Property Type Description
DEGREES_TO_RADIANS double
DEG_180_AS_RADS double
DEG_225_AS_RADS double
DEG_270_AS_RADS double
DEG_45_AS_RADS double
DEG_90_AS_RADS double
DEG_TO_KM double
EARTH_EQUATORIAL_RADIUS_KM double
EARTH_EQUATORIAL_RADIUS_MI double
EARTH_MEAN_RADIUS_KM double
EARTH_MEAN_RADIUS_MI double
KM_TO_DEG double
KM_TO_MILES double
MILES_TO_KM double
RADIANS_TO_DEGREES double
SIN_45_AS_RADS double

Public Methods

Method Description
CalcBoxByDistFromPtDEG ( double lat, double lon, double distDEG, SpatialContext ctx, Rectangle reuse ) : Rectangle
CalcBoxByDistFromPt_deltaLonDEG ( double lat, double lon, double distDEG ) : double

The delta longitude of a point-distance. In other words, half the width of the bounding box of a circle.

CalcBoxByDistFromPt_latHorizAxisDEG ( double lat, double lon, double distDEG ) : 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 from.getY() but, perhaps surprisingly, on a sphere it is going to be slightly different.

Degrees2Dist ( double degrees, double radius ) : double
Dist2Degrees ( double dist, double radius ) : 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 dist, double radius ) : double

Converts a distance in the units of radius (e.g. kilometers) to radians (multiples of the radius). A spherical earth model is assumed.

DistHaversineRAD ( double lat1, double lon1, double lat2, double lon2 ) : double
DistLawOfCosinesRAD ( double lat1, double lon1, double lat2, double lon2 ) : double
DistSquaredCartesian ( double vec1, double vec2 ) : double
DistVincentyRAD ( double lat1, double lon1, double lat2, double lon2 ) : double
NormLatDEG ( double lat_deg ) : double

Puts in range -90 <= lat_deg <= 90.

NormLonDEG ( double lon_deg ) : double

Puts in range -180 <= lon_deg <= +180.

PointOnBearingRAD ( double startLat, double startLon, double distanceRAD, double bearingRAD, SpatialContext ctx, System.Point reuse ) : System.Point
Radians2Dist ( double radians, double radius ) : double
ToDegrees ( double radians ) : double

Same as {@link Math#toDegrees(double)} but 3x faster (multiply vs. divide). See CompareRadiansSnippet.java in tests.

ToRadians ( double degrees ) : double

Same as {@link Math#toRadians(double)} but 3x faster (multiply vs. divide). See CompareRadiansSnippet.java in tests.

VectorBoxCorner ( double center, double result, double distance, bool upperRight ) : double[]
VectorDistance ( double vec1, double vec2, double power ) : double

Calculate the p-norm (i.e. length) between two vectors

VectorDistance ( double vec1, double vec2, double power, double oneOverPower ) : double

Calculate the p-norm (i.e. length) between two vectors

Method Details

CalcBoxByDistFromPtDEG() public static method

public static CalcBoxByDistFromPtDEG ( double lat, double lon, double distDEG, SpatialContext ctx, Rectangle reuse ) : Rectangle
lat double
lon double
distDEG double
ctx Spatial4n.Core.Context.SpatialContext
reuse Rectangle
return Rectangle

CalcBoxByDistFromPt_deltaLonDEG() public static method

The delta longitude of a point-distance. In other words, half the width of the bounding box of a circle.
public static CalcBoxByDistFromPt_deltaLonDEG ( double lat, double lon, double distDEG ) : double
lat double
lon double
distDEG double
return double

CalcBoxByDistFromPt_latHorizAxisDEG() public static method

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 from.getY() but, perhaps surprisingly, on a sphere it is going to be slightly different.
public static CalcBoxByDistFromPt_latHorizAxisDEG ( double lat, double lon, double distDEG ) : double
lat double
lon double
distDEG double
return double

Degrees2Dist() public static method

public static Degrees2Dist ( double degrees, double radius ) : double
degrees double
radius double
return double

Dist2Degrees() public static method

Converts a distance in the units of the radius to degrees (360 degrees are in a circle). A spherical earth model is assumed.
public static Dist2Degrees ( double dist, double radius ) : double
dist double
radius double
return double

Dist2Radians() public static method

Converts a distance in the units of radius (e.g. kilometers) to radians (multiples of the radius). A spherical earth model is assumed.
public static Dist2Radians ( double dist, double radius ) : double
dist double
radius double
return double

DistHaversineRAD() public static method

public static DistHaversineRAD ( double lat1, double lon1, double lat2, double lon2 ) : double
lat1 double
lon1 double
lat2 double
lon2 double
return double

DistLawOfCosinesRAD() public static method

public static DistLawOfCosinesRAD ( double lat1, double lon1, double lat2, double lon2 ) : double
lat1 double
lon1 double
lat2 double
lon2 double
return double

DistSquaredCartesian() public static method

public static DistSquaredCartesian ( double vec1, double vec2 ) : double
vec1 double
vec2 double
return double

DistVincentyRAD() public static method

public static DistVincentyRAD ( double lat1, double lon1, double lat2, double lon2 ) : double
lat1 double
lon1 double
lat2 double
lon2 double
return double

NormLatDEG() public static method

Puts in range -90 <= lat_deg <= 90.
public static NormLatDEG ( double lat_deg ) : double
lat_deg double
return double

NormLonDEG() public static method

Puts in range -180 <= lon_deg <= +180.
public static NormLonDEG ( double lon_deg ) : double
lon_deg double
return double

PointOnBearingRAD() public static method

public static PointOnBearingRAD ( double startLat, double startLon, double distanceRAD, double bearingRAD, SpatialContext ctx, System.Point reuse ) : System.Point
startLat double
startLon double
distanceRAD double
bearingRAD double
ctx Spatial4n.Core.Context.SpatialContext
reuse System.Point
return System.Point

Radians2Dist() public static method

public static Radians2Dist ( double radians, double radius ) : double
radians double
radius double
return double

ToDegrees() public static method

Same as {@link Math#toDegrees(double)} but 3x faster (multiply vs. divide). See CompareRadiansSnippet.java in tests.
public static ToDegrees ( double radians ) : double
radians double
return double

ToRadians() public static method

Same as {@link Math#toRadians(double)} but 3x faster (multiply vs. divide). See CompareRadiansSnippet.java in tests.
public static ToRadians ( double degrees ) : double
degrees double
return double

VectorBoxCorner() public static method

public static VectorBoxCorner ( double center, double result, double distance, bool upperRight ) : double[]
center double
result double
distance double
upperRight bool
return double[]

VectorDistance() public static method

Calculate the p-norm (i.e. length) between two vectors
public static VectorDistance ( double vec1, double vec2, double power ) : double
vec1 double The first vector
vec2 double The second vector
power double The power (2 for cartesian distance, 1 for manhattan, etc.)
return double

VectorDistance() public static method

Calculate the p-norm (i.e. length) between two vectors
public static VectorDistance ( double vec1, double vec2, double power, double oneOverPower ) : double
vec1 double The first vector
vec2 double The second vector
power double The power (2 for cartesian distance, 1 for manhattan, etc.)
oneOverPower double If you've precalculated oneOverPower and cached it, use this method to save one division operation over {@link #vectorDistance(double[], double[], double)}.
return double

Property Details

DEGREES_TO_RADIANS public static property

public static double DEGREES_TO_RADIANS
return double

DEG_180_AS_RADS public static property

public static double DEG_180_AS_RADS
return double

DEG_225_AS_RADS public static property

public static double DEG_225_AS_RADS
return double

DEG_270_AS_RADS public static property

public static double DEG_270_AS_RADS
return double

DEG_45_AS_RADS public static property

public static double DEG_45_AS_RADS
return double

DEG_90_AS_RADS public static property

public static double DEG_90_AS_RADS
return double

DEG_TO_KM public static property

public static double DEG_TO_KM
return double

EARTH_EQUATORIAL_RADIUS_KM public static property

public static double EARTH_EQUATORIAL_RADIUS_KM
return double

EARTH_EQUATORIAL_RADIUS_MI public static property

public static double EARTH_EQUATORIAL_RADIUS_MI
return double

EARTH_MEAN_RADIUS_KM public static property

The International Union of Geodesy and Geophysics says the Earth's mean radius in KM is: [1] http://en.wikipedia.org/wiki/Earth_radius
public static double EARTH_MEAN_RADIUS_KM
return double

EARTH_MEAN_RADIUS_MI public static property

public static double EARTH_MEAN_RADIUS_MI
return double

KM_TO_DEG public static property

public static double KM_TO_DEG
return double

KM_TO_MILES public static property

public static double KM_TO_MILES
return double

MILES_TO_KM public static property

public static double MILES_TO_KM
return double

RADIANS_TO_DEGREES public static property

public static double RADIANS_TO_DEGREES
return double

SIN_45_AS_RADS public static property

public static double SIN_45_AS_RADS
return double