DistanceFunctions.Distance Function
The DISTANCE function calculates the distance between any two locations.
Format
DISTANCE ( <location> TO <location> )
{fn DISTANCE ( <location>, <location> )}
The result is a positive distance in meters between the two locations (the direction or order are not relevant).
Where Location can be one of the following:
- A location literal.
- A parameter marker.
- A string expression that evaluates to a string containing the standard location format.
The following is an example of the use of the Distance function in conjunction with the Location literal:
SELECT
NAME, GISLOCATION->GEOPOSITION, DISTANCE( LOCATION '51.476852,0' TO GEOPOSITION ) / 1000.0 AS "DistanceInKm"
FROM
CDBOBJECT
WHERE
GEOPOSITION IS NOT NULL
Also see: