turf
turf copied to clipboard
booleanIntersects returns false for LineStrings that share a point
I'm using turf version 6.5.0.
booleanIntersects returns false for the following 2 LineStrings although they share a point:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.3930069,
52.5275117
],
[
13.3928956,
52.5274816
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
13.392838775,
52.527573275
],
[
13.3928956,
52.5274816
]
]
}
}
]
}
Gist: http://geojson.io/#id=gist:mschilde/fc89dc38b2fd81d1e80add4fa93f34c9&map=22/52.52753/13.39292
Other touching LineStrings that also share a point are treated as intersecting and booleanIntersects returns true, e.g.
[
{
"type":"Feature",
"properties":{ },
"geometry":{
"type":"LineString",
"coordinates":[
[
13.3930069,
52.5275117
],
[
13.3928956,
52.5274816
]
]
}
},
{
"type":"Feature",
"properties":{},
"geometry":{
"type":"LineString",
"coordinates":[
[
13.3927809,
52.5274499
],
[
13.3928956,
52.5274816
]
]
}
}
]
I suspect this is a floating point math error coming from https://github.com/Turfjs/turf/blob/fcdaa939c905e6cfa80cca11a0e7cbb851ad1a47/packages/turf-boolean-disjoint/index.ts#L150-L174
This could possibly be rewritten with the robust-predicates library