diff --git a/externs/olx.js b/externs/olx.js index 6e4c60afcf..14579f32fe 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -6194,7 +6194,7 @@ olx.source.VectorOptions.prototype.wrapX; * tileGrid: ol.tilegrid.WMTS, * projection: ol.ProjectionLike, * reprojectionErrorThreshold: (number|undefined), - * requestEncoding: (ol.source.WMTS.RequestEncoding|string|undefined), + * requestEncoding: (ol.source.WMTSRequestEncoding|string|undefined), * layer: string, * style: string, * tilePixelRatio: (number|undefined), @@ -6276,7 +6276,7 @@ olx.source.WMTSOptions.prototype.reprojectionErrorThreshold; /** * Request encoding. Default is `KVP`. - * @type {ol.source.WMTS.RequestEncoding|string|undefined} + * @type {ol.source.WMTSRequestEncoding|string|undefined} * @api stable */ olx.source.WMTSOptions.prototype.requestEncoding; diff --git a/src/ol/source/wmts.js b/src/ol/source/wmts.js index dc93580883..7d62d24cc3 100644 --- a/src/ol/source/wmts.js +++ b/src/ol/source/wmts.js @@ -7,6 +7,7 @@ goog.require('ol.extent'); goog.require('ol.obj'); goog.require('ol.proj'); goog.require('ol.source.TileImage'); +goog.require('ol.source.WMTSRequestEncoding'); goog.require('ol.tilegrid.WMTS'); goog.require('ol.uri'); @@ -70,11 +71,11 @@ ol.source.WMTS = function(options) { /** * @private - * @type {ol.source.WMTS.RequestEncoding} + * @type {ol.source.WMTSRequestEncoding} */ this.requestEncoding_ = options.requestEncoding !== undefined ? - /** @type {ol.source.WMTS.RequestEncoding} */ (options.requestEncoding) : - ol.source.WMTS.RequestEncoding.KVP; + /** @type {ol.source.WMTSRequestEncoding} */ (options.requestEncoding) : + ol.source.WMTSRequestEncoding.KVP; var requestEncoding = this.requestEncoding_; @@ -90,7 +91,7 @@ ol.source.WMTS = function(options) { 'tilematrixset': this.matrixSet_ }; - if (requestEncoding == ol.source.WMTS.RequestEncoding.KVP) { + if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) { ol.obj.assign(context, { 'Service': 'WMTS', 'Request': 'GetTile', @@ -111,7 +112,7 @@ ol.source.WMTS = function(options) { // order conforms to wmts spec guidance, and so that we can avoid to escape // special template params - template = (requestEncoding == ol.source.WMTS.RequestEncoding.KVP) ? + template = (requestEncoding == ol.source.WMTSRequestEncoding.KVP) ? ol.uri.appendParams(template, context) : template.replace(/\{(\w+?)\}/g, function(m, p) { return (p.toLowerCase() in context) ? context[p.toLowerCase()] : m; @@ -135,7 +136,7 @@ ol.source.WMTS = function(options) { }; ol.obj.assign(localContext, dimensions); var url = template; - if (requestEncoding == ol.source.WMTS.RequestEncoding.KVP) { + if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) { url = ol.uri.appendParams(url, localContext); } else { url = url.replace(/\{(\w+?)\}/g, function(m, p) { @@ -218,7 +219,7 @@ ol.source.WMTS.prototype.getMatrixSet = function() { /** * Return the request encoding, either "KVP" or "REST". - * @return {ol.source.WMTS.RequestEncoding} Request encoding. + * @return {ol.source.WMTSRequestEncoding} Request encoding. * @api */ ol.source.WMTS.prototype.getRequestEncoding = function() { @@ -438,8 +439,8 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { // requestEncoding not provided, use the first encoding from the list requestEncoding = encodings[0]; } - if (requestEncoding === ol.source.WMTS.RequestEncoding.KVP) { - if (ol.array.includes(encodings, ol.source.WMTS.RequestEncoding.KVP)) { + if (requestEncoding === ol.source.WMTSRequestEncoding.KVP) { + if (ol.array.includes(encodings, ol.source.WMTSRequestEncoding.KVP)) { urls.push(/** @type {string} */ (gets[i]['href'])); } } else { @@ -448,7 +449,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { } } if (urls.length === 0) { - requestEncoding = ol.source.WMTS.RequestEncoding.REST; + requestEncoding = ol.source.WMTSRequestEncoding.REST; l['ResourceURL'].forEach(function(element) { if (element['resourceType'] === 'tile') { format = element['format']; @@ -472,13 +473,3 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { }; }; - - -/** - * Request encoding. One of 'KVP', 'REST'. - * @enum {string} - */ -ol.source.WMTS.RequestEncoding = { - KVP: 'KVP', // see spec §8 - REST: 'REST' // see spec §10 -}; diff --git a/src/ol/source/wmtsrequestencoding.js b/src/ol/source/wmtsrequestencoding.js new file mode 100644 index 0000000000..27b1fba80d --- /dev/null +++ b/src/ol/source/wmtsrequestencoding.js @@ -0,0 +1,10 @@ +goog.provide('ol.source.WMTSRequestEncoding'); + +/** + * Request encoding. One of 'KVP', 'REST'. + * @enum {string} + */ +ol.source.WMTSRequestEncoding = { + KVP: 'KVP', // see spec §8 + REST: 'REST' // see spec §10 +};