boostorg / boostorg/geometry

Wrong intersection of polygon and linestring

Open
#1,406 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
517
Forks
232
PR merge metrics
No merged PRs in 30d

Description

The following code

```cpp
#include
#include
#include

namespace bg = boost::geometry;

int main() {
// Define the polygon
bg::model::polygon> polygon;
bg::read_wkt("POLYGON((1 1.5,3.5 4.5,4 6,2.5 4.5,1 1.5))", polygon);

// Define the linestring
bg::model::linestring> linestring;
bg::read_wkt("LINESTRING(1.5 1.5,0.5 1.5)", linestring);

// Compute the intersection
std::tuple<
bg::model::multi_point>,
bg::model::multi_linestring>>
> output;
bg::intersection(polygon, linestring, output);

// Print the results
auto linestrings = std::get<1>(output);
auto points = std::get<0>(output);
std::cout << "Intersection linestrings: " << bg::wkt(linestrings) << std::endl;
std::cout << "Intersection points: " << bg::wkt(points) << std::endl;

return 0;
}
```

Gives the following incorrect output:
```
Intersection linestrings: MULTILINESTRING((1 1.5,0.5 1.5))
Intersection points: MULTIPOINT()
```

on current develop with clang-15 on ubuntu 22.

![Image](https://github.com/user-attachments/assets/13c74026-7013-4a8e-8fbf-91e10dab3419)

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.