[postgis-users] Reasonable Way to Convert MULTIPOINT to POINT?

Martin Davis mbdavis at VividSolutions.com
Thu Feb 24 11:09:05 PST 2005


I have no idea whether or how this would work in PostGIS, but FWIW I
thought I'd comment on a feature recently added to JTS to simplify just
this kind of problem.

In the OGC SFS spec GeometryCollections (including MultiPoint, etc)
provide a getGeometryN() method.  So if you know you have a MultiPoint,
it's easy to just extract the first  point.  The problem is that since
Point doesn't support this method, a (inconvenient) test is required to
see what type of geometry you're dealing with.  

A nicer way of handling this is enabled by moving the getGeometryN and
getNumGeometries methods up to the Geometry base class.  Then no test is
required - you can simply call getGeometryN(0).  The net result is to
make the API more uniform and easier to use.

Generally, a clear pattern that has emerged from using the SFS API is
that methods should be supported by ALL Geometry types if at all
possible, using reasonable default return values if necessary.
PostGIS/GEOS might want to consider providing similar methods.

Martin Davis, Senior Technical Architect
Vivid Solutions Inc.      www.vividsolutions.com
Suite #1A-2328 Government Street Victoria, B.C. V8T 5G5
Phone: (250) 385 6040 - Local 308 Fax: (250) 385 6046


> -----Original Message-----
> From: Jeff Maki [mailto:jmaki at andrew.cmu.edu] 
> Sent: February 23, 2005 6:24 PM
> To: postgis-users at postgis.refractions.net
> Subject: [postgis-users] Reasonable Way to Convert MULTIPOINT 
> to POINT?
> 
> 
> All,
> 
> I'm new to the whole GIS thing, so bear with my (perhaps 
> dumb) questions--I 
> have a query that searches for the intersection of two roads 
> (which are 
> MULTILINES or LINES?), using the Intersection() function, and 
> for most of 
> them, a simple POINT() is returned. Which I have a column in 
> another table 
> that happily stores the result. The problem: one combination 
> of streets, 
> perhaps more than one (that I don't know about yet), returns a 
> MULTIPOINT(). This can't go into my POINT() column. Plus, 
> other queries 
> rely on the storage column only being a POINT(). It has to be 
> a POINT(), 
> basically.
> 
> Short of changing the WKT POINT/MULTIPOINT identifier, and 
> taking the first 
> two, discarding the other points (i.e. hacking together a new 
> WKT format) 
> what's the best way to convert between these two primitives? 
> Looking at the 
> documentation, I see it says not to put in GeometryCollections into 
> Intersection(). I think I do this when I input columns that have been 
> Collect()'d. Is that the problem? It seems to work 99% 
> (number made up!) of 
> the time, though--just this one failed combo (so far).
> 
> Help!
> 
> Thanks!
> 
> -Jeff.
> _______________________________________________
> postgis-users mailing list postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 



More information about the postgis-users mailing list