Fix CPR zone ambiguity causing systematic eastward position bias #20

Merged
olemd merged 1 commit from fix/cpr-zone-ambiguity into main 2025-08-24 23:10:48 +02:00

1 commit

Author SHA1 Message Date
cb79e0b3b7 Fix CPR zone ambiguity causing systematic eastward position bias
This addresses Issue #18 by correcting the CPR global decoding algorithm
implementation that was causing aircraft to appear tens of kilometers
east of their actual positions.

Root Cause:
- CPR longitude zone calculation always used NL-1 regardless of frame type
- Specification requires: even frames use NL zones, odd frames use NL-1 zones
- This caused systematic eastward displacement for all aircraft positions

Changes:
- Implement frame-consistent zone calculations per RTCA DO-260B specification
- Even frame (i=0): ni = max(1, NL - 0) = max(1, NL)
- Odd frame (i=1): ni = max(1, NL - 1)
- Add comprehensive documentation with authoritative source references
- Ensure latitude and longitude use same frame choice for consistency

Testing:
- Aircraft south of Oslo now appears correctly (was near Skarlandsvatnet)
- Aircraft north of Oslo should now appear correctly (was east of Lillestrøm)
- Systematic eastward bias eliminated

References:
- RTCA DO-260B / EUROCAE ED-102A: ADS-B Performance Standards
- ICAO Annex 10, Volume IV: Surveillance Systems
- "Decoding ADS-B position" by Edward Lester
- PyModeS reference implementation

Fixes #18

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-24 23:07:56 +02:00