[GIS] How to request group of layers from GeoServer with turn off/on capabilities

geoserverlayerswms

I would like to organize my layers by topics, and for each of them (if chosen on the client-side), I would like to request a single-tile image, which contains the predefined layers in the correct rendering order (e.g. if one topic has 5 layers, it renders them from the bottom to top like this: water, roads, highways, railways, poi). But, I also want to be capable to request just four of it, or three, etc. in any combination but still in the correct order.

My first idea was Geoserver's "Layer group", but as I've learned that is really more suited for group of layers which are not meant to be turned on/off separately. (Please let me know if I am wrong about this, though.) And I also kinda lose GetFeatureInfo capability with this.

After some research I figured out, that in the GetMap request, if I add all my layers' name in the correct order (from bottom to top–>LAYERS=water,roads,highways,railways,poi), I get the same result, and I can also narrow down the list to the required ones.

The GetMap solution seems to by right, but in that case I need to fill up the list for each topic on the client side.

So my main question: is there a solution to get a list of layers from GeoServer by topic in the right rendering order? Or is there an extension for organizing layers this way? (I haven't seen any extension for that purpose)

My idea was that if I organize all layers of a topic to a workspace, I can request a GetCapabilities for the workspace WMS endpoint, parse and read out the layers, but unfortunately it gives back the layers in a pseudo-random order, so not really good. Maybe a custom GetCapabilities XML can solve this?

Please share your ideas, what's the best practice to do this?

I'm on GeoServer 2.4.2.

Best Answer

You don't mention what your client is...

If you're using JavaScript, you can form a WMS request that includes multiple layers and the order in the request changes what order they are rendered in. This is getting into custom web-mapping though, and it will take a bit of coding to set up a UI that lets you turn on and off layers, and ensures that they are rendered in the order you want.

So, let us know what client you're using and I'll update.

Related Question