[postgis-devel] ST_Npoints vs. ST_NumPoints

Paragon Corporation lr at pcorp.us
Mon May 18 01:34:40 PDT 2009


 
I don't have the specs sitting in front of me, but ST_NumPoints is the
official spec name, but I think the specs talks about LINESTRINGS and not
other geometries. ST_Npoints is a PostGIS specific function that deals with
all geometries.


-----Original Message-----
From: postgis-devel-bounces at postgis.refractions.net
[mailto:postgis-devel-bounces at postgis.refractions.net] On Behalf Of Mark
Cave-Ayland
Sent: Monday, May 18, 2009 4:30 AM
To: PostGIS Development Discussion
Subject: Re: [postgis-devel] ST_Npoints vs. ST_NumPoints

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
_______________________________________________
postgis-devel mailing list
postgis-devel at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-devel





More information about the postgis-devel mailing list