AlgoViz

Geohash prefixes and cell edges

medium 4 min

Geohash encodes a location in hierarchical rectangular cells.

Video lesson · Chapter 1 of 5

The two riders cross a prefix line

0:00 / 3:56

A 20-metre neighbour with a different prefix

1:12Reel

Theory

Read or listen first. About 1 min.

What it is

A geohash prefix names a rectangular region. Two nearby points on opposite sides of its edge receive different prefixes even when their separation is tiny.

A charger just across a prefix boundary

DriverCharger1 cell searched · nearby charger missed
The driver is 10 metres west of the boundary. A charger 10 metres east is only 20 metres away, yet a lookup restricted to the driver’s prefix misses it.

Why it exists

A radius query needs a covering of all intersecting cells followed by a distance check. Looking only inside the starting cell creates a gap precisely at its boundary.

Words to know

Cell covering
A set of cells whose union contains the requested geographic area.

How it works

Step through the idea, or press Play.

Step 1 of 3

Encode. Convert a charger location into a hierarchical cell key.

Understand it

Worked example

Geohash prefixes and cell edges in practice

A driver is ten metres from a neighboring cell. Scanning only the driver’s prefix omits a charger twenty metres away across that edge. Cover the search area and apply an exact distance test.

Related case

Find every charger across a cell boundary

A driver near the edge of a grid cell requests chargers within 800 metres. The closest charger sits across the street in another cell.

Across the street, across the cell
Chargers on both sides of the streetABCOne cell misses charger B

Fetch intersecting cells and check candidates.

Sources