Shift and/or scale the span of a bounding box by one or two values
shiftValue(box,{integer,float}) → box
scaleValue(box,{integer,float}) → box
shiftScaleValue(tbox,{integer,float},{integer,float}) → box
SELECT shiftValue(tbox 'TBOXFLOAT XT([1.5, 2.5],[2001-01-01,2001-01-02])', 1.0); -- TBOXFLOAT XT([2.5, 3.5],[2001-01-01, 2001-01-02]) SELECT scaleValue(tbox 'TBOXFLOAT XT([1.5, 2.5],[2001-01-01,2001-01-02])', 2.0); -- TBOXFLOAT XT([1.5, 3.5],[2001-01-01, 2001-01-02]) SELECT shiftScaleValue(tbox 'TBOXFLOAT XT([1.5, 2.5],[2001-01-01,2001-01-02])', 2.0, 3.0); -- TBOXFLOAT XT([3.5, 6.5],[2001-01-01, 2001-01-02])
Shift and/or scale the span or the period of the bounding box to a value or interval
shiftTime(box,interval) → box
scaleTime(box,interval) → box
shiftScaleTime(box,interval,interval) → box
For scaling, if the width or the time span of the period is zero (that is, the lower and upper bound are equal), the result is the box. The given value or interval must be strictly greater than zero.
SELECT shiftTime(tbox 'TBOXFLOAT XT([1.5, 2.5],[2001-01-01,2001-01-02])', interval '1 day'); -- TBOXFLOAT XT([1.5, 2.5],[2001-01-02, 2001-01-03]) SELECT shiftTime(stbox 'STBOX T([2001-01-01,2001-01-02])', interval '-1 day'); -- STBOX T([2001-12-31, 2001-01-01]) SELECT shiftTime(stbox 'STBOX ZT(((1,1,1),(2,2,2)),[2001-01-01,2001-01-02])', interval '1 day'); -- STBOX ZT(((1,1,1),(2,2,2)),[2001-01-02, 2001-01-03]) SELECT scaleTime(tbox 'TBOXFLOAT XT([1.5, 2.5],[2001-01-01,2001-01-02])', interval '2 days'); -- TBOXFLOAT XT([1.5, 2.5],[2001-01-01, 2001-01-03]) SELECT scaleTime(stbox 'STBOX ZT(((1,1,1),(2,2,2)),[2001-01-01,2001-01-02])', interval '1 hour'); -- STBOX ZT(((1,1,1),(2,2,2)),[2001-01-01 00:00:00, 2001-01-01 01:00:00]) SELECT scaleTime(stbox 'STBOX ZT(((1,1,1),(2,2,2)),[2001-01-01,2001-01-02])', interval '-1 day'); -- ERROR: The interval must be positive: -1 days SELECT shiftScaleTime(tbox 'TBOXFLOAT XT([1.5, 2.5],[2001-01-01,2001-01-02])', interval '1 day', interval '3 days'); -- TBOXFLOAT XT([1.5, 2.5],[2001-01-02, 2001-01-05]) SELECT shiftScaleTime(stbox 'STBOX ZT(((1,1,1),(2,2,2)),[2001-01-01,2001-01-02])', interval '1 hour', interval '3 hours'); -- STBOX ZT(((1,1,1),(2,2,2)),[2001-01-01 01:00:00, 2001-01-01 04:00:00])
Return the spatial dimension of the bounding box, removing the temporal dimension if any
getSpace(stbox) → stbox
SELECT getSpace(stbox 'STBOX ZT(((1,1,1),(2,2,2)),[2001-01-01,2001-01-03])'); -- STBOX Z((1,1,1),(2,2,2))
The functions given next expand the bounding boxes on the value and the time dimension or set the precision of the value dimension. These functions raise an error if the corresponding dimension is not present.
Expand the numeric or spatial dimension of a bounding box by a value
expandValue(tbox,{integer,float}) → tbox
expandSpace(stbox,float) → stbox
SELECT expandValue(tbox 'TBOXFLOAT XT((1,2),[2001-01-01,2001-01-03])', 1.0); -- TBOXFLOAT XT((0,3),[2001-01-01,2001-01-03]) SELECT expandValue(tbox 'TBOX T([2001-01-01,2001-01-03))', 1); -- The box must have value dimension
SELECT expandSpace(stbox 'STBOX ZT(((1,1,1),(2,2,2)),[2001-01-01,2001-01-03])', 1); -- STBOX ZT(((0,0,0),(3,3,3)),[2001-01-01,2001-01-03]) SELECT expandSpace(stbox 'STBOX T([2001-01-01,2001-01-03))', 1); -- The box must have space dimension
Expand the temporal dimension of the bounding box by a time interval
expandTime(box,interval) → box
SELECT expandTime(tbox 'TBOXFLOAT XT((1,2),[2001-01-01,2001-01-03])', interval '1 day'); -- TBOXFLOAT XT((1,2),[2011-12-31,2001-01-04]) SELECT expandTime(stbox 'STBOX ZT(((1,1,1),(2,2,2)),[2001-01-01,2001-01-03])', interval '1 day'); -- STBOX ZT(((1,1,1),(2,2,2)),[2011-12-31,2001-01-04])
Round the value or the coordinates of the bounding box to a number of decimal places
round(box,integer=0) → box
SELECT round(tbox 'TBOXFLOAT XT((1.12345,2.12345),[2001-01-01,2001-01-02])', 2); -- TBOXFLOAT XT((1.12,2.12),[2001-01-01, 2001-01-02]) SELECT round(stbox 'STBOX XT(((1.12345, 1.12345),(2.12345, 2.12345)), [2001-01-01,2001-01-02])', 2); -- STBOX XT(((1.12,1.12),(2.12,2.12)),[2001-01-01, 2001-01-02])