Oihana PHP Arango

within.php

Table of Contents

Functions

within()  : string
Return documents of a collection within a radius of a coordinate (legacy).

Functions

within()

Return documents of a collection within a radius of a coordinate (legacy).

within(string $collection, float|int|string $latitude, float|int|string $longitude, float|int|string $radius[, string|null $distanceName = null ]) : string

This helper wraps the ArangoDB AQL function WITHIN(collection, latitude, longitude, radius, distanceName) which returns all documents located within radius meters of the given point, ordered by ascending distance. 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 FILTER DISTANCE(doc.lat, doc.lng, @lat, @lng) <= @radius for new code.

Example AQL usage:

FOR place IN WITHIN(places, 48.8566, 2.3522, 5000, "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).

$radius : float|int|string

The search radius, in meters (or AQL expression).

$distanceName : string|null = null

Optional attribute name to store the computed distance.

Tags
example
use function oihana\arango\db\functions\geo\within;

$expr = within( 'places' , 48.8566 , 2.3522 , 5000 , 'distance' );
// Produces: 'WITHIN(places,48.8566,2.3522,5000,"distance")'
see
https://docs.arangodb.com/stable/aql/functions/geo/#within
since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results