Support different resolutions in x and y direction for ol.source.ImageStatic

This commit is contained in:
Bart van den Eijnden
2015-10-30 15:01:01 +01:00
parent 7f4c6e3634
commit 979342091a
13 changed files with 75 additions and 31 deletions

View File

@@ -150,7 +150,7 @@ ol.source.ImageMapGuide.prototype.getImageInternal =
var imageUrl = this.imageUrlFunction_(extent, size, projection);
if (imageUrl !== undefined) {
image = new ol.Image(extent, resolution, pixelRatio,
image = new ol.Image(extent, [resolution, resolution], pixelRatio,
this.getAttributions(), imageUrl, this.crossOrigin_,
this.imageLoadFunction_);
goog.events.listen(image, goog.events.EventType.CHANGE,

View File

@@ -26,10 +26,12 @@ ol.source.ImageStatic = function(options) {
var imageExtent = options.imageExtent;
var resolution, resolutions;
var xResolution, yResolution, resolutions, imgResolution;
if (options.imageSize !== undefined) {
resolution = ol.extent.getHeight(imageExtent) / options.imageSize[1];
resolutions = [resolution];
xResolution = ol.extent.getWidth(imageExtent) / options.imageSize[0];
yResolution = ol.extent.getHeight(imageExtent) / options.imageSize[1];
imgResolution = [xResolution, yResolution];
resolutions = [yResolution];
}
var crossOrigin = options.crossOrigin !== undefined ?
@@ -50,8 +52,8 @@ ol.source.ImageStatic = function(options) {
* @private
* @type {ol.Image}
*/
this.image_ = new ol.Image(imageExtent, resolution, 1, attributions,
options.url, crossOrigin, imageLoadFunction);
this.image_ = new ol.Image(imageExtent, imgResolution, 1,
attributions, options.url, crossOrigin, imageLoadFunction);
goog.events.listen(this.image_, goog.events.EventType.CHANGE,
this.handleImageChange, false, this);

View File

@@ -217,7 +217,7 @@ ol.source.ImageWMS.prototype.getImageInternal =
var image = this.image_;
if (image &&
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getResolution()[0] == resolution &&
image.getPixelRatio() == pixelRatio &&
ol.extent.containsExtent(image.getExtent(), extent)) {
return image;
@@ -247,7 +247,7 @@ ol.source.ImageWMS.prototype.getImageInternal =
var url = this.getRequestUrl_(extent, this.imageSize_, pixelRatio,
projection, params);
this.image_ = new ol.Image(extent, resolution, pixelRatio,
this.image_ = new ol.Image(extent, [resolution, resolution], pixelRatio,
this.getAttributions(), url, this.crossOrigin_, this.imageLoadFunction_);
this.renderedRevision_ = this.getRevision();