Question about ST_NumGeometries behavior for PolyhedralSurface and TIN

lr at pcorp.us lr at pcorp.us
Wed Apr 16 03:20:14 PDT 2025


I personally think they should be treated as one geometry.

Also it's kind of pointless to have a function that is just an alias for another and provides know additional info.

On the con side,

It's a breaking change
Might break X3D export and some others, but easy enough to fix there.

> -----Original Message-----
> From: Loïc Bartoletti <loic.bartoletti at oslandia.com>
> Sent: Wednesday, April 16, 2025 1:28 AM
> To: postgis-devel at lists.osgeo.org
> Subject: Question about ST_NumGeometries behavior for PolyhedralSurface
> and TIN
> 
> 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