商店¶
上载形状文件¶
通过上载形状文件“roads.zip”创建新商店“roads”
请求
卷曲
curl -v -u admin:geoserver -XPUT -H "Content-type: application/zip"
--data-binary @roads.zip
http://localhost:8080/geoserver/rest/workspaces/acme/datastores/roads/file.shp
响应
201 Created
列出商店详细信息¶
检索有关特定存储的信息 *
请求
卷曲
curl -v -u admin:geoserver -XGET
http://localhost:8080/geoserver/rest/workspaces/acme/datastores/roads.xml
Python
TBD
爪哇
TBD
响应
<dataStore>
<name>roads</name>
<type>Shapefile</type>
<enabled>true</enabled>
<workspace>
<name>acme</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate"
href="http://localhost:8080/geoserver/rest/workspaces/acme.xml" type="application/xml"/>
</workspace>
<connectionParameters>
<entry key="url">file:/C:/path/to/data_dir/data/acme/roads/</entry>
<entry key="namespace">http://acme</entry>
</connectionParameters>
<__default>false</__default>
<featureTypes>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate"
href="http://localhost:8080/geoserver/rest/workspaces/acme/datastores/roads/featuretypes.xml"
type="application/xml"/>
</featureTypes>
</dataStore>
请求
备注
XML响应只提供有关存储本身的详细信息,因此您可以使用HTML查看存储的内容。
curl -v -u admin:geoserver -XGET
http://localhost:8080/geoserver/rest/workspaces/acme/datastores/roads.html
列出FeatureType详细信息¶
备注
默认情况下,上载形状文件时,将自动创建FeatureType。
请求
卷曲
curl -v -u admin:geoserver -XGET
http://localhost:8080/geoserver/rest/workspaces/acme/datastores/roads/featuretypes/roads.xml
Python
TBD
爪哇
TBD
响应
<featureType>
<name>roads</name>
<nativeName>roads</nativeName>
<namespace>
<name>acme</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate"
href="http://localhost:8080/geoserver/rest/namespaces/acme.xml" type="application/xml"/>
</namespace>
...
</featureType>
添加现有形状文件¶
发布服务器上已存在的形状文件“rivers.shp”,无需上载
请求
卷曲
curl -v -u admin:geoserver -XPUT -H "Content-type: text/plain"
-d "file:///data/shapefiles/rivers/rivers.shp"
http://localhost:8080/geoserver/rest/workspaces/acme/datastores/rivers/external.shp
备注
这个 external.shp
请求URI的一部分表示该文件来自目录之外。
响应
201 Created
添加现有形状文件的目录¶
创建一个存储区,其中包含服务器上已存在的不需要上载的shapefiles目录
请求
卷曲
curl -v -u admin:geoserver -XPUT -H "Content-type: text/plain"
-d "file:///data/shapefiles/"
"http://localhost:8080/geoserver/rest/workspaces/acme/datastores/shapefiles/external.shp?configure=all"
备注
这个 configure=all
查询字符串参数设置要加载和发布的目录中的每个形状文件。
响应
201 Created
添加PostGIS数据库存储¶
将名为“NYC”的现有PostGIS数据库添加为新存储
备注
此示例假定名为 nyc
存在于本地系统上,用户可以访问 bob
.
给定以下内容另存为 nycDataStore.xml
:
<dataStore>
<name>nyc</name>
<connectionParameters>
<host>localhost</host>
<port>5432</port>
<database>nyc</database>
<user>bob</user>
<passwd>postgres</passwd>
<dbtype>postgis</dbtype>
</connectionParameters>
</dataStore>
请求
卷曲
curl -v -u admin:geoserver -XPOST -T nycDataStore.xml -H "Content-type: text/xml"
http://localhost:8080/geoserver/rest/workspaces/acme/datastores
响应
201 Created
列出PostGIS数据库存储详细信息¶
检索有关PostGIS存储的信息
请求
卷曲
curl -v -u admin:geoserver -XGET http://localhost:8080/geoserver/rest/workspaces/acme/datastores/nyc.xml
响应
<dataStore>
<name>nyc</name>
<type>PostGIS</type>
<enabled>true</enabled>
<workspace>
<name>acme</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate"
href="http://localhost:8080/geoserver/rest/workspaces/acme.xml" type="application/xml"/>
</workspace>
<connectionParameters>
<entry key="port">5432</entry>
<entry key="dbtype">postgis</entry>
<entry key="host">localhost</entry>
<entry key="user">bob</entry>
<entry key="database">nyc</entry>
<entry key="namespace">http://acme</entry>
</connectionParameters>
<__default>false</__default>
<featureTypes>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate"
href="http://localhost:8080/geoserver/rest/workspaces/acme/datastores/nyc/featuretypes.xml"
type="application/xml"/>
</featureTypes>
</dataStore>
从现有PostGIS存储发布表¶
从PostGIS存储表“建筑物”中发布新功能类型
备注
此示例假定已创建表。
请求
卷曲
curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml"
-d "<featureType><name>buildings</name></featureType>"
http://localhost:8080/geoserver/rest/workspaces/acme/datastores/nyc/featuretypes
备注
可以使用WMS GETMAP请求查看此层:
http://localhost:8080/geoserver/wms/reflect?layers=acme:buildings
创建PostGIS表¶
在geoserver中创建一个新的featureType,同时在postgis中创建一个表。
给定以下内容另存为 annotations.xml
:
<featureType>
<name>annotations</name>
<nativeName>annotations</nativeName>
<title>Annotations</title>
<srs>EPSG:4326</srs>
<attributes>
<attribute>
<name>the_geom</name>
<binding>org.locationtech.jts.geom.Point</binding>
</attribute>
<attribute>
<name>description</name>
<binding>java.lang.String</binding>
</attribute>
<attribute>
<name>timestamp</name>
<binding>java.util.Date</binding>
</attribute>
</attributes>
</featureType>
请求
卷曲
curl -v -u admin:geoserver -XPOST -T annotations.xml -H "Content-type: text/xml"
http://localhost:8080/geoserver/rest/workspaces/acme/datastores/nyc/featuretypes
备注
纽约商店必须是一个Postgis商店才能成功。
响应
201 Created
也将在“NYC”数据库中创建一个名为“annotations”的新的空表。
添加外部WMTS存储¶
Create a new WMTS store "Basemap-Nat-Geo-Datastore"
请求
卷曲
curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml"
-d "<wmtsStore><name>basemap-nat-geo-datastore</name><description>esri-street-map</description><capabilitiesURL>https://services.arcgisonline.com/arcgis/rest/services/NatGeo_World_Map/MapServer/WMTS/1.0.0/WMTSCapabilities.xml</capabilitiesURL><type>WMTS</type></wmtsStore>"
http://localhost:8080/geoserver/rest/workspaces/acme/wmtsstores
响应
201 Created
添加外部WMTS图层¶
Publish a new WMTS Layer "NatGeo_World_Map" from the WMTS store "Basemap-Nat-Geo-Datastore"
请求
卷曲
curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml"
-d "<wmtsLayer><name>NatGeo_World_Map</name></wmtsLayer>"
http://localhost:8080/geoserver/rest/workspaces/acme/wmtsstores/Basemap-Nat-Geo-Datastore/layers
响应
201 Created