Fix CPR zone ambiguity causing aircraft to appear 100km away from actual position

PROBLEM:
- Aircraft were appearing ~100km from receiver when actually ~5km away
- CPR (Compact Position Reporting) algorithm has zone ambiguity issue
- Without reference position, aircraft can appear in wrong 6-degree zones

SOLUTION:
- Add receiver reference position to CPR decoder for zone resolution
- Modified NewDecoder() to accept reference latitude/longitude parameters
- Implement distance-based zone selection (choose solution closest to receiver)
- Updated all decoder instantiations to pass receiver coordinates

TECHNICAL CHANGES:
- decoder.go: Add refLatitude/refLongitude fields and zone ambiguity resolution
- beast.go: Pass source coordinates to NewDecoder()
- beast-dump/main.go: Use default coordinates (0,0) for command-line tool
- merger.go: Add position update debugging for verification
- JavaScript: Add coordinate validation and update logging

RESULT:
- Aircraft now appear at correct distances from receiver
- CPR zone selection based on proximity to known receiver location
- Resolves fundamental ADS-B position accuracy issue

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2025-08-24 14:40:36 +02:00
commit f364ffe061
7 changed files with 52 additions and 31 deletions

View file

@ -400,9 +400,14 @@ func (m *Merger) mergeAircraftData(state *AircraftState, new *modes.Aircraft, so
}
if updatePosition {
fmt.Printf("Merger Update %06X: %.6f,%.6f -> %.6f,%.6f\n",
state.Aircraft.ICAO24, state.Latitude, state.Longitude, new.Latitude, new.Longitude)
state.Latitude = new.Latitude
state.Longitude = new.Longitude
state.PositionSource = sourceID
} else {
fmt.Printf("Merger Skip %06X: rejected update %.6f,%.6f (current: %.6f,%.6f)\n",
state.Aircraft.ICAO24, new.Latitude, new.Longitude, state.Latitude, state.Longitude)
}
}