1

我遇到了 GeoServer SLD XML 的问题。

我的 XML 代码如下:

<Fill>
    <CssParameter name="fill">
        <ogc:Function name="if_then_else">
            <ogc:Function name="isNull">
                <ogc:PropertyName>LTE_RSRP</ogc:PropertyName>
            </ogc:Function>
            <ogc:Literal>#FF0000</ogc:Literal>
            <ogc:Function name="Interpolate">

                <ogc:PropertyName>LTE_RSRP</ogc:PropertyName>

                <ogc:Literal>-80</ogc:Literal>
                <ogc:Literal>#ff0000</ogc:Literal>

                <ogc:Literal>-70</ogc:Literal>
                <ogc:Literal>#00ff00</ogc:Literal>

                <ogc:Literal>-60</ogc:Literal>
                <ogc:Literal>#0000ff</ogc:Literal>

                <ogc:Literal>color</ogc:Literal>

            </ogc:Function>
        </ogc:Function>
    </CssParameter>
    <CssParameter name="fill-opacity">0.3</CssParameter>
</Fill>

我的意图如下:

  • 如果 LTE_RSRP 为空,则填写#FF0000。
  • 否则,插入颜色。

但是当应用上述 XML 时,会出现以下错误。

ERROR [geotools.rendering] - Filter Function problem for function if_then_else argument #2 - expected type Object

这里,参数 #2 是函数 Interpolate。(参数计数从0开始,根据geotools源代码。)看起来函数Interpolate的返回值不是一个对象。

这是故意的吗?还是我做错了什么?

4

1 回答 1

0

这是故意的 - 插入颜色图的函数如何返回对象?您想要做的事情可以使用规则和过滤器来完成,所以像这样的东西(未经测试)应该可以工作:

<Rule>
<ogc:Filter>
    <ogc:PropertyIsNull>
       <ogc:PropertyName>LTE_RSRP</ogc:PropertyName>
    </ogc:PropertyIsNull>
</ogc:Filter>
  <ogc:PolygonSymbolizer>
   ....
   <Fill>
      ....
 </Rule>
 <Rule>
   <ElseFilter/>
   <PolygonSymbolizer>
     ....
     <Fill>
       <ogc:Function name="Interpolate">
            <ogc:PropertyName>LTE_RSRP</ogc:PropertyName>
            <ogc:Literal>-80</ogc:Literal>
            <ogc:Literal>#ff0000</ogc:Literal>
            <ogc:Literal>-70</ogc:Literal>
            <ogc:Literal>#00ff00</ogc:Literal>
            <ogc:Literal>-60</ogc:Literal>
            <ogc:Literal>#0000ff</ogc:Literal>
            <ogc:Literal>color</ogc:Literal>
        </ogc:Function>
       ....
于 2015-09-09T08:33:01.073 回答