boostorg / boostorg/geometry

Wrong result of sym_difference.

Open
#900 9 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
517
Forks
232
PR merge metrics
No merged PRs in 30d

Description

To reproduce (polygon's point order doesn't matter):
```
namespace bg = boost::geometry;
namespace bgm = boost::geometry::model;

using cpt_t = bgm::point;
using cpo_t = bgm::polygon;
using cmpo_t = bgm::multi_polygon;

int main()
{
cpo_t a, b, c, d;
bg::read_wkt("POLYGON((25 0,0 15,30 15,22 10,25 0))", a);
bg::read_wkt("POLYGON((5 0,15 25,25 0,15 5,5 0))", b);
bg::read_wkt("POLYGON((15 0,17 10,10 15,20 15,25 25,30 15,40 15,32 10,35 0,25 5,15 0))", c);
bg::read_wkt("POLYGON((5 0,7 10,0 15,10 15,15 25,20 15,30 15,22 10,25 0,15 5,5 0))", d);
bg::correct(a);
bg::correct(b);
bg::correct(c);
bg::correct(d);

cmpo_t ab, abc, dc, abcdc;
bg::sym_difference(a, b, ab); // ok
bg::sym_difference(ab, c, abc); // ok
bg::sym_difference(d, c, dc); // ok
bg::sym_difference(abc, dc, abcdc); // wrong!
}
```

Wrong result for geometries:
```
abc = MULTIPOLYGON(((20 2.5,25 0,25 -8.8817841970012523e-16,20.454545454545453 2.7272727272727271,20 2.5)),((20 2.5,15.909090909090908 4.5454545454545459,15 0,20 2.5)),((20.454545454545453 2.7272727272727271,23.333333333333332 4.166666666666667,19 15,15 25,11 15,10.777777777777779 14.444444444444443,17 10,16.071428571428573 5.3571428571428577,20.454545454545453 2.7272727272727271)),((16.071428571428573 5.3571428571428577,8.870967741935484 9.67741935483871,5 0,15 5,15.90909090909091 4.5454545454545459,16.071428571428573 5.3571428571428577)),((23.333333333333332 4.166666666666667,25 0,23.695652173913043 4.3478260869565215,23.333333333333332 4.166666666666667)),((10.777777777777779 14.444444444444443,10 15,0 15,8.870967741935484 9.67741935483871,10.777777777777779 14.444444444444443)),((23.695652173913043 4.3478260869565215,25 5,35 0,32 10,40 15,30 15,22 10,23.695652173913043 4.3478260869565215)),((30 15,25 25,20 15,30 15)))
dc = MULTIPOLYGON(((20 15,15 25,10 15,20 15)),((20 15,30 15,25 25,20 15)),((15.90909090909091 4.5454545454545459,17 10,10 15,0 15,7 10,5 0,15 5,15.90909090909091 4.5454545454545459)),((15.90909090909091 4.5454545454545459,15 0,20 2.5,15.90909090909091 4.5454545454545459)),((20 2.5,25 0,23.695652173913043 4.3478260869565215,20 2.5)),((23.695652173913043 4.3478260869565215,25 5,35 0,32 10,40 15,30 15,22 10,23.695652173913043 4.3478260869565215)))
```

Visual help:

![image871](https://user-images.githubusercontent.com/1226951/129460573-18478b97-6168-457d-9135-1136c34f3fed.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.