แก้ไข

แชร์ผ่าน


ST_WITHIN (NoSQL query)

APPLIES TO: NoSQL

Returns a boolean expression indicating whether the GeoJSON object (GeoJSON Point, Polygon, or LineString expression) specified in the first argument is within the GeoJSON object in the second argument.

Syntax

ST_WITHIN(<spatial_expr_1>, <spatial_expr_2>)  

Arguments

Description
spatial_expr_1 Any valid GeoJSON Point, Polygon, MultiPolygon or LineString expression.
spatial_expr_2 Any valid GeoJSON Point, Polygon, MultiPolygon or LineString expression.

Return types

Returns a boolean value.

Examples

The following example shows how to find if a Point is within a Polygon.

SELECT VALUE {
    isHeadquartersWithinCampus: ST_WITHIN({
        "type": "Point",
        "coordinates": [
            -122.12824857332558,
            47.6395516675712
        ]
    }, {            
        "type": "Polygon",
        "coordinates": [ [
            [
              -122.13236581015025,
              47.64606476313813
            ],
            [
              -122.13221982500913,
              47.633757091363975
            ],
            [
              -122.11840598103835,
              47.641749416109235
            ],
            [
              -122.12061400629656,
              47.64589264786028
            ],
            [
              -122.13236581015025,
              47.64606476313813
            ]
        ] ]
    })
}
[
  {
    "isHeadquartersWithinCampus": true
  }
]

Remarks

  • This function benefits from a geospatial index except in queries with aggregates.
  • The GeoJSON specification requires that points within a Polygon be specified in counter-clockwise order. A Polygon specified in clockwise order represents the inverse of the region within it.