Integrate image reprojection with ol.source.Image

This commit is contained in:
Petr Sloup
2015-06-11 16:26:19 +02:00
parent 15575288e0
commit be0a0de759
2 changed files with 50 additions and 9 deletions

View File

@@ -8,6 +8,8 @@ goog.require('ol.Attribution');
goog.require('ol.Extent');
goog.require('ol.ImageState');
goog.require('ol.array');
goog.require('ol.proj');
goog.require('ol.reproj.Image');
goog.require('ol.source.Source');
@@ -90,7 +92,39 @@ ol.source.Image.prototype.findNearestResolution =
* @param {ol.proj.Projection} projection Projection.
* @return {ol.ImageBase} Single image.
*/
ol.source.Image.prototype.getImage = goog.abstractMethod;
ol.source.Image.prototype.getImage =
function(extent, resolution, pixelRatio, projection) {
var sourceProjection = this.getProjection();
if (!ol.ENABLE_RASTER_REPROJECTION ||
!goog.isDefAndNotNull(sourceProjection) ||
!goog.isDefAndNotNull(projection) ||
ol.proj.equivalent(sourceProjection, projection)) {
if (!goog.isNull(sourceProjection)) {
projection = sourceProjection;
}
return this.getImageInternal(extent, resolution, pixelRatio, projection);
} else {
var image = new ol.reproj.Image(
sourceProjection, projection, extent, resolution, pixelRatio,
goog.bind(function(extent, resolution, pixelRatio) {
return this.getImageInternal(extent, resolution,
pixelRatio, sourceProjection);
}, this));
return image;
}
};
/**
* @param {ol.Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection.
* @return {ol.ImageBase} Single image.
* @protected
*/
ol.source.Image.prototype.getImageInternal = goog.abstractMethod;
/**