Skip to content

About

Play a road trip forward in time against the forecast. HRRR weather, road conditions, and cameras for California and Oregon.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Roadtripper

Plays a road trip forward in time on a map, so you can see the weather you will actually drive through. Built for one question: if we leave San Diego for Portland in the RV at 10 PM, or at 4 AM, what wind do we hit at the Siskiyous?

Live at trip.joemattie.com.

It covers California and Oregon. The forecasts work anywhere in the US, but road conditions and cameras only know those two states. If you want it for somewhere else, fork it. See Making it yours.

What it does

  • Plan a trip. Start, destination, stops with dwell times, departure time, and a pace slider for vehicles slower than a car. Address search, or use your current location.
  • Play it. Play, pause, scrub, and change speed. The vehicle moves along the route and the weather layer moves with the clock.
  • Forecast map layer. Precipitation, animated wind, and gust bands from NOAA's HRRR model (3 km, hourly), continuing with GFS past 48 hours. It loads for whatever the map is showing: zoom in for more detail, zoom out for more area.
  • Composite view. One still picture of the whole trip, where each place shows the forecast for the hour you pass it.
  • Route timeline. Wind, gusts, crosswind, precipitation, and temperature at each point for your arrival time, with hazard bands tuned for a high-profile vehicle.
  • Find best departure. Pick what to avoid (wind, rain, ice and snow, fog, steep grades at night, traffic) and a window. It scores a departure every 30 minutes and ranks them.
  • Departure slider. Drag across 24 hours and watch the exposure change.
  • Road conditions. Caltrans and ODOT lane closures, chain controls, message signs, incidents, and weather stations, matched to the route. Scheduled work is checked against the time you pass.
  • Traffic cameras. Icons along the route open the live Caltrans or ODOT image.
  • Live radar. NOAA MRMS, shown when the clock is within an hour of now.
  • Weather alerts. Active NWS alerts along the route, checked against your arrival time.
  • Directions. Highway changes only, in a card you can hide.
  • Live GPS. On the road, the marker follows your real position and the schedule shifts to match your actual progress.
  • Works on a phone or tablet. Map on top, everything else in a bottom sheet.

Preferences and the current trip are saved in the browser.

Run it

npm install
npm run dev        # http://localhost:5173

It runs with no keys: free-flow routing from the OSRM demo server, the NWS forecast, and a GFS map layer fetched straight from NOAA.

Keys add the rest. Copy .env.example to .env.local and fill in what you have:

Variable Adds Where to get it
TOMTOM_API_KEY Traffic-aware routing, directions, address search, traffic in the departure search developer.tomtom.com, free tier
ODOT_API_KEY Oregon road conditions and cameras apiportal.odot.state.or.us, subscribe to "TripCheck Data", free
HRRR_ORIGIN, HRRR_TOKEN The HRRR map layer Your own deploy of modal/hrrr_service.py. See modal/README.md.

The keys stay on the server. The Vite dev server proxies /api/* and adds them; in production the Cloudflare Worker does the same. Nothing with a key in it reaches the browser, so never give one a VITE_ prefix.

npm test              # vitest
npm run typecheck
npm run build

Deploy

The app is a single Cloudflare Worker that serves the built files and proxies the upstream APIs.

npx wrangler login
npx wrangler secret put TOMTOM_API_KEY     # run these in a real terminal; they prompt for the value
npx wrangler secret put ODOT_API_KEY
npx wrangler secret put HRRR_TOKEN
npm run deploy

Edit wrangler.jsonc first: set routes to a hostname on your own Cloudflare zone, and HRRR_ORIGIN to your Modal service (or empty to go without it).

wrangler secret put stores an empty value if it can't prompt. If you are scripting it, use npx wrangler secret bulk <file> with NAME=value lines.

The HRRR service is a small Python app on Modal that pulls each HRRR run from NOAA's open data bucket and serves route-sized grids. Deploying it is one command; modal/README.md has the details. It cost about two cents on its first night.

Once deployed, nothing runs on your own machine. The Worker and the Modal service keep going on their own.

How it works

src/types.ts              shared contracts
src/lib/routing/          TomTom and OSRM adapters, directions, traffic by departure time
src/lib/timeline.ts       route + plan -> a path with a time at every point
src/lib/weather/          NWS and Open-Meteo forecasts, HRRR and GFS grids, GRIB2 decoder, hazards, alerts
src/lib/roads/            Caltrans and ODOT conditions and cameras, matched to the route
src/lib/optimize.ts       departure search; elevation.ts and sun.ts feed it
src/map/                  MapLibre map, forecast canvas, wind particles, markers
src/components/           panels
src/state/                trip pipeline, playback clock, saved preferences
worker/index.ts           Cloudflare Worker: static files and allow-listed proxies
modal/hrrr_service.py     HRRR and GFS grid service

Times are UTC milliseconds inside and local time on screen. Units are metric inside and imperial on screen.

The route is sampled every 25 km. Each sample gets the forecast for the moment the vehicle arrives there, which is what the timeline, hazards, and departure search use. Sample locations depend only on the route, so changing the departure time re-reads forecasts already in memory.

The map layer always tries the HRRR service first, asking for the area in view at the finest grid that fits about 2 MB. Failing that it uses GFS from NOAA's NOMADS (decoded in the browser by grib2.ts) or the Open-Meteo grid, whichever matches the selected source, then the other. The route forecast defaults to NWS and falls back to Open-Meteo when NWS can't cover the trip, such as outside the US or more than a week out. The Data tab shows what was used.

Data sources

Source Used for Key
OpenFreeMap Basemap No
TomTom Routing with traffic, directions, address search Yes
OSRM demo server Routing without a key No
NWS API Route forecast, alerts No
NOAA HRRR and GFS on AWS Open Data Map layer, through the Modal service No
NCEP NOMADS GFS map layer without the Modal service No
NOAA MRMS Live radar No
Open-Meteo Alternative forecast source, place search fallback No
Caltrans CWWP2 California road conditions and cameras No
ODOT TripCheck API Oregon road conditions and cameras Yes
Mapzen Terrain Tiles Elevation for the grades search No

Credits required by the sources are shown in the app. Open-Meteo's free tier is for non-commercial use. Camera images are linked from the agencies' servers and credited to them.

What you type in the search box goes to TomTom through the Worker. "Use my location" sends your coordinates to the NWS API to find the nearest town.

Limits

  • California and Oregon. Road conditions and cameras come from those two agencies. Nothing else knows about road work in other states.
  • Hazard thresholds are a judgment call for an RV: gusts of 25, 35, and 45 mph for watch, caution, and severe, plus crosswind, rain, snow, ice, and visibility. They are in src/lib/weather/hazards.ts.
  • The departure search adds categories together. How a minute of traffic compares with a minute of wind is a set of weights in src/lib/optimize.ts.
  • Steep grades come from a 240 m terrain model, so short grades can be missed.
  • Directions can miss a highway change where one road continues straight into another.
  • NWS forecasts give wind in multi-hour blocks after the first day, rain as 6-hour totals, and visibility for about 36 hours.
  • The proxies have no login. They only pass the specific requests the app makes and they reject other sites, but someone determined could still use up the free quotas. Put rate limiting in front of /api/* if that worries you.
  • Tested in Chrome, and by hand on an iPad. Not tested in Firefox. Live GPS was tested with simulated positions before the trip it was built for.

Check Caltrans QuickMap and ODOT TripCheck before you drive.

Making it yours

Use it as a starting point. To cover another state you need a source for road conditions there:

  1. Add an adapter beside src/lib/roads/caltrans.ts that returns RoadEvent and RoadCamera records. match.ts handles fitting them to the route.
  2. Add its upstream to the allow-list in worker/index.ts and the dev proxy in vite.config.ts.
  3. Register it in src/lib/roads/index.ts.

Routing, forecasts, the map layer, alerts, radar, and the departure search already work across the US. Outside the US, the route forecast falls back to Open-Meteo and the map layer to GFS.

How it was built

In one evening, by Claude Code running a handful of agents in parallel, starting from roadtripper-poc-handoff.md and a lot of "one more thing" messages. The write-up is at joemattie.com/blog/roadtripper.

License

MIT. See LICENSE.

About

Play a road trip forward in time against the forecast. HRRR weather, road conditions, and cameras for California and Oregon.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages