[postgis-tickets] [PostGIS] #4736: ST_NumGeometries is zero for GeometryCollection with empty parts

PostGIS trac at osgeo.org
Tue Aug 4 21:06:51 PDT 2020


#4736: ST_NumGeometries is zero for GeometryCollection with empty parts
------------------------+---------------------------
 Reporter:  Mike Taves  |      Owner:  pramsey
     Type:  defect      |     Status:  new
 Priority:  medium      |  Milestone:  PostGIS 3.1.0
Component:  postgis     |    Version:  2.4.x
 Keywords:              |
------------------------+---------------------------
 Take a !GeometryCollection with mixed empty/non-empty parts:
 {{{
 db=> select ST_IsEmpty(g), ST_NumGeometries(g), ST_AsText(g),
 ST_AsText(ST_GeometryN(g, 1)), ST_AsText(ST_GeometryN(g, 2))
 db-> from (select 'GeometryCollection(Point empty, point(1 2), LineString
 empty)'::geometry g) f;
 -[ RECORD 1
 ]----+------------------------------------------------------------
 st_isempty       | f
 st_numgeometries | 3
 st_astext        | GEOMETRYCOLLECTION(POINT EMPTY,POINT(1 2),LINESTRING
 EMPTY)
 st_astext        | POINT EMPTY
 st_astext        | POINT(1 2)
 }}}
 that seems fine. Now with two empty parts:
 {{{
 db=> select ST_IsEmpty(g), ST_NumGeometries(g), ST_AsText(g),
 ST_AsText(ST_GeometryN(g, 1)), ST_AsText(ST_GeometryN(g, 2))
 db-> from (select 'GeometryCollection(Point empty, LineString
 empty)'::geometry g) f;
 -[ RECORD 1 ]----+-------------------------------------------------
 st_isempty       | t
 st_numgeometries | 0
 st_astext        | GEOMETRYCOLLECTION(POINT EMPTY,LINESTRING EMPTY)
 st_astext        | POINT EMPTY
 st_astext        | LINESTRING EMPTY
 }}}
 why is ST_NumGeometries now suggesting there are zero geometries, but
 ST_GeometryN is able to retrieve the two empty parts? An expected result
 would have ST_NumGeometries return 2 instead of 0.

 ----

 postgis_full_version | POSTGIS="2.4.0 r15853" PGSQL="96"
 GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL
 1.11.4, released 2016/01/25" LIBXML="2.9.1" LIBJSON="0.11" RASTER

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4736>
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