Merge pull request #695 from ahocevar/wmts
Support for multiple resource urls for WMTS. r=@sbrunner
This commit is contained in:
@@ -73,6 +73,8 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers
|
||||
* matrixSet - {String} The matrix set identifier, required if there is
|
||||
* more than one matrix set in the layer capabilities.
|
||||
* style - {String} The name of the style
|
||||
* format - {String} Image format for the layer. Default is the first
|
||||
* format returned in the GetCapabilities response.
|
||||
* param - {Object} The dimensions values eg: {"Year": "2012"}
|
||||
*
|
||||
* Returns:
|
||||
@@ -102,6 +104,11 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers
|
||||
if (!layerDef) {
|
||||
throw new Error("Layer not found");
|
||||
}
|
||||
|
||||
var format = config.format;
|
||||
if (!format && layerDef.formats && layerDef.formats.length) {
|
||||
format = layerDef.formats[0];
|
||||
}
|
||||
|
||||
// find the matrixSet definition
|
||||
var matrixSet;
|
||||
@@ -170,17 +177,26 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers
|
||||
}
|
||||
|
||||
var url;
|
||||
if (requestEncoding === "REST" && layerDef.resourceUrl) {
|
||||
url = layerDef.resourceUrl.tile.template;
|
||||
if (requestEncoding === "REST" && layerDef.resourceUrls) {
|
||||
url = [];
|
||||
var resourceUrls = layerDef.resourceUrls,
|
||||
resourceUrl;
|
||||
for (var t = 0, tt = layerDef.resourceUrls.length; t < tt; ++t) {
|
||||
resourceUrl = layerDef.resourceUrls[t];
|
||||
if (resourceUrl.format === format && resourceUrl.resourceType === "tile") {
|
||||
url.push(resourceUrl.template);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
var httpGet = capabilities.operationsMetadata.GetTile.dcp.http.get;
|
||||
url = httpGet[0].url;
|
||||
url = [];
|
||||
var constraint;
|
||||
for (var i = 0, ii = httpGet.length; i < ii; i++) {
|
||||
if (httpGet[i].constraints && httpGet[i].constraints.
|
||||
GetEncoding.allowedValues[requestEncoding]) {
|
||||
url = httpGet[i].url;
|
||||
break;
|
||||
constraint = httpGet[i].constraints;
|
||||
if (!constraint || (constraint && constraint.
|
||||
GetEncoding.allowedValues[requestEncoding])) {
|
||||
url.push(httpGet[i].url);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,6 +207,7 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers
|
||||
requestEncoding: requestEncoding,
|
||||
name: layerDef.title,
|
||||
style: style.identifier,
|
||||
format: format,
|
||||
matrixIds: matrixSet.matrixIds,
|
||||
matrixSet: matrixSet.identifier,
|
||||
projection: projection,
|
||||
|
||||
@@ -195,10 +195,16 @@ OpenLayers.Format.WMTSCapabilities.v1_0_0 = OpenLayers.Class(
|
||||
},
|
||||
"ResourceURL": function(node, obj) {
|
||||
obj.resourceUrl = obj.resourceUrl || {};
|
||||
obj.resourceUrl[node.getAttribute("resourceType")] = {
|
||||
var resourceType = node.getAttribute("resourceType");
|
||||
if (!obj.resourceUrls) {
|
||||
obj.resourceUrls = [];
|
||||
}
|
||||
var resourceUrl = obj.resourceUrl[resourceType] = {
|
||||
format: node.getAttribute("format"),
|
||||
template: node.getAttribute("template")
|
||||
template: node.getAttribute("template"),
|
||||
resourceType: resourceType
|
||||
};
|
||||
obj.resourceUrls.push(resourceUrl);
|
||||
},
|
||||
// not used for now, can be added in the future though
|
||||
/*"Themes": function(node, obj) {
|
||||
|
||||
Reference in New Issue
Block a user