ST_BoundingDiagonal

更新时间:
复制 MD 格式

Returns a LineString representing the diagonal of the bounding box of the input geometry object.

Syntax

geometry ST_BoundingDiagonal(geometry geom, boolean fits);

Parameters

ParameterDescription
geomThe geometry object.
fitsSpecifies whether the best fit is required. Default value: false.

Description

  • If geom is 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 fits is false, 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 fits value, 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)