Initial implementation of SkyView - ADS-B aircraft tracker
- Go application with embedded static files for dump1090 frontend - TCP client for SBS-1/BaseStation format (port 30003) - Real-time WebSocket updates with aircraft tracking - Modern web frontend with Leaflet maps and mobile-responsive design - Aircraft table with filtering/sorting and statistics dashboard - Origin configuration for receiver location and distance calculations - Automatic config.json loading from current directory - Foreground execution by default with optional -daemon flag 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
commit
8ce4f4c397
19 changed files with 1971 additions and 0 deletions
95
internal/parser/sbs1.go
Normal file
95
internal/parser/sbs1.go
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
package parser
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Aircraft struct {
|
||||
Hex string `json:"hex"`
|
||||
Flight string `json:"flight,omitempty"`
|
||||
Altitude int `json:"alt_baro,omitempty"`
|
||||
GroundSpeed int `json:"gs,omitempty"`
|
||||
Track int `json:"track,omitempty"`
|
||||
Latitude float64 `json:"lat,omitempty"`
|
||||
Longitude float64 `json:"lon,omitempty"`
|
||||
VertRate int `json:"vert_rate,omitempty"`
|
||||
Squawk string `json:"squawk,omitempty"`
|
||||
Emergency bool `json:"emergency,omitempty"`
|
||||
OnGround bool `json:"on_ground,omitempty"`
|
||||
LastSeen time.Time `json:"last_seen"`
|
||||
Messages int `json:"messages"`
|
||||
}
|
||||
|
||||
type AircraftData struct {
|
||||
Now int64 `json:"now"`
|
||||
Messages int `json:"messages"`
|
||||
Aircraft map[string]Aircraft `json:"aircraft"`
|
||||
}
|
||||
|
||||
func ParseSBS1Line(line string) (*Aircraft, error) {
|
||||
parts := strings.Split(strings.TrimSpace(line), ",")
|
||||
if len(parts) < 22 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
messageType := parts[1]
|
||||
if messageType != "1" && messageType != "3" && messageType != "4" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
aircraft := &Aircraft{
|
||||
Hex: strings.TrimSpace(parts[4]),
|
||||
LastSeen: time.Now(),
|
||||
Messages: 1,
|
||||
}
|
||||
|
||||
if parts[10] != "" {
|
||||
aircraft.Flight = strings.TrimSpace(parts[10])
|
||||
}
|
||||
|
||||
if parts[11] != "" {
|
||||
if alt, err := strconv.Atoi(parts[11]); err == nil {
|
||||
aircraft.Altitude = alt
|
||||
}
|
||||
}
|
||||
|
||||
if parts[12] != "" {
|
||||
if gs, err := strconv.Atoi(parts[12]); err == nil {
|
||||
aircraft.GroundSpeed = gs
|
||||
}
|
||||
}
|
||||
|
||||
if parts[13] != "" {
|
||||
if track, err := strconv.Atoi(parts[13]); err == nil {
|
||||
aircraft.Track = track
|
||||
}
|
||||
}
|
||||
|
||||
if parts[14] != "" && parts[15] != "" {
|
||||
if lat, err := strconv.ParseFloat(parts[14], 64); err == nil {
|
||||
aircraft.Latitude = lat
|
||||
}
|
||||
if lon, err := strconv.ParseFloat(parts[15], 64); err == nil {
|
||||
aircraft.Longitude = lon
|
||||
}
|
||||
}
|
||||
|
||||
if parts[16] != "" {
|
||||
if vr, err := strconv.Atoi(parts[16]); err == nil {
|
||||
aircraft.VertRate = vr
|
||||
}
|
||||
}
|
||||
|
||||
if parts[17] != "" {
|
||||
aircraft.Squawk = strings.TrimSpace(parts[17])
|
||||
}
|
||||
|
||||
if parts[21] != "" {
|
||||
aircraft.OnGround = parts[21] == "1"
|
||||
}
|
||||
|
||||
return aircraft, nil
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue