math.geo_distance

Supported in:
math.geo_distance(longitude1, latitude1, longitude2, latitude2))

Description

Returns the distance between two geographic locations (coordinates) in meters. Returns -1 if the coordinates are invalid.

Parameter data types

FLOAT, FLOAT, FLOAT, FLOAT

Return type

FLOAT

Code samples

Example 1

The following example returns the distance when all parameters are valid coordinates:

math.geo_distance(-122.020287, 37.407574, -122.021810, 37.407574) = 134.564318
Example 2

The following example returns the distance when one of the parameters is a truncated coordinate:

math.geo_distance(-122.000000, 37.407574, -122.021810, 37.407574) = 1926.421905
Example 3

The following example returns -1 when one of the parameters is an invalid coordinate:

math.geo_distance(0-122.897680, 37.407574, 0-122.021810, 97.407574) = -1.000000
Example 4

The following example returns 0 when coordinates are the same:

math.geo_distance(-122.897680, 37.407574, -122.897680, 37.407574) = 0.000000