Mein Shapefile als WMS in weniger als 5 Minuten

Christian Mayer Christian Mayer

Christian Mayer, meggsimum
FOSSGIS 2014, Berlin

Christian Mayer

Christian Mayer

GeoServer REST API

Dynamische Anpassung der GeoServer Instanz mittels einfacher HTTP-Aufrufe

  • GET - Abrufen
  • POST & PUT - Ändern / Hinzufügen
  • DELETE - Löschen
  • über benannte Ressourcen (URLs)
					
z.B.
http://<geoserver-url>/rest/
http://<geoserver-url>/rest/workspaces/
http://<geoserver-url>/rest/workspaces/xyz/datastores/
http://<geoserver-url>/rest/layers/xyz:abc
				

Auf Sendung?

Anlegen eines Workspaces
				
curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<workspace><name>fossgis2014</name></workspace>" http://localhost:10080/geoserver243/rest/workspaces
			

Eat This!

Publizieren eines Shape-Files
				
curl -v -u admin:geoserver -XPUT -H "Content-type: application/zip" --data-binary @bands.zip http://localhost:10080/geoserver243/rest/workspaces/fossgis2014/datastores/bands/file.shp
			

New Dress?

Anlegen eines neuen Styles
				
curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<style><name>bands</name><filename>bands.sld</filename></style>" http://localhost:10080/geoserver243/rest/styles
			
Import eines SLD in neuen Style
				
curl -v -u admin:geoserver -XPUT -H "Content-type: application/vnd.ogc.sld+xml" -d @bands.sld http://localhost:10080/geoserver243/rest/styles/bands
			

Suit Up!

Neuer Style einem Layer zuweisen
				
curl -v -u admin:geoserver -XPUT -H "Content-type: text/xml" -d "<layer><defaultStyle><name>bands</name></defaultStyle></layer>" http://localhost:10080/geoserver243/rest/layers/fossgis2014:bands
			

Batch me if you can...

				
#!/bin/bash
echo "-------------------------------------------------------------"
echo "create style $1 and add it as default style to layer $2 ..."
echo "-------------------------------------------------------------"
echo ""

curl -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<style><name>$1</name><filename>$1.sld</filename></style>" http://localhost:10080/geoserver243/rest/styles

echo "  - added the new style $1"

curl -u admin:geoserver -XPUT -H "Content-type: application/vnd.ogc.sld+xml" -d @$1.sld http://localhost:10080/geoserver243/rest/styles/$1

echo "  - uploaded $1.sld in new style $1"

curl -u admin:geoserver -XPUT -H "Content-type: text/xml" -d "<layer><defaultStyle><name>$1</name></defaultStyle></layer>" http://localhost:10080/geoserver243/rest/layers/fossgis2014:$2

echo "  - set $1 as default style for layer $2"

echo "... done cause GeoServer REST API rocks!"
			
				
>> add-default-style.bat newbandstyle bands
			

Impressum

Autor

Christian Mayer
meggsimum
Hauptstraße 165a
67125 Dannstadt-Schauernheim
chris@meggsimum.de

(web) www.meggsimum.de
(twitter) @geofootballer
(github) @chrismayer

Lizenz

Diese Folien sind unter CC BY-SA veröffentlicht.

/