[PostGIS] #220: Implement ST_Numcurves and ST_CurveN

PostGIS trac at osgeo.org
Thu Feb 15 17:54:34 PST 2024


#220: Implement ST_Numcurves and ST_CurveN
--------------------------+---------------------------
  Reporter:  robe         |      Owner:  mleslie
      Type:  enhancement  |     Status:  new
  Priority:  medium       |  Milestone:  PostGIS 3.5.0
 Component:  postgis      |    Version:  master
Resolution:               |   Keywords:
--------------------------+---------------------------
Comment (by robe):

 Examples copied over from #5663 dbaston note

 > ST_NumCurves(linestring) should be 1

 `NumCurves` is actually more like `NumSegments`. Here are some examples
 from MS SQL (which I assume is following ISO)

 {{{
 "SELECT geometry::Parse('LINESTRING (0 0, 1 1, 2 2)').STNumCurves()"


 -----------
           2

 }}}

 {{{
 "SELECT geometry::Parse('CIRCULARSTRING (0 0, 1 1, 2 2)').STNumCurves()"


 -----------
           1

 }}}

 And corresponding `ST_CurveN` calls:

 {{{
 "SELECT geometry::Parse('LINESTRING (0 0, 1 1, 2
 2)').STCurveN(2).ToString()"


 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 LINESTRING (1 1, 2 2)
 }}}

 {{{
 "SELECT geometry::Parse('CIRCULARSTRING (0 0, 1 1, 2
 2)').STCurveN(1).ToString()"


 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 CIRCULARSTRING (0 0, 1 1, 2 2)
 }}}


 Damn so maybe not as useful as I thought.

 I tried this one on SQL Server to see what a compound would do


 {{{
 SELECT Geometry::STGeomFromText('COMPOUNDCURVE(
 (2 2, 2.5 2.5),
 CIRCULARSTRING(2.5 2.5, 4.5 2.5, 3.5 3.5),
 (3.5 3.5, 2.5 4.5, 3 5)
 )',0).STNumCurves()

 --
 4

 SELECT Geometry::STGeomFromText('COMPOUNDCURVE(
 (2 2, 2.5 2.5),
 CIRCULARSTRING(2.5 2.5, 4.5 2.5, 3.5 3.5),
 (3.5 3.5, 2.5 4.5, 3 5)
 )',0).STCurveN(4).STAsText();

 --
 LINESTRING (2.5 4.5, 3 5)
 }}}

 So sadly not what I was looking for.

 Maybe this isn't worth it.

 I checked what our ST_DumpSegments  does and sadly it seems a bit
 confused.


 {{{
 SELECT dp.path, ST_AsText(dp.geom)
 FROM ST_DumpSegments('COMPOUNDCURVE(
 (2 2, 2.5 2.5),
 CIRCULARSTRING(2.5 2.5, 4.5 2.5, 3.5 3.5),
 (3.5 3.5, 2.5 4.5, 3 5)
 )'::geometry) AS dp;

 }}}

 Doesn't give an error but returns no rows.
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/220#comment:6>
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