Turfjs / Turfjs/turf

polygonTangents returns two of the same point

Open
#2,898 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

In certain situations, the function returns two of the same tangent, rather than the two actual tangents.


Reproduction:


const tangents = turf.polygonTangents([
    -79.41285676230808,
    43.627309605975235
], {
    "type": "Feature",
    "properties": {},
    "geometry": {
        "type": "Polygon",
        "coordinates": [
            [
                [
                    -79.428776,
                    43.708224
                ],
                [
                    -79.325734,
                    43.675502
                ],
                [
                    -79.414155,
                    43.595383
                ],
                [
                    -79.353931,
                    43.670969
                ],
                [
                    -79.428776,
                    43.708224
                ]
            ]
        ]
    }
}).features.map((point) => turf.getCoord(point));

console.log(tangents) // [-79.414155,43.595383,-79.414155,43.595383]

For your convenience: https://turf-sandbox.netlify.app/

visualization

Image

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 polygonTangents entry point and run the supplied reproduction to inspect why both returned coordinates are identical. Compare the result with the two actual tangents shown by the visualization; done means this case returns two distinct correct tangent points and is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.