Oihana PHP Arango

isInPolygon.php

Table of Contents

Functions

isInPolygon()  : string
Check whether a coordinate lies inside a polygon (legacy).

Functions

isInPolygon()

Check whether a coordinate lies inside a polygon (legacy).

isInPolygon(array<string|int, mixed>|string $polygon, float|int|string $latitude, float|int|string $longitude) : string

This helper wraps the ArangoDB AQL function IS_IN_POLYGON(polygon, latitude, longitude) which returns true when the point is inside the polygon. The polygon is a plain array of [latitude, longitude] pairs, and — unlike the GeoJSON functions — the point is given in the latitude-first order.

This is a legacy function kept for completeness; prefer geoContains() with proper GeoJSON geometries and a geo index for new code.

Example AQL usage:

IS_IN_POLYGON([ [48.8, 2.2], [48.9, 2.2], [48.9, 2.4] ], doc.geo.latitude, doc.geo.longitude)
Parameters
$polygon : array<string|int, mixed>|string

The polygon as an array of [latitude, longitude] pairs, or an AQL expression.

$latitude : float|int|string

Latitude of the point to test (or AQL expression).

$longitude : float|int|string

Longitude of the point to test (or AQL expression).

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

$expr = isInPolygon( '@area' , 'doc.geo.latitude' , 'doc.geo.longitude' );
// Produces: 'IS_IN_POLYGON(@area,doc.geo.latitude,doc.geo.longitude)'
see
https://docs.arangodb.com/stable/aql/functions/geo/#is_in_polygon
since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results