Skip to content

Auto-populate weather data from Open-Meteo API #5

Description

@bgorzelic

Description

When an observation has GPS coordinates, automatically fetch current weather conditions from the Open-Meteo API and pre-fill relevant fields. The WeatherResponse type already exists in @firevector/schema but is not yet integrated.

Open-Meteo Integration

Open-Meteo is free, no API key required. Relevant endpoints:

  • Current weather: https://api.open-meteo.com/v1/forecast?latitude=X&longitude=Y&current=temperature_2m,relative_humidity_2m,wind_speed_10m,wind_direction_10m,wind_gusts_10m

Proposed Implementation

  1. Server-side API route (/api/weather): accepts lat/lng, fetches from Open-Meteo, returns structured weather data
  2. Client-side trigger: When GPS coordinates are set (either manual or auto-locate), offer a "Fetch Weather" button
  3. Auto-fill fields: Relative humidity, eye-level wind speed (10m wind ≈ eye-level)
  4. Weather metadata: Store fetch timestamp, source, and coordinates used (the weather_meta field in schema)
  5. DB schema update: Add weather_meta JSONB column or individual columns to observations table

Acceptance Criteria

  • "Fetch Weather" button appears when lat/lng are populated
  • Open-Meteo data pre-fills RH and wind speed fields
  • User can override auto-filled values
  • Weather source and timestamp are stored with observation
  • Graceful fallback if Open-Meteo is unavailable
  • Loading state while fetching weather
  • Works for both new and edited observations

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2: mediumMedium priority — important but not blockingarea: schemaShared types (@firevector/schema)area: webNext.js web app (apps/web)size: LLarge — 3-5 daystype: featureNew feature or capability

    Projects

    Status
    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions