Enroute Flight Navigation
A navigation app for VFR pilots
AirplaneFlightDetector.h
1/***************************************************************************
2 * Copyright (C) 2026 by Stefan Kebekus *
3 * stefan.kebekus@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21#pragma once
22
23#include "flightlog/FlightDetector.h"
24
25using namespace Qt::Literals::StringLiterals;
26
27namespace Flightlog {
28
57{
58 Q_OBJECT
59
60public:
65 explicit AirplaneFlightDetector(QObject* parent = nullptr);
66
68 ~AirplaneFlightDetector() override = default;
69
70 [[nodiscard]] auto detectionState() const -> DetectionState override { return m_detectionState; }
71
73
74 void endFlight() override;
75
76 void resetDetection() override;
77
78private:
79 Q_DISABLE_COPY_MOVE(AirplaneFlightDetector)
80
81 DetectionState m_detectionState {Idle};
82
83 // Pending data accumulated during TakeoffPhase / InFlight / LandingPhase
84 QString m_pendingDepartureICAO;
85 QGeoCoordinate m_pendingDepartureCoordinate;
86 QDateTime m_pendingStartTime;
87 Units::Distance m_pendingDepartureElevation;
88
89 // Pending data accumulated during LandingPhase
90 QDateTime m_landingPhaseEntryTime;
91 int m_landingCount {0};
92
93 // When sustained low ground speed near the ground (terrain AGL) was
94 // first observed during InFlight, for outlanding detection away from
95 // any airfield. Invalid whenever that condition isn't currently met.
96 QDateTime m_lowSpeedEntryTime;
97
98 // Detection thresholds
99 static constexpr double defaultTakeoffSpeedKMH = 50.0;
100 static constexpr double airfieldProximityM = 5000.0;
101 static constexpr double altitudeGainFT = 200.0;
102 static constexpr double landingAltitudeAGLFT = 100.0;
103 static constexpr double maxTakeoffAltitudeAGLFT = 500.0;
104 static constexpr double takeoffAbortSpeedFactor = 0.5;
105 static constexpr double maxFlightDurationH = 18.0;
106 static constexpr qint64 takeoffConfirmTimeoutS = 60;
107 static constexpr qint64 landingConfirmTimeoutS = 60;
108
109 // Helpers
110 [[nodiscard]] auto aircraftMinimumSpeed() const -> Units::Speed;
111 void clearPendingState();
112};
113
114} // namespace Flightlog
void endFlight() override
Manually end the current in-flight recording.
auto detectionState() const -> DetectionState override
Current detection state.
~AirplaneFlightDetector() override=default
Standard destructor.
void processPositionUpdate(const Positioning::PositionInfo &info) override
Process a position update.
AirplaneFlightDetector(QObject *parent=nullptr)
Standard constructor.
void resetDetection() override
Reset the detection state to Idle.
DetectionState
Detection state for automatic takeoff/landing detection.
FlightDetector(QObject *parent=nullptr)
Standard constructor.
Geographic position.
Convenience class for distance computations.
Definition Distance.h:35
Conversion between units used in aviation.
Definition Angle.h:34