官方手册
filters: https://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>
<