ST_ForceSFS
Name
ST_ForceSFS — Force geometries to use SFS 1.1 or 1.2 geometry types.
Synopsis
geometry
ST_ForceSFS
(
geometry
geomA
)
;
geometry
ST_ForceSFS
(
geometry
geomA
, text
version
)
;
Description
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.
Availability: 2.1.0
This function supports Polyhedral surfaces.
This function supports Triangles and Triangulated Irregular Network Surfaces (TIN).
This method supports Circular Strings and Curves.
This function supports 3d and will not drop the z-index.
Examples
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.
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)