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 to query. |
n | The 1-based index of the face to return. |
The index is 1-based. The first face is at index 1, not 0.
Description
ST_PatchN returns the Nth face (polygon) of a polyhedral surface or polyhedral surfacem geometry. For all other geometry types, it returns NULL.
Supports polyhedral surfaces.
Supports 3D objects and preserves z coordinates.
To extract all faces at once, use ST_Dump, which is more efficient.
Example
-- Extract 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));
st_astext
---------------------------------------------
POLYGON Z ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0))
(1 row)该文章对您有帮助吗?