-
Notifications
You must be signed in to change notification settings - Fork 1
/
shp2geoserver_oneStyle.sh
31 lines (26 loc) · 1.12 KB
/
shp2geoserver_oneStyle.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# script to add layer/style information
# for every SLD file in our collection
# Autor: Luis Octavio Ramírez Fernández
# correo: lramirez@igg.unam.mx
# fecha: enero 2016
#
restapi=http://localhost:8080/geoserver/rest
login=admin:geoserver
workspace=osm
store=osm
stylename=mystyle
for shpfile in *.shp; do
# strip the extension from the filename to use for layer/style names
layername=`basename $shpfile .shp`
# create a new featuretype in the store, assuming the table
# already exists in the database and is named $layername
# this step automatically creates a layer of the same name
# as a side effect
curl -v -u $login -XPOST -H "Content-type: text/xml" \
-d "<featureType><name>$layername</name></featureType>" \
$restapi/workspaces/$workspace/datastores/$store/featuretypes?recalculate=nativebbox,latlonbbox
# associate the style with the layer as the default style
curl -v -u $login -XPUT -H "Content-type: text/xml" \
-d "<layer><enabled>true</enabled><defaultStyle><name>$stylename</name><workspace>$workspace</workspace></defaultStyle></layer>" \
$restapi/layers/$workspace:$layername
done