INCLUDED operators

更新时间:
复制 MD 格式

The INCLUDED operators test whether the bounding box of the left operand is contained within the bounding box of the right operand across a specified set of dimensions. They are the inverse of the INCLUDE operators, which test containment in the opposite direction. Bounding boxes are computed using ST_MakeBox.

Syntax

boolean /<@/  ( {geometry | trajectory | boxndf}, {geometry | trajectory | boxndf} )
boolean #<@#  ( {trajectory | boxndf}, {trajectory | boxndf} )
boolean <@    ( {geometry | trajectory | boxndf}, {geometry | trajectory | boxndf} )
boolean </@   ( {geometry | trajectory | boxndf}, {geometry | trajectory | boxndf} )
boolean <#@   ( {trajectory | boxndf}, {trajectory | boxndf} )
boolean </#@  ( {trajectory | boxndf}, {trajectory | boxndf} )

Each operator returns true if the left operand's bounding box is fully contained within the right operand's bounding box in the specified dimensions, and false otherwise.

Operators

The operator symbol encodes the dimensions it compares. A # prefix or suffix indicates the time dimension (t); a / prefix or suffix indicates the z dimension.

OperatorDimensionsSupported types
/<@/zgeometry, trajectory, boxndf
#<@#ttrajectory, boxndf
<@x, ygeometry, trajectory, boxndf
</@x, y, zgeometry, trajectory, boxndf
<#@x, y, ttrajectory, boxndf
</#@x, y, z, ttrajectory, boxndf

Example

The following example creates two bounding boxes and runs all six INCLUDED operators against them.

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

Reading the results:

  • OpZ (/<@/) = t: box b (z: 3–5) is fully within box a (z: 0–10) in the z dimension.

  • OpT (#<@#) = f: box b ends at 2013, which exceeds box a's upper bound of 2012 in the t dimension.

  • Op2D (<@) = t: box b (x: 6–8, y: 6–8) is fully within box a (x: 0–10, y: 0–10).

  • Op3D (</@) = t: box b is within box a in all three spatial dimensions (x, y, z).

  • Op2DT (<#@) = f: box b exceeds box a in the t dimension, so the combined x, y, and t containment check fails.

  • Op3DT (</#@) = f: the t dimension overflow causes the full 4D containment check to fail.

What's next

  • INCLUDE operators — test whether the left operand's bounding box *contains* the right operand's bounding box (the inverse direction)

  • ST_MakeBox — query the bounding box of an object over a specified time range