boostorg / boostorg/geometry

Inconsistent Results from crosses() with Equivalent Geometries

オープン
#831 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C++
スター
517
フォーク
232
PR マージ指標
30日以内にマージされた PR はありません

説明

Input:
```
#include "boost/geometry.hpp"
#include

namespace bg = boost::geometry;
typedef bg::model::d2::point_xy Point;
typedef bg::model::linestring Linestring;
typedef bg::model::polygon Polygon;

int main() {
Polygon poly;
auto &o = poly.outer();
o.push_back(Point(-41.72930145263671875f, -33.68047332763671875f));
o.push_back(Point(-41.729339599609375f, -11.68046855926513671875f));
o.push_back(Point(-47.73418426513671875f, -11.6804676055908203125f));
o.push_back(Point(-47.73418426513671875f, 15.7195301055908203125f));
o.push_back(Point(-36.33417510986328125f, 15.7195301055908203125f));
o.push_back(Point(-36.334136962890625f, -6.28046894073486328125f));
o.push_back(Point(-29.7302703857421875f, -6.28046894073486328125f));
o.push_back(Point(-29.730274200439453125f, 15.7195301055908203125f));
o.push_back(Point(-12.3253917694091796875f, 15.7195301055908203125f));
o.push_back(Point(-12.3253936767578125f, -6.28046894073486328125f));
o.push_back(Point(0.2726857662200927734375f, -6.28046894073486328125f));
o.push_back(Point(0.2726562023162841796875f, 15.7195301055908203125f));
o.push_back(Point(11.6726551055908203125f, 15.7195301055908203125f));
o.push_back(Point(11.6726551055908203125f, -33.68047332763671875f));
o.push_back(Point(-17.731250762939453125f, -33.68047332763671875f));
o.push_back(Point(-17.7312469482421875f, -11.68046855926513671875f));
o.push_back(Point(-24.3244171142578125f, -11.68046855926513671875f));
o.push_back(Point(-24.324413299560546875f, -33.68047332763671875f));
o.push_back(Point(-41.72930145263671875f, -33.68047332763671875f));

Linestring line1(
{Point(-65.7273406982421875f, -6.280469417572021484375f),
Point(0.2726857662200927734375f, -6.28046894073486328125f)});
Linestring line2({line1[1], line1[0]});

std::cout << "Poly valid: " << bg::is_valid(poly) << std::endl;
std::cout << "Line1 valid: " << bg::is_valid(line1) << std::endl;
std::cout << "Line2 valid: " << bg::is_valid(line2) << std::endl;
std::cout << "Lines equivalent: " << bg::equals(line1, line2) << std::endl;
std::cout << std::endl;

std::cout << "Line1 crosses: " << bg::crosses(line1, poly) << std::endl;
std::cout << "Line2 crosses: " << bg::crosses(line2, poly) << std::endl;

return 0;
}
```
Output:
```
Poly valid: 1
Line1 valid: 1
Line2 valid: 1
Lines equivalent: 1

Line1 crosses: 1
Line2 crosses: 0
```

The ordering of the points in the line segment affects the results of crosses(). In this particular case, I believe both tests should return true. I'm using g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 and boost geometry 1.75.0.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。