geostyler / geostyler-openlayers-parser

GeoStyler Style Parser implementation for OpenLayers styles
BSD 2-Clause "Simplified" License
38 stars 29 forks source link

Scale dependency being ignored on TextSymbolizer #321

Open jnewmoyer opened 3 years ago

jnewmoyer commented 3 years ago

Bug

Describe the bug Converting from SLD to OpenLayers style, my labels are showing at all zoom levels, even though the SLD uses a max scale denominator.

To Reproduce Steps to reproduce the behavior:

  1. Create an SLD with a label style and max scale denom
  2. Convert the style to geostyler and then to OpenLayers
  3. Style a vector layer with the OL style.

Expected behavior the labels appear only at scales inside of 1:5M.

Desktop (please complete the following information):

Additional context

The geostyler rule after converted:

{
      "name": "Labels",
      "scaleDenominator": {
        "max": 5000000
      },
      "symbolizers": [
        {
          "kind": "Text",
          "label": "{{title}}",
          "color": "#ffffff",
          "haloWidth": 1,
          "haloColor": "#000000",
          "offset": [
            0,
            10
          ],
          "size": 19,
          "font": [
            "SansSerif.bold"
          ],
          "fontStyle": "normal",
          "fontWeight": "bold"
        }
      ]
    }
jansule commented 3 years ago

Thanks for the info @jnewmoyer.

Which projection are you using on your map client?

jnewmoyer commented 3 years ago

EPSG:4326

jansule commented 3 years ago

Could you check if it works for you in EPSG:3857?

EPSG:4326 uses degrees as units. Currently, geostyler-openlayers-parser assumes metric units (https://github.com/geostyler/geostyler-openlayers-parser/blob/master/src/OlStyleParser.ts#L537). Adding a switch 'm' / 'degrees' for the second argument there might solve your problem.

Would you like to create a PR for that?

jnewmoyer commented 3 years ago

Absolutely. Stand by...

KaiVolland commented 6 months ago

Seems like you could fix the issue @jnewmoyer. If not please reply or reopen.

jnewmoyer commented 6 months ago

Apologies for never getting to the PR. I don't believe this is fixed though. It seems like scale is always evaluated with Meters in mind: https://github.com/geostyler/geostyler-openlayers-parser/blob/78c9ee318bec348a9c4cd6da1b5d8c192f12c225/src/OlStyleParser.ts#L772

KaiVolland commented 6 months ago

Ok. Thanks for keeping this alive. I was just in tabula rasa mode. :smile: