lineSlice is very imprecise
See original GitHub issueOn turf 6.3.0: lineSlice is very imprecise:
// Start with a line to slice
const line = {
"type": "Feature",
"properties": {
"index": 0
},
"geometry": {
"type": "LineString",
"coordinates": [
[
3.69140625,
51.72702815704774
],
[
-5.3173828125,
41.60722821271717
]
]
}
}
// The start point of the line (Just the first coordinate of the line)
const pointStart = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
3.69140625,
51.72702815704774
]
}
}
// The end point of our slice (obtained by intersecting the line with another line with lineIntersect(line, splitter) )
const pointEnd = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
0.31936718356317106,
47.93913163509963
]
}
}
// Double check that this point is on the line :
pointToLineDistance(point, segment, { units: "meters" }) < 0.001 ;
// true
// Now run lineSlice
lineSlice( pointStart, pointEnd, line )
// It returns this result:
{
"type": "Feature",
"properties": {
"index": 0
},
"geometry": {
"type": "LineString",
"coordinates": [
// The first coordinate is the start point, normal
[
3.69140625,
51.72702815704774
],
////////////////////////////////////////////////////////////////////////////////////
// The second coordinate below is VERY far
// from the slice point we asked for, even though we
// showed it was on the line
[
-0.13132027083960374,
47.4328630517935
]
// It should be this instead
// [
// 0.31936718356317106,
// 47.93913163509963
// ]
////////////////////////////////////////////////////////////////////////////////////
]
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
@turf/line-slice - npm
@turf/line-slice. TypeScript icon, indicating that this package has built-in type declarations · Readme · Code Beta · 3 Dependencies · 25 Dependents ...
Read more >Analysis and Calculation of Threshold Pressure Gradient ...
The fluid begins to flow above the pressure gradient matching to this point, which can also be called the threshold pressure gradient. Point...
Read more >A New Methodology for Storing Consistent Fuzzy Geospatial ...
Geographic data are imprecise by nature; their qualifica- ... In most existing databases, users consider data to be precise. ... Each lineCut presents....
Read more >Slam Poetry Part 2 – Frankie's Passion Blog - Sites at Penn State
Far too often today, poetry is stereotyped as being an emotional release for teen girls ... Obviously, these statements are just inaccurate and...
Read more >hafas-find-trips - npm Package Health Analysis | Snyk
Provide location and bearing, get a list of vehicles you're most likely ... Location and bearing are expected to be inaccurate because they ......
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 FreeTop 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
Top GitHub Comments
@stebogit you said this:
The problem is that this is wrong! In particular, the Point C is NOT along LineString L , it is NOT on the line, which is clearly a bug, given that the name of the function is
nearestPointONLINE
.See this comment who expresses the problem clearly https://github.com/Turfjs/turf/issues/1726#issuecomment-527246089
Basically if we have point from “nearestPointOnLine” and check it with “booleanPointOnLine”, we will get “false”…
And this is one aspect of the general problem expressed here https://github.com/Turfjs/turf/issues/1440#issuecomment-768909097
@rowanwins here’s the implementation - it uses [longittude, latatutide] ordering as per the GeoJSON spec and has no dependencies - inputs are coordinates rather than GeoJSON points/lines, but that could easily be changed:
It passes the unit tests in the original code.
Interestingly compared to the Turf implementation here is the difference:
Above implementation results:
Turf
I would assume this means that Turf implementation is trying to find the point on a Great Circle as per the above implementation. The precision on the latitude there concerns me slightly as 0.0003 degrees is probably in the region of 33 meters of error.