mapstrailspublic-landsllmgeminiengineering

Forest Service Closures on Your Trail Maps

RidgeText now reads Forest Service closure orders for more than 100 national forests every week, draws closed trails and roads in red on your trail maps, and answers questions about trails closed to motorcycles, bikes or horses.

Allan Bogh·

A trail map tells you where a trail goes. It doesn't tell you whether you're allowed on it this week. After a wildfire, a washout or a bridge failure, the Forest Service closes trails and roads by issuing an order. If you didn't read the order before you lost signal, you may not find out about the closure until you reach the gate.

RidgeText now reads those orders for you. Ask for a trail map in a national forest, and the trails and roads an order closes are drawn in red, with the order's name, dates and contact in the reply.

Trail map of the Entiat valley around Brief, Washington, with dozens of trails and roads closed by the Little Giant Fire order drawn in red, and open trails in orange with numbered pins

What you can ask

A trail map, with its closures

You: Show me a trail map for Brief, WA

Brief sits in the Entiat valley, inside the area of the Little Giant Fire closure on the Okanogan-Wenatchee National Forest. The map above came back with every trail and road the order closes drawn in red, and the open trails in orange, numbered to match the list in the reply. The map is framed to take in every closure in the area you asked about, so a closed road at the edge of the map isn't cut off.

When you ask RidgeText to zoom in, the closer map uses the same colors:

Closer trail map near Brief, Washington: closed roads in red winding up the ridges beside open numbered trails in orange

Red routes are closed to everyone by the order. Orange routes are open, and their numbered pins match the reply's trail list.

Closed to some uses, open to others

Most trail restrictions don't close a trail. They close it to motorcycles, mountain bikes or pack animals, and leave it open to everyone else. Drawing those trails in red would tell a hiker they can't walk a trail when they really can, so RidgeText doesn't draw them in red. They stay on the map as open trails, and the trail list in the reply marks what isn't allowed, such as "(closed to motor vehicles)".

That means you can ask:

You: Can I ride my dirt bike on the Prince Creek Trail?

and RidgeText answers from the order that closes Prince Creek Trail 1255 to motor vehicles, without telling you that the trail is closed to hikers, because it isn't.

How an order is read

We get the orders for each national forest directly from the Forest Service: each order's text and its signed PDF. What happens next is the interesting part, because orders are written differently from one forest to the next. Some list closed trails in a table, some in sentences, some only on a scanned map, and a 1991 order is a typewritten page run through OCR. Fixed parsing rules broke on each new forest's orders, so now a language model reads each order, and our code checks everything the model reports.

Being a good neighbor to the Forest Service

The Forest Service's servers are public infrastructure, shared by everyone planning a trip, and we want RidgeText to add as little load to them as possible. So we keep our own copy of every order, its text and its signed PDF, on our servers. The first time we read a forest's orders we download each one. After that, we only ask for an order again when the Forest Service shows that it has changed, or once a month in case its dates moved. When we ask for a signed PDF we already hold, we send along the version we have, and an unchanged PDF comes back as a short "not modified" reply instead of the whole document. Everything else happens on our copy: when we improve the reader, we read every stored order again without sending a single request to the Forest Service.

We also pace ourselves. Our requests go out one at a time, eight seconds apart, so the servers have time to answer everyone else's requests between ours. If the servers turn a request away, we wait 30 seconds before trying again, up to twice. If we're still turned away after that, we end the run instead of continuing to ask, and try again on the next scheduled run.

Flow chart: an order from the Forest Service is read by Gemini unless a reading of the same text and PDF is stored; a rule-based reading stands in when Gemini fails; when the order names 20 or more route numbers the reading left out, Gemini is asked about each; every route must appear in its quote and in the order's text or it is dropped; routes closed to everyone are drawn red and routes closed to some uses are answered in text; the result is stored with the order

Tap the chart to open it full size.

One request, one schema

Gemini, with its temperature set to 0 so its answers vary as little as possible, gets the order's text and the PDF itself, so it can see scanned exhibits and maps that aren't in the PDF's text layer. The prompt tells it that the PDF is the signed order, so where the text and the PDF disagree, the PDF wins. It answers in JSON against a fixed schema:

The prompt spells out what isn't a closed route: a road named as a boundary ("north of FSR 6101"), the junction where a closure starts, townships, dates, mileposts and order numbers. Speed limits, parking rules and camping rules are still recorded as prohibitions, but they don't count as closing a route to anyone. A road written with its spurs, "5900-114,112,113", is three roads.

When Gemini can't answer

If the request fails after its retries, or Gemini says the document isn't an order while our older rule-based reader found prohibitions in it, the rule-based reading is stored instead, and the order records which reader it came from. A rate-limited request waits 30, 60 and then 120 seconds before giving up, and the next run tries Gemini again.

Reading once

Each reading is stored beside the order under a key made from the reader's version, the order's text and the PDF's bytes. An unchanged order is never sent to Gemini twice. When the reader improves, we raise its version number, and the next run reads every stored order again.

Checking the model's work

A trail drawn in red when it's actually open sends people home who didn't need to turn around, and we consider that worse than missing a closed trail. So every route the model reports has to pass two checks before it's stored:

  1. It's in its quote. The route's number must appear in the sentence the model quoted as closing it. If the number isn't in the quote, the model supplied it from somewhere other than the order.
  2. It's in the order. The number must appear in the order's text or the PDF's text layer. A PDF with almost no text layer (under 200 characters) is a scan, and there's nothing to check it against, so we accept the routes the model read from the scanned image.

A route that fails either check is dropped and logged with the reason. One order shows why the checks matter: the Manastash area closure lists trails that stay open to motor vehicles. Gemini listed them, but they appear only in the scanned part of the PDF and not in its text, so the checks dropped them and kept these open trails off the closure list. Finally, if the model lists a route as both closed to everyone and closed to some uses, only the full closure is kept.

Long orders

A 1991 forestwide order on the Okanogan-Wenatchee lists about 200 trails across seven exhibits. Each exhibit closes its trails to one kind of use, such as motor vehicles, 4-wheel drives, bicycles or pack animals, and some only for part of the year. When we asked Gemini to list every trail, it listed about half of them in one run and only a handful of examples in the next.

Rewording the prompt to insist on every trail didn't fix that, so we added a second step that doesn't depend on Gemini being thorough. Our code finds the route numbers in the order itself, and Gemini only has to say what the order does with each one. When a trail appears in several exhibits, Gemini gives it the restricted uses from every one of them.

Diagram of the long-order step for the 1991 trail order: the 31-page order text is searched for every route number, finding 286; Gemini's first reading left out 99 of them; because 20 or more were left out, Gemini is asked about every number, 60 per request, in 5 requests, and its answers replace the first reading; after the usual checks, 191 trails are kept and 9 dropped. Orders that leave out fewer than 20 keep their first reading.

It still isn't perfect. Text from a 35-year-old scan has stray spaces and misread characters ("1315.l"), so a few real trails fail the checks and are dropped. We accept that over the alternative, which would be to hand the model a list of every known trail number and ask it to find each one in the order. That approach invites the model to find trails that aren't there.

From the order to your map

When you ask for a trail map, RidgeText checks the Forest Service's ranger district boundaries to see which districts the map covers, then finds the orders in effect in those districts. Closed trails are matched to OpenStreetMap trails by their Forest Service number, then by name. Closed roads are drawn from the Forest Service's own road layer, and only the roads inside the national forest the order covers are drawn. The map is framed to include every closure in the area, and when an order closes a whole area instead of naming trails, the reply names that order.

Before you go

A national forest whose orders RidgeText hasn't read yet is reported as unchecked, never as closure-free. And closure orders change quickly during fire season, sometimes daily. Treat the map as a first look, and confirm with the ranger district before you go. The reply includes the order's contact when it lists one, or you can ask for it.

Check the trail before you drive to it

Text RidgeText for a trail map and see which trails and roads a Forest Service order has closed, by SMS, even with one bar of signal.