Turfjs / Turfjs/turf

Interpolate should bail early if an exact distance match is found

Open
#2,743 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Is there a logic error in the fast path of the following code? If the certeroid in interpolate is an exact match zw is set to the value of the feature but the forEach loop is not aborted.

This means that we should have a different result depending on which order the points are checked. If the point is found at the end of the feature set the zValue will be taken from the feature, if it's one of the first points it would just be accounted for as normal.

https://github.com/Turfjs/turf/blob/1dec2f2474ba37ca3cb40e492ba85f70aecd055a/packages/turf-interpolate/index.js#L94C1-L95C1

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 linked fast-path code in packages/turf-interpolate/index.js around lines 94–95 and inspect how an exact distance match is handled inside the forEach loop. Verify the behavior with points in different orders, then confirm that an exact match consistently determines the result.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.