Add ol.source.WMTS#getRequestEncoding

This commit is contained in:
Éric Lemoine
2015-04-22 15:11:30 +02:00
parent 2a2fea379e
commit 3a03e9f76a
2 changed files with 44 additions and 1 deletions

View File

@@ -96,10 +96,17 @@ ol.source.WMTS = function(options) {
// FIXME: should we guess this requestEncoding from options.url(s)
// structure? that would mean KVP only if a template is not provided.
var requestEncoding = goog.isDef(options.requestEncoding) ?
/**
* @private
* @type {ol.source.WMTSRequestEncoding}
*/
this.requestEncoding_ = goog.isDef(options.requestEncoding) ?
/** @type {ol.source.WMTSRequestEncoding} */ (options.requestEncoding) :
ol.source.WMTSRequestEncoding.KVP;
var requestEncoding = this.requestEncoding_;
// FIXME: should we create a default tileGrid?
// we could issue a getCapabilities xhr to retrieve missing configuration
var tileGrid = options.tileGrid;
@@ -268,6 +275,16 @@ ol.source.WMTS.prototype.getMatrixSet = function() {
};
/**
* Return the request encoding, either "KVP" or "REST".
* @return {ol.source.WMTSRequestEncoding} Request encoding.
* @api
*/
ol.source.WMTS.prototype.getRequestEncoding = function() {
return this.requestEncoding_;
};
/**
* Return the style of the WMTS source.
* @return {string} Style.

View File

@@ -209,6 +209,32 @@ describe('ol.source.WMTS', function() {
});
});
describe('#getRequestEncoding', function() {
var source;
beforeEach(function() {
source = new ol.source.WMTS({
layer: 'layer',
style: 'default',
matrixSet: 'foo',
requestEncoding: 'REST',
tileGrid: new ol.tilegrid.WMTS({
origin: [0, 0],
resolutions: [],
matrixIds: []
})
});
});
it('returns the request encoding', function() {
var requestEncoding = source.getRequestEncoding();
expect(requestEncoding).to.be.eql('REST');
});
});
});
goog.require('ol.format.WMTSCapabilities');