名称

ST_ForceSFS — Force geometries to use SFS 1.1 or 1.2 geometry types.

大纲

geometry ST_ForceSFS(geometry geomA);

geometry ST_ForceSFS(geometry geomA, text version);

描述

Forces a geometry to use the geometry types defined by the requested version of the OGC Simple Features Specification. The default is SFS 1.1. Curved geometries are converted to linear representations, TRIANGLE is converted to POLYGON, and TIN and POLYHEDRALSURFACE are converted to GEOMETRYCOLLECTION values containing POLYGON elements.

If version begins with 1.2, curved geometries are still converted to linear representations, but TRIANGLE, TIN, and POLYHEDRALSURFACE are preserved. Other version values use the default SFS 1.1 behavior. Geometry collections are processed recursively, and the SRID and Z/M coordinates are preserved.

可用性:2.1.0

该函数支持多面体曲面。

此函数支持三角形和不规则三角网面 (TIN)。

此方法支持圆形字符串和曲线。

该函数支持 3d 并且不会丢失 z-index。

示例

Compare the geometry types produced for SFS 1.1 (the default) and SFS 1.2. Read each row from the input type in the direction of the result columns.

Code
WITH inputs(geom) AS (VALUES
    ('CIRCULARSTRING(0 0, 1 1, 2 0)'::geometry),
    ('TRIANGLE((0 0, 0 2, 2 0, 0 0))'::geometry),
    ('TIN(((0 0, 0 2, 2 0, 0 0)))'::geometry),
    ('POLYHEDRALSURFACE(((0 0, 0 2, 2 0, 0 0)))'::geometry)
)
SELECT ST_GeometryType(geom) || ' →' AS input,
       ST_GeometryType(ST_ForceSFS(geom)) AS "SFS 1.1 (default)",
       ST_GeometryType(ST_ForceSFS(geom, '1.2')) AS "SFS 1.2"
FROM inputs;
栅格输出
input          |   SFS 1.1 (default)   |       SFS 1.2
------------------------+-----------------------+----------------------
 ST_CircularString →    | ST_LineString         | ST_LineString
 ST_Triangle →          | ST_Polygon            | ST_Triangle
 ST_Tin →               | ST_GeometryCollection | ST_Tin
 ST_PolyhedralSurface → | ST_GeometryCollection | ST_PolyhedralSurface
(4 rows)