@atmosx/event-product-parser 3.0.6 → 3.0.7

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 (181) hide show
  1. package/.github/docs/docs-functions.md +2 -2
  2. package/.github/docs/docs-general-configurations.md +2 -12
  3. package/.github/docs/docs-integrations.md +4 -3
  4. package/.github/docs/docs-listeners.md +1 -1
  5. package/.github/docs/docs-source-configuration.md +1 -1
  6. package/.github/docs/docs-technical.md +1 -1
  7. package/{.github/README.md → README.md} +15 -9
  8. package/dist/cjs/index.cjs +24073 -7018
  9. package/dist/esm/index.mjs +24035 -6983
  10. package/package.json +56 -47
  11. package/pnpm-workspace.yaml +4 -0
  12. package/src/bootstrap.ts +64 -48
  13. package/src/{@building → building}/CreateEvent.ts +22 -24
  14. package/src/{@building → building}/GetCleanedEvent.ts +2 -2
  15. package/src/{@building → building}/GetEventAttachments.ts +14 -12
  16. package/src/building/GetEventDirection.ts +28 -0
  17. package/src/{@building → building}/GetEventEnhancedName.ts +5 -8
  18. package/src/{@building → building}/GetEventGeometry.ts +19 -13
  19. package/src/{@building → building}/GetEventHeader.ts +13 -13
  20. package/src/{@building → building}/GetEventNodes.ts +21 -19
  21. package/src/{@building → building}/GetEventOffice.ts +13 -13
  22. package/src/building/GetEventProperties.ts +105 -0
  23. package/src/{@building → building}/GetEventSignature.ts +9 -9
  24. package/src/{@building → building}/GetEventTags.ts +3 -3
  25. package/src/building/GetEventTheme.ts +26 -0
  26. package/src/building/GetEventTracking.ts +64 -0
  27. package/src/components/audio/GenerateAudioMessage.ts +149 -0
  28. package/src/{@modules/@eas → components/audio/components}/GetCleanDescription.ts +2 -2
  29. package/src/{@modules/@eas → components/audio/components}/GetFloatPCM16.ts +2 -2
  30. package/src/{@modules/@eas → components/audio/components}/GetMergedPCM16.ts +2 -2
  31. package/src/{@modules/@eas → components/audio/components}/GetPCM16.ts +13 -8
  32. package/src/{@modules/@eas → components/audio/components}/GetPCMToFloat.ts +2 -2
  33. package/src/{@modules/@eas → components/audio/components}/GetSampledPCM16.ts +14 -8
  34. package/src/{@modules/@eas → components/audio/components}/GetTTS.ts +17 -10
  35. package/src/{@modules/@eas → components/audio/components}/GetWavPCM16.ts +7 -7
  36. package/src/{@modules/@eas → components/audio/components}/SetAFSK.ts +13 -8
  37. package/src/{@modules/@eas → components/audio/components}/SetAsciiToBits.ts +2 -2
  38. package/src/{@modules/@eas → components/audio/components}/SetAttentionTone.ts +11 -6
  39. package/src/{@modules/@eas → components/audio/components}/SetNoise.ts +12 -7
  40. package/src/{@modules/@eas → components/audio/components}/SetRadioEffect.ts +12 -7
  41. package/src/{@modules/@eas → components/audio/components}/SetSameHeader.ts +22 -14
  42. package/src/{@modules/@utilities/SetWarning.ts → components/database/CreateQuery.ts} +18 -13
  43. package/src/{@modules/@database → components/database}/GetCachedEvents.ts +18 -15
  44. package/src/components/database/ImportBoundaries.ts +168 -0
  45. package/src/{@modules/@database → components/database}/ImportBroadcastify.ts +14 -24
  46. package/src/components/database/ImportCities.ts +87 -0
  47. package/src/{@modules/@database → components/database}/ImportShapefiles.ts +23 -26
  48. package/src/{@modules/@database → components/database}/ImportStanza.ts +15 -19
  49. package/src/components/database/InitializeDatabase.ts +71 -0
  50. package/src/components/images/GenerateGraphic.ts +234 -0
  51. package/src/components/images/components/CreateRectangle.ts +22 -0
  52. package/src/components/images/components/CreateText.ts +22 -0
  53. package/src/components/images/modules/CreateSVG.ts +37 -0
  54. package/src/components/images/modules/GetGeographicalBoundaries.ts +72 -0
  55. package/src/components/images/modules/GetGeographicalCities.ts +58 -0
  56. package/src/components/images/modules/GetGeographicalEvents.ts +48 -0
  57. package/src/components/images/modules/GetGeometryBounds.ts +82 -0
  58. package/src/components/images/modules/GetParsedBoundary.ts +58 -0
  59. package/src/components/images/modules/GetSVGPath.ts +53 -0
  60. package/src/components/images/modules/NormalizePolygon.ts +57 -0
  61. package/src/{@modules/@stanza → components/stanza}/GetAwipsType.ts +16 -17
  62. package/src/{@modules/@stanza → components/stanza}/ValidateStanza.ts +27 -15
  63. package/src/{@modules/@utilities → components/utilities}/CreateHttp.ts +26 -26
  64. package/src/{@modules/@utilities → components/utilities}/GetFormattedTime.ts +2 -2
  65. package/src/{@modules/@utilities → components/utilities}/GetLatestIssuance.ts +2 -2
  66. package/src/{@modules/@utilities → components/utilities}/GetMatched.ts +10 -5
  67. package/src/{@modules/@utilities → components/utilities}/GetShapeNearestPoint.ts +24 -19
  68. package/src/components/utilities/GetUnionPolygon.ts +36 -0
  69. package/src/components/utilities/QueueManager.ts +70 -0
  70. package/src/{@modules/@utilities → components/utilities}/SetCronSchedule.ts +29 -25
  71. package/src/{@modules/@utilities → components/utilities}/SetDebug.ts +12 -12
  72. package/src/components/utilities/SetEventEmit.ts +42 -0
  73. package/src/{@modules/@utilities → components/utilities}/SetSettings.ts +7 -7
  74. package/src/{@modules/@utilities → components/utilities}/SetSleep.ts +5 -5
  75. package/src/components/utilities/SetTimeoutAction.ts +64 -0
  76. package/src/components/utilities/SetWarning.ts +47 -0
  77. package/src/{@modules/@xmpp → components/xmpp}/DeployXMPP.ts +20 -20
  78. package/src/{@core/CreateListener.ts → components/xmpp/ErrorXMPP.ts} +8 -5
  79. package/src/{@modules/@xmpp → components/xmpp}/OfflineXMPP.ts +13 -13
  80. package/src/{@modules/@xmpp → components/xmpp}/OnlineXMPP.ts +18 -18
  81. package/src/components/xmpp/ReconnectXMPP.ts +64 -0
  82. package/src/{@modules/@xmpp → components/xmpp}/StanzaXMPP.ts +25 -25
  83. package/src/{@core → core}/ClearEvents.ts +9 -9
  84. package/src/{@core → core}/GetEvents.ts +4 -4
  85. package/src/{@core → core}/GetNodes.ts +4 -4
  86. package/src/{@core → core}/GetRandomEvent.ts +4 -4
  87. package/src/{@core → core}/GetVersion.ts +4 -4
  88. package/src/{@core → core}/ManualEvent.ts +23 -24
  89. package/src/{@core → core}/QueryStanza.ts +12 -11
  90. package/src/core/SetNode.ts +87 -0
  91. package/src/{@core → core}/StartService.ts +21 -20
  92. package/src/{@core → core}/StopService.ts +10 -10
  93. package/src/{@enums → enums}/AWIPS.ts +2 -2
  94. package/src/{@enums → enums}/Actions.ts +2 -2
  95. package/src/{@enums → enums}/Cancellation.ts +2 -2
  96. package/src/{@enums → enums}/Causes.ts +2 -2
  97. package/src/{@enums → enums}/Correlations.ts +2 -2
  98. package/src/{@enums → enums}/Enhanced.ts +2 -2
  99. package/src/{@enums → enums}/Events.ts +2 -2
  100. package/src/{@enums → enums}/Expressions.ts +3 -3
  101. package/src/{@enums → enums}/GlobalFilter.ts +2 -2
  102. package/src/{@enums → enums}/Hail.ts +2 -2
  103. package/src/{@enums → enums}/ICAO.ts +2 -2
  104. package/src/{@enums → enums}/Matches.ts +8 -3
  105. package/src/{@enums → enums}/Products.ts +2 -2
  106. package/src/{@enums → enums}/Records.ts +2 -2
  107. package/src/{@enums → enums}/Severity.ts +2 -2
  108. package/src/{@enums → enums}/Shapefiles.ts +2 -2
  109. package/src/{@enums → enums}/States.ts +68 -4
  110. package/src/{@enums → enums}/Status.ts +2 -2
  111. package/src/{@enums → enums}/Strings.ts +2 -2
  112. package/src/{@enums → enums}/Tags.ts +9 -4
  113. package/src/{@enums → enums}/Testing.ts +2 -2
  114. package/src/enums/Themes.ts +70 -0
  115. package/src/events/ParseAPI.ts +129 -0
  116. package/src/{@events → events}/ParseText.ts +24 -22
  117. package/src/{@events → events}/ParseUGC.ts +27 -26
  118. package/src/{@events → events}/ParseVTEC.ts +38 -37
  119. package/src/index.ts +57 -37
  120. package/src/manager/MakeEvents.ts +110 -0
  121. package/src/manager/RemoveEvent.ts +74 -0
  122. package/src/{@manager → manager}/SetHash.ts +18 -13
  123. package/src/{@manager → manager}/UpdateEvents.ts +12 -12
  124. package/src/{@manager → manager}/UpdateNode.ts +14 -14
  125. package/src/{@building → manager}/ValidateEvents.ts +47 -57
  126. package/src/{@parsers/@hvtec → parsers/hvtec}/HVExtract.ts +11 -11
  127. package/src/{@parsers/@text → parsers/text}/GetDescriptionFromProduct.ts +20 -21
  128. package/src/{@parsers/@text → parsers/text}/GetEmbededText.ts +7 -6
  129. package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
  130. package/src/{@parsers/@text → parsers/text}/GetStringText.ts +9 -9
  131. package/src/{@parsers/@text → parsers/text}/GetTextFromProduct.ts +12 -12
  132. package/src/parsers/ugc/GetCache.ts +24 -0
  133. package/src/{@parsers/@ugc → parsers/ugc}/GetExpiry.ts +2 -2
  134. package/src/{@parsers/@ugc/GetUGCHeader.ts → parsers/ugc/GetHeader.ts} +4 -4
  135. package/src/{@parsers/@ugc → parsers/ugc}/GetLocations.ts +10 -10
  136. package/src/parsers/ugc/GetZonePolygon.ts +73 -0
  137. package/src/{@parsers/@ugc → parsers/ugc}/GetZones.ts +3 -3
  138. package/src/{@parsers/@ugc → parsers/ugc}/SetCache.ts +13 -8
  139. package/src/{@parsers/@ugc → parsers/ugc}/UGCExtract.ts +14 -14
  140. package/src/{@parsers/@pvtec → parsers/vtec}/GetExpiry.ts +2 -2
  141. package/src/parsers/vtec/VTECExtract.ts +49 -0
  142. package/src/{@types → static}/Attributes.ts +2 -3
  143. package/src/{@types → static}/Event.ts +8 -7
  144. package/src/{@types → static}/Properties.ts +7 -3
  145. package/src/{@types → static}/Stanza.ts +2 -2
  146. package/src/tasks/CreateTasks.ts +123 -0
  147. package/src/tasks/TaskGenerateJSON.ts +34 -0
  148. package/src/tasks/TaskGenerateText.ts +34 -0
  149. package/src/tasks/TaskSendNTFY.ts +97 -0
  150. package/src/tasks/TaskSendWebhook.ts +107 -0
  151. package/src/{@types → types}/Actions.ts +3 -3
  152. package/src/{@types → types}/HVTEC.ts +6 -6
  153. package/src/{@types → types}/Hash.ts +5 -5
  154. package/src/types/Nodes.ts +29 -0
  155. package/src/{@types → types}/Settings.ts +16 -8
  156. package/src/{@types → types}/StanzaCompiled.ts +15 -15
  157. package/src/{@types → types}/UGC.ts +5 -5
  158. package/src/{@modules/@utilities/GetSettings.ts → types/VTEC.ts} +12 -7
  159. package/tools/build.js +47 -0
  160. package/tsconfig.json +28 -1
  161. package/src/@building/GetEventProperties.ts +0 -96
  162. package/src/@building/GetEventTracking.ts +0 -68
  163. package/src/@core/SetNode.ts +0 -81
  164. package/src/@events/ParseAPI.ts +0 -117
  165. package/src/@manager/CreateActions.ts +0 -213
  166. package/src/@manager/MakeEvent.ts +0 -99
  167. package/src/@manager/RemoveEvent.ts +0 -70
  168. package/src/@modules/@database/InitializeDatabase.ts +0 -59
  169. package/src/@modules/@eas/GenerateEASMessage.ts +0 -144
  170. package/src/@modules/@utilities/SetEventEmit.ts +0 -41
  171. package/src/@modules/@utilities/SetListener.ts +0 -30
  172. package/src/@modules/@utilities/SetTimeoutAction.ts +0 -64
  173. package/src/@modules/@xmpp/ErrorXMPP.ts +0 -27
  174. package/src/@modules/@xmpp/ReconnectXMPP.ts +0 -64
  175. package/src/@parsers/@pvtec/VTECExtract.ts +0 -49
  176. package/src/@parsers/@text/GetPolygonFromProduct.ts +0 -53
  177. package/src/@parsers/@text/GetXML.ts +0 -61
  178. package/src/@parsers/@ugc/GetCache.ts +0 -24
  179. package/src/@parsers/@ugc/GetZonePolygon.ts +0 -111
  180. package/src/@types/VTEC.ts +0 -30
  181. package/tsup.config.ts +0 -16
@@ -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 { TypeEvent } from "../../@types/Event"
20
+ import { TypeEvent } from "StaticTypes/Event"
21
21
 
22
- export const GetEmebedText = (event: TypeEvent): string => {
22
+ export const GetEmbededText = (event: TypeEvent): string => {
23
23
  const line = (label: string, value: unknown, condition = true) => condition && value ? `${label} ${value}` : null;
24
24
  const isStatement = event.properties.status_metadata.is_statement;
25
25
  const isExpired = event.properties.status_metadata.is_expired;
@@ -30,8 +30,9 @@ export const GetEmebedText = (event: TypeEvent): string => {
30
30
  line(`**Damage Threat:**`, event?.properties?.parameters?.damage_threat, !isExpired),
31
31
  line(`**Flood Threat:**`, event?.properties?.parameters?.flood_threat, !isExpired),
32
32
  line(`**Tornado Threat:**`, event?.properties?.parameters?.tornado_threat, !isExpired),
33
- line(`**Estimated Wind Gusts:**`, `${event?.properties?.parameters?.estimated_wind_gusts} ${event?.properties?.parameters?.wind_threat ? ` (${event?.properties?.parameters?.wind_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_wind_gusts != null),
34
- line(`**Estimated Hail Size:**`, `${event?.properties?.parameters?.estimated_hail_size} ${event?.properties?.parameters?.hail_threat ? ` (${event?.properties?.parameters?.hail_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_hail_size != null),
33
+ line(`**Wind Gusts:**`, `${event?.properties?.parameters?.estimated_wind_gusts} ${event?.properties?.parameters?.wind_threat ? ` (${event?.properties?.parameters?.wind_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_wind_gusts != null),
34
+ line(`**Hail Size:**`, `${event?.properties?.parameters?.estimated_hail_size} ${event?.properties?.parameters?.hail_threat ? ` (${event?.properties?.parameters?.hail_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_hail_size != null),
35
+ line(`**Direction:**`, event?.properties?.parameters?.direction, !isExpired && event?.properties?.parameters?.direction != null),
35
36
  line(`**Discussion:**`, event?.properties?.discussion_parameters?.discussion_number, !isExpired),
36
37
  line(`**Concern:**`, event?.properties?.discussion_parameters?.discussion_concerning, !isExpired),
37
38
  line(`**SPC Max Tornado Threat:**`, event?.properties?.discussion_parameters?.discussion_max_tornado, !isExpired),
@@ -0,0 +1,71 @@
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 GetPolygonFromProduct = (message: string): number[][] => {
21
+ const coordinates: number[][] = [];
22
+ const match = message.match(
23
+ /LAT\.\.\.LON\s+([\s\S]*?)(?=\n\s*(?:TIME\.\.\.MOT\.\.\.LOC|\$\$|[A-Za-z]|$))/i
24
+ );
25
+ if (!match) return coordinates;
26
+ const text = match[1]
27
+ .split(/\r?\n/).map(l => l.trim())
28
+ .filter(l => l && !/[A-Za-z]/.test(l))
29
+ .join(' ').trim();
30
+ if (!text) return coordinates;
31
+ const values = text.match(/\d{4,8}/g);
32
+ if (!values || values.length === 0) return coordinates;
33
+ const points: { lat: number; lon: number }[] = [];
34
+ if (values.every(v => v.length === 8)) {
35
+ for (const value of values) {
36
+ const lat = parseInt(value.slice(0, 4), 10) / 100;
37
+ let lon = parseInt(value.slice(4, 8), 10) / 100;
38
+ if (lon < 20) lon += 100;
39
+ points.push({ lat, lon });
40
+ }
41
+ } else if (values.every(v => v.length === 4)) {
42
+ for (let i = 0; i + 1 < values.length; i += 2) {
43
+ const lat = parseInt(values[i], 10) / 100;
44
+ const lon = parseInt(values[i + 1], 10) / 100;
45
+ points.push({ lat, lon });
46
+ }
47
+ } else {
48
+ for (let i = 0; i + 1 < values.length; i += 2) {
49
+ const latStr = values[i];
50
+ const lonStr = values[i + 1];
51
+ if (latStr.length !== 4) continue;
52
+ if (lonStr.length < 4 || lonStr.length > 5) continue;
53
+ const lat = parseInt(latStr, 10) / 100;
54
+ let lon = parseInt(lonStr, 10) / 100;
55
+ points.push({ lat, lon });
56
+ }
57
+ }
58
+ if (points.length === 0) return coordinates;
59
+ const isEast = points.some(p => p.lon > 130 && p.lon < 180);
60
+ for (const p of points) {
61
+ const lon = isEast ? p.lon : -p.lon;
62
+ if (Number.isFinite(p.lat) && Number.isFinite(lon) && p.lat >= -90 && p.lat <= 90 && lon >= -180 && lon <= 180) {
63
+ coordinates.push([lon, p.lat]);
64
+ }
65
+ }
66
+ if (coordinates.length > 2 && (coordinates[0][0] !== coordinates[coordinates.length - 1][0] || coordinates[0][1] !== coordinates[coordinates.length - 1][1])) {
67
+ coordinates.push([...coordinates[0]]);
68
+ }
69
+
70
+ return coordinates;
71
+ };
@@ -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/Event"
21
- import { TypeSettings } from "../../@types/Settings";
22
- import { bootstrap } from "../../bootstrap";
20
+ import { TypeEvent } from "StaticTypes/Event"
21
+ import { TypeSettings } from "Types/Settings"
22
+ import { Bootstrap } from "@Bootstrap"
23
23
 
24
24
  export const GetStringText = (event: TypeEvent): string => {
25
- const settings = bootstrap.settings as TypeSettings;
26
- const timezone = settings.NotifyServer.Timezone ?? `UTC`;
25
+ const timezone = Bootstrap.Settings.Timezone ?? `UTC`;
27
26
  const line = (label: string, value: unknown, condition = true) => condition && value ? `${label} ${value}` : null;
28
27
  const isStatement = event.properties.status_metadata.is_statement;
29
28
  const isExpired = event.properties.status_metadata.is_expired;
@@ -34,8 +33,9 @@ export const GetStringText = (event: TypeEvent): string => {
34
33
  line(`Damage Threat:`, event?.properties?.parameters?.damage_threat, !isExpired),
35
34
  line(`Flood Threat:`, event?.properties?.parameters?.flood_threat, !isExpired),
36
35
  line(`Tornado Threat:`, event?.properties?.parameters?.tornado_threat, !isExpired),
37
- line(`Estimated Wind Gusts:`, `${event?.properties?.parameters?.estimated_wind_gusts} ${event?.properties?.parameters?.wind_threat ? ` (${event?.properties?.parameters?.wind_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_wind_gusts != null),
38
- line(`Estimated Hail Size:`, `${event?.properties?.parameters?.estimated_hail_size} ${event?.properties?.parameters?.hail_threat ? ` (${event?.properties?.parameters?.hail_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_hail_size != null),
36
+ line(`Wind Gusts:`, `${event?.properties?.parameters?.estimated_wind_gusts} ${event?.properties?.parameters?.wind_threat ? ` (${event?.properties?.parameters?.wind_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_wind_gusts != null),
37
+ line(`Hail Size:`, `${event?.properties?.parameters?.estimated_hail_size} ${event?.properties?.parameters?.hail_threat ? ` (${event?.properties?.parameters?.hail_threat})` : ''}`, !isExpired && event?.properties?.parameters?.estimated_hail_size != null),
38
+ line(`Direction:`, event?.properties?.parameters?.direction, !isExpired && event?.properties?.parameters?.direction != null),
39
39
  line(`Discussion:`, event?.properties?.discussion_parameters?.discussion_number, !isExpired),
40
40
  line(`Concern:`, event?.properties?.discussion_parameters?.discussion_concerning, !isExpired),
41
41
  line(`SPC Max Tornado Threat:`, event?.properties?.discussion_parameters?.discussion_max_tornado, !isExpired),
@@ -11,32 +11,32 @@
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
20
  interface GetTextFromProductOptions {
21
- message: string
22
- find: string[]
23
- append?: string
24
- removal?: string[]
21
+ Message: string
22
+ Find: string[]
23
+ Append?: string
24
+ Removal?: string[]
25
25
  }
26
26
 
27
- export const GetTextFromProduct = (options: GetTextFromProductOptions): string => {
28
- const lines = options.message.split(`\n`);
27
+ export const GetTextFromProduct = ({ Message, Find, Append, Removal }: GetTextFromProductOptions): string => {
28
+ const lines = Message.split(`\n`);
29
29
  for (const line of lines) {
30
- const matchedFind = options.find.find((find) => line.includes(find));
30
+ const matchedFind = Find.find((find) => line.includes(find));
31
31
  if (matchedFind) {
32
32
  let result = line.slice(line.indexOf(matchedFind) + matchedFind.length).trim();
33
- if (options.removal) {
34
- for (const str of options.removal) {
33
+ if (Removal) {
34
+ for (const str of Removal) {
35
35
  result = result.toLowerCase().split(str.toLowerCase()).join('');
36
36
  }
37
37
  result = result.replace(matchedFind, '').replace('<', '').trim();
38
38
  }
39
- return result.toUpperCase() + (options?.append ?? ``);
39
+ return result.toUpperCase() + (Append ?? ``);
40
40
  }
41
41
  }
42
42
  return null;
@@ -0,0 +1,24 @@
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 { Bootstrap } from "@Bootstrap"
21
+
22
+ export const GetCache = (key: string) => {
23
+ return Bootstrap.Cache.UGC.get(key);
24
+ };
@@ -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,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 { EnumExpressions } from "../../@enums/Expressions"
20
+ import { EnumExpressions } from "@Enums/Expressions"
21
21
 
22
- export const getUGCHeader = (message: string): string | null => {
22
+ export const GetHeader = (message: string): string | null => {
23
23
  const start = message.search(EnumExpressions.ugc1)
24
24
  const sub = message.substring(start)
25
25
  const end = sub.search(EnumExpressions.ugc2)
@@ -11,17 +11,17 @@
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 { bootstrap } from "../../bootstrap";
21
- import { getCache } from "./GetCache";
22
- import { setCache } from "./SetCache";
20
+ import { Bootstrap } from "@Bootstrap"
21
+ import { GetCache } from "@ParsingUGC/GetCache"
22
+ import { SetCache } from "@ParsingUGC/SetCache"
23
23
 
24
- export const getLocations = async (zones: string[]): Promise<string[]> => {
24
+ export const GetLocations = async (zones: string[]): Promise<string[]> => {
25
25
  const uniqueZones = Array.from(new Set(zones));
26
26
 
27
27
  const results: string[] = [];
@@ -29,7 +29,7 @@ export const getLocations = async (zones: string[]): Promise<string[]> => {
29
29
 
30
30
  for (let i = 0; i < uniqueZones.length; i++) {
31
31
  const zone = uniqueZones[i];
32
- const cached = getCache(zone);
32
+ const cached = GetCache(zone);
33
33
 
34
34
  if (cached) {
35
35
  for (let j = 0; j < cached.length; j++) {
@@ -41,7 +41,7 @@ export const getLocations = async (zones: string[]): Promise<string[]> => {
41
41
  }
42
42
 
43
43
  if (missing.length > 0) {
44
- const rows = await bootstrap.database
44
+ const rows = await Bootstrap.Database
45
45
  .prepare(
46
46
  `SELECT id, location FROM shapefiles WHERE id IN (${missing.map(() => '?').join(',')})`
47
47
  )
@@ -49,9 +49,9 @@ export const getLocations = async (zones: string[]): Promise<string[]> => {
49
49
 
50
50
  for (let i = 0; i < rows.length; i++) {
51
51
  const r = rows[i] as any;
52
- setCache(r.id, [r.location]);
52
+ SetCache({ Key: r.id, Value: [r.location] });
53
53
  results.push(r.location);
54
54
  }
55
55
  }
56
- return results;
56
+ return Array.from(new Set(results));
57
57
  };
@@ -0,0 +1,73 @@
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 { CreateQuery } from "@Database/CreateQuery"
21
+ import { GetUnionPolygon } from "@Utilities/GetUnionPolygon"
22
+ import { createHash } from "crypto";
23
+
24
+ interface CoordinatesOptions {
25
+ Zones: string[]
26
+ Union: boolean
27
+ }
28
+
29
+ interface CoordinatesResponse {
30
+ type: `Polygon` | `MultiPolygon`
31
+ coordinates: any[]
32
+ }
33
+
34
+ export const GetZonePolygon = ({ Zones, Union }: CoordinatesOptions): CoordinatesResponse | null => {
35
+ const list = [...new Set(Zones.map(z => z.trim()))].filter(z => z === 'XX000' ? false : true);
36
+ if (list.length === 0) return null;
37
+
38
+ const placeholders = list.map(() => "?").join(",");
39
+ const rows = CreateQuery({
40
+ Query: `SELECT geometry FROM shapefiles WHERE id IN (${placeholders})`,
41
+ Parameters: list
42
+ });
43
+ const polygons: any[] = [];
44
+ const geometryHashes = new Set<string>();
45
+ for (const row of rows) {
46
+ if (!row?.geometry) continue;
47
+ const geometryHash = createHash("sha256").update(row.geometry).digest("hex");
48
+ if (geometryHashes.has(geometryHash)) continue;
49
+ geometryHashes.add(geometryHash);
50
+ const geom = JSON.parse(row.geometry);
51
+ if (geom?.type === "Polygon") {
52
+ polygons.push(geom.coordinates);
53
+ }
54
+ if (geom?.type === "MultiPolygon") {
55
+ for (const poly of geom.coordinates) {
56
+ polygons.push(poly);
57
+ }
58
+ }
59
+ }
60
+ if (polygons.length === 0) return null;
61
+ if (Union) {
62
+ return GetUnionPolygon({ Polygons: polygons });
63
+ } else {
64
+ const multi: any[] = [];
65
+ for (const polyCoords of polygons) {
66
+ if (Array.isArray(polyCoords) && Array.isArray(polyCoords[0])) {
67
+ multi.push(polyCoords);
68
+ }
69
+ }
70
+ if (multi.length === 0) return null;
71
+ return {type: "MultiPolygon", coordinates: multi};
72
+ }
73
+ }
@@ -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
- export const getZones = (header: string): string[] => {
20
+ export const GetZones = (header: string): string[] => {
21
21
  const splits = header.split('-');
22
22
  const zones: string[] = [];
23
23
  let state = splits[0].substring(0, 2);
@@ -11,18 +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 { bootstrap } from "../../bootstrap";
20
+ import { Bootstrap } from "@Bootstrap"
21
21
 
22
- export const setCache = (key: string, value: string[]) => {
23
- if (bootstrap.cache.ugc.size >= 5000) {
24
- const firstKey = bootstrap.cache.ugc.keys().next().value;
25
- bootstrap.cache.ugc.delete(firstKey);
22
+ interface SetCacheOptions {
23
+ Key: string
24
+ Value: string[]
25
+ }
26
+
27
+ export const SetCache = ({ Key, Value }: SetCacheOptions) => {
28
+ if (Bootstrap.Cache.UGC.size >= 5000) {
29
+ const firstKey = Bootstrap.Cache.UGC.keys().next().value;
30
+ Bootstrap.Cache.UGC.delete(firstKey);
26
31
  }
27
- bootstrap.cache.ugc.set(key, value);
32
+ Bootstrap.Cache.UGC.set(Key, Value);
28
33
  };
@@ -11,27 +11,27 @@
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 { TypeUGC } from "../../@types/UGC";
21
- import { getUGCHeader } from "./GetUGCHeader"
22
- import { getZones } from "./GetZones";
23
- import { GetExpiry } from './GetExpiry';
24
- import { getLocations } from "./GetLocations";
20
+ import { TypeUGC } from "Types/UGC"
21
+ import { GetHeader } from "@ParsingUGC/GetHeader"
22
+ import { GetZones } from "@ParsingUGC/GetZones"
23
+ import { GetExpiry } from "@ParsingUGC/GetExpiry"
24
+ import { GetLocations } from "@ParsingUGC/GetLocations"
25
25
 
26
- export const ugcExtract = async (message: string): Promise<TypeUGC> => {
27
- const head = getUGCHeader(message);
28
- const ugcs = getZones(head)
26
+ export const UGCExtract = async (message: string): Promise<TypeUGC> => {
29
27
  const expires = GetExpiry(message)
30
- const areas = await getLocations(ugcs)
28
+ const head = GetHeader(message);
29
+ const ugcs = GetZones(head);
30
+ const areas = await GetLocations(ugcs)
31
31
  if (!head || ugcs?.length == 0) return;
32
32
  return {
33
- zones: ugcs,
34
- locations: areas,
35
- expires: expires
33
+ Zones: ugcs,
34
+ Locations: areas,
35
+ Expires: expires
36
36
  }
37
37
  }
@@ -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
 
@@ -0,0 +1,49 @@
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 { TypeVTEC } from "Types/VTEC"
21
+ import { EnumExpressions } from "@Enums/Expressions"
22
+ import { EnumProducts } from "@Enums/Products"
23
+ import { EnumEvents } from "@Enums/Events"
24
+ import { EnumActions } from "@Enums/Actions"
25
+ import { EnumStatus } from "@Enums/Status"
26
+ import { GetExpiry } from "@ParsingVTEC/GetExpiry"
27
+
28
+ export const VTECExtract = (message: string): TypeVTEC[] | null => {
29
+ if (!message) return null;
30
+ const getVTECs = message.match(EnumExpressions.vtec) ?? [];
31
+ const vtecs: TypeVTEC[] = [];
32
+ for (const vtec of getVTECs) {
33
+ const sub = vtec.split(`.`);
34
+ if (sub?.length < 7) continue;
35
+ const dates = sub[6]?.split(`-`);
36
+ vtecs.push({
37
+ Raw: vtec,
38
+ ProductType: EnumProducts[sub[0]],
39
+ Tracking: `${sub[2]}.${sub[3]}.${sub[4]}.${sub[5]}`,
40
+ Event: `${EnumEvents[sub[3]]} ${EnumActions[sub[4]]}`,
41
+ Status: EnumStatus[sub[1]],
42
+ WMO: message.match(EnumExpressions.wmo)?.[0] ?? null,
43
+ Expires: GetExpiry(dates),
44
+ Watch: (sub[4] == `A` || sub[4] == `Y`) && (sub[3] == `TO` || sub[3] == `SV`),
45
+ PredictionCenter: sub[2] == `KWNS` ? true : false
46
+ })
47
+ }
48
+ return vtecs.length > 0 ? vtecs : null;
49
+ }
@@ -11,13 +11,12 @@
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
-
21
20
  export type TypeAttributes = {
22
21
  xmlns: string
23
22
  id: string
@@ -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 { TypeEventProperties as BaseTypeEventProperties } from "./Properties";
21
- import { TypeHVTEC } from "./HVTEC";
22
- import { TypePVTEC } from "./VTEC";
20
+ import { TypeEventProperties as BaseTypeEventProperties } from "StaticTypes/Properties"
21
+ import { TypeHVTEC } from "Types/HVTEC"
22
+ import { TypeVTEC } from "Types/VTEC"
23
23
 
24
24
  export type TypeEvent = {
25
25
  type: string
26
26
  geometry: {
27
- type: string
27
+ type: "Polygon" | "MultiPolygon"
28
28
  coordinates: number[][]
29
29
  }
30
30
  properties: {
@@ -33,6 +33,7 @@ export type TypeEvent = {
33
33
  status: string
34
34
  issued: string
35
35
  expires: string
36
+ theme: string
36
37
  status_metadata?: {
37
38
  is_issued?: boolean
38
39
  is_updated?: boolean
@@ -46,7 +47,7 @@ export type TypeEvent = {
46
47
  tracking: string
47
48
  hash?: string
48
49
  header: string
49
- vtec?: TypePVTEC | null
50
+ vtec?: TypeVTEC | null
50
51
  hvtec?: TypeHVTEC[] | null
51
52
  nodes?: {
52
53
  id?: string | number
@@ -11,17 +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 { TypeAttributes } from "./Attributes";
20
+ import { TypeAttributes } from "StaticTypes/Attributes"
21
21
 
22
+
22
23
  export type TypeEventProperties = {
23
24
  locations: string
24
25
  locations_array: string[]
26
+ regions: string[]
27
+ regions_string: string
25
28
  description: string
26
29
  attributes?: TypeAttributes
27
30
  geocode: {
@@ -42,6 +45,7 @@ export type TypeEventProperties = {
42
45
  impacts: string
43
46
  estimated_hail_size: string
44
47
  estimated_wind_gusts: string
48
+ direction: string
45
49
  damage_threat: string
46
50
  tornado_threat: string
47
51
  flood_threat: 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