2022년 9월 22일 목요일

Geoserver SLD 동적 env 적용(PropertyName)

https://docs.geoserver.org/latest/en/user/styling/sld/extensions/substitution.html

참조 


SLD 스타일의 컬럼명을 지정할 때 

같은 스타일을 여러 레이어에서 활용하여 라벨링할 경우 레이어마다 컬럼명이 다를 수 있다.        

<se:Label>

    <ogc:PropertyName>spo_1km</ogc:PropertyName>

 </se:Label>

PropertyName이 동적으로 들어가야할 경우인데,

공식문서에 동적 SLD env 방법이 이렇게 적혀있어서 

<ogc:Function name="env">
   <ogc:Literal>size</ogc:Literal>
   <ogc:Literal>6</ogc:Literal>
</ogc:Function>

<ogc:PropertyName>안에 env를 넣으려고 한참 헤맸다.

다음과 같이 지정하면 된다.

colNm이 레이어에서 표현하고 싶은 컬럼명

            <se:Label>

              <ogc:Function name="property">

                <ogc:Function name="env">

                  <ogc:Literal>colNm</ogc:Literal>

                  <ogc:Literal>yr1995</ogc:Literal>

                </ogc:Function>

              </ogc:Function>

            </se:Label>

  

이후 코드에서 WMS 요청시  레이어에 맞게 env에 컬럼 명을 넣으면 동적으로 컬럼명을 입력한다.

 L.WMS.overlay(
                            GEOSERVER_URL + 'wms?',
                            {
                                service: 'WMS',
                                version: '1.1.0',
                                layers: 'seoulpolicy:' + POP_LAYER,
                                format: 'image/png',
                                transparent: true,
                                style: 'seoulpolicy:layerLabel',
                                env: 'colNm:spo_1km'
}
);





Eclipse 프로젝트에서 java.lang.NoClassDefFoundError 대처

Eclipse에서  자바 클래스 파일을 jar파일을 통해 추가 했을 때 소스 상에서는 클래스 파일을 찾지만 서버에 배포했을 때 못찾는 경우  프로젝트 옵션에서 Web Deplyment Assembly에 라이브러리 위치나 jar파일을 직접 추가하자   ...