ACalc.3 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. .TH "ACalc" 3 "Sun Dec 27 2020" "openPilotLog" \" -*- nroff -*-
  2. .ad l
  3. .nh
  4. .SH NAME
  5. ACalc \- The \fBACalc\fP 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 "Functions"
  10. .in +1c
  11. .ti -1c
  12. .RI "QTime \fBblocktime\fP (QTime tofb, QTime tonb)"
  13. .br
  14. .RI "\fBACalc::blocktime\fP Calculates Block Time for a given departure and arrival time\&. "
  15. .ti -1c
  16. .RI "QString \fBminutesToString\fP (QString block_minutes)"
  17. .br
  18. .RI "ACalc::minutes_to_string Converts database time to String Time\&. "
  19. .ti -1c
  20. .RI "QString \fBminutesToString\fP (int block_minutes)"
  21. .br
  22. .ti -1c
  23. .RI "int \fBQTimeToMinutes\fP (QTime time)"
  24. .br
  25. .RI "ACalc::time_to_minutes converts QTime to int minutes\&. "
  26. .ti -1c
  27. .RI "int \fBstringToMinutes\fP (QString timestring)"
  28. .br
  29. .RI "ACalc::string_to_minutes Converts String Time to String Number of Minutes\&. "
  30. .ti -1c
  31. .RI "double \fBradToDeg\fP (double rad)"
  32. .br
  33. .RI "radToDeg Converts radians to degrees "
  34. .ti -1c
  35. .RI "double \fBdegToRad\fP (double deg)"
  36. .br
  37. .RI "degToRad Converts degrees to radians "
  38. .ti -1c
  39. .RI "double \fBradToNauticalMiles\fP (double rad)"
  40. .br
  41. .RI "radToNauticalMiles Convert Radians to nautical miles "
  42. .ti -1c
  43. .RI "double \fBgreatCircleDistance\fP (double lat1, double lon1, double lat2, double lon2)"
  44. .br
  45. .RI "greatCircleDistance Calculates Great Circle distance between two coordinates, return in Radians\&. "
  46. .ti -1c
  47. .RI "double \fBgreatCircleDistanceBetweenAirports\fP (const QString &dept, const QString &dest)"
  48. .br
  49. .RI "\fBACalc::greatCircleDistanceBetweenAirports\fP Calculates Great Circle distance between two coordinates, return in nautical miles\&. "
  50. .ti -1c
  51. .RI "QVector< QVector< double > > \fBintermediatePointsOnGreatCircle\fP (double lat1, double lon1, double lat2, double lon2, int tblk)"
  52. .br
  53. .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\&. "
  54. .ti -1c
  55. .RI "double \fBsolarElevation\fP (QDateTime utc_time_point, double lat, double lon)"
  56. .br
  57. .RI "Calculates solar elevation angle for a given point in time and latitude/longitude coordinates\&. "
  58. .ti -1c
  59. .RI "int \fBcalculateNightTime\fP (const QString &dept, const QString &dest, QDateTime departureTime, int tblk, int nightAngle)"
  60. .br
  61. .RI "Calculates which portion of a flight was conducted in night conditions\&. "
  62. .ti -1c
  63. .RI "bool \fBisNight\fP (const QString &icao, QDateTime event_time, int night_angle)"
  64. .br
  65. .ti -1c
  66. .RI "QString \fBformatTimeInput\fP (QString user_input)"
  67. .br
  68. .RI "\fBACalc::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\&. "
  69. .ti -1c
  70. .RI "void \fBupdateAutoTimes\fP (int acft_id)"
  71. .br
  72. .RI "\fBACalc::updateAutoTimes\fP When the details of an aircraft are changed, this function recalculates deductable times for this aircraft and updates the database accordingly\&. "
  73. .ti -1c
  74. .RI "void \fBautoTimes\fP (\fBFlight\fP, \fBAircraft\fP)"
  75. .br
  76. .ti -1c
  77. .RI "void \fBupdateNightTimes\fP ()"
  78. .br
  79. .RI "\fBACalc::updateNightTimes\fP updates the night times in the database, used when changing night angle setting for example\&. "
  80. .in -1c
  81. .SH "Detailed Description"
  82. .PP
  83. The \fBACalc\fP 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\&.
  84. .SH "Function Documentation"
  85. .PP
  86. .SS "QTime ACalc::blocktime (QTime tofb, QTime tonb)\fC [inline]\fP"
  87. .PP
  88. \fBACalc::blocktime\fP Calculates Block Time for a given departure and arrival time\&.
  89. .PP
  90. \fBParameters\fP
  91. .RS 4
  92. \fItofb\fP QTime Time Off Blocks
  93. .br
  94. \fItonb\fP QTime Time On Blocks
  95. .RE
  96. .PP
  97. \fBReturns\fP
  98. .RS 4
  99. Block Time in minutes
  100. .RE
  101. .PP
  102. .SS "int ACalc::calculateNightTime (const QString & dept, const QString & dest, QDateTime departureTime, int tblk, int nightAngle)"
  103. .PP
  104. Calculates which portion of a flight was conducted in night conditions\&.
  105. .PP
  106. \fBParameters\fP
  107. .RS 4
  108. \fIdept\fP - ICAO 4-letter code of Departure Airport
  109. .br
  110. \fIdest\fP - ICAO 4-letter Code of Destination Airport
  111. .br
  112. \fIdepartureTime\fP - QDateTime of Departure (UTC)
  113. .br
  114. \fItblk\fP - Total block time in minutes
  115. .br
  116. \fInightAngle\fP - the solar elevation angle where night conditons exist\&. Default -6 (end of civil evening twilight)
  117. .RE
  118. .PP
  119. \fBReturns\fP
  120. .RS 4
  121. Total number of minutes under night flying conditions
  122. .RE
  123. .PP
  124. .SS "double ACalc::degToRad (double deg)\fC [inline]\fP"
  125. .PP
  126. degToRad Converts degrees to radians
  127. .PP
  128. \fBParameters\fP
  129. .RS 4
  130. \fIdeg\fP
  131. .RE
  132. .PP
  133. \fBReturns\fP
  134. .RS 4
  135. radians
  136. .RE
  137. .PP
  138. .SS "QString ACalc::formatTimeInput (QString user_input)"
  139. .PP
  140. \fBACalc::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\&.
  141. .PP
  142. \fBParameters\fP
  143. .RS 4
  144. \fIuserinput\fP from a QLineEdit
  145. .RE
  146. .PP
  147. \fBReturns\fP
  148. .RS 4
  149. formatted QString 'hh:mm' or Empty String
  150. .RE
  151. .PP
  152. .SS "double ACalc::greatCircleDistance (double lat1, double lon1, double lat2, double lon2)"
  153. .PP
  154. greatCircleDistance Calculates Great Circle distance between two coordinates, return in Radians\&.
  155. .PP
  156. \fBParameters\fP
  157. .RS 4
  158. \fIlat1\fP Location Latitude in degrees -90:90 ;S(-) N(+)
  159. .br
  160. \fIlon1\fP Location Longitude in degrees -180:180 W(-) E(+)
  161. .br
  162. \fIlat2\fP Location Latitude in degrees -90:90 ;S(-) N(+)
  163. .br
  164. \fIlon2\fP Location Longitude in degrees -180:180 W(-) E(+)
  165. .RE
  166. .PP
  167. \fBReturns\fP
  168. .RS 4
  169. .RE
  170. .PP
  171. The purpose of the following functions is to provide functionality enabling the Calculation of night flying time\&. EASA defines night as follows:
  172. .PP
  173. ‘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\&.
  174. .PP
  175. This is the proccess of Calculating night time in this program:
  176. .PP
  177. 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)
  178. .PP
  179. 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\&.
  180. .PP
  181. 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\&.
  182. .SS "double ACalc::greatCircleDistanceBetweenAirports (const QString & dept, const QString & dest)"
  183. .PP
  184. \fBACalc::greatCircleDistanceBetweenAirports\fP Calculates Great Circle distance between two coordinates, return in nautical miles\&.
  185. .PP
  186. \fBParameters\fP
  187. .RS 4
  188. \fIdept\fP ICAO 4-letter Airport Identifier
  189. .br
  190. \fIdest\fP ICAO 4-letter Airport Identifier
  191. .RE
  192. .PP
  193. \fBReturns\fP
  194. .RS 4
  195. Nautical Miles From Departure to Destination
  196. .RE
  197. .PP
  198. .SS "QVector< QVector< double > > ACalc::intermediatePointsOnGreatCircle (double lat1, double lon1, double lat2, double lon2, int tblk)"
  199. .PP
  200. 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\&.
  201. .PP
  202. \fBParameters\fP
  203. .RS 4
  204. \fIlat1\fP Location Latitude in degrees -90:90 ;S(-) N(+)
  205. .br
  206. \fIlon1\fP Location Longitude in degrees -180:180 W(-) E(+)
  207. .br
  208. \fIlat2\fP Location Latitude in degrees -90:90 ;S(-) N(+)
  209. .br
  210. \fIlon2\fP Location Longitude in degrees -180:180 W(-) E(+)
  211. .br
  212. \fItblk\fP Total Blocktime in minutes
  213. .RE
  214. .PP
  215. \fBReturns\fP
  216. .RS 4
  217. coordinates {lat,lon} along the Great Circle Track
  218. .RE
  219. .PP
  220. .SS "QString ACalc::minutesToString (QString block_minutes)\fC [inline]\fP"
  221. .PP
  222. ACalc::minutes_to_string Converts database time to String Time\&.
  223. .PP
  224. \fBParameters\fP
  225. .RS 4
  226. \fIblockminutes\fP from database
  227. .RE
  228. .PP
  229. \fBReturns\fP
  230. .RS 4
  231. String hh:mm
  232. .RE
  233. .PP
  234. .SS "int ACalc::QTimeToMinutes (QTime time)\fC [inline]\fP"
  235. .PP
  236. ACalc::time_to_minutes converts QTime to int minutes\&.
  237. .PP
  238. \fBParameters\fP
  239. .RS 4
  240. \fItime\fP QTime
  241. .RE
  242. .PP
  243. \fBReturns\fP
  244. .RS 4
  245. int time as number of minutes
  246. .RE
  247. .PP
  248. .SS "double ACalc::radToDeg (double rad)\fC [inline]\fP"
  249. .PP
  250. radToDeg Converts radians to degrees
  251. .PP
  252. \fBParameters\fP
  253. .RS 4
  254. \fIrad\fP
  255. .RE
  256. .PP
  257. \fBReturns\fP
  258. .RS 4
  259. degrees
  260. .RE
  261. .PP
  262. .SS "double ACalc::radToNauticalMiles (double rad)\fC [inline]\fP"
  263. .PP
  264. radToNauticalMiles Convert Radians to nautical miles
  265. .PP
  266. \fBParameters\fP
  267. .RS 4
  268. \fIrad\fP
  269. .RE
  270. .PP
  271. \fBReturns\fP
  272. .RS 4
  273. nautical miles
  274. .RE
  275. .PP
  276. .SS "double ACalc::solarElevation (QDateTime utc_time_point, double lat, double lon)"
  277. .PP
  278. 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
  279. .PP
  280. 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++\&.
  281. .PP
  282. Darin C\&. Koblock: https://www.mathworks.com/matlabcentral/profile/authors/1284781 Kevin Godden: https://www.ridgesolutions.ie/index.php/about-us/
  283. .PP
  284. \fBParameters\fP
  285. .RS 4
  286. \fIutc_time_point\fP - QDateTime (UTC) for which the elevation is Calculated
  287. .br
  288. \fIlat\fP - Location Latitude in degrees -90:90 ;S(-) N(+)
  289. .br
  290. \fIlon\fP - Location Longitude in degrees -180:180 W(-) E(+)
  291. .RE
  292. .PP
  293. \fBReturns\fP
  294. .RS 4
  295. elevation - double of solar elevation in degrees\&.
  296. .RE
  297. .PP
  298. .SS "int ACalc::stringToMinutes (QString timestring)\fC [inline]\fP"
  299. .PP
  300. ACalc::string_to_minutes Converts String Time to String Number of Minutes\&.
  301. .PP
  302. \fBParameters\fP
  303. .RS 4
  304. \fItimestring\fP 'hh:mm'
  305. .RE
  306. .PP
  307. \fBReturns\fP
  308. .RS 4
  309. String number of minutes
  310. .RE
  311. .PP
  312. .SS "void ACalc::updateAutoTimes (int acft_id)"
  313. .PP
  314. \fBACalc::updateAutoTimes\fP When the details of an aircraft are changed, this function recalculates deductable times for this aircraft and updates the database accordingly\&.
  315. .PP
  316. \fBParameters\fP
  317. .RS 4
  318. \fIacft\fP An aircraft object\&.
  319. .RE
  320. .PP
  321. \fBReturns\fP
  322. .RS 4
  323. .RE
  324. .PP
  325. .SH "Author"
  326. .PP
  327. Generated automatically by Doxygen for openPilotLog from the source code\&.