Skip to content
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

Reproject DataTiles #13654

Merged
merged 13 commits into from
Sep 7, 2022
Merged

Reproject DataTiles #13654

merged 13 commits into from
Sep 7, 2022

Conversation

mike-000
Copy link
Contributor

@mike-000 mike-000 commented May 8, 2022

Fixes #13197

Allows reprojection of multiband and raw values GeoTIFF and DataTile sources by reprojecting 3 bytes per pixel in sequence via raster reprojection until all bytes per pixel have been reprojected, then combining the result in a new DataTile. A ReprojDataTile class avoids the need for intermediate sources.

https://deploy-preview-13654--ol-site.netlify.app/en/latest/examples/geotiff-reprojection.html

To handle non-parallel projections data for areas outside the source tile grid but inside reprojected tiles with partial coverage of the source grid is returned as zeros, so sources should be configured to include alpha. Tiles in the reprojection tile grid which are entirely outside the source tile grid have an EMPTY state which is handled by the renderer.

Sources are expected to have the same band count and data type at each zoom level.

A second (and more realistic use case scenario) example is added - displaying two adjacent Sentinel COGs which are in different projections due to being in different UTM zones.

https://deploy-preview-13654--ol-site.netlify.app/en/latest/examples/multiple-cogs.html

Added a static method to determine browser accuracy:
https://deploy-preview-13654--ol-site.netlify.app/en/latest/apidoc/module-ol_source_datatile#.getReprojectCapability
Gecko browsers which might interpolate a reprojection canvas even if imageSmoothingEnabled is false currently account for around 3.2% of browser use https://gs.statcounter.com/browser-market-share#monthly-201708-202208

@mike-000 mike-000 marked this pull request as draft May 8, 2022 15:21
@github-actions
Copy link

github-actions bot commented May 8, 2022

📦 Preview the examples and docs from this branch here: https://deploy-preview-13654--ol-site.netlify.app/.

@mike-000 mike-000 force-pushed the geotiff-reproj branch 2 times, most recently from 7ca8c06 to 114d0b8 Compare May 8, 2022 22:41
@mike-000 mike-000 marked this pull request as ready for review May 8, 2022 22:46
@mike-000 mike-000 force-pushed the geotiff-reproj branch 2 times, most recently from d07e5cf to 121a34b Compare May 9, 2022 08:58
@mike-000 mike-000 force-pushed the geotiff-reproj branch 3 times, most recently from 8ca64e1 to 4d18106 Compare May 21, 2022 10:39
@mike-000 mike-000 marked this pull request as draft July 28, 2022 21:37
@mike-000 mike-000 marked this pull request as ready for review July 29, 2022 12:54
@mike-000 mike-000 marked this pull request as draft August 2, 2022 10:29
@mike-000 mike-000 marked this pull request as ready for review August 2, 2022 17:32
@mike-000 mike-000 force-pushed the geotiff-reproj branch 4 times, most recently from eb8b318 to ef153d2 Compare August 7, 2022 18:35
@mike-000 mike-000 force-pushed the geotiff-reproj branch 6 times, most recently from db1048a to c67ef84 Compare August 12, 2022 20:38
@mike-000 mike-000 changed the title Support GeoTIFF reprojection Reproject DataTiles Aug 19, 2022
@mike-000 mike-000 force-pushed the geotiff-reproj branch 2 times, most recently from 3393b95 to 3254aaf Compare August 19, 2022 14:30
@mike-000 mike-000 force-pushed the geotiff-reproj branch 4 times, most recently from aba597a to 50788c7 Compare August 31, 2022 14:09
@mike-000
Copy link
Contributor Author

mike-000 commented Sep 3, 2022

@tschaub @ahocevar This has now been fully reworked from the original experimental implementation to be a DataTile equivalent of a ReprojTile. Would anyone like to review it?

releaseCanvas(ctx2);
canvasPool.push(ctx2.canvas);
return data[0] === 0 || data[0] === 255;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a function that we necessarily need or want to maintain in the API (better at the application level). So I've pushed a commit that removes it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem with that. I now have a workaround which reduces an image (by removing rows or columns) so it does not need to be downscaled but that is perhaps best left as a follow-up PR?

const key = this.getKey();
if (tile && tile.key == key) {
return tile;
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but we can have less indentation on the happy path if we avoid these return-else. I've pushed a commit that reworks these and will add a linter rule separately.

* @protected
* @type {!Object<string, import("../tilegrid/TileGrid.js").default>}
*/
this.tileGridForProjection = {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can be private. I've pushed a commit that changes this.

Copy link
Member

@tschaub tschaub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your efforts on this, @mike-000. I know this will be appreciated new functionality in the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reprojection for WebGlTile layer
2 participants