boostorg / boostorg/geometry

within(Point, Polygon) returns wrong result for geographic coordinates

Open
#1,112 3 comments 0 reactions 0 assignees View on GitHub
documentation not a bug
Dominant language
C++
Stars
517
Forks
232
PR merge metrics
No merged PRs in 30d

Description

```
typedef boost::geometry::model::d2::point_xy> Point;
typedef boost::geometry::model::polygon Polygon;

Polygon p;
Point p1(21.0005, 3.00053);
Point p2(21.0005, 1.99947);
Point p3(19.9995, 1.99947);
Point p4(19.9995, 3.00053);
Point p5(21.0005, 3.00053);

boost::geometry::append(p.outer(), p1);
boost::geometry::append(p.outer(), p2);
boost::geometry::append(p.outer(), p3);
boost::geometry::append(p.outer(), p4);
boost::geometry::append(p.outer(), p5);

Point testPoint(20, -177.5);

assert(boost::geometry::is_valid(p));
assert(!boost::geometry::within(testPoint, p));
```

the second assert fails. As the testPoint is on the other side of the planet this is clearly wrong.

branch: develop.

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.