Builds a boxndf bounding box from axis bounds across spatial and temporal dimensions. Use the variant that matches the dimensions your query requires.
Syntax
boxndf ST_MakeBoxZ(float8 zmin, float8 zmax);
boxndf ST_MakeBoxT(timestamp tmin, timestamp tmax);
boxndf ST_MakeBox2D(float8 xmin, float8 ymin, float8 xmax, float8 ymax);
boxndf ST_MakeBox2DT(float8 xmin, float8 ymin, timestamp tmin, float8 xmax, float8 yax, timestamp tmax);
boxndf ST_MakeBox3D(float8 xmin, float8 ymin, float8 zmin, float8 xmax, float8 ymax, float8 zmax);
boxndf ST_MakeBox3DT(float8 xmin, float8 ymin, float8 zmin, timestamp tmin, float8 xmax, float8 ymax, float8 zmax, timestamp tmax);Parameters
| Parameter | Description |
|---|---|
xmin | The lower bound on the x axis. |
xmax | The upper bound on the x axis. |
ymin | The lower bound on the y axis. |
ymax | The upper bound on the y axis. |
zmin | The lower bound on the z axis. |
zmax | The upper bound on the z axis. |
tmin | The lower bound on the t axis. |
tmax | The upper bound on the t axis. |
Description
These functions construct bounding boxes for spatial index range queries. Because boxndf uses the FLOAT data type internally, the returned box may be slightly larger than the exact bounds you provide: the lower bound may be fractionally smaller, and the upper bound may be fractionally larger.
Examples
-- x and y dimensions only (2D spatial)
SELECT ST_MakeBox2d(0,0,3,3);Result:
st_makebox2d
----------------
BOX2D(0 0,3 3)-- z dimension only
SELECT ST_MakeBoxZ(1.0, 5.0);-- t (time) dimension only
SELECT ST_MakeBoxT('2000-01-01 00:00:00'::timestamp, '2000-12-31 23:59:59'::timestamp);-- x, y, and z dimensions (3D spatial)
SELECT ST_MakeBox3D(0,0,0,3,3,3);-- x, y, and t dimensions (2D spatial + time)
SELECT ST_MakeBox2DT(0,0,'2000-01-01 00:00:00'::timestamp, 3,3,'2000-12-31 23:59:59'::timestamp);-- x, y, z, and t dimensions (3D spatial + time)
SELECT ST_MakeBox3dt(0,0,3,'2000-01-01 00:00:03'::timestamp, 2,5,4,'2000-01-01 02:46:40'::timestamp);Result:
st_makebox3dt
---------------------------------------------------------------------------
BOX3DT(0 0 3 2000-01-01 00:00:02.999999,2 5 4 2000-01-01 02:46:40.000476)
(1 row)TheST_MakeBox3dtresult shows the FLOAT precision expansion: the input lower time bound2000-01-01 00:00:03appears as2000-01-01 00:00:02.999999, and the upper time bound2000-01-01 02:46:40appears as2000-01-01 02:46:40.000476.
该文章对您有帮助吗?