WMS/WFS 服务器:我自己写是疯了吗?

发布于 2024-10-24 07:20:57 字数 1889 浏览 7 评论 0原文

我是一个“自己动手”的人,但我想确保我不会因为试图贪多嚼不烂而把自己搞砸。

我正在编写一个基于浏览器的地图应用程序,需要选择在最终用户的计算机上独立运行(无互联网连接)。也就是说,应用程序是某种服务器,在许多情况下,它会安装在最终用户的计算机上,并且浏览器将指向某个本地主机 URL 来访问它。

我将在客户端使用MapLayers,服务器端将有一堆特定于应用程序的自定义逻辑,例如以某些自定义方式处理地图上的点击事件,在特定时间在地图上创建各种自定义对象,等等。

对于服务器的“业务逻辑”部分,我很高兴将paste/webob 与python 一起使用。这是一个简单的基础设施,让我可以轻松地将所有这些自定义逻辑放入其中。

我一直认为客户端将与两个服务器通信:这个paste/webob 业务逻辑服务器,以及一个仅用于服务WMS 和WFS 地图元素的服务器。所以我正在寻找 MapServer 和 GeoServer 来处理地图部分......我不高兴。

我不高兴,因为我不想安装并担心客户端计算机上的“野兽”。对于 MapServer,我真的不想安装像 Apache 这样成熟的 Web 服务器,并且必须处理 CGI、PHP 和 MapScript。对于 GeoServer,(可能)需要安装 Java,并处理 GeoServer 设置和管理的各种复杂性。

部分原因只是学习曲线问题。如果我能避免的话,我对学习 MapServer 或 GeoServer 的复杂性并不是特别感兴趣。我安装了 GeoServer,将其指向我的一些数据,并且能够使用 GeoServer 漂亮的 Web 管理中内置的 MapLayers 预览来查看我的数据。但是当我尝试使用我自己的指向 GeoServer 的 MapLayers 网页来提供真实的数据时,我使 GeoServer 崩溃了。我很惊讶,仅仅从客户端发送一些可能格式错误的请求就可能导致服务器崩溃。我可以深入研究 GeoServer 日志来尝试找出我做错了什么,但是......我真的不想花很多时间在这上面。

因此,我正在考虑使用我已有的粘贴/webob 服务器来自己实现 WMS 和 WFS 界面的部分内容。事实上,我可能只需要 WMS,因为我可以通过一个简单的自定义协议来处理矢量对象,该协议将数据传递给客户端,然后客户端可以使用 OpenLayers 直接创建和操作对象。

我查看了 WMS 的规范和示例消息(WFS 的规范和示例消息稍少一些)。自己实现这个协议似乎并不困难,特别是因为在这种情况下我可以完全控制客户端——我不需要能够充当通用的 WMS 或 WFS 服务器;我只需要让我自己的 OpenLayers 客户满意即可。

我需要 WMS 服务器具备的两个主要功能是:

  • 从我提前创建的预渲染图块存储中提供图块(我将使用 OpenStreetMap 数据和 mapnik 作为渲染引擎来预渲染图块;我将使用 OpenLayers 期望的正常 Google 地图样式图块命名方案来存储和访问它们)

  • 能够服务器这些图块的修改版本,其中我本地存储的某些数据位于绘制在瓷砖的顶部。例如,我可能在一个“层”上有 10000 个点,在另一层上有 10000 个多边形,当用户激活这些层时,我将提供相同的基础图块,但当我提供这些图块时,我将渲染在这些附加功能之上,我可能会实现一个简单的缓存方案,以将这些过度渲染的图块保留一段时间。

所以我的问题是:尽管我知道现有的工具可以执行这些操作(MapServer、GeoServer、TileCache 等),但我实际上觉得仅响应一些简单的 WMS 消息对我来说工作量较少,并且我自己用 python 在我的图块上进行额外的过度绘制,确保所有内容都正确投影,等等。我不需要为这些覆盖层绘制花哨的宽街道或任何东西,只需简单的线条、图标,也许还有标签。拥有一个仅使用 python 的解决方案听起来确实不错且简单。

我想如果我需要扩展以支持更多的 WMS/WFS 协议,或者进行更高级的透支,我可以在那时插入 MapServer/GeoServer。

这里有我没有考虑到的陷阱吗?

I'm a "do it yourself" kind of guy, but I want to make sure I'm not going to do myself in by trying to bite off more than I can chew.

I am writing a browser-based mapping application that needs to have the option to run standalone (no internet connection) on the end-user's machine. That is, the application is some kind of server that will, in many cases, get installed on the end user's machine and the browser will point to some localhost URL to access it.

I will be using MapLayers on the client side, and the server side will have a bunch of custom logic specific to the application, such as handling click events on the map in certain custom ways, creating various custom objects on the map at certain times, and so on.

For the "business logic" part of the server, I'm happy using paste/webob with python. It's a simple infrastructure that lets me put all this custom logic in easily.

I had been thinking that the client would communicate with two servers: this paste/webob business logic server, and a server just for serving WMS and WFS map elements. So I was looking at MapServer and GeoServer to handle the map parts and ... I'm not happy.

I'm not happy because I don't want to have to install and worry about a "beast" on the client machines. For MapServer, I don't really want to install a full-blown web server like Apache, and have to deal with CGI and PHP and MapScript. For GeoServer, there's (potentially) installing Java, and dealing with various complexities of the GeoServer setup and administration.

Part of this is simply a learning curve issue. If I can avoid it, I'm not especially interested in learning the intricacies of either MapServer or GeoServer. I installed GeoServer, pointed it to some of my data, and was able to use the MapLayers preview built into GeoServer's nice web admin to view my data. But when I tried to serve the data for real using my own MapLayers web page pointed at GeoServer, I crashed GeoServer. That I could crash the server just be sending some presumably malformed requests from the client was quite surprising to me. And I could dig into the GeoServer logs to try to figure out what I did wrong, but ... I don't really want to spend a lot of time on that.

So, I am considering implementing parts of the WMS and WFS interface myself just using the paste/webob server I already have. It may in fact be that I only need the WMS, since I might handle vector objects through a simple custom protocol that I make to pass data to the client, which can then create and manipulate the objects directly using OpenLayers.

I've looked at the specs and example messages for WMS (and a bit less at WFS). It seems not so difficult just to implement this protocol myself, especially because I have full control of the client in this case -- it's not like I need to be able to act as a generic WMS or WFS server; I just have to make my own OpenLayers client happy.

The two main abilities that I need the WMS server to have are:

  • Serve tiles from a store of prerendered tiles that I've created ahead of time (I'll prerender the tiles using OpenStreetMap data and mapnik as the redering engine; and I'll store and access them using the normal Google Maps style tile naming scheme that OpenLayers expects)

  • Have the ability to server modified versions of these tiles where certain data that I store locally is drawn on top of the tiles. For instance, I might have, say, 10000 points on one "layer" and 10000 polygons on another layer, and when the user activates these layers I will serve my same base tiles, but as I'm serving these tiles I'll render these additional features on top of them, and probably I'll implement a simple caching scheme to keep these over-rendered tiles around for some amount of time.

So my question is: Even though I know there are existing tools that do these things (MapServer, GeoServer, TileCache, and others), I'm actually feeling like it's less work for me to just to respond to some simple WMS messages, and do this additional over-drawing on my tiles myself in python, making sure everything is projected correctly, etc. I don't need to draw fancy wide streets or anything for these over-layers, just simple lines, icons, and perhaps labels. It sure sounds nice and simple to have a python-only solution.

I figure if I ever need to expand into supporting more of the WMS/WFS protocol, or doing fancier overdrawing, I can just insert MapServer/GeoServer at that time.

Are there pitfalls here I'm not considering?

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

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

发布评论

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

评论(3

剪不断理还乱 2024-10-31 07:20:57

地图服务器非常容易设置和学习。自己实现任何类型的渲染都需要付出更多的努力,并且您可能会发现很多意想不到的陷阱。

mapserver cgi 应该足以满足您的需求。如果您需要一些非常具体的调整,那么 Mapscript 可能会很有用。

我认为如果您可以制作一个纯 JavaScript 应用程序,并且无需安装 Web 服务器(和地图服务器),那会很有趣。如果您只需要浏览图块马赛克,也许您只需使用 JavaScript 即可完成(生成一个 html 表格,每个图块都有一个单元格)。您可以使用 JavaScript 渲染点或多边形,使用画布并进行一些基本的坐标转换,将地理点转换为像素。我认为 Openlayers 有这个功能。

编辑:我刚刚检查过,使用Openlayers,您可以浏览本地图块,并且可以渲染kml和一些其他矢量数据。所以,我认为你应该尝试一下 Openlayers。

Mapserver is very easy to setup and learn. Implementing any kind of rendering by yourself is going to require much more effort, and you will probably find a lots of unexpected traps.

mapserver cgi should be enough for your needs. If you require some very specific tweak, then mapscript can be useful.

I think it could be interesting if you could make a pure JavaScript application, and save yourself from installing a web server (and a map server). If you just needed browsing a tile mosaic, may be you could do it just with JavaScript (generate an html table with a cell for each tile). You can render points or polygons, with JavaScript, using a canvas and doing some basic coordinate conversion to translate geographic points to pixels. Openlayers have this functionality, I think.

EDIT: I just checked and with Openlayers you can browse local tiles, and you can render kml and some other vect data. So, I think you should give Openlayers a try.

趁年轻赶紧闹 2024-10-31 07:20:57

不需要 wms/wfs。您需要的是一个tile 实现。基本上,您应该拥有某种生成图块的中央服务或桌面服务。生成这些图块后,您可以简单地将它们转换为“非真实网络服务器架构”文件系统。您可以创建符合 /{x}/{y}/{z}.png 的目录结构并从 javascript 调用它。

可以在此处找到 openstreetmap 如何执行此操作的示例: http://wiki.openstreetmap.org/wiki/OpenLayers_Simple_Example

No need to have a wms/wfs. What you need is a tile implementation. Basically you should have some sort of central service, or desktop service that generates the tiles. Once these tiles are generated, you can simply transform them to your "no-real-webserver-architecture" filesystem. You can create a directory structure that conforms to /{x}/{y}/{z}.png and call it from javascript.

An example of how openstreetmap does this can be found here: http://wiki.openstreetmap.org/wiki/OpenLayers_Simple_Example

笑,眼淚并存 2024-10-31 07:20:57

您可能喜欢功能服务器:http://featureserver.org/
它有自己的WFS。我现在正在使用它。

You may like featureserver: http://featureserver.org/.
It has its own WFS. I am using it right now.

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