Closed mike-000 closed 8 months ago
Hi, @mike-000 . I appreciate your finding a solution that works for both uses cases. fwiw, looks good to me!
@DanielJDufour In OpenLayers I simply applied the matrix transform or its inverse before or after any proj4 or identity transforms https://deploy-preview-15402--ol-site.netlify.app/en/latest/examples/cog-modeltransformation.html I'm not sure if that would be possible with Leaflet?
@mike-000 , would you be able to share where in the OL code base you've been able to accomplish this? I'd love to learn more!
The newest version of GeoRasterLayer uses geowarp for the core resampling/reprojecting operations. It currently doesn't leverage the GPU or matrix multiplication, but I'm certainly open to it. I agree that there's a lot of potential there.
Our specific use case for getBoundingBox is Leaflet's GridLayer calling _isValidTile and needing to know if a web map tile intersects the rendered geotiff. A web map tile could be "valid" (need to render) depending on whether the matrix transform is applied.
@DanielJDufour OpenLayers uses the same algorithm as its canvas reprojection https://openlayers.org/doc/tutorials/raster-reprojection.html using the canvas RGB bands - where there are more than 3 bytes of data per pixel the process is repeated until all have been processed (source code is in https://github.com/openlayers/openlayers/blob/main/src/ol/reproj/DataTile.js). The first commit in #15402 allows a transform matrix to be set on a projection which, if present, is used to create a custom coordinate transform which may also include a proj4 transform for the projection codes.
@DanielJDufour Could you please take another look at this? Having this merged and published would help in adding support for skewed or rotated GeoTIFFs in OpenLayers (openlayers/openlayers#15402), where this code is currently more or less duplicated.
Hi, @constantinius . Just wanted to highlight this PR for your consideration. I think it's a great solution that works for both the OL and GeoRasterLayer use cases :-)
The change introduced by #361 is not useful for OpenLayers which now has to duplicate the original code. An option to return the original value as a tilegrid extent would be more maintainable than duplication of code.