1. 程式人生 > 其它 >GeoServer style 配置樣例

GeoServer style 配置樣例

<?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">
	<!-- a Named Layer is the basic building block of an SLD document -->
	<NamedLayer>
		<Name>default_line</Name>
		<UserStyle>
			<!-- Styles can have names, titles and abstracts -->
			<Title>Default Line</Title>
			<Abstract>A sample style that draws a line</Abstract>
			<!-- FeatureTypeStyles describe how to render different features -->
			<!-- A FeatureTypeStyle for rendering lines -->
			<FeatureTypeStyle>
				<Rule>
				   <ogc:Filter>
                                                <!-- 欄位等於7的規則-->
						<ogc:PropertyIsEqualTo>
							<ogc:PropertyName>SUBTYPE</ogc:PropertyName>
							<ogc:Literal>7</ogc:Literal>
						</ogc:PropertyIsEqualTo>
					</ogc:Filter>
			                <!-- 線條展示-->
					<PolygonSymbolizer>
						<Stroke>
							<CssParameter name="stroke">#FF8C00</CssParameter>
							<CssParameter name="stroke-width">2</CssParameter>
						</Stroke>
					</PolygonSymbolizer>
                                          <!-- 文字展示-->
					<TextSymbolizer>
						<Label>
							<ogc:PropertyName>NAME</ogc:PropertyName>
						</Label>
						<Fill>
							<CssParameter name="fill">#FF8C00</CssParameter>
						</Fill>
						<Font>
							<CssParameter name="font-style">Normal</CssParameter>
							<CssParameter name="font-size">14</CssParameter>
							<CssParameter name="font-weight">bold</CssParameter>
						</Font>
					</TextSymbolizer>
				</Rule>
							<Rule>
				   <ogc:Filter>
						<ogc:PropertyIsEqualTo>
							<ogc:PropertyName>SUBTYPE</ogc:PropertyName>
							<ogc:Literal>8</ogc:Literal>
						</ogc:PropertyIsEqualTo>
					</ogc:Filter>
			
					<PolygonSymbolizer>
						<Stroke>
							<CssParameter name="stroke">#2F695E</CssParameter>
							<CssParameter name="stroke-width">2</CssParameter>
						</Stroke>
					</PolygonSymbolizer>
					<TextSymbolizer>
						<Label>
							<ogc:PropertyName>NAME</ogc:PropertyName>
						</Label>
						<Fill>
							<CssParameter name="fill">#2F695E</CssParameter>
						</Fill>
						<Font>
							<CssParameter name="font-style">Normal</CssParameter>
							<CssParameter name="font-size">14</CssParameter>
							<CssParameter name="font-weight">bold</CssParameter>
						</Font>
					</TextSymbolizer>
				</Rule>
			</FeatureTypeStyle>
		</UserStyle>
	</NamedLayer>
</StyledLayerDescriptor>
  • 效果展示

本文來自部落格園,作者:微笑帶你去,轉載請註明原文連結:https://www.cnblogs.com/wxdnq/p/15576080.html