Repository navigation
Conversation
Stop distance weighting when a grid point coincides with an input sample. Add regressions for sample order, value sources, weights, and grid types. Fixes Turfjs#2743. Related to Turfjs#1601. AI assistance: OpenAI's assistant prepared this patch and tests.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2743. Related to #1601.
When a grid location exactly matches an input point,
interpolatesets the known value but continues into distance weighting. For positive weights this reachesInfinity / Infinityand returnsNaN.Set the accumulated weight to 1 and stop the inner
featureEachiteration at the first exact match. This follows the approach discussed by cbbeau in #1601 and the early-exit mechanism noted by lemonig in #2743.The regression tests cover the exact match first, middle and last; zero and negative elevations; property precedence over the third coordinate; coordinate fallback; different accepted weights; polygon centroids; input immutability; and missing-value validation. The final tests produce 18 failures against the original implementation and pass after the fix.
Validation
Performed on Linux with Node 24.19.0, pnpm 11.19.0 and TypeScript 6.0.3:
pnpm build,pnpm run docs,pnpm run lintandgit diff --checkpassed; documentation generation made no changestsxreplaced by its supportednode --import tsxlauncherThe standard
pnpm testcommand passed lint but could not start the tsx CLI because the cloud environment blocks its IPC socket. The alternate-launcher result is separate from that blocked command. Node 22/26, live browser execution and benchmarks were not run locally.Behavior notes
An exact input value takes precedence for all currently accepted weights, including zero and negative weights. Conflicting samples at the same coordinates use the first match. Unused later samples are not checked for missing values after early exit; a missing value on the matched sample still raises the existing error.
AI assistance
OpenAI's assistant researched the issue, prepared the code, tests and this description, and executed the checks above. A second AI review checked the patch and suggested additional regression coverage. Submitted as a draft for review.