OPL::Calc 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...

## Classes

struct | NightTimeValues
| The NightTimeValues struct encapsulates values relating to night time that are needed by the NewFlightDialog. More...

## Functions

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)
| Opl::Calc::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)
| OPL::Calc::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)
| OPL::Calc::updateAutoTimes When the details of an aircraft are changed, this function recalculates deductable times for this aircraft and updates the database accordingly. More...
void | updateNightTimes ()
| OPL::Calc::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

## calculateNightTime()

int OPL::Calc::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 OPL::Calc::degToRad | ( | double | deg | ) |

inline

degToRad Converts degrees to radians

Parameters

  deg |

Returns
  radians

## formatTimeInput()

QT_DEPRECATED QString OPL::Calc::formatTimeInput | ( | QString | user_input | ) |

OPL::Calc::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

  userinput | from a QLineEdit

Returns
  formatted QString "hh:mm" or Empty String

## greatCircleDistance()

double OPL::Calc::greatCircleDistance | ( | double | lat1,
|  | double | lon1,
|  | double | lat2,
|  | double | lon2
| ) |  |

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

Parameters

  lat1 | Location Latitude in degrees -90:90 ;S(-) N(+)
  lon1 | Location Longitude in degrees -180:180 W(-) E(+)
  lat2 | Location Latitude in degrees -90:90 ;S(-) N(+)
  lon2 | Location 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 OPL::Calc::greatCircleDistanceBetweenAirports | ( | const QString & | dept,
|  | const QString & | dest
| ) |  |

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

Parameters

  dept | ICAO 4-letter Airport Identifier
  dest | ICAO 4-letter Airport Identifier

Returns
  Nautical Miles From Departure to Destination

## intermediatePointsOnGreatCircle()

QVector< QVector< double > > OPL::Calc::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

  lat1 | Location Latitude in degrees -90:90 ;S(-) N(+)
  lon1 | Location Longitude in degrees -180:180 W(-) E(+)
  lat2 | Location Latitude in degrees -90:90 ;S(-) N(+)
  lon2 | Location Longitude in degrees -180:180 W(-) E(+)
  tblk | Total Blocktime in minutes

Returns
  coordinates {lat,lon} along the Great Circle Track

## radToDeg()

double OPL::Calc::radToDeg | ( | double | rad | ) |

inline

radToDeg Converts radians to degrees

Parameters

  rad |

Returns
  degrees

## radToNauticalMiles()

double OPL::Calc::radToNauticalMiles | ( | double | rad | ) |

inline

radToNauticalMiles Convert Radians to nautical miles

Parameters

  rad |

Returns
  nautical miles

## solarElevation()

double OPL::Calc::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.

## updateAutoTimes()

void OPL::Calc::updateAutoTimes | ( | int | acft_id | ) |

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

Parameters

  acft | An aircraft object.

Returns