It seems that one of the input polygons to the union_ function is
invalid. To understand my mistake, I outputed the operand polygons to
SVG files and I discovered punctures in one of them. I believe
Boost.Geometry thinks my polygon is self-intersecting (may be due to
precision error with floats ?) - but this polygon itself is the result
of a previous union operation.
I don't know if solutions to this problem exists or if the library is
faulty (the bad polygon is the result of an union operation). One
workaround would be to detect punctures and remove them, but it's kind
of ugly imho...
Some more details:
- point coordinates type is float,
- I use custom class instead of point_xy model,
- polygon winding is counter-clockwise.
Thank you in advance for any help,
Olivier
I exported the two inputs which produce the error during the algorithm execution and I wrote a simple program appart with thoose polygons. I also simplified a little the inputs and i was able to reproduce the problem (see attached source file main.cpp).
I'll attach the generated SVG for inputs and output.As you suggested, I also tried to use double instead of float. The result is different (note: not all digits printed for doubles) :-1.1414213180542001069 -0.14142137765884399414 <- A
-0.97336012125015303198 0.19470110535621598657 <- one new extra-point-0.97336008742385127235 0.19470109862769818809 <--1.1414213180542001069 -0.14142137765884399414 <- point equal to A (I checked till last digit, not shown here)
One more thing I forgot to mention: I'm using boost 1.53 - I see another version has been released very recently and I think i'll give a try with it asap.
I'm not very familiar with Boost.Geometry, so maybe I'm doing something wrong or maybe I'm expecting too much.