Skip to content

Only evaluate CrossFaded properties at integer zooms - #6430

Merged
mollymerp merged 4 commits into
masterfrom
validate-nonint-crossfade
Apr 13, 2018
Merged

mollymerp merged 4 commits into
masterfrom
validate-nonint-crossfade

Conversation

@mollymerp

Copy link
Copy Markdown
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

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

mollymerp commented Apr 10, 2018 •

Copy link
Copy Markdown
Contributor Author

@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 🤦‍♀️

Comment thread src/style-spec/reference/v8.json Outdated
"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
Copy Markdown
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
Copy Markdown
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
@lbud lbud mentioned this pull request Apr 12, 2018
4 tasks done
@mollymerp
mollymerp force-pushed the validate-nonint-crossfade branch from 617bb68 to 09e7894 Compare April 13, 2018 19:17
@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