Geoserver通过SLD配置字段值在面边线内侧显示

Geoserver通过SLD配置字段值在面边线内侧显示,如下图所示:

 参考配置SLD代码如下:

        <sld:Rule>
          <sld:Name>aaa</sld:Name>
          <sld:Title>aaa</sld:Title>
          <sld:MinScaleDenominator>100000</sld:MinScaleDenominator>
          <sld:MaxScaleDenominator>5000000000</sld:MaxScaleDenominator>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>TYPE</ogc:PropertyName>
              <ogc:Literal>aaa</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <sld:PolygonSymbolizer>
            <sld:Stroke>
              <sld:CssParameter name="stroke">#FFC90E</sld:CssParameter>
              <sld:CssParameter name="stroke-width">1</sld:CssParameter>
              <sld:CssParameter name="stroke-opacity">1</sld:CssParameter>
            </sld:Stroke>
          </sld:PolygonSymbolizer>
          <sld:TextSymbolizer>
            <Geometry>
              <ogc:Function name="boundary">
                <ogc:Function name="buffer">
                  <ogc:PropertyName>the_geom</ogc:PropertyName>
                  <ogc:Function name="Categorize">
                    <!-- Value to transform -->
                    <ogc:Function name="env">
                      <ogc:Literal>wms_scale_denominator</ogc:Literal>
                    </ogc:Function>
                    <ogc:Literal>-0.005</ogc:Literal>
                    <ogc:Literal>200000</ogc:Literal>
                    <ogc:Literal>-0.01</ogc:Literal>
                    <ogc:Literal>500000</ogc:Literal>
                    <ogc:Literal>-0.02</ogc:Literal>
                    <ogc:Literal>1000000</ogc:Literal>
                    <ogc:Literal>-0.04</ogc:Literal>
                    <ogc:Literal>2000000</ogc:Literal>
                    <ogc:Literal>-0.08</ogc:Literal>
                    <ogc:Literal>4000000</ogc:Literal>
                    <ogc:Literal>-0.16</ogc:Literal>
                    <ogc:Literal>8000000</ogc:Literal>
                    <ogc:Literal>-0.24</ogc:Literal>
                    <ogc:Literal>16000000</ogc:Literal>
                    <ogc:Literal>-0.32</ogc:Literal>
                    <ogc:Literal>32000000</ogc:Literal>
                    <ogc:Literal>-0.64</ogc:Literal>
                  </ogc:Function>
                </ogc:Function>
              </ogc:Function>
            </Geometry>
            <sld:Label>
              <ogc:PropertyName>NAME</ogc:PropertyName>
            </sld:Label>
            <sld:Font>
              <sld:CssParameter name="font-family">.PingFang SC Medium</sld:CssParameter>
              <sld:CssParameter name="font-family">0</sld:CssParameter>
              <sld: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 -->
                  <!-- Ranges: -->
                  <!-- [scale <= 100000, font 16] -->
                  <!-- [scale 100000 - 5000000, font 14] -->
                  <!-- [...] -->
                  <!-- [scale 50000000 - 100000000, font 8] -->
                  <!-- [scale > 100000000, font 0] -->
                  <ogc:Literal>16</ogc:Literal>
                  <ogc:Literal>100000</ogc:Literal>
                  <ogc:Literal>14</ogc:Literal>
                  <ogc:Literal>5000000</ogc:Literal>
                  <ogc:Literal>12</ogc:Literal>
                  <ogc:Literal>10000000</ogc:Literal>
                  <ogc:Literal>10</ogc:Literal>
                  <ogc:Literal>50000000</ogc:Literal>
                  <ogc:Literal>8</ogc:Literal>
                  <ogc:Literal>100000000</ogc:Literal>
                  <ogc:Literal>0</ogc:Literal>
                </ogc:Function>
              </sld:CssParameter>
              <sld:CssParameter name="font-style">normal</sld:CssParameter>
              <sld:CssParameter name="font-weight">normal</sld:CssParameter>
            </sld:Font>
            <sld:Fill>
              <!--<sld:CssParameter name="fill">#FFC90E</sld:CssParameter>-->
              <sld:CssParameter name="fill">#FFF</sld:CssParameter>
              <sld:CssParameter name="fill-opacity">1.0</sld:CssParameter>
            </sld:Fill>
            <ogc:LabelPlacement>
              <ogc:PointPlacement>
                <ogc:AnchorPoint>
                  <ogc:AnchorPointX>0.5</ogc:AnchorPointX>
                  <ogc:AnchorPointY>0.0</ogc:AnchorPointY>
                </ogc:AnchorPoint>
                <ogc:Displacement>
                  <ogc:DisplacementX>0</ogc:DisplacementX>
                  <ogc:DisplacementY>0</ogc:DisplacementY>
                </ogc:Displacement>
              </ogc:PointPlacement>
            </ogc:LabelPlacement>
            <VendorOption name="followLine">true</VendorOption><!-- 文字沿着直线方向显示 -->
            <VendorOption name="spaceAround">10</VendorOption><!--Overlapping and Separating Labels-->
            <VendorOption name="repeat">400</VendorOption>
          </sld:TextSymbolizer>
        </sld:Rule>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值