Clean up and optimize codebase for production readiness

Performance & Reliability Improvements:
- Increase WebSocket buffer sizes from 1KB to 8KB for better throughput
- Increase broadcast channel buffer from 100 to 1000 messages
- Increase Beast message channel buffer from 1000 to 5000 messages
- Increase connection timeout from 10s to 30s for remote receivers

Code Quality Improvements:
- Remove debug output from production code (CPR Debug, Merger Update spam)
- Add MaxDistance constant to replace magic number (999999)
- Clean up comments for better maintainability
- Implement auto-enable for selected aircraft trails

Benefits:
- Much cleaner server logs without debug spam
- Better performance under high aircraft density
- More reliable WebSocket connections with larger buffers
- Improved fault tolerance with increased timeouts

🤖 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 17:54:17 +02:00
commit 064ba2de71
5 changed files with 23 additions and 23 deletions

View file

@ -434,9 +434,7 @@ func (d *Decoder) decodeCPRPosition(aircraft *Aircraft) {
oddLon := d.cprOddLon[aircraft.ICAO24]
d.mu.RUnlock()
// Debug: Log CPR input values
fmt.Printf("CPR Debug %s: even=[%.6f,%.6f] odd=[%.6f,%.6f]\n",
aircraft.ICAO24, evenLat, evenLon, oddLat, oddLon)
// CPR input values ready for decoding
// CPR decoding algorithm
dLat := 360.0 / 60.0
@ -479,12 +477,8 @@ func (d *Decoder) decodeCPRPosition(aircraft *Aircraft) {
// Choose the latitude solution that's closer to the receiver position
if distToOdd < distToEven {
aircraft.Latitude = latOdd
fmt.Printf("CPR Zone: chose ODD lat=%.6f (dist=%.3f) over EVEN lat=%.6f (dist=%.3f) [ref=%.6f]\n",
latOdd, distToOdd, latEven, distToEven, d.refLatitude)
} else {
aircraft.Latitude = latEven
fmt.Printf("CPR Zone: chose EVEN lat=%.6f (dist=%.3f) over ODD lat=%.6f (dist=%.3f) [ref=%.6f]\n",
latEven, distToEven, latOdd, distToOdd, d.refLatitude)
}
// Longitude calculation
@ -508,8 +502,7 @@ func (d *Decoder) decodeCPRPosition(aircraft *Aircraft) {
aircraft.Longitude = lon
// Debug: Log final decoded coordinates
fmt.Printf("CPR Result %s: lat=%.6f lon=%.6f\n", aircraft.ICAO24, aircraft.Latitude, aircraft.Longitude)
// CPR decoding completed successfully
}
// nlFunction calculates the number of longitude zones (NL) for a given latitude.