Why "What's Ahead?" Is a Hard Question

9 min readGuide

Anyone who has driven a long stretch of highway has seen it: a gas station just beyond the fence, close enough to read the price sign, with no way to get there. The exit was two miles back, or the station sits on a road the highway simply passes by. On a map the station is near. On the road it is not. The gap between "what is near me?" and "what is ahead of me on this road?" is one of the quietly difficult problems in navigation software. This guide explains why the second question is so much harder than the first, and surveys the broad kinds of approaches used to answer it.

Where Am I, Really?

Every answer starts with a position, and a position is an estimate. Consumer GPS, along with the similar satellite systems that phones also listen to, is typically accurate to several meters under open sky. It gets worse among tall buildings, where signals bounce off walls before they reach the phone, and under heavy tree cover. In a tunnel the signals do not arrive at all.

Position also arrives in steps. Most phones produce a new fix about once a second, and a car at highway speed covers roughly 100 feet (30 meters) in that second. The dot on the map is always a slightly old report of where the car used to be.

Direction is shakier still. A GPS heading is worked out from movement, so it is dependable at speed and unreliable when the car is stopped or crawling in traffic, because the distance moved between fixes is smaller than the error in the fixes themselves. A phone's compass does not need movement, but it is disturbed by nearby metal and electronics, and a car is full of both.

Which Road Am I On?

Turning a raw position into "this car is on this road" is called map matching. The obvious method is to snap the position to the nearest road on the map. Around highways, the nearest road is often the wrong one:

  • Frontage and service roads run right beside a freeway for miles, sometimes closer to it than the GPS error is wide.
  • Overpasses and stacked interchanges put roads directly on top of one another. A position on a flat map looks the same on every level.
  • Ramps peel away gradually. For the first few hundred feet, an exit ramp and the lane beside it are practically the same line.

Matching can draw on more than position. Heading, speed, and the recent history of positions all carry evidence: a car that was on the freeway a moment ago and is still moving at freeway speed is probably still on the freeway. In the research literature, probabilistic methods such as hidden Markov model map matching are a well-known way of weighing that kind of evidence. None of it makes the problem go away: the evidence is often thinnest, as in a slow crawl past an interchange, exactly when the answer matters most.

Which Way Am I Going?

On paper, a divided highway looks like one road. In map data it is usually two: a pair of separate one-way roads, often only a few car lengths apart. The two halves share a name and a route number, and they sit well inside each other's margin of GPS error.

Knowing the direction of travel matters as much as knowing the road. An exit that is two miles ahead for a northbound driver is two miles behind for a southbound one. Some interchanges serve only one direction. A rest area may be built on one side with no access from the other. Software that has the right highway and the wrong direction gives answers that are confidently and completely backward.

What Does "Ahead" Actually Mean?

There are two ways to measure how far away something is. Straight-line distance is the length of a line drawn on the map. Distance along the road is how far a car must actually travel. On a highway the two can differ enormously. A restaurant a few hundred feet away across the median can be miles of driving away: on to the next exit, over the bridge, and back along the other side.

Curves break the idea of "in front." On a long bend or a mountain switchback, the road doubles back on itself. A place farther along the route can lie behind the car by compass, while a place the driver has already passed sits out in front of the windshield.

What a driver means by "ahead" is closer to this: reachable by continuing on this road, in this direction, and taking an exit. That is a statement about the road network, not about the shape of the ground. It depends on which ramps exist, which way they run, and where they lead.

How Road Data Is Organized

Digital maps store roads as a network: a set of points joined by segments, much like a connect-the-dots drawing. Each segment carries attributes such as its name, its route number, the type of road, and whether traffic may use it in one direction or both. A long highway is a chain of many short segments.

Ramps are segments in their own right, joined to the highway at one end and to a surface road, or another highway, at the other. An exit is a junction: the point where a ramp leaves the main road, usually labeled with a number or a name. How those numbers are assigned is a story of its own, told in Understanding Highway Exit Numbers.

Highway agencies have long used another way to describe location, called linear referencing. Instead of a latitude and a longitude, a location is given as a named route and a distance along it. The mile markers posted along the shoulder are the roadside form of the same idea.

Families of Approaches

The approaches discussed in the navigation industry and in academic research fall into a few broad families. They differ in the information they rely on, and each has places where it tends to struggle. The summary below is a survey, not a ranking.

FamilyRelies onStrengthsTends to struggle with
Geometric reasoningPositions, distances, and directionsNeeds little data; simple to compute and to explainCurves, parallel roads, and anything that depends on how roads connect
Network reasoningThe road graph: segments, junctions, and one-way rulesReflects how a car can actually travelGaps and errors in map data; being matched to the wrong segment to begin with
Linear referencingA named route with distances measured along itTurns a two-dimensional question into a one-dimensional oneRoutes that split, merge, or overlap; measurements that are missing or inconsistent
HybridsSome combination of the aboveOne kind of information can cover for the weak spots of anotherMore moving parts, and sources that disagree with each other

Geometric Reasoning

Geometric approaches work from positions, distances, and directions alone, using the kind of math covered in Distance, Bearing, and Position on a Sphere. They need very little data and are easy to reason about. Their blind spot is that geometry knows nothing about pavement: two points can be close together and pointed the right way with no drivable connection between them.

Network Reasoning

Network approaches follow the road graph the way a routing engine does, moving from segment to segment through junctions and respecting one-way rules. Their answers reflect how a car can really move. They are only as good as the map data underneath, and they depend on first placing the car on the correct segment, which is the map-matching problem all over again.

Linear Referencing

Linear referencing reduces a position to "how far along this route," so that places on the same route can be compared along a single line. The idea is compact and matches how highway agencies already describe their roads. It gets complicated where routes split, merge, or share pavement, and where distance measurements are missing, restart at a boundary, or do not agree between sources.

Hybrids

Nothing forces a choice of one family. A hybrid combines them so that one kind of information can cover for another's weak spots. The cost is complexity: more data to maintain, and the new question of what to do when two sources of evidence disagree.

Why Real Highways Make It Harder

A straight rural interstate with an exit every few miles is the easy case. Real road networks are full of exceptions.

  • Major interchanges: Where several highways meet, dozens of ramps cross, stack, and braid within a small area, and continuing "on this road" may itself require taking a ramp.
  • Collector-distributor lanes: Some freeways have a parallel roadway that gathers entering and exiting traffic away from the through lanes. A driver on it is on the highway in one sense and off it in another.
  • Left-hand exits: In the United States most exits leave from the right. Some leave from the left, against what drivers and software alike tend to expect.
  • Median service plazas: Some toll roads place a service area between the two directions of travel, reachable from both. It belongs to neither side and to both.
  • Widely spaced exits: On some toll roads and remote stretches, exits are far apart, so the next chance to stop may be a long way off.
  • Construction and stale data: Ramps close, lanes shift, and new interchanges open. Map data always lags behind the road by some amount, and the map cannot know what it has not been told.

Why It Matters to Drivers

At highway speed a car covers about a mile a minute. The decision to stop for fuel or food is made well before the exit, with time to change lanes safely, not at the ramp itself. Information that arrives late is of little use, and information that is wrong can cost miles: a missed exit may mean driving to the next one and doubling back.

The information also has to be glanceable. A driver can spare a glance, not a study session, and anything that needs scrolling, zooming, or interpretation is better left to a passenger or to a stop. For more on driving safely at speed, see Essential Highway Safety Tips.

A Hard Question With No Single Answer

"What is ahead?" sounds like a question about distance. It is really four questions in a row: where the car is, which road it is on, which way it is going, and what can be reached by staying on that road. Each one has to be answered from imperfect positions and imperfect maps. Geometry, road networks, linear referencing, and combinations of them each handle part of the problem, and each falls short somewhere.

For the math behind distances and directions, see Distance, Bearing, and Position on a Sphere. For how software finds nearby things quickly among millions of mapped places, see Grids, Tiles, and Organizing Location Data.

Exit Explorer uses your location to find upcoming highway exits and the businesses near them. These guides are general background on mapping technology for curious travelers.