geoserver sld样式(一)filter

官方手册

filtershttps://docs.geoserver.org/main/en/user/styling/sld/reference/filters.html

1、问题描述

目前项目上的所有制图都是sld格式的。其中有一个图层的制图根据某字段的属性值进行配置。问题是使用工具编辑地图的时候该字段没有默认值,现在想做到属性为空时显示绘制的要素。PropertyIsNull

1.1、原始制图

只对lifecycle字段为4、5时配置了样式,使用的是过滤器的比较运算符中PropertyIsEqualTo。其他值、null的时候在地图上没有显示。

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0"
                       xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
                       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">
  <NamedLayer>
    <Name>pipeline</Name>
    <UserStyle>
      <Name>pipeline</Name>
      <FeatureTypeStyle>
        <Rule>
          <Title>建设期</Title>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>lifecycle</ogc:PropertyName>
              <ogc:Literal>4</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <LineSymbolizer>
            <Stroke>
              <CssParameter name="stroke">#ff0000</CssParameter>
              <CssParameter name="stroke-dashoffset">8</CssParameter>
              <CssParameter name="stroke-dasharray">3.0</CssParameter>
              <CssParameter name="stroke-width">
                <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 <= 300, font 12] -->
                  <!-- [scale 300 - 2500, font 10] -->
                  <!-- [scale > 2500, font 8] -->
                  <ogc:Literal>5</ogc:Literal>
                  <ogc:Literal>200</ogc:Literal>
                  <ogc:Literal>5</ogc:Literal>
                  <ogc:Literal>500</ogc:Literal>
                  <ogc:Literal>5</ogc:Literal>
                  <ogc:Literal>1000</ogc:Literal>
                  <ogc:Literal>5</ogc:Literal>
                  <ogc:Literal>2000</ogc:Literal>
                  <ogc:Literal>5</ogc:Literal>
                  <ogc:Literal>20000</ogc:Literal>
                  <ogc:Literal>3</ogc:Literal>
                  <ogc:Literal>2000000</ogc:Literal>
                  <ogc:Literal>3</ogc:Literal>
                </ogc:Function>
              </CssParameter>
            </Stroke>
            <!--设置标注不叠加到当前符号上-->
            <!--<VendorOption name="labelObstacle">true</VendorOption>-->
          </LineSymbolizer>
        </Rule>

        <Rule>
          <Title>运营期</Title>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>lifecycle</ogc:PropertyName>
              <ogc:Literal>5</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <LineSymbolizer>
            <Stroke>
              <CssParameter name="stroke">#ff0000</CssParameter>
              <CssParameter name="stroke-width">
                <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 <= 300, font 12] -->
                  <!-- [scale 300 - 2500, font 10] -->
                  <!-- [scale > 2500, font 8] -->
                  <ogc:Literal>5</ogc:Literal>
                  <ogc:Literal>200</ogc:Literal>
                  <ogc:Literal>5</ogc:Literal>
                  <ogc:Literal>500</ogc:Literal>
                  <ogc:Literal>5</ogc:Literal>
                  <ogc:Literal>1000</ogc:Literal>
                  <ogc:Literal>5</ogc:Literal>
                  <ogc:Literal>2000</ogc:Literal>
                  <ogc:Literal>5</ogc:Literal>
                  <ogc:Literal>20000</ogc:Literal>
                  <ogc:Literal>3</ogc:Literal>
                  <ogc:Literal>2000000</ogc:Literal>
                  <ogc:Literal>3</ogc:Literal>
                </ogc:Function>
              </CssParameter>
            </Stroke>
          </LineSymbolizer>
        </Rule>
        <Rule>

          <!--标注样式-->
          <TextSymbolizer>
            <Label>
              <
  • 13
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值