func (db *FlightDBFr24) ParsePlayback(body []byte) (*flightdb.Flight, error) { r := FlightPlaybackResponse{} if err := json.Unmarshal(body, &r); err != nil { return nil, err } if r.Result.Response.Timestamp == 0 { return nil, fmt.Errorf("ParsePlayback: no response element (%s no longer exists)", r.Result.Request.FlightId) } // Note: we need the track before we can do the flight identifier (it needs a timestamp from the track data) track := flightdb.Track{} for _, frame := range r.Result.Response.Data.Flight.Track { track = append(track, flightdb.TrackPoint{ Source: "fr24", TimestampUTC: time.Unix(int64(frame.Timestamp), 0).UTC(), Heading: float64(frame.Heading), Latlong: geo.Latlong{float64(frame.Latitude), float64(frame.Longitude)}, SpeedKnots: float64(frame.Speed.Kts), AltitudeFeet: float64(frame.Altitude.Feet), Squawk: frame.Squawk, }) } f := flightdb.Flight{ EquipmentType: r.Result.Response.Data.Flight.Aircraft.Model.Code, Track: track, } f.Tracks = map[string]flightdb.Track{} if err := playback2FlightIdentifier(r, &f.Id); err != nil { return nil, err } return &f, nil }