Returns the bounding box diagonal of a pcpatch object as a geometry.
Syntax
geometry ST_boundingDiagonalGeometry(pcpatch pc);Parameters
| Parameter | Description |
|---|---|
pc | The pcpatch object. |
Description
The returned geometry is a LineString representing the diagonal of the bounding box of the patch. The exact type depends on the dimensions present in the patch data:
LINESTRING— X and Y only (2D)LINESTRING Z— X, Y, and ZLINESTRING M— X, Y, and MLINESTRING ZM— X, Y, Z, and M
The returned geometry is a Ganos Geometry object compatible with GiST spatial indexes. Use this function to create an index on a pcpatch column and accelerate spatial queries.
Examples
Query the bounding box diagonal for each patch in the patches table:
SELECT ST_AsText(ST_BoundingDiagonalGeometry(pa)) FROM patches;Output:
st_astext
------------------------------------------------
LINESTRING Z (-126.99 45.01 1,-126.91 45.09 9)
LINESTRING Z (-126 46 100,-126 46 100)
LINESTRING Z (-126.2 45.8 80,-126.11 45.89 89)
LINESTRING Z (-126.4 45.6 60,-126.31 45.69 69)
LINESTRING Z (-126.3 45.7 70,-126.21 45.79 79)
LINESTRING Z (-126.8 45.2 20,-126.71 45.29 29)
LINESTRING Z (-126.5 45.5 50,-126.41 45.59 59)
LINESTRING Z (-126.6 45.4 40,-126.51 45.49 49)
LINESTRING Z (-126.9 45.1 10,-126.81 45.19 19)
LINESTRING Z (-126.7 45.3 30,-126.61 45.39 39)
LINESTRING Z (-126.1 45.9 90,-126.01 45.99 99)To create a GiST index on the patch column using this function:
CREATE INDEX ON patches USING GIST(ST_BoundingDiagonalGeometry(patch) gist_geometry_ops_nd);该文章对您有帮助吗?