I. 목표
GeoServer로 거점등을 표시할때 각 상태별로 다른 아이콘, 색상을 가져왔으면 하는 요구사항이 있어 연구를 하였다.
II. 연구및 개발내용
1. 새로운 스타일 추가하기
좌측메뉴에서 “스타일”을 클릭, 우측 화면에서 “새로운 스타일 추가하기”를 선택
2. 스타일 저장
다음의 항목을 입력하고 “유효성 검증” 및 “저장”버튼을 클릭한다.
3. 스타일 편집
<?xml version=”1.0″ encoding=”UTF-8″?>
<StyledLayerDescriptor version=”1.0.0″ 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” xsi:schemaLocation=”http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd“> <NamedLayer> <Name>branch</Name> <UserStyle> <Name>branch</Name> <Title>Branch Style</Title> <Abstract>Mosaic Branch Info Style</Abstract> <FeatureTypeStyle> <Rule> <Title>거점아이콘, 거점명 표시</Title> <ogc:Filter> <ogc:PropertyIsEqualTo> <ogc:Function name=”env”> <ogc:Literal>branchViewType</ogc:Literal></ogc:Function> <ogc:Literal>01</ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Filter> <MaxScaleDenominator>32000000</MaxScaleDenominator>
<TextSymbolizer> <Label> <ogc:PropertyName>branch_name</ogc:PropertyName> (<ogc:PropertyName>inout_radius</ogc:PropertyName>) </Label> <Font> <CssParameter name=”font-family”>Arial</CssParameter> <CssParameter name=”font-size”>11</CssParameter> <CssParameter name=”font-style”>normal</CssParameter> <CssParameter name=”font-weight”>bold</CssParameter> </Font> <LabelPlacement> <PointPlacement> <AnchorPoint> <AnchorPointX>0.5</AnchorPointX> <AnchorPointY>0.5</AnchorPointY> </AnchorPoint> <Displacement> <DisplacementX>0</DisplacementX> <DisplacementY>-15</DisplacementY> </Displacement> </PointPlacement> </LabelPlacement> <Halo> <Radius><ogc:Literal>2</ogc:Literal></Radius> <Fill><CssParameter name=”fill”><ogc:Function name=”env”><ogc:Literal>textBackColor</ogc:Literal></ogc:Function></CssParameter></Fill> </Halo> <Fill><CssParameter name=”fill”><ogc:Function name=”env”><ogc:Literal>textFontColor</ogc:Literal></ogc:Function></CssParameter></Fill> </TextSymbolizer> <PointSymbolizer> <Graphic> <ExternalGraphic> <OnlineResource xlink:type=”simple” xlink:href=”${icon}” /> <Format>image/png</Format> </ExternalGraphic> <Size><ogc:Literal>30</ogc:Literal></Size> </Graphic> </PointSymbolizer> </Rule>
<Rule> <Title>거점아이콘, 거점명, 타원 표시</Title> <ogc:Filter> <ogc:PropertyIsEqualTo> <ogc:Function name=”env”><ogc:Literal>branchViewType</ogc:Literal></ogc:Function> <ogc:Literal>02</ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Filter> <MaxScaleDenominator>32000000</MaxScaleDenominator>
<PointSymbolizer uom=”http://www.opengeospatial.org/se/units/metre”> <Graphic> <Mark> <WellKnownName>circle</WellKnownName> <Fill> <CssParameter name=”fill”><ogc:Function name=”env”><ogc:Literal>circleFillColor</ogc:Literal></ogc:Function></CssParameter> <CssParameter name=”fill-opacity”>0.5</CssParameter> </Fill> <Stroke> <CssParameter name=”stroke”><ogc:Function name=”env”><ogc:Literal>circleStrokeColor</ogc:Literal></ogc:Function></CssParameter> <CssParameter name=”stroke-width”>2</CssParameter>
</Stroke> </Mark> <Size><ogc:PropertyName>distance</ogc:PropertyName></Size> </Graphic> </PointSymbolizer> <TextSymbolizer> <Label> <ogc:PropertyName>branch_name</ogc:PropertyName> (<ogc:PropertyName>inout_radius</ogc:PropertyName>) </Label> <Font> <CssParameter name=”font-family”>Arial</CssParameter> <CssParameter name=”font-size”>11</CssParameter> <CssParameter name=”font-style”>normal</CssParameter> <CssParameter name=”font-weight”>bold</CssParameter> </Font> <LabelPlacement> <PointPlacement> <AnchorPoint> <AnchorPointX>0.5</AnchorPointX> <AnchorPointY>0.5</AnchorPointY> </AnchorPoint> <Displacement> <DisplacementX>0</DisplacementX> <DisplacementY>-15</DisplacementY> </Displacement> </PointPlacement> </LabelPlacement> <Halo> <Radius><ogc:Literal>2</ogc:Literal></Radius> <Fill><CssParameter name=”fill”><ogc:Function name=”env”><ogc:Literal>textBackColor</ogc:Literal></ogc:Function></CssParameter></Fill> </Halo> <Fill><CssParameter name=”fill”><ogc:Function name=”env”><ogc:Literal>textFontColor</ogc:Literal></ogc:Function></CssParameter></Fill> </TextSymbolizer> <PointSymbolizer> <Graphic> <ExternalGraphic> <OnlineResource xlink:type=”simple” xlink:href=”${icon}” /> <Format>image/png</Format> </ExternalGraphic> <Size><ogc:Literal>30</ogc:Literal></Size> </Graphic> </PointSymbolizer> </Rule>
<Rule> <Title>거점아이콘 표시</Title> <ogc:Filter> <ogc:PropertyIsEqualTo> <ogc:Function name=”env”><ogc:Literal>branchViewType</ogc:Literal></ogc:Function> <ogc:Literal>03</ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Filter> <MaxScaleDenominator>32000000</MaxScaleDenominator> <PointSymbolizer> <Graphic> <ExternalGraphic> <OnlineResource xlink:type=”simple” xlink:href=”${icon}” /> <Format>image/png</Format> </ExternalGraphic> <Size><ogc:Literal>30</ogc:Literal></Size> </Graphic> </PointSymbolizer> </Rule>
</FeatureTypeStyle> </UserStyle> </NamedLayer> </StyledLayerDescriptor> |
4. 스타일 레이어 적용
- 좌측 메뉴에서 “레이어” 선택, 우측 화면에서 ports 레이어 선택
- 레이어 편집의 “발행” 탭으로 이동 하여 기본스타일을 “port” 로 선택하여 저장
III. 결론
해당 거점별로 색상이 다른것을 확인할수 있었다.