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

Only evaluate CrossFaded properties at integer zooms #6430

Merged
merged 4 commits into from
Apr 13, 2018

Conversation

mollymerp
Copy link
Contributor

fixes #6390

⚠️ this might be a breaking change for some people even though it is also a bug fix

question: should we have a style spec field that indicates if the property is cross-faded or not to avoid having to hard code the property name string check?

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

@@ -18,5 +18,12 @@ export default function validateExpression(options: any) {
return [new ValidationError(options.key, options.value, 'Invalid data expression for "text-font". Output values must be contained as literals within the expression.')];
}

if (options.expressionContext === 'property' && expression.value.kind === 'camera' && options.propertyKey.match(/(-pattern)|(-dasharray)/)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be slightly clearer to explicitly list all the properties this applies to instead of using a regular expression?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's another case where #6389 (specifically #6389 (comment)) would help.

@jfirebaugh
Copy link
Contributor

I'm slightly worried about the consequences of changing this. We had at least one case where we made validation stricter in a similar area and later had to roll it back because existing styles stopped working (mapbox/mapbox-gl-style-spec#413).

@jfirebaugh
Copy link
Contributor

Other prior history in #4147 -- this would be a partial revert of that change. Maybe the erroneous behavior in #6390 was part of the "original rationale" that I couldn't remember.

@anandthakker
Copy link
Contributor

then we also can (and, I think, should) address this by making sure that in CrossFadedProperty#possiblyEvaluate, we only evaluate the expression at integer zoom levels

@mollymerp is the above correct? If so, and we want to avoid risking breaking existing styles, we could just do that instead.

@mollymerp
Copy link
Contributor Author

mollymerp commented Apr 10, 2018

@jfirebaugh good point – definitely don't want to break existing styles.

@anandthakker yes, we can take this approach and it will be less strict – is possiblyEvaluate the right place for that clamping or would we want to clamp the stops on parsing into expressions? the difference being that parameters.zoom in possiblyEvaluate is the current camera zoom, not bucket zoom. nevermind the output is the same either way 🤦‍♀️

@@ -2965,7 +2965,7 @@
"function": "piecewise-constant",
"zoom-function": true,
"transition": true,
"doc": "Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).",
"doc": "Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that this property does not support zoom-dependent expressions with non-integer zoom inputs.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe reword to: "Note that zoom-dependent expressions will be evaluated only at integer zoom levels."?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 yep that's more concise.

@mollymerp mollymerp changed the title Disallow non-integer zoom stops for crossfaded properties Only evaluate CrossFaded properties at integer zooms Apr 10, 2018
@mollymerp mollymerp force-pushed the validate-nonint-crossfade branch 2 times, most recently from 6e162e9 to 617bb68 Compare April 10, 2018 17:46
@mollymerp mollymerp merged commit 9090d10 into master Apr 13, 2018
@mollymerp mollymerp deleted the validate-nonint-crossfade branch April 13, 2018 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect cross-fading at non-integer zoom levels
4 participants