-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add source
option to TileDebug
#16279
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
Conversation
📦 Preview the website for this branch here: https://deploy-preview-16279--ol-site.netlify.app/. |
5cfb105
to
b6a91ff
Compare
I'm not in favour of exposing the transform matrix to the public API for now. It's good to have it internally, but let's wait a few release cycles and see if there's really a need for it to be used externally. |
Yes, without the matrix the debug tiles would still appear, just not in the same place as the GeoTIFF. The code setting tile (texture) sizes to integer values is still needed as many GeoTIFFs (including the one in the example) return a tile grid with fractional sizes which don't work with reprojection. However any integer values should be valid, not just the rounded down sizes set here, so that could be moved to one fix for #16278 (which looks like two separate bugs). |
I think a better way would be for TileDebug to take a |
Yes, that would make for a nice API. And it could also work when the source is not yet ready, by waiting until the source is ready before the TileDebug source is configured. |
4342cd8
to
6c51fc2
Compare
source
option to TileDebug
c769ea0
to
3f746f6
Compare
6153f70
to
af5b777
Compare
Done, and ready for another review. |
src/ol/source/GeoTIFF.js
Outdated
getTransformMatrix() { | ||
return this.transformMatrix?.slice() || null; | ||
} |
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.
Since this is only used internally, it would be better to remove the @protected
flag from ol/source/DataTile#transformMatrix
, and get rid of this getter. On a related note, a getter returning a copy of something is not really a getter.
src/ol/source/TileDebug.js
Outdated
if (source instanceof GeoTIFF) { | ||
this.transformMatrix = source.getTransformMatrix(); | ||
} |
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 instanceof check should check for DataTile
instead of GeoTIFF
, and a copy of the member property instead of the getter should be used when assigning this.transformMatrix
.
<form> | ||
<div class="form-check"> | ||
<input class="form-check-input" type="checkbox" id="show-tiles" checked /> | ||
<label class="form-check-label" for="show-tiles">Show tile coordinates</label><br> |
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.
<label class="form-check-label" for="show-tiles">Show tile coordinates</label><br> | |
<label class="form-check-label" for="show-tiles">Show source tile coordinates</label><br> |
Set integer tile sizes (avoid increasing pixel ratio)
e1f1389
to
8c11d7e
Compare
examples/cog-modeltransformation.js
Outdated
const invert = (band, power) => ['-', 1, ['^', ['band', band], power]]; | ||
const showTilesCheckbox = document.getElementById('show-tiles'); | ||
const debugLayer = new TileLayer({ | ||
source: new TileDebug({source: cogSource}), | ||
style: { | ||
color: ['array', invert(1, 4), invert(2, 4), 0, ['band', 4]], | ||
}, | ||
visible: showTilesCheckbox.checked, | ||
}); |
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.
const invert = (band, power) => ['-', 1, ['^', ['band', band], power]]; | |
const showTilesCheckbox = document.getElementById('show-tiles'); | |
const debugLayer = new TileLayer({ | |
source: new TileDebug({source: cogSource}), | |
style: { | |
color: ['array', invert(1, 4), invert(2, 4), 0, ['band', 4]], | |
}, | |
visible: showTilesCheckbox.checked, | |
}); | |
const showTilesCheckbox = document.getElementById('show-tiles'); | |
const debugLayer = new TileLayer({ | |
source: new TileDebug({source: cogSource}), | |
visible: showTilesCheckbox.checked, | |
}); |
Nice way to change the colors, but let's try to keep the example's focus on what's in the title and description.
d1adce0
to
ba500b2
Compare
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.
Thanks, @mike-000
Adds a
source
option to TileDebug to allow easy use of settings from another tile source.Adds a non-API getter to GeoTIFF to obtain to the transform matrix for any ModelTransformation.
Updates the
COG with ModelTransformation
example to show tile coordinates.The PR currently uses one commit cherry picked from #16280 to enable correct reprojection of TileDebug.Browser tests added, and one ModelTransformation rendering test updated to include TileDebug.