Oihana PHP Arango

geoInRange.php

Table of Contents

Functions

geoInRange()  : string
Check whether the distance between two geometries falls within a range.

Functions

geoInRange()

Check whether the distance between two geometries falls within a range.

geoInRange(array<string|int, mixed>|string $geo1, array<string|int, mixed>|string $geo2, float|int|string $low, float|int|string $high[, bool|null $includeLow = null ][, bool|null $includeHigh = null ]) : string

This helper wraps the ArangoDB AQL function GEO_IN_RANGE(geoJson1, geoJson2, low, high, includeLow, includeHigh) which returns true when the distance (in meters) between the two geometries lies between low and high. The boundary inclusion flags default to true on the ArangoDB side and are only emitted when explicitly provided. Both geometries use the GeoJSON longitude-first convention.

Example AQL usage:

GEO_IN_RANGE(doc.geo, @center, 1000, 5000)
GEO_IN_RANGE(doc.geo, @center, 1000, 5000, false, true)
Parameters
$geo1 : array<string|int, mixed>|string

First GeoJSON geometry (AQL expression or coordinates).

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

Second GeoJSON geometry (AQL expression or coordinates).

$low : float|int|string

Lower distance bound, in meters (or AQL expression).

$high : float|int|string

Upper distance bound, in meters (or AQL expression).

$includeLow : bool|null = null

Whether the lower bound is inclusive (ArangoDB default: true).

$includeHigh : bool|null = null

Whether the upper bound is inclusive (ArangoDB default: true).

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

$expr = geoInRange( 'doc.geo' , '@center' , 1000 , 5000 );
// Produces: 'GEO_IN_RANGE(doc.geo,@center,1000,5000)'

$expr = geoInRange( 'doc.geo' , '@center' , 1000 , 5000 , false , true );
// Produces: 'GEO_IN_RANGE(doc.geo,@center,1000,5000,false,true)'
see
https://docs.arangodb.com/stable/aql/functions/geo/#geo_in_range
since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results