diff --git a/changelog/upgrade-notes.md b/changelog/upgrade-notes.md index 1efc662d75..c3b851276b 100644 --- a/changelog/upgrade-notes.md +++ b/changelog/upgrade-notes.md @@ -19,6 +19,7 @@ A number of internal types have been renamed. This will not affect those who us * rename `ol.OverlayPositioning` to `ol.Overlay.Positioning` * rename `ol.control.MousePositionProperty` to `ol.control.MousePosition.Property` * rename `ol.layer.VectorTileRenderType` to `ol.layer.VectorTile.RenderType` + * rename `ol.source.WMTSRequestEncoding` to `ol.source.WMTS.RequestEncoding` ### v3.18.0 diff --git a/externs/olx.js b/externs/olx.js index c4acd7f48e..62d4e6f2d7 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5985,7 +5985,7 @@ olx.source.VectorOptions.prototype.wrapX; * tileGrid: ol.tilegrid.WMTS, * projection: ol.ProjectionLike, * reprojectionErrorThreshold: (number|undefined), - * requestEncoding: (ol.source.WMTSRequestEncoding|string|undefined), + * requestEncoding: (ol.source.WMTS.RequestEncoding|string|undefined), * layer: string, * style: string, * tilePixelRatio: (number|undefined), @@ -6067,7 +6067,7 @@ olx.source.WMTSOptions.prototype.reprojectionErrorThreshold; /** * Request encoding. Default is `KVP`. - * @type {ol.source.WMTSRequestEncoding|string|undefined} + * @type {ol.source.WMTS.RequestEncoding|string|undefined} * @api stable */ olx.source.WMTSOptions.prototype.requestEncoding; diff --git a/src/ol/source/wmts.js b/src/ol/source/wmts.js index 454404c05f..147d6e4688 100644 --- a/src/ol/source/wmts.js +++ b/src/ol/source/wmts.js @@ -1,5 +1,4 @@ goog.provide('ol.source.WMTS'); -goog.provide('ol.source.WMTSRequestEncoding'); goog.require('ol'); goog.require('ol.TileUrlFunction'); @@ -12,16 +11,6 @@ goog.require('ol.tilegrid.WMTS'); goog.require('ol.uri'); -/** - * Request encoding. One of 'KVP', 'REST'. - * @enum {string} - */ -ol.source.WMTSRequestEncoding = { - KVP: 'KVP', // see spec §8 - REST: 'REST' // see spec §10 -}; - - /** * @classdesc * Layer source for tile data from WMTS servers. @@ -81,11 +70,11 @@ ol.source.WMTS = function(options) { /** * @private - * @type {ol.source.WMTSRequestEncoding} + * @type {ol.source.WMTS.RequestEncoding} */ this.requestEncoding_ = options.requestEncoding !== undefined ? - /** @type {ol.source.WMTSRequestEncoding} */ (options.requestEncoding) : - ol.source.WMTSRequestEncoding.KVP; + /** @type {ol.source.WMTS.RequestEncoding} */ (options.requestEncoding) : + ol.source.WMTS.RequestEncoding.KVP; var requestEncoding = this.requestEncoding_; @@ -101,7 +90,7 @@ ol.source.WMTS = function(options) { 'tilematrixset': this.matrixSet_ }; - if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) { + if (requestEncoding == ol.source.WMTS.RequestEncoding.KVP) { ol.obj.assign(context, { 'Service': 'WMTS', 'Request': 'GetTile', @@ -122,7 +111,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.WMTSRequestEncoding.KVP) ? + template = (requestEncoding == ol.source.WMTS.RequestEncoding.KVP) ? ol.uri.appendParams(template, context) : template.replace(/\{(\w+?)\}/g, function(m, p) { return (p.toLowerCase() in context) ? context[p.toLowerCase()] : m; @@ -146,7 +135,7 @@ ol.source.WMTS = function(options) { }; ol.obj.assign(localContext, dimensions); var url = template; - if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) { + if (requestEncoding == ol.source.WMTS.RequestEncoding.KVP) { url = ol.uri.appendParams(url, localContext); } else { url = url.replace(/\{(\w+?)\}/g, function(m, p) { @@ -229,7 +218,7 @@ ol.source.WMTS.prototype.getMatrixSet = function() { /** * Return the request encoding, either "KVP" or "REST". - * @return {ol.source.WMTSRequestEncoding} Request encoding. + * @return {ol.source.WMTS.RequestEncoding} Request encoding. * @api */ ol.source.WMTS.prototype.getRequestEncoding = function() { @@ -442,8 +431,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.WMTSRequestEncoding.KVP) { - if (ol.array.includes(encodings, ol.source.WMTSRequestEncoding.KVP)) { + if (requestEncoding === ol.source.WMTS.RequestEncoding.KVP) { + if (ol.array.includes(encodings, ol.source.WMTS.RequestEncoding.KVP)) { urls.push(/** @type {string} */ (gets[i]['href'])); } } else { @@ -452,7 +441,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) { } } if (urls.length === 0) { - requestEncoding = ol.source.WMTSRequestEncoding.REST; + requestEncoding = ol.source.WMTS.RequestEncoding.REST; l['ResourceURL'].forEach(function(element) { if (element['resourceType'] === 'tile') { format = element['format']; @@ -476,3 +465,13 @@ 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 +};