turf
turf copied to clipboard
Unexpected null,null values in turf.lineOffset
Hi, with turf.lineOffset I'm getting null,null values after a few coordinates.
This is an example, as you see it returns:
{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[-5.659527716280386,43.529426062328994],[-5.659396931069477,43.529476364333185],[-5.659078282820753,43.52960581518423],[-5.6588566137359075,43.52968291747461],[-5.658607634418292,43.52973079811262],[-5.658263354062074,43.52976030785744],[-5.65746124145509,43.52981043989537],[-5.657156661212797,43.529851050594345],[-5.657030727080651,43.52987203961637],[-5.656911375382799,43.52990459007942],[-5.6567831114019915,43.52995589567173],[-5.656703126941215,43.52998788945605],[-5.6564786744399935,43.53010011570666],[-5.656052220977889,43.53032821872128],[-5.655786888151882,43.530432456617206],[-5.655722689038365,43.53044162791914],[-5.655642689038308,43.53046162791915],[-5.655441431409643,43.53049037900896],[-5.655045581504581,43.530509688760425],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null],[null,null]]}}
I think my code is right (?). Any idea please?
Thanks in advance!
I have the same issue.
@costales did you ever figure out a solution to this? We have a map where we import .geojson files and most files works fine but today we had a file with the same issue you had back in 2020.
I made a fork of your example and i get the same problem with my coordinates (130 of 2287 coordinates):
http://jsfiddle.net/turbolego/46o0fhw3/12/
Seems like there's some coordinates where turf.lineOffset just breaks randomly? 🤔
I solved this issue by removing "artifacts" in my coordinates using @turf/simplify:
https://www.npmjs.com/package/@turf/simplify