← All posts

The Diversity Gate Breakthrough: Finding the Engine-Rebuild Bug

For weeks, the geolocation engine had been producing zero PIN_DROPs on field test after field test. The diversity gate — a minimum spatial separation requirement between RF observations of the same transmitter — was never being satisfied, no matter how fast the vehicle traveled or how many bursts were captured. Analysis of a 53-minute test drive revealed the root cause: 663 engine rebuilds, one every five seconds.

Every GPS location_update from the Android app triggered the engine to call SiteResolver.trunked_sites_near(), which returned the same 12 trunked sites for all of Frederick County. The code then unconditionally rebuilt the InsightsEngine from scratch — constructing a brand new instance with empty observation windows. Every accumulated per-RID observation was destroyed before the next burst could arrive. Spatial diversity was permanently zero because the observation window never contained more than one burst at a time.

The fix was surgical: compare the new site list against the existing one using a frozenset of (syid, rfss_id, site_id) tuples. Only rebuild if the set actually changes — which, for a drive within a single county, is never. The existing observation windows now persist across the entire drive, accumulating the spatial diversity the grid search requires.

The impact was immediate and dramatic. Applying the fix retroactively to the same drive’s traffic profile: talkgroup 5543 (FPD Ops 2) had three bursts spanning 372 meters of vehicle travel — 37x the 10-meter diversity threshold. The full grid search would have fired with all seven likelihood modules active, producing a confidence estimate of 60–75%. Across all multi-burst talkgroups in the drive, the projection was 4–8 PIN_DROPs from traffic that had previously yielded zero.

A follow-up field test confirmed the projection. Three PIN_DROPs appeared on the map during a routine commute, with transmitter coordinate offsets of 0.04, 0.06, and 0.07 miles from the device — all within the expected accuracy envelope. The system was geolocating. The engine-rebuild bug had been the single bottleneck blocking all geolocation output since the pipeline was first assembled.

A secondary change lowered MIN_SPATIAL_DIVERSITY_M from 25 meters to 10 meters, reducing the minimum vehicle speed needed to accumulate diversity from roughly 16 mph to 7 mph. This allows the engine to produce results in slower traffic and residential driving, not just highway corridors.

← The Live Web Dashboard...From Pin Drops to Road Stripes... →