Boost logo

Geometry :

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

Hi Andrew.

Would it be possible to send a WKT (or other description of your input
data so that we can reproduce the problem?

Another question: what kind of geometries do you pass as in bg::union_
as input? Are they polygons, rings or multi-polygons? Have you checked
whether they are defined properly? By my last question I mean that your
data conforms with the type of geometry you use: if you use a
counter-clockwise ring, the data should also be in counter-clockwise

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.

As of boost 1.56 (and in the current develop branch), there is a very
easy way to do this, but still undocumented: there is a iterator
iterating over the points of a geometry. So for you could do something
like this:

MultiPolygon /* my multipolygon type */ mpoly;

boost::geometry::point_iterator<MultiPolygon> first =
boost::geometry::point_iterator<MultiPolygon> last =

boost::geometry::point_iterator<MultiPolygon> it;

for (it = first; it != last; ++it)
     // do what you want here

In case you want a const iterator, replace
"boost::geometry::point_iterator<MultiPolygon>" above by
"boost::geometry::point_iterator<MultiPolygon const>".


- m.

> 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:
>> 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.
> 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]

Geometry list run by mateusz at