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

Handle NaN as input to a style function or 'interpolate' expression #4172

Closed
lucaswoj opened this issue Feb 1, 2017 · 4 comments
Closed
Assignees
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.)

Comments

@lucaswoj
Copy link
Contributor

lucaswoj commented Feb 1, 2017

From @kronick on January 19, 2017 21:38

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: #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.

Copied from original issue: mapbox/mapbox-gl-style-spec#657

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Feb 1, 2017

From @jfirebaugh on January 19, 2017 22:18

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.

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Feb 1, 2017

From @kronick on January 20, 2017 1:23

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

@1ec5 1ec5 added the cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) label Feb 3, 2017
@jfirebaugh
Copy link
Contributor

@kronick This is unblocked now if you want to pick it up.

@kronick
Copy link

kronick commented Feb 6, 2017

@jfirebaugh great! I'll get on it some time this week

@anandthakker anandthakker changed the title Handle NaN as input to a style function Handle NaN as input to a style function or expression Nov 27, 2017
@anandthakker anandthakker changed the title Handle NaN as input to a style function or expression Handle NaN as input to a style function or 'interpolate' expression Nov 27, 2017
@anandthakker anandthakker self-assigned this Nov 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.)
Projects
None yet
Development

No branches or pull requests

5 participants