Monday, November 1, 2010

uDig styles and filters

When it comes to filters in SLD it gets really hairy. Filters can be really everything, from an constant value to a complex nested operation on properties. It is one of those things with superpowers but also scary when it comes to the moment to create a gui for it.

So what we decided to do for now, is to expose the pieces of xml that represents the filter part in a rule. Sure it is only for the brave, but even if you do not edit it, you can at least get some useful info out of it.

Let's for example start with a themed style with only two classes:

if you go to the simple polygon style panel now, you will find a new tab, which states Filter. Inside that you now find the current filter definistion (if one is in).

In this case it gets how the themed styles work, right? As highlighted in the following screenshot, the filter states that the first rule is applied if:
* the property POP_CNTRY >= 0
* the property POP_CNTRY < 50000

That is how themed style works. A set of rules is created with filters in a row.

You may have noticed that some countries have disappeared in the previous image. That is because in the previous image I changed the upper limit of the first rule to 50000, while it was different in the first screenshots.

So you really can modify the filter as you which. You have then to make sure you push the Apply Filter button. At that point the filter will replace the previous filter in the style.

Just to give you one more example of what you can do, here is how normalization works. Imagine you want to style the population attribute, but normalized on the area, so that it gives a better idea of population density. That is how to change the filter for it:

What you are saying now is that the first rule is applied if:
* the property POP_CNTRY divided by the property SQKM is >= 0
* the property POP_CNTRY divided by the property SQKM is < 58.513

One last hint though. Don't do this by hand, in uDig for doing normalization we have a button on the themed style page :)
Post a Comment