Developer’s Corner: Bridging CSS and SLD unit of measure treatment in GeoServer
in this blog we are introducing some work with did to bridge the unit of measure treatment in SLD and CSS. The beginning of the blog is a bit technical, so if you want to just get the news, skip towards the map screenshots.
Unit of measure treatment in CSS is rather straightforward, every size is in pixel, unless otherwise specified by appending a unit of measure to it. In GeoServer geospatial CSS design there are three unit of measure, meter (m), feet (ft) and pixels (px), for example, say we want to have a circular mark, whose size is 2 meters, but whose outline is always 1 pixel, regardless of the zoom:
Generally speaking, every property is free to have a different unit of measure. That’s nice, too bad it does not work in the current CSS support, more on this later.
How does this compare with the SLD unit of measure model? Well, in SLD 1.0 there is no official support for unit of measure (although GeoServer support the same syntax as SLD 1.1 as an extension).
In SLD 1.1 the unit of measure can be specified only at the whole symbolizer level, with a twist: if one property inside that symbolizer needs to be expressed in pixels, then it’s valid to append the px suffix to it.
So the above CSS style could be roughly translated to:
- It makes the CSS translation un-necessarily complex
- Being able to overload the current unit of measure requires a some code to make it just for pixels, and just a little more to make it available also for meters and feets
Here are some example outputs using the usual bugsites demo layer:
Ok, so, long story short: it’s now possible to specify per property unit of measure in both CSS and SLD by adding the “m”, “ft” and “px” suffixes!
This new feature is now available in the development series nightly builds.
If you’d like to know more about what you could achieve with us, do not hesitate and get in touch with us. If you need professional services to get started with Open Source software make sure to have a look at our GeoSolutions Enterprise Services.
The GeoSolutions team,