Returns the Nth face of a polyhedral surface geometry. Returns NULL for all other geometry types.
Syntax
geometry ST_PatchN(geometry geomA, integer n);Parameters
| Parameter | Description |
|---|---|
geomA | The geometry object. Must be a polyhedral surface (POLYHEDRALSURFACE or POLYHEDRALSURFACEM). |
n | The 1-based index of the face to return. |
Usage notes
Indexing is 1-based. The first face has index 1, not 0.
Returns NULL if
geomAis not a polyhedral surface.Supports 3D geometries and preserves Z coordinates.
To extract all faces at once, use
ST_Dump.
Example
-- Return the first face of a polyhedral surface
SELECT ST_AsText(
ST_PatchN(
'POLYHEDRALSURFACE(
((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),
((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),
((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)),
((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)),
((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1))
)'::geometry,
1
)
);Output:
st_astext
---------------------------------------------
POLYGON Z ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0))
(1 row)See also
ST_Dump— expands a geometry into a set of component geometries; more efficient for extracting all faces
该文章对您有帮助吗?