Oihana PHP Arango

geoDistance.php

Table of Contents

Functions

geoDistance()  : string
Return the distance between two GeoJSON geometries, in meters.

Functions

geoDistance()

Return the distance between two GeoJSON geometries, in meters.

geoDistance(array<string|int, mixed>|string $geo1, array<string|int, mixed>|string $geo2[, string|null $ellipsoid = null ]) : string

This helper wraps the ArangoDB AQL function GEO_DISTANCE(geoJson1, geoJson2, ellipsoid) which computes the shortest distance between two GeoJSON objects. Both arguments are GeoJSON geometries (built with geoPoint(), geoPolygon(), … or a document attribute), using the longitude-first coordinate convention. The optional ellipsoid ("sphere" or "wgs84") selects the reference model.

Example AQL usage:

GEO_DISTANCE(doc.geo, GEO_POINT(2.3522, 48.8566))
GEO_DISTANCE(doc.geo, @target, "wgs84")
Parameters
$geo1 : array<string|int, mixed>|string

First GeoJSON geometry (AQL expression or [longitude, latitude]).

$geo2 : array<string|int, mixed>|string

Second GeoJSON geometry (AQL expression or [longitude, latitude]).

$ellipsoid : string|null = null

Optional reference ellipsoid: "sphere" (default) or "wgs84".

Tags
example
use function oihana\arango\db\functions\geo\geoDistance;
use function oihana\arango\db\functions\geo\geoPoint;

$expr = geoDistance( 'doc.geo' , geoPoint( 48.8566 , 2.3522 ) );
// Produces: 'GEO_DISTANCE(doc.geo,GEO_POINT(2.3522,48.8566))'

$expr = geoDistance( 'doc.geo' , '@target' , 'wgs84' );
// Produces: 'GEO_DISTANCE(doc.geo,@target,"wgs84")'
see
https://docs.arangodb.com/stable/aql/functions/geo/#geo_distance
distance()

For the latitude-first scalar equivalent.

since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results