arangodb

Difference between distance() and geo_distance() in arangodb


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

Thanks, Nilotpal


Solution

  • 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 https://docs.arangodb.com/3.11/index-and-search/indexing/working-with-indexes/geo-spatial-indexes/#geojson

    There are also utility functions to make the construction of GeoJSON objects a bit more convenient (GEO_LINESTRING, GEO_MULTILINESTRING, GEO_MULTIPOINT, GEO_POINT, GEO_POLYGON and GEO_MULTIPOLYGON, see https://docs.arangodb.com/3.11/aql/functions/geo/#geojson-constructors)