Boost logo

Geometry :

Subject: Re: [geometry] Fwd: Some updates
From: Menelaos Karavelas (menelaos.karavelas_at_[hidden])
Date: 2014-08-04 10:43:24


Hi again Andrew.

On 04/08/2014 05:14 ??, Andrew Hundt wrote:
> A coworker is running into an issue while attempting to run union_(),
> and I was hoping you may be able to provide some feedback on what the
> problem may be. I've included an abridged version of the emails below.
> Any help or ideas would be very much appreciated.
>
> Cheers!
> Andrew Hundt
>
>
> terminate called after throwing an instance of
> 'boost::geometry::overlay_invalid_input_exception'
> what(): Boost.Geometry Overlay invalid input exception
>
> So this is what is happening:
>
> The self intersection happens after you take a union of the above two
> rings.
>
> I tried calling simplify on the multi_polygon, but that just made the
> multi_polygon of size zero. I then tried calling simplify on each
> polygon inside the multi_polygon, but that just made the size of each
> polygon inside zero. I've tried different size parameters for
> simplify, including 1, 2, 5, all with the same effect.
>
> As usual, it is really too bad the documentation for boost is so
> terrible. I would probably like it a lot more if it had reasonable
> documentation. Just getting to the above point, figuring out things
> like how to even get the points out of a multi_polygon has taken me
> hours, and I have no idea why simplify just makes everything size zero.
>

If you just want to "see on the screen" the multipolygon you can always
use boost::geometry::wkt.

>
> On Aug 1, 2014, at 7:16 PM, Andrew Hundt <ahundt_at_[hidden]
> <mailto:ahundt_at_[hidden]>> wrote:
>
>>
>> On Fri, Aug 1, 2014 at 6:15 PM, Carl Wellington <carlw_at_[hidden]
>> <mailto:carlw_at_[hidden]>> wrote:
>>
>> overlay_invalid_input_exception
>>
>>
>> Here is some info on it:
>> http://boost-geometry.203548.n3.nabble.com/overlay-invalid-input-exception-td3688234.html
>>
>> Basically it means there is some self intersection. May need to do
>> something like call simplify in between union operations.
>
> A few more quick observations:
>
> The multi-polygon after calling union on the red and blue rings in the
> figure has two polygons: one of size 17 (the size of the first ring to
> be added) and one of size 23. This multi-polygon self intersects so I
> guess something goes wrong with the union and that's why there are two
> polygons when I expect there should only be one.
>

The above sentence has triggered another possible cause for your
problems: polygons in a multi-polygon are invalid if they have
overlapping interiors, and/or if they touch at whole segments. According
to the OGC standard they are only allowed to touch at isolated points.

As of boost 1.56 (and again also in the develop branch), there is a new
free function called is_valid (this is documented in the boost 1.56
documentation). You can pass a geometry to it and test whether it is
valid in the OGC standard sense. Boost.Geometry algorithms are expecting
valid input in order to work correctly, but validity is not tested
internally.
So another thing to try is to test whether you input geometries are valid.

Best,

- m.

> If I try convex_hull on each polygon inside the multi-polygon after
> the union, then as soon as I add a single ring to the multi-polygon
> using union and run convex_hull on the first polygon, the size goes
> from 17 to 28 and it self-intersects. This seems very odd and I'm
> probably doing something wrong since it's just a single convex ring.
>
> Any ideas for what to try next?
>
> -Carl
>
>
>
>
> _______________________________________________
> Geometry mailing list
> Geometry_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/geometry



Geometry list run by mateusz at loskot.net