0
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 .

jayt.dev
  • 975
  • 6
  • 14
  • 36
  • Let's say you have a Coördinate (0,0) and a Coördinate (0,1). The distance between these two coördinates is a coördinate's unit. – Nils O May 04 '15 at 13:24

2 Answers2

1

The units MAY or MAY NOT be meters, depending on your spatial reference system. Assuming you have a geograpic system (e.g. WGS84), that means you assign coordinates in degrees, you have degrees as unit. On rectangular reference systems you may however have meters as units. Another unit would be pixels which is the distance unit for displays - e.g. your browser. Here the coordinate (0; 0) means left upper corner, whereas (0, 0) in geographic system means somewehere in the atlantic ocean.

I´m pretty sure that SpatialLite has a method to project (that´s what you need to look for) one coordinate from one spatial reference-system into another.

EDIT: I´ve found this method for spatialLite that does what you need. Transform the points for that you need the distance into the target spatial-reference-system and than calculate the distance by using simple algebra. Alternatively reproject the whole data to UTM34. Thus you may use the method you already mentioned because you do not need any on-the-fly-transformations which takes long time. However you permanently change your data.

MakePeaceGreatAgain
  • 35,491
  • 6
  • 60
  • 111
1

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.

Steve Mitcham
  • 5,268
  • 1
  • 28
  • 56