Turfjs / Turfjs/turf

turf-rhumb-bearing return a valid bearing for coincident points (zero length line)

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

Nobody has claimed this yet.

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

Description

While taking a look at #2475 noticed turf-rhumb-bearing returns a valid bearing for a line of zero length (its points are coincident).

For example, passing the line [5, 5] -> [5, 5] into turf returns a bearing of 0 (North). This doesn't seem quite right. I understand that's what the math spits out. However, logically how can we say this line runs North? Or alternatively that it doesn't run South?

It should be invalid as it can't be determined. As a comparision Geodesy currently includes a specific check for this and returns NaN.

Please provide the following when reporting an issue:

Turf version: 6.5.0
Code snippet: Pass points at [5, 5] and [5, 5] into turf-rhumb-bearing and get a value of 0

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 turf-rhumb-bearing entry point and reproduce the case with points [5, 5] and [5, 5]. Compare the result with the issue's Geodesy reference; done means the coincident-point case is reported as indeterminate rather than as a northward bearing.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
54/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.