Skip to content

andrewlengly.com/chain-routes-casestudy :: chain routes case study

# A 3D terrain map of Sierra chain controls between Sacramento and Tahoe. It stores every change, so each storm can be replayed.

designed page ......... /chain-routes-casestudy

THE SHORT VERSION

  Chain Routes is a 3D terrain map of Sierra chain controls that saves every checkpoint
  every 10 minutes, since Caltrans publishes the current status only. Each storm between
  Sacramento and Tahoe can be replayed. It is built with Next.js, MapLibre, deck.gl and
  Supabase, and the snapshots it has stored since November 7, 2026 go public once the first
  build merges.

the problem ........... Caltrans publishes chain controls as current status only. Nobody can
                        look up what I-80 did last Saturday.
what i did ............ Built a map that saves every checkpoint every 10 minutes and lines
                        it up with snowfall and the next storm at each summit.
where it stands ....... Tested on sample storms, with snapshots stored since November 7.
                        That history goes public once the first build merges.

kind .................. Case study · Build
role .................. Developer
year .................. 2026
tools ................. Next.js, MapLibre, deck.gl, d3, Supabase, GitHub Actions, Claude
                        Code

what it does .......... A 3D terrain map of Sierra chain controls and closures, for deciding
                        whether to drive up this weekend.

WHY I BUILT IT

  # Chain controls drop out of the record the moment they lift.

  Chain Routes answers one question. Should I drive up this weekend, and when?

  Caltrans publishes chain control status as current-only. Once controls lift, they’re gone
  from the feed, so nobody can check how long Donner sat at R-2 last Saturday or how fast it
  cleared.

  So Chain Routes keeps its own record. Every 10 minutes it reads every checkpoint between
  Sacramento and Tahoe and stores each change.
the feed chain routes reads
                        Caltrans CWWP2

WHAT IT DOES

  # The passes and Tahoe share one map.

passes map ............ Chain controls and closures on the Sierra passes from Sacramento to
                        Tahoe, over snowfall on 3D terrain.
tahoe basin map ....... The lake loop and its summits, with Nevada 511 conditions placed on
                        the same R-level ramp.
replay ................ A scrubber that steps through each 10-minute frame. Watch a storm
                        close the passes and clear them.
trip check ............ Pick one of 16 routes and a departure up to 72 hours out. It
                        estimates when you reach each summit and shows the NWS forecast for
                        that hour.
summit pages .......... 13 pinned summits, each with current conditions and its last five
                        storms.
storm log ............. Each storm gets a page with its hours under control by route and its
                        time to clear at each summit.
methodology ........... Every source and formula in plain language, plus the full chart of
                        status codes.

HOW I BUILT IT

  # I started from what the feeds really send.

  # From a live source check to the 10-minute schedule
  01. Source check
      One script calls every source once
      CI runs it on every pull request
  02. Test fixtures
      Trimmed copies of live responses
      Nevada 511 samples written from its docs
  03. Tests
      Unit tests on saved responses and SQL migrations
      20 of 20 Playwright tests on sample storms
      Crawl: 39 links, none broken
  04. Color review
      Deuteranopia simulated on each status step
      I kept R-2 and R-3, the closest pair at ΔE 13.3
  05. Schedule
      The snapshot job started November 7
      Runs: 852 by November 12, with no failed jobs

  Where a feed broke one of my assumptions, the parser or the rule changed to fit the feed.
source ................ What the data got wrong

THE 3D MAP

  # The snow level sits right on the mountains.

  I modeled the map on FireTrace, Dilum Sanjaya’s wildfire map. It recolors its imagery with
  a Mapbox paint property that MapLibre doesn’t have.

  So Chain Routes repaints each USGS imagery tile in the browser onto a night blue-gray
  ramp. The ramp stays dark so every route keeps its contrast.
the map i modeled this on
                        FireTrace

snow level ............ The NWS snow level at each summit, spread across the map. Ground
                        above it turns frosty, under a labeled ice-blue line.
follows your trip ..... The line uses the current hour, or your departure once a trip check
                        is set. Snow level is a forecast and isn’t stored, so past replay
                        frames leave it off.
conifers .............. Cones on OpenStreetMap woodland at three times life size, mostly
                        between 3,000 and 8,500 ft and thicker on north-facing slopes. Above
                        the snow level they get white caps.
checkpoint posts ...... Controlled checkpoints stand as posts in their status color. Up to
                        six carry a chip like R-2 · since 4:10 AM, most severe first.
key events ............ The first control on each route, closures and reopenings, each
                        route’s peak and the all clear. Each row jumps the replay and flies
                        to the checkpoint.
terrain height ........ 1x, 1.5x, 2x or 3x, saved in the link so a shared view opens the
                        same way.

snow level ............ sum of each summit’s level ÷ d² / sum of 1 ÷ d²
  Here d is the distance to each pinned summit in km, never under 0.5. Frost covers ground
  above that level on a 384 by 384 elevation grid from zoom 9 terrain tiles, or zoom 10 for
  the Tahoe Basin. Away from the summits the line is an estimate.

HOW IT WORKS

  # A scheduled job keeps the record every 10 minutes.

  # How a snapshot moves from the feeds to the page
  01. Caltrans and Nevada 511
      Chain control status
      Lane closures and road weather
  02. Snapshot job
      Supabase Edge Function
      Stores each change
      Checks every record’s time
      Runs on: pg_cron every 10 minutes
  03. Postgres
      Its own chainline schema
      Public reads through views
      Shares a free project with Grid Watch
  04. Next.js site
      Passes and Tahoe maps
      Storm and summit pages
      Also reads: NOHRSC snowfall grids from a GitHub Actions job twice a day, plus NWS
      forecasts

  When the database is missing or fails, the site reads the feeds directly. It shows one
  frame with no past, and the map keeps working.

THE MATH

  # Each number has one fixed definition.

  Every day and time boundary uses Pacific time. Definitions stay fixed once published, so
  this season can be compared with the next.

hours(route, level) ... time when the highest checkpoint on the route sits at that level
  A route counts while at least one checkpoint is above R-0. Overlapping checkpoints never
  double count.

storm opens ........... when a checkpoint on I-80, US-50, SR-89 or SR-267 leaves R-0 for 3
                        hours or more
spells merge .......... when they fall less than 12 hours apart
time to clear ......... hours from the last hour of snow depth gain over 0.5 in. to R-0 at
                        every checkpoint near the summit
  A Nevada basin segment reporting chains or a closure for 3 hours also opens a storm. A
  spell longer than 14 days counts as a seasonal closure and can’t start one.

weekend odds .......... Saturday windows with chain controls / Saturdays this season with
                        data
  A Saturday window runs 6:00 to 10:00 a.m. It counts as controlled if any checkpoint shows
  a status above R-0 in any frame inside it. I-80 is scored westbound and eastbound on their
  own.

threshold ............. median NOHRSC 24-hour snowfall at the summit for the period when
                        controls went up
  The summit page waits for 10 storms before it shows one, and prints the sample size beside
  it.

WHAT THE DATA GOT WRONG

  # The live feeds broke a few of my assumptions.

  I pulled every feed live before writing a metric. Each of these would have written false
  history.

  Caltrans sometimes serves an old copy of a file
    risk .............. Months-old readings written as fresh history
    call .............. Check record times, and mark a district down when nothing is newer
                        than 2 hours

  Some weather stations stay in service long after their last reading
    risk .............. Readings up to 2,270 days old on the map
    call .............. Drop readings older than 3 hours

  District 3 lists each checkpoint several times with letter suffixes
    risk .............. One checkpoint counted three times
    call .............. Collapse matching rows into one

  The District 10 weather file ships malformed JSON
    risk .............. A whole district’s road weather fails to parse
    call .............. Repair the missing commas before parsing

  Nevada has no R codes
    risk .............. Two states on two scales
    call .............. Place each Nevada condition on the nearest step and print the Nevada
                        wording beside it

  Supabase returns at most 1,000 rows per request
    risk .............. Replay frames and season numbers cut off with no error
    call .............. Page through every long read

  The Central Sierra Snow Lab reports no hourly depth
    risk .............. Time to clear at Donner drops to 12-hour resolution
    call .............. Read depth from Independence Camp and keep the lab’s water content

DECISIONS

  # Built so a stale file can’t write false history.

a line for each direction
                        Eastbound and westbound have their own road lines, so a segment’s
                        status follows the way you’re driving.
retention that keeps the numbers true
                        Raw rows age out after 120 days. The rows that weekend odds and
                        closure totals depend on stay.
truck-only codes on the r-1 step
                        They restrict some traffic with no rule for cars.
a schema of its own ... Chain Routes lives in a chainline schema inside the free Supabase
                        project that runs Grid Watch.
its own secret for the schedule
                        The cron call signs in with a random secret kept in Vault, so the
                        service role key never goes there.
the map loads after the page
                        It starts 1.2 s after load on desktop and 2.5 s on a phone, or as
                        soon as you interact.

DESIGN

  # Roads stay the brightest thing on the map.

  Chain levels run from yellow to red over a near-black map, and closed roads turn white
  with a hatch. Every status prints its Caltrans code and plain meaning beside the color.

type .................. Overpass for text and Overpass Mono for every code and reading.
feed down in gray ..... When a feed goes quiet, the map keeps the last known status in gray
                        and prints when the feed went down.

  # Color distance between neighboring status steps under simulated deuteranopia (ΔE)
columns ............... ΔE | Lightness
none to r-1 ........... 90.3 | 29 to 87
r-1 to r-2 ............ 23.1 | 87 to 70
r-2 to r-3 ............ 13.3 | 70 to 57
r-3 to closed ......... 59.2 | 57 to 100
  Every pair stays at least 10 apart. R-2 and R-3 sit closest, and both print their code.

WHERE IT STANDS

  # Tested on sample storms and waiting on a real one.

between snapshots ..... 10 min
summit pages .......... 13
routes in the trip check
                        16
unit tests passing .... 130

  The last source check ran 29 sources with no failures and skipped Nevada 511, which needs
  a key. Its parsers are built from the published docs.

  # Lighthouse on mobile, run against sample data
columns ............... Performance | Accessibility | Best practices | SEO
passes map ............ 100 | 100 | 100 | 100
tahoe basin map ....... 100 | 100 | 100 | 100
donner summit page .... 100 | 100 | 100 | 100
  Read the map scores with care. Lighthouse stops before the map starts, so they measure the
  server-rendered page. With a laptop GPU at 4x CPU throttle, the map is ready in about 3.0
  s at 375 px and 1.6 s at 1440 px.

WHAT’S NEXT

  # What I still need to check.

  # Next
the first real storm
                        Swap the sample storm on this page for a real one once history
                        builds.
a live nevada check ... Run the Nevada parsers against a real 511 key.
a phone test .......... Map timings so far come from a laptop. A real phone will differ.
the snowfall upload ... Turn on the upload to Supabase storage. So far the grid job has run
                        against NOHRSC with the upload off.

  # Known limits
up to 10 minutes old
                        Chain rules change by the minute, so Caltrans QuickMap and Nevada
                        511 have the final word.
no road forecast ...... The forecast covers snow. It can’t say when Caltrans will put chains
                        up.
early odds ............ Weekend odds describe this season so far and carry little weight
                        early on.

TL;DR

built ................. A 3D terrain map of Sierra chain controls from Sacramento to Tahoe,
                        saved every 10 minutes.
found ................. 130 unit tests pass, and the last source check ran 29 sources with
                        no failures.
  # by the numbers
  130 ................. Unit tests passing
  29 .................. Sources in the last check, no failures
  16 .................. Routes in the trip check
the catch ............. Every result so far comes from sample storms. The page is still
                        waiting on a real one.
next .................. Replace the sample storm with the first real storm once enough
                        history builds up.

LINKS

open chain routes ..... chains.andrewlengly.com
read the methodology
                        chains.andrewlengly.com/methodology
code .................. github.com/AndrewLengLy/chainline (private)
the developer side .... /machine/developer

# end of /machine/chain-routes-casestudy. andrew.leng.ly@gmail.com · leave machine mode