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

Expressions / add geometry-type operator, fix exponential interpolate #14837

Merged
merged 2 commits into from
Jun 17, 2023

Conversation

jahow
Copy link
Contributor

@jahow jahow commented Jun 16, 2023

This PR:

  • adds a new geometry-type operator; this operator returns the current geometry type of the feature, either Point, Polygon or LineString; other types (multi*, collections) are resolved to one of these three (see doc)
  • reworks the interpolate computation when the interpolation type is exponential; the computation is now compliant with the MapBox style spec and allows for example scaling values according to the current zoom using ['exponential', 2]. The linear interpolation is unchanged.

Note: the change on the interpolate operator can be considered as breaking since any style using it might notice a difference in the final result. The difference can be quite significant depending on the range. Here is a visual representation of the curve before and after for an interpolation of type ['exponential', 2], input range 5..15, output range 0..100:

Before:
image

After:
image

On the other hand it is now compliant to the reference implementation so this can also be considered as fixing an erroneous behavior.

@github-actions
Copy link

📦 Preview the website for this branch here: https://deploy-preview-14837--ol-site.netlify.app/.

The way the interpolation used to work was not compliant with the reference
implementation seen here:
https://github.com/maplibre/maplibre-style-spec/blob/5c4b8b62f01ed4bea4fa4c6f0853c6bd58aa3d71/src/expression/definitions/interpolate.ts#L230-L241

This has been fixed and now allows having primitives with a fixed size in world
coordinates by using an exponential interpolation with a base of 2. This is
showcased in the webgl-points-layer
Copy link
Member

@tschaub tschaub left a comment

Choose a reason for hiding this comment

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

Looks great, @jahow

@jahow jahow merged commit b80fc19 into openlayers:main Jun 17, 2023
@jahow jahow deleted the add-get-type-operator branch June 17, 2023 06:12
@jahow
Copy link
Contributor Author

jahow commented Jun 17, 2023

thanks for the quick review @tschaub!!

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.

2 participants