[postgis-devel] Re: IsValidOp throwing IllegalArgumentException

strk at refractions.net strk at refractions.net
Sat Nov 6 03:08:26 PST 2004


On Fri, Nov 05, 2004 at 01:33:26PM -0800, Martin Davis wrote:
> I've fixed the problem in JTS, by eliminating the exception being thrown
> in isCCW.  (isCCW doesn't peform a complete check for invalid rings
> anyway, so there's no much point in having it throw an exception in some
> cases).
> 
> Fix is commited to CVS.

Fix in GEOS CVS too.
--strk;

> 
> 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: strk [mailto:strk at keybit.net] 
> > Sent: November 5, 2004 2:19 AM
> > To: Martin Davis
> > Cc: postgis-devel at postgis.refractions.net
> > Subject: IsValidOp throwing IllegalArgumentException
> > 
> > 
> > Martin, I've tracked down wher the problem is.
> > 
> > In CGAlgoritms::isCCW():
> > 
> >         // this will catch all cases where there are not 3 
> > distinct points,
> >         // including the case where the input array has fewer 
> > than 4 elements
> >         if (prev==hip || next==hip || prev==next)
> >                 throw new 
> > IllegalArgumentException("degenerate ring (does not contain 3 
> > distinct points)");
> > 
> > In GeoemtryGraph::addPolygonRing():
> > 
> >         lrcl = lr->getCoordinatesRO();
> >         CoordinateSequence* 
> > coord=CoordinateSequence::removeRepeatedPoints(lrcl);
> > 	if (coord->getSize()<4)  // CLEANLY HANDLES !
> > 	...
> > 	if (cga->isCCW(coord))  // THROWS !
> > 	...
> >  
> > Note that this is the IsValidOp running, so it should be able 
> > to return a result in that case (IS NOT VALID).
> > 
> > Currently I've made IsValidOp wrap GeometryGraph construction 
> > in a try/catch block catching IllegalArgumentException as a 
> > sign of invalidity, but isn't this too large of a catch ?
> > 
> > --strk;
> > 



More information about the postgis-devel mailing list