-
Notifications
You must be signed in to change notification settings - Fork 944
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
lineSplit does not split a lineString if splitter is very close to a vertex point #852
Comments
@grundid it seems to be a matter of decimals in the splitter ( const lineString = turf.lineString([[9.2202022, 49.1438226], [9.2199531, 49.1439048], [9.2196177, 49.1440264]]);
const resultFc = turf.lineSplit(lineString, turf.point([9.219953, 49.143905])); // coordinates truncated to 6 decimals
//={ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": {}, "geometry": { "type": "LineString", "coordinates": [ [ 9.2202022, 49.1438226 ], [ 9.2199531, 49.1439048 ], [ 9.219953, 49.143905 ] ] } }, { "type": "Feature", "properties": {}, "geometry": { "type": "LineString", "coordinates": [ [ 9.219953, 49.143905 ], [ 9.2196177, 49.1440264 ] ] } } ] } Turf follows GeoJSON recommendations by using 6 decimals to define coordinates. @DenisCarriere we might want to |
If Turf follows the GeoJSON recommendations then maybe turf.point should not create a GeoJSON object with to many decimals. ;) |
Might not be a good idea to add
👍 Agreed, for this scenario we might want to introduce @grundid Good catch! |
- applied truncate on splitter; - added throw tests; - updated feature test results and bench;
Fixed in the next minor release. |
After the latest release lineSplit became somehow quite useless for my cases: Case 1: const lineString = turf.lineString([[9.2202022, 49.1438226], [9.2199531, 49.1439048], [9.2196177, 49.1440264]]);
const resultFc = turf.lineSplit(lineString, turf.point([9.2202022, 49.1438226])); Returns two lines. One very short: Case 2: const lineString = turf.lineString([[9.2185956, 49.1450893], [9.2181343, 49.1443734], [9.2192501, 49.1438962]]);
const resultFc = turf.lineSplit(lineString, turf.point([9.2181343, 49.1443734])); Here the cut does not work. lineSplit returns one feature which is the original line. |
@grundid Thanks for reporting this, could you add these test cases to the |
Bug still somewhere... 🐛 |
Those pesky 🐛 🐞 ! |
added test cases for issue #852
This is fixed in the latest |
Scenario 1 Expected Result Scenario 2 I was trying to get split parts of 2 lines and get the merge.What I did was get line split in line1 vs line2 and again line2 vs line1. Issue is line splitting not working properly when splitting is close to vertex point as in above images.I noticed that line split is not giving proper splitter parts.In last scenario line splitting is giving only 2 splitter parts of line A instead of 3. |
The following test returns a feature collection with only one element.
I would expect two elements.
When I reduce the precision of the splitter the result is correct:
The text was updated successfully, but these errors were encountered: