Merge pull request #3964 from rattai/imagewms_extent

Compute new image extent for comparison to existing image extent
This commit is contained in:
Andreas Hocevar
2015-08-05 22:52:10 +02:00
2 changed files with 19 additions and 1 deletions

View File

@@ -92,6 +92,12 @@ ol.source.ImageWMS = function(opt_options) {
*/
this.image_ = null;
/**
* @private
* @type {ol.Extent}
*/
this.imageExtent_ = null;
/**
* @private
* @type {ol.Size}
@@ -203,7 +209,7 @@ ol.source.ImageWMS.prototype.getImage =
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio &&
ol.extent.containsExtent(image.getExtent(), extent)) {
ol.extent.containsExtent(image.getExtent(), this.imageExtent_)) {
return image;
}
@@ -240,6 +246,8 @@ ol.source.ImageWMS.prototype.getImage =
extent[1] = centerY - imageResolution * height / 2;
extent[3] = centerY + imageResolution * height / 2;
this.imageExtent_ = extent;
this.imageSize_[0] = width;
this.imageSize_[1] = height;
@@ -362,6 +370,7 @@ ol.source.ImageWMS.prototype.setUrl = function(url) {
if (url != this.url_) {
this.url_ = url;
this.image_ = null;
this.imageExtent_ = null;
this.changed();
}
};
@@ -376,6 +385,7 @@ ol.source.ImageWMS.prototype.updateParams = function(params) {
goog.object.extend(this.params_, params);
this.updateV13_();
this.image_ = null;
this.imageExtent_ = null;
this.changed();
};

View File

@@ -155,6 +155,14 @@ describe('ol.source.ImageWMS', function() {
expect(imageLoadFunction.calledWith(image, image.src_)).to.be(true);
});
it('returns same image for consecutive calls with same args', function() {
var extent = [10.01, 20, 30.01, 40];
var source = new ol.source.ImageWMS(options);
var image1 = source.getImage(extent, resolution, pixelRatio, projection);
var image2 = source.getImage(extent, resolution, pixelRatio, projection);
expect(image1).to.equal(image2);
});
});
describe('#getGetFeatureInfo', function() {