Dedicated module for WMTS request encoding enum
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user