KItinerary

flightutil.cpp
1/*
2 SPDX-FileCopyrightText: 2017-2019 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "flightutil_p.h"
8
9#include <QDebug>
10
11using namespace KItinerary;
12
13constexpr inline const auto AirplaneSpeedLowerBound = 250; // km/h, turboprop aircraft, and a bit lower than average cruise speed to account for takeoff/landing
14constexpr inline const auto AirplaneSpeedUpperBound = 2140; // km/h, Concorde, so a bit excessive
15
16bool FlightUtil::isPlausibleDistanceForDuration(int distance, std::chrono::seconds duration)
17{
18 auto lowerBoundDistance = AirplaneSpeedLowerBound * ((double)duration.count() / 3.6);
19 if (duration < std::chrono::hours(1)) { // for ultra short flights the takeoff/landing overhead is so big that our expected speed range doesn't work reliable anymore
20 lowerBoundDistance /= 2;
21 }
22 const auto upperBoundDistance = AirplaneSpeedUpperBound * ((double)duration.count() / 3.6);
23
24 return distance < upperBoundDistance && distance > lowerBoundDistance;
25}
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.