Categories: Geospatial
GEO_NEARBY
Returns TRUE if the distance between two geographic points is within the specified threshold in meters. Opposite of GEO_BEYOND.
Syntax
GEO_NEARBY(lat1 float, lon1 float, lat2 float, lon2 float, distance double) → boolean
- lat1: Latitude of the first point in degrees.
- lon1: Longitude of the first point in degrees.
- lat2: Latitude of the second point in degrees.
- lon2: Longitude of the second point in degrees.
- distance: Distance threshold in meters.
Examples
Determine whether the distance from Venice, Italy to Paris, France is within 800,000 metersSELECT GEO_NEARBY(45.4408, 12.3155, 48.8566, 2.3522, 800000)
-- False
SELECT GEO_NEARBY(45.4408, 12.3155, 48.8566, 2.3522, 1000000)
-- True
Usage Notes
The lat and lon parameters to this function can only be the FLOAT data type. The distance parameter can only be the DOUBLE data type. You must CAST other data types for lat and lon to FLOAT and the distance parameter to DOUBLE. This function calculates the result using the Haversine distance algorithm.