The set operators for box types are union (+
) and intersection (*
). In the case of union, the operands must have exactly the same dimensions, otherwise an error is raised. Furthermore, if the operands do not overlap on all the dimensions and error is raised, since in this would result in a box with disjoint values, which cannot be represented. The operator computes the union on all dimensions that are present in both arguments. In the case of intersection, the operands must have at least one common dimension, otherwise an error is raised. The operator computes the intersection on all dimensions that are present in both arguments.
Union of the bounding boxes
box + box → box
SELECT tbox 'TBOXINT XT([1,3),[2001-01-01,2001-01-03])' + tbox 'TBOXINT XT([2,4),[2001-01-02,2001-01-04])'; -- TBOXINT XT([1,4),[2001-01-01,2001-01-04]) SELECT stbox 'STBOX ZT(((1,1,1),(2,2,2)),[2001-01-01,2001-01-02])' + stbox 'STBOX XT(((2,2),(3,3))),[2001-01-01,2001-01-03]'; -- ERROR: The arguments must be of the same dimensionality SELECT tbox 'TBOXFLOAT XT((1,3),[2001-01-01,2001-01-02])' + tbox 'TBOXFLOAT XT((3,4),[2001-01-03,2001-01-04])'; -- ERROR: Result of box union would not be contiguous
Intersection of the bounding boxes
box * box → box
SELECT tbox 'TBOXINT XT([1,3),[2001-01-01,2001-01-03])' * tbox 'TBOX T([2001-01-02,2001-01-04))'; -- TBOX T([2001-01-02,2001-01-03)) SELECT stbox 'STBOX ZT(((1,1,1),(3,3,3)),[2001-01-01,2001-01-02])' * stbox 'STBOX X((2,2),(4,4))'; -- STBOX X((2,2),(3,3))