diff --git a/lib/OpenLayers/Format/WMTSCapabilities.js b/lib/OpenLayers/Format/WMTSCapabilities.js index bc5d35d211..6ed811ad99 100644 --- a/lib/OpenLayers/Format/WMTSCapabilities.js +++ b/lib/OpenLayers/Format/WMTSCapabilities.js @@ -114,10 +114,13 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers layer = new OpenLayers.Layer.WMTS( OpenLayers.Util.applyDefaults(config, { - url: capabilities.operationsMetadata.GetTile.dcp.http.get, + url: config.requestEncoding === "REST" && layerDef.resourceUrl ? + layerDef.resourceUrl.tile.template : + capabilities.operationsMetadata.GetTile.dcp.http.get, name: layerDef.title, style: style.identifier, - matrixIds: matrixSet.matrixIds + matrixIds: matrixSet.matrixIds, + tileFullExtent: matrixSet.bounds }) ); } diff --git a/lib/OpenLayers/Layer/WMTS.js b/lib/OpenLayers/Layer/WMTS.js index 54d6d55be0..970942e240 100644 --- a/lib/OpenLayers/Layer/WMTS.js +++ b/lib/OpenLayers/Layer/WMTS.js @@ -38,7 +38,10 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, { /** * APIProperty: url - * {String} The base URL for the WMTS service. Must be provided. + * {String|Array(String)} The base URL or request URL template for the WMTS + * service. Must be provided. Array is only supported for base URLs, not + * for request URL templates. URL templates are only supported for + * REST . */ url: null, @@ -416,39 +419,59 @@ OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, { var center = bounds.getCenterLonLat(); var info = this.getTileInfo(center); var matrixId = this.matrix.identifier; + var dimensions = this.dimensions, params; if (this.requestEncoding.toUpperCase() === "REST") { - - // include 'version', 'layer' and 'style' in tile resource url - var path = this.version + "/" + this.layer + "/" + this.style + "/"; - - // append optional dimension path elements - if (this.dimensions) { - for (var i=0; i=0; --i) { + dimension = dimensions[i]; + context[dimension] = params[dimension.toUpperCase()]; } } - } - - // append other required path elements - path = path + this.matrixSet + "/" + this.matrix.identifier + - "/" + info.row + "/" + info.col + "." + this.formatSuffix; - - if (OpenLayers.Util.isArray(this.url)) { - url = this.selectUrl(path, this.url); + url = OpenLayers.String.format(template, context); } else { - url = this.url; - } - if (!url.match(/\/$/)) { - url = url + "/"; - } - url = url + path; + // include 'version', 'layer' and 'style' in tile resource url + var path = this.version + "/" + this.layer + "/" + this.style + "/"; + // append optional dimension path elements + if (dimensions) { + for (var i=0; i