Open staffordsmith83 opened 5 months ago
@staffordsmith83 I'm glad to see you continue to support TIFF in Terriajs. This issue is the same as #18 #22 , and I've been quite busy lately. I'll try to fix this issue next week, which seems to be related to resampling
Thats great, thanks @hongfaqiu, @nf-s watch this ticket
@staffordsmith83 I spent a day solving this problem, and now:
I will submit the improved code in the next two days.
That's great news thanks for your hard work on this, I'll let the Terria team know!
@staffordsmith83 I have released the corrected version v2.11.0. The reason for this issue is as follows:
The implementation approach is as follows:
The current issues are:
The optimization plan is:
@Staffordsmith83 @nf-s, a huge thanks to the wonderful new contributor @TheMrCam for offering the resampling method for bilinear.
Thank you so much for your hard work, and the functionality of this library has become even more splendid. How delightful it is!
But there are still some problems (unusual)
The test tiff is here https://github.com/hongfaqiu/TIFFImageryProvider/issues/33#issuecomment-2229888733
@staffordsmith83 I have released the corrected version v2.11.0. The reason for this issue is as follows:
- For tiles exceeding the maximum level of the COG (Cloud Optimized GeoTIFF), the accuracy is lost when calculating the sampling window using latitude and longitude.
- The default resampling method of GeoTIFF changes the width and height structure of the acquired TIFF grid.
- When rendering the data resampled with a small window using GeoTIFF, the grid boundaries of the original TIFF cannot be aligned.
The implementation approach is as follows:
- No longer set the maximum level to maximumLevel by default for COG.
- Use the tiles of the last level of the COG at higher levels.
- Calculate the window size of the current tile on the clipped tiles.
- Resample to the target resolution.
The current issues are:
- Although WebWorker is used to accelerate, the speed seems to be average.
- When fetching TIFF data at higher levels, there are cases of repeated calculations, especially poor performance when using reprojection.
The optimization plan is:
- Use WebGL for resampling, pass the original data as a texture, and resample to the target width and height.
GPU based resampling supported, please check the latest version @staffordsmith83
Thanks @hongfaqiu this is great work! Just to let you know, the latest terria release incorporates your TIFFImageryProvider, we had to fork the code to make some modifications to suit our custom fork of cesium, but it is essentially your code that powers our COG support. Ive now left the project, but want to thank you very much for your contribution! I will alert the existing team to this new version
@staffordsmith83 I have noticed that terriajs seems to have opened a rather different branch. The main branch fixed some obvious bugs some time ago. Therefore, I would like to remind you.
Dear Hongfaqiou,
there seems to be an issue with how TIFFImageryProvider maps the tiff values to the canvas. This occurs even when re-projection is not needed, e.g. for cogs in EPSG:4326 and EPSG:3857.
Using this Climate Data cog as an example (it is in EPSG:4326): https://nex-gddp-cmip6-cog.s3-us-west-2.amazonaws.com/daily/GFDL-CM4/ssp585/r1i1p1f1/pr/pr_day_GFDL-CM4_ssp585_r1i1p1f1_gr1_2015_01_25.tif
The data should look like this:
But TIFFImageryProvider renders it like this:
Note the following:
Note in a more zoomed in example, how the pixels are clearly not square. This is TIFFImageryProvider in TerriaJS:
This is TIFFImageryProvider in your online demo:
Whereas the tru data is square pixels (shown in QGIS):
Please note, to be able to see what is happening at the pixel level we have changed the Cesium settings for
_defaultMagnificationFilter
and_defaultMinificationFilter
to remove the blurring: https://github.com/TerriaJS/terriajs/blob/13fa4cfaabecdc82dff749836a1dcef602b0a1ae/lib/Models/Catalog/CatalogItems/CogCatalogItem.ts#L140-L141If you like, we have put more details on the perceived error in out PR here: https://github.com/TerriaJS/terriajs/pull/7209