OPL_Calc.3 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. .TH "OPL::Calc" 3 "Tue Aug 9 2022" "openPilotLog" \" -*- nroff -*-
  2. .ad l
  3. .nh
  4. .SH NAME
  5. OPL::Calc \- 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\&.
  6. .SH SYNOPSIS
  7. .br
  8. .PP
  9. .SS "Classes"
  10. .in +1c
  11. .ti -1c
  12. .RI "struct \fBNightTimeValues\fP"
  13. .br
  14. .RI "The \fBNightTimeValues\fP struct encapsulates values relating to night time that are needed by the \fBNewFlightDialog\fP\&. "
  15. .in -1c
  16. .SS "Functions"
  17. .in +1c
  18. .ti -1c
  19. .RI "double \fBradToDeg\fP (double rad)"
  20. .br
  21. .RI "radToDeg Converts radians to degrees "
  22. .ti -1c
  23. .RI "double \fBdegToRad\fP (double deg)"
  24. .br
  25. .RI "degToRad Converts degrees to radians "
  26. .ti -1c
  27. .RI "double \fBradToNauticalMiles\fP (double rad)"
  28. .br
  29. .RI "radToNauticalMiles Convert Radians to nautical miles "
  30. .ti -1c
  31. .RI "double \fBgreatCircleDistance\fP (double lat1, double lon1, double lat2, double lon2)"
  32. .br
  33. .RI "greatCircleDistance Calculates Great Circle distance between two coordinates, return in Radians\&. "
  34. .ti -1c
  35. .RI "double \fBgreatCircleDistanceBetweenAirports\fP (const QString &dept, const QString &dest)"
  36. .br
  37. .RI "Opl::Calc::greatCircleDistanceBetweenAirports Calculates Great Circle distance between two coordinates, return in nautical miles\&. "
  38. .ti -1c
  39. .RI "QVector< QVector< double > > \fBintermediatePointsOnGreatCircle\fP (double lat1, double lon1, double lat2, double lon2, int tblk)"
  40. .br
  41. .RI "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\&. "
  42. .ti -1c
  43. .RI "double \fBsolarElevation\fP (QDateTime utc_time_point, double lat, double lon)"
  44. .br
  45. .RI "Calculates solar elevation angle for a given point in time and latitude/longitude coordinates\&. "
  46. .ti -1c
  47. .RI "int \fBcalculateNightTime\fP (const QString &dept, const QString &dest, QDateTime departureTime, int tblk, int nightAngle)"
  48. .br
  49. .RI "Calculates which portion of a flight was conducted in night conditions\&. "
  50. .ti -1c
  51. .RI "bool \fBisNight\fP (const QString &icao, QDateTime event_time, int night_angle)"
  52. .br
  53. .ti -1c
  54. .RI "QString \fBformatTimeInput\fP (QString user_input)"
  55. .br
  56. .RI "\fBOPL::Calc::formatTimeInput\fP 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\&. "
  57. .ti -1c
  58. .RI "void \fBupdateAutoTimes\fP (int acft_id)"
  59. .br
  60. .RI "\fBOPL::Calc::updateAutoTimes\fP When the details of an aircraft are changed, this function recalculates deductable times for this aircraft and updates the database accordingly\&. "
  61. .ti -1c
  62. .RI "void \fBupdateNightTimes\fP ()"
  63. .br
  64. .RI "\fBOPL::Calc::updateNightTimes\fP updates the night times in the database, used when changing night angle setting for example\&. "
  65. .in -1c
  66. .SH "Detailed Description"
  67. .PP
  68. 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\&.
  69. .SH "Function Documentation"
  70. .PP
  71. .SS "int OPL::Calc::calculateNightTime (const QString & dept, const QString & dest, QDateTime departureTime, int tblk, int nightAngle)"
  72. .PP
  73. Calculates which portion of a flight was conducted in night conditions\&.
  74. .PP
  75. \fBParameters\fP
  76. .RS 4
  77. \fIdept\fP - ICAO 4-letter code of Departure Airport
  78. .br
  79. \fIdest\fP - ICAO 4-letter Code of Destination Airport
  80. .br
  81. \fIdepartureTime\fP - QDateTime of Departure (UTC)
  82. .br
  83. \fItblk\fP - Total block time in minutes
  84. .br
  85. \fInightAngle\fP - the solar elevation angle where night conditons exist\&. Default -6 (end of civil evening twilight)
  86. .RE
  87. .PP
  88. \fBReturns\fP
  89. .RS 4
  90. Total number of minutes under night flying conditions
  91. .RE
  92. .PP
  93. .SS "double OPL::Calc::degToRad (double deg)\fC [inline]\fP"
  94. .PP
  95. degToRad Converts degrees to radians
  96. .PP
  97. \fBParameters\fP
  98. .RS 4
  99. \fIdeg\fP
  100. .RE
  101. .PP
  102. \fBReturns\fP
  103. .RS 4
  104. radians
  105. .RE
  106. .PP
  107. .SS "QT_DEPRECATED QString OPL::Calc::formatTimeInput (QString user_input)"
  108. .PP
  109. \fBOPL::Calc::formatTimeInput\fP 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\&.
  110. .PP
  111. \fBParameters\fP
  112. .RS 4
  113. \fIuserinput\fP from a QLineEdit
  114. .RE
  115. .PP
  116. \fBReturns\fP
  117. .RS 4
  118. formatted QString 'hh:mm' or Empty String
  119. .RE
  120. .PP
  121. .SS "double OPL::Calc::greatCircleDistance (double lat1, double lon1, double lat2, double lon2)"
  122. .PP
  123. greatCircleDistance Calculates Great Circle distance between two coordinates, return in Radians\&.
  124. .PP
  125. \fBParameters\fP
  126. .RS 4
  127. \fIlat1\fP Location Latitude in degrees -90:90 ;S(-) N(+)
  128. .br
  129. \fIlon1\fP Location Longitude in degrees -180:180 W(-) E(+)
  130. .br
  131. \fIlat2\fP Location Latitude in degrees -90:90 ;S(-) N(+)
  132. .br
  133. \fIlon2\fP Location Longitude in degrees -180:180 W(-) E(+)
  134. .RE
  135. .PP
  136. \fBReturns\fP
  137. .RS 4
  138. .RE
  139. .PP
  140. The purpose of the following functions is to provide functionality enabling the Calculation of night flying time\&. EASA defines night as follows:
  141. .PP
  142. ‘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\&.
  143. .PP
  144. This is the proccess of Calculating night time in this program:
  145. .PP
  146. 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)
  147. .PP
  148. 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\&.
  149. .PP
  150. 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\&.
  151. .SS "double OPL::Calc::greatCircleDistanceBetweenAirports (const QString & dept, const QString & dest)"
  152. .PP
  153. Opl::Calc::greatCircleDistanceBetweenAirports Calculates Great Circle distance between two coordinates, return in nautical miles\&.
  154. .PP
  155. \fBParameters\fP
  156. .RS 4
  157. \fIdept\fP ICAO 4-letter Airport Identifier
  158. .br
  159. \fIdest\fP ICAO 4-letter Airport Identifier
  160. .RE
  161. .PP
  162. \fBReturns\fP
  163. .RS 4
  164. Nautical Miles From Departure to Destination
  165. .RE
  166. .PP
  167. .SS "QVector< QVector< double > > OPL::Calc::intermediatePointsOnGreatCircle (double lat1, double lon1, double lat2, double lon2, int tblk)"
  168. .PP
  169. 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\&.
  170. .PP
  171. \fBParameters\fP
  172. .RS 4
  173. \fIlat1\fP Location Latitude in degrees -90:90 ;S(-) N(+)
  174. .br
  175. \fIlon1\fP Location Longitude in degrees -180:180 W(-) E(+)
  176. .br
  177. \fIlat2\fP Location Latitude in degrees -90:90 ;S(-) N(+)
  178. .br
  179. \fIlon2\fP Location Longitude in degrees -180:180 W(-) E(+)
  180. .br
  181. \fItblk\fP Total Blocktime in minutes
  182. .RE
  183. .PP
  184. \fBReturns\fP
  185. .RS 4
  186. coordinates {lat,lon} along the Great Circle Track
  187. .RE
  188. .PP
  189. .SS "double OPL::Calc::radToDeg (double rad)\fC [inline]\fP"
  190. .PP
  191. radToDeg Converts radians to degrees
  192. .PP
  193. \fBParameters\fP
  194. .RS 4
  195. \fIrad\fP
  196. .RE
  197. .PP
  198. \fBReturns\fP
  199. .RS 4
  200. degrees
  201. .RE
  202. .PP
  203. .SS "double OPL::Calc::radToNauticalMiles (double rad)\fC [inline]\fP"
  204. .PP
  205. radToNauticalMiles Convert Radians to nautical miles
  206. .PP
  207. \fBParameters\fP
  208. .RS 4
  209. \fIrad\fP
  210. .RE
  211. .PP
  212. \fBReturns\fP
  213. .RS 4
  214. nautical miles
  215. .RE
  216. .PP
  217. .SS "double OPL::Calc::solarElevation (QDateTime utc_time_point, double lat, double lon)"
  218. .PP
  219. 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
  220. .PP
  221. 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++\&.
  222. .PP
  223. Darin C\&. Koblock: https://www.mathworks.com/matlabcentral/profile/authors/1284781 Kevin Godden: https://www.ridgesolutions.ie/index.php/about-us/
  224. .PP
  225. \fBParameters\fP
  226. .RS 4
  227. \fIutc_time_point\fP - QDateTime (UTC) for which the elevation is Calculated
  228. .br
  229. \fIlat\fP - Location Latitude in degrees -90:90 ;S(-) N(+)
  230. .br
  231. \fIlon\fP - Location Longitude in degrees -180:180 W(-) E(+)
  232. .RE
  233. .PP
  234. \fBReturns\fP
  235. .RS 4
  236. elevation - double of solar elevation in degrees\&.
  237. .RE
  238. .PP
  239. .SS "void OPL::Calc::updateAutoTimes (int acft_id)"
  240. .PP
  241. \fBOPL::Calc::updateAutoTimes\fP When the details of an aircraft are changed, this function recalculates deductable times for this aircraft and updates the database accordingly\&.
  242. .PP
  243. \fBParameters\fP
  244. .RS 4
  245. \fIacft\fP An aircraft object\&.
  246. .RE
  247. .PP
  248. \fBReturns\fP
  249. .RS 4
  250. .RE
  251. .PP
  252. .SH "Author"
  253. .PP
  254. Generated automatically by Doxygen for openPilotLog from the source code\&.