REST 上传 Shapefile

发布于 2024-07-30 07:47:55 字数 680 浏览 3 评论 0原文

我正在尝试使用 REST API 上传形状文件。 这是我得到的错误: 没有这样的数据存储:ws1,nete

我已经安装了版本 1.7.5 以及restconfig-1.7.5.jar 插件。

这是我所做的: 1) 创建工作区 ws1

curl -u admin:geoserver -v -XPOST -H 'Content-type: text/xml' -d 'ws1'localhost:8080/geoserver/rest/workspaces

2) 检查工作区

curl -XGET -H '接受:text/xml' localhost:8080/geoserver/rest/workspaces/ws1

回复即可

3) 上传 shapefile

curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @roads .zip localhost:8080/geoserver/rest/workspaces/ws1/datastores/roads/file.shp

回复:

警告:无法从文件“roads.z​​ip”读取数据,这会生成一个空的 POST。 解压缩文件时发生错误:打开 zip 时出错,

需要帮助!!!

I'm trying to upload a shape file with REST API.
Here is the error I get :
No such datastore: ws1,nete

I've installed version 1.7.5 together with the restconfig-1.7.5.jar plugin.

Here is what I do:
1) Create workspace ws1

curl -u admin:geoserver -v -XPOST -H 'Content-type: text/xml' -d 'ws1'localhost:8080/geoserver/rest/workspaces

2) Check workspace

curl -XGET -H 'Accept: text/xml' localhost:8080/geoserver/rest/workspaces/ws1

reply is ok

3) Upload shapefile

curl -u admin:geoserver -XPUT -H 'Content-type: application/zip' --data-binary @roads.zip localhost:8080/geoserver/rest/workspaces/ws1/datastores/roads/file.shp

Reply:

Warning: Couldn't read data from file "roads.zip", this makes an empty POST.
Error occured unzipping file:error in opening zip

need help please!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

残月升风 2024-08-06 07:47:56

今天我也问了自己同样的问题,终于解决了。 我正在运行带有 REST 扩展的 Geoserver 2.0.2。

以下curl命令正在工作:

curl -u admin:geoserver -v -XPUT -H 'Content-type: application/zip' --data-binary @/home/shape.zip http://localhost:8085/geoserver/rest/workspaces/ws/datastores/test1/file.shp

“.shp”前面的“文件”是任意的,使用你喜欢的。

“test1”是新数据存储的名称。

“/home/shape.zip”是压缩 Shapefile 的路径。 注意:一个Shapefile由多个文件组成! 参见维基百科的介绍。 Geoserver 的压缩 Shapefie 至少应包含 .shp、.dbf、.shx、.prj。

如果您使用 Java 进行开发,您可能希望使用 Java 客户端通过 REST 配置 Geoserver。 GSRCJ 是一个用 Java 1.5+ 编写的非常小的(2 个类,零依赖项)客户端。 它不是一个完整的实现,但具有如何将 Shapefile 上传到 Geoserver 等的工作代码。 请参阅此处的代码< /a>.

I asked myself the same problem today, and solved it finally. I am running Geoserver 2.0.2 with REST extension.

The following curl command is working:

curl -u admin:geoserver -v -XPUT -H 'Content-type: application/zip' --data-binary @/home/shape.zip http://localhost:8085/geoserver/rest/workspaces/ws/datastores/test1/file.shp

The "file" in front of ".shp" is arbitrary, use what you like.

"test1" is the name of the new datastore.

"/home/shape.zip" is path to a zipped Shapefile. Note: A Shapefile consists of multiple files! See wIkipedia for an introduction. A zipped Shapefie for Geoserver should at least contain .shp, .dbf, .shx, .prj.

If you are developing in Java, you might want to use a Java client to configure Geoserver via REST. GSRCJ is a very small (2 classes, zero dependencies) client written in Java 1.5+. It is not a complete implementation, but has working code of how to upload a Shapefile to Geoserver and more. See the code here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文