Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.

Handle NaN as input to a style function #657

Closed
kronick opened this issue Jan 19, 2017 · 3 comments
Closed

Handle NaN as input to a style function #657

kronick opened this issue Jan 19, 2017 · 3 comments
Assignees

Comments

@kronick
Copy link
Contributor

kronick commented Jan 19, 2017

Right now the binary search I wrote for style function interpolation will go into an infinite loop if passed a NaN as input. I think @lucaswoj fixed this for most use cases by validating stops in the style json before they are passed to interpolated().

But this check is not performed for other uses of this module (as would be desired to get rid of custom color interpolation code in https://www.mapbox.com/mapbox-gl-js/example/data-join/ . See also: mapbox/mapbox-gl-js#4018). I have hit this problem in my own use of this function, and am now just checking isNaN() myself, but since the failure mode is an infinite loop I feel we should offer a better answer.

What should interpolated() return if passed a NaN? The value of the first stop (as is the default case in categorical functions)? The value of the last stop (as it looks like the old search would have done)? Throw an error? Something else?

I can update the function once I get some advice on what the desired output should be.

@kronick kronick self-assigned this Jan 19, 2017
@jfirebaugh
Copy link
Contributor

I think this falls under the same category as #588, and should have the same behavior as whatever we decide there -- probably, return undefined, until there's some means of specifying a fallback result as in #480.

@kronick
Copy link
Contributor Author

kronick commented Jan 20, 2017

@jfirebaugh Thanks-- I'll stand by until a decision is made there

@lucaswoj
Copy link

lucaswoj commented Feb 1, 2017

This issue was moved to mapbox/mapbox-gl-js#4172

@lucaswoj lucaswoj closed this as completed Feb 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants