I am trying to pass my fill parameter for GeoServer SLD and I am using SVG, found some reference from here GeoServer filter , but getting below error, also sharing the working code where I tried to make rule with and filter
This sample svg can be use here, with any sample data which have two attributes here in my case act_id
and structure_type
This one will create dynamic fill value depending upon property value
<Rule>
<Name>Cement Nala Bunds</Name>
<Filter>
<PropertyIsEqualTo>
<PropertyName>act_id</PropertyName>
<Literal>305</Literal>
</PropertyIsEqualTo>
</Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="nrm_styles/KTW.svg?fill=${if_then_else(structure_type == 'existing', '#cfcccc', '#84fa8d')}" />
<Format>image/svg+xml</Format>
</ExternalGraphic>
<Size>
<Literal>20</Literal>
</Size>
</Graphic>
</PointSymbolizer>
</Rule>
This one is working which will be forced to make seperate rule for each condintion which will be repeatable
<Rule>
<Name>Cement Nala Bunds</Name>
<Filter>
<And>
<PropertyIsEqualTo>
<PropertyName>act_id</PropertyName>
<Literal>305</Literal>
</PropertyIsEqualTo>
<PropertyIsEqualTo>
<PropertyName>structure_type</PropertyName>
<Literal>existing</Literal>
</PropertyIsEqualTo>
</And>
</Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource xlink:type="simple" xlink:href="nrm_styles/KTW.svg?fill=#84fa8d" />
<Format>image/svg+xml</Format>
</ExternalGraphic>
<Size>
<Literal>20</Literal>
</Size>
</Graphic>
</PointSymbolizer>
</Rule>
Error
java.lang.illegalArgumentException: Invalid cql expression 'if_then_else(structure_type == 'existing', '#cfcccc', '#84fa8d')'
Invalid cql expression 'if_then_else(structure_type == 'existing', '#cfcccc', '#84fa8d')'
Encountered "==" at line 1, column 29.
was expecting one of:
")"...
"."...
":"...
"*"...
"+"...
<IDENTIFIER>...
"("...
Parsing : 'if_then_else(structure_type == 'existing', '#cfcccc', '#84fa8d')'
Also trying same thing in CSS module using recode and dynamic url as suggested by previous question
/* @title Cement Nala */
[act_id = 305] {
mark: url('KTW.svg?fill=#cfcccc');
mark-mime: "image/svg+xml";
mark-size: 20;
}
/* @title Cement Nala Bund */
[act_id = 322] {
mark: url('${if_then_else(structure_type=existing, KTW.svg?fill=#cfcccc, KTW.svg?fill=#ff0000)}');
mark-mime: "image/svg+xml";
mark-size: 20;
}
/* @title Cement Nala Bund */
[act_id = 322] {
mark-size: 20;
:mark {
url: [
recode(structure_type,
'existing','KTW.svg?fill=#ff0000',
'proposed','KTW.svg?fill=#ff9933'
)]
};
mark-mime: "image/svg+xml";
}