CALC_DISTANCE
The CALC_DISTANCE
function is used to calculate the Euclidean distance between two Point
type geographical coordinates.
Syntax
CALC_DISTANCE(point1, point2)
Parameters:
point1
: The first geographical coordinate of typePoint
.point2
: The second geographical coordinate of typePoint
.
Examples
Consider the following table Foo
:
Example 1: Calculate the distance between two points
SELECT CALC_DISTANCE(geo1, geo2) AS georesult FROM Foo;
Result:
georesult |
---|
1.104150152832485 |
Errors
- If the number of arguments is not 2, a
FunctionArgsLengthNotMatching
error will be thrown. - If any of the arguments are not of type
Point
, aFunctionRequiresPointValue
error will be thrown. - If any of the arguments are
NULL
, the result will beNULL
.