Turfjs / Turfjs/turf

The intersection of two lines is not on these two lines

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

Nobody has claimed this yet.

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

Description

question:
hello, Use the Turf intersection function to calculate the intersection point of two lines, and then use Turf to calculate that the intersection point is not on the two lines.

function inter() {
  const point = turf.lineIntersect(
    {
      type: 'LineString',
      coordinates: [
        [109.97765856266103, 30.90174439429663],
        [109.99221445294349, 30.834370219066155],
      ],
    },
    {
      type: 'LineString',
      coordinates: [
        [109.99221445197468, 30.83437021906627],
        [109.9776585755893, 30.9017443942969],
      ],
    }
  )
  const result1 = turf.booleanPointOnLine(point.features[0], {
    type: 'LineString',
    coordinates: [
      [109.97765856266103, 30.90174439429663],
      [109.99221445294349, 30.834370219066155],
    ],
  })
  const result2 = turf.booleanPointOnLine(point.features[0], {
    type: 'LineString',
    coordinates: [
      [109.99221445197468, 30.83437021906627],
      [109.9776585755893, 30.9017443942969],
    ],
  })
  console.log(result1, result2)
}

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 by running the provided JavaScript example and inspect Turf's lineIntersect and booleanPointOnLine entry points. Reproduce the result with the supplied coordinates, then determine the expected precision behavior for the reported intersection. Done means the behavior is corrected or clearly documented, with coverage for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.