Rename ol.source.WMTSRequestEncoding to ol.source.WMTS.RequestEncoding

This commit is contained in:
Frederic Junod
2016-08-29 12:52:35 +02:00
committed by Tim Schaub
parent 8b3536fc85
commit 0b2d183009
3 changed files with 23 additions and 23 deletions

View File

@@ -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.OverlayPositioning` to `ol.Overlay.Positioning`
* rename `ol.control.MousePositionProperty` to `ol.control.MousePosition.Property` * rename `ol.control.MousePositionProperty` to `ol.control.MousePosition.Property`
* rename `ol.layer.VectorTileRenderType` to `ol.layer.VectorTile.RenderType` * rename `ol.layer.VectorTileRenderType` to `ol.layer.VectorTile.RenderType`
* rename `ol.source.WMTSRequestEncoding` to `ol.source.WMTS.RequestEncoding`
### v3.18.0 ### v3.18.0

View File

@@ -5985,7 +5985,7 @@ olx.source.VectorOptions.prototype.wrapX;
* tileGrid: ol.tilegrid.WMTS, * tileGrid: ol.tilegrid.WMTS,
* projection: ol.ProjectionLike, * projection: ol.ProjectionLike,
* reprojectionErrorThreshold: (number|undefined), * reprojectionErrorThreshold: (number|undefined),
* requestEncoding: (ol.source.WMTSRequestEncoding|string|undefined), * requestEncoding: (ol.source.WMTS.RequestEncoding|string|undefined),
* layer: string, * layer: string,
* style: string, * style: string,
* tilePixelRatio: (number|undefined), * tilePixelRatio: (number|undefined),
@@ -6067,7 +6067,7 @@ olx.source.WMTSOptions.prototype.reprojectionErrorThreshold;
/** /**
* Request encoding. Default is `KVP`. * Request encoding. Default is `KVP`.
* @type {ol.source.WMTSRequestEncoding|string|undefined} * @type {ol.source.WMTS.RequestEncoding|string|undefined}
* @api stable * @api stable
*/ */
olx.source.WMTSOptions.prototype.requestEncoding; olx.source.WMTSOptions.prototype.requestEncoding;

View File

@@ -1,5 +1,4 @@
goog.provide('ol.source.WMTS'); goog.provide('ol.source.WMTS');
goog.provide('ol.source.WMTSRequestEncoding');
goog.require('ol'); goog.require('ol');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
@@ -12,16 +11,6 @@ goog.require('ol.tilegrid.WMTS');
goog.require('ol.uri'); 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 * @classdesc
* Layer source for tile data from WMTS servers. * Layer source for tile data from WMTS servers.
@@ -81,11 +70,11 @@ ol.source.WMTS = function(options) {
/** /**
* @private * @private
* @type {ol.source.WMTSRequestEncoding} * @type {ol.source.WMTS.RequestEncoding}
*/ */
this.requestEncoding_ = options.requestEncoding !== undefined ? this.requestEncoding_ = options.requestEncoding !== undefined ?
/** @type {ol.source.WMTSRequestEncoding} */ (options.requestEncoding) : /** @type {ol.source.WMTS.RequestEncoding} */ (options.requestEncoding) :
ol.source.WMTSRequestEncoding.KVP; ol.source.WMTS.RequestEncoding.KVP;
var requestEncoding = this.requestEncoding_; var requestEncoding = this.requestEncoding_;
@@ -101,7 +90,7 @@ ol.source.WMTS = function(options) {
'tilematrixset': this.matrixSet_ 'tilematrixset': this.matrixSet_
}; };
if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) { if (requestEncoding == ol.source.WMTS.RequestEncoding.KVP) {
ol.obj.assign(context, { ol.obj.assign(context, {
'Service': 'WMTS', 'Service': 'WMTS',
'Request': 'GetTile', '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 // order conforms to wmts spec guidance, and so that we can avoid to escape
// special template params // special template params
template = (requestEncoding == ol.source.WMTSRequestEncoding.KVP) ? template = (requestEncoding == ol.source.WMTS.RequestEncoding.KVP) ?
ol.uri.appendParams(template, context) : ol.uri.appendParams(template, context) :
template.replace(/\{(\w+?)\}/g, function(m, p) { template.replace(/\{(\w+?)\}/g, function(m, p) {
return (p.toLowerCase() in context) ? context[p.toLowerCase()] : m; return (p.toLowerCase() in context) ? context[p.toLowerCase()] : m;
@@ -146,7 +135,7 @@ ol.source.WMTS = function(options) {
}; };
ol.obj.assign(localContext, dimensions); ol.obj.assign(localContext, dimensions);
var url = template; var url = template;
if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) { if (requestEncoding == ol.source.WMTS.RequestEncoding.KVP) {
url = ol.uri.appendParams(url, localContext); url = ol.uri.appendParams(url, localContext);
} else { } else {
url = url.replace(/\{(\w+?)\}/g, function(m, p) { 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 the request encoding, either "KVP" or "REST".
* @return {ol.source.WMTSRequestEncoding} Request encoding. * @return {ol.source.WMTS.RequestEncoding} Request encoding.
* @api * @api
*/ */
ol.source.WMTS.prototype.getRequestEncoding = function() { 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 not provided, use the first encoding from the list
requestEncoding = encodings[0]; requestEncoding = encodings[0];
} }
if (requestEncoding === ol.source.WMTSRequestEncoding.KVP) { if (requestEncoding === ol.source.WMTS.RequestEncoding.KVP) {
if (ol.array.includes(encodings, ol.source.WMTSRequestEncoding.KVP)) { if (ol.array.includes(encodings, ol.source.WMTS.RequestEncoding.KVP)) {
urls.push(/** @type {string} */ (gets[i]['href'])); urls.push(/** @type {string} */ (gets[i]['href']));
} }
} else { } else {
@@ -452,7 +441,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
} }
} }
if (urls.length === 0) { if (urls.length === 0) {
requestEncoding = ol.source.WMTSRequestEncoding.REST; requestEncoding = ol.source.WMTS.RequestEncoding.REST;
l['ResourceURL'].forEach(function(element) { l['ResourceURL'].forEach(function(element) {
if (element['resourceType'] === 'tile') { if (element['resourceType'] === 'tile') {
format = element['format']; 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
};