geostyler / geostyler-mapbox-parser

GeoStyler-Style-Parser implementation for Mapbox
BSD 2-Clause "Simplified" License
14 stars 10 forks source link

Reading non-hex Colors #316

Open jansule opened 9 months ago

jansule commented 9 months ago

Bug

Describe the bug

If a color value is not an expression, we currently simply pass the color value of a mapbox-style as-is to the geostyler-style. However, these values might come in the format of rgba(r, g, b, a), whereas geostyler-style expects hex-values. So we have to check for those values and replace them with their hex-color value in order for geostyler to work as expected.

Expected behavior

Color values that are not hex-colors should be replaced with hex-colors when reading a mapbox style.

Example mapbox-style with rgba color values.

 {
      "id": "boundaries",
      "type": "fill",
      "source": "terrestris_boundaries",
      "source-layer": "vector_osm_world_boundaries",
      "layout": {"visibility": "visible"},
      "paint": {
        "fill-color": "rgba(255, 255, 255, 0.82)",
        "fill-outline-color": "rgba(0, 0, 0, 1)",
        "fill-opacity": 1
      }
    },