ThinkGeo.com    |     Documentation    |     Premium Support

WMS Styles and Layer Names

Hi,

I’ve been working on implementing the WMSRasterLayer into my project and I’m a bit confused by a few of the details regarding layer names and styles.

First, it seems the only way to find what layers are available to display is to call GetServerLayerNames; however, this returns the name but that is not the commonly referred Title that most users see when loading WMS in other products such as ArcMAP or QGis. Is there a way to find the Title of a layer rather than the name?

Second, I have found that styles are particularly problematic. The GetServerStyleNames function returns all styles names, but there is no way to determine which styles refer to which layers. Not only that, it seems there are multiple styles that can be applied to layers. In the example I am working with, there are 11 layers and 60 styles available. How can I figure out which of the styles are associated with a given layer?

Finally, if I don’t assign any ActiveStyleNames, I still get a display. What is the exact behavior here? Is it loading all available styles for the layer? It seemed to be the case, but I found if I added more than 1 style to the ActvieStyleNames that I get a “styles does not match the number of specified layers” error.

Thanks,
Damian

Hi Damian,

Thanks for the question. WmsRasterLayer is designed according to the “WMS Specification” as the purpose of rendering, “title” is only a human-readable string for presentation in a menu, while “Name” is a map layer that can be requested by using that name in the LAYERS parameter of a GetMap request. If a layer has a Title but no name, then that layer is only a category title for all the layers nested within. I guess that’s the reason why only public the methods, such as GetServerLayerNames, GetServerStyleNames, GetServerCrss etc. All will be used as the parameters of GetMap request. To get more details of the service, we can call “GetServerCapabilitiesXml” method instead, such as the Title of a layer mentioned.

Very sorry that there isn’t a kind of method provided to get only styles of a specific layer, please still try “GetServerCapabilitiesXml” method to get its service capabilities to take a check, the response should be an xml file, similar to http://ows.mundialis.de/services/service?version=1.3.0&request=GetCapabilities , there we can get all details.

The STYLES parameter lists the style in which each layer is to be rendered. The value of the STYLES parameter is a comma-separated list of one or more valid style names. There is a one-to-one correspondence between the values in the LAYERS parameter and the values in the STYLES parameter. Each map in the list of LAYERS is drawn using the corresponding style in the same position in the list of STYLES. Each style Name shall be one that was defined in a element that is either directly contained within. A server shall throw a service exception (code = StyleNotDefined) if an unadvertised Style is requested. A client may request the default Style using a null value (as in “STYLES=”). In other words, if not any ActiveStyleNames assigned, a default style would be used for display, instead of loading all available styles for the layer. To avoiding the error “styles does not match the number of specified layers”, we should have same number of ActiveStyleNames to ActiveLayerNames, just as mentioned early, STYLES should be one-to-one correspondence to LAYERS.

Hope it helped.

Thanks,
Johnny

Thanks Johnny. The GetServerCapabilitiesXml is what I was looking for.

Regards,
Damian

Sorry for the inconvenience, glad to hear that it helped, the suggestion is an good idea, I have listed it in the task tracking system.

Thanks,
Johnny