geostyler / geostyler-cli

BSD 2-Clause "Simplified" License
21 stars 8 forks source link

Is there a way to convert a QML raster style to an OpenLayer Style via cli? #359

Closed aborruso closed 1 year ago

aborruso commented 1 year ago

Hi, I need to create, starting from a qml, something like this in the OL schema:

      style: {
        color: [
          "case",
          ["==", ["band", 2], 0],
          [0, 0, 0, 0],
          ["==", ["band", 1], 0],
          ["color", 31, 119, 180, 1],
          ["==", ["band", 1], 1],
          ["color", 255, 127, 14, 1],
          ["==", ["band", 1], 2],
          ["color", 44, 160, 44, 1],
          ["==", ["band", 1], 3],
          ["color", 214, 39, 40, 1],
          ["==", ["band", 1], 4],
          ["color", 255, 0, 12, 1],
          ["color", 1, 1, 1, 255]
        ]
      }

Is there a way to do it?

Thank you

geographika commented 1 year ago

@aborruso this is currently not supported - see https://github.com/geostyler/geostyler-cli/issues/19 You can convert to MapBox style or SLD and then convert these in a browser application to an OpenLayers style using JS. It could be a useful function though to add in for debugging purposes.

aborruso commented 1 year ago

thank you @geographika

I have used this qml and this command

geostyler -s qml -t mapbox -o style.mpx style.qml

In output I have and empty description

{"version":8,"name":"QGIS Style","layers":[]}

Is it right?

aborruso commented 1 year ago

Does it work for raster styles?

geographika commented 1 year ago

I have used this qml and this command

geostyler -s qml -t mapbox -o style.mpx style.qml

In output I have and empty description

{"version":8,"name":"QGIS Style","layers":[]}

Is it right?

This is the correct syntax. I get the same result as you, so unfortunately this particular QML doesn't seem to be supported. Probably best to open an issue in https://github.com/geostyler/geostyler-qgis-parser/ and review the test cases in https://github.com/geostyler/geostyler-qgis-parser/tree/0d096fd9cfb47c3cb146123fbe209370e50d1ad4/data/qmls

aborruso commented 1 year ago

thank you

aborruso commented 1 year ago

This is the correct syntax. I get the same result as you, so unfortunately this particular QML doesn't seem to be supported. Probably best to open an issue in geostyler/geostyler-qgis-parser

Done, thank you https://github.com/geostyler/geostyler-qgis-parser/issues/492