openPilotLog
ACalc Namespace Reference

The ACalc namespace provides various functions for calculations that are performed outside of the database. This includes tasks like converting different units and formats, or functions calculating block time or night time. More...

Functions

QTime blocktime (QTime tofb, QTime tonb)
 ACalc::blocktime Calculates Block Time for a given departure and arrival time. More...
 
QString minutesToString (QString block_minutes)
 ACalc::minutes_to_string Converts database time to String Time. More...
 
QString minutesToString (int block_minutes)
 
int QTimeToMinutes (QTime time)
 ACalc::time_to_minutes converts QTime to int minutes. More...
 
int stringToMinutes (QString timestring)
 ACalc::string_to_minutes Converts String Time to String Number of Minutes. More...
 
double radToDeg (double rad)
 radToDeg Converts radians to degrees More...
 
double degToRad (double deg)
 degToRad Converts degrees to radians More...
 
double radToNauticalMiles (double rad)
 radToNauticalMiles Convert Radians to nautical miles More...
 
double greatCircleDistance (double lat1, double lon1, double lat2, double lon2)
 greatCircleDistance Calculates Great Circle distance between two coordinates, return in Radians. More...
 
double greatCircleDistanceBetweenAirports (const QString &dept, const QString &dest)
 ACalc::greatCircleDistanceBetweenAirports Calculates Great Circle distance between two coordinates, return in nautical miles. More...
 
QVector< QVector< double > > intermediatePointsOnGreatCircle (double lat1, double lon1, double lat2, double lon2, int tblk)
 Calculates a list of points (lat,lon) along the Great Circle between two points. The points are spaced equally, one minute of block time apart. More...
 
double solarElevation (QDateTime utc_time_point, double lat, double lon)
 Calculates solar elevation angle for a given point in time and latitude/longitude coordinates. More...
 
int calculateNightTime (const QString &dept, const QString &dest, QDateTime departureTime, int tblk, int nightAngle)
 Calculates which portion of a flight was conducted in night conditions. More...
 
bool isNight (const QString &icao, QDateTime event_time, int night_angle)
 
QString formatTimeInput (QString user_input)
 ACalc::formatTimeInput verifies user input and formats to hh:mm if the output is not a valid time, an empty string is returned. Accepts input as hh:mm, h:mm, hhmm or hmm. More...
 
void updateAutoTimes (int acft_id)
 ACalc::updateAutoTimes When the details of an aircraft are changed, this function recalculates deductable times for this aircraft and updates the database accordingly. More...
 
void autoTimes (Flight, Aircraft)
 
void updateNightTimes ()
 ACalc::updateNightTimes updates the night times in the database, used when changing night angle setting for example.
 

Detailed Description

The ACalc namespace provides various functions for calculations that are performed outside of the database. This includes tasks like converting different units and formats, or functions calculating block time or night time.

Function Documentation

◆ blocktime()

QTime ACalc::blocktime ( QTime  tofb,
QTime  tonb 
)
inline

ACalc::blocktime Calculates Block Time for a given departure and arrival time.

Parameters
tofbQTime Time Off Blocks
tonbQTime Time On Blocks
Returns
Block Time in minutes

◆ calculateNightTime()

int ACalc::calculateNightTime ( const QString &  dept,
const QString &  dest,
QDateTime  departureTime,
int  tblk,
int  nightAngle 
)

Calculates which portion of a flight was conducted in night conditions.

Parameters
dept- ICAO 4-letter code of Departure Airport
dest- ICAO 4-letter Code of Destination Airport
departureTime- QDateTime of Departure (UTC)
tblk- Total block time in minutes
nightAngle- the solar elevation angle where night conditons exist. Default -6 (end of civil evening twilight)
Returns
Total number of minutes under night flying conditions

◆ degToRad()

double ACalc::degToRad ( double  deg)
inline

degToRad Converts degrees to radians

Parameters
deg
Returns
radians

◆ formatTimeInput()

QString ACalc::formatTimeInput ( QString  user_input)

ACalc::formatTimeInput verifies user input and formats to hh:mm if the output is not a valid time, an empty string is returned. Accepts input as hh:mm, h:mm, hhmm or hmm.

Parameters
userinputfrom a QLineEdit
Returns
formatted QString "hh:mm" or Empty String

◆ greatCircleDistance()

double ACalc::greatCircleDistance ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)

greatCircleDistance Calculates Great Circle distance between two coordinates, return in Radians.

Parameters
lat1Location Latitude in degrees -90:90 ;S(-) N(+)
lon1Location Longitude in degrees -180:180 W(-) E(+)
lat2Location Latitude in degrees -90:90 ;S(-) N(+)
lon2Location Longitude in degrees -180:180 W(-) E(+)
Returns

The purpose of the following functions is to provide functionality enabling the Calculation of night flying time. EASA defines night as follows:

‘Night’ means the period between the end of evening civil twilight and the beginning of morning civil twilight or such other period between sunset and sunrise as may be prescribed by the appropriate authority, as defined by the Member State.

This is the proccess of Calculating night time in this program:

1) A flight from A to B follows the Great Circle Track along these two points at an average cruising height of 11km. (~FL 360)

2) Any time the Elevation of the Sun at the current position is less than -6 degrees, night conditions are present. 3) The Calculation is performed for every minute of flight time.

In general, input and output for most functions is decimal degrees, like coordinates are stowed in the airports table. Calculations are normally done using Radians.

◆ greatCircleDistanceBetweenAirports()

double ACalc::greatCircleDistanceBetweenAirports ( const QString &  dept,
const QString &  dest 
)

ACalc::greatCircleDistanceBetweenAirports Calculates Great Circle distance between two coordinates, return in nautical miles.

Parameters
deptICAO 4-letter Airport Identifier
destICAO 4-letter Airport Identifier
Returns
Nautical Miles From Departure to Destination

◆ intermediatePointsOnGreatCircle()

QVector< QVector< double > > ACalc::intermediatePointsOnGreatCircle ( double  lat1,
double  lon1,
double  lat2,
double  lon2,
int  tblk 
)

Calculates a list of points (lat,lon) along the Great Circle between two points. The points are spaced equally, one minute of block time apart.

Parameters
lat1Location Latitude in degrees -90:90 ;S(-) N(+)
lon1Location Longitude in degrees -180:180 W(-) E(+)
lat2Location Latitude in degrees -90:90 ;S(-) N(+)
lon2Location Longitude in degrees -180:180 W(-) E(+)
tblkTotal Blocktime in minutes
Returns
coordinates {lat,lon} along the Great Circle Track

◆ minutesToString()

QString ACalc::minutesToString ( QString  block_minutes)
inline

ACalc::minutes_to_string Converts database time to String Time.

Parameters
blockminutesfrom database
Returns
String hh:mm

◆ QTimeToMinutes()

int ACalc::QTimeToMinutes ( QTime  time)
inline

ACalc::time_to_minutes converts QTime to int minutes.

Parameters
timeQTime
Returns
int time as number of minutes

◆ radToDeg()

double ACalc::radToDeg ( double  rad)
inline

radToDeg Converts radians to degrees

Parameters
rad
Returns
degrees

◆ radToNauticalMiles()

double ACalc::radToNauticalMiles ( double  rad)
inline

radToNauticalMiles Convert Radians to nautical miles

Parameters
rad
Returns
nautical miles

◆ solarElevation()

double ACalc::solarElevation ( QDateTime  utc_time_point,
double  lat,
double  lon 
)

Calculates solar elevation angle for a given point in time and latitude/longitude coordinates.

It is based on the formulas found here: http://stjarnhimlen.se/comp/tutorial.html#5

Credit also goes to Darin C. Koblick for his matlab implementation of various of these formulas and to Kevin Godden for porting it to C++.

Darin C. Koblock: https://www.mathworks.com/matlabcentral/profile/authors/1284781 Kevin Godden: https://www.ridgesolutions.ie/index.php/about-us/

Parameters
utc_time_point- QDateTime (UTC) for which the elevation is Calculated
lat- Location Latitude in degrees -90:90 ;S(-) N(+)
lon- Location Longitude in degrees -180:180 W(-) E(+)
Returns
elevation - double of solar elevation in degrees.

◆ stringToMinutes()

int ACalc::stringToMinutes ( QString  timestring)
inline

ACalc::string_to_minutes Converts String Time to String Number of Minutes.

Parameters
timestring"hh:mm"
Returns
String number of minutes

◆ updateAutoTimes()

void ACalc::updateAutoTimes ( int  acft_id)

ACalc::updateAutoTimes When the details of an aircraft are changed, this function recalculates deductable times for this aircraft and updates the database accordingly.

Parameters
acftAn aircraft object.
Returns