boostorg / boostorg/geometry

Intersection of geographic segment that crosses the antimeridian with its envelope

Open
#916 1 comment 0 reactions 1 assignee Claimed by @vissarion View on GitHub
bug
Dominant language
C++
Stars
517
Forks
232
PR merge metrics
No merged PRs in 30d

Description

Dear maintainers,

with boost 1.77, the following program

``` c++
#include

#include

namespace bg = boost::geometry;
namespace bm = bg::model::d2;

using point = bm::point_xy >;
using linestring = bg::model::linestring;
using multi_linestring = bg::model::multi_linestring;
using box = bg::model::box;

point a() { return { -179.9958, -47.2835 }; }
point b() { return { 179.9972, -47.2753 }; }

linestring ls() {return {a(), { b() }};}

int main() {
multi_linestring result;
auto const envelope = bg::return_envelope(ls());
bool const success = bg::intersection (envelope, ls(), result);
std::cout << "input : " << bg::wkt(ls()) << std::endl;
std::cout << "envelope : " << bg::wkt(envelope) << std::endl;
std::cout << "success : " << success << std::endl;
std::cout << "output : " << bg::wkt(result) << std::endl;
return 0;
}

```
yields the output (Compiler Explorer)

```
input : LINESTRING(-179.996 -47.2835,179.997 -47.2753)
envelope : POLYGON((179.997 -47.2835,179.997 -47.2753,180.004 -47.2753,180.004 -47.2835,179.997 -47.2835))
success : 1
output : MULTILINESTRING((179.997 -47.2753))
```

The envelope appears to be correct. However, the intersection of the segment with its own envelope only yields a single point.

In the case of the intersection, it seems that boost::geometry assumes that the geodesic between `a()` and `b()` does not cross the antimeridian.

While this appears to be a bug, is there any simple workaround other than rotating back/forth before/after the transformation?

Thanks a lot in advance! 😄

Kind regards,
Andreas


Andreas Dirks andreas.dirks@daimler.com on behalf of MBition GmbH Provider Information

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.