ol2
ol2 copied to clipboard
WMS 1.3.0 Capabilities parser with a capabilities document including sld:GetLegendGraphic element fails
A WMS 1.3.0 service that has a Capability > Request like:
<sld:GetLegendGraphic>
<Format>image/png</Format>
<Format>image/gif</Format>
<Format>image/jpeg</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="http://server/wms/railway?"/>
</Get>
<Post>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="http://server/wms/railway?"/>
</Post>
</HTTP>
</DCPType>
</sld:GetLegendGraphic>
causes the WMS capabilities parser to fail.
I think is related to the WMS v1.3 parser extending v1 instead of v1.1.:
https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Format/WMSCapabilities/v1_3.js#L28
The problem seem that the delegation of the following code fails:
https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Format/WMSCapabilities/v1_3.js#L134-L136
as this.readers.wms.GetLegendGraphic
is not defined in v1 parser, only in v1.1 parser.
Code snippet used to parse the WMS capabilities response:
format = new OpenLayers.Format.WMSCapabilities({
namespaces: {"sld": "http://www.opengis.net/sld",
"wms": "http://www.opengis.net/wms",
"xlink": "http://www.w3.org/1999/xlink",
"xsi": "http://www.w3.org/2001/XMLSchema-instance"}
});
OpenLayers.Request.GET({
url: "http://server/wms/railway?",
params: {
SERVICE: "WMS",
VERSION: "1.3.0",
REQUEST: "GetCapabilities"
},
success: function(request) {
var doc = request.responseXML;
if (!doc || !doc.documentElement) {
doc = request.responseText;
}
var capabilities = format.read(doc);
// Additional code
},
failure: function() {
alert("Trouble getting capabilities doc");
OpenLayers.Console.error.apply(OpenLayers.Console, arguments);
}
});