There are five topological operators: overlaps (&&), contains (@>), contained (<@), same (~=), and adjacent (-|-). The operators verify the topological relationship between the bounding boxes taking into account the value and/or the time dimension for as many dimensions that are present on both arguments.
A numspan or a tstzspan is an operand of these operators against a tbox, in either order: the operator answers on the box of the span, which has the value dimension alone or the time dimension alone.
SELECT intspan '[1,5)' && tbox 'TBOXINT XT([3,8),[2001-01-01,2001-01-02])'; -- true SELECT tstzspan '[2001-01-01,2001-01-03]' @> tbox 'TBOXINT XT([3,8),[2001-01-01,2001-01-02])'; -- true
Do the bounding boxes overlap?
box && box → boolean
SELECT tbox 'TBOXFLOAT XT((1,3),[2001-01-01,2001-01-03])' && tbox 'TBOXFLOAT XT((2,4),[2001-01-02,2001-01-04])'; -- true SELECT stbox 'STBOX XT(((1,1),(2,2)),[2001-01-01,2001-01-02])' && stbox 'STBOX T([2001-01-02,2001-01-02])'; -- true
Does the first bounding box contain the second one?
box @> box → boolean
SELECT tbox 'TBOXFLOAT XT((1,4),[2001-01-01,2001-01-04])' @> tbox 'TBOXFLOAT XT((2,3),[2001-01-01,2001-01-02])'; -- true SELECT stbox 'STBOX Z((1,1,1),(3,3,3))' @> stbox 'STBOX XT(((1,1),(2,2)),[2001-01-01,2001-01-02])'; -- true
Is the first bounding box contained in the second one?
box <@ box → boolean
SELECT tbox 'TBOXFLOAT XT((1,2),[2001-01-01,2001-01-02])' <@ tbox 'TBOXFLOAT XT((1,2), [2001-01-01,2001-01-02])'; -- true SELECT stbox 'STBOX XT(((1,1),(2,2)),[2001-01-01,2001-01-02])' <@ stbox 'STBOX ZT(((1,1,1),(2,2,2)),[2001-01-01,2001-01-02])'; -- true
Are the bounding boxes equal in their common dimensions?
box ~= box → boolean
SELECT tbox 'TBOXFLOAT XT((1,2), [2001-01-01,2001-01-02])' ~= tbox 'TBOXFLOAT T([2001-01-01,2001-01-02])'; -- true SELECT stbox 'STBOX XT(((1,1),(3,3)), [2001-01-01,2001-01-03])' ~= stbox 'STBOX Z((1,1,1),(3,3,3))'; -- true
Are the bounding boxes adjacent?
box -|- box → boolean
Two boxes are adjacent if their extents meet in every dimension the boxes share and touch at a single value in at least one of them. A dimension in which the boxes are apart separates them whatever the remaining dimensions do.
SELECT tbox 'TBOXINT XT([1,2),[2001-01-01,2001-01-02])' -|- tbox 'TBOXINT XT([2,3), [2001-01-02,2001-01-03])'; -- true SELECT tbox 'TBOXFLOAT XT((1,2), [2001-01-01,2001-01-02])' -|- tbox 'TBOX T([2001-01-02,2001-01-03])'; -- true SELECT stbox 'STBOX XT(((1,1),(3,3)), [2001-01-01,2001-01-03])' -|- stbox 'STBOX XT(((2,2),(4,4)),[2001-01-03,2001-01-04])'; -- true
The position operators consider the relative position of the bounding boxes. The operators <<, >>, &<, and &> consider the X value for the tbox type and the X coordinates for the stbox type, the operators <<|, |>>, &<|, and |&> consider the Y coordinates for the stbox type, the operators <</, />>, &</, and /&> consider the Z coordinates for the stbox type, and the operators <<#, #>>, #&<, and #&> consider the time dimension for the tbox and stbox types. The operators raise an error if both boxes do not have the required dimension.
A numspan is an operand of the operators on the value dimension against a tbox, and a tstzspan of those on the time dimension, in either order, answered on the box of the span.
SELECT intspan '[1,5)' &< tbox 'TBOXINT XT([3,8),[2001-01-01,2001-01-02])'; -- true SELECT tstzspan '[2001-01-05,2001-01-06]' #>> tbox 'TBOXINT XT([3,8),[2001-01-01,2001-01-02])'; -- true
The operators for the numeric dimension of the tbox type are given next.
Are the X/Y/Z/T values of the first bounding box strictly less than those of the second one?
tbox {<<, <<#} tbox → boolean
stbox {<<, <<|, <</, <<#} stbox → boolean
SELECT tbox 'TBOXFLOAT XT((1,2),[2001-01-01,2001-01-02])' << tbox 'TBOXFLOAT XT((3,4),[2001-01-03,2001-01-04])'; -- true SELECT tbox 'TBOXFLOAT XT((1,2),[2001-01-01,2001-01-02])' << tbox 'TBOXFLOAT T([2001-01-03,2001-01-04])'; -- ERROR: The box must have value dimension SELECT stbox 'STBOX Z((1,1,1),(2,2,2))' <<| stbox 'STBOX Z((3,3,3),(4,4,4))'; -- true SELECT stbox 'STBOX Z((1,1,1),(2,2,2))' <</ stbox 'STBOX Z((3,3,3),(4,4,4))'; -- true SELECT tbox 'TBOXFLOAT XT((1,2), [2001-01-01,2001-01-02])' <<# tbox 'TBOXFLOAT XT((3,4),[2001-01-03,2001-01-04])'; -- true
Are the X/Y/Z/T values of the first bounding box strictly greater than those of the second one?
tbox {>>, #>>} tbox → boolean
stbox {>>, |>>, />>, #>>} stbox → boolean
SELECT tbox 'TBOXFLOAT XT((3,4),[2001-01-03,2001-01-04])' >> tbox 'TBOXFLOAT XT((1,2),[2001-01-01,2001-01-02])'; -- true SELECT stbox 'STBOX Z((3,3,3),(4,4,4))' |>> stbox 'STBOX Z((1,1,1),(2,2,2))'; -- true SELECT stbox 'STBOX Z((3,3,3),(4,4,4))' />> stbox 'STBOX Z((1,1,1),(2,2,2))'; -- true SELECT stbox 'STBOX XT(((3,3),(4,4)),[2001-01-03,2001-01-04])' #>> stbox 'STBOX XT(((1,1),(2,2)),[2001-01-01,2001-01-02])'; -- true
Are the X/Y/Z/T values of the first bounding box not greater than those of the second one?
tbox {&<, &<#} box → boolean
stbox {&<, &<|, &</, &<#} stbox → boolean
SELECT tbox 'TBOXFLOAT XT((1,4),[2001-01-01,2001-01-04])' &< tbox 'TBOXFLOAT XT((3,4),[2001-01-03,2001-01-04])'; -- true SELECT stbox 'STBOX Z((1,1,1),(4,4,4))' &<| stbox 'STBOX Z((3,3,3),(4,4,4))'; -- true SELECT stbox 'STBOX Z((1,1,1),(4,4,4))' &</ stbox 'STBOX Z((3,3,3),(4,4,4))'; -- true SELECT tbox 'TBOXFLOAT XT((1,4), [2001-01-01,2001-01-04])' &<# tbox 'TBOXFLOAT XT((3,4),[2001-01-03,2001-01-04])'; -- true
Are the X/Y/Z/T values of the first bounding box not less than those of the second one?
tbox {&>, #&>} tbox → boolean
stbox {&>, |&>, /&>, #&>} stbox} → boolean
SELECT tbox 'TBOXFLOAT XT((1,2),[2001-01-01,2001-01-02])' &> tbox 'TBOXFLOAT XT((1,4),[2001-01-01,2001-01-04])'; -- true SELECT stbox 'STBOX Z((3,3,3),(4,4,4))' |&> stbox 'STBOX Z((1,1,1),(2,2,2))'; -- false SELECT stbox 'STBOX Z((3,3,3),(4,4,4))' /&> stbox 'STBOX Z((1,1,1),(2,2,2))'; -- true SELECT stbox 'STBOX XT(((1,1),(2,2)),[2001-01-01,2001-01-02])' #&> stbox 'STBOX XT(((1,1),(4,4)),[2001-01-01,2001-01-04])'; -- true