使用 OpenLayers 将数据保存到 Shapefile

发布于 2024-10-02 23:46:48 字数 107 浏览 1 评论 0原文

我正在使用 OpenLayers 创建一个 Web 应用程序。我已经实现了这样的功能:用户可以向使用 JavaScript 显示的地图添加点或多边形。我现在需要将此数据保存到形状文件中。有什么想法吗?

I am creating a web application using OpenLayers. I have implemented functionality such that a user can add a point or polygon to the map that is displayed using JavaScript. I now need to save this data to a shapefile. Any ideas on how?

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

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

发布评论

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

评论(3

剑心龙吟 2024-10-09 23:46:48

我知道这是一个旧线程,但在我自己进行了一些谷歌搜索以查看是否有任何内容之后,我带着同样的问题来到这里。我的结论是不存在,但可能存在,所以我写了它:

https://code。 google.com/p/js2shapefile/

这是我第一次在 Javascript 中完成这些工作,所以我相信您会发现我的代码有各种奇怪的地方...但是,它有效,无论如何,对于 ESRI Javascript API 图形和 Google 地图标记。它也可以很容易地扩展为将 OpenLayers 向量作为输入,但我还没有时间这样做。

I know it's an old thread but I came here with the same question after doing a bit of googling myself to see if there was anything out there. I concluded that there wasn't but that there could be, so I wrote it:

https://code.google.com/p/js2shapefile/

It's the first time I've done anything along these lines in Javascript so I'm sure you'll find all kinds of oddities with my code...but, it works, for ESRI Javascript API graphics and Google Maps markers, at any rate. It could be easily extended to take OpenLayers vectors as input too, but I haven't got round to doing that.

万水千山粽是情ミ 2024-10-09 23:46:48

您可能必须在服务器上执行此操作,除非有 shapelib 的 javascript 实现。

实际上,您希望网络用户获取要保存的 shapefile 还是将其保存在服务器上?

在服务器上执行此操作的方法有很多种,具体取决于您选择的服务器语言。在 python 中,您只需导入 ogr 库并编写它...您需要使用其中的数据从客户端构造一个 Web 请求...

也许 geoscript 可以提供帮助:

http://geoscriptblog.blogspot.com/2010/06/merging-shapefiles-with-javascript.html< /a>

You'll probably have to do it on the server, unless there's a javascript implementation of shapelib.

Actually, do you want the web user to get a shapefile to save or do you want to save it on the server?

There's lots of ways of doing it on a server, depending on your server language of choice. In python, you just import the ogr library and write it... You'll need to construct a web request from the client with the data in it though...

Maybe geoscript can help:

http://geoscriptblog.blogspot.com/2010/06/merging-shapefiles-with-javascript.html

花海 2024-10-09 23:46:48

此处对此问题有很好的概述。要仅使用客户端 javascipt 转换为形状,您可以基于 JavaScript Shapefile 到 GeoJSON 进行工作库

There's a good overview on this issue here. For converting to shape using client side javascipt only, you could base you work on the JavaScript Shapefile to GeoJSON library.

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