Choosing a spatial index 00:00:01 Three maps need different guarantees Dispatch wants every courier within fifty metres. Planning wants a daily demand heat map. Operations wants to know which homes lie inside a service zone with a hole. Could one map answer all three? A courier stands twenty-seven metres from a query point across a cell boundary. In the dispatch view, leaving that courier out is a wrong answer even if the result is fast. For planning, the same coordinate belongs in one reporting bucket per event. For service eligibility, its side of a polygon border matters. These three contracts require different tests of correctness. Write the acceptance tests before picking a grid. For the first map, moving one rider just across a cell boundary must not make the rider disappear. For the second map, every delivered package should count exactly once in the chosen interval. 00:00:55 Choose an index for candidate search For dispatch, index the raw points by spatial buckets. Read a conservative cover for the fifty-metre circle, then test each candidate using the required distance model. Include every bucket that could supply an in-range point, even if the overlap is tiny. The courier twenty-seven metres away survives the distance test, regardless of which side of a cell edge they occupy. Benchmark extra candidates, actual matches, lookup latency and update cost. A larger bucket can read more unrelated riders; a finer bucket can require many reads to cover the same radius. A moving courier creates two costs, the search cost and the cost of retiring the old location. For strict freshness, version the position and verify it after lookup, or specify how stale the answer may be. 00:01:48 Choose a unit for aggregation For the heat map, assign events to H three cells at a chosen resolution. Store the cell identifier, reporting period and event count. A cell at a different resolution has a different identifier. For hierarchical summaries, add fine bucket totals to their logical parent. That rule conserves event counts without requiring the geographic edge of a parent hexagon to coincide with all child outlines. If the map claims deliveries per square kilometre, divide the event count by that cell’s actual area. A raw count map answers a different question from a density map. If a manager asks which cell is busier per resident, dividing by area is still the wrong denominator. Define demand, exposure, and time window before interpreting a bright patch on the heat map. 00:02:39 Choose a cover for a region For the service zone, build an exterior S two covering of the spherical polygon. This creates a compact set of indexed regions that collectively contain the full zone. Fetch the candidate locations, then apply exact containment under the chosen geometry model. Two homes in one covering cell can be on opposite sides of the service boundary. Place a test address inside the polygon’s exclusion hole. A broad cell cover may return it, but the final decision must reject it. Test a genuine inside address from the same cell too. The polygon is authoritative. An outer covering can include water, excluded neighborhoods, or holes. It supplies candidates. The point-in-polygon test with a declared boundary rule decides whether an address is entitled to service. 00:03:28 Run the same truth set I compare all three methods: missed neighbors, extra candidates, query time, and update cost across real data. Compare dispatch against a brute-force distance scan. Reconcile heat-map counts to source events. Check the service-zone answer against direct polygon containment, including points on a boundary. Choose a single index only if it meets all three contracts at an acceptable cost. Several derived indexes can be a good trade when the workload justifies their memory, update and operational cost. All three views may be derived from the same canonical coordinates. Track event versions and lag per view. When the dispatcher disagrees with the report, reconstruct which positions and time window each one actually read.