
Geometry : 
Subject: Re: [geometry] overlay_invalid_input_exception
From: Barend Gehrels (barend_at_[hidden])
Date: 20120125 14:08:46
Hi Vishnu,
On 2512012 17:45, Vishnu wrote:
> I sometimes see the exception 'overlay_invalid_input_exception' is thrown
Yes that can happen. That is intentional.
> What conditions cause this to be thrown?
They are thrown if there are selfintersections AND they are such that
the overlay (the graph traversal) is bothered by it. So this is not so
easy to predict. If geometry A has a selfintersection but that
intersection point is completely separate from geometry B, the overlay
can be done correctly and the exception will NOT be thrown. The output
of a union will then contain the same selfintersection as one of the
inputs had.
But if the selfintersection interferes the process, e.g. it lies in
between two other intersection points, the exception is raised.
This is a little different then the first released version where all
intersections were checked beforehand. Disadvantage thus that it is less
predictable. Advantage is efficiency and the fact that even polygons
with selfintersections can (sometimes) be intersected correctly.
> Are there any boostgeometry
> functions that I can use on input geometries to identify the likelihood of
> this being thrown before actually doing a boolean operation that causes the
> exception to be thrown?
Yes, but it checks not exactly the same.
You can call
if (! intersects(A) && ! intersects(B))
{
// perform the union_
}
But note that it is less efficient code. So depends on your usecase if
you want this or want to catch the exception.
With a define you can avoid the exception being thrown but you risk the
chance of invalid output then.
>
> The exception is thrown when I do a union operation:
>
> boost::geometry::union_(psA, psB, psResult); // psA and psB are both
> multi_polygons
In case of multi_polygons , if two polygons of one multi_polygon
intersect, then is this a selfintersection and this might throw the
exception... But for the rest there is no difference.
Regards, Barend
Geometry list run by mateusz at loskot.net