2

我正在使用 GeoServer 环境。我正在尝试使用基于比例的 sld 设置字体大小。到目前为止,我有以下内容:

<CssParameter name="font-size">
  <ogc:Mult>
    <ogc:Function name="env">
      <ogc:Literal>wms_scale_denominator</ogc:Literal>
    </ogc:Function>
    <ogc:Literal>.001</ogc:Literal>
  </ogc:Mult>
</CssParameter>

但是在 GeoServer 中出现日志错误:“指定的字体大小为空”。为什么乘法功能无法设置字体大小?

更新:无需使用乘法功能根据比例设置字体大小。请改用 Categorize 函数,如下例所示。

4

1 回答 1

4

不要问我这是如何工作的,但它完美无缺!

<CssParameter name="font-size">
  <ogc:Function name="Categorize">
    <!-- Value to transform -->
    <ogc:Function name="env">
      <ogc:Literal>wms_scale_denominator</ogc:Literal>
    </ogc:Function>
    <!-- Output values and thresholds -->
    <!-- Font Size Range [<= 5000]=14, [5000-10000]=10, and [>10000]=6 -->
    <ogc:Literal>14</ogc:Literal>
    <ogc:Literal>5000</ogc:Literal>
    <ogc:Literal>10</ogc:Literal>
    <ogc:Literal>10000</ogc:Literal>
    <ogc:Literal>6</ogc:Literal>
  </ogc:Function>
</CssParameter>

注意:根据您的比例分母调整字体大小/范围。

于 2015-12-16T14:35:53.700 回答