Returns a LineString representing the diagonal of the bounding box of the input geometry object.
Syntax
geometry ST_BoundingDiagonal(geometry geom, boolean fits);Parameters
| Parameter | Description |
|---|---|
geom | The geometry object. |
fits | Specifies whether the best fit is required. Default value: false. |
Description
If
geomis empty, the returned diagonal is also empty. Otherwise, the function returns a two-point LineString where the start point holds the minimum value of each dimension and the end point holds the maximum value.The returned LineString retains the spatial reference identifier (SRID) and dimension of the input geometry object.
If
fitsisfalse, the function may return the diagonal of a larger bounding box. This allows faster processing of geometry objects with many vertices in a short period of time.Regardless of the
fitsvalue, the bounding box corresponding to the returned diagonal always covers the input geometry object.This function supports 3D objects and preserves z coordinates.
This function supports m coordinates.
Examples
SELECT ST_AsText(ST_BoundingDiagonal('LINESTRING(2 2,0 0)'::geometry));Output:
st_astext
---------------------
LINESTRING(0 0,2 2)
(1 row)