use ResourceURL for WMTS layers for REST encoding. p=fredj,me r=elemoine,me (closes http://trac.osgeo.org/openlayers/ticket/3044)
This commit is contained in:
@@ -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
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 <requestEncoding>.
|
||||
*/
|
||||
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<this.dimensions.length; i++) {
|
||||
if (this.params[this.dimensions[i]]) {
|
||||
path = path + this.params[this.dimensions[i]] + "/";
|
||||
params = this.params;
|
||||
if (typeof this.url === "string" && this.url.indexOf("{") !== -1) {
|
||||
var template = this.url.replace(/\{/g, "${");
|
||||
var context = {
|
||||
// spec does not make clear if capital S or not
|
||||
style: this.style, Style: this.style,
|
||||
TileMatrixSet: this.matrixSet,
|
||||
TileMatrix: this.matrix.identifier,
|
||||
TileRow: info.row,
|
||||
TileCol: info.col
|
||||
};
|
||||
if (dimensions) {
|
||||
var dimension, i;
|
||||
for (i=dimensions.length-1; 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<dimensions.length; i++) {
|
||||
if (params[dimensions[i]]) {
|
||||
path = path + params[dimensions[i]] + "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
} else {
|
||||
url = this.url;
|
||||
}
|
||||
if (!url.match(/\/$/)) {
|
||||
url = url + "/";
|
||||
}
|
||||
url = url + path;
|
||||
}
|
||||
} else if (this.requestEncoding.toUpperCase() === "KVP") {
|
||||
|
||||
// assemble all required parameters
|
||||
var params = {
|
||||
params = {
|
||||
SERVICE: "WMTS",
|
||||
REQUEST: "GetTile",
|
||||
VERSION: this.version,
|
||||
|
||||
Reference in New Issue
Block a user