[postgis-devel] ST_Npoints vs. ST_NumPoints

Paragon Corporation lr at pcorp.us
Sun May 17 09:19:37 PDT 2009


I thought we were going to change ST_NumPoints to be an alias for
ST_Npoints.  Doesn't look like we have as of 1.4

Anyrate there is one thing I am noticing disturbing about ST_NumPoints.  It
appears that for MULTILINESTRINGS it returns the number of points of only
the first line string.  Is that by design?

SELECT atype, ST_NPoints(the_geom) As npoints, ST_NumPoints(the_geom) As
numpoints
FROM (VALUES ('a line m ' , ST_GeomFromEWKT('LINESTRINGM(1 2 3, 3 4 5, 5 8
7, 6 10 11)') ) ,
 ('a circular string' ,  ST_GeomFromText('CIRCULARSTRING(2.5 2.5,4.5 2.5,
4.5 4.5)') ) ,
('A triangle', ST_GeomFromText('POLYGON((0 1,1 -1,-1 -1,0 1))')  ),
('a multilinestring', ST_GeomFromText('MULTILINESTRING ((1 2, 3 4, 5 6), (10
20, 30 40))') ),
('A collection', ST_Collect(ST_GeomFromText('POLYGON((0 1,1 -1,-1 -1,0
1))'), ST_Point(1,3)) )
)
As foo(atype,the_geom);


Gives:

       atype       | npoints | numpoints
-------------------+---------+-----------
 a line m          |       4 |         4
 a circular string |       3 |
 A triangle        |       4 |
 a multilinestring |       5 |         3
 A collection      |       5 |

Thanks,
Regina





More information about the postgis-devel mailing list