Check view extent within image extent

This commit is contained in:
Andreas Hocevar
2015-10-28 23:58:00 +01:00
parent 6d9dd030a1
commit 40c1a6d112
2 changed files with 19 additions and 8 deletions

View File

@@ -201,14 +201,6 @@ ol.source.ImageWMS.prototype.getImageInternal =
extent = extent.slice();
var centerX = (extent[0] + extent[2]) / 2;
var centerY = (extent[1] + extent[3]) / 2;
if (this.ratio_ != 1) {
var halfWidth = this.ratio_ * ol.extent.getWidth(extent) / 2;
var halfHeight = this.ratio_ * ol.extent.getHeight(extent) / 2;
extent[0] = centerX - halfWidth;
extent[1] = centerY - halfHeight;
extent[2] = centerX + halfWidth;
extent[3] = centerY + halfHeight;
}
var imageResolution = resolution / pixelRatio;
@@ -231,6 +223,15 @@ ol.source.ImageWMS.prototype.getImageInternal =
return image;
}
if (this.ratio_ != 1) {
var halfWidth = this.ratio_ * ol.extent.getWidth(extent) / 2;
var halfHeight = this.ratio_ * ol.extent.getHeight(extent) / 2;
extent[0] = centerX - halfWidth;
extent[1] = centerY - halfHeight;
extent[2] = centerX + halfWidth;
extent[3] = centerY + halfHeight;
}
var params = {
'SERVICE': 'WMS',
'VERSION': ol.DEFAULT_WMS_VERSION,