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

Add $meters_per_pixel keyword for filters and JS functions #2144

Merged
merged 3 commits into from
Feb 8, 2020

Conversation

matteblair
Copy link
Member

  • Add the $meters_per_pixel keyword, determine its value from the current zoom in StyleContext, and make it accessible to filter expressions and JS functions.
  • Clean up the logic for keywords in StyleContext - setting arbitrary keywords is no longer supported.
  • Updated tests for changes to StyleContext and added a case using $meters_per_pixel in a JS function.

Resolves #2138

@matteblair matteblair force-pushed the keyword-meters-per-pixel branch from 1a54e09 to 2638131 Compare February 8, 2020 20:31
@matteblair matteblair merged commit 78c2d2e into master Feb 8, 2020
@matteblair matteblair deleted the keyword-meters-per-pixel branch February 8, 2020 21:53
@westnordost
Copy link
Contributor

Very cool! :-D

Could it be that with this change, you also changed unintentionally or not the $zoom keyword from an int value to a float value?

@matteblair
Copy link
Member Author

The variable that provides the value of $zoom was changed from an int to a double to reduce casting, but it still holds an integer value (because filters and styling functions are only applied at integer zoom levels).

@westnordost
Copy link
Contributor

westnordost commented Feb 9, 2020 via email

@matteblair
Copy link
Member Author

Yes. Filters and styling functions are evaluated on features once, using the zoom level of the tile that contains them.

@westnordost
Copy link
Contributor

Oh, too bad, so the use case I had in mind for this will not work (#1121)

westnordost referenced this pull request in streetcomplete/streetcomplete-mapstyle Jun 2, 2020
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.

Support for $meters_per_pixel
2 participants