lineSplit doesn't split correctly
See original GitHub issueLineSplit is a great feature but it doesn’t work as expected. I use a simple Polygon (triangle) as a splitter to split a simple four-point LineString. This should result in three LineStrings but only two are produced:
var line = {
type: "Feature",
geometry: {
type: "LineString",
coordinates: [[13.8716,56.2783],[13.8715,56.2785],[13.8743,56.2794],[13.8796,56.2746]]
}
};
var splitter = {
type: "Feature",
geometry: {
type: "Polygon",
coordinates: [[[13.8726,56.2786],[13.8716,56.2786],[13.8713,56.2784],[13.8726,56.2786]]]
}
};
var split = turf.lineSplit(line, splitter);
Returns this collection:
{
type: "FeatureCollection",
features: [{
type: "Feature",
geometry: {
type: "LineString",
coordinates: [[13.8716, 56.2783], [13.871532142857145, 56.27843571428571]]
}
},
{
type: "Feature",
geometry: {
type: "LineString",
coordinates: [[13.871532142857145, 56.27843571428571], [13.8715, 56.2785], [13.8743, 56.2794], [13.8796, 56.2746]]
}
}]
}
Instead of this:
{
type: "FeatureCollection",
features: [{
type: "Feature",
geometry: {
type: "LineString",
coordinates: [[13.8716, 56.2783], [13.871532142857145, 56.27843571428571]]
}
},
{
type: "Feature",
geometry: {
type: "LineString",
coordinates: [[13.871532142857145, 56.27843571428571], [13.8715, 56.2785], [13.871811111111098, 56.2786]]
}
},
{
type: "Feature",
geometry: {
type: "LineString",
coordinates: [[13.871811111111098, 56.2786], [13.8743, 56.2794], [13.8796, 56.2746]]
}
}]
}
This is my first post ever on GitHub, so please be kind if I’m doing something wrong. Have searched earlier issues and haven’t seen this bug report.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:10 (1 by maintainers)
Top Results From Across the Web
The line is splitting at the wrong place - python - Stack Overflow
I want the line to split at the ',' but it splits each character even when the .split() function has a parameter. Can...
Read more >Line feeds not splitting correctly - Power Platform Community
Solved: Hi, Further to my previous post regarding importing a text file that has been converted from a csv file, microsoft sees the...
Read more >String split function not working properly. Any suggestions ...
Specifying -1 as the second parameter in the split method considers the "empty" while splitting a string to a list or an array....
Read more >string.Split doesn't work with multiple separator characters
My gut feeling is that @('x', 'y') is converted to a string and an incorrect overload of String.Split from the runtime is called...
Read more >Split a String Only on the First Occurrence of Delimiter
User management is very complex, when implemented properly. No surprise here. Not having to roll all of that out manually, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @andersfalk
Thanks for a great first bug report, test cases like you provided are always super helpful!
When I’ve got a computer turned on i’ll take a look into things and report back.
Related issue: https://github.com/Turfjs/turf/issues/2023
The function above uses lineSlice, but lineSlice is super imprecise