Bounding Box Operations

Topological Operations

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.

  • 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 they share n dimensions and their intersection is at most of n-1 dimensions.

    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
    

Position Operations

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.

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,stbox} << {tbox,stbox} → boolean

    stbox <<| stbox → boolean

    stbox <</ stbox → boolean

    {tbox,stbox} <<# {tbox,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,stbox} >> {tbox,stbox} → boolean

    stbox |>> stbox → boolean

    stbox />> stbox → boolean

    {tbox,stbox} #>> {tbox,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,stbox} &< {tbox,stbox} → boolean

    stbox &<| stbox → boolean

    stbox &</ stbox → 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,stbox} &> {tbox,stbox} → boolean

    stbox |&> stbox → boolean

    stbox /&> stbox → boolean

    {tbox,stbox} #&> {tbox,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