Get rid of unnecessary coord key prefix
This commit is contained in:
@@ -81,13 +81,6 @@ ol.source.TileWMS = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true;
|
this.hidpi_ = options.hidpi !== undefined ? options.hidpi : true;
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.coordKeyPrefix_ = '';
|
|
||||||
this.resetCoordKeyPrefix_();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.Extent}
|
* @type {ol.Extent}
|
||||||
@@ -171,14 +164,6 @@ ol.source.TileWMS.prototype.getGutterInternal = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.source.TileWMS.prototype.getKeyZXY = function(z, x, y) {
|
|
||||||
return this.coordKeyPrefix_ + ol.source.TileImage.prototype.getKeyZXY.call(this, z, x, y);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the user-provided params, i.e. those passed to the constructor through
|
* Get the user-provided params, i.e. those passed to the constructor through
|
||||||
* the "params" option, and possibly updated using the updateParams method.
|
* the "params" option, and possibly updated using the updateParams method.
|
||||||
@@ -273,24 +258,6 @@ ol.source.TileWMS.prototype.getTilePixelRatio = function(pixelRatio) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
ol.source.TileWMS.prototype.resetCoordKeyPrefix_ = function() {
|
|
||||||
var i = 0;
|
|
||||||
var res = [];
|
|
||||||
|
|
||||||
if (this.urls) {
|
|
||||||
var j, jj;
|
|
||||||
for (j = 0, jj = this.urls.length; j < jj; ++j) {
|
|
||||||
res[i++] = this.urls[j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.coordKeyPrefix_ = res.join('#');
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @return {string} The key for the current params.
|
* @return {string} The key for the current params.
|
||||||
@@ -352,15 +319,6 @@ ol.source.TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRati
|
|||||||
pixelRatio, projection, baseParams);
|
pixelRatio, projection, baseParams);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.source.TileWMS.prototype.setUrls = function(urls) {
|
|
||||||
ol.source.TileImage.prototype.setUrls.call(this, urls);
|
|
||||||
this.resetCoordKeyPrefix_();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the user-provided params.
|
* Update the user-provided params.
|
||||||
* @param {Object} params Params.
|
* @param {Object} params Params.
|
||||||
@@ -368,7 +326,6 @@ ol.source.TileWMS.prototype.setUrls = function(urls) {
|
|||||||
*/
|
*/
|
||||||
ol.source.TileWMS.prototype.updateParams = function(params) {
|
ol.source.TileWMS.prototype.updateParams = function(params) {
|
||||||
ol.obj.assign(this.params_, params);
|
ol.obj.assign(this.params_, params);
|
||||||
this.resetCoordKeyPrefix_();
|
|
||||||
this.updateV13_();
|
this.updateV13_();
|
||||||
this.setKey(this.getKeyForParams_());
|
this.setKey(this.getKeyForParams_());
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -275,15 +275,13 @@ describe('ol.source.TileWMS', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('#setUrls()', function() {
|
describe('#setUrls()', function() {
|
||||||
it ('resets coordKeyPrefix_', function() {
|
it ('updates the source key', function() {
|
||||||
var urls = ['u1', 'u2'];
|
var source = new ol.source.TileWMS({
|
||||||
var source1 = new ol.source.TileWMS({
|
urls: ['u1', 'u2']
|
||||||
urls: urls
|
|
||||||
});
|
});
|
||||||
var source2 = new ol.source.TileWMS({});
|
var originalKey = source.getKey();
|
||||||
expect(source2.coordKeyPrefix_).to.be.empty();
|
source.setUrls(['u3', 'u4']);
|
||||||
source2.setUrls(urls);
|
expect(source.getKey() !== originalKey).to.be(true);
|
||||||
expect(source2.coordKeyPrefix_).to.equal(source1.coordKeyPrefix_);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user