ST_IsClosed — Tests if a LineStrings's start and end points are coincident. For a PolyhedralSurface tests if it is closed (volumetric).
boolean ST_IsClosed(geometry g);
Returns TRUE if the LINESTRING's
start and end points are coincident.
For a nonempty MultiLineString, each component must be closed.
To test a loop formed by separate lines, first use ST_LineMerge
to stitch the lines and check that it returned one LineString.
For Polyhedral Surfaces, reports if the surface is areal (open) or volumetric (closed).
This method implements the OGC Simple Features
Implementation Specification for SQL 1.1.
This method implements the SQL/MM specification.
SQL-MM 3: 7.1.5, 9.3.3
|
|
|
SQL-MM defines the result of
|
This function supports 3d and will not drop the z-index.
This method supports Circular Strings and Curves.
Enhanced: 2.0.0 support for Polyhedral surfaces was introduced.
This function supports Polyhedral surfaces.
SELECT ST_IsClosed('LINESTRING(0 0,1 1)'::geometry);
f
SELECT ST_IsClosed('LINESTRING(0 0,0 1,1 1,0 0)'::geometry);
t
SELECT ST_IsClosed('MULTILINESTRING((0 0,0 1,1 1,0 0),(0 0,1 1))'::geometry);
f
SELECT ST_IsClosed('POINT(0 0)'::geometry);
t
SELECT ST_IsClosed('MULTIPOINT((0 0),(1 1))'::geometry);
t
These three open components merge into a closed LineString.
WITH input(geom) AS (
VALUES ('MULTILINESTRING((0 0,2 0),(2 0,1 2),(1 2,0 0))'::geometry)
)
SELECT ST_IsClosed(geom) AS parts_closed,
ST_IsClosed(ST_LineMerge(geom)) AS merged_closed
FROM input;
parts_closed | merged_closed --------------+--------------- f | t (1 row)
This example uses a cube.
SELECT ST_IsClosed('POLYHEDRALSURFACE( ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 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)) )');
t
This example uses the same cube with one side missing.
SELECT ST_IsClosed('POLYHEDRALSURFACE( ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 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)) )');
f