lineSplit returns line segments in an unexpected order
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.5k
- Forks
- 1k
- Avg merge
- 1h 11m
- Merged PRs (30d)
- 4
Description
I split a LineString with a Polygon and the resulting Features were returned in an odd order. I don't see that lineSplit actually makes any promise regarding the order of the returned line segments, but without that order it becomes a lot more complicated to determine which segments are inside the polygon and which are outside. I have seen other people write code that assumes the segments returned by lineSplit are ordered, for example https://bl.ocks.org/rveciana/e0565ca3bfcebedb12bbc2d4edb9b6b3
Link to gist demonstrating the issue: https://gist.github.com/wiseman/5e6769cad94e3df318ca3aa00f736b7c
In that gist, the first feature is the line that I split. It's a line that runs from south to north. The second feature is the polygon I used to split the line. The rest of the features are the features that lineSplit returned, in order.
lineSplit correctly split the line into 3 segments: A segment (A) that is outside and south of the polygon; A segment (B) that is inside the polygon; A segment (C) that is outside and north of the polygon.
The unexpected behavior is that those 3 segments are returned in the order [C, A, B].
I had been trying to use the simple method from @rveciana's code, referenced above, to determine which line segments are in the polygon, but without a consistent ordering that method doesn't work.
(Just as background, the problem I'm solving is figuring out when an aircraft will transition into and out of various airspaces. That polygon is part of the Burbank, California class E5 airspace.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the lineSplit entry point and reproduce the reported [C, A, B] result using the linked gist. Trace how split segments are collected and determine whether their order can consistently follow the original line; done means the three segments are returned in source-line order without breaking existing splitting behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100