-
Notifications
You must be signed in to change notification settings - Fork 946
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
smallsaucepan
merged 11 commits into
Turfjs:master
from
pm0u:pm0u/self-intersections-line-intersect
Dec 14, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f5df121
Update self intersection argument, doc gen, add self intersection geo…
pm0u 39e8236
Merge branch 'master' of github.com:pm0u/turf into pm0u/self-intersec…
pm0u a0be0c2
Remove additional param clarifications
pm0u 7a54fec
Add fixture for self intersecting multi-line in non-intersecting coll…
pm0u e77c500
More test cases
pm0u f82e274
Merge branch 'master' into pm0u/self-intersections-line-intersect
smallsaucepan 2c8d081
Merge branch 'master' of github.com:pm0u/turf into pm0u/self-intersec…
pm0u 8559032
revert removal of example, add comment explaining test
pm0u 92a39b4
Merge branch 'pm0u/self-intersections-line-intersect' of github.com:p…
pm0u cc80f9b
re include newline in example
pm0u 542bba7
update readme
pm0u File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/turf-line-intersect/test/in/self-intersecting-line.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [ | ||
[0, 0], | ||
[0, 2], | ||
[2, 1], | ||
[-1, 1] | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [ | ||
[3, 3], | ||
[4, 4], | ||
[5, 5] | ||
] | ||
} | ||
} | ||
] | ||
} |
36 changes: 36 additions & 0 deletions
36
packages/turf-line-intersect/test/in/self-intersecting-multiline.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "MultiLineString", | ||
"coordinates": [ | ||
[ | ||
[0, 0], | ||
[1, 2], | ||
[0, 4] | ||
], | ||
[ | ||
[1, 0], | ||
[0, 2], | ||
[1, 4] | ||
] | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [ | ||
[3, 3], | ||
[4, 4], | ||
[5, 5] | ||
] | ||
} | ||
} | ||
] | ||
} |
52 changes: 52 additions & 0 deletions
52
packages/turf-line-intersect/test/in/self-intersecting-multipoly.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"fill": "#ed333b", | ||
"fill-opacity": 0.5 | ||
}, | ||
"geometry": { | ||
"coordinates": [ | ||
[ | ||
[ | ||
[2.8208987964653716, 5.206515064293427], | ||
[2.8208987964653716, -4.530167455797994], | ||
[6.383916833323553, -4.530167455797994], | ||
[6.383916833323553, 5.206515064293427], | ||
[2.8208987964653716, 5.206515064293427] | ||
] | ||
], | ||
[ | ||
[ | ||
[-0.33343506038161763, 3.67541603033537], | ||
[-0.33343506038161763, 2.1793088174136273], | ||
[8.775841349855597, 2.1793088174136273], | ||
[8.775841349855597, 3.67541603033537], | ||
[-0.33343506038161763, 3.67541603033537] | ||
] | ||
] | ||
], | ||
"type": "MultiPolygon" | ||
}, | ||
"id": 0 | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"coordinates": [ | ||
[ | ||
[-7.951422534380413, 5.231149187754099], | ||
[-7.951422534380413, -4.552832252613101], | ||
[-5.701165954657256, -4.552832252613101], | ||
[-5.701165954657256, 5.231149187754099], | ||
[-7.951422534380413, 5.231149187754099] | ||
] | ||
], | ||
"type": "Polygon" | ||
} | ||
} | ||
] | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/turf-line-intersect/test/in/self-intersecting-poly.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"coordinates": [ | ||
[ | ||
[-0.8680870854922205, 3.0368343508535673], | ||
[-1.321147431010786, 5.333329344976903], | ||
[1.0099462525165848, 5.611566335081363], | ||
[0.47439299724965167, -1.9282285399474688], | ||
[3.2162894164922875, -1.8166964568157766], | ||
[2.707220996335252, 7.192842763774053], | ||
[-3.8645185945755713, 6.519248925309753], | ||
[-3.8571038955967083, 0.3483632770754781], | ||
[-0.5093053180867742, 0.39824548653076874], | ||
[4.4119165583018685, 0.21046777461485533], | ||
[3.9804563423212755, 3.7937082620644844], | ||
[-0.8680870854922205, 3.0368343508535673] | ||
] | ||
], | ||
"type": "Polygon" | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"coordinates": [ | ||
[ | ||
[-7.4564971746842446, 6.278543929857676], | ||
[-13.631981273628753, 6.323585458965155], | ||
[-12.43687692686214, -2.589094309688946], | ||
[-6.376915352576532, -3.0767722870515115], | ||
[-7.4564971746842446, 6.278543929857676] | ||
] | ||
], | ||
"type": "Polygon" | ||
} | ||
} | ||
] | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/turf-line-intersect/test/out/self-intersecting-line.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [ | ||
[0, 0], | ||
[0, 2], | ||
[2, 1], | ||
[-1, 1] | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [ | ||
[3, 3], | ||
[4, 4], | ||
[5, 5] | ||
] | ||
} | ||
} | ||
] | ||
} |
36 changes: 36 additions & 0 deletions
36
packages/turf-line-intersect/test/out/self-intersecting-multiline.geojson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "MultiLineString", | ||
"coordinates": [ | ||
[ | ||
[0, 0], | ||
[1, 2], | ||
[0, 4] | ||
], | ||
[ | ||
[1, 0], | ||
[0, 2], | ||
[1, 4] | ||
] | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [ | ||
[3, 3], | ||
[4, 4], | ||
[5, 5] | ||
] | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.