boostorg / boostorg/geometry

difference returns wrong results if double is the data type

Open
#1,241 11 comments 0 reactions 1 assignee Claimed by @barendgehrels View on GitHub
bug
Dominant language
C++
Stars
517
Forks
232
PR merge metrics
No merged PRs in 30d

Description

The sample code:
```
static const char p1_wkt[] = "POLYGON((-124.19999999845255 51.901455507812500, -124.19999999460376 51.935823093966235, -123.99999999648789 51.935823093966235, -123.99999999317222 51.902564290309876, -124.19999999845255 51.901455507812500))";
static const char p2_wkt[] = "POLYGON((-123.99999999367975 51.907655109375000, -123.99999999291659 51.900000006653443, -124.19999999861555 51.900000005468293, -124.19999999792353 51.906179355468751, -123.99999999367975 51.907655109375000))";

TEST_F( SpatialOperationF, t3_double )
{
using point = boost::geometry::model::point;
using polygon = boost::geometry::model::polygon;
using polygon_vector = std::vector;

auto left = boost::geometry::from_wkt( p1_wkt );
auto right = boost::geometry::from_wkt( p2_wkt );

{
THIS_IS_A_BUG();

polygon_vector actual;
boost::geometry::difference( left, right, actual );
EXPECT_EQ( 0, actual.size() );
}
{
polygon_vector actual;
boost::geometry::intersection( left, right, actual );
EXPECT_EQ( 1, actual.size() );
}
{
polygon_vector actual;
/* swap arguments */
boost::geometry::difference( right, left, actual );
EXPECT_EQ( 1, actual.size() );
}
}
```
![image](https://github.com/boostorg/geometry/assets/85246214/7f1b9a98-0995-49ae-a539-63b59df274e4)

**The same code ran with `float` data type produces expected results (1 polygon in difference results)**

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.