[postgis-devel] ST_Npoints vs. ST_NumPoints
Mark Cave-Ayland
mark.cave-ayland at siriusit.co.uk
Mon May 18 01:30:24 PDT 2009
Paragon Corporation wrote:
> 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
Hmmm that smells like a bug to me. What does spec say about
ST_NPoints()/ST_NumPoints() and its behaviour for MULTI types? I'd
imagine only one of these is the "official" function for counting
points within a geometry.
ATB,
Mark.
--
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063
More information about the postgis-devel
mailing list