[postgis-devel] IsValidOp throwing IllegalArgumentException

strk strk at keybit.net
Fri Nov 5 02:19:05 PST 2004

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 ?


More information about the postgis-devel mailing list