@atmosx/event-product-parser 3.0.63 → 3.0.75

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 (164) hide show
  1. package/.github/docs/docs-functions.md +1 -1
  2. package/.github/docs/docs-general-configurations.md +1 -11
  3. package/.github/docs/docs-integrations.md +3 -2
  4. package/README.md +4 -4
  5. package/dist/cjs/index.cjs +3590 -623
  6. package/dist/esm/index.mjs +3589 -624
  7. package/package.json +11 -4
  8. package/src/bootstrap.ts +50 -33
  9. package/src/{@building → building}/CreateEvent.ts +10 -10
  10. package/src/{@building → building}/GetCleanedEvent.ts +2 -2
  11. package/src/{@building → building}/GetEventAttachments.ts +12 -10
  12. package/src/building/GetEventDirection.ts +28 -0
  13. package/src/{@building → building}/GetEventEnhancedName.ts +5 -6
  14. package/src/{@building → building}/GetEventGeometry.ts +19 -13
  15. package/src/{@building → building}/GetEventHeader.ts +4 -4
  16. package/src/{@building → building}/GetEventNodes.ts +16 -14
  17. package/src/{@building → building}/GetEventOffice.ts +5 -5
  18. package/src/building/GetEventPopulation.ts +58 -0
  19. package/src/{@building → building}/GetEventProperties.ts +23 -18
  20. package/src/{@building → building}/GetEventSignature.ts +8 -8
  21. package/src/{@building → building}/GetEventTags.ts +3 -3
  22. package/src/{@core/CreateListener.ts → building/GetEventTheme.ts} +8 -6
  23. package/src/{@building → building}/GetEventTracking.ts +6 -6
  24. package/src/{@modules/@eas/GenerateEASMessage.ts → components/audio/GenerateAudioMessage.ts} +32 -33
  25. package/src/{@modules/@eas → components/audio/components}/GetCleanDescription.ts +2 -2
  26. package/src/{@modules/@eas → components/audio/components}/GetFloatPCM16.ts +2 -2
  27. package/src/{@modules/@eas → components/audio/components}/GetMergedPCM16.ts +2 -2
  28. package/src/{@modules/@eas → components/audio/components}/GetPCM16.ts +2 -2
  29. package/src/{@modules/@eas → components/audio/components}/GetPCMToFloat.ts +2 -2
  30. package/src/{@modules/@eas → components/audio/components}/GetSampledPCM16.ts +2 -2
  31. package/src/{@modules/@eas → components/audio/components}/GetTTS.ts +5 -3
  32. package/src/{@modules/@eas → components/audio/components}/GetWavPCM16.ts +2 -2
  33. package/src/{@modules/@eas → components/audio/components}/SetAFSK.ts +2 -2
  34. package/src/{@modules/@eas → components/audio/components}/SetAsciiToBits.ts +2 -2
  35. package/src/{@modules/@eas → components/audio/components}/SetAttentionTone.ts +2 -2
  36. package/src/{@modules/@eas → components/audio/components}/SetNoise.ts +4 -4
  37. package/src/{@modules/@eas → components/audio/components}/SetRadioEffect.ts +4 -4
  38. package/src/{@modules/@eas → components/audio/components}/SetSameHeader.ts +5 -5
  39. package/src/{@modules/@utilities/SetWarning.ts → components/database/CreateQuery.ts} +18 -13
  40. package/src/{@modules/@database → components/database}/GetCachedEvents.ts +14 -9
  41. package/src/components/database/ImportBoundaries.ts +168 -0
  42. package/src/{@modules/@database → components/database}/ImportBroadcastify.ts +8 -17
  43. package/src/components/database/ImportCities.ts +87 -0
  44. package/src/{@modules/@database → components/database}/ImportShapefiles.ts +14 -16
  45. package/src/{@modules/@database → components/database}/ImportStanza.ts +13 -17
  46. package/src/components/database/InitializeDatabase.ts +71 -0
  47. package/src/components/images/GenerateGraphic.ts +242 -0
  48. package/src/components/images/components/CreateRectangle.ts +22 -0
  49. package/src/components/images/components/CreateText.ts +22 -0
  50. package/src/components/images/modules/CreateSVG.ts +37 -0
  51. package/src/components/images/modules/GetGeographicalBoundaries.ts +72 -0
  52. package/src/components/images/modules/GetGeographicalCities.ts +58 -0
  53. package/src/components/images/modules/GetGeographicalEvents.ts +48 -0
  54. package/src/components/images/modules/GetGeometryBounds.ts +82 -0
  55. package/src/components/images/modules/GetParsedBoundary.ts +58 -0
  56. package/src/components/images/modules/GetSVGPath.ts +53 -0
  57. package/src/components/images/modules/NormalizePolygon.ts +57 -0
  58. package/src/{@modules/@stanza → components/stanza}/GetAwipsType.ts +4 -4
  59. package/src/{@modules/@stanza → components/stanza}/ValidateStanza.ts +6 -6
  60. package/src/{@modules/@utilities → components/utilities}/CreateHttp.ts +2 -2
  61. package/src/{@parsers/@text → components/utilities}/GetEmbededText.ts +6 -4
  62. package/src/{@modules/@utilities → components/utilities}/GetFormattedTime.ts +2 -2
  63. package/src/{@modules/@utilities → components/utilities}/GetLatestIssuance.ts +2 -2
  64. package/src/{@modules/@utilities → components/utilities}/GetMatched.ts +2 -2
  65. package/src/{@modules/@utilities → components/utilities}/GetShapeNearestPoint.ts +2 -2
  66. package/src/{@parsers/@text → components/utilities}/GetStringText.ts +7 -7
  67. package/src/components/utilities/GetUnionPolygon.ts +36 -0
  68. package/src/{@modules/@utilities → components/utilities}/QueueManager.ts +2 -2
  69. package/src/{@modules/@utilities → components/utilities}/SetCronSchedule.ts +37 -25
  70. package/src/{@modules/@utilities → components/utilities}/SetDebug.ts +4 -4
  71. package/src/{@modules/@utilities → components/utilities}/SetEventEmit.ts +8 -7
  72. package/src/{@modules/@utilities → components/utilities}/SetSettings.ts +4 -4
  73. package/src/{@modules/@utilities → components/utilities}/SetSleep.ts +2 -2
  74. package/src/{@modules/@utilities → components/utilities}/SetTimeoutAction.ts +3 -3
  75. package/src/components/utilities/SetWarning.ts +47 -0
  76. package/src/{@modules/@xmpp → components/xmpp}/DeployXMPP.ts +12 -12
  77. package/src/{@modules/@xmpp → components/xmpp}/ErrorXMPP.ts +3 -3
  78. package/src/{@modules/@xmpp → components/xmpp}/OfflineXMPP.ts +4 -4
  79. package/src/{@modules/@xmpp → components/xmpp}/OnlineXMPP.ts +5 -5
  80. package/src/{@modules/@xmpp → components/xmpp}/ReconnectXMPP.ts +6 -6
  81. package/src/{@modules/@xmpp → components/xmpp}/StanzaXMPP.ts +8 -8
  82. package/src/{@core → core}/ClearEvents.ts +4 -4
  83. package/src/{@core → core}/GetEvents.ts +3 -3
  84. package/src/{@core → core}/GetNodes.ts +3 -3
  85. package/src/{@core → core}/GetRandomEvent.ts +3 -3
  86. package/src/{@core → core}/GetVersion.ts +3 -3
  87. package/src/{@core → core}/ManualEvent.ts +6 -6
  88. package/src/{@core → core}/QueryStanza.ts +9 -8
  89. package/src/{@core → core}/SetNode.ts +5 -5
  90. package/src/{@core → core}/StartService.ts +13 -12
  91. package/src/{@core → core}/StopService.ts +3 -3
  92. package/src/{@enums → enums}/AWIPS.ts +2 -2
  93. package/src/{@enums → enums}/Actions.ts +2 -2
  94. package/src/{@enums → enums}/Cancellation.ts +2 -2
  95. package/src/{@enums → enums}/Causes.ts +2 -2
  96. package/src/{@enums → enums}/Correlations.ts +2 -2
  97. package/src/{@enums → enums}/Enhanced.ts +4 -3
  98. package/src/{@enums → enums}/Events.ts +2 -2
  99. package/src/{@enums → enums}/Expressions.ts +2 -2
  100. package/src/{@enums → enums}/GlobalFilter.ts +2 -2
  101. package/src/{@enums → enums}/Hail.ts +2 -2
  102. package/src/{@enums → enums}/ICAO.ts +2 -2
  103. package/src/{@enums → enums}/Matches.ts +8 -3
  104. package/src/{@enums → enums}/Products.ts +2 -2
  105. package/src/{@enums → enums}/Records.ts +2 -2
  106. package/src/{@enums → enums}/Severity.ts +2 -2
  107. package/src/{@enums → enums}/Shapefiles.ts +2 -2
  108. package/src/{@enums → enums}/States.ts +68 -4
  109. package/src/{@enums → enums}/Status.ts +2 -2
  110. package/src/{@enums → enums}/Strings.ts +2 -2
  111. package/src/{@enums → enums}/Tags.ts +8 -3
  112. package/src/{@enums → enums}/Testing.ts +2 -2
  113. package/src/enums/Themes.ts +70 -0
  114. package/src/{@events → events}/ParseAPI.ts +28 -17
  115. package/src/{@events → events}/ParseText.ts +13 -11
  116. package/src/{@events → events}/ParseUGC.ts +15 -14
  117. package/src/{@events → events}/ParseVTEC.ts +18 -16
  118. package/src/index.ts +49 -32
  119. package/src/{@manager → manager}/MakeEvents.ts +16 -28
  120. package/src/{@manager → manager}/RemoveEvent.ts +9 -9
  121. package/src/{@manager → manager}/SetHash.ts +5 -5
  122. package/src/{@manager → manager}/UpdateEvents.ts +6 -6
  123. package/src/{@manager → manager}/UpdateNode.ts +6 -6
  124. package/src/{@manager → manager}/ValidateEvents.ts +31 -20
  125. package/src/{@parsers/@hvtec → parsers/hvtec}/HVExtract.ts +7 -7
  126. package/src/{@parsers/@text → parsers/text}/GetDescriptionFromProduct.ts +3 -3
  127. package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
  128. package/src/{@parsers/@text → parsers/text}/GetTextFromProduct.ts +2 -2
  129. package/src/{@parsers/@ugc → parsers/ugc}/GetCache.ts +4 -4
  130. package/src/{@parsers/@ugc → parsers/ugc}/GetExpiry.ts +2 -2
  131. package/src/{@parsers/@ugc → parsers/ugc}/GetHeader.ts +3 -3
  132. package/src/{@parsers/@ugc → parsers/ugc}/GetLocations.ts +9 -9
  133. package/src/parsers/ugc/GetZonePolygon.ts +73 -0
  134. package/src/{@parsers/@ugc → parsers/ugc}/GetZones.ts +2 -2
  135. package/src/{@parsers/@ugc → parsers/ugc}/SetCache.ts +4 -4
  136. package/src/{@parsers/@ugc → parsers/ugc}/UGCExtract.ts +9 -9
  137. package/src/{@parsers/@vtec → parsers/vtec}/GetExpiry.ts +2 -2
  138. package/src/{@parsers/@vtec → parsers/vtec}/VTECExtract.ts +9 -9
  139. package/src/{@types-lower → static}/Attributes.ts +2 -3
  140. package/src/{@types-lower → static}/Event.ts +7 -6
  141. package/src/{@types-lower → static}/Properties.ts +17 -4
  142. package/src/{@types-lower → static}/Stanza.ts +3 -3
  143. package/src/{@tasks → tasks}/CreateTasks.ts +40 -34
  144. package/src/{@tasks → tasks}/TaskGenerateJSON.ts +2 -2
  145. package/src/{@tasks → tasks}/TaskGenerateText.ts +2 -2
  146. package/src/{@tasks → tasks}/TaskSendNTFY.ts +29 -25
  147. package/src/{@tasks → tasks}/TaskSendWebhook.ts +22 -15
  148. package/src/{@types → types}/Actions.ts +3 -3
  149. package/src/{@types → types}/HVTEC.ts +2 -2
  150. package/src/{@types → types}/Hash.ts +2 -2
  151. package/src/types/Nodes.ts +29 -0
  152. package/src/{@types → types}/Settings.ts +17 -8
  153. package/src/{@types → types}/StanzaCompiled.ts +3 -3
  154. package/src/{@types → types}/UGC.ts +2 -2
  155. package/src/{@types → types}/VTEC.ts +2 -2
  156. package/tools/build.js +2 -0
  157. package/tsconfig.json +25 -18
  158. package/src/@modules/@database/InitializeDatabase.ts +0 -59
  159. package/src/@modules/@utilities/GetSettings.ts +0 -25
  160. package/src/@modules/@utilities/SetListener.ts +0 -30
  161. package/src/@parsers/@text/GetPolygonFromProduct.ts +0 -53
  162. package/src/@parsers/@text/GetXML.ts +0 -61
  163. package/src/@parsers/@ugc/GetZonePolygon.ts +0 -111
  164. package/src/@tasks/TaskGenerateAudio.ts +0 -34
@@ -11,13 +11,13 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
20
- import { TypeAttributes } from "types-lower/Attributes"
20
+ import { TypeAttributes } from "StaticTypes/Attributes"
21
21
 
22
22
  export type TypeStanzaCompiled = {
23
23
  Message?: string
@@ -11,9 +11,9 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
@@ -11,9 +11,9 @@
11
11
  Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
12
  Discord: https://atmosphericx-discord.scriptkitty.cafe
13
13
  Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
14
+ Documentation: https://atmosphericx.scriptkitty.cafe/documentation
15
15
 
16
- Internal Package: @atmosx/event-product-parser
16
+ Independent Package: @atmosx/event-product-parser
17
17
 
18
18
  */
19
19
 
package/tools/build.js CHANGED
@@ -10,6 +10,7 @@ const commands = [
10
10
  "--target=node22",
11
11
  "--format=esm",
12
12
  "--external:better-sqlite3",
13
+ "--external:sharp",
13
14
  "--out-extension:.js=.mjs",
14
15
  "--outdir=dist/esm",
15
16
  ...(watch ? ["--watch"] : []),
@@ -24,6 +25,7 @@ const commands = [
24
25
  "--target=node22",
25
26
  "--format=cjs",
26
27
  "--external:better-sqlite3",
28
+ "--external:sharp",
27
29
  "--out-extension:.js=.cjs",
28
30
  "--outdir=dist/cjs",
29
31
  ...(watch ? ["--watch"] : []),
package/tsconfig.json CHANGED
@@ -9,25 +9,32 @@
9
9
  "esModuleInterop": true,
10
10
  "allowSyntheticDefaultImports": true,
11
11
  "skipLibCheck": true,
12
+ "strict": true,
13
+ "strictNullChecks": false, // Note: I use optional changing and heavily rely on `null` and `undefined` values in the codebase. Please do not set this to true unless you want the compiler to throw a fucking temper tantrum every time you try to access a property of an object that may or may not be null or undefined. I have better things to do than to deal with that nonsense.
14
+ "noImplicitAny": true,
12
15
  "paths": {
13
- "@parsers/hvtec/*": ["./src/@parsers/@hvtec/*"],
14
- "@parsers/vtec/*": ["./src/@parsers/@vtec/*"],
15
- "@parsers/ugc/*": ["./src/@parsers/@ugc/*"],
16
- "@parsers/text/*": ["./src/@parsers/@text/*"],
17
- "@database/*": ["./src/@modules/@database/*"],
18
- "@eas/*": ["./src/@modules/@eas/*"],
19
- "@stanza/*": ["./src/@modules/@stanza/*"],
20
- "@utilities/*": ["./src/@modules/@utilities/*"],
21
- "@xmpp/*": ["./src/@modules/@xmpp/*"],
22
- "@manager/*": ["./src/@manager/*"],
23
- "@tasks/*": ["./src/@tasks/*"],
24
- "@events/*": ["./src/@events/*"],
25
- "@enums/*": ["./src/@enums/*"],
26
- "@core/*": ["./src/@core/*"],
27
- "@building/*": ["./src/@building/*"],
28
- "types/*": ["./src/@types/*"],
29
- "types-lower/*": ["./src/@types-lower/*"],
30
- "@bootstrap": ["./src/bootstrap.ts"],
16
+ "@ParsingHVTEC/*": ["./src/parsers/hvtec/*"],
17
+ "@ParsingVTEC/*": ["./src/parsers/vtec/*"],
18
+ "@ParsingUGC/*": ["./src/parsers/ugc/*"],
19
+ "@ParsingText/*": ["./src/parsers/text/*"],
20
+ "@Database/*": ["./src/components/database/*"],
21
+ "@Audio/*": ["./src/components/audio/*"],
22
+ "@AudioComponents/*": ["./src/components/audio/components/*"],
23
+ "@Image/*": ["./src/components/images/*"],
24
+ "@ImageModules/*": ["./src/components/images/modules/*"],
25
+ "@ImageComponents/*": ["./src/components/images/components/*"],
26
+ "@Stanza/*": ["./src/components/stanza/*"],
27
+ "@Utilities/*": ["./src/components/utilities/*"],
28
+ "@XMPP/*": ["./src/components/xmpp/*"],
29
+ "@Manager/*": ["./src/manager/*"],
30
+ "@Tasks/*": ["./src/tasks/*"],
31
+ "@Events/*": ["./src/events/*"],
32
+ "@Enums/*": ["./src/enums/*"],
33
+ "@Core/*": ["./src/core/*"],
34
+ "@Building/*": ["./src/building/*"],
35
+ "Types/*": ["./src/types/*"],
36
+ "StaticTypes/*": ["./src/static/*"],
37
+ "@Bootstrap": ["./src/bootstrap.ts"],
31
38
  }
32
39
  },
33
40
  "include": ["src"]
@@ -1,59 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
-
21
- import { TypeSettings } from "types/Settings"
22
- import { Bootstrap } from "@bootstrap"
23
- import { SetWarning } from "@utilities/SetWarning"
24
- import { ImportShapefiles } from "@database/ImportShapefiles"
25
- import { ImportBroadcastify } from "@database/ImportBroadcastify"
26
- import { existsSync, writeFileSync } from "fs"
27
- import sqlite3 from "better-sqlite3"
28
-
29
- export const InitializeDatabase = async (): Promise<void> => {
30
- const settings = Bootstrap.Settings as TypeSettings;
31
- try {
32
- if (!existsSync(settings.Database)) {
33
- writeFileSync(settings.Database, '')
34
- SetWarning({ Message: `Creating new database at ${settings.Database}` })
35
- }
36
- Bootstrap.Database = new sqlite3(settings.Database);
37
- Bootstrap.Database
38
- .prepare(`CREATE TABLE IF NOT EXISTS stanzas ( id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT, issued TEXT, stanza TEXT )`)
39
- .run();
40
- Bootstrap.Database
41
- .prepare(`CREATE TABLE IF NOT EXISTS shapefiles (id TEXT PRIMARY KEY, location TEXT, geometry TEXT)`)
42
- .run();
43
- const isNeedingShapefiles = Bootstrap.Database
44
- .prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='shapefiles';`)
45
- .get();
46
- const isNeedingBroadcastify = Bootstrap.Database
47
- .prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='broadcastify';`)
48
- .get();
49
-
50
- if (!isNeedingShapefiles || !isNeedingBroadcastify) {
51
- SetWarning({Message: `Required database tables are currently building, please ${Bootstrap.Colors.Red}DO NOT${Bootstrap.Colors.Reset} close your terminal. The building will not finish and will remain incomplete. If you do mess up, you will need to delete ${settings.Database} and restart the application.` })
52
- await ImportBroadcastify();
53
- await ImportShapefiles();
54
- SetWarning({ Message: `Building has completed, you can now continue or close the terminal`})
55
- }
56
- } catch (error) {
57
- SetWarning({ Message: `An error occurred while initializing the database: ${error.message}` })
58
- }
59
- }
@@ -1,25 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- import { TypeSettings } from "types/Settings"
21
- import { Bootstrap } from "@bootstrap"
22
-
23
- export const GetSettings = (): TypeSettings => {
24
- return Bootstrap.Settings;
25
- }
@@ -1,30 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- import { Bootstrap } from "@bootstrap"
21
-
22
- interface SetListenerOptions {
23
- Event: string,
24
- Callback: () => void
25
- }
26
-
27
- export const SetListener = ({ Event, Callback }: SetListenerOptions): (() => void) => {
28
- Bootstrap.Listener.on(Event, Callback)
29
- return () => { void Bootstrap.Listener.off(Event, Callback) };
30
- }
@@ -1,53 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- export const getPolygonFromProduct = (message: string): number[][] => {
21
- const coordinates: number[][] = [];
22
- const match = message.match(
23
- /LAT\.\.\.LON\s+([\s\S]*?)(?=\n[A-Z]{2,}(?:\.\.\.|:)|\$\$|&&|$)/i
24
- );
25
- if (!match) return coordinates;
26
- const text = match[1];
27
- const values = text.match(/\d{4,8}/g);
28
- if (!values) return coordinates;
29
-
30
- if (values.every(v => v.length === 8)) {
31
- for (const value of values) {
32
- const lat = parseInt(value.slice(0, 4), 10) / 100;
33
- const lon = -parseInt(value.slice(4, 8), 10) / 100;
34
- if (Number.isFinite(lat) && Number.isFinite(lon)) {
35
- coordinates.push([lon, lat]);
36
- }
37
- }
38
- }
39
-
40
- else {
41
- for (let i = 0; i + 1 < values.length; i += 2) {
42
- const lat = parseInt(values[i], 10) / 100;
43
- const lon = -parseInt(values[i + 1], 10) / 100;
44
- if (Number.isFinite(lat) && Number.isFinite(lon)) {
45
- coordinates.push([lon, lat]);
46
- }
47
- }
48
- }
49
- if (coordinates.length > 2) {
50
- coordinates.push([...coordinates[0]]);
51
- }
52
- return coordinates;
53
- };
@@ -1,61 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- interface GetXMLOptions {
21
- Message: string
22
- Targets: string[]
23
- }
24
-
25
- export const GetXML = ({ Message, Targets }: GetXMLOptions): Record<string, string> => {
26
- const extracted: Record<string, any> = {};
27
- const findValueByKey = (obj: any, searchKey: string) => {
28
- const results = [];
29
- if (obj === null || typeof obj !== 'object') {
30
- return results;
31
- }
32
- const searchKeyLower = searchKey.toLowerCase();
33
- for (const key in obj) {
34
- if (obj.hasOwnProperty(key) && key.toLowerCase() === searchKeyLower) {
35
- results.push(obj[key]);
36
- }
37
- }
38
- if (Array.isArray(obj)) {
39
- for (const item of obj) {
40
- if (item.valueName && item.valueName.toLowerCase() === searchKeyLower && item.value !== undefined) {
41
- results.push(item.value);
42
- }
43
- const nestedResults = findValueByKey(item, searchKey);
44
- results.push(...nestedResults);
45
- }
46
- }
47
- for (const key in obj) {
48
- if (obj.hasOwnProperty(key)) {
49
- const nestedResults = findValueByKey(obj[key], searchKey);
50
- results.push(...nestedResults);
51
- }
52
- }
53
- return results;
54
- };
55
- for (const key of Targets) {
56
- const values = findValueByKey(Message, key);
57
- const uniqueValues = [...new Set(values)];
58
- extracted[key] = uniqueValues.length === 0 ? null : (uniqueValues.length === 1 ? uniqueValues[0] : uniqueValues);
59
- }
60
- return extracted;
61
- }
@@ -1,111 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- import { Bootstrap } from "@bootstrap"
21
- import { union } from "polygon-clipping"
22
-
23
- interface CoordinatesOptions {
24
- Zones: string[]
25
- Union: boolean
26
- }
27
-
28
- interface CoordinatesResponse {
29
- type: `Polygon` | `MultiPolygon`
30
- coordinates: any[]
31
- }
32
-
33
- export const getZonePolygon = ({ Zones, Union }: CoordinatesOptions): CoordinatesResponse | null => {
34
- const list = [...new Set(Zones.map(z => z.trim()))].filter(z => z === 'XX000' ? false : true);
35
- if (list.length === 0) return null;
36
-
37
- const placeholders = list.map(() => "?").join(",");
38
- const rows = Bootstrap.Database
39
- .prepare(`SELECT geometry FROM shapefiles WHERE id IN (${placeholders})`)
40
- .all(...list);
41
- const polygons: any[] = [];
42
- for (const row of rows) {
43
- if (!row?.geometry) continue;
44
- const geom = JSON.parse(row.geometry);
45
- if (geom?.type === "Polygon") {
46
- polygons.push(geom.coordinates);
47
- }
48
- }
49
-
50
- if (polygons.length === 0) return null;
51
-
52
- if (Union) {
53
- const unionFn = union as (...polys: any[]) => any;
54
- const mergedCoords = unionFn(...polygons);
55
- if (!mergedCoords || mergedCoords.length === 0) return null;
56
- let maxArea = -1;
57
- let bestPoly: any[] = [];
58
- for (const poly of mergedCoords) {
59
- const outerRing = poly[0];
60
- let area = 0;
61
- for (let i = 0; i < outerRing.length - 1; i++) {
62
- const [x1, y1] = outerRing[i];
63
- const [x2, y2] = outerRing[i + 1];
64
- area += x1 * y2 - x2 * y1;
65
- }
66
- area = Math.abs(area / 2);
67
- if (area > maxArea) {
68
- maxArea = area;
69
- bestPoly = poly;
70
- }
71
- }
72
- if (!bestPoly || bestPoly.length === 0) return null;
73
- const outerRing = bestPoly[0];
74
- const skip = Math.max(1, parseInt(String(Bootstrap.Settings.GlobalSettings.ShapefileSkipPoints), 10) ?? 1);
75
- let skipped = outerRing.filter((_: any, idx: number) => idx % skip === 0);
76
- if (skipped.length < 4) {
77
- skipped = outerRing.slice();
78
- }
79
- const first = skipped[0];
80
- const last = skipped[skipped.length - 1];
81
- if (!first || !last || first[0] !== last[0] || first[1] !== last[1]) {
82
- skipped.push([first[0], first[1]]);
83
- }
84
- return {type: "Polygon", coordinates: [skipped]};
85
- } else {
86
- const multi: any[] = [];
87
- for (const polyCoords of polygons) {
88
- if (Array.isArray(polyCoords) && Array.isArray(polyCoords[0])) {
89
- multi.push(polyCoords);
90
- }
91
- }
92
- if (multi.length === 0) return null;
93
- const skip = Math.max(1, parseInt(String(Bootstrap.Settings.GlobalSettings.ShapefileSkipPoints), 10) ?? 1);
94
- if (skip > 1) {
95
- for (let p = 0; p < multi.length; p++) {
96
- for (let r = 0; r < multi[p].length; r++) {
97
- const ring = multi[p][r];
98
- let reduced = ring.filter((_: any, i: number) => i % skip === 0);
99
- if (reduced.length < 4) reduced = ring.slice();
100
- const first = reduced[0];
101
- const last = reduced[reduced.length - 1];
102
- if ( first && last && (first[0] !== last[0] || first[1] !== last[1])) {
103
- reduced.push([first[0], first[1]]);
104
- }
105
- multi[p][r] = reduced;
106
- }
107
- }
108
- }
109
- return {type: "MultiPolygon", coordinates: multi};
110
- }
111
- }
@@ -1,34 +0,0 @@
1
- /*
2
- _ _ _ __ __
3
- /\ | | | | (_) \ \ / /
4
- / \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
5
- / /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
6
- / ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
7
- /_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
8
- | |
9
- |_|
10
-
11
- Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
12
- Discord: https://atmosphericx-discord.scriptkitty.cafe
13
- Ko-Fi: https://ko-fi.com/k3yomi
14
- Documentation: http://localhost/documentation | https://atmosphericx.scriptkitty.cafe/documentation
15
-
16
- Internal Package: @atmosx/event-product-parser
17
-
18
- */
19
-
20
- import { GenerateEASMessage } from "@eas/GenerateEASMessage"
21
-
22
- interface TaskGenerateAudioOptions {
23
- Filename: string;
24
- Description: string;
25
- Header: string;
26
- }
27
-
28
- export const TaskGenerateAudio = async function({ Filename, Description, Header }: TaskGenerateAudioOptions): Promise<string> {
29
- return await GenerateEASMessage({
30
- Title: Filename,
31
- Message: Description,
32
- Header: Header
33
- });
34
- }