Difference between distance() and geo_distance() in arangodb

Viewed 47

What is the difference between the arango function - DISTANCE() and GE0_DISTANCE(). I know both of them calculates distance using haversines formula.

Thanks, Nilotpal

1 Answers

Both are used for two different purposes

DISTANCE(latitude1, longitude1, latitude2, longitude2) → distance

The value is computed using the haversine formula, which is based on a spherical Earth model. It’s fast to compute and is accurate to around 0.3%, which is sufficient for most use cases such as location-aware services.

GEO_DISTANCE(geoJsonA, geoJsonB, ellipsoid) → distance

Return the distance between two GeoJSON objects, measured from the centroid of each shape. For a list of supported types see the geo index page. (Ref: https://www.arangodb.com/docs/3.8/aql/functions-geo.html#geo-index-functions)

This GeoJSON objects can be anything like GEO_LINESTRING, GEO_MULTILINESTRING, GEO_MULTIPOINT, GEO_POINT, GEO_POLYGON and GEO_MULTIPOLYGON - Reference<2>

Reference:

  1. https://www.arangodb.com/docs/3.8/aql/functions-geo.html#geo-utility-functions
  2. https://www.arangodb.com/docs/3.8/aql/functions-geo.html#geojson-constructors
Related