-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Simplify tilegrid API and internals #3815
Conversation
1fedef7
to
6e36188
Compare
e8f32dc
to
240e683
Compare
Nice! |
|
||
The first `tileCoord` argument of `ol.TileUrlFunctionType` now expects transformed tile coordinates instead of internal OpenLayers tile coordinates. Accordingly, `ol.tilegrid.TileGrid#getTileCoordForCoordAndZ` and `ol.tilegrid.TileGrid#getTileCoordForCoordAndResolution` now return transformed tile coordinates. | ||
Previously, tile grids created by OpenLayers either had their origin at the top-left or at the bottom-left corner of the tile grid. To make it easier to for application developers to transform tile coordinates to the common XYZ tiling scheme, all tile grids that OpenLayers creates internally have their origin now at the top-left corner. |
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.
Don't you mean bottom-left
here?
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.
No, it's the top-left corner of the extent now. But the tile coordinates increase upwards.
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.
"of the extent" was what I was missing. I got it.
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.
/easier to for/easier for/
Tile coord calculation was wrong in the case of reverseIntersectionPolicy for y coords, and for extents with +/- Infinity.
240e683
to
f85fcf3
Compare
var adjustX = reverseIntersectionPolicy ? 0.5 : 0; | ||
var adjustY = reverseIntersectionPolicy ? 0 : 0.5; | ||
var xFromOrigin = Math.floor((x - origin[0]) / resolution + adjustX); | ||
var yFromOrigin = Math.floor((y - origin[1]) / resolution + adjustY); |
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.
Why did you change this?
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.
Two reasons:
- The change from
(whatever) | 0
toMath.floor(whatever)
was necessary because(Infinity) | 0
is0
, but we need the result ofMath.floor(Infinity)
, which isInfinity
. - The
y
adjustment for snapping to screen pixels was previously incorrect, because screen coordinates increase downwards, but map coordinates increase upwards. The tests caught this problem after changing the origin to the top-left corner of the extent.
I just added questions for me to understand. I think this no-surprises branch is just great. Please merge. |
Simplify tilegrid API and internals
|
||
The first `tileCoord` argument of `ol.TileUrlFunctionType` now expects transformed tile coordinates instead of internal OpenLayers tile coordinates. Accordingly, `ol.tilegrid.TileGrid#getTileCoordForCoordAndZ` and `ol.tilegrid.TileGrid#getTileCoordForCoordAndResolution` now return transformed tile coordinates. | ||
Previously, tile grids created by OpenLayers either had their origin at the top-left or at the bottom-left corner of the extent. To make it easier to for application developers to transform tile coordinates to the common XYZ tiling scheme, all tile grids that OpenLayers creates internally have their origin now at the top-left corner of the extent. |
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.
/easier to for/easier for/
From talking clients through all iterations of the tilegrid API when using custom tile url functions, and from experiences with the ol3-cesium integration of tile layers, it became clear that things are still not straightforward:
ol.TileCoord
has y values increasing from bottom to top.With these API simplifications, it is also possible to simplify tile grid handling internally. The Zoomify tile grid can finally be removed, because
ol.tilegrid.TileGrid
now provides everything that the Zoomify tile source needs.