Contained by operator

更新时间:
复制 MD 格式

INCLUDED operators check whether the bounding box of the left operand is contained within the bounding box of the right operand in a specified dimension. Bounding boxes are generated by the ST_MakeBox function. These operators are the inverse of INCLUDE operators: the left operand is the contained object, not the container.

Syntax

{geometry, trajectory, boxndf} /<@/ {geometry, trajectory, boxndf}
{trajectory, boxndf} #<@# {trajectory, boxndf}
{geometry, trajectory, boxndf} <@ {geometry, trajectory, boxndf}
{geometry, trajectory, boxndf} </@ {geometry, trajectory, boxndf}
{trajectory, boxndf} <#@ {trajectory, boxndf}
{trajectory, boxndf} </#@ {trajectory, boxndf}

Parameters

Parameter Description
Left operand The object whose bounding box you want to compare.
Right operand The object whose bounding box you want to compare.

Operators

Each operator checks containment in a specific set of dimensions.

Operator Dimensions Supported types
/<@/ z geometry, trajectory, boxndf
#<@# t trajectory, boxndf
<@ x and y geometry, trajectory, boxndf
</@ x, y, and z geometry, trajectory, boxndf
<#@ x, y, and t trajectory, boxndf
</#@ x, y, z, and t trajectory, boxndf

Example

The following query tests all six operators against two bounding boxes. Box a spans x: 0–10, y: 0–10, z: 0–10, t: 2010–2012. Box b spans x: 6–8, y: 6–8, z: 3–5, t: 2010–2013.

WITH box AS(
    SELECT ST_MakeBox3dt(0,0,0, '2010-01-01 00:00:00',10,10,10, '2012-01-01 00:00:00') a,
           ST_MakeBox3dt(6,6,3,'2010-01-01 00:00:00',8,8,5,'2013-01-01 00:00:00') b
)
SELECT b /<@/ a AS OpZ, b #<@# a AS OpT, b <@ a AS Op2D, b </@ a AS Op3D, b <#@ a AS Op2DT, b </#@ a AS Op3DT from box;

Result:

 opz | opt | op2d | op3d | op2dt | op3dt
-----+-----+------+------+-------+-------
 t   | f   | t    | t    | f     | f

opz=t: b's z range [3, 5] is within a's z range [0, 10].

opt=f: b's t range extends to 2013, outside a's t range ending in 2012.

op2d=t: b's x range [6, 8] and y range [6, 8] are within a's x and y ranges [0, 10].

op3d=t: b's x, y, and z ranges are all within a's corresponding ranges.

op2dt=f: b's t range extends beyond a's, so the x-y-t containment check fails.

op3dt=f: b's t range extends beyond a's, so the x-y-z-t containment check fails.

What's next

  • ST_MakeBox: Generate a bounding box for an object over a specified time range.

  • INCLUDE operators: Check whether the left operand's bounding box contains the right operand's bounding box.