[postgis-devel] Polygon ctors again

strk at refractions.net strk at refractions.net
Mon Dec 12 06:48:19 PST 2005


On Sat, Dec 10, 2005 at 08:07:18PM +0100, strk at refractions.net wrote:
> On Sat, Dec 10, 2005 at 01:32:03PM -0500, Carl Anderson wrote:
> > strk at refractions.net wrote:
...
> > To convert this example into a valid MultiPolygon
> > take the  exterior ring of Pa  and symmetric difference it with the 
> > exterior ring of Pb.
> > 
> > <no particular language>
> > 
> > shp=NULL;
> > for (i=1; i<=numgeometries(PolygonCollection); i++) {
> >   if ( shp != NULL and dimension(geometryn(PolygonCollection) == 2 ) {   
> >      shp = symdifference(shp, 
> > LinearRingtoPolygon(outerring(geometryn(PolygonCollection,i))));
> >  } else {
> >      shp = LinearRingtoPolygon(outerring(geometryn(PolygonCollection,i)));
> >  }
> > }
> > 
> > </no particular language>
> 
> I'm not sure I can follow this. What's ``shp'' ?
> 
> What are you trying to do, add a space padding
> between Pa and Pb ?

Sorry, I got it now, was confused by your "valid MultiPolygon"
statement. Your algorithm would return a valid *Polygon* in
the discussed case (two rings: La and Lb). And returns
a valid *MultiPolygon* in the four rings case.

I've adopted the algorithm for a new BuildPolygon() function.
More on this when I've finished testing it.

Kudos to you :)

--strk;



More information about the postgis-devel mailing list