<?xml version="1.0"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>USA states population</Name>
<UserStyle>
<Name>population</Name>
<Title>Population in the United States</Title>
<Abstract>A sample filter that filters the United States into three
categories of population, drawn in different colors</Abstract>
<FeatureTypeStyle>
<Rule>
<Title>< 2M</Title>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">
<ogc:Function name="Interpolate">
<!-- Property to transform -->
<ogc:PropertyName>t_p</ogc:PropertyName>
<!-- Mapping curve definition pairs (input, output) -->
<ogc:Function name="env">
<ogc:Literal>interval1</ogc:Literal>
<ogc:Literal>685430</ogc:Literal>
</ogc:Function>
<ogc:Function name="env">
<ogc:Literal>color1</ogc:Literal>
<ogc:Literal>#06E852</ogc:Literal>
</ogc:Function>
<ogc:Function name="env">
<ogc:Literal>interval2</ogc:Literal>
<ogc:Literal>1000000</ogc:Literal>
</ogc:Function>
<ogc:Function name="env">
<ogc:Literal>color2</ogc:Literal>
<ogc:Literal>#FF0303</ogc:Literal>
</ogc:Function>
<!-- Interpolation method -->
<ogc:Literal>color</ogc:Literal>
<!-- Interpolation mode - defaults to linear -->
</ogc:Function>
</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Title>Boundary</Title>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke-width">0.2</CssParameter>
</Stroke>
</LineSymbolizer>
<TextSymbolizer>
<Label>
<ogc:PropertyName>label</ogc:PropertyName>
</Label>
<Halo>
<Radius>3</Radius>
<Fill>
<CssParameter name="fill">#FFFFFF</CssParameter>
</Fill>
</Halo>
<Font>
<CssParameter name="font-family">Times New Roman</CssParameter>
<CssParameter name="font-style">Normal</CssParameter>
<CssParameter name="font-size">14</CssParameter>
</Font>
<LabelPlacement>
<PointPlacement>
<AnchorPoint>
<AnchorPointX>0.5</AnchorPointX>
<AnchorPointY>0.5</AnchorPointY>
</AnchorPoint>
</PointPlacement>
</LabelPlacement>
</TextSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
The SLD of my layer looks something like this in which i have given two variables minpop
and maxpop
in form of two ogc functions.
In this SLD I am giving values to the variables and those values are taken as parameters in ogc function, but it seems like the ogc function is not working properly.
I have tried not enclosing the env in the literal but the color are still not working? Can you please point out the mistakes in the above SLD?
By enclosing your function in a <Literal>
block you are asking GeoServer to use that as text. Your XML should look like:
<Fill>
<CssParameter name="fill">
<ogc:Function name="Interpolate">
<!-- Property to transform -->
<ogc:PropertyName>POP</ogc:PropertyName>
<!-- Mapping curve definition pairs (input, output) -->
<ogc:Function name="env">
<ogc:Literal>minpop</ogc:Literal>
<ogc:Literal>64000</ogc:Literal>
</ogc:Function>
<ogc:Literal>#06E852</ogc:Literal>
<ogc:Function name="env">
<ogc:Literal>maxpop</ogc:Literal>
<ogc:Literal>100000000</ogc:Literal>
</ogc:Function>
<ogc:Literal>#FF0303</ogc:Literal>
<!-- Interpolation method -->
<ogc:Literal>color</ogc:Literal>
<!-- Interpolation mode - defaults to linear -->
</ogc:Function>
</CssParameter>
</Fill>