본문 바로가기
공간정보/Geoserver

Geoserver REST API를 이용한 스타일(SLD) 업데이트 팁

by 요긴소프트 2022. 1. 7.
728x90
반응형

Geoserver는 웹 브라우저를 통해 관리 화면을 제공합니다.

또한 REST API를 이용해 명령 창 인터페이스(CLI, Command line interface)를 통해 관리가 가능합니다.

 

https://docs.geoserver.org/latest/en/api/#1.0.0/styles.yaml

 

여러가지 중 이 글에서는 cURL을 이용해서 style(SLD)를 내려받고 업로드 하는 방법을 알려드립니다.

 

# Style 다운로드 방법

curl -v -u admin:geoserver -GET http://127.0.0.1:8080/geoserver/rest/workspaces/{workspace 이름}/styles/{스타일 이름}.sld -o {다운로드 받을 스타일 파일 이름}.sld

예를 들어, cite workspace에 building 이라는 스타일을 다운로드 받는 법은

curl -v -u admin:geoserver -GET http://127.0.0.1:8080/geoserver/rest/workspaces/cite/styles/building.sld -o building.sld

이렇게 받을 수 있습니다.

 

# Style 업로드 방법

curl -v -u admin:geoserver -XPUT -H "Content-type: application/vnd.ogc.se+xml" -d @{수정할 sld 파일이름 경로} http://127.0.0.1:8080/geoserver/rest/workspaces/{workspace 이름}/styles/{스타일 이름}

예를 들어, cite workspace에 buiding.modified.sld 파일을 업데이트 하려면

curl -v -u admin:geoserver -XPUT -H "Content-type: application/vnd.ogc.se+xml" -d @building.modified.sld http://127.0.0.1:8080/geoserver/rest/workspaces/cite/styles/building

이렇게 해주시면 됩니다.

 

스타일 업데이트 작업은 되돌리기가 되지 않으니, 이런 작업은 반드시 백업을 먼저하고 진행 합시다!!

 

728x90
반응형