Skip to content

Add 1° download grid layer and download modal#256

Merged
m-mohr merged 10 commits into
fieldsoftheworld:mainfrom
haithcoatj:feature/download-grid
Apr 22, 2026
Merged

Add 1° download grid layer and download modal#256
m-mohr merged 10 commits into
fieldsoftheworld:mainfrom
haithcoatj:feature/download-grid

Conversation

@haithcoatj
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a toggleable 1° WGS84 download grid overlay (Global mode only) sourced from the new download-tiles/ftw-download-grid.geojson manifest on Source Cooperative.
  • Clicking a grid cell opens a Download Field Data modal showing tile ID, bounding box, feature count, and file size, with a direct link to the per-tile GeoParquet for the year selected in the left panel.
  • New composable useDownloadGrid manages layer visibility, hover/selected state, and modal state as singleton state; idempotent per-map init via WeakSet avoids duplicate pointermove listeners across mode switches.

Details

  • src/layers/Download-Grid-Layer.ts — vector layer + URL helpers pointing at data.source.coop/ftw/global-field-boundaries/download-tiles/....
  • src/composables/useDownloadGrid.ts — visibility/hover/click/modal state; auto-disables when leaving global mode.
  • src/components/DownloadModal.vue — Vuetify dialog; uses settings.year (no year picker), disables download + shows warning when the tile has no data for the selected year.
  • src/components/GlobalDataPanel.vue — adds the "Download Data" switch.
  • src/components/MapComponent.vue / src/composables/useMap.ts — wire click handling to the grid layer and render the modal.
  • Tests: src/composables/__tests__/useDownloadGrid.test.ts covers URL builders, featureToGridCell edge cases, singleton state, mode-change auto-disable, and click-gating.

Test plan

  • npm run type-check
  • npm run lint
  • npm run test:unit (12 passing)
  • npm run build
  • Manual: toggle grid on/off in Global mode, hover highlights, click opens modal, download link resolves, year switch updates modal, disabled state for tiles without data for selected year, grid auto-hides when leaving Global mode.

Adds a toggleable 1-degree grid overlay in Global Predictions mode that
lets users click any cell to download its field boundaries as a
GeoParquet file from Source Cooperative.

- `Download-Grid-Layer.ts`: vector layer loading the grid manifest
  (`ftw-download-grid.geojson`) from Source Cooperative, with
  normal/hover/selected styles.
- `useDownloadGrid.ts`: composable managing layer visibility, hover,
  click handling, and download modal state; idempotent per-map
  initialization avoids duplicate listeners across mode switches.
- `DownloadModal.vue`: Vuetify dialog showing tile id, bounding box,
  feature count / size, and a direct download link for the currently
  selected year.
- `useMap.ts`: initializes the grid layer when entering global mode and
  delegates grid-cell clicks from `handleMapClick`.
- `GlobalDataPanel.vue`: adds a "Show 1° download grid" toggle to the
  side panel.
- `MapComponent.vue`: mounts the modal and registers `handleMapClick`.
- Unit tests covering URL construction, feature-to-cell mapping, and
  composable state transitions.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@m-mohr m-mohr self-requested a review April 21, 2026 09:37
@m-mohr
Copy link
Copy Markdown
Collaborator

m-mohr commented Apr 21, 2026

Let's merge after #255 and then see whether we have to align the styling etc.
We also then still have to resolve merge conflicts.

@haithcoatj
Copy link
Copy Markdown
Collaborator Author

Let's merge after #255 and then see whether we have to align the styling etc. We also then still have to resolve merge conflicts.

Sounds good. Let me know when #255 lands and I'll rebase #256, resolve the conflicts, and do a styling pass.

@m-mohr
Copy link
Copy Markdown
Collaborator

m-mohr commented Apr 21, 2026

ToDos:

  • Whether the download grid is shown or not is not saved in the settings, but in a local ref in the composable.
  • Whether the download grid is shown or not is not persisted into the URL.
  • When you are zoomed to higher zoom levels, you may actually not see the boxes, the screen only gets a little bluish. Should we zoom out when we enable download so that tiles get shown?
  • Hide the explanatory text until downloads are enabled?
  • ...

Sometimes random cells are missing?

{735C52D0-D662-4BF5-BB51-3E2D72DE5917}

@m-mohr m-mohr force-pushed the feature/download-grid branch from 42b1963 to ecbfac5 Compare April 21, 2026 20:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new “download grid” capability in Global mode, intended to let users identify 1° tiles and download per-tile GeoParquet outputs hosted on Source Cooperative.

Changes:

  • Introduces an OpenLayers vector overlay for the 1° download grid plus URL helpers for per-tile GeoParquet downloads.
  • Adds settings/permalink support for new downloads toggle and renames fieldBoundariesOpacityopacity.
  • Adds initial UI pieces (Global panel toggle + new DownloadModal.vue) and unit tests for permalink/download-grid helpers.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/layers/Download-Grid-Layer.ts New OL vector layer sourcing the grid GeoJSON + style and URL helpers.
src/composables/useDownloadGrid.ts Singleton composable for grid layer init, hover/select state, and click handling.
src/components/DownloadModal.vue New modal UI intended to show tile metadata and provide a download link.
src/components/GlobalDataPanel.vue Adds “Download Data” help + toggle; updates opacity binding.
src/components/MapComponent.vue Wires map singleclick handler; initializes download-grid composable.
src/composables/useMap.ts Routes clicks to either results selection or download-grid click handler; initializes grid layer in global mode.
src/components/ProcessingResults.vue Removes per-component map click listener hookup (centralized in MapComponent).
src/composables/useSettings.ts Renames opacity setting and adds downloads flag with defaults.
src/composables/usePermalink.ts Adds downloads + opacity to global permalink; refactors parsing/building helpers.
src/composables/tests/useDownloadGrid.test.ts Unit tests for URL helpers, feature extraction, visibility/mode behavior, and click gating.
src/composables/tests/usePermalink.test.ts Unit tests for global permalink parts + parsing downloads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/composables/usePermalink.ts Outdated
Comment thread src/composables/useDownloadGrid.ts
Comment thread src/composables/useDownloadGrid.ts Outdated
Comment thread src/components/MapComponent.vue
Comment thread src/composables/useMap.ts Outdated
Comment thread src/components/DownloadModal.vue Outdated
Comment thread src/components/DownloadModal.vue Outdated
Comment thread src/composables/useSettings.ts
Copy link
Copy Markdown
Collaborator

@m-mohr m-mohr left a comment

Choose a reason for hiding this comment

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

Made various updates, lgtm.

As I'm the last committer, someone else should do another review and approval.

@m-mohr m-mohr added this to the 1.1 - Global Data milestone Apr 21, 2026
@m-mohr m-mohr merged commit e6c0f10 into fieldsoftheworld:main Apr 22, 2026
1 check passed
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.

5 participants