Forked from bruceh48/gist:b725e2c10d36442d8cd26a16e44e5e79
Last active
March 9, 2023 05:32
-
-
Save bryaneaton/3296856541384efff81d555d52ed7eb0 to your computer and use it in GitHub Desktop.
Geoserver REST Example calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See this for important info : | |
http://docs.geoserver.org/stable/en/user/_sources/rest/examples/curl.txt | |
// Get all workspaces | |
curl -v -u admin:geoserver -GET http://localhost:8080/geoserver/rest/workspaces.xml | |
// Create a new WORKSPACE | |
curl -u admin:geoserver -v -XPOST -H 'Content-type:text/xml' | |
-d '<workspace><name>WORKSPACE</name></workspace>' | |
http://localhost:8080/geoserver/rest/workspaces | |
// DELETE a WORKSPACE & all layers in it. | |
// NOTE: trailing parameter must be in double quotes! | |
curl -v -u admin:geoserver -XDELETE http://localhost:8080/geoserver/rest/workspaces/WORKSPACE?recurse="true" | |
// Get a workspace's settings | |
curl -v -u admin:geoserver http://localhost:8080/geoserver/rest/workspaces/tiger/settings.xml | |
// Modify a workspace's name | |
curl -v -u admin:geoserver -XPUT -H "Content-type: text/xml" -d | |
'<settings><name>tiger1</name></settings>' | |
http://localhost:8080/geoserver/rest/workspaces/tiger/settings.xml | |
// Get settings for local WMS settings | |
curl -v -u admin:geoserver | |
http://localhost:8080/geoserver/rest/services/wms/workspaces/WORKSPACE/settings.xml | |
// Enable a local WMS service | |
curl -v -u admin:geoserver -v -XPUT -H "Content-type: text/xml" | |
-d '<wms><enabled>true</enabled></wms>' | |
http://localhost:8080/geoserver/rest/services/wms/workspaces/WORKSPACE/settings.xml | |
// Set the "Limited SRS list" for a local WMS service | |
curl -v -u admin:geoserver -v -XPUT -H "Content-type: text/xml" | |
-d '<wms><srs><string>4326</string><string>3857</string></srs> | |
<bboxForEachCRS>true</bboxForEachCRS></wms>' | |
http://localhost:8080/geoserver/rest/services/wms/workspaces/WORKSPACE/settings.xml | |
// Change the title of a local WMS service | |
curl -v -u admin:geoserver -v -XPUT -H "Content-type: text/xml" | |
-d '<wms><name>New EarthWS WMS Service</name></wms>' | |
http://localhost:8080/geoserver/rest/services/wms/workspaces/WORKSPACE/settings.xml | |
// Get all Raster Stores (CoverageStores) for a workspace WORKSPACE | |
curl -v -u admin:geoserver -GET | |
http://localhost:8080/geoserver/rest/workspaces/WORKSPACE/coveragestores.xml | |
// Using response from above, get coverage/raster layer for a particular COVERAGESTORE | |
curl -u admin:geoserver | |
http://localhost:8080/geoserver/rest/workspaces/WORKSPACE/coveragestores/COVERAGESTORE.xml | |
// Get all coverages for a coveragestore daily1 | |
curl -u admin:geoserver | |
http://localhost:8080/geoserver/rest/workspaces/getsat/coveragestores/rain_weekly/coverages.json | |
// this will contain a coverages.coverage object containg name and href | |
// this href returns.. | |
curl -u admin:geoserver | |
http://localhost:8080/geoserver/rest/workspaces/getsat/coveragestores/daily1/coverages/20170211a.xml | |
// Bulk update a bunch of coverage properties | |
// Bulk set a bunch of layer properties. | |
curl -v -u admin:geoserver -v -XPUT -H "Content-type: text/xml" | |
-d "<coverage><abstract>THis yet another abstract test</abstract> | |
<title>A new title</title> | |
<requestSRS><string>EPSG:4326</string> | |
<string>EPSG:3857</string> | |
<string>EPSG:900913</string> | |
</requestSRS> | |
<responseSRS> | |
<string>EPSG:4326</string> | |
<string>EPSG:3857</string> | |
<string>EPSG:900913</string> | |
</responseSRS> | |
</coverage>" | |
http://localhost:8080/geoserver/rest/workspaces/WORKSPACE/coveragestores/COVERAGENAME/coverages/COVERAGENAME.xml | |
// Create a GeoTIFF raster coverageStore in a $WORKSPACE, for a file that already exists on the server. | |
// And change its name tp $COVERAGE_NAME | |
curl -v -u admin:geoserver -XPUT -H "Content-type: text/plain" -d | |
"file:///Users/bruce/Downloads/GIS_data/rain/daily/20170214.tif" | |
'http://localhost:8080/geoserver/rest/workspaces/getsat/coveragestores/rain_daily_20170214/external.geotiff?configure=first&coverageName=rain_daily_20170214' | |
//Assign an SLD to a raster image | |
// Image title : 20170211.tif | |
// NOTE: Don't set the InputTransparentColor if a SLD is attached. | |
curl -v -u admin:geoserver -XPUT -H "Content-type: text/xml" | |
-d "<layer><defaultStyle><name>raster_rain</name></defaultStyle></layer>" | |
http://localhost:8080/geoserver/rest/layers/WORKSPACE:LAYERNAME | |
// Set a layers title | |
curl -v -u admin:geoserver -v -XPUT -H "Content-type: text/xml" | |
-d "<layer><title>New_title</title></coverage>" | |
http://localhost:8080/geoserver/rest/workspaces/WORKSPACE/coveragestores/COVERAGENAME/coverages/COVERAGENAME.xml | |
// Update the Default WMS path for a layer | |
curl -v -u admin:geoserver -XPUT -H "Content-type: | |
text/xml" -d "<layer><path>wms/test/path</path></layer>" | |
http://localhost:8080/geoserver/rest/layers/WORKSPACE:LAYERNAME.xml | |
// Create a coverageStore in the first call, then attach an GeoTIFF to the newly created coverageStore | |
//Step1: | |
curl -u admin:geoserver -v -XPOST -H 'Content-Type: application/xml' | |
-d '<coverageStore><name>COVERAGESTORENAME</name><workspace>WORKSPACE</workspace><enabled>true</enabled> | |
<type>GeoTIFF</type></coverageStore>' | |
http://localhost:8080/geoserver/rest/workspaces/WORKSPACE/coveragestores | |
//Step 2: | |
curl -u admin:geoserver -v -XPUT -H 'Content-type: text/plain' | |
-d 'file:///Users/bruce/Downloads/GIS_data/rain/week/20170214.tif' | |
http://localhost:8080/geoserver/rest/workspaces/WORKSPACE/coveragestores/COVERAGESTORENAME/external.geotiff?configure=first&coverageName=NAME_OF_LAYER_TO_DISPLAY | |
curl -u admin:geoserver -XGET -H 'Content-type: text/xml' http://localhost:8080/geoserver/rest/settings.xml | |
# SQL View | |
data='<featureType> | |
<name>fn_query_for_best_raster</name> | |
<nativeName>fn_query_for_best_raster</nativeName> | |
<namespace> | |
<name>gist</name> | |
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8989/geoserver/rest/namespaces/gist.xml" type="application/xml"/> | |
</namespace> | |
<title>fn_query_for_best_raster</title> | |
<keywords> | |
<string>features</string> | |
<string>test_view</string> | |
</keywords> | |
<nativeCRS>GEOGCS["WGS 84", | |
DATUM["World Geodetic System 1984", | |
SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], | |
AUTHORITY["EPSG","6326"]], | |
PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], | |
UNIT["degree", 0.017453292519943295], | |
AXIS["Geodetic longitude", EAST], | |
AXIS["Geodetic latitude", NORTH], | |
AUTHORITY["EPSG","4326"]]</nativeCRS> | |
<srs>EPSG:4326</srs> | |
<nativeBoundingBox> | |
<minx>-180.0</minx> | |
<maxx>180.0</maxx> | |
<miny>-90.0</miny> | |
<maxy>90.0</maxy> | |
<crs>EPSG:4326</crs> | |
</nativeBoundingBox> | |
<latLonBoundingBox> | |
<minx>-180.0</minx> | |
<maxx>180.0</maxx> | |
<miny>-90.0</miny> | |
<maxy>90.0</maxy> | |
<crs>EPSG:4326</crs> | |
</latLonBoundingBox> | |
<projectionPolicy>FORCE_DECLARED</projectionPolicy> | |
<enabled>true</enabled> | |
<metadata> | |
<entry key="JDBC_VIRTUAL_TABLE"> | |
<virtualTable> | |
<name>fn_query_for_best_raster</name> | |
<sql>select * from fn_query_for_best_raster(%p_b64%, %p_table%, %p_srid%) | |
</sql> | |
<escapeSql>false</escapeSql> | |
<geometry> | |
<name>input_geog</name> | |
<type>Geometry</type> | |
<srid>4326</srid> | |
</geometry> | |
<parameter> | |
<name>p_srid</name> | |
<defaultValue>4326</defaultValue> | |
<regexpValidator>^[\w\d\s]+$</regexpValidator> | |
</parameter> | |
<parameter> | |
<name>p_b64</name> | |
<defaultValue>'UE9MWUdPTigoLTE4LjY2OTkxMDI4Njc4MzQyIDEuODY3MDQ0NjQ3NDQxOTMxMywtMTAuOTc5NDgwNTk5MjgzNDIgMS44NjcwNDQ2NDc0NDE5MzEzLC0xMC45Nzk0ODA1OTkyODM0MiAtMi40Mzg1Mjg5NDk4NDI4Mjk1LC0xOC42Njk5MTAyODY3ODM0MiAtMi40Mzg1Mjg5NDk4NDI4Mjk1LC0xOC42Njk5MTAyODY3ODM0MiAxLjg2NzA0NDY0NzQ0MTkzMTMpKQ=='</defaultValue> | |
</parameter> | |
<parameter> | |
<name>p_table</name> | |
<defaultValue>'egm2008'</defaultValue> | |
<regexpValidator>^[\w\d\s]+$</regexpValidator> | |
</parameter> | |
</virtualTable> | |
</entry> | |
</metadata> | |
<store class="dataStore"> | |
<name>gist:tardis</name> | |
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8989/geoserver/rest/workspaces/gist/datastores/tardis.xml" type="application/xml"/> | |
</store> | |
<serviceConfiguration>false</serviceConfiguration> | |
<maxFeatures>0</maxFeatures> | |
<numDecimals>0</numDecimals> | |
<padWithZeros>false</padWithZeros> | |
<forcedDecimal>false</forcedDecimal> | |
<overridingServiceSRS>false</overridingServiceSRS> | |
<skipNumberMatched>false</skipNumberMatched> | |
<circularArcPresent>false</circularArcPresent> | |
<attributes> | |
<attribute> | |
<name>id</name> | |
<minOccurs>0</minOccurs> | |
<maxOccurs>1</maxOccurs> | |
<nillable>true</nillable> | |
<binding>java.lang.Integer</binding> | |
</attribute> | |
<attribute> | |
<name>path</name> | |
<minOccurs>0</minOccurs> | |
<maxOccurs>1</maxOccurs> | |
<nillable>true</nillable> | |
<binding>java.lang.String</binding> | |
</attribute> | |
<attribute> | |
<name>hsigma</name> | |
<minOccurs>0</minOccurs> | |
<maxOccurs>1</maxOccurs> | |
<nillable>true</nillable> | |
<binding>java.lang.Float</binding> | |
</attribute> | |
<attribute> | |
<name>vsigma</name> | |
<minOccurs>0</minOccurs> | |
<maxOccurs>1</maxOccurs> | |
<nillable>true</nillable> | |
<binding>java.lang.Float</binding> | |
</attribute> | |
<attribute> | |
<name>area</name> | |
<minOccurs>0</minOccurs> | |
<maxOccurs>1</maxOccurs> | |
<nillable>true</nillable> | |
<binding>java.lang.Double</binding> | |
</attribute> | |
<attribute> | |
<name>input_geog</name> | |
<minOccurs>0</minOccurs> | |
<maxOccurs>1</maxOccurs> | |
<nillable>true</nillable> | |
<binding>org.locationtech.jts.geom.Geometry</binding> | |
</attribute> | |
</attributes> | |
</featureType>' | |
curl -v -u admin:geoserver -POST -H 'Content-type: text/xml' -d "$data" http://localhost:8989/geoserver/rest/workspaces/gist/datastores/tardis/featuretypes | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment