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 'TBOX((1,2001-01-01),(3,2001-01-03))' + tbox 'TBOX((2,2001-01-02),(4,2001-01-04))'; -- "TBOX((1,2001-01-01),(4,2001-01-04))" SELECT stbox 'STBOX ZT((1,1,1,2001-01-01),(2,2,2,2001-01-02))' + stbox 'STBOX T((2,2,2001-01-01),(3,3,2001-01-03))'; -- ERROR: Boxes must be of the same dimensionality SELECT tbox 'TBOX((1,2001-01-01),(3,2001-01-02))' + tbox 'TBOX((2,2001-01-03),(4,2001-01-04))'; -- ERROR: Result of box union would not be contiguous
Intersection of the bounding boxes
box * box: box
SELECT tbox 'TBOX((1,2001-01-01),(3,2001-01-03))' * tbox 'TBOX((,2001-01-02),(,2001-01-04))'; -- "TBOX((,2001-01-02),(,2001-01-03))" SELECT stbox 'STBOX ZT((1,1,1,2001-01-01),(3,3,3,2001-01-02))' * stbox 'STBOX((2,2),(4,4))'; -- "STBOX((2,2),(3,3))"