near.php
Table of Contents
Functions
- near() : string
- Return the nearest documents of a collection to a coordinate (legacy).
Functions
near()
Return the nearest documents of a collection to a coordinate (legacy).
near(string $collection, float|int|string $latitude, float|int|string $longitude[, int|string|null $limit = null ][, string|null $distanceName = null ]) : string
This helper wraps the ArangoDB AQL function NEAR(collection, latitude, longitude, limit, distanceName) which returns up to limit documents
ordered by ascending distance from the given point. The collection must have
a geo index. The coordinate is given in the latitude-first order.
This is a legacy function; prefer a geo index combined with
SORT DISTANCE(doc.lat, doc.lng, @lat, @lng) ASC LIMIT n for new code.
Example AQL usage:
FOR place IN NEAR(places, 48.8566, 2.3522, 10, "distance") RETURN place
Parameters
- $collection : string
-
The target collection name (AQL identifier).
- $latitude : float|int|string
-
Latitude of the reference point (or AQL expression).
- $longitude : float|int|string
-
Longitude of the reference point (or AQL expression).
- $limit : int|string|null = null
-
Optional maximum number of documents to return.
- $distanceName : string|null = null
-
Optional attribute name to store the computed distance (requires
$limit).
Tags
Return values
string —The formatted AQL expression.