diff --git a/src/ol/ol.js b/src/ol/ol.js index cffdecbc29..c0c458349a 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -94,6 +94,13 @@ ol.ENABLE_NAMED_COLORS = false; ol.ENABLE_PROJ4JS = true; +/** + * @define {boolean} Enable automatic reprojection of raster sources. Default is + * `true`. + */ +ol.ENABLE_RASTER_REPROJECTION = true; + + /** * @define {boolean} Enable rendering of ol.layer.Tile based layers. Default is * `true`. Setting this to false at compile time in advanced mode removes diff --git a/src/ol/source/tileimagesource.js b/src/ol/source/tileimagesource.js index 9e2c850cf3..3239cf8c36 100644 --- a/src/ol/source/tileimagesource.js +++ b/src/ol/source/tileimagesource.js @@ -101,6 +101,9 @@ ol.source.TileImage.defaultTileLoadFunction = function(imageTile, src) { * @inheritDoc */ ol.source.TileImage.prototype.canExpireCache = function() { + if (!ol.ENABLE_RASTER_REPROJECTION) { + return goog.base(this, 'canExpireCache'); + } var canExpire = this.tileCache.canExpireCache(); if (canExpire) { return true; @@ -116,11 +119,15 @@ ol.source.TileImage.prototype.canExpireCache = function() { * @inheritDoc */ ol.source.TileImage.prototype.expireCache = function(projection, usedTiles) { + if (!ol.ENABLE_RASTER_REPROJECTION) { + goog.base(this, 'expireCache', projection, usedTiles); + return; + } var usedTileCache = this.getTileCacheForProjection(projection); this.tileCache.expireCache(this.tileCache == usedTileCache ? usedTiles : {}); goog.object.forEach(this.tileCacheForProjection, function(tileCache) { - return tileCache.expireCache(tileCache == usedTileCache ? usedTiles : {}); + tileCache.expireCache(tileCache == usedTileCache ? usedTiles : {}); }); }; @@ -129,6 +136,9 @@ ol.source.TileImage.prototype.expireCache = function(projection, usedTiles) { * @inheritDoc */ ol.source.TileImage.prototype.getTileGridForProjection = function(projection) { + if (!ol.ENABLE_RASTER_REPROJECTION) { + return goog.base(this, 'getTileGridForProjection', projection); + } var thisProj = this.getProjection(); if (!goog.isNull(this.tileGrid) && (goog.isNull(thisProj) || ol.proj.equivalent(thisProj, projection))) { @@ -148,6 +158,9 @@ ol.source.TileImage.prototype.getTileGridForProjection = function(projection) { * @inheritDoc */ ol.source.TileImage.prototype.getTileCacheForProjection = function(projection) { + if (!ol.ENABLE_RASTER_REPROJECTION) { + return goog.base(this, 'getTileCacheForProjection', projection); + } var thisProj = this.getProjection(); if (goog.isNull(thisProj) || ol.proj.equivalent(thisProj, projection)) { return this.tileCache; @@ -166,7 +179,8 @@ ol.source.TileImage.prototype.getTileCacheForProjection = function(projection) { */ ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection) { - if (!goog.isDefAndNotNull(this.getProjection()) || + if (!ol.ENABLE_RASTER_REPROJECTION || + !goog.isDefAndNotNull(this.getProjection()) || !goog.isDefAndNotNull(projection) || ol.proj.equivalent(this.getProjection(), projection)) { return this.getTileInternal(z, x, y, pixelRatio, projection);