Skip to content
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

lineOverlap tolerance is not handled in every case #2582

Open
jsiedentop opened this issue Feb 26, 2024 · 0 comments
Open

lineOverlap tolerance is not handled in every case #2582

jsiedentop opened this issue Feb 26, 2024 · 0 comments

Comments

@jsiedentop
Copy link

The current implementation splits thepassed features into lineStrings. Then, for each segment in feature2, rbush is used to search whether there are overlapping points to a segment from feature1. In principle, at least one point must lie within the bounding box of a feature1 segment. The bug is, that the tolerance parameter passed is not taken into account here.

Even if two segments are very close to each other and run parallel, no overlapping would be detected even if a generous tolerance value was selected.

In TurfDart, I have chosen the approach of increasing the bounding box by the tolerance. This allows us to find all segments that lie within the specified tolerance. For details see: line_overlap.dart

In this example, I have two LineStrings that run parallel to each other. The distance is 11.4km and if you pass a tolerance of 12km, I think lineOverlap should return a result. Admittedly the distance is quite long, the example is for demonstration purposes and also works at distances of a few meters.

image

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "stroke": "#0F0",
        "fill": "#0F0",
        "stroke-width": 25
      },
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            10,
            0
          ],
          [
            11,
            0
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "stroke": "#F00",
        "fill": "#F00",
        "stroke-width": 10,
        "stroke-opacity": 1,
        "fill-opacity": 0.1
      },
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            10,
            0.1
          ],
          [
            11,
            0.1
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "stroke": "#00F",
        "fill": "#00F",
        "stroke-width": 3,
        "stroke-opacity": 1,
        "fill-opacity": 0.1
      },
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            10,
            0
          ],
          [
            11,
            0
          ]
        ]
      }
    }
  ]
}
@smallsaucepan smallsaucepan changed the title @turf/turf-line-overlap tolerance is not handled in every case lineOverlap tolerance is not handled in every case Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants