@mxtommy/kip 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (315) hide show
  1. package/.angulardoc.json +3 -3
  2. package/CHANGELOG.md +145 -124
  3. package/CONTRIBUTORS.md +16 -13
  4. package/README.md +102 -101
  5. package/angular.json +162 -152
  6. package/karma.conf.js +31 -31
  7. package/package.json +87 -80
  8. package/public/3rdpartylicenses.txt +317 -62
  9. package/public/assets/NoSleep.min.js +1 -1
  10. package/public/assets/fontawesome6/css/all.min.css +6 -0
  11. package/public/assets/fontawesome6/webfonts/fa-brands-400.ttf +0 -0
  12. package/public/assets/fontawesome6/webfonts/fa-brands-400.woff2 +0 -0
  13. package/public/assets/fontawesome6/webfonts/fa-regular-400.ttf +0 -0
  14. package/public/assets/fontawesome6/webfonts/fa-regular-400.woff2 +0 -0
  15. package/public/assets/fontawesome6/webfonts/fa-solid-900.ttf +0 -0
  16. package/public/assets/fontawesome6/webfonts/fa-solid-900.woff2 +0 -0
  17. package/public/assets/fontawesome6/webfonts/fa-v4compatibility.ttf +0 -0
  18. package/public/assets/fontawesome6/webfonts/fa-v4compatibility.woff2 +0 -0
  19. package/public/assets/icon-192x192.png +0 -0
  20. package/public/assets/icon-256x256.png +0 -0
  21. package/public/assets/icon-384x384.png +0 -0
  22. package/public/assets/icon-512x512.png +0 -0
  23. package/public/assets/steelseries-min.js +25 -25
  24. package/public/assets/steelseries-min.js.map +8 -8
  25. package/public/assets/steelseries.js +15834 -15834
  26. package/public/assets/svg-autopilot-inkscape-plain.svg +983 -983
  27. package/public/assets/svg-wind-inkscape.svg +1358 -1358
  28. package/public/assets/tween.js +381 -381
  29. package/public/index.html +19 -20
  30. package/public/main-es2018.98175eb4c61ccaf7eb17.js +1 -0
  31. package/public/main-es5.98175eb4c61ccaf7eb17.js +1 -0
  32. package/public/manifest.json +33 -0
  33. package/public/polyfills-es2018.3a61665863c173cd6ba3.js +1 -0
  34. package/public/polyfills-es5.44827ae4ff4e41de51fb.js +1 -0
  35. package/public/runtime-es2018.baedb88c6d2abacae2b8.js +1 -0
  36. package/public/runtime-es5.baedb88c6d2abacae2b8.js +1 -0
  37. package/public/styles.b92ae2c466c89712209d.css +5 -0
  38. package/src/app/alarm-menu/alarm-menu.component.html +55 -55
  39. package/src/app/alarm-menu/alarm-menu.component.scss +52 -53
  40. package/src/app/alarm-menu/alarm-menu.component.spec.ts +25 -25
  41. package/src/app/alarm-menu/alarm-menu.component.ts +186 -186
  42. package/src/app/app-help/app-help.component.css +4 -4
  43. package/src/app/app-help/app-help.component.html +135 -121
  44. package/src/app/app-help/app-help.component.ts +45 -45
  45. package/src/app/app.component.css +39 -39
  46. package/src/app/app.component.html +93 -93
  47. package/src/app/app.component.scss +79 -79
  48. package/src/app/app.component.spec.ts +32 -32
  49. package/src/app/app.component.ts +191 -192
  50. package/src/app/app.module.ts +200 -200
  51. package/src/app/config.blank.const.ts +51 -51
  52. package/src/app/config.blank.notification.const.ts +19 -19
  53. package/src/app/config.blank.units.const.ts +23 -23
  54. package/src/app/config.demo.const.ts +383 -382
  55. package/src/app/data-browser/data-browser.component.css +29 -29
  56. package/src/app/data-browser/data-browser.component.html +44 -44
  57. package/src/app/data-browser/data-browser.component.spec.ts +25 -25
  58. package/src/app/data-browser/data-browser.component.ts +91 -91
  59. package/src/app/data-browser-row/data-browser-row-unit-modal.html +17 -17
  60. package/src/app/data-browser-row/data-browser-row.component.css +9 -9
  61. package/src/app/data-browser-row/data-browser-row.component.html +4 -4
  62. package/src/app/data-browser-row/data-browser-row.component.ts +78 -78
  63. package/src/app/data-set.service.ts +273 -273
  64. package/src/app/dynamic-widget.directive.ts +11 -11
  65. package/src/app/gauge-steel/gauge-steel.component.css +4 -4
  66. package/src/app/gauge-steel/gauge-steel.component.html +4 -4
  67. package/src/app/gauge-steel/gauge-steel.component.spec.ts +25 -25
  68. package/src/app/gauge-steel/gauge-steel.component.ts +282 -282
  69. package/src/app/gauges-module/base-gauge.ts +301 -0
  70. package/src/app/gauges-module/gauges.module.ts +17 -0
  71. package/src/app/gauges-module/linear-gauge.ts +50 -0
  72. package/src/app/gauges-module/radial-gauge.ts +48 -0
  73. package/src/app/layout-split/layout-split.component.html +30 -30
  74. package/src/app/layout-split/layout-split.component.scss +33 -33
  75. package/src/app/layout-split/layout-split.component.spec.ts +25 -25
  76. package/src/app/layout-split/layout-split.component.ts +59 -59
  77. package/src/app/layout-splits.service.ts +284 -284
  78. package/src/app/modal-path-selector/modal-path-selector.component.html +62 -62
  79. package/src/app/modal-path-selector/modal-path-selector.component.scss +39 -39
  80. package/src/app/modal-path-selector/modal-path-selector.component.spec.ts +25 -25
  81. package/src/app/modal-path-selector/modal-path-selector.component.ts +132 -132
  82. package/src/app/modal-widget/modal-widget.component.css +32 -32
  83. package/src/app/modal-widget/modal-widget.component.html +341 -334
  84. package/src/app/modal-widget/modal-widget.component.spec.ts +25 -25
  85. package/src/app/modal-widget/modal-widget.component.ts +84 -84
  86. package/src/app/notifications.service.ts +392 -387
  87. package/src/app/object-keys.pipe.spec.ts +8 -8
  88. package/src/app/object-keys.pipe.ts +13 -13
  89. package/src/app/reset-config/reset-config.component.html +3 -3
  90. package/src/app/reset-config/reset-config.component.spec.ts +25 -25
  91. package/src/app/reset-config/reset-config.component.ts +31 -31
  92. package/src/app/root-display/root-display.component.html +4 -4
  93. package/src/app/root-display/root-display.component.spec.ts +25 -25
  94. package/src/app/root-display/root-display.component.ts +57 -57
  95. package/src/app/safe.pipe.ts +15 -15
  96. package/src/app/settings/settings.component.css +9 -9
  97. package/src/app/settings/settings.component.html +25 -25
  98. package/src/app/settings/settings.component.spec.ts +25 -25
  99. package/src/app/settings/settings.component.ts +22 -22
  100. package/src/app/settings-config/settings-config.component.css +38 -38
  101. package/src/app/settings-config/settings-config.component.spec.ts +25 -25
  102. package/src/app/settings-config/settings-config.component.ts +161 -161
  103. package/src/app/settings-datasets/settings-datasets.component.html +43 -43
  104. package/src/app/settings-datasets/settings-datasets.component.scss +39 -39
  105. package/src/app/settings-datasets/settings-datasets.component.spec.ts +25 -25
  106. package/src/app/settings-datasets/settings-datasets.component.ts +98 -98
  107. package/src/app/settings-datasets/settings-datasets.modal.html +54 -54
  108. package/src/app/settings-notifications/settings-notifications.component.html +65 -65
  109. package/src/app/settings-notifications/settings-notifications.component.spec.ts +25 -25
  110. package/src/app/settings-notifications/settings-notifications.component.ts +29 -29
  111. package/src/app/settings-signalk/settings-signalk.component.html +8 -8
  112. package/src/app/settings-signalk/settings-signalk.component.spec.ts +25 -25
  113. package/src/app/settings-signalk/settings-signalk.component.ts +6 -17
  114. package/src/app/settings-units/settings-units.component.css +4 -4
  115. package/src/app/settings-units/settings-units.component.html +19 -19
  116. package/src/app/settings-units/settings-units.component.spec.ts +25 -25
  117. package/src/app/settings-units/settings-units.component.ts +62 -62
  118. package/src/app/settings-zones/settings-zones.component.css +21 -21
  119. package/src/app/settings-zones/settings-zones.component.html +70 -70
  120. package/src/app/settings-zones/settings-zones.modal.html +38 -38
  121. package/src/app/signalk-connection.service.ts +344 -344
  122. package/src/app/signalk-delta.service.spec.ts +15 -15
  123. package/src/app/signalk-delta.service.ts +97 -97
  124. package/src/app/signalk-full.service.ts +99 -99
  125. package/src/app/signalk-interfaces.ts +129 -129
  126. package/src/app/signalk-requests.service.spec.ts +12 -12
  127. package/src/app/signalk-requests.service.ts +180 -180
  128. package/src/app/svg-autopilot/svg-autopilot.component.html +1036 -1036
  129. package/src/app/svg-autopilot/svg-autopilot.component.spec.ts +25 -25
  130. package/src/app/svg-autopilot/svg-autopilot.component.ts +174 -174
  131. package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.html +119 -119
  132. package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.spec.ts +25 -25
  133. package/src/app/svg-simple-linear-gauge/svg-simple-linear-gauge.component.ts +49 -49
  134. package/src/app/svg-wind/svg-wind.component.html +969 -969
  135. package/src/app/svg-wind/svg-wind.component.scss +76 -76
  136. package/src/app/svg-wind/svg-wind.component.spec.ts +25 -25
  137. package/src/app/svg-wind/svg-wind.component.ts +280 -280
  138. package/src/app/unit-window/unit-window.component.css +37 -37
  139. package/src/app/unit-window/unit-window.component.html +8 -8
  140. package/src/app/unit-window/unit-window.component.spec.ts +25 -25
  141. package/src/app/unit-window/unit-window.component.ts +134 -134
  142. package/src/app/unit-window/unit-window.modal.html +24 -24
  143. package/src/app/units.service.ts +300 -300
  144. package/src/app/widget-autopilot/widget-autopilot.component.html +78 -85
  145. package/src/app/widget-autopilot/widget-autopilot.component.scss +191 -191
  146. package/src/app/widget-autopilot/widget-autopilot.component.spec.ts +25 -25
  147. package/src/app/widget-autopilot/widget-autopilot.component.ts +774 -781
  148. package/src/app/widget-blank/widget-blank.component.scss +21 -22
  149. package/src/app/widget-blank/widget-blank.component.spec.ts +25 -25
  150. package/src/app/widget-blank/widget-blank.component.ts +17 -17
  151. package/src/app/widget-gauge/widget-gauge.component.css +25 -25
  152. package/src/app/widget-gauge/widget-gauge.component.html +29 -29
  153. package/src/app/widget-gauge/widget-gauge.component.spec.ts +25 -25
  154. package/src/app/widget-gauge/widget-gauge.component.ts +120 -120
  155. package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.html +126 -126
  156. package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.scss +94 -93
  157. package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.spec.ts +25 -25
  158. package/src/app/widget-gauge-ng-linear/widget-gauge-ng-linear.component.ts +424 -424
  159. package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.html +122 -122
  160. package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.scss +69 -69
  161. package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.spec.ts +25 -25
  162. package/src/app/widget-gauge-ng-radial/widget-gauge-ng-radial.component.ts +553 -553
  163. package/src/app/widget-historical/widget-historical.component.html +14 -14
  164. package/src/app/widget-historical/widget-historical.component.spec.ts +25 -25
  165. package/src/app/widget-historical/widget-historical.component.ts +306 -307
  166. package/src/app/widget-iframe/widget-iframe.component.css +11 -11
  167. package/src/app/widget-iframe/widget-iframe.component.html +21 -21
  168. package/src/app/widget-iframe/widget-iframe.component.spec.ts +25 -25
  169. package/src/app/widget-iframe/widget-iframe.component.ts +63 -63
  170. package/src/app/widget-list.service.ts +135 -135
  171. package/src/app/widget-manager.service.ts +141 -140
  172. package/src/app/widget-numeric/widget-numeric.component.html +1 -1
  173. package/src/app/widget-numeric/widget-numeric.component.scss +3 -3
  174. package/src/app/widget-numeric/widget-numeric.component.spec.ts +25 -25
  175. package/src/app/widget-simple-linear/widget-simple-linear.component.html +28 -28
  176. package/src/app/widget-simple-linear/widget-simple-linear.component.scss +64 -64
  177. package/src/app/widget-simple-linear/widget-simple-linear.component.spec.ts +25 -25
  178. package/src/app/widget-simple-linear/widget-simple-linear.component.ts +199 -199
  179. package/src/app/widget-state/widget-state.component.html +27 -27
  180. package/src/app/widget-state/widget-state.component.scss +68 -68
  181. package/src/app/widget-state/widget-state.component.spec.ts +25 -25
  182. package/src/app/widget-state/widget-state.component.ts +178 -178
  183. package/src/app/widget-switch/widget-switch.component.css +69 -69
  184. package/src/app/widget-switch/widget-switch.component.html +17 -17
  185. package/src/app/widget-switch/widget-switch.component.spec.ts +25 -25
  186. package/src/app/widget-switch/widget-switch.component.ts +134 -134
  187. package/src/app/widget-text-generic/widget-text-generic.component.html +9 -9
  188. package/src/app/widget-text-generic/widget-text-generic.component.spec.ts +25 -25
  189. package/src/app/widget-tutorial/widget-tutorial.component.html +34 -34
  190. package/src/app/widget-tutorial/widget-tutorial.component.spec.ts +25 -25
  191. package/src/app/widget-tutorial/widget-tutorial.component.ts +18 -18
  192. package/src/app/widget-unknown/widget-unknown.component.spec.ts +25 -25
  193. package/src/app/widget-wind/widget-wind.component.css +23 -23
  194. package/src/app/widget-wind/widget-wind.component.html +20 -20
  195. package/src/app/widget-wind/widget-wind.component.spec.ts +25 -25
  196. package/src/app/widget-wind/widget-wind.component.ts +369 -369
  197. package/src/assets/NoSleep.min.js +1 -1
  198. package/src/assets/fontawesome6/css/all.min.css +6 -0
  199. package/src/assets/fontawesome6/webfonts/fa-brands-400.ttf +0 -0
  200. package/src/assets/fontawesome6/webfonts/fa-brands-400.woff2 +0 -0
  201. package/src/assets/fontawesome6/webfonts/fa-regular-400.ttf +0 -0
  202. package/src/assets/fontawesome6/webfonts/fa-regular-400.woff2 +0 -0
  203. package/src/assets/fontawesome6/webfonts/fa-solid-900.ttf +0 -0
  204. package/src/assets/fontawesome6/webfonts/fa-solid-900.woff2 +0 -0
  205. package/src/assets/fontawesome6/webfonts/fa-v4compatibility.ttf +0 -0
  206. package/src/assets/fontawesome6/webfonts/fa-v4compatibility.woff2 +0 -0
  207. package/src/assets/icon-192x192.png +0 -0
  208. package/src/assets/icon-256x256.png +0 -0
  209. package/src/assets/icon-384x384.png +0 -0
  210. package/src/assets/icon-512x512.png +0 -0
  211. package/src/assets/steelseries-min.js +25 -25
  212. package/src/assets/steelseries-min.js.map +8 -8
  213. package/src/assets/steelseries.js +15834 -15834
  214. package/src/assets/svg-autopilot-inkscape-plain.svg +983 -983
  215. package/src/assets/svg-wind-inkscape.svg +1358 -1358
  216. package/src/assets/tween.js +381 -381
  217. package/src/index.html +20 -20
  218. package/src/main.ts +11 -11
  219. package/src/manifest.json +33 -0
  220. package/src/polyfills.ts +80 -76
  221. package/src/styles.scss +11 -11
  222. package/src/themes/darkBlueTheme.scss +117 -116
  223. package/src/themes/defaultTheme.scss +50 -49
  224. package/src/themes/highContrastTheme.scss +47 -46
  225. package/src/themes/modernTheme.scss +143 -142
  226. package/src/themes/nightMode.scss +185 -184
  227. package/src/themes/platypusTheme.scss +80 -79
  228. package/src/themes/signalkTheme.scss +112 -111
  229. package/src/tsconfig.app.json +15 -15
  230. package/src/tsconfig.spec.json +20 -20
  231. package/tsconfig.json +23 -23
  232. package/tslint.json +143 -143
  233. package/public/assets/font-awesome/HELP-US-OUT.txt +0 -7
  234. package/public/assets/font-awesome/css/font-awesome.css +0 -2337
  235. package/public/assets/font-awesome/css/font-awesome.min.css +0 -4
  236. package/public/assets/font-awesome/desktop.ini +0 -4
  237. package/public/assets/font-awesome/fonts/FontAwesome.otf +0 -0
  238. package/public/assets/font-awesome/fonts/fontawesome-webfont.eot +0 -0
  239. package/public/assets/font-awesome/fonts/fontawesome-webfont.svg +0 -2671
  240. package/public/assets/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
  241. package/public/assets/font-awesome/fonts/fontawesome-webfont.woff +0 -0
  242. package/public/assets/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
  243. package/public/assets/font-awesome/less/animated.less +0 -34
  244. package/public/assets/font-awesome/less/bordered-pulled.less +0 -25
  245. package/public/assets/font-awesome/less/core.less +0 -12
  246. package/public/assets/font-awesome/less/fixed-width.less +0 -6
  247. package/public/assets/font-awesome/less/font-awesome.less +0 -18
  248. package/public/assets/font-awesome/less/icons.less +0 -789
  249. package/public/assets/font-awesome/less/larger.less +0 -13
  250. package/public/assets/font-awesome/less/list.less +0 -19
  251. package/public/assets/font-awesome/less/mixins.less +0 -60
  252. package/public/assets/font-awesome/less/path.less +0 -15
  253. package/public/assets/font-awesome/less/rotated-flipped.less +0 -20
  254. package/public/assets/font-awesome/less/screen-reader.less +0 -5
  255. package/public/assets/font-awesome/less/stacked.less +0 -20
  256. package/public/assets/font-awesome/less/variables.less +0 -800
  257. package/public/assets/font-awesome/scss/_animated.scss +0 -34
  258. package/public/assets/font-awesome/scss/_bordered-pulled.scss +0 -25
  259. package/public/assets/font-awesome/scss/_core.scss +0 -12
  260. package/public/assets/font-awesome/scss/_fixed-width.scss +0 -6
  261. package/public/assets/font-awesome/scss/_icons.scss +0 -789
  262. package/public/assets/font-awesome/scss/_larger.scss +0 -13
  263. package/public/assets/font-awesome/scss/_list.scss +0 -19
  264. package/public/assets/font-awesome/scss/_mixins.scss +0 -60
  265. package/public/assets/font-awesome/scss/_path.scss +0 -15
  266. package/public/assets/font-awesome/scss/_rotated-flipped.scss +0 -20
  267. package/public/assets/font-awesome/scss/_screen-reader.scss +0 -5
  268. package/public/assets/font-awesome/scss/_stacked.scss +0 -20
  269. package/public/assets/font-awesome/scss/_variables.scss +0 -800
  270. package/public/assets/font-awesome/scss/font-awesome.scss +0 -18
  271. package/public/main-es2018.625fb92c9cbb6a4131de.js +0 -1
  272. package/public/main-es5.625fb92c9cbb6a4131de.js +0 -1
  273. package/public/polyfills-es2018.713f95af1f028e444854.js +0 -1
  274. package/public/polyfills-es5.c78877945523541d2597.js +0 -1
  275. package/public/runtime-es2018.a4dadbc03350107420a4.js +0 -1
  276. package/public/runtime-es5.a4dadbc03350107420a4.js +0 -1
  277. package/public/styles.71bb0d04cad96b5efbe1.css +0 -19
  278. package/src/assets/font-awesome/HELP-US-OUT.txt +0 -7
  279. package/src/assets/font-awesome/css/font-awesome.css +0 -2337
  280. package/src/assets/font-awesome/css/font-awesome.min.css +0 -4
  281. package/src/assets/font-awesome/desktop.ini +0 -4
  282. package/src/assets/font-awesome/fonts/FontAwesome.otf +0 -0
  283. package/src/assets/font-awesome/fonts/fontawesome-webfont.eot +0 -0
  284. package/src/assets/font-awesome/fonts/fontawesome-webfont.svg +0 -2671
  285. package/src/assets/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
  286. package/src/assets/font-awesome/fonts/fontawesome-webfont.woff +0 -0
  287. package/src/assets/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
  288. package/src/assets/font-awesome/less/animated.less +0 -34
  289. package/src/assets/font-awesome/less/bordered-pulled.less +0 -25
  290. package/src/assets/font-awesome/less/core.less +0 -12
  291. package/src/assets/font-awesome/less/fixed-width.less +0 -6
  292. package/src/assets/font-awesome/less/font-awesome.less +0 -18
  293. package/src/assets/font-awesome/less/icons.less +0 -789
  294. package/src/assets/font-awesome/less/larger.less +0 -13
  295. package/src/assets/font-awesome/less/list.less +0 -19
  296. package/src/assets/font-awesome/less/mixins.less +0 -60
  297. package/src/assets/font-awesome/less/path.less +0 -15
  298. package/src/assets/font-awesome/less/rotated-flipped.less +0 -20
  299. package/src/assets/font-awesome/less/screen-reader.less +0 -5
  300. package/src/assets/font-awesome/less/stacked.less +0 -20
  301. package/src/assets/font-awesome/less/variables.less +0 -800
  302. package/src/assets/font-awesome/scss/_animated.scss +0 -34
  303. package/src/assets/font-awesome/scss/_bordered-pulled.scss +0 -25
  304. package/src/assets/font-awesome/scss/_core.scss +0 -12
  305. package/src/assets/font-awesome/scss/_fixed-width.scss +0 -6
  306. package/src/assets/font-awesome/scss/_icons.scss +0 -789
  307. package/src/assets/font-awesome/scss/_larger.scss +0 -13
  308. package/src/assets/font-awesome/scss/_list.scss +0 -19
  309. package/src/assets/font-awesome/scss/_mixins.scss +0 -60
  310. package/src/assets/font-awesome/scss/_path.scss +0 -15
  311. package/src/assets/font-awesome/scss/_rotated-flipped.scss +0 -20
  312. package/src/assets/font-awesome/scss/_screen-reader.scss +0 -5
  313. package/src/assets/font-awesome/scss/_stacked.scss +0 -20
  314. package/src/assets/font-awesome/scss/_variables.scss +0 -800
  315. package/src/assets/font-awesome/scss/font-awesome.scss +0 -18
@@ -1,300 +1,300 @@
1
- import { Injectable } from '@angular/core';
2
- import * as Qty from 'js-quantities';
3
-
4
- import { AppSettingsService } from './app-settings.service';
5
- import { Subscription } from 'rxjs';
6
-
7
- /**
8
- * Group of Kip units array
9
- */
10
- export interface IUnitGroup {
11
- group: string;
12
- units: IUnit[];
13
- }[]
14
-
15
- /**
16
- * Individual Kip units system measures definition
17
- */
18
- export interface IUnit {
19
- measure: string;
20
- description: string;
21
- }
22
-
23
- /**
24
- * Interface for defaults Units per unit Groups to be applied
25
- */
26
- export interface IUnitDefaults {
27
- [key: string]: string;
28
- }
29
-
30
- @Injectable()
31
-
32
- export class UnitsService {
33
-
34
-
35
-
36
- defaultUnits: IUnitDefaults;
37
- defaultUnitsSub: Subscription;
38
-
39
- /**
40
- * Definition of available Kip units to be used for conversion.
41
- * Measure property has to match one Unit Conversion Function for proper operation.
42
- * Description is human readable property.
43
- */
44
- conversionList: IUnitGroup[] = [
45
- { group: 'Unitless', units: [
46
- { measure: 'unitless', description: "As-Is numeric value" }
47
- ] },
48
- { group: 'Speed', units: [
49
- { measure: 'knots', description: "Knots - Nautical miles per hour"},
50
- { measure: 'kph', description: "kph - Kilometers per hour"},
51
- { measure: 'mph', description: "mph - Miles per hour"},
52
- { measure: 'm/s', description: "m/s - Meters per second (default)"}
53
- ] },
54
- { group: 'Flow', units: [
55
- { measure: 'm3/s', description: "Cubic meters per second (default)"},
56
- { measure: 'l/min', description: "Litters per minute"},
57
- { measure: 'l/h', description: "Litters per hour"},
58
- { measure: 'g/min', description: "Gallons per minute"},
59
- { measure: 'g/h', description: "Gallons per hour"}
60
- ] },
61
- { group: 'Temperature', units: [
62
- { measure: 'K', description: "Kelvin (default)"},
63
- { measure: 'celsius', description: "Celsius"},
64
- { measure: 'fahrenheit', description: "Fahrenheit"}
65
- ] },
66
- { group: 'Length', units: [
67
- { measure: 'm', description: "Metres (default)"},
68
- { measure: 'fathom', description: "Fathoms"},
69
- { measure: 'feet', description: "Feets"},
70
- { measure: 'km', description: "Kilometers"},
71
- { measure: 'nm', description: "Nautical Miles"},
72
- { measure: 'mi', description: "Miles"},
73
- ] },
74
- { group: 'Volume', units: [
75
- { measure: 'liter', description: "Liters (default)"},
76
- { measure: 'm3', description: "Cubic Meters"},
77
- { measure: 'gallon', description: "Gallons"},
78
- ] },
79
- { group: 'Current', units: [
80
- { measure: 'A', description: "Amperes"},
81
- { measure: 'mA', description: "Milliamperes"}
82
- ] },
83
- { group: 'Potential', units: [
84
- { measure: 'V', description: "Volts"},
85
- { measure: 'mV', description: "Millivolts"}
86
- ] },
87
- { group: 'Charge', units: [ { measure: 'C', description: "Current"} ] },
88
- { group: 'Power', units: [
89
- { measure: 'W', description: "Watts"},
90
- { measure: 'mW', description: "Milliwatts"},
91
- ] },
92
- { group: 'Energy', units: [ { measure: 'J', description: "Joules"} ] },
93
- { group: 'Pressure', units: [
94
- { measure: 'Pa', description: "Pascal (default)" },
95
- { measure: 'bar', description: "Bars" },
96
- { measure: 'psi', description: "psi" },
97
- { measure: 'mmHg', description: "mmHg" },
98
- { measure: 'inHg', description: "inHg" },
99
- { measure: 'hPa', description: "hPa" },
100
- { measure: 'mbar', description: "mbar" },
101
- ] },
102
- { group: 'Density', units: [ { measure: 'kg/m3', description: "Air density - kg/cubic meter"} ] },
103
- { group: 'Time', units: [
104
- { measure: 's', description: "Seconds (default)" },
105
- { measure: 'Minutes', description: "Minutes" },
106
- { measure: 'Hours', description: "Hours" },
107
- { measure: 'Days', description: "Days" },
108
- { measure: 'HH:MM:SS', description: "Hours:Minute:seconds"}
109
- ] },
110
- { group: 'Angular Velocity', units: [
111
- { measure: 'rad/s', description: "Radians per second" },
112
- { measure: 'deg/s', description: "Degrees per second" },
113
- { measure: 'deg/min', description: "Degrees per minute" },
114
- ] },
115
- { group: 'Angle', units: [
116
- { measure: 'rad', description: "Radians" },
117
- { measure: 'deg', description: "Degrees" },
118
- { measure: 'grad', description: "Gradians" },
119
- ] },
120
- { group: 'Frequency', units: [
121
- { measure: 'rpm', description: "RPM - Rotations per minute" },
122
- { measure: 'Hz', description: "Hz - Hertz (default)" },
123
- { measure: 'KHz', description: "KHz - KiloHertz" },
124
- { measure: 'MHz', description: "MHz - MegaHertz" },
125
- { measure: 'GHz', description: "GHz - GigaHertz" },
126
- ] },
127
- { group: 'Ratio', units: [
128
- { measure: 'percent', description: "% - Percentage value (value multiplied by 100)" },
129
- { measure: 'percentraw', description: "% - Percentage value (value unchanged)" },
130
- { measure: 'ratio', description: "Ratio 0-1 (value multiplied by 100)" }
131
- ] },
132
- { group: 'Position', units: [
133
- { measure: 'latitudeMin', description: "Latitude in minutes" },
134
- { measure: 'latitudeSec', description: "Latitude in seconds" },
135
- { measure: 'longitudeMin', description: "Longitude in minutes" },
136
- { measure: 'longitudeSec', description: "Longitude in seconds" },
137
- ] },
138
- ];
139
-
140
-
141
- constructor( private AppSettingsService: AppSettingsService,
142
- ) {
143
- this.defaultUnitsSub = this.AppSettingsService.getDefaultUnitsAsO().subscribe(
144
- newDefaults => {
145
- this.defaultUnits = newDefaults;
146
- }
147
- );
148
- // console.log(Qty.getKinds());
149
- // console.log(Qty.getUnits());
150
- // console.log(Qty.getAliases('naut-mile'));
151
- //build list for others.
152
- /* Object.keys(this.conversions).forEach(group => {
153
- this.conversionList[group] = [];
154
- Object.keys(this.conversions[group]).forEach(unit => {
155
- this.conversionList[group].push(unit);
156
- });
157
- }); */
158
- }
159
-
160
-
161
- unitConversionFunctions = {
162
- 'unitless': function(v) { return v; },
163
- // speed
164
- 'knots': Qty.swiftConverter("m/s", "kn"),
165
- 'kph': Qty.swiftConverter("m/s", "kph"),
166
- 'm/s': function(v) { return v; },
167
- 'mph': Qty.swiftConverter("m/s", "mph"),
168
- // volume
169
- "liter": Qty.swiftConverter('m^3', 'liter'),
170
- "gallon": Qty.swiftConverter('m^3', 'gallon'),
171
- "m3": function(v) { return v; },
172
- // flow
173
- 'm3/s': function(v) { return v; },
174
- 'l/min': Qty.swiftConverter("m^3/s", "liter/minute"),
175
- 'l/h': Qty.swiftConverter("m^3/s", "liter/hour"),
176
- 'g/min': Qty.swiftConverter("m^3/s", "gallon/minute"),
177
- 'g/h': Qty.swiftConverter("m^3/s", "gallon/hour"),
178
- // temp
179
- "K": function(v) { return v; },
180
- "celsius": Qty.swiftConverter("tempK", "tempC"),
181
- "fahrenheit": Qty.swiftConverter("tempK", "tempF"),
182
- // length
183
- "m": function(v) { return v; },
184
- "fathom": Qty.swiftConverter('m', 'fathom'),
185
- "feet": Qty.swiftConverter('m', 'foot'),
186
- "km": Qty.swiftConverter('m', 'km'),
187
- "nm": Qty.swiftConverter('m', 'nmi'),
188
- "mi": Qty.swiftConverter('m', 'mi'),
189
- // Potential
190
- "V": function(v) { return v; },
191
- "mV": function(v) { return v*1000; },
192
- // Current
193
- "A": function(v) { return v; },
194
- "mA": function(v) { return v*1000; },
195
- // charge
196
- "C": function(v) { return v; },
197
- // Power
198
- "W": function(v) { return v; },
199
- "mW": function(v) { return v*1000; },
200
- // Energy
201
- "J": function(v) { return v; },
202
- // pressure
203
- "Pa": function(v) { return v; },
204
- "bar": Qty.swiftConverter('Pa', 'bar'),
205
- "psi": Qty.swiftConverter('Pa', 'psi'),
206
- "mmHg": Qty.swiftConverter('Pa', 'mmHg'),
207
- "inHg": Qty.swiftConverter('Pa', 'inHg'),
208
- "hPa": Qty.swiftConverter('Pa', 'hPa'),
209
- "mbar": Qty.swiftConverter('Pa', 'millibar'),
210
- // Density - Description: Current outside air density
211
- "kg/m3": function(v) { return v; },
212
- // Time
213
- "s": function(v) { return v; },
214
- "Minutes": Qty.swiftConverter('s', 'minutes'),
215
- "Hours": Qty.swiftConverter('s', 'hours'),
216
- "Days": Qty.swiftConverter('s', 'days'),
217
- "HH:MM:SS": function(v) {
218
- v = parseInt(v, 10);
219
- if (v < 0) { v = v *-1} // always positive
220
-
221
- var h = Math.floor(v / 3600);
222
- var m = Math.floor(v % 3600 / 60);
223
- var s = Math.floor(v % 3600 % 60);
224
- return ('0' + h).slice(-2) + ":" + ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);
225
- },
226
- // angularVelocity
227
- "rad/s": function(v) { return v; },
228
- "deg/s": Qty.swiftConverter('rad/s', 'deg/s'),
229
- "deg/min": Qty.swiftConverter('rad/s', 'deg/min'),
230
- // frequency
231
- "rpm": function(v) { return v*60; },
232
- "Hz": function(v) { return v; },
233
- "KHz": function(v) { return v/1000; },
234
- "MHz": function(v) { return v/1000000; },
235
- "GHz": function(v) { return v/1000000000; },
236
- // angle
237
- "rad": function(v) { return v; },
238
- "deg": Qty.swiftConverter('rad', 'deg'),
239
- "grad": Qty.swiftConverter('rad', 'grad'),
240
- // ratio
241
- 'percent': function(v) { return (v * 100) + '%' },
242
- 'percentraw': function(v) { return v + '%' },
243
- 'ratio': function(v) { return v * 100 },
244
- // lat/lon
245
- 'latitudeMin': function(v) {
246
- v = Qty(v, 'rad').to('deg').scalar ;
247
- let degree = Math.trunc(v);
248
- let s = 'N';
249
- if (v < 0) { s = 'S'; degree = degree * -1 }
250
- let r = (v % 1) * 60; // decimal part of input, * 60 to get minutes
251
- return degree + '° ' + r.toFixed(2).padStart(5, '0') + '\' ' + s;
252
- },
253
- 'latitudeSec': function(v) {
254
- v = Qty(v, 'rad').to('deg').scalar ;
255
- let degree = Math.trunc(v);
256
- let s = 'N';
257
- if (v < 0) { s = 'S'; degree = degree * -1 }
258
- let r = (v % 1) * 60; // decimal part of input, * 60 to get minutes
259
- let minutes = Math.trunc(r);
260
- let seconds = (r % 1) * 60;
261
-
262
- return degree + '° ' + minutes + '\' ' + seconds.toFixed(2).padStart(5, '0') + '" ' + s;
263
- },
264
- 'longitudeMin': function(v) {
265
- v = Qty(v, 'rad').to('deg').scalar ;
266
- let degree = Math.trunc(v);
267
- let s = 'E';
268
- if (v < 0) { s = 'W'; degree = degree * -1 }
269
- let r = (v % 1) * 60; // decimal part of input, * 60 to get minutes
270
- return degree + '° ' + r.toFixed(2).padStart(5, '0') + '\' ' + s;
271
- },
272
- 'longitudeSec': function(v) {
273
- v = Qty(v, 'rad').to('deg').scalar ;
274
- let degree = Math.trunc(v);
275
- let s = 'E';
276
- if (v < 0) { s = 'W'; degree = degree * -1 }
277
- let r = (v % 1) * 60; // decimal part of input, * 60 to get minutes
278
- let minutes = Math.trunc(r);
279
- let seconds = (r % 1) * 60;
280
-
281
- return degree + '° ' + minutes + '\' ' + seconds.toFixed(2).padStart(5, '0') + '" ' + s;
282
- },
283
- }
284
-
285
-
286
-
287
- convertUnit(unit: string, value: number): number {
288
- if (!(unit in this.unitConversionFunctions)) { return null; }
289
- if (value === null) { return null; }
290
- return this.unitConversionFunctions[unit](value);
291
- }
292
-
293
- getDefaults(): IUnitDefaults {
294
- return this.defaultUnits;
295
- }
296
- getConversions(): IUnitGroup[] {
297
- return this.conversionList;
298
- }
299
-
300
- }
1
+ import { Injectable } from '@angular/core';
2
+ import * as Qty from 'js-quantities';
3
+
4
+ import { AppSettingsService } from './app-settings.service';
5
+ import { Subscription } from 'rxjs';
6
+
7
+ /**
8
+ * Group of Kip units array
9
+ */
10
+ export interface IUnitGroup {
11
+ group: string;
12
+ units: IUnit[];
13
+ }[]
14
+
15
+ /**
16
+ * Individual Kip units system measures definition
17
+ */
18
+ export interface IUnit {
19
+ measure: string;
20
+ description: string;
21
+ }
22
+
23
+ /**
24
+ * Interface for defaults Units per unit Groups to be applied
25
+ */
26
+ export interface IUnitDefaults {
27
+ [key: string]: string;
28
+ }
29
+
30
+ @Injectable()
31
+
32
+ export class UnitsService {
33
+
34
+
35
+
36
+ defaultUnits: IUnitDefaults;
37
+ defaultUnitsSub: Subscription;
38
+
39
+ /**
40
+ * Definition of available Kip units to be used for conversion.
41
+ * Measure property has to match one Unit Conversion Function for proper operation.
42
+ * Description is human readable property.
43
+ */
44
+ conversionList: IUnitGroup[] = [
45
+ { group: 'Unitless', units: [
46
+ { measure: 'unitless', description: "As-Is numeric value" }
47
+ ] },
48
+ { group: 'Speed', units: [
49
+ { measure: 'knots', description: "Knots - Nautical miles per hour"},
50
+ { measure: 'kph', description: "kph - Kilometers per hour"},
51
+ { measure: 'mph', description: "mph - Miles per hour"},
52
+ { measure: 'm/s', description: "m/s - Meters per second (default)"}
53
+ ] },
54
+ { group: 'Flow', units: [
55
+ { measure: 'm3/s', description: "Cubic meters per second (default)"},
56
+ { measure: 'l/min', description: "Litters per minute"},
57
+ { measure: 'l/h', description: "Litters per hour"},
58
+ { measure: 'g/min', description: "Gallons per minute"},
59
+ { measure: 'g/h', description: "Gallons per hour"}
60
+ ] },
61
+ { group: 'Temperature', units: [
62
+ { measure: 'K', description: "Kelvin (default)"},
63
+ { measure: 'celsius', description: "Celsius"},
64
+ { measure: 'fahrenheit', description: "Fahrenheit"}
65
+ ] },
66
+ { group: 'Length', units: [
67
+ { measure: 'm', description: "Metres (default)"},
68
+ { measure: 'fathom', description: "Fathoms"},
69
+ { measure: 'feet', description: "Feets"},
70
+ { measure: 'km', description: "Kilometers"},
71
+ { measure: 'nm', description: "Nautical Miles"},
72
+ { measure: 'mi', description: "Miles"},
73
+ ] },
74
+ { group: 'Volume', units: [
75
+ { measure: 'liter', description: "Liters (default)"},
76
+ { measure: 'm3', description: "Cubic Meters"},
77
+ { measure: 'gallon', description: "Gallons"},
78
+ ] },
79
+ { group: 'Current', units: [
80
+ { measure: 'A', description: "Amperes"},
81
+ { measure: 'mA', description: "Milliamperes"}
82
+ ] },
83
+ { group: 'Potential', units: [
84
+ { measure: 'V', description: "Volts"},
85
+ { measure: 'mV', description: "Millivolts"}
86
+ ] },
87
+ { group: 'Charge', units: [ { measure: 'C', description: "Current"} ] },
88
+ { group: 'Power', units: [
89
+ { measure: 'W', description: "Watts"},
90
+ { measure: 'mW', description: "Milliwatts"},
91
+ ] },
92
+ { group: 'Energy', units: [ { measure: 'J', description: "Joules"} ] },
93
+ { group: 'Pressure', units: [
94
+ { measure: 'Pa', description: "Pascal (default)" },
95
+ { measure: 'bar', description: "Bars" },
96
+ { measure: 'psi', description: "psi" },
97
+ { measure: 'mmHg', description: "mmHg" },
98
+ { measure: 'inHg', description: "inHg" },
99
+ { measure: 'hPa', description: "hPa" },
100
+ { measure: 'mbar', description: "mbar" },
101
+ ] },
102
+ { group: 'Density', units: [ { measure: 'kg/m3', description: "Air density - kg/cubic meter"} ] },
103
+ { group: 'Time', units: [
104
+ { measure: 's', description: "Seconds (default)" },
105
+ { measure: 'Minutes', description: "Minutes" },
106
+ { measure: 'Hours', description: "Hours" },
107
+ { measure: 'Days', description: "Days" },
108
+ { measure: 'HH:MM:SS', description: "Hours:Minute:seconds"}
109
+ ] },
110
+ { group: 'Angular Velocity', units: [
111
+ { measure: 'rad/s', description: "Radians per second" },
112
+ { measure: 'deg/s', description: "Degrees per second" },
113
+ { measure: 'deg/min', description: "Degrees per minute" },
114
+ ] },
115
+ { group: 'Angle', units: [
116
+ { measure: 'rad', description: "Radians" },
117
+ { measure: 'deg', description: "Degrees" },
118
+ { measure: 'grad', description: "Gradians" },
119
+ ] },
120
+ { group: 'Frequency', units: [
121
+ { measure: 'rpm', description: "RPM - Rotations per minute" },
122
+ { measure: 'Hz', description: "Hz - Hertz (default)" },
123
+ { measure: 'KHz', description: "KHz - KiloHertz" },
124
+ { measure: 'MHz', description: "MHz - MegaHertz" },
125
+ { measure: 'GHz', description: "GHz - GigaHertz" },
126
+ ] },
127
+ { group: 'Ratio', units: [
128
+ { measure: 'percent', description: "% - Percentage value (value multiplied by 100)" },
129
+ { measure: 'percentraw', description: "% - Percentage value (value unchanged)" },
130
+ { measure: 'ratio', description: "Ratio 0-1 (value multiplied by 100)" }
131
+ ] },
132
+ { group: 'Position', units: [
133
+ { measure: 'latitudeMin', description: "Latitude in minutes" },
134
+ { measure: 'latitudeSec', description: "Latitude in seconds" },
135
+ { measure: 'longitudeMin', description: "Longitude in minutes" },
136
+ { measure: 'longitudeSec', description: "Longitude in seconds" },
137
+ ] },
138
+ ];
139
+
140
+
141
+ constructor( private AppSettingsService: AppSettingsService,
142
+ ) {
143
+ this.defaultUnitsSub = this.AppSettingsService.getDefaultUnitsAsO().subscribe(
144
+ newDefaults => {
145
+ this.defaultUnits = newDefaults;
146
+ }
147
+ );
148
+ // console.log(Qty.getKinds());
149
+ // console.log(Qty.getUnits());
150
+ // console.log(Qty.getAliases('naut-mile'));
151
+ //build list for others.
152
+ /* Object.keys(this.conversions).forEach(group => {
153
+ this.conversionList[group] = [];
154
+ Object.keys(this.conversions[group]).forEach(unit => {
155
+ this.conversionList[group].push(unit);
156
+ });
157
+ }); */
158
+ }
159
+
160
+
161
+ unitConversionFunctions = {
162
+ 'unitless': function(v) { return v; },
163
+ // speed
164
+ 'knots': Qty.swiftConverter("m/s", "kn"),
165
+ 'kph': Qty.swiftConverter("m/s", "kph"),
166
+ 'm/s': function(v) { return v; },
167
+ 'mph': Qty.swiftConverter("m/s", "mph"),
168
+ // volume
169
+ "liter": Qty.swiftConverter('m^3', 'liter'),
170
+ "gallon": Qty.swiftConverter('m^3', 'gallon'),
171
+ "m3": function(v) { return v; },
172
+ // flow
173
+ 'm3/s': function(v) { return v; },
174
+ 'l/min': Qty.swiftConverter("m^3/s", "liter/minute"),
175
+ 'l/h': Qty.swiftConverter("m^3/s", "liter/hour"),
176
+ 'g/min': Qty.swiftConverter("m^3/s", "gallon/minute"),
177
+ 'g/h': Qty.swiftConverter("m^3/s", "gallon/hour"),
178
+ // temp
179
+ "K": function(v) { return v; },
180
+ "celsius": Qty.swiftConverter("tempK", "tempC"),
181
+ "fahrenheit": Qty.swiftConverter("tempK", "tempF"),
182
+ // length
183
+ "m": function(v) { return v; },
184
+ "fathom": Qty.swiftConverter('m', 'fathom'),
185
+ "feet": Qty.swiftConverter('m', 'foot'),
186
+ "km": Qty.swiftConverter('m', 'km'),
187
+ "nm": Qty.swiftConverter('m', 'nmi'),
188
+ "mi": Qty.swiftConverter('m', 'mi'),
189
+ // Potential
190
+ "V": function(v) { return v; },
191
+ "mV": function(v) { return v*1000; },
192
+ // Current
193
+ "A": function(v) { return v; },
194
+ "mA": function(v) { return v*1000; },
195
+ // charge
196
+ "C": function(v) { return v; },
197
+ // Power
198
+ "W": function(v) { return v; },
199
+ "mW": function(v) { return v*1000; },
200
+ // Energy
201
+ "J": function(v) { return v; },
202
+ // pressure
203
+ "Pa": function(v) { return v; },
204
+ "bar": Qty.swiftConverter('Pa', 'bar'),
205
+ "psi": Qty.swiftConverter('Pa', 'psi'),
206
+ "mmHg": Qty.swiftConverter('Pa', 'mmHg'),
207
+ "inHg": Qty.swiftConverter('Pa', 'inHg'),
208
+ "hPa": Qty.swiftConverter('Pa', 'hPa'),
209
+ "mbar": Qty.swiftConverter('Pa', 'millibar'),
210
+ // Density - Description: Current outside air density
211
+ "kg/m3": function(v) { return v; },
212
+ // Time
213
+ "s": function(v) { return v; },
214
+ "Minutes": Qty.swiftConverter('s', 'minutes'),
215
+ "Hours": Qty.swiftConverter('s', 'hours'),
216
+ "Days": Qty.swiftConverter('s', 'days'),
217
+ "HH:MM:SS": function(v) {
218
+ v = parseInt(v, 10);
219
+ if (v < 0) { v = v *-1} // always positive
220
+
221
+ var h = Math.floor(v / 3600);
222
+ var m = Math.floor(v % 3600 / 60);
223
+ var s = Math.floor(v % 3600 % 60);
224
+ return ('0' + h).slice(-2) + ":" + ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);
225
+ },
226
+ // angularVelocity
227
+ "rad/s": function(v) { return v; },
228
+ "deg/s": Qty.swiftConverter('rad/s', 'deg/s'),
229
+ "deg/min": Qty.swiftConverter('rad/s', 'deg/min'),
230
+ // frequency
231
+ "rpm": function(v) { return v*60; },
232
+ "Hz": function(v) { return v; },
233
+ "KHz": function(v) { return v/1000; },
234
+ "MHz": function(v) { return v/1000000; },
235
+ "GHz": function(v) { return v/1000000000; },
236
+ // angle
237
+ "rad": function(v) { return v; },
238
+ "deg": Qty.swiftConverter('rad', 'deg'),
239
+ "grad": Qty.swiftConverter('rad', 'grad'),
240
+ // ratio
241
+ 'percent': function(v) { return (v * 100) + '%' },
242
+ 'percentraw': function(v) { return v + '%' },
243
+ 'ratio': function(v) { return v * 100 },
244
+ // lat/lon
245
+ 'latitudeMin': function(v) {
246
+ v = Qty(v, 'rad').to('deg').scalar ;
247
+ let degree = Math.trunc(v);
248
+ let s = 'N';
249
+ if (v < 0) { s = 'S'; degree = degree * -1 }
250
+ let r = (v % 1) * 60; // decimal part of input, * 60 to get minutes
251
+ return degree + '° ' + r.toFixed(2).padStart(5, '0') + '\' ' + s;
252
+ },
253
+ 'latitudeSec': function(v) {
254
+ v = Qty(v, 'rad').to('deg').scalar ;
255
+ let degree = Math.trunc(v);
256
+ let s = 'N';
257
+ if (v < 0) { s = 'S'; degree = degree * -1 }
258
+ let r = (v % 1) * 60; // decimal part of input, * 60 to get minutes
259
+ let minutes = Math.trunc(r);
260
+ let seconds = (r % 1) * 60;
261
+
262
+ return degree + '° ' + minutes + '\' ' + seconds.toFixed(2).padStart(5, '0') + '" ' + s;
263
+ },
264
+ 'longitudeMin': function(v) {
265
+ v = Qty(v, 'rad').to('deg').scalar ;
266
+ let degree = Math.trunc(v);
267
+ let s = 'E';
268
+ if (v < 0) { s = 'W'; degree = degree * -1 }
269
+ let r = (v % 1) * 60; // decimal part of input, * 60 to get minutes
270
+ return degree + '° ' + r.toFixed(2).padStart(5, '0') + '\' ' + s;
271
+ },
272
+ 'longitudeSec': function(v) {
273
+ v = Qty(v, 'rad').to('deg').scalar ;
274
+ let degree = Math.trunc(v);
275
+ let s = 'E';
276
+ if (v < 0) { s = 'W'; degree = degree * -1 }
277
+ let r = (v % 1) * 60; // decimal part of input, * 60 to get minutes
278
+ let minutes = Math.trunc(r);
279
+ let seconds = (r % 1) * 60;
280
+
281
+ return degree + '° ' + minutes + '\' ' + seconds.toFixed(2).padStart(5, '0') + '" ' + s;
282
+ },
283
+ }
284
+
285
+
286
+
287
+ convertUnit(unit: string, value: number): number {
288
+ if (!(unit in this.unitConversionFunctions)) { return null; }
289
+ if (value === null) { return null; }
290
+ return this.unitConversionFunctions[unit](value);
291
+ }
292
+
293
+ getDefaults(): IUnitDefaults {
294
+ return this.defaultUnits;
295
+ }
296
+ getConversions(): IUnitGroup[] {
297
+ return this.conversionList;
298
+ }
299
+
300
+ }