Derive grid extent and resolution from the store on fetch (#30)#67
Merged
Conversation
Spatial extent, resolution, dimension sizes, and native chunk footprint are no longer hardcoded. They are read from the remote Zarr store's metadata at runtime, with the previous constants kept as a fallback for first paint and error states. - Add GridSpec type and deriveGridSpec() that reads shape, chunks and lon/lat coordinate arrays from the store - Memoize derivation on ZarrChunkReader via getGridSpec() - Thread GridSpec through geogrid helpers and map components, defaulting to DEFAULT_GRID_SPEC - Add unit tests covering derivation and the fallback path
|
🚀 Vercel preview deployed Preview URL: https://earth-prints-a9b5nj1ii-anastasiia-s-projects10.vercel.app |
lazarusA
approved these changes
Jul 25, 2026
lazarusA
left a comment
Member
There was a problem hiding this comment.
Since for now we only have one dataset to test, let's go with this, others will have other conventions, but we cannot do all at once.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #30.
What
Spatial extent, resolution, dimension sizes, and native chunk footprint are no longer hardcoded in
src/lib/constants/store.ts. They are now derived from the remote Zarr store's metadata at runtime, so the app adapts to whatever store it opens. The previous constants stay as a fallback (DEFAULT_GRID_SPEC) for first paint and error states, so behavior is unchanged when derivation has not resolved yet or fails.How
src/lib/zarr/gridSpec.ts(new):deriveGridSpec(store, variable)reads the data variable'sshape,chunks, and_ARRAY_DIMENSIONS, then opens thelon/latcoordinate arrays to compute start and step (resolution). ReturnsDEFAULT_GRID_SPECon any failure.src/types/map.ts: newGridSpectype (grid, dimensions, nativeChunks, spatialResolutionDeg).src/lib/constants/store.ts:DEFAULT_GRID_SPECexported from the existing constants as the fallback.src/lib/zarr/ZarrChunkReader.ts: memoizedgetGridSpec()delegating toderiveGridSpec.src/lib/map/geogrid.ts: geometry helpers take aGridSpecparam defaulting to the fallback, instead of reading the global constant.src/components/map/EarthMap.tsx: holdsgridSpecin state, fetches it once on mount via the shared reader, and threads it intohandlePick,MapReadout, andGlobeSelectionOverlay.src/components/map/{GlobeSelectionOverlay,MapReadout}.tsx: accept and use thegridSpecprop.Verification
npx next build: compiled, TypeScript passed.npx vitest run: 47 tests pass across 10 files (2 new ingridSpec.test.tscovering derivation and fallback).DEFAULT_GRID_SPEC, so first paint and offline states behave exactly as before.