Checks whether a bounding box has specific spatial or temporal dimensions.
Syntax
bool ST_HasXY(boxndf box);
bool ST_HasZ(boxndf box);
bool ST_HasT(boxndf box);Parameters
| Parameter | Description |
|---|---|
box | The bounding box to query. |
Description
These functions return true if the given boxndf bounding box contains the specified dimension, and false otherwise.
ST_HasXY — checks for the x and y dimensions. The x and y dimensions are bound to each other: a bounding box either has both or neither.
ST_HasZ — checks for the z dimension.
ST_HasT — checks for the t (time) dimension.
Use these functions to filter or validate multi-dimensional spatio-temporal data before running dimension-specific queries.
Examples
The following examples use a 2D+time bounding box created with ST_MakeBox2dt. Because this box has no z dimension, ST_HasZ returns f (false), while ST_HasT returns t (true).
postgres=# select ST_hasz(ST_MakeBox2dt(0,0,'2000-01-01'::timestamp, 20,20, '2020-01-01'::timestamp));
st_hasz
---------
f
postgres=# select ST_hast(ST_MakeBox2dt(0,0,'2000-01-01'::timestamp, 20,20, '2020-01-01'::timestamp));
st_hast
---------
tSee also
ST_MakeBox2dt— construct a 2D+timeboxndfbounding boxST_Ndims— return the number of dimensions of aboxndfbounding box