public double CalculateDistance(
Coordinate c,
Coordinate a,
Coordinate b,
LineMode mode)
Parameters:
c Type: SpatialLite.Core.API.Coordinate The coordinate to compute the distance for.
a Type: SpatialLite.Core.API.Coordinate One point of the line.
b Type: SpatialLite.Core.API.Coordinate Another point of the line.
mode Type: SpatialLite.Core.Algorithms.LineMode LineMode value that specifies whether AB should be treated as infinite line or as line segment.
Return Value The distance from C to line AB in coordinate's units.
I am using the above method from SpatialLite Library. The returned variable is of type double and as described in the documentation it is the distance in coordinate's units. I do not understand what exactly "coordinate's units" are. How can I convert them in to meters?
Source code here .
The CalculateDistance
method is found on an interface that has two different default implementations: Euclidean2DCalculator
and Sphere2DCalculator
. The Euclidean implementation is assuming a unit-less cartesian coordinate space and calculates a straight line distance between the two coordinates. This is what looks like you are getting.
If you are looking for Spherical coordinates, then you need to instantiate the Sphere2DCalculator
. I'm not familiar with the usage of the library, just digging through the code on Google Code.
The sphere algorithm returns a great circle distance between the two points in meters, assuming a spherical earth with a radius of 6371010 meters.
A spherical earth is not the best representation, but depending on your application may be sufficient. Current cartography standardizes on WGS 84 and this library does not support that representation.