turf icon indicating copy to clipboard operation
turf copied to clipboard

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

Open Month7 opened this issue 1 year ago • 0 comments

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));

Month7 avatar Aug 05 '24 13:08 Month7