turf icon indicating copy to clipboard operation
turf copied to clipboard

lineOverlap does not recognize partially overlaps

Open jsiedentop opened this issue 1 year ago • 1 comments

The lineOverlap function currently does not recognize when two lines partially overlap. This also affects booleanOverlap.

You can see it in this example: The blue and red lines clearly overlap in the green area. However, this is not recognized because the implementation can currently only recognize an overlap if a segment is completely overlapping.

image
  • Example on geojson.io
  • Playground on jsfiddle
  • GeoJson:
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "stroke": "#0F0",
        "fill": "#0F0",
        "stroke-width": 25
      },
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [120, -25],
          [150, -25]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "stroke": "#F00",
        "fill": "#F00",
        "stroke-width": 10,
        "stroke-opacity": 1,
        "fill-opacity": 0.1
      },
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [120, -25],
          [160, -25]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "stroke": "#00F",
        "fill": "#00F",
        "stroke-width": 3,
        "stroke-opacity": 1,
        "fill-opacity": 0.1
      },
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [110, -25],
          [150, -25]
        ]
      }
    }
  ]
}

jsiedentop avatar Feb 24 '24 01:02 jsiedentop

This issue could possibly be solved with #2349. By the way, I noticed it because the test case from #901 is passing only due to the generous tolerance and it is actually a false positive.

jsiedentop avatar Feb 26 '24 12:02 jsiedentop