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

Revert self intersection behavior: line-intersect #2742

Merged

Conversation

pm0u
Copy link
Contributor

@pm0u pm0u commented Oct 30, 2024

Purpose: Bug fix

Partially Addresses:
#2728
#2722

line-intersect

  • Sets default value of options property ignoreSelfIntersections to true
  • Adds a geojson file test case for a feature collection with a geometry with a self intersection but no intersections between geometries
  • Adds a test case for default behavior of ignoreSelfIntersections and explicitly setting to false, using same geometry from the geojson test case added.

Copy link
Member

@smallsaucepan smallsaucepan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pm0u. Added a couple of comments. The code change itself is fine. Would you mind adding some more tests to better lock down the current ignores behaviour with other feature types?

packages/turf-line-intersect/index.ts Outdated Show resolved Hide resolved
@@ -132,3 +132,48 @@ test("turf-line-intersect - polygon support #586", (t) => {
t.equal(results.features.length, 1, "should return single point");
t.end();
});

test("turf-line-intersect - self intersection behavior", (t) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there advantages to running the same features through both "in code" and as in/out fixture tests?

Would you mind adding some simple tests for MultiLineString, Polygon, and MultiPolygon as well e.g.

Screenshot 2024-11-13 at 11 04 55 PM

To be honest I'm not sure what the expected behaviour of those are. Should ignoreSelfIntersections apply to the entire MultiLineString, or only take effect within each individual LineString? If you're got the time let's take this opportunity to embed whatever the behaviour is into some baseline tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably no reason to have both - is there a preference for one or the other? Its not clear to me why some tests are based on fixtures - is this preferred for simple T/F style testing?

Copy link
Contributor Author

@pm0u pm0u Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remembering my logic here - The reason was that the tests below specifically test the behavior of the ignoreSelfIntersections param. Because the in/out fixture tests all use the same setup it can't be validated in that setting.

If we think this approach makes sense I can add a note as to why this is set up this way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixtures were probaby chosen to avoid 1000s of lines of geojson in code. If that approach doesn't fit nicely though, by all means add normal test cases.

@pm0u pm0u requested a review from smallsaucepan December 4, 2024 03:45
@pm0u
Copy link
Contributor Author

pm0u commented Dec 4, 2024

Added a few more test cases, let me know if there are any additional cases we would like covered

  • MultiPolygon (self intersecting) and polygon collection
  • Polygon (self intersecting) and polygon collection
  • MultiLineString (self intersecting) and LineString collection
  • LineString (self intersecting) and LineString collection

All of the above test cases produce no intersecting geometries when ignoreSelfIntersections is set to true (default)

Copy link
Member

@smallsaucepan smallsaucepan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can please restore the // addToMap line of the example, good to go 👍

Once that's pushed and CI passes again, I'll go ahead and merge.

packages/turf-line-intersect/index.ts Outdated Show resolved Hide resolved
@pm0u
Copy link
Contributor Author

pm0u commented Dec 11, 2024

@smallsaucepan I believe this should be in a state to be merged. Please let me know if you find any issues at this point, I believe I addressed everything in your last round of feedback

@smallsaucepan
Copy link
Member

Hmm, builds are successful but not being marked as completed for some reason. Will press on with merging.

Screenshot 2024-12-14 at 21 55 57

@smallsaucepan smallsaucepan merged commit e7a28da into Turfjs:master Dec 14, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants