<?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>
我的图层的SLD看起来像这样,我用两个ogc函数的形式给出了两个变量minpop和maxpop 在这个sld我给变量值,这些值作为ogc函数中的参数,但似乎ogc函数不能正常工作在这个sld我给变量的值,这些值作为参数在ogc中功能,但似乎ogc功能无法正常工作
我试过不把文字封在文字中,但颜色仍然没有用?你能指出上述SLD中的错误吗?
答案 0 :(得分:1)
通过将您的函数封装在<Literal>
块中,您要求GeoServer将其用作文本。您的XML应如下所示:
<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>