Turfjs / Turfjs/turf

Include current bearing at point returned from @turf/along

Open
#1,982 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I find that often when I call turf.along I also need the angle of the given point along the line (for instance, if animating an icon along a line, you want it to rotate to face the direction of travel).

There's no convenient way to compute that angle: you can use turf.bearing, but you have to compute a point slightly forward and slightly behind the point (two more calls to turf.along), and handle the cases where you're very close to the end of the line.

Either of these would be great:

  • turf.along could provide that bearing as a property on the feature (maybe an optional flag, so the computation doesn't happen if it's not needed)
  • a convenient turf.bearingAt method, taking a point and a line and returning the angle
  • or maybe adding an extra property to the return value of turf.nearestPointOnLine, to include the angle of the line at that nearest point.

Thoughts?

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 reading the @turf/along and @turf/nearestPointOnLine entry points named in the issue, then inspect how their returned features and properties are tested. Done requires choosing and documenting one bearing API, implementing it consistently, and adding coverage for points along a line, including positions near its end.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.