[postgis-tickets] [PostGIS] #4736: ST_NumGeometries is zero for GeometryCollection with empty parts
PostGIS
trac at osgeo.org
Thu Jul 29 14:05:30 PDT 2021
#4736: ST_NumGeometries is zero for GeometryCollection with empty parts
-------------------------+---------------------------
Reporter: Mike Taves | Owner: strk
Type: defect | Status: assigned
Priority: medium | Milestone: PostGIS 3.0.4
Component: postgis | Version: 2.4.x
Resolution: | Keywords:
-------------------------+---------------------------
Comment (by pramsey):
The overloading of ST_NumGeometries to return non-null on simple geometry
means that we end up with an odd situation where behaviours are slightly
different with respect to element counts on empty things. I feel like the
below is the least disruptive thing that involves the least change.
{{{
ST_NumGeometries('POINT EMPTY') => 1
ST_NumGeometries('GEOMETRYCOLLECTION EMPTY') => 0
ST_NumGeometries('GEOMETRYCOLLECTION(POINT EMPTY)') => 1
ST_GeometryN('POINT EMPTY', 1) => POINT EMPTY
ST_GeometryN('GEOMETRYCOLLECTION EMPTY', 1) => NULL
ST_GeometryN('GEOMETRYCOLLECTION(POINT EMPTY)', 1) => POINT EMPTY
}}
So just adjusting the return of ST_NumGeometries to be non-zero for
collections of empty sub-elements.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4736#comment:8>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list