[PostGIS] #5663: ST_GeometryN cannot access sections of CompoundCurve
    PostGIS 
    trac at osgeo.org
       
    Thu Feb  1 16:47:32 PST 2024
    
    
  
#5663: ST_GeometryN cannot access sections of CompoundCurve
----------------------+---------------------------
  Reporter:  dbaston  |      Owner:  pramsey
      Type:  defect   |     Status:  new
  Priority:  medium   |  Milestone:  PostGIS 3.4.2
 Component:  postgis  |    Version:  3.4.x
Resolution:           |   Keywords:
----------------------+---------------------------
Description changed by dbaston:
Old description:
> ST_NumGeometries reports that the following curve has two sub-geometries:
>
> {{{
>  SELECT ST_NumGeometries('COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 1 0),
> (1 0, 0 1))'::geometry);
>  st_numgeometries
> ------------------
>                 2
> }}}
>
> However, attempting to access the first section of the curve with
> ST_GeometryN returns the entire CompoundCurve:
>
> {{{
> SELECT ST_AsText(ST_GeometryN('COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 1
> 0), (1 0, 0 1))'::geometry, 1));
>                       st_astext
> ------------------------------------------------------
>  COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1))
>
> }}}
>
> This behavior differs from OGR:
>
> {{{
> from osgeo import ogr
> g = ogr.CreateGeometryFromWkt('COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 1
> 0), (1 0, 0 1))')
> g.GetGeometryCount()
> # 2
> g.GetGeometryRef(1).ExportToWkt()
> # LINESTRING (1 0,0 1)
> }}}
New description:
 ST_NumGeometries reports that the following curve has two sub-geometries:
 {{{
  SELECT ST_NumGeometries('COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 1 0),
 (1 0, 0 1))'::geometry);
  st_numgeometries
 ------------------
                 2
 }}}
 However, attempting to access the first section of the curve with
 ST_GeometryN returns the entire CompoundCurve:
 {{{
 SELECT ST_AsText(ST_GeometryN('COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 1
 0), (1 0, 0 1))'::geometry, 1));
                       st_astext
 ------------------------------------------------------
  COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1))
 }}}
 This behavior differs from OGR:
 {{{
 from osgeo import ogr
 g = ogr.CreateGeometryFromWkt('COMPOUNDCURVE (CIRCULARSTRING (0 0, 1 1, 1
 0), (1 0, 0 1))')
 g.GetGeometryCount()
 # 2
 g.GetGeometryRef(1).ExportToWkt()
 # LINESTRING (1 0,0 1)
 }}}
 I can see an argument that ST_GeometryN is not intended to return sections
 of a curve (that must be what #220 proposes to implement), but
 ST_NumGeometries and ST_GeometryN should at least be consistent.
--
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5663#comment:1>
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