-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix for reprojecting opaque tile sources #4628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for reprojecting opaque tile sources #4628
Conversation
@@ -365,7 +365,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = | |||
/** @type {Array.<number>} */ | |||
var zs = Object.keys(tilesToDrawByZ).map(Number); | |||
zs.sort(ol.array.numberSafeCompareFunction); | |||
var opaque = tileSource.getOpaque(); | |||
var opaque = tileSource.getOpaque(projection); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The source.getOpaque(projection)
method is now a bit hard to explain. And the opaque
value is deceptive. Why not move the projection equivalence check here? Maybe something like:
var opaqueAndNotReprojecting = ol.ENABLE_RASTER_REPROJECTION ?
ol.proj.equivalent(tileSource.getProjection(), projection) : tileSource.getOpaque();
And then use opaqueAndNotReprojecting
below. Cumbersome name, but at least it describes what it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far, most of the tile reprojection handling is in ol.source.TileImage
so I added it there to keep it in all one place.
The renderer has no special handling related to reprojection and the opaqueAndNotReprojecting
would make sense only for ol.source.TileImage
(not for other subclasses of ol.source.Tile
).
Alternatively, we could rename getOpaque
to getOpaqueForProjection
(or keep getOpaque
unchanged and add getOpaqueForProjection
) to make it more clear (and consistent with getTileGridForProjection
and getTileCacheForProjection
methods).
I have no strong opinion on this, so I'm not opposed to moving the projection equivalence check to the canvastilelayerrenderer.js
if others also think it would be better. Opinions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main concern that I have is that I can't make any sense of source.getOpaque(projection)
(or getOpaqueForProjection
). How would you explain what that method means? Opacity and projection are unrelated. So it suggests to me that "opacity" is being overloaded in a bad way (how many additional meanings should be packed into the same word?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-reading your original description, it sounds like you are talking about the reprojection resulting in non-opaque pixels being rendered.
Can you provide a screenshot to help illustrate the issue?
@tschaub Sorry the problem description was not clear. I'll try to explain it better this time. Some sources are marked as "opaque", which the When reprojecting for example MapQuest source to some projections, the new tiles (created by the reprojection) can be partially transparent although the original tiles are always opaque: |
Thanks for the clarified description and illustration of the problem @petrsloup. So ideally the canvas renderer could know I agree it is nice to contain the concerns about reprojecting. So I think this makes sense to merge as it is. Given your screenshot above, this looks like a great place for a rendering test. I'm not sure how sensitive the assertions would be to changes in the reprojection implementation, so I don't have a sense for how hard these would be to maintain (or create in the first place). |
42767de
to
7555b1b
Compare
@tschaub I tried to create the rendering test for this, but it proved to be quite complicated. The issue is only visible under certain conditions (after interaction -- at least zooming), so the test needs to have several "steps" and a lot of trial and error is required to get the test constants right. I'm afraid I don't have enough time to look at the test now, so (unless there are other comments or notes) I think we should merge this as it is to have the fix in v3.13.0. |
@petrsloup I agree this should be merged. Thanks for the fix and for the additional explanation. |
7555b1b
to
08b52f3
Compare
08b52f3
to
2c3ed38
Compare
Fix for reprojecting opaque tile sources
Thanks @tschaub |
The tile sources that are marked as 'opaque' (to benefit from rendering optimizations) are sometimes rendered incorrectly when reprojected -- the resulting reprojected tiles are not always opaque (e.g. projection boundaries, deformations, ...) and tiles from other zoom levels "bleed-through".
This PR changes
getOpaque
to returnfalse
when reprojecting.