开发者

Dynamic MapServer on OpenLayers

开发者 https://www.devze.com 2023-01-13 19:33 出处:网络
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&

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 mapf开发者_运维技巧ile 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


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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号