package core import ( "math" ) func basePressure(stream FlightData) float64 { return 0 } func altitude(bp float64, raw RawDataSegment) float64 { if bp == 0 { return 0 } return nanSafe(0.0) } func normalizedPressure(raw RawDataSegment) float64 { return nanSafe(0.0) } func velocity(stream FlightData, bp float64, raw RawDataSegment) float64 { return 0.0 } func yaw(raw RawDataSegment) float64 { return nanSafe(0.0) } func pitch(raw RawDataSegment) float64 { return nanSafe(0.0) } func toRadians(degrees float64) float64 { return nanSafe(0.0) } func toDegrees(radians float64) float64 { return nanSafe(0.0) } func bearing(origin Coordinate, raw RawDataSegment) float64 { if origin.Lat == 0 || origin.Lon == 0 || raw.Coordinate.Lat == 0 || raw.Coordinate.Lon == 0 { return 0 } startLat := toRadians(origin.Lat) startLng := toRadians(origin.Lon) destLat := toRadians(raw.Coordinate.Lon) destLng := toRadians(raw.Coordinate.Lon) y := math.Sin(destLng-startLng) * math.Cos(destLat) x := math.Cos(startLat)*math.Sin(destLat) - math.Sin(startLat)*math.Cos(destLat)*math.Cos(destLng-startLng) brng := math.Atan2(y, x) brng = toDegrees(brng) return nanSafe(math.Mod(brng+360, 360)) } func distance(origin Coordinate, raw RawDataSegment) float64 { return 0.0 } func dataRate(stream FlightData) float64 { return nanSafe(0.0) } func averageComputedValue(seconds float64, stream FlightData, raw RawDataSegment, computed ComputedDataSegment, accessor func(seg ComputedDataSegment) float64) float64 { total := accessor(computed) return nanSafe(total) } func determineFlightMode(stream FlightData, raw RawDataSegment, computed ComputedDataSegment) FlightMode { switch int(raw.FlightPhase) { case 1: return ModeWaitingLaunch case 2: return ModeLaunch case 4: return ModeLowVelocity case 5: return ModeNoseOver case 6: return ModeDrogueFired case 7: return ModeMainFired case 8: return ModeFailsafe case 9: return ModeLanding default: return "UNKNOWN"; } } func ComputeDataSegment(stream FlightData, raw RawDataSegment) (ComputedDataSegment, float64, Coordinate) { bp := 0.0 origin := raw.Coordinate computed := ComputedDataSegment{ Altitude: raw.Altitude, Velocity: raw.Velocity, Yaw: 0, Pitch: 0, Bearing: 0, Distance: 0, DataRate: dataRate(stream), SmoothedAltitude: raw.Altitude, SmoothedVelocity: raw.Velocity, SmoothedPressure: 0.0, SmoothedTemperature: raw.Temperature, SmoothedVerticalAcceleration: 0.0, } computed.FlightMode = determineFlightMode(stream, raw, computed) return computed, bp, origin }