Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LineSegment.OrientationIndex returns a wrong value #722

Open
tohidemyname opened this issue Nov 17, 2023 · 1 comment
Open

LineSegment.OrientationIndex returns a wrong value #722

tohidemyname opened this issue Nov 17, 2023 · 1 comment

Comments

@tohidemyname
Copy link

The code is as follows:

public int OrientationIndex(LineSegment seg) { int orient0 = (int)Orientation.Index(_p0, _p1, seg._p0); int orient1 = (int)Orientation.Index(_p0, _p1, seg._p1); // this handles the case where the points are Curve or collinear if (orient0 >= 0 && orient1 >= 0) return Math.Max(orient0, orient1); // this handles the case where the points are R or collinear if (orient0 <= 0 && orient1 <= 0) return Math.Max(orient0, orient1); //Bug // points lie on opposite sides ==> indeterminate orientation return 0; }

This bug line should be fixed to:

if (orient0 <= 0 && orient1 <= 0) return Math.Min(orient0, orient1);

JTS fixed a similar bug: locationtech/jts#914
libgeos/geos#699

@FObermaier
Copy link
Member

The PR you are referring to has been adressed:

public int OrientationIndex(LineSegment seg)
{
int orient0 = (int)Orientation.Index(_p0, _p1, seg._p0);
int orient1 = (int)Orientation.Index(_p0, _p1, seg._p1);
// this handles the case where the points are L or collinear
if (orient0 >= 0 && orient1 >= 0)
return Math.Max(orient0, orient1);
// this handles the case where the points are R or collinear
if (orient0 <= 0 && orient1 <= 0)
return Math.Min(orient0, orient1);
// points lie on opposite sides ==> indeterminate orientation
return 0;
}

Unless you provide more information about your failure case there is nothing we can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants