Turfjs / Turfjs/turf

booleanIntersects returns false for LineStrings that share a point

Open
#2,250 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

@turf/boolean-intersects
Dominant language
TypeScript
Stars
10.5k
Forks
1k
Avg merge
1h 11m
Merged PRs (30d)
4

Description

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
            ]
         ]
      }
   }
]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the booleanIntersects implementation and reproduce the issue with the supplied LineString coordinates, comparing them with the second example that returns true. The fix is complete when LineStrings sharing the reported endpoint are recognized as intersecting and the existing behavior is preserved for the comparison case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.