Allow different source and view projection in image layer renderers

To enable image layer reprojection.
This commit is contained in:
Petr Sloup
2015-06-11 16:28:19 +02:00
parent be0a0de759
commit ed1e49045a
4 changed files with 24 additions and 17 deletions
@@ -170,12 +170,14 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] && if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) { !ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection; var projection = viewState.projection;
if (!ol.ENABLE_RASTER_REPROJECTION) {
var sourceProjection = imageSource.getProjection(); var sourceProjection = imageSource.getProjection();
if (sourceProjection) { if (sourceProjection) {
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection), goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection),
'projection and sourceProjection are equivalent'); 'projection and sourceProjection are equivalent');
projection = sourceProjection; projection = sourceProjection;
} }
}
image = imageSource.getImage( image = imageSource.getImage(
renderedExtent, viewResolution, pixelRatio, projection); renderedExtent, viewResolution, pixelRatio, projection);
if (image) { if (image) {
@@ -101,12 +101,14 @@ ol.renderer.dom.ImageLayer.prototype.prepareFrame =
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] && if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) { !ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection; var projection = viewState.projection;
if (!ol.ENABLE_RASTER_REPROJECTION) {
var sourceProjection = imageSource.getProjection(); var sourceProjection = imageSource.getProjection();
if (sourceProjection) { if (sourceProjection) {
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection), goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection),
'projection and sourceProjection are equivalent'); 'projection and sourceProjection are equivalent');
projection = sourceProjection; projection = sourceProjection;
} }
}
var image_ = imageSource.getImage(renderedExtent, viewResolution, var image_ = imageSource.getImage(renderedExtent, viewResolution,
frameState.pixelRatio, projection); frameState.pixelRatio, projection);
if (image_) { if (image_) {
+3 -2
View File
@@ -159,8 +159,9 @@ ol.renderer.Layer.prototype.loadImage = function(image) {
if (imageState == ol.ImageState.IDLE) { if (imageState == ol.ImageState.IDLE) {
image.load(); image.load();
imageState = image.getState(); imageState = image.getState();
goog.asserts.assert(imageState == ol.ImageState.LOADING, goog.asserts.assert(imageState == ol.ImageState.LOADING ||
'imageState is "loading"'); imageState == ol.ImageState.LOADED,
'imageState is "loading" or "loaded"');
} }
return imageState == ol.ImageState.LOADED; return imageState == ol.ImageState.LOADED;
}; };
@@ -125,12 +125,14 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame =
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] && if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) { !ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection; var projection = viewState.projection;
if (!ol.ENABLE_RASTER_REPROJECTION) {
var sourceProjection = imageSource.getProjection(); var sourceProjection = imageSource.getProjection();
if (sourceProjection) { if (sourceProjection) {
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection), goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection),
'projection and sourceProjection are equivalent'); 'projection and sourceProjection are equivalent');
projection = sourceProjection; projection = sourceProjection;
} }
}
var image_ = imageSource.getImage(renderedExtent, viewResolution, var image_ = imageSource.getImage(renderedExtent, viewResolution,
pixelRatio, projection); pixelRatio, projection);
if (image_) { if (image_) {