Hi,
one of the thing that I’m having troubles emulating in CSS is the Rule else filter behavior.
Sometimes what one wants is “do this when no other rules matches this feature”,
and CSS seems to be making my life hard at doing that.
As an example, I have just added an env variable which allows the style to know whether
we are generating KML output as ground overlays or vector output (https://jira.codehaus.org/browse/GEOS-5983).
In SLD I would express it with something like:
Now, I cannot find a way to get that exact representation from a CSS style, but the following two
are functionally equivalent:
- Making a perfect negation of the first expression to control the creation of the red square mark:
[env(‘kmlOutputMode’) = ‘vector’]
{
mark: url('http://maps.google.com/mapfiles/kml/pal4/icon25.png’);
mark-mime: ‘image/png’;
}
[env(‘kmlOutputMode’) <> ‘vector’]
{
mark: symbol(square);
mark-size: 8;
}
:mark [env(‘kmlOutputMode’) <> ‘vector’] {
fill: red;
}
- Try to use cascading somehow:
[env(‘kmlOutputMode’) = ‘vector’]
{
mark: url('http://maps.google.com/mapfiles/kml/pal4/icon25.png’);
mark-mime: ‘image/png’;
mark-size: none;
}
{
mark: symbol(square);
mark-size: 8;
}
:mark {
fill: red;
}
Funny enough, if I do the following instead I don’t end up getting the png icon
in the output style, but two rules with a :
{
mark: symbol(square);
mark-size: 8;
}
:mark {
fill: red;
}
[env(‘kmlOutputMode’) = ‘vector’]
{
mark: url('http://maps.google.com/mapfiles/kml/pal4/icon25.png’);
mark-mime: ‘image/png’;
mark-size: none;
}
:mark [env(‘kmlOutputMode’) = ‘vector’]
{
fill: none;
}
(the last rule is trying to make the engine stop trying to generate a mark,
the result is the same whether it’s there, or not)
Hmmm… anyways, can anybody think of a better way?
Of course the first solution works, but I was hoping for something simpler
Cheers
Andrea
–
==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it