[postgis-users] How do multipolygons work?

Simon Schneider Kallas at gmx.de
Sun Dec 9 22:49:08 PST 2007


Thx for your answer, now PostGIS's behaviour became clear. I think I'll set work on finding a OGC conform solution for my model.

Ciao,
Simon

-------- Original-Nachricht --------
> Datum: Sun, 09 Dec 2007 21:48:06 -0800
> Von: Kevin Neufeld <kneufeld at refractions.net>
> An: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
> Betreff: Re: [postgis-users] How do multipolygons work?

> Hi Simon,
> 
> For most spatial functions, PostGIS assumes that input geometries are 
> valid - nondeterministic results are bound to occur otherwise.  This is 
> what you are seeing here.  The MultiPolygon you've posted here is not 
> valid.  It's actually a multipolygon geometry with a single internal 
> invalid polygon whose internal ring lies outside and intersecting the 
> boundary of the exterior ring on a line.  Also, the orientation of the 
> exterior ring is counter-clockwise.
> 
> I think you may have meant to post a multipolygon of two touching 
> adjacent polygons:
> MULTIPOLYGON(((0 0 0, 40 0 0, 40 50 0, 0 50 0, 0 0 0)),((40 0 0, 50 0 0, 
> 50 50 0, 40 50 0, 40 0 0)))
> 
> But this too is invalid according to the OpenGIS Simple Features 
> Specification for SQL.
>   "The Boundaries of any 2 Polygons that are elements of a MultiPolygon 
> may not 'cross' and may touch at only a finite number of points."
> In otherwords, your adjacent polygons may only touch at a point(s), not 
> a line.
> 
> However, having said that, you will probably get the the answer you are 
> looking for using the modified multipolygon and the current version of 
> PostGIS.
> postgis=# SELECT
> postgis-#   intersects(
> postgis(#     'MULTIPOLYGON ((( 0 0, 40 0, 40 50, 0 50, 0 0 )),
> postgis(#                    (( 40 0, 50 0, 50 50, 40 50, 40 0 
> )))'::geometry,
> postgis(#     'POINT(45 5)'::geometry),
> postgis-#   intersects(
> postgis(#     'MULTIPOLYGON ((( 0 0, 40 0, 40 50, 0 50, 0 0 )),
> postgis(#                    (( 40 0, 50 0, 50 50, 40 50, 40 0 
> )))'::geometry,
> postgis(#     'POINT(20 5)'::geometry);
>  intersects | intersects
> ------------+------------
>  t          | t
> (1 row)
> 
> But like I said, this result is nondeterministic.  Since the input is 
> still invalid, you may not get this same result in future releases.
> 
> Hope this clarify things,
> Cheers,
> Kevin
> 
> Simon Schneider wrote:
> > Hi,
> >
> > I've a table with a multigeometry geometry column with only one object 
> > inserted:
> >
> > insert into test(name, geom) values('Main', 
> > GeomFromEWKT('MULTIPOLYGON(((0 0 0, 40 0 0, 40 50 0, 0 50 0, 0 0 
> > 0),(40 0 0, 50 0 0, 50 50 0, 40 50 0, 40 0 0)))'));
> >
> >
> > And now I wanted to check whether a certain point lies within this 
> > multipolygon via this query:
> >
> > SELECT name FROM test WHERE distance(GeomFromText('POINT(45 5)',-1), 
> > geom)=0;
> >
> > The thing I don't understand is that above query delivers no result, 
> > but when I try a query with the point inside the first part of the 
> > multipolygon like:
> >
> > SELECT name FROM test WHERE distance(GeomFromText('POINT(20 5)',-1), 
> > geom)=0;
> >
> > it returns "Main" as expected.
> >
> >
> >
> > Can anybody explain to me why the query doesn't return anythin wheng 
> > the point is in the second polygon?
> >
> >
> >
> > Cheers,
> > Simon
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser



More information about the postgis-users mailing list