OpenLayers 上的动态地图服务器

发布于 2024-09-16 16:15:41 字数 799 浏览 4 评论 0原文

我正在努力解决一个特殊的设置:我们在 OpenLayers 中有一个 WMS 层(在 GeoExt Web 界面内)调用 MapServer 字符串(例如 http://mydomain/cgi-bin/mapserv.exe?map=someMapFile.map&etcetc)。

现在我们需要将数据集分成几个层。 我们尝试实例化 n 个单独的 WMS 图层,但速度太慢,因此我们尝试一个非常简单的解决方案:生成仅包含所需图层的自定义地图文件。此动态映射文件由服务返回:

http://mydomain/myservice/get?layers =listoflayers,otherparams,etc 返回自定义地图文件的路径。该解决方案非常简单且高效。

因此,现在我们应该更新 WMS 图层,以便动态替换此地图文件,而无需重新加载整个页面。

所以我的问题是:

  • 这可能吗?

  • 是否可以拥有一个单独的图层列表(不是 OpenLayers 提供的默认图层列表)并触发事件“changeLayers”?有这种设置的示例吗?

预先感谢您的任何提示!

穆隆

I'm struggling with a peculiar set up: we have a WMS layer in OpenLayers (within a GeoExt web interface) invoking a MapServer string (e.g. http://mydomain/cgi-bin/mapserv.exe?map=someMapFile.map&etcetc).

Now we need to split the dataset into several layers.
We tried by instanciating n separate WMS layers and it's way too slow, so we're trying a pretty simple solution: generating a custom mapFile containing only the required layers. This dynamic mapfile is returned by a service:

http://mydomain/myservice/get?layers=listoflayers,otherparams,etc that returns the path to the custom mapfile. This solution is very simple and efficient.

So now we should update the WMS layer in order to replace this mapfile on the fly, without reloading the whole page.

So my questions are:

  • Is this possible?

  • Is it ok to have a separate layer list (not the default one offered by OpenLayers) and trigger an event "changeLayers"? Are there any examples of this setup?

Thanks in advance for any hints!

Mulone

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

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

发布评论

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

评论(2

如梦亦如幻 2024-09-23 16:15:41

为此,您不需要动态地图文件。 GetMap请求有一个参数LAYERS。

LAYERS=layer_list:一个或多个地图图层的逗号分隔列表。如果存在 SLD 参数,则可选。 (http://mapserver.org/ogc/wms_server.html)

或者你在做什么除了选择图层的子集之外还可以吗?

You shouldn't need dynamic mapfiles for this. The GetMap request has a parameter LAYERS.

LAYERS=layer_list: Comma-separated list of one or more map layers. Optional if SLD parameter is present. (http://mapserver.org/ogc/wms_server.html)

Or are you doing anything else but selecting a subset of layers?

绝對不後悔。 2024-09-23 16:15:41

在我看来,在您提到的情况下,最好将 WMS 地图文件分解为几层。即使在某些情况下,数据来自完全相同的来源,但您仍然可以应用一些过滤器以在 WMS 中拥有多个图层。

例如,某个地方有 100 万条道路存储在数据库的表中,要发布道路要素,您可能会为该数据集创建多个图层。图层可以按年份、类型或基于属性或空间关系的任何内容进行过滤。当在图层块或图层文件中使用过滤器解析字符串以通过数据库连接进行查询时,会发生这种情况。当您生成请求字符串时,图层名称可以是动态的,所以我认为这可能就是您正在寻找的。

因此,在此之后,当您只对州际公路感兴趣时,您可以通过在请求中使用“layer=interstate_road”来仅查询州际公路层,而不是对 WMS 请求中的所有图层使用 WMS 端点。然后仅返回州际公路,而不是详尽地扫描/渲染整个数据集。

如果您不介意多读一点,MapServer 中也有空间、非空间过滤器。例如,过滤器编码将为您提供要素级别的空间/非空间查询。它也是动态的,因为过滤器位于请求 URL 内,您也可以动态更改它。

In my opinion, in the case like you mentioned, it is good to break down the WMS mapfile into several layers. Even in some cases the data are from exact same source but you can still apply some filter to have multiple layers in your WMS.

For example, there are 1 million road in a place that stored in a table in database, to publish the road feature, you could potentially have several layers for this dataset. Layers can be filter by year, or by type or whatever you want based on the attribute or spatial relationship. This happens when using filter in your layer block or layer file parsing the string to query via database connection. The layers name can be dynamic when you generate your request string so i think that's maybe what you are looking for.

So after this, when you only interested in, say, interstate road, instead of using the WMS endpoint for the whole bunch of layers in your WMS request, you can query only against the interstate layer by using 'layer=interstate_road' in the request. Then only interstate road would be returned not exhaustively scanning/rendering the whole dataset.

And if you don't mind read a little bit more, there are spatial, non-spatial filter in MapServer as well. For example the filter encoding, would provide you spatial/non spatial query at feature level. And it is also dynamic because the filter is within the request url which you can change dynamically as well.

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