Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolate should bail early if an exact distance match is found #2743

Open
KilianB opened this issue Nov 4, 2024 · 2 comments
Open

Interpolate should bail early if an exact distance match is found #2743

KilianB opened this issue Nov 4, 2024 · 2 comments

Comments

@KilianB
Copy link

KilianB commented Nov 4, 2024

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

@smallsaucepan
Copy link
Member

Thanks for raising this @KilianB. Would you mind taking a look at #1601 and seeing how it's related? Are the two issues suggesting the same outcome for different reasons?

@lemonig
Copy link
Contributor

lemonig commented Jan 23, 2025

Thanks for raising this @KilianB. Would you mind taking a look at #1601 and seeing how it's related? Are the two issues suggesting the same outcome for different reasons?

Yeah, Even though the grid points rarely match up exactly with the known points (d === 0),
Nevertheless, the sequence of values is no longer pertinent.because zw / sw will be Infinity /Infinity
it's still an issue and we should break out of the loop. when featureEach function return false will be broken loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants