Archive

Tag Archives: SLD

The upcoming 1.8 release contains many new features for handling layer styles.

Copy-paste Styles

Very handy new entries in the layer list context menu: “Copy Style” and “Paste Style” make copying layer styles really fast. You don’t even have to open layer properties anymore.

SLD Support

Besides the classic QML layer style files, QGIS 1.8 supports the SLD standard. SLDs can be exported from and imported into new symbology.

One thing worth to note: SLDs can be exported from any type of renderer: single symbol, categorized, graduated or rule-based, but when importing an SLD, either a single symbol or rule-based renderer is created.

That means that categorized or graduated styles are converted to rule-based. If you want to preserve those renderers, you have to stick to the QML format. On the other hand, it could be very handy sometimes to have this easy way of converting styles to rule-based.

Symbol Levels

If you are looking for the “Symbol level” settings, they have been moved to the “Advanced” button:

Rule-based Renderer

The rule-based renderer GUI got a major face-lift. Just compare the 1.7 version

Rule-based renderer GUI in 1.7

to the new clean 1.8 version:

Rule-based renderer in 1.8

Grouping of styles has been overhauled too: Using drag-and-drop, layers can be arranged into groups in a more flexible manner than previously possible.

There is also a new context menu which enables workflows such as changing the transparency of multiple symbols at once:

Symbol levels for the rule-based renderer can now be accessed via “Rendering order”.

It’s obvious that a lot of work has been put into style handling since the 1.7 release and these improvements are just a small fraction of what’s been done to get closer to the big goal: releasing 2.0.

Advertisement

It sounds incredible, but it’s true: OGC Filter Encoding in it’s current version 1.1 lacks an IN operator [1]. Combining multiple PropertyIsEqualTo using ORs performs really badly both on Arcgis Server [2] and Geoserver [3]. That calls for the implementation of this standard-exceeding IN operator. Maybe PropertyIsIn?

[1] http://www.opengeospatial.org/standards/filter
[2] http://viswaug.wordpress.com/2009/01/20/filter-encoding-standard-11-and-the-curious-case-of-the-missing-in-operator/
[3] https://underdark.wordpress.com/2010/06/10/dynamic-styling-and-filtering-of-a-geoserver-wms-using-openlayers-layer-wms-post/

There is a new layer class in OpenLayers API: OpenLayers.Layer.WMS.Post [1]. – Great work!

While the “normal” OpenLayers.Layer.WMS class requests maps via HTTP GET, this new class sends the request via HTTP POST. This way, we can now send big client-side created SLD files in our GetMap requests that used to exceed size limits of GET.

This code snippet shows the basic use of OpenLayers.Layer.WMS.Post with a client-side created SLD. You’ll need at least OpenLayers 2.9 to test this on your server. (A full example can be found at http://www.openlayers.org/dev/examples/wms-long-url.html)

var sld = 'define your SLD here';

wms = new OpenLayers.Layer.WMS.Post(
  "name",
  "http://localhost:8080/geoserver/wms",
  {
    'layers': 'myNs:layername',
    format: 'image/jpeg',
    sld_body: sld
  },
  {
    unsupportedBrowsers: []
  }
);

Setting unsupportedBrowsers to an empty list is important! This list by default contains [“mozilla”, “firefox”, “opera”]. These browsers support long GET requests so the developers argued that these browsers wouldn’t need to use POST. Well, turns out that they do ;)

I performed a small stress test using an SLD with approximately 1,000 rules being applied on a big city road network. While my browser would willingly send a GET request of that size, Apache doesn’t want to accept it. So, I tried the POST way and it turns out that it really works! (But it’s slow, very slow …)

Thanks to the developers for yet another great feature!

[1] http://trac.openlayers.org/ticket/2224

%d bloggers like this: