geoserver配置线图层样式(QGIS版的SLD格式)
一、线图层
-
stroke
颜色: string [r,g,b,a] as int 0-255 or #AARRGGBB as hex or color as color's name -
stroke-width
宽度 -
stroke-dasharray
描边样式: [no|solid|dash|dot|dash dot|dash dot dot] -
stroke-linejoin
连接样式:[bevel|miter|round] -
stroke-linecap
端点样式:[square|flat|round]
PerpendicularOffset
偏移量
二、简单符号
1.基本样式
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:ogc="http://www.opengis.net/ogc" xmlns:se="http://www.opengis.net/se" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<se:Name>Line</se:Name>
<UserStyle>
<se:Name>Line</se:Name>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name>Single symbol</se:Name>
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#ff9e17</se:SvgParameter> // 设置颜色
<se:SvgParameter name="stroke-width">1</se:SvgParameter> // 设置宽度
</se:Stroke>
</se:LineSymbolizer>
</se:Rule>
</se:FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
下面基于上面模板,只改中间
2.虚线
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#ff9e17</se:SvgParameter>
<se:SvgParameter name="stroke-width">5</se:SvgParameter>
<se:SvgParameter name="stroke-dasharray">5 10</se:SvgParameter>
</se:Stroke>
</se:LineSymbolizer>
3.路符号
上面边框下面内容
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#ff0000</se:SvgParameter>
<se:SvgParameter name="stroke-width">10</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">round</se:SvgParameter>
<se:SvgParameter name="stroke-linecap">round</se:SvgParameter>
</se:Stroke>
</se:LineSymbolizer>
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">4</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">round</se:SvgParameter>
<se:SvgParameter name="stroke-linecap">round</se:SvgParameter>
</se:Stroke>
</se:LineSymbolizer>
随意搭配
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#ff9e17</se:SvgParameter>
<se:SvgParameter name="stroke-width">12</se:SvgParameter>
<se:SvgParameter name="stroke-dasharray">2 7</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">round</se:SvgParameter>
<se:SvgParameter name="stroke-linecap">round</se:SvgParameter>
</se:Stroke>
</se:LineSymbolizer>
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#00ff00</se:SvgParameter>
<se:SvgParameter name="stroke-width">4</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">round</se:SvgParameter>
<se:SvgParameter name="stroke-linecap">round</se:SvgParameter>
</se:Stroke>
</se:LineSymbolizer>
4.铁路符号
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">round</se:SvgParameter>
<se:SvgParameter name="stroke-linecap">round</se:SvgParameter>
</se:Stroke>
</se:LineSymbolizer>
<se:LineSymbolizer>
<se:Stroke>
<se:GraphicStroke>
<se:Graphic>
<se:Mark>
<se:WellKnownName>line</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#ff0000</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>9</se:Size>
</se:Graphic>
<se:Gap>
<ogc:Literal>11</ogc:Literal>
</se:Gap>
</se:GraphicStroke>
</se:Stroke>
</se:LineSymbolizer>
5.圆圈符号
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">2</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
<se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
</se:Stroke>
</se:LineSymbolizer>
<se:LineSymbolizer>
<se:Stroke>
<se:GraphicStroke>
<se:Graphic>
<se:Mark>
<se:WellKnownName>circle</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#ffffff</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>7</se:Size>
</se:Graphic>
<se:Gap>
<ogc:Literal>21</ogc:Literal>
</se:Gap>
</se:GraphicStroke>
</se:Stroke>
<se:PerpendicularOffset>7</se:PerpendicularOffset>
</se:LineSymbolizer>
<se:LineSymbolizer>
<se:Stroke>
<se:GraphicStroke>
<se:Graphic>
<se:Mark>
<se:WellKnownName>circle</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#ffffff</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>7</se:Size>
</se:Graphic>
<se:Gap>
<ogc:Literal>21</ogc:Literal>
</se:Gap>
</se:GraphicStroke>
</se:Stroke>
<se:PerpendicularOffset>-7</se:PerpendicularOffset>
</se:LineSymbolizer>
6.设置标注
GeoServer发布服务,中文标注乱码
中文可能会乱码
<se:Rule>
<se:Name>Single symbol</se:Name>
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#e77148</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
<se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
</se:Stroke>
</se:LineSymbolizer>
</se:Rule>
<se:Rule>
<se:TextSymbolizer>
<se:Label>
<ogc:PropertyName>shape_area</ogc:PropertyName>
</se:Label>
<se:Font>
<se:SvgParameter name="font-family">Arial</se:SvgParameter>
<se:SvgParameter name="font-size">13</se:SvgParameter>
</se:Font>
<se:LabelPlacement>
<se:LinePlacement>
<se:GeneralizeLine>true</se:GeneralizeLine>
</se:LinePlacement>
</se:LabelPlacement>
<se:Fill>
<se:SvgParameter name="fill">#323232</se:SvgParameter>
</se:Fill>
</se:TextSymbolizer>
</se:Rule>
三、分类符号
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:ogc="http://www.opengis.net/ogc" xmlns:se="http://www.opengis.net/se" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<se:Name>Road</se:Name>
<UserStyle>
<se:Name>Road</se:Name>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name>allCars</se:Name>
<se:Description>
<se:Title>allCars</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>allCars</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#da21b8</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
<se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
</se:Stroke>
</se:LineSymbolizer>
</se:Rule>
<se:Rule>
<se:Name>bike</se:Name>
<se:Description>
<se:Title>bike</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>bike</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#80d68f</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
<se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
</se:Stroke>
</se:LineSymbolizer>
</se:Rule>
<se:Rule>
<se:Name>onlyWalk</se:Name>
<se:Description>
<se:Title>onlyWalk</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>onlyWalk</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#e1b253</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
<se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
</se:Stroke>
</se:LineSymbolizer>
</se:Rule>
<se:Rule>
<se:Name></se:Name>
<se:Description>
<se:Title>type is ''</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:Or>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsNull>
<ogc:PropertyName>type</ogc:PropertyName>
</ogc:PropertyIsNull>
</ogc:Or>
</ogc:Filter>
<se:LineSymbolizer>
<se:Stroke>
<se:SvgParameter name="stroke">#5683e3</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
<se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
</se:Stroke>
</se:LineSymbolizer>
</se:Rule>
</se:FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>