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

Why Geostyler IconSymbolyzer size is parsed as Ol Icon scale? #624

Closed
pragmaeuge opened this issue Oct 14, 2022 · 4 comments
Closed

Why Geostyler IconSymbolyzer size is parsed as Ol Icon scale? #624

pragmaeuge opened this issue Oct 14, 2022 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@pragmaeuge
Copy link
Contributor

Question

Why Geostyler IconSymbolyzer size is parsed as Ol Icon scale?

Maybe Ol Icon imgSize should be preferred?

 /**
   * Get the OL Style object  from an GeoStyler-Style IconSymbolizer.
   *
   * @param symbolizer  A GeoStyler-Style IconSymbolizer.
   * @return The OL Style object
   */
  getOlIconSymbolizerFromIconSymbolizer(symbolizer: IconSymbolizer, feat?: OlFeature): OlStyleIcon | OlStyleFunction {
    for (const key of Object.keys(symbolizer)) {
      if (isGeoStylerFunction(symbolizer[key])) {
        symbolizer[key] = OlStyleUtil.evaluateFunction(symbolizer[key], feat);
      }
    }

    const baseProps = {
      src: symbolizer.image,
      crossOrigin: 'anonymous',
      opacity: symbolizer.opacity,
      scale: symbolizer.size || 1,
      // Rotation in openlayers is radians while we use degree
      rotation: typeof(symbolizer.rotate) === 'number' ? symbolizer.rotate * Math.PI / 180 : undefined,
      displacement: symbolizer.offset
    };
@pragmaeuge pragmaeuge added the question Further information is requested label Oct 14, 2022
@jansule
Copy link
Contributor

jansule commented Oct 17, 2022

According to the OpenLayers API, imgSize is only applicable when using the img instead of the src property of ol/style/Icon. In our parser, we use src, since we usually provide a URL to an image.

We also have a closed PR (#549) that was trying to make use of the size property, which was closed since it did not scale, but rather cut the image.

Unfortunately this approach is not working as i didn't read the API-Docs of OpenLayers carefully enough.
The size property does not shrink or grow the selected image but cut a piece out of it...

source: #549 (comment)

@jnewmoyer
Copy link

jnewmoyer commented Nov 4, 2022

We are also seeing this issue where basically icon sizes are being scaled up dramatically. So if you set size to 1, the icon is displayed at its normal size (size of the image file) and no scaling, but if you go higher than 1, the size increases in an exponential factor.

I feel like this line should say scale: symbolizer.scale || 1:
https://github.com/geostyler/geostyler-openlayers-parser/blob/master/src/OlStyleParser.ts#L1125

@KaiVolland
Copy link
Contributor

KaiVolland commented Dec 9, 2022

openlayers/openlayers#14364 is now merged and we are able to adapt the geostyler-openlayers-parser with the next openlayers release. Until then we could remove the parsing of symbolizer.size and add it to the unsupportedProperties.

Any volunteers for a PR? 🙂

@KaiVolland
Copy link
Contributor

Thix should be fixed with the latest release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants