Skip to content

Commit 85de2a3

Browse files
Simran-Bnerpaula
andauthored
DOC-772 | GEO_POINT() accepts elevation but z coordinate is ignored in geo functions / validation of points in GEO_MULTIPOINT() and GEO_(MULTI_)LINESTRING (#733)
* GEO_POINT() accepts elevation but z coordinate is ignored in geo functions * Add more details * Add introduced in 3.11 * Add release notes about point validation in AQL GeoJSON functions * Fix order --------- Co-authored-by: Paula Mihu <97217318+nerpaula@users.noreply.github.com>
1 parent 9cc6d81 commit 85de2a3

File tree

6 files changed

+340
-194
lines changed

6 files changed

+340
-194
lines changed

site/content/3.12/aql/functions/geo.md

Lines changed: 116 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ called `location` (with coordinates in `[longitude, latitude]` order):
7171
GeoJSON uses a geographic coordinate reference system,
7272
World Geodetic System 1984 (WGS 84), and units of decimal degrees.
7373

74-
Internally ArangoDB maps all coordinate pairs onto a unit sphere. Distances are
75-
projected onto a sphere with the Earth's *Volumetric mean radius* of *6371
76-
km*. ArangoDB implements a useful subset of the GeoJSON format
74+
Internally, ArangoDB maps all coordinate pairs onto a unit sphere. Distances are
75+
projected onto a sphere with the Earth's *Volumetric mean radius* of
76+
*6371 km*. ArangoDB implements a useful subset of the GeoJSON format
7777
[(RFC 7946)](https://tools.ietf.org/html/rfc7946).
7878
Feature Objects and the GeometryCollection type are not supported.
7979
Supported geometry object types are:
@@ -98,6 +98,18 @@ a longitude and a latitude:
9898
}
9999
```
100100

101+
GeoJSON Points can optionally have a third coordinate for the elevation, but
102+
ArangoDB doesn't use it in calculations:
103+
104+
```json
105+
{
106+
"location": {
107+
"type": "Point",
108+
"coordinates": [ 100.0, 0.0, 43.0 ]
109+
}
110+
}
111+
```
112+
101113
#### MultiPoint
102114

103115
A [GeoJSON MultiPoint](https://tools.ietf.org/html/rfc7946#section-3.1.7) is
@@ -425,11 +437,11 @@ fully contains `geoJsonB` (every point in B is also in A). The object `geoJsonA`
425437
has to be of type _Polygon_ or _MultiPolygon_. For other types containment is
426438
not well-defined because of numerical stability problems.
427439

428-
- **geoJsonA** (object): first GeoJSON object
429-
- **geoJsonB** (object): second GeoJSON object, or a coordinate array in
430-
`[longitude, latitude]` order
440+
- **geoJsonA** (object): First GeoJSON object.
441+
- **geoJsonB** (object): Second GeoJSON object, or a coordinate array in
442+
`[longitude, latitude]` order.
431443
- returns **bool** (bool): `true` if every point in B is also contained in A,
432-
otherwise `false`
444+
otherwise `false`.
433445

434446
{{< info >}}
435447
ArangoDB follows and exposes the same behavior as the underlying
@@ -468,14 +480,14 @@ Return the distance between two GeoJSON objects in meters, measured from the
468480
**centroid** of each shape. For a list of supported types see the
469481
[geo index page](#geojson).
470482

471-
- **geoJsonA** (object): first GeoJSON object, or a coordinate array in
472-
`[longitude, latitude]` order
473-
- **geoJsonB** (object): second GeoJSON object, or a coordinate array in
474-
`[longitude, latitude]` order
475-
- **ellipsoid** (string, *optional*): reference ellipsoid to use.
483+
- **geoJsonA** (object): First GeoJSON object, or a coordinate array in
484+
`[longitude, latitude]` order.
485+
- **geoJsonB** (object): Second GeoJSON object, or a coordinate array in
486+
`[longitude, latitude]` order.
487+
- **ellipsoid** (string, *optional*): Reference ellipsoid to use.
476488
Supported are `"sphere"` (default) and `"wgs84"`.
477-
- returns **distance** (number): the distance between the centroid points of
478-
the two objects on the reference ellipsoid in **meters**
489+
- returns **distance** (number): The distance between the centroid points of
490+
the two objects on the reference ellipsoid in **meters**.
479491

480492
```aql
481493
LET polygon = {
@@ -522,10 +534,10 @@ functions.
522534
Return the area for a [Polygon](#polygon) or [MultiPolygon](#multipolygon)
523535
on a sphere with the average Earth radius, or an ellipsoid.
524536

525-
- **geoJson** (object): a GeoJSON object
526-
- **ellipsoid** (string, *optional*): reference ellipsoid to use.
537+
- **geoJson** (object): A GeoJSON object.
538+
- **ellipsoid** (string, *optional*): Reference ellipsoid to use.
527539
Supported are `"sphere"` (default) and `"wgs84"`.
528-
- returns **area** (number): the area of the polygon in **square meters**
540+
- returns **area** (number): The area of the polygon in **square meters**.
529541

530542
```aql
531543
LET polygon = {
@@ -541,8 +553,8 @@ RETURN GEO_AREA(polygon, "wgs84")
541553

542554
Checks whether two [GeoJSON objects](#geojson) are equal or not.
543555

544-
- **geoJsonA** (object): first GeoJSON object.
545-
- **geoJsonB** (object): second GeoJSON object.
556+
- **geoJsonA** (object): First GeoJSON object.
557+
- **geoJsonB** (object): Second GeoJSON object.
546558
- returns **bool** (bool): `true` if they are equal, otherwise `false`.
547559

548560
```aql
@@ -572,10 +584,10 @@ RETURN GEO_EQUALS(polygonA, polygonB) // false
572584
Checks whether the [GeoJSON object](#geojson) `geoJsonA`
573585
intersects with `geoJsonB` (i.e. at least one point in B is also in A or vice-versa).
574586

575-
- **geoJsonA** (object): first GeoJSON object
576-
- **geoJsonB** (object): second GeoJSON object, or a coordinate array in
577-
`[longitude, latitude]` order
578-
- returns **bool** (bool): true if B intersects A, false otherwise
587+
- **geoJsonA** (object): First GeoJSON object.
588+
- **geoJsonB** (object): Second GeoJSON object, or a coordinate array in
589+
`[longitude, latitude]` order.
590+
- returns **bool** (bool): `true` if B intersects A, `false` otherwise.
579591

580592
You can optimize queries that contain a `FILTER` expression of the following
581593
form with an S2-based [geospatial index](../../index-and-search/indexing/working-with-indexes/geo-spatial-indexes.md):
@@ -604,19 +616,19 @@ Checks whether the distance between two [GeoJSON objects](#geojson)
604616
lies within a given interval. The distance is measured from the **centroid** of
605617
each shape.
606618

607-
- **geoJsonA** (object\|array): first GeoJSON object, or a coordinate array
608-
in `[longitude, latitude]` order
609-
- **geoJsonB** (object\|array): second GeoJSON object, or a coordinate array
610-
in `[longitude, latitude]` order
611-
- **low** (number): minimum value of the desired range
612-
- **high** (number): maximum value of the desired range
613-
- **includeLow** (bool, optional): whether the minimum value shall be included
619+
- **geoJsonA** (object\|array): First GeoJSON object, or a coordinate array
620+
in `[longitude, latitude]` order.
621+
- **geoJsonB** (object\|array): Second GeoJSON object, or a coordinate array
622+
in `[longitude, latitude]` order.
623+
- **low** (number): Minimum value of the desired range.
624+
- **high** (number): Maximum value of the desired range.
625+
- **includeLow** (bool, optional): Whether the minimum value shall be included
614626
in the range (left-closed interval) or not (left-open interval). The default
615-
value is `true`
616-
- **includeHigh** (bool): whether the maximum value shall be included in the
627+
value is `true`.
628+
- **includeHigh** (bool): Whether the maximum value shall be included in the
617629
range (right-closed interval) or not (right-open interval). The default value
618-
is `true`
619-
- returns **bool** (bool): whether the evaluated distance lies within the range
630+
is `true`.
631+
- returns **bool** (bool): Whether the evaluated distance lies within the range.
620632

621633
### IS_IN_POLYGON()
622634

@@ -630,10 +642,10 @@ favor of the new [`GEO_CONTAINS()` AQL function](#geo_contains), which works wit
630642

631643
`IS_IN_POLYGON(polygon, latitude, longitude) → bool`
632644

633-
- **polygon** (array): an array of arrays with 2 elements each, representing the
634-
points of the polygon in the format `[latitude, longitude]`
635-
- **latitude** (number): the latitude of the point to search
636-
- **longitude** (number): the longitude of the point to search
645+
- **polygon** (array): An array of arrays with two elements each, representing the
646+
points of the polygon in the format `[latitude, longitude]`.
647+
- **latitude** (number): The latitude of the point to search for.
648+
- **longitude** (number): The longitude of the point to search for.
637649
- returns **bool** (bool): `true` if the point (`[latitude, longitude]`) is
638650
inside the `polygon` or `false` if it's not. The result is undefined (can be
639651
`true` or `false`) if the specified point is exactly on a boundary of the
@@ -648,17 +660,17 @@ IS_IN_POLYGON( [ [ 0, 0 ], [ 0, 10 ], [ 10, 10 ], [ 10, 0 ] ], 4, 7 )
648660

649661
`IS_IN_POLYGON(polygon, coord, useLonLat) → bool`
650662

651-
The 2nd parameter can alternatively be specified as an array with two values.
663+
The second parameter can alternatively be specified as an array with two values.
652664

653665
By default, each array element in `polygon` is expected to be in the format
654-
`[latitude, longitude]`. This can be changed by setting the 3rd parameter to `true` to
666+
`[latitude, longitude]`. This can be changed by setting the third parameter to `true` to
655667
interpret the points as `[longitude, latitude]`. `coord` is then also interpreted in
656668
the same way.
657669

658-
- **polygon** (array): an array of arrays with 2 elements each, representing the
659-
points of the polygon
660-
- **coord** (array): the point to search as a numeric array with two elements
661-
- **useLonLat** (bool, *optional*): if set to `true`, the coordinates in
670+
- **polygon** (array): An array of arrays with 2 elements each, representing the
671+
points of the polygon.
672+
- **coord** (array): The point to search as a numeric array with two elements.
673+
- **useLonLat** (bool, *optional*): If set to `true`, the coordinates in
662674
`polygon` and the coordinate pair `coord` are interpreted as
663675
`[longitude, latitude]` (like in GeoJSON). The default is `false` and the
664676
format `[latitude, longitude]` is expected.
@@ -687,8 +699,9 @@ will help you to make all your AQL queries shorter and easier to read.
687699
Construct a GeoJSON LineString.
688700
Needs at least two longitude/latitude pairs.
689701

690-
- **points** (array): an array of `[longitude, latitude]` pairs
691-
- returns **geoJson** (object): a valid GeoJSON LineString
702+
- **points** (array): An array of `[longitude, latitude]` pairs, or optionally
703+
`[longitude, latitude, elevation]`.
704+
- returns **geoJson** (object): A valid GeoJSON LineString.
692705

693706
```aql
694707
---
@@ -707,8 +720,9 @@ RETURN GEO_LINESTRING([
707720
Construct a GeoJSON MultiLineString.
708721
Needs at least two elements consisting valid LineStrings coordinate arrays.
709722

710-
- **points** (array): array of LineStrings
711-
- returns **geoJson** (object): a valid GeoJSON MultiLineString
723+
- **points** (array): An array of arrays of `[longitude, latitude]` pairs,
724+
or optionally `[longitude, latitude, elevation]`.
725+
- returns **geoJson** (object): A valid GeoJSON MultiLineString.
712726

713727
```aql
714728
---
@@ -727,8 +741,9 @@ RETURN GEO_MULTILINESTRING([
727741

728742
Construct a GeoJSON LineString. Needs at least two longitude/latitude pairs.
729743

730-
- **points** (array): an array of `[longitude, latitude]` pairs
731-
- returns **geoJson** (object): a valid GeoJSON Point
744+
- **points** (array): An array of `[longitude, latitude]` pairs, or optionally
745+
`[longitude, latitude, elevation]`.
746+
- returns **geoJson** (object): A valid GeoJSON Point.
732747

733748
```aql
734749
---
@@ -742,13 +757,15 @@ RETURN GEO_MULTIPOINT([
742757

743758
### GEO_POINT()
744759

745-
`GEO_POINT(longitude, latitude) → geoJson`
760+
`GEO_POINT(longitude, latitude, elevation) → geoJson`
746761

747762
Construct a valid GeoJSON Point.
748763

749-
- **longitude** (number): the longitude portion of the point
750-
- **latitude** (number): the latitude portion of the point
751-
- returns **geoJson** (object): a GeoJSON Point
764+
- **longitude** (number): The longitude portion of the point.
765+
- **latitude** (number): The latitude portion of the point.
766+
- **elevation** (number, *optional*): The elevation portion of the point
767+
(introduced in v3.11.14-2 and v3.12.6).
768+
- returns **geoJson** (object): A valid GeoJSON Point.
752769

753770
```aql
754771
---
@@ -769,8 +786,9 @@ any subsequent linear ring will be interpreted as holes.
769786

770787
For details about the rules, see [GeoJSON polygons](#polygon).
771788

772-
- **points** (array): an array of (arrays of) `[longitude, latitude]` pairs
773-
- returns **geoJson** (object\|null): a valid GeoJSON Polygon
789+
- **points** (array): An array of (arrays of) `[longitude, latitude]` pairs,
790+
or optionally `[longitude, latitude, elevation]`.
791+
- returns **geoJson** (object\|null): A valid GeoJSON Polygon.
774792

775793
A validation step is performed using the S2 geometry library. If the
776794
validation is not successful, an AQL warning is issued and `null` is
@@ -809,8 +827,9 @@ Construct a GeoJSON MultiPolygon. Needs at least two Polygons inside.
809827
See [`GEO_POLYGON()`](#geo_polygon) and [GeoJSON MultiPolygon](#multipolygon)
810828
for the rules of Polygon and MultiPolygon construction.
811829

812-
- **polygons** (array): an array of arrays of arrays of `[longitude, latitude]` pairs
813-
- returns **geoJson** (object\|null): a valid GeoJSON MultiPolygon
830+
- **polygons** (array): An array of arrays of arrays of `[longitude, latitude]`
831+
pairs, or optionally `[longitude, latitude, elevation]`.
832+
- returns **geoJson** (object\|null): A valid GeoJSON MultiPolygon.
814833

815834
A validation step is performed using the S2 geometry library, if the
816835
validation is not successful, an AQL warning is issued and `null` is
@@ -860,31 +879,31 @@ FOR doc IN coll
860879
RETURN doc
861880
```
862881
Assuming there exists a geo-type index on `latitude` and `longitude`, the
863-
optimizer will recognize it and accelerate the query.
882+
optimizer recognizes it and accelerates the query.
864883
{{< /warning >}}
865884

866885
`NEAR(coll, latitude, longitude, limit, distanceName) → docArray`
867886

868-
Return at most *limit* documents from collection *coll* that are near
869-
*latitude* and *longitude*. The result contains at most *limit* documents,
887+
Return at most `limit` documents from collection `coll` that are near
888+
`latitude` and `longitude`. The result contains at most `limit` documents,
870889
returned sorted by distance, with closest distances being returned first.
871890
Optionally, the distances in meters between the specified coordinate pair
872-
(*latitude* and *longitude*) and the stored coordinate pairs can be returned as
891+
(`latitude` and `longitude`) and the stored coordinate pairs can be returned as
873892
well. To make use of that, the desired attribute name for the distance result
874-
has to be specified in the *distanceName* argument. The result documents will
875-
contain the distance value in an attribute of that name.
876-
877-
- **coll** (collection): a collection
878-
- **latitude** (number): the latitude of the point to search
879-
- **longitude** (number): the longitude of the point to search
880-
- **limit** (number, *optional*): cap the result to at most this number of
881-
documents. The default is 100. If more documents than *limit* are found,
882-
it is undefined which ones will be returned.
883-
- **distanceName** (string, *optional*): include the distance (in meters)
893+
has to be specified in the `distanceName` argument. The result documents
894+
contains the distance value in an attribute of that name.
895+
896+
- **coll** (collection): A collection.
897+
- **latitude** (number): The latitude of the point to search for.
898+
- **longitude** (number): The longitude of the point to search for.
899+
- **limit** (number, *optional*): Cap the result to at most this number of
900+
documents. The default is `100`. If more documents than `limit` are found,
901+
it is undefined which ones are returned.
902+
- **distanceName** (string, *optional*): Include the distance (in meters)
884903
between the reference point and the stored point in the result, using the
885-
attribute name *distanceName*
886-
- returns **docArray** (array): an array of documents, sorted by distance
887-
(shortest distance first)
904+
attribute name `distanceName`.
905+
- returns **docArray** (array): An array of documents, sorted by distance
906+
(shortest distance first).
888907

889908
### WITHIN()
890909

@@ -901,29 +920,29 @@ FOR doc IN coll
901920
```
902921

903922
Assuming there exists a geo-type index on `latitude` and `longitude`, the
904-
optimizer will recognize it and accelerate the query.
923+
optimizer recognizes it and accelerates the query.
905924
{{< /warning >}}
906925

907926
`WITHIN(coll, latitude, longitude, radius, distanceName) → docArray`
908927

909-
Return all documents from collection *coll* that are within a radius of *radius*
910-
around the specified coordinate pair (*latitude* and *longitude*). The documents
928+
Return all documents from collection `coll` that are within a radius of `radius`
929+
around the specified coordinate pair (`latitude` and `longitude`). The documents
911930
returned are sorted by distance to the reference point, with the closest
912931
distances being returned first. Optionally, the distance (in meters) between the
913932
reference point and the stored point can be returned as well. To make
914933
use of that, an attribute name for the distance result has to be specified in
915-
the *distanceName* argument. The result documents will contain the distance
934+
the `distanceName` argument. The result documents contains the distance
916935
value in an attribute of that name.
917936

918-
- **coll** (collection): a collection
919-
- **latitude** (number): the latitude of the point to search
920-
- **longitude** (number): the longitude of the point to search
921-
- **radius** (number): radius in meters
922-
- **distanceName** (string, *optional*): include the distance (in meters)
937+
- **coll** (collection): A collection.
938+
- **latitude** (number): The latitude of the point to search for.
939+
- **longitude** (number): The longitude of the point to search for.
940+
- **radius** (number): Radius in meters.
941+
- **distanceName** (string, *optional*): Include the distance (in meters)
923942
between the reference point and stored point in the result, using the
924-
attribute name *distanceName*
925-
- returns **docArray** (array): an array of documents, sorted by distance
926-
(shortest distance first)
943+
attribute name `distanceName`.
944+
- returns **docArray** (array): An array of documents, sorted by distance
945+
(shortest distance first).
927946

928947
### WITHIN_RECTANGLE()
929948

@@ -947,18 +966,18 @@ FOR doc IN coll
947966
```
948967

949968
Assuming there exists a geo-type index on `latitude` and `longitude`, the
950-
optimizer will recognize it and accelerate the query.
969+
optimizer recognizes it and accelerates the query.
951970
{{< /warning >}}
952971

953972
`WITHIN_RECTANGLE(coll, latitude1, longitude1, latitude2, longitude2) → docArray`
954973

955-
Return all documents from collection *coll* that are positioned inside the
956-
bounding rectangle with the points (*latitude1*, *longitude1*) and (*latitude2*,
957-
*longitude2*). There is no guaranteed order in which the documents are returned.
974+
Return all documents from collection `coll` that are positioned inside the
975+
bounding rectangle with the points (`latitude1`, `longitude1`) and (`latitude2`,
976+
`longitude2`). There is no guaranteed order in which the documents are returned.
958977

959-
- **coll** (collection): a collection
960-
- **latitude1** (number): the latitude of the bottom-left point to search
961-
- **longitude1** (number): the longitude of the bottom-left point to search
962-
- **latitude2** (number): the latitude of the top-right point to search
963-
- **longitude2** (number): the longitude of the top-right point to search
964-
- returns **docArray** (array): an array of documents, in random order
978+
- **coll** (collection): A collection.
979+
- **latitude1** (number): The latitude of the bottom-left point to search for.
980+
- **longitude1** (number): The longitude of the bottom-left point to search for.
981+
- **latitude2** (number): The latitude of the top-right point to search for.
982+
- **longitude2** (number): The longitude of the top-right point to search for.
983+
- returns **docArray** (array): An array of documents, in random order.

0 commit comments

Comments
 (0)