Reprojection#681
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces coordinate reprojection capabilities using the proj4 library, adding a new Reprojection UI component, a ProjectionTexture utility, and updating global stores, plot components, and shaders to support remapping textures. The review feedback highlights several critical issues, including multiple GPU memory leaks from missing .dispose() calls on textures, potential runtime crashes from unhandled exceptions in proj4 operations, a TypeError when reversing undefined arrays, and a RangeError from unhandled NaN resolution inputs. Additionally, improvements are suggested to handle division-by-zero during array normalization, replace strict floating-point equality checks with tolerance thresholds, and clean up a duplicated CSS class name.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| for (let i = 2; i < len; i++) { | ||
| if (array[i] - array[i - 1] !== step) { | ||
| return false; | ||
| } | ||
| } |
There was a problem hiding this comment.
Strict equality check (!==) on floating-point differences can fail due to precision inaccuracies in JavaScript (e.g., 0.3 - 0.2 !== 0.1). Use an epsilon/tolerance threshold to check for uniform steps reliably.
| for (let i = 2; i < len; i++) { | |
| if (array[i] - array[i - 1] !== step) { | |
| return false; | |
| } | |
| } | |
| for (let i = 2; i < len; i++) { | |
| if (Math.abs((array[i] - array[i - 1]) - step) > 1e-9) { | |
| return false; | |
| } | |
| } |
There was a problem hiding this comment.
I may come back to this
This update brings reprojection to Browzarr using the https://github.com/proj4js/proj4js package.
Workflow
Reprojection is handled in the adjustments menu like all other tweaks. At the moment there is no parsing or searching for CRS on datasets so you have to set the CRS manually (The UI could use some love)
Proj4js is not as flexible as rioxarray so there aren't a lot of prenamed CRS you can use:
After entering a CRS (I like Mollweide)
+proj=moll +lon_0=0Resolution represents the vertical resolution of the new grid. It affects the jaggedness along valid and invalid coordinates. It also is the number of little cubes that will show up in the
FlatBlocksdisplacement. So in the animation that is not a surface, that is a high resolution number of blocks.After reprojecting, the shape of the plot and the Axis ticks will update to reflect the new CRS.
Limitations/Conflicts
I dunno how this will behave with Analysis and the Country lines haven't been updated to work with this.
Sphere and point-cloud are unaffected
At the moment I'm assuming all variables in a dataset have the same CRS and only wipe the CRS when changing datasets. Can remove annoyance with having to re-enter CRS each time you change variable.
The reset icon is always visible
Misc
I went with 12 textures for the main texture arrays since I need 3 extra textures and 13 is random. It makes sense 2x2x3
added mutable
axisDim#states to update the axis values. This will also be used when transformations is added.