Dedicated module for WMTS request encoding enum
This commit is contained in:
@@ -6194,7 +6194,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.WMTS.RequestEncoding|string|undefined),
|
* requestEncoding: (ol.source.WMTSRequestEncoding|string|undefined),
|
||||||
* layer: string,
|
* layer: string,
|
||||||
* style: string,
|
* style: string,
|
||||||
* tilePixelRatio: (number|undefined),
|
* tilePixelRatio: (number|undefined),
|
||||||
@@ -6276,7 +6276,7 @@ olx.source.WMTSOptions.prototype.reprojectionErrorThreshold;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Request encoding. Default is `KVP`.
|
* Request encoding. Default is `KVP`.
|
||||||
* @type {ol.source.WMTS.RequestEncoding|string|undefined}
|
* @type {ol.source.WMTSRequestEncoding|string|undefined}
|
||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
olx.source.WMTSOptions.prototype.requestEncoding;
|
olx.source.WMTSOptions.prototype.requestEncoding;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ goog.require('ol.extent');
|
|||||||
goog.require('ol.obj');
|
goog.require('ol.obj');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.TileImage');
|
goog.require('ol.source.TileImage');
|
||||||
|
goog.require('ol.source.WMTSRequestEncoding');
|
||||||
goog.require('ol.tilegrid.WMTS');
|
goog.require('ol.tilegrid.WMTS');
|
||||||
goog.require('ol.uri');
|
goog.require('ol.uri');
|
||||||
|
|
||||||
@@ -70,11 +71,11 @@ ol.source.WMTS = function(options) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.source.WMTS.RequestEncoding}
|
* @type {ol.source.WMTSRequestEncoding}
|
||||||
*/
|
*/
|
||||||
this.requestEncoding_ = options.requestEncoding !== undefined ?
|
this.requestEncoding_ = options.requestEncoding !== undefined ?
|
||||||
/** @type {ol.source.WMTS.RequestEncoding} */ (options.requestEncoding) :
|
/** @type {ol.source.WMTSRequestEncoding} */ (options.requestEncoding) :
|
||||||
ol.source.WMTS.RequestEncoding.KVP;
|
ol.source.WMTSRequestEncoding.KVP;
|
||||||
|
|
||||||
var requestEncoding = this.requestEncoding_;
|
var requestEncoding = this.requestEncoding_;
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ ol.source.WMTS = function(options) {
|
|||||||
'tilematrixset': this.matrixSet_
|
'tilematrixset': this.matrixSet_
|
||||||
};
|
};
|
||||||
|
|
||||||
if (requestEncoding == ol.source.WMTS.RequestEncoding.KVP) {
|
if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) {
|
||||||
ol.obj.assign(context, {
|
ol.obj.assign(context, {
|
||||||
'Service': 'WMTS',
|
'Service': 'WMTS',
|
||||||
'Request': 'GetTile',
|
'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
|
// order conforms to wmts spec guidance, and so that we can avoid to escape
|
||||||
// special template params
|
// special template params
|
||||||
|
|
||||||
template = (requestEncoding == ol.source.WMTS.RequestEncoding.KVP) ?
|
template = (requestEncoding == ol.source.WMTSRequestEncoding.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;
|
||||||
@@ -135,7 +136,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.WMTS.RequestEncoding.KVP) {
|
if (requestEncoding == ol.source.WMTSRequestEncoding.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) {
|
||||||
@@ -218,7 +219,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.WMTS.RequestEncoding} Request encoding.
|
* @return {ol.source.WMTSRequestEncoding} Request encoding.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.source.WMTS.prototype.getRequestEncoding = function() {
|
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 not provided, use the first encoding from the list
|
||||||
requestEncoding = encodings[0];
|
requestEncoding = encodings[0];
|
||||||
}
|
}
|
||||||
if (requestEncoding === ol.source.WMTS.RequestEncoding.KVP) {
|
if (requestEncoding === ol.source.WMTSRequestEncoding.KVP) {
|
||||||
if (ol.array.includes(encodings, ol.source.WMTS.RequestEncoding.KVP)) {
|
if (ol.array.includes(encodings, ol.source.WMTSRequestEncoding.KVP)) {
|
||||||
urls.push(/** @type {string} */ (gets[i]['href']));
|
urls.push(/** @type {string} */ (gets[i]['href']));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -448,7 +449,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (urls.length === 0) {
|
if (urls.length === 0) {
|
||||||
requestEncoding = ol.source.WMTS.RequestEncoding.REST;
|
requestEncoding = ol.source.WMTSRequestEncoding.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'];
|
||||||
@@ -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
|
|
||||||
};
|
|
||||||
|
|||||||
10
src/ol/source/wmtsrequestencoding.js
Normal file
10
src/ol/source/wmtsrequestencoding.js
Normal file
@@ -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
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user