@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atmosx/event-product-parser",
3
- "version": "3.0.63",
3
+ "version": "3.0.75",
4
4
  "description": "NOAA Weather Wire & NWS API Parser - Built for standalone and Project AtmosphericX Integration.",
5
5
  "main": "dist/cjs/index.cjs",
6
6
  "module": "dist/esm/index.mjs",
@@ -36,14 +36,21 @@
36
36
  "@xmpp/client": "0.14.0",
37
37
  "better-sqlite3": "12.9.0",
38
38
  "croner": "10.0.1",
39
- "esbuild": "^0.28.1",
40
- "fast-glob": "^3.3.3",
39
+ "d3-geo": "3.1.1",
40
+ "esbuild": "0.28.1",
41
41
  "jszip": "3.10.1",
42
42
  "polygon-clipping": "0.15.7",
43
43
  "shapefile": "0.6.6",
44
+ "sharp": "0.35.3",
45
+ "topojson-client": "3.1.0",
44
46
  "typescript": "5.9.3"
45
47
  },
46
48
  "devDependencies": {
47
- "@types/node": "25.2.0"
49
+ "@types/better-sqlite3": "7.6.13",
50
+ "@types/d3-geo": "3.1.0",
51
+ "@types/node": "25.2.0",
52
+ "@types/shapefile": "0.6.4",
53
+ "@types/topojson-client": "3.1.5",
54
+ "@types/xmpp__client": "0.14.1"
48
55
  }
49
56
  }
package/src/bootstrap.ts CHANGED
@@ -11,22 +11,29 @@
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 path from "path"
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { TypeHash } from "Types/Hash"
22
+ import { TypeActions } from "Types/Actions"
23
+ import { TypeNode } from "Types/Nodes"
24
+ import { EnumThemes } from "@Enums/Themes"
21
25
  import { EventEmitter } from "node:events"
26
+ import { client } from "@xmpp/client"
27
+ import { Database } from "better-sqlite3"
28
+ import { join } from "path"
22
29
 
23
30
  export const Bootstrap = {
24
- Version: `3.0.63`,
31
+ Version: `3.0.75`,
25
32
  Ready: true,
26
- Ratelimits: {},
27
- Session: null,
28
- Database: null,
29
- Job: null,
33
+ Ratelimits: {} as Record<string, number[]>,
34
+ Session: null as ReturnType<typeof client>,
35
+ Database: null as Database,
36
+ Job: null as unknown,
30
37
  Listener: new EventEmitter(),
31
38
  Colors: {
32
39
  Red: `\x1b[31m`, Green: `\x1b[32m`, Yellow: `\x1b[33m`,
@@ -34,30 +41,33 @@ export const Bootstrap = {
34
41
  White: `\x1b[37m`, Reset: `\x1b[0m`
35
42
  },
36
43
  Cache: {
37
- LastStanzaTime: null,
44
+ LastStanzaTime: null as number,
38
45
  Connected: false,
39
46
  Reconnecting: false,
40
47
  TotalReconnects: 0,
41
48
  Hault: false,
42
- Events: {type: "FeatureCollection", features: []},
43
- Nodes: {type: "FeatureCollection", features: []},
44
- Hashes: [],
45
- Parsed: [],
49
+ Events: {type: "FeatureCollection", features: [] as TypeEvent[]},
50
+ Nodes: {type: "FeatureCollection", features: [] as TypeNode[]},
51
+ Hashes: [] as TypeHash[],
52
+ Parsed: [] as TypeEvent[],
46
53
  UGC: new Map<string, string[]>()
47
54
  },
48
55
  Settings: {
49
- Database: path.join(process.cwd(), 'shapefiles.db'),
56
+ Timezone: "UTC",
57
+ Database: join(process.cwd(), 'shapefiles.db'),
58
+ DebugDisableAllEvents: false,
50
59
  EnableWireService: false,
51
60
  EnableDebugging: false,
52
61
  EnableJournal: true,
62
+ EnhancedEventJournaling: false,
53
63
  NOAAWeatherWireServiceSettings: {
54
64
  ReconnectionSettings: {
55
65
  Enabled: true,
56
66
  ReconnectionInterval: 60,
57
67
  },
58
68
  CredentialSettings: {
59
- Username: null,
60
- Password: null,
69
+ Username: null as string,
70
+ Password: null as string,
61
71
  Nickname: "@atmosx/event-product-parser/3.0",
62
72
  },
63
73
  CacheSettings: {
@@ -80,45 +90,52 @@ export const Bootstrap = {
80
90
  BroadcastifyDatabase: `https://scriptkitty.cafe/ftp/@atmosphericx/assets/broadcastify.json`,
81
91
  BroadcastifyTags: [`Ham`, `Air`, `Fire`, `Public Safety`, `Weather`, `EMS`, `Police`, `Rail`]
82
92
  },
93
+ BoundarySettings: {
94
+ BoundaryDatabase: `https://scriptkitty.cafe/ftp/@atmosphericx/assets/counties-10m.json`,
95
+ CityDatabase: `https://scriptkitty.cafe/ftp/@atmosphericx/assets/cities500.json`
96
+ },
83
97
  NotifyServer: {
84
98
  Enabled: false,
85
99
  Server: `https://ntfy.sh`,
86
- Timezone: "UTC",
87
100
  MediaStorage: {
88
- EAS: null,
89
- TEXT: null,
90
- JSON: null,
101
+ AUDIO: null as string,
102
+ TEXT: null as string,
103
+ JSON: null as string,
104
+ IMAGE: null as string
91
105
  },
92
106
  Credentials: {
93
- Username: null,
94
- Password: null
107
+ Username: null as string,
108
+ Password: null as string
95
109
  }
96
110
  },
97
- ActionSettings: [],
111
+ ActionSettings: [] as TypeActions[],
98
112
  GlobalSettings: {
99
113
  EventManagement: true,
100
114
  DisableGeometryParsing: false,
101
115
  UseShapefileCoordinates: true,
102
116
  SPCWatchesOnly: true,
103
- ShapefileSkipPoints: 15,
117
+ CensusPopulationData: true,
104
118
  NodeTTL: 60,
105
119
  NodeMaxDistance: 120,
106
120
  EventFiltering: {
107
- ListeningEvents: [],
108
- ListeningICAO: [],
109
- ListeningUGC: [],
110
- ListeningStates: [],
111
- IgnoredICAO: [],
121
+ ListeningEvents: [] as string[],
122
+ ListeningICAO: [] as string[],
123
+ ListeningUGC: [] as string[],
124
+ ListeningStates: [] as string[],
125
+ IgnoredICAO: [] as string[],
112
126
  IgnoredEvents: [`Test Message`],
113
127
  NodeLocationFiltering: false,
114
128
  IgnoreTestProducts: true,
115
129
  },
130
+ Themes: EnumThemes,
116
131
  ArchiveSettings: {
117
132
  TTL: 60,
118
- JSONDirectory: null,
119
- TextDirectory: null,
120
- EasDirectory: null,
121
- EasToneout: null
133
+ ImageDirectory: `Archive/Images` as string,
134
+ JSONDirectory: `Archive/Products` as string,
135
+ TextDirectory: `Archive/Text` as string,
136
+ AudioDirectory: `Archive/Audio` as string,
137
+ Logo: null as string,
138
+ AudioToneout: null as string
122
139
  }
123
140
  }
124
141
  },
@@ -11,20 +11,20 @@
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 { TypeStanzaCompiled } from "types/StanzaCompiled"
21
- import { TypeSettings } from "types/Settings"
22
- import { Bootstrap } from "@bootstrap"
23
- import { ParseText } from "@events/ParseText"
24
- import { ParseUGC } from "@events/ParseUGC"
25
- import { ParseVTEC } from "@events/ParseVTEC"
26
- import { ParseAPI } from "@events/ParseAPI"
27
- import { ValidateEvents } from "@manager/ValidateEvents"
20
+ import { TypeStanzaCompiled } from "Types/StanzaCompiled"
21
+ import { TypeSettings } from "Types/Settings"
22
+ import { Bootstrap } from "@Bootstrap"
23
+ import { ParseText } from "@Events/ParseText"
24
+ import { ParseUGC } from "@Events/ParseUGC"
25
+ import { ParseVTEC } from "@Events/ParseVTEC"
26
+ import { ParseAPI } from "@Events/ParseAPI"
27
+ import { ValidateEvents } from "@Manager/ValidateEvents"
28
28
 
29
29
  export const CreateEvent = async (Stanza: TypeStanzaCompiled): Promise<void | string> => {
30
30
  const settings = Bootstrap.Settings as TypeSettings
@@ -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,17 +11,18 @@
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 { TypeEvent } from "types-lower/Event"
21
- import { Bootstrap } from "@bootstrap"
22
- import { EnumStates } from "@enums/States"
23
- import { EnumExpressions } from "@enums/Expressions"
24
- import { GetLatestIssuance } from "@utilities/GetLatestIssuance"
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { EnumStates } from "@Enums/States"
22
+ import { Bootstrap } from "@Bootstrap"
23
+ import { EnumExpressions } from "@Enums/Expressions"
24
+ import { GetLatestIssuance } from "@Utilities/GetLatestIssuance"
25
+ import { CreateQuery } from "@Database/CreateQuery"
25
26
 
26
27
  interface GetEventAttachmentsResponse {
27
28
  name: string
@@ -64,14 +65,15 @@ export const GetEventAttachments = (event: TypeEvent): GetEventAttachmentsRespon
64
65
  const lines = [`Northern`, `Southern`, `Eastern`, `Western`, `Inland`, `Costal`, `County`]
65
66
  const county = location?.split(',')[0]?.trim().replace(new RegExp(`^(${lines.join('|')}) `), '')
66
67
  const state = EnumStates[location?.split(',')[1]?.trim()]
67
- const feeds = Bootstrap.Database.prepare(`SELECT * FROM broadcastify WHERE state = ? AND county = ?`).all(state, county).sort((a, b) => {
68
+ const feeds = CreateQuery({ Query: `SELECT * FROM broadcastify WHERE state = ? AND county = ?`, Parameters: [state, county] }) as BroadcastifyResponse[];
69
+ const so = feeds.sort((a: BroadcastifyResponse, b: BroadcastifyResponse) => {
68
70
  const typeOrder = ['Other', 'Public Safety'];
69
71
  const indexA = typeOrder.indexOf(a.type);
70
72
  const indexB = typeOrder.indexOf(b.type);
71
73
  return indexA - indexB;
72
- })
74
+ });
73
75
  const tags = Bootstrap.Settings.BroadcastifySettings.BroadcastifyTags;
74
- const filtered = feeds.filter((feed: BroadcastifyResponse) => tags.includes(feed.type));
76
+ const filtered = so.filter((feed: BroadcastifyResponse) => tags.includes(feed.type));
75
77
  if (filtered.length > 0) {
76
78
  filtered.map((filtered: BroadcastifyResponse) => {
77
79
  if (!attachments.some((a) => a.link === filtered.link)) {
@@ -0,0 +1,28 @@
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: https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Independent Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ export const GetEventDirection = (message: string): string | null => {
21
+ const direction = message
22
+ .replace(/\s+/g, ' ')
23
+ .match(/moving\s+(north|south|east|west|northeast|northwest|southeast|southwest)\s+at\s+(\d+)\s+mph/i);
24
+ if (direction) {
25
+ return direction[1].charAt(0).toUpperCase() + direction[1].slice(1).toLowerCase() + ` @ ${direction[2]} MPH`;
26
+ }
27
+ return null;
28
+ };
@@ -11,19 +11,18 @@
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 { TypeEvent } from "types-lower/Event"
21
- import { EnumEnhanced } from "@enums/Enhanced"
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { EnumEnhanced } from "@Enums/Enhanced"
22
22
 
23
23
  export const GetEventEnhancedName = (event: TypeEvent): string => {
24
24
  let name = event?.properties?.event;
25
-
26
- const damage = event?.properties?.parameters?.damage_threat
25
+ const damage = event?.properties?.parameters?.damage_threat ?? event?.properties?.parameters?.flood_threat
27
26
  const tornado = event?.properties?.parameters?.tornado_threat;
28
27
  const pdswatch = event?.properties?.watch_parameters?.pds_watch;
29
28
  const description = event?.properties?.description?.toLowerCase()
@@ -11,32 +11,38 @@
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 { TypeSettings } from "types/Settings"
21
- import { TypeEvent } from "types-lower/Event"
22
- import { GetSettings } from "@utilities/GetSettings"
23
- import { getZonePolygon } from "@parsers/ugc/GetZonePolygon"
20
+ import { TypeSettings } from "Types/Settings"
21
+ import { TypeEvent } from "StaticTypes/Event"
22
+ import { Bootstrap } from "@Bootstrap"
23
+ import { GetZonePolygon } from "@ParsingUGC/GetZonePolygon"
24
24
 
25
- interface GetGeometryResponse {
25
+ interface GetEventGeometryOptions {
26
+ Event: TypeEvent
27
+ Union?: boolean
28
+ }
29
+
30
+ interface GetEventGeometryResponse {
26
31
  type: `Polygon` | `MultiPolygon`
27
32
  coordinates: any[]
28
33
  }
29
34
 
30
- export const GetEventGeometry = (event: TypeEvent): GetGeometryResponse => {
31
- const settings = GetSettings() as TypeSettings
32
- const generated = event?.properties?.geocode?.polygon ?? null;
33
- const ugc = event?.properties?.geocode?.ugc ?? null;
34
- let geo: GetGeometryResponse = {
35
+ export const GetEventGeometry = ({ Event, Union }: GetEventGeometryOptions): GetEventGeometryResponse => {
36
+ const { properties } = Event;
37
+ const settings = Bootstrap.Settings as TypeSettings
38
+ const generated = properties?.geocode?.polygon ?? null;
39
+ const ugc = properties?.geocode?.ugc ?? null;
40
+ let geo: GetEventGeometryResponse = {
35
41
  type: `Polygon`,
36
42
  coordinates: generated != null ? JSON.parse(Buffer.from(generated, 'base64').toString('utf-8')) : null
37
43
  }
38
44
  if (settings.GlobalSettings.UseShapefileCoordinates && generated == null && ugc != null) {
39
- geo = getZonePolygon({Zones: ugc, Union: false})
45
+ geo = GetZonePolygon({Zones: ugc, Union: Union ?? false});
40
46
  if (geo == null) {
41
47
  geo = {
42
48
  type: `Polygon`,
@@ -11,14 +11,14 @@
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 { TypeVTEC } from "types/VTEC"
21
- import { TypeEventProperties } from "types-lower/Properties"
20
+ import { TypeVTEC } from "Types/VTEC"
21
+ import { TypeEventProperties } from "StaticTypes/Properties"
22
22
 
23
23
  interface GetHeaderOptions {
24
24
  Properties: TypeEventProperties
@@ -11,16 +11,16 @@
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 { TypeEvent } from "types-lower/Event"
21
- import { Bootstrap } from "@bootstrap"
22
- import { GetEventGeometry } from "@building/GetEventGeometry"
23
- import { GetShapeNearestPoint } from "@utilities/GetShapeNearestPoint"
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { Bootstrap } from "@Bootstrap"
22
+ import { GetEventGeometry } from "@Building/GetEventGeometry"
23
+ import { GetShapeNearestPoint } from "@Utilities/GetShapeNearestPoint"
24
24
 
25
25
  interface GetEventNodesResponse {
26
26
  nodes: {
@@ -40,30 +40,32 @@ export const GetEventNodes = async (event: TypeEvent): Promise<GetEventNodesResp
40
40
  if (!nodes || nodes.length === 0) {
41
41
  return { nodes: [], filtered: false, updated: Date.now() };
42
42
  }
43
- const metadata = { nodes: [], proximity: false, filtered: false };
44
- const geometry = await GetEventGeometry(event);
43
+ const metadata = { nodes: [] as GetEventNodesResponse['nodes'], proximity: false, filtered: false };
44
+ const geometry = await GetEventGeometry({ Event: event });;
45
45
  if (!geometry || !geometry.coordinates) {
46
46
  return { nodes: [], filtered: false, updated: Date.now() }
47
47
  }
48
48
  for (const node of nodes) {
49
- const [longitude, latitude] = node.geometry.coordinates;
49
+ const [longitude, latitude] = (node?.geometry?.coordinates ?? []) as [number, number];
50
+
50
51
  const getPoint = GetShapeNearestPoint({ Coordinates: geometry.coordinates, Point: [longitude, latitude] });
51
52
  const miles = getPoint.Distance ?? null;
52
- const kilometers = Number((miles * 1.609344).toFixed(3));
53
+ const kilometers = miles != null ? Number((miles * 1.609344).toFixed(3)) : null;
53
54
 
54
55
  const info = {
55
56
  id: node.properties?.identifier,
56
- coordinates: [longitude, latitude],
57
- nearest: getPoint.Point,
57
+ coordinates: [longitude, latitude] as [number, number],
58
+ nearest: getPoint.Point as [number, number],
58
59
  miles,
59
60
  kilometers,
60
61
  proximity: false
61
- }
62
+ };
63
+
62
64
  if (miles != null && (miles < Bootstrap.Settings.GlobalSettings.NodeMaxDistance)) {
63
65
  info.proximity = true;
64
66
  metadata.proximity = true;
65
67
  }
66
- metadata.nodes.push(info)
68
+ metadata.nodes.push(info);
67
69
  }
68
70
  return {
69
71
  nodes: metadata.nodes,
@@ -11,15 +11,15 @@
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"
21
- import { TypeVTEC } from "types/VTEC"
22
- import { EnumICAO } from "@enums/ICAO"
20
+ import { TypeAttributes } from "StaticTypes/Attributes"
21
+ import { TypeVTEC } from "Types/VTEC"
22
+ import { EnumICAO } from "@Enums/ICAO"
23
23
 
24
24
  interface GetOfficeOptions {
25
25
  Attributes: TypeAttributes
@@ -0,0 +1,58 @@
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: https://atmosphericx.scriptkitty.cafe/documentation
15
+
16
+ Independent Package: @atmosx/event-product-parser
17
+
18
+ */
19
+
20
+ import { TypeCities } from "StaticTypes/Properties"
21
+ import { Bootstrap } from "@Bootstrap"
22
+ import { CreateQuery } from "@Database/CreateQuery"
23
+ import { NormalizePolygon } from "@ImageModules/NormalizePolygon"
24
+
25
+ interface GetEventPopulationResponse {
26
+ population: number
27
+ cities: TypeCities[]
28
+ }
29
+
30
+ export const GetEventPopulation = (geometry: GeoJSON.Polygon | GeoJSON.MultiPolygon | null): GetEventPopulationResponse => {
31
+ const coordinates = geometry?.coordinates;
32
+ if (!coordinates || !Array.isArray(coordinates) || coordinates.length === 0 || !Bootstrap.Settings.GlobalSettings.CensusPopulationData) {
33
+ return { population: 0, cities: [] };
34
+ }
35
+ const normalized = NormalizePolygon(geometry) as GeoJSON.Polygon | GeoJSON.MultiPolygon;
36
+ const points = normalized.type === `Polygon` ? normalized.coordinates[0] : normalized.coordinates.flatMap(polygon => polygon[0]);
37
+ const latitudes = points.map(([lon, lat]) => lat);
38
+ const longitudes = points.map(([lon, lat]) => lon);
39
+ const minLat = Math.min(...latitudes);
40
+ const maxLat = Math.max(...latitudes);
41
+ const minLon = Math.min(...longitudes);
42
+ const maxLon = Math.max(...longitudes);
43
+ const A = CreateQuery({
44
+ Query: `SELECT * FROM cities WHERE LAT BETWEEN ? AND ? AND LON BETWEEN ? AND ?`,
45
+ Parameters: [ minLat, maxLat, minLon, maxLon ]
46
+ });
47
+ const population = A.reduce((acc: number, city: any) => {
48
+ const census = Number(city.population);
49
+ return acc + (isNaN(census) ? 0 : census);
50
+ }, 0);
51
+ const cities = A.map((city: any) => ({
52
+ name: city.name,
53
+ state: city.state,
54
+ county: city.county.replace(/ County$/i, ``),
55
+ population: Number(city.population)
56
+ }));
57
+ return { population, cities };
58
+ }
@@ -11,23 +11,23 @@
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 { TypeEventProperties } from "types-lower/Properties"
21
- import { TypeAttributes } from "types-lower/Attributes"
22
- import { TypeUGC } from "types/UGC"
23
- import { TypeVTEC } from "types/VTEC"
24
- import { TypeHVTEC } from "types/HVTEC"
25
- import { EnumExpressions } from "@enums/Expressions"
26
- import { GetDescriptionFromProduct } from "@parsers/text/GetDescriptionFromProduct"
27
- import { getPolygonFromProduct } from "@parsers/text/GetPolygonFromProduct"
28
- import { GetTextFromProduct } from "@parsers/text/GetTextFromProduct"
29
- import { GetEventOffice } from "@building/GetEventOffice"
30
- import { GetEventTags } from "@building/GetEventTags"
20
+ import { TypeEventProperties } from "StaticTypes/Properties"
21
+ import { TypeAttributes } from "StaticTypes/Attributes"
22
+ import { TypeUGC } from "Types/UGC"
23
+ import { TypeVTEC } from "Types/VTEC"
24
+ import { EnumExpressions } from "@Enums/Expressions"
25
+ import { GetDescriptionFromProduct } from "@ParsingText/GetDescriptionFromProduct"
26
+ import { GetPolygonFromProduct } from "@ParsingText/GetPolygonFromProduct"
27
+ import { GetTextFromProduct } from "@ParsingText/GetTextFromProduct"
28
+ import { GetEventOffice } from "@Building/GetEventOffice"
29
+ import { GetEventTags } from "@Building/GetEventTags"
30
+ import { GetEventDirection } from "@Building/GetEventDirection"
31
31
 
32
32
  interface GetEventPropertiesOptions {
33
33
  Message: string
@@ -36,24 +36,28 @@ interface GetEventPropertiesOptions {
36
36
  VTEC?: TypeVTEC
37
37
  }
38
38
 
39
-
40
39
  export const GetEventProperties = ({ Message, Attributes, UGC, VTEC }: GetEventPropertiesOptions): TypeEventProperties => {
41
40
  const organization = Message.match(EnumExpressions.wmo)?.[0] ?? null
42
- const polygons = getPolygonFromProduct(Message)
41
+ const polygons = GetPolygonFromProduct(Message)
43
42
  const properties = {
44
43
  locations: UGC?.Locations?.join(`; `) ?? null,
45
44
  locations_array: UGC?.Locations ?? [],
46
- location_states: [...new Set(
47
- UGC?.Locations
48
- ?.map((location: string) => location.match(/,\s*([A-Z]{2})\b/)?.[1])
45
+ regions: [...new Set(
46
+ UGC?.Zones
47
+ ?.map((location: string) => location.match(/^([A-Z]{2})[CZ](\d{3})$/)?.[1])
49
48
  .filter(Boolean) ?? []
50
49
  )],
50
+ regions_string: (() => {
51
+ const abbrs = [...new Set(UGC?.Zones?.map((l: string) => l.match(/^([A-Z]{2})[CZ](\d{3})$/)?.[1]).filter(Boolean) ?? [])];
52
+ return abbrs.length ? abbrs.join(`-`) : null;
53
+ })(),
51
54
  description: GetDescriptionFromProduct({ Message: Message, Handle: VTEC?.Raw ?? null }),
52
55
  attributes: Attributes,
53
56
  geocode: {
54
57
  office: GetEventOffice({ Attributes: Attributes, Organization: organization, VTEC: VTEC }),
55
58
  organization: organization,
56
59
  ugc: UGC?.Zones ?? [],
60
+ census: {},
57
61
  polygon: polygons.length > 0 ? Buffer.from(JSON.stringify([polygons])).toString('base64') : null,
58
62
  polygon_generated: polygons.length > 0 ? true : false
59
63
  },
@@ -65,6 +69,7 @@ export const GetEventProperties = ({ Message, Attributes, UGC, VTEC }: GetEventP
65
69
  impacts: GetTextFromProduct({ Message: Message, Find: [`IMPACT...`], Removal: [`.`]}) ?? null,
66
70
  estimated_hail_size: GetTextFromProduct({ Message: Message, Find: [`MAX HAIL SIZE...`, `HAIL...`], Removal: ['in']}) ?? null,
67
71
  estimated_wind_gusts: GetTextFromProduct({ Message: Message, Find: [`MAX WIND GUST...`, `WIND...`]}) ?? null,
72
+ direction: GetEventDirection(Message) ?? null,
68
73
  damage_threat: GetTextFromProduct({ Message: Message, Find: [`DAMAGE THREAT...`], Removal: []}) ?? null,
69
74
  tornado_threat: GetTextFromProduct({ Message: Message, Find: [`TORNADO...`, `WATERSPOUT...`] }) ?? null,
70
75
  flood_threat: GetTextFromProduct({ Message: Message, Find: [`FLASH FLOOD...`]}) ?? null,