DistanceGetHaversineDistance Method (CoordinateReferenceSystem, Double, Double, Double, Double) |
Extension method that calculates the haversine distance between to
points using a specific coordinate reference system.
Namespace:
Ptv.Components.Projections
Assembly:
Ptv.Components.Projections (in Ptv.Components.Projections.dll) Version: 1.7.10.0
Syntax public static double GetHaversineDistance(
this CoordinateReferenceSystem crs,
double x0,
double y0,
double x1,
double y1
)
<ExtensionAttribute>
Public Shared Function GetHaversineDistance (
crs As CoordinateReferenceSystem,
x0 As Double,
y0 As Double,
x1 As Double,
y1 As Double
) As Double
public:
[ExtensionAttribute]
static double GetHaversineDistance(
CoordinateReferenceSystem^ crs,
double x0,
double y0,
double x1,
double y1
)
[<ExtensionAttribute>]
static member GetHaversineDistance :
crs : CoordinateReferenceSystem *
x0 : float *
y0 : float *
x1 : float *
y1 : float -> float
Parameters
- crs
- Type: Ptv.Components.ProjectionsCoordinateReferenceSystem
Coordinate reference system - x0
- Type: SystemDouble
X-coordinate of first point - y0
- Type: SystemDouble
Y-coordinate of first point - x1
- Type: SystemDouble
X-coordinate of second point - y1
- Type: SystemDouble
Y-coordinate of second point
Return Value
Type:
DoubleHaversine distance in [km].
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
CoordinateReferenceSystem. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Remarks This extension has been provided for convenience reasons only. It is good enough for single
coordinates but should be used in batch processing scenarios where performance is an issue. On each
call this extension method gets a coordinate transformation for transforming from the specified CRS
to EPSG:4326, transforms the specified coordinates to EPSG:4326 and finally uses the transformed
coordinates with the default, lon/lat based haversine distance calculation. When it comes to
mass-calculations it is recommended to cache and re-use any coordinate transformation necessary by
the client thus avoid per coordinate transformation lookups.
Examples double d_Frankfurt_Berlin = CoordinateReferenceSystem.XServer.PTV_MERCATOR.GetHaversineDistance(965820, 6458402, 1489888, 6883432);
See Also