lineIntersect does not find an intersection for two lines that share the same endpoint

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

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Domain
data

Research direction

Start by locating the lineIntersect implementation and reproducing the supplied lineString case where the segments share an endpoint. Inspect how endpoint intersections are handled, then verify that the result includes the shared coordinate and that existing intersection behavior remains intact.

Written by the indexing model from the issue text.

Description

@turf/line-intersect

Please provide the following when reporting an issue:

  • [turf7 ] The version of Turf you are using, and any other relevant versions.
  • [wrong.json] GeoJSON data as a gist file or geojson.io (filename extension must be .geojson).
  • [ done] Verify this issue hasn't already been reported, or resolved in the latest alpha pre-release.

my geoJson

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            116.388349,
            39.949004
          ],
          [
            116.409595,
            39.900803
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
          "type": "LineString",
          "coordinates": [
              [
                  116.409595,
                  39.900803
              ],
              [

                  116.447661,
                  39.896049
              ]
          ]
      }
  }
  ]
}

The two lines have an approximate intersection point, but I cannot get the intersection point using lineIntersect.

image

my code

  const line1 = lineString([
    [
      116.352264,
      39.86083
    ],
    [
      116.507446,
      39.931158
    ]
  ]);
  const line2 = lineString([[
    116.507446,
    39.931158
  ],
  [
    116.525642,
    39.959058
  ]
  ]);
  console.log('res', lineIntersect(line1, line2));

Dominant language
TypeScript
Stars
10.5k
Forks
1k
Avg merge
1h 11m
Merged PRs (30d)
4

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.

More from Turfjs/turf

All issues in Turfjs/turf

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.