ST_MakeBox{Z|T|2D|2DT|3D|3DT}

更新时间:
复制 MD 格式

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

ParameterDescription
xminThe lower bound on the x axis.
xmaxThe upper bound on the x axis.
yminThe lower bound on the y axis.
ymaxThe upper bound on the y axis.
zminThe lower bound on the z axis.
zmaxThe upper bound on the z axis.
tminThe lower bound on the t axis.
tmaxThe 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)
The ST_MakeBox3dt result shows the FLOAT precision expansion: the input lower time bound 2000-01-01 00:00:03 appears as 2000-01-01 00:00:02.999999, and the upper time bound 2000-01-01 02:46:40 appears as 2000-01-01 02:46:40.000476.