boostorg / boostorg/geometry

Empty union in spherical coordinate system (and cartesian intersection strategy)

Open
#476 6 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

Consider the test case:
```
namespace spherical {
using point = boost::geometry::model::d2::point_xy >;
using linestring = boost::geometry::model::linestring;
using polygon = boost::geometry::model::polygon;
using multipolygon = boost::geometry::model::multi_polygon;
using mpoint = boost::geometry::model::multi_point;
const double earthRadiusMts = 6371000;
}

BOOST_AUTO_TEST_CASE(unionTestCase) {
auto p1wkt = "POLYGON((-118.4333440130425 34.01738213274482,-118.3666773220425 34.01738213274482,-118.366677322 34.0166734220001,-118.366677321 34.0000067500001,-118.3666773209543 33.99962584406412,-118.370368063634 33.9889823854999,-118.373872409729 33.983340078,-118.383343992 33.983340078,-118.400010665 33.983340077,-118.400010663 33.9666734050001,-118.416677336 33.9666734040001,-118.433344009 33.9666734030001,-118.43334401 33.9833400750001,-118.416677338 33.983340076,-118.416677339 34.000006747,-118.433344012 34.000006747,-118.433344013 34.016673418,-118.4333440130425 34.01738213274482))";
auto p2wkt = "POLYGON((-118.4779357910156 33.89957063423745,-118.433344012 34.000006747,-118.416677339 34.000006747,-118.3656294438703 34.00264773892163,-118.3666773209543 33.99962584406414,-118.366677319 33.983340078,-118.4779357910156 33.89957063423745))";
spherical::polygon p1,p2;
boost::geometry::read_wkt(p1wkt, p1);
boost::geometry::read_wkt(p2wkt, p2);

spherical::multipolygon out;
boost::geometry::union_(p1,p2,out,boost::geometry::strategy::intersection::cartesian_segments<>());
boost::geometry::union_(p1,p2,out,boost::geometry::strategy::intersection::cartesian_segments<>());
std::cout << "Cartesian union empty: " << boost::geometry::wkt(out) << std::endl;
}
```
with the output:
```
Cartesian union empty: MULTIPOLYGON()
```
Continuing our work with @vosst and as a workaround to https://github.com/boostorg/geometry/issues/475 we tried this, perhaps exotic approach, of using `boost::geometry::strategy::intersection::cartesian_segments<>()` over geometries defined in a spherical coordinate system. We calculated we can mostly live with the consequences in the interim.

But then this happened.

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.