Question about ST_NumGeometries behavior for PolyhedralSurface and TIN
Loïc Bartoletti
loic.bartoletti at oslandia.com
Tue Apr 15 22:27:46 PDT 2025
Hello,
I'm thinking about the current implementation of ST_NumGeometries for
PolyhedralSurface and TIN geometries.
According to the documentation, ST_NumGeometries is currently an alias
for ST_NumPatches for these types.
However, if I'm not wrong, this may not align with the SimpleFeature
specification.
In the document, PolyhedralSurface and TIN inherit from Surface (like
Polygon) and are not "multi" geometries. They should be considered as a
single geometry (one surface) that contains multiple patches, which
differiates them from MultiPolygon.
Consider these examples:
```sql
SELECT ST_NumGeometries('MULTIPOLYGON( ((0 0, 0 1, 1 1, 0 0)), ((0 1, 1 1, 1 0, 0 1)) )');
-- Currently returns 2, which is correct as there are 2 polygons
SELECT ST_NumGeometries('POLYHEDRALSURFACE( ((0 0, 0 1, 1 1, 0 0)), ((0 1, 1 1, 1 0, 0 1)) )');
-- Currently returns 2, but should return 1 (one surface) if following the object model
SELECT ST_NumPatches('POLYHEDRALSURFACE( ((0 0, 0 1, 1 1, 0 0)), ((0 1, 1 1, 1 0, 0 1)) )');
-- Returns 2, which is correct as there are 2 patches
```
Additionally, ST_NumPatches support appears to be missing for TIN
geometries and should be added.
What are you thoughts on this interpretation?
Regards,
Loïc
More information about the postgis-devel
mailing list