@atmosx/event-product-parser 3.0.621 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CHANGELOGS.md +52 -0
- package/.github/CODE_OF_CONDUCT.md +24 -1
- package/.github/CONTRIBUTING.md +22 -3
- package/.github/FUNDING.yaml +3 -0
- package/.github/LICENSE +24 -1
- package/.github/SECURITY.md +25 -6
- package/.github/docs/chapters/general-configurations.md +109 -0
- package/.github/docs/chapters/sources-and-attributes.md +219 -0
- package/README.md +56 -146
- package/dist/index.cjs +25333 -0
- package/package.json +17 -11
- package/pnpm-workspace.yaml +4 -0
- package/src/bootstrap.ts +67 -52
- package/src/components/audio/GenerateAudioMessage.ts +149 -0
- package/src/{@modules/@eas → components/audio/components}/GetCleanDescription.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetFloatPCM16.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetMergedPCM16.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetPCM16.ts +13 -8
- package/src/{@modules/@eas → components/audio/components}/GetPCMToFloat.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetSampledPCM16.ts +14 -8
- package/src/{@modules/@eas → components/audio/components}/GetTTS.ts +17 -10
- package/src/{@modules/@eas → components/audio/components}/GetWavPCM16.ts +7 -7
- package/src/{@modules/@eas → components/audio/components}/SetAFSK.ts +13 -8
- package/src/{@modules/@eas → components/audio/components}/SetAsciiToBits.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/SetAttentionTone.ts +11 -6
- package/src/{@modules/@eas → components/audio/components}/SetNoise.ts +12 -7
- package/src/{@modules/@eas → components/audio/components}/SetRadioEffect.ts +12 -7
- package/src/{@modules/@eas → components/audio/components}/SetSameHeader.ts +22 -14
- package/src/components/database/CreateQuery.ts +39 -0
- package/src/components/database/InitializeDatabase.ts +71 -0
- package/src/components/database/imports/Boundaires.ts +168 -0
- package/src/{@modules/@database/ImportBroadcastify.ts → components/database/imports/Broadcastify.ts} +15 -25
- package/src/components/database/imports/Census.ts +87 -0
- package/src/{@modules/@database/ImportShapefiles.ts → components/database/imports/Shapefiles.ts} +24 -27
- package/src/{@modules/@database/ImportStanza.ts → components/database/imports/Stanza.ts} +15 -19
- package/src/components/events/CreateEvents.ts +88 -0
- package/src/components/events/FilterEvents.ts +149 -0
- package/src/{@building/CreateEvent.ts → components/events/ProcessStanza.ts} +22 -24
- package/src/components/events/RemoveEvents.ts +74 -0
- package/src/{@building → components/events/components}/GetCleanedEvent.ts +2 -2
- package/src/{@building → components/events/components}/GetEventAttachments.ts +14 -12
- package/src/components/events/components/GetEventDirection.ts +28 -0
- package/src/{@building → components/events/components}/GetEventEnhancedName.ts +5 -8
- package/src/{@building → components/events/components}/GetEventGeometry.ts +19 -13
- package/src/{@building → components/events/components}/GetEventHeader.ts +13 -13
- package/src/components/events/components/GetEventMerged.ts +51 -0
- package/src/{@building → components/events/components}/GetEventNodes.ts +22 -20
- package/src/{@building → components/events/components}/GetEventOffice.ts +13 -13
- package/src/components/events/components/GetEventPopulation.ts +58 -0
- package/src/components/events/components/GetEventProperties.ts +106 -0
- package/src/{@building → components/events/components}/GetEventSignature.ts +9 -9
- package/src/{@building → components/events/components}/GetEventTags.ts +3 -3
- package/src/components/events/components/GetEventTheme.ts +26 -0
- package/src/components/events/components/GetEventTracking.ts +64 -0
- package/src/{@modules/@database → components/events/utilities}/GetCachedEvents.ts +18 -15
- package/src/{@manager → components/events/utilities}/SetHash.ts +18 -13
- package/src/{@manager → components/events/utilities}/UpdateEvents.ts +12 -12
- package/src/{@manager → components/events/utilities}/UpdateNode.ts +14 -14
- package/src/{@parsers/@text → components/formatting}/GetEmbededText.ts +14 -8
- package/src/{@parsers/@text → components/formatting}/GetStringText.ts +15 -11
- package/src/{@modules/@utilities → components/geometry}/GetShapeNearestPoint.ts +24 -19
- package/src/components/geometry/GetUnionPolygon.ts +36 -0
- package/src/components/images/GenerateGraphic.ts +242 -0
- package/src/components/images/components/CreateRectangle.ts +22 -0
- package/src/components/images/components/CreateText.ts +22 -0
- package/src/components/images/modules/CreateSVG.ts +37 -0
- package/src/components/images/modules/GetGeographicalBoundaries.ts +72 -0
- package/src/components/images/modules/GetGeographicalCities.ts +58 -0
- package/src/components/images/modules/GetGeographicalEvents.ts +48 -0
- package/src/components/images/modules/GetGeometryBounds.ts +82 -0
- package/src/components/images/modules/GetParsedBoundary.ts +58 -0
- package/src/components/images/modules/GetSVGPath.ts +53 -0
- package/src/components/images/modules/NormalizePolygon.ts +57 -0
- package/src/{@modules/@stanza → components/stanza}/GetAwipsType.ts +16 -17
- package/src/{@modules/@stanza → components/stanza}/ValidateStanza.ts +27 -15
- package/src/{@modules/@utilities → components/utilities}/CreateHttp.ts +26 -26
- package/src/components/utilities/EmitThread.ts +97 -0
- package/src/{@modules/@utilities → components/utilities}/GetLatestIssuance.ts +2 -2
- package/src/{@modules/@utilities → components/utilities}/GetMatched.ts +10 -5
- package/src/components/utilities/QueueManager.ts +70 -0
- package/src/{@modules/@utilities → components/utilities}/SetDebug.ts +13 -13
- package/src/components/utilities/SetEventEmit.ts +42 -0
- package/src/{@modules/@utilities → components/utilities}/SetSettings.ts +7 -7
- package/src/{@modules/@utilities → components/utilities}/SetSleep.ts +5 -5
- package/src/components/utilities/SetTimeoutAction.ts +64 -0
- package/src/components/utilities/SetWarning.ts +47 -0
- package/src/{@modules/@xmpp → components/xmpp}/DeployXMPP.ts +20 -20
- package/src/{@core/CreateListener.ts → components/xmpp/ErrorXMPP.ts} +8 -5
- package/src/{@modules/@xmpp → components/xmpp}/OfflineXMPP.ts +13 -13
- package/src/{@modules/@xmpp → components/xmpp}/OnlineXMPP.ts +18 -18
- package/src/components/xmpp/ReconnectXMPP.ts +64 -0
- package/src/{@modules/@xmpp → components/xmpp}/StanzaXMPP.ts +26 -26
- package/src/{@enums → enums}/AWIPS.ts +2 -2
- package/src/{@enums → enums}/Actions.ts +2 -2
- package/src/{@enums → enums}/Cancellation.ts +2 -2
- package/src/{@enums → enums}/Causes.ts +2 -2
- package/src/{@enums → enums}/Correlations.ts +2 -2
- package/src/{@enums → enums}/Enhanced.ts +4 -3
- package/src/{@enums → enums}/Events.ts +2 -2
- package/src/{@enums → enums}/Expressions.ts +3 -3
- package/src/{@enums → enums}/GlobalFilter.ts +2 -2
- package/src/{@enums → enums}/Hail.ts +2 -2
- package/src/{@enums → enums}/ICAO.ts +2 -2
- package/src/{@enums → enums}/Matches.ts +8 -3
- package/src/{@enums → enums}/Products.ts +2 -2
- package/src/{@enums → enums}/Records.ts +2 -2
- package/src/{@enums → enums}/Severity.ts +2 -2
- package/src/{@enums → enums}/Shapefiles.ts +2 -2
- package/src/{@enums → enums}/States.ts +68 -4
- package/src/{@enums → enums}/Status.ts +2 -2
- package/src/{@enums → enums}/Strings.ts +2 -2
- package/src/{@enums → enums}/Tags.ts +9 -4
- package/src/{@enums → enums}/Testing.ts +2 -2
- package/src/enums/Themes.ts +70 -0
- package/src/events/ParseAPI.ts +133 -0
- package/src/{@events → events}/ParseText.ts +24 -22
- package/src/{@events → events}/ParseUGC.ts +27 -26
- package/src/{@events → events}/ParseVTEC.ts +37 -36
- package/src/{@core → exports}/ClearEvents.ts +9 -9
- package/src/{@core → exports}/GetEvents.ts +4 -4
- package/src/exports/GetNearestCity.ts +45 -0
- package/src/{@core → exports}/GetNodes.ts +4 -4
- package/src/{@core → exports}/GetRandomEvent.ts +4 -4
- package/src/{@core → exports}/GetVersion.ts +4 -4
- package/src/exports/ManualEvent.ts +55 -0
- package/src/{@core → exports}/QueryStanza.ts +12 -11
- package/src/exports/SetNode.ts +100 -0
- package/src/{@core → exports}/StartService.ts +23 -22
- package/src/{@core → exports}/StopService.ts +10 -10
- package/src/index.ts +57 -37
- package/src/{@parsers/@hvtec → parsers/hvtec}/HVExtract.ts +7 -7
- package/src/{@parsers/@text → parsers/text}/GetDescriptionFromProduct.ts +20 -21
- package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
- package/src/{@parsers/@text → parsers/text}/GetTextFromProduct.ts +12 -12
- package/src/parsers/ugc/GetCache.ts +24 -0
- package/src/{@parsers/@ugc → parsers/ugc}/GetExpiry.ts +2 -2
- package/src/{@parsers/@ugc/GetUGCHeader.ts → parsers/ugc/GetHeader.ts} +4 -4
- package/src/{@parsers/@ugc → parsers/ugc}/GetLocations.ts +10 -10
- package/src/parsers/ugc/GetZonePolygon.ts +73 -0
- package/src/{@parsers/@ugc → parsers/ugc}/GetZones.ts +3 -3
- package/src/{@parsers/@ugc → parsers/ugc}/SetCache.ts +13 -8
- package/src/{@parsers/@ugc → parsers/ugc}/UGCExtract.ts +14 -14
- package/src/{@parsers/@pvtec → parsers/vtec}/GetExpiry.ts +2 -2
- package/src/{@parsers/@pvtec → parsers/vtec}/VTECExtract.ts +17 -17
- package/src/tasks/CreateTasks.ts +116 -0
- package/src/tasks/TaskGenerateJSON.ts +34 -0
- package/src/tasks/TaskGenerateText.ts +34 -0
- package/src/tasks/TaskSendNTFY.ts +96 -0
- package/src/tasks/TaskSendWebhook.ts +107 -0
- package/src/{@types → types/event}/Attributes.ts +2 -3
- package/src/{@types → types/event}/Event.ts +8 -7
- package/src/{@types → types/event}/HVTEC.ts +2 -2
- package/src/{@types → types/event}/Properties.ts +17 -3
- package/src/{@types → types/event}/Stanza.ts +2 -2
- package/src/{@types → types/event}/VTEC.ts +8 -8
- package/src/{@types → types/standard}/Actions.ts +3 -3
- package/src/{@types → types/standard}/Hash.ts +5 -5
- package/src/{@modules/@utilities/GetSettings.ts → types/standard/Nodes.ts} +15 -7
- package/src/{@types → types/standard}/Settings.ts +19 -12
- package/src/{@types → types/standard}/StanzaCompiled.ts +15 -15
- package/src/{@types → types/standard}/UGC.ts +5 -5
- package/tools/build.js +32 -0
- package/tsconfig.json +32 -1
- package/.github/SUPPORTED_EVENTS.md +0 -370
- package/.github/docs/docs-functions.md +0 -30
- package/.github/docs/docs-general-configurations.md +0 -209
- package/.github/docs/docs-integrations.md +0 -37
- package/.github/docs/docs-listeners.md +0 -28
- package/.github/docs/docs-source-configuration.md +0 -218
- package/.github/docs/docs-technical.md +0 -50
- package/.github/logo.png +0 -0
- package/.github/samples/SAMPLE_EAS_GENERATION.wav +0 -0
- package/.github/samples/SAMPLE_GEOJSON.json +0 -204
- package/.github/samples/SAMPLE_TEXT_PRODUCT.txt +0 -119
- package/dist/cjs/index.cjs +0 -8005
- package/dist/esm/index.mjs +0 -7985
- package/src/@building/GetEventProperties.ts +0 -96
- package/src/@building/GetEventTracking.ts +0 -68
- package/src/@core/ManualEvent.ts +0 -56
- package/src/@core/SetNode.ts +0 -81
- package/src/@events/ParseAPI.ts +0 -117
- package/src/@manager/MakeEvents.ts +0 -106
- package/src/@manager/RemoveEvent.ts +0 -70
- package/src/@manager/Tasks.ts +0 -246
- package/src/@manager/ValidateEvents.ts +0 -142
- package/src/@modules/@database/InitializeDatabase.ts +0 -59
- package/src/@modules/@eas/GenerateEASMessage.ts +0 -144
- package/src/@modules/@utilities/GetFormattedTime.ts +0 -43
- package/src/@modules/@utilities/SetCronSchedule.ts +0 -94
- package/src/@modules/@utilities/SetEventEmit.ts +0 -41
- package/src/@modules/@utilities/SetListener.ts +0 -30
- package/src/@modules/@utilities/SetTimeoutAction.ts +0 -64
- package/src/@modules/@utilities/SetWarning.ts +0 -34
- package/src/@modules/@xmpp/ErrorXMPP.ts +0 -27
- package/src/@modules/@xmpp/ReconnectXMPP.ts +0 -64
- package/src/@parsers/@text/GetPolygonFromProduct.ts +0 -53
- package/src/@parsers/@text/GetXML.ts +0 -61
- package/src/@parsers/@ugc/GetCache.ts +0 -24
- package/src/@parsers/@ugc/GetZonePolygon.ts +0 -111
- package/tsup.config.ts +0 -16
|
@@ -11,26 +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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeSettings } from "
|
|
21
|
-
import {
|
|
22
|
-
import { SetWarning } from
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
20
|
+
import { TypeSettings } from "TypesStandard/Settings"
|
|
21
|
+
import { Bootstrap } from "@Bootstrap"
|
|
22
|
+
import { SetWarning } from "@Utilities/SetWarning"
|
|
23
|
+
import { ProcessStanza } from "@Builder/ProcessStanza"
|
|
24
|
+
import { CreateQuery } from "@Database/CreateQuery"
|
|
25
25
|
|
|
26
26
|
export const GetCachedEvents = async (): Promise<void> => {
|
|
27
27
|
try {
|
|
28
|
-
const settings =
|
|
28
|
+
const settings = Bootstrap.Settings as TypeSettings;
|
|
29
29
|
const tick = performance.now();
|
|
30
30
|
if (settings.NOAAWeatherWireServiceSettings.CacheSettings.Enabled) {
|
|
31
31
|
const max = settings.NOAAWeatherWireServiceSettings.CacheSettings.MaxRetentionHistory ?? 500;
|
|
32
|
-
const get = await
|
|
33
|
-
|
|
32
|
+
const get = await CreateQuery({
|
|
33
|
+
Query: `SELECT * FROM stanzas ORDER BY rowid DESC LIMIT ?`,
|
|
34
|
+
Parameters: [max]
|
|
35
|
+
}) as { rowid: number; stanza: string }[];
|
|
36
|
+
SetWarning({ Message: `Fetched ${get.length} cached stanzas from the database in ${Math.floor(performance.now() - tick)} ms` })
|
|
34
37
|
let events = get.map((row) => JSON.parse(row.stanza))
|
|
35
38
|
.filter(stanza => {
|
|
36
39
|
if (!stanza) { return }
|
|
@@ -40,11 +43,11 @@ export const GetCachedEvents = async (): Promise<void> => {
|
|
|
40
43
|
return !isSkippable
|
|
41
44
|
});
|
|
42
45
|
events = events.sort((a, b) => b.issued - a.issued)
|
|
43
|
-
await Promise.all(events.map(event =>
|
|
44
|
-
SetWarning({
|
|
45
|
-
await ValidateEvents(bootstrap.cache.processed)
|
|
46
|
+
await Promise.all(events.map(event => ProcessStanza(event)))
|
|
47
|
+
SetWarning({ Message: `Processed ${events.length} cached stanzas in ${Math.floor(performance.now() - tick)} ms` })
|
|
46
48
|
}
|
|
47
|
-
} catch (error) {
|
|
48
|
-
|
|
49
|
+
} catch (error: unknown) {
|
|
50
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
51
|
+
SetWarning({ Message: `An error occurred while fetching cached stanzas: ${message}` })
|
|
49
52
|
}
|
|
50
53
|
}
|
|
@@ -11,26 +11,31 @@
|
|
|
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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeEvent } from "
|
|
21
|
-
import { TypeHash } from "
|
|
22
|
-
import {
|
|
20
|
+
import { TypeEvent } from "TypesEvent/Event"
|
|
21
|
+
import { TypeHash } from "TypesStandard/Hash"
|
|
22
|
+
import { Bootstrap } from "@Bootstrap"
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
interface SetHashOptions {
|
|
25
|
+
Event: TypeEvent
|
|
26
|
+
Entry: TypeHash
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const SetHash = ({ Event, Entry }: SetHashOptions): void => {
|
|
30
|
+
if (!Entry) {
|
|
31
|
+
Bootstrap.Cache.Hashes.push({
|
|
32
|
+
Tracking: Event.properties.metadata.tracking,
|
|
33
|
+
Hashes: [Event.properties.metadata.hash],
|
|
34
|
+
Expires: Event.properties.expires
|
|
30
35
|
});
|
|
31
36
|
return;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
Entry.Hashes.push(Event.properties.metadata.hash);
|
|
40
|
+
Entry.Expires = Event.properties.expires;
|
|
36
41
|
}
|
|
@@ -11,25 +11,25 @@
|
|
|
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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeEvent } from "
|
|
21
|
-
import {
|
|
22
|
-
import { SetEventEmit } from "
|
|
23
|
-
import {
|
|
20
|
+
import { TypeEvent } from "TypesEvent/Event"
|
|
21
|
+
import { Bootstrap } from "@Bootstrap"
|
|
22
|
+
import { SetEventEmit } from "@Utilities/SetEventEmit"
|
|
23
|
+
import { RemoveEvents } from "@Builder/RemoveEvents"
|
|
24
24
|
|
|
25
|
-
export const UpdateEvents = async (
|
|
26
|
-
const events =
|
|
25
|
+
export const UpdateEvents = async (selected?: TypeEvent): Promise<void> => {
|
|
26
|
+
const events = Bootstrap.Cache.Events.features;
|
|
27
27
|
async function update(event: TypeEvent) {
|
|
28
28
|
if (new Date(event.properties.expires) < new Date()) {
|
|
29
|
-
SetEventEmit({
|
|
30
|
-
await
|
|
29
|
+
SetEventEmit({ Event: `onExpiredProduct`, Metadata: event })
|
|
30
|
+
await RemoveEvents({ Event: event, IsTimeBasedExpiration: true })
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
if (!
|
|
34
|
-
if (
|
|
33
|
+
if (!selected) { await Promise.all(events.map(async (event) => { await update(event) })) }
|
|
34
|
+
if (selected) { await update(selected) }
|
|
35
35
|
}
|
|
@@ -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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeEvent } from "
|
|
21
|
-
import {
|
|
22
|
-
import { GetEventNodes } from "
|
|
23
|
-
import { SetEventEmit } from "
|
|
20
|
+
import { TypeEvent } from "TypesEvent/Event"
|
|
21
|
+
import { Bootstrap } from "@Bootstrap"
|
|
22
|
+
import { GetEventNodes } from "@BuilderComponents/GetEventNodes"
|
|
23
|
+
import { SetEventEmit } from "@Utilities/SetEventEmit"
|
|
24
24
|
|
|
25
|
-
export const UpdateNode = async (
|
|
26
|
-
const events =
|
|
27
|
-
const ttl =
|
|
25
|
+
export const UpdateNode = async (selected?: TypeEvent): Promise<void> => {
|
|
26
|
+
const events = Bootstrap.Cache.Events.features;
|
|
27
|
+
const ttl = Bootstrap.Settings.GlobalSettings.NodePolygonTTL * 1e3;
|
|
28
28
|
let total = 0;
|
|
29
29
|
|
|
30
|
-
const TTLEvents =
|
|
30
|
+
const TTLEvents = selected ? [selected] : events.filter((evt) => {
|
|
31
31
|
const lastUpdate = evt?.properties?.metadata?.updated ?? null;
|
|
32
32
|
return lastUpdate == null || (Date.now() - lastUpdate) >= ttl;
|
|
33
33
|
});
|
|
@@ -52,10 +52,10 @@ export const UpdateNode = async (selectedEvent?: TypeEvent): Promise<void> => {
|
|
|
52
52
|
|
|
53
53
|
if (total > 0) {
|
|
54
54
|
SetEventEmit({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
Event: `onNodeUpdate`,
|
|
56
|
+
Metadata: {
|
|
57
|
+
Type: `global-update`,
|
|
58
|
+
Updated: total
|
|
59
59
|
},
|
|
60
60
|
})
|
|
61
61
|
}
|
|
@@ -11,27 +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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeEvent } from "
|
|
20
|
+
import { TypeEvent } from "TypesEvent/Event"
|
|
21
21
|
|
|
22
|
-
export const
|
|
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;
|
|
26
|
+
const isIssued = event.properties.status_metadata.is_issued;
|
|
27
|
+
const isUpdated = event.properties.status_metadata.is_updated;
|
|
26
28
|
return [
|
|
27
29
|
line(`**Locations:**`, event?.properties?.locations?.slice(0, 100)),
|
|
28
|
-
line(`**Issued:**`, `<t:${Math.floor(new Date(event.properties.issued).getTime() / 1000)}:R>`,
|
|
29
|
-
line(`**
|
|
30
|
+
line(`**Issued:**`, `<t:${Math.floor(new Date(event.properties.issued).getTime() / 1000)}:R>`, isIssued),
|
|
31
|
+
line(`**Updated:**`, `<t:${Math.floor(new Date(event.properties.issued).getTime() / 1000)}:R>`, isUpdated && !isExpired),
|
|
32
|
+
line(`**Expires:**`, `<t:${Math.floor(new Date(event.properties.expires).getTime() / 1000)}:R>`, !isStatement && !isExpired),
|
|
33
|
+
line(`**Expired:**`, `<t:${Math.floor(new Date(event.properties.expires).getTime() / 1000)}:R>`, isExpired),
|
|
30
34
|
line(`**Damage Threat:**`, event?.properties?.parameters?.damage_threat, !isExpired),
|
|
31
35
|
line(`**Flood Threat:**`, event?.properties?.parameters?.flood_threat, !isExpired),
|
|
32
36
|
line(`**Tornado Threat:**`, event?.properties?.parameters?.tornado_threat, !isExpired),
|
|
33
|
-
line(`**
|
|
34
|
-
line(`**
|
|
37
|
+
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),
|
|
38
|
+
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),
|
|
39
|
+
line(`**Direction:**`, event?.properties?.parameters?.direction, !isExpired && event?.properties?.parameters?.direction != null),
|
|
35
40
|
line(`**Discussion:**`, event?.properties?.discussion_parameters?.discussion_number, !isExpired),
|
|
36
41
|
line(`**Concern:**`, event?.properties?.discussion_parameters?.discussion_concerning, !isExpired),
|
|
37
42
|
line(`**SPC Max Tornado Threat:**`, event?.properties?.discussion_parameters?.discussion_max_tornado, !isExpired),
|
|
@@ -50,6 +55,7 @@ export const GetEmebedText = (event: TypeEvent): string => {
|
|
|
50
55
|
line(`**Max Tops (x100 feet):**`, event?.properties?.watch_parameters?.max_tops_x100feet, !isExpired),
|
|
51
56
|
line(`**Tags:**`, event?.properties?.parameters?.tags?.length > 0 ? event?.properties?.parameters?.tags.join(', ') : null, !isExpired),
|
|
52
57
|
line(`**Sender:**`, event?.properties?.geocode?.office?.name ? `${event?.properties?.geocode?.office?.name} (${event?.properties?.geocode?.office?.office})` : event?.properties?.geocode?.office?.office),
|
|
58
|
+
line(`**Population:**`, event?.properties?.geocode?.census?.population, !isExpired),
|
|
53
59
|
line(`**Tracking:**`, event?.properties?.metadata?.tracking),
|
|
54
60
|
line(`**Logs:**`, event?.properties?.metadata?.history?.length > 0 ? event?.properties?.metadata?.history.length : null),
|
|
55
61
|
].filter(Boolean).join('\n');
|
|
@@ -11,31 +11,34 @@
|
|
|
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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeEvent } from "
|
|
21
|
-
import {
|
|
22
|
-
import { bootstrap } from "../../bootstrap";
|
|
20
|
+
import { TypeEvent } from "TypesEvent/Event"
|
|
21
|
+
import { Bootstrap } from "@Bootstrap"
|
|
23
22
|
|
|
24
23
|
export const GetStringText = (event: TypeEvent): string => {
|
|
25
|
-
const
|
|
26
|
-
const timezone = settings.NotifyServer.Timezone ?? `UTC`;
|
|
24
|
+
const timezone = Bootstrap.Settings.Timezone ?? `UTC`;
|
|
27
25
|
const line = (label: string, value: unknown, condition = true) => condition && value ? `${label} ${value}` : null;
|
|
28
26
|
const isStatement = event.properties.status_metadata.is_statement;
|
|
29
27
|
const isExpired = event.properties.status_metadata.is_expired;
|
|
28
|
+
const isIssued = event.properties.status_metadata.is_issued;
|
|
29
|
+
const isUpdated = event.properties.status_metadata.is_updated;
|
|
30
30
|
return [
|
|
31
31
|
line(`Locations:`, event?.properties?.locations?.slice(0, 100)),
|
|
32
|
-
line(`Issued:`, `${new Date(event.properties.issued).toLocaleString([], { timeZone: timezone })} (${(timezone.replace(`America/`, ``))})`,
|
|
33
|
-
line(`
|
|
32
|
+
line(`Issued:`, `${new Date(event.properties.issued).toLocaleString([], { timeZone: timezone })} (${(timezone.replace(`America/`, ``))})`, isIssued),
|
|
33
|
+
line(`Updated:`, `${new Date(event.properties.issued).toLocaleString([], { timeZone: timezone })} (${(timezone.replace(`America/`, ``))})`, isUpdated && !isExpired),
|
|
34
|
+
line(`Expires:`, `${new Date(event.properties.expires).toLocaleString([], { timeZone: timezone })} (${(timezone.replace(`America/`, ``))})`, !isStatement && !isExpired),
|
|
35
|
+
line(`Expired:`, `${new Date(event.properties.expires).toLocaleString([], { timeZone: timezone })} (${(timezone.replace(`America/`, ``))})`, isExpired),
|
|
34
36
|
line(`Damage Threat:`, event?.properties?.parameters?.damage_threat, !isExpired),
|
|
35
37
|
line(`Flood Threat:`, event?.properties?.parameters?.flood_threat, !isExpired),
|
|
36
38
|
line(`Tornado Threat:`, event?.properties?.parameters?.tornado_threat, !isExpired),
|
|
37
|
-
line(`
|
|
38
|
-
line(`
|
|
39
|
+
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),
|
|
40
|
+
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),
|
|
41
|
+
line(`Direction:`, event?.properties?.parameters?.direction, !isExpired && event?.properties?.parameters?.direction != null),
|
|
39
42
|
line(`Discussion:`, event?.properties?.discussion_parameters?.discussion_number, !isExpired),
|
|
40
43
|
line(`Concern:`, event?.properties?.discussion_parameters?.discussion_concerning, !isExpired),
|
|
41
44
|
line(`SPC Max Tornado Threat:`, event?.properties?.discussion_parameters?.discussion_max_tornado, !isExpired),
|
|
@@ -53,6 +56,7 @@ export const GetStringText = (event: TypeEvent): string => {
|
|
|
53
56
|
line(`Max Surface Wind:`, event?.properties?.watch_parameters?.max_wind_surface, !isExpired),
|
|
54
57
|
line(`Max Tops (x100 feet):`, event?.properties?.watch_parameters?.max_tops_x100feet, !isExpired),
|
|
55
58
|
line(`Sender:`, event?.properties?.geocode?.office?.name ? `${event?.properties?.geocode?.office?.name} (${event?.properties?.geocode?.office?.office})` : event?.properties?.geocode?.office?.office),
|
|
59
|
+
line(`Population:`, event?.properties?.geocode?.census?.population, !isExpired),
|
|
56
60
|
line(`Tracking:`, event?.properties?.metadata?.tracking),
|
|
57
61
|
].filter(Boolean).join('\n');
|
|
58
62
|
}
|
|
@@ -11,23 +11,28 @@
|
|
|
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:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
interface GetShapeNearestPointOptions {
|
|
21
|
+
Coordinates: number[][]
|
|
22
|
+
Point: [number, number]
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
interface GetShapeNearestPointResponse {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
Proximity: boolean
|
|
27
|
+
Point: [number, number]
|
|
28
|
+
Distance: number | null
|
|
29
|
+
DistanceKm?: number | null
|
|
30
|
+
DistanceMeters?: number | null
|
|
26
31
|
}
|
|
27
32
|
|
|
28
|
-
export const GetShapeNearestPoint = (
|
|
29
|
-
if (!
|
|
30
|
-
return {
|
|
33
|
+
export const GetShapeNearestPoint = ({ Coordinates, Point }: GetShapeNearestPointOptions): GetShapeNearestPointResponse => {
|
|
34
|
+
if (!Coordinates || !Point) {
|
|
35
|
+
return { Proximity: false, Point: [0, 0], Distance: null }
|
|
31
36
|
}
|
|
32
37
|
const normalize = (coords: any): any[] => {
|
|
33
38
|
if (!Array.isArray(coords)) return [];
|
|
@@ -43,10 +48,10 @@ export const GetShapeNearestPoint = (coordinates: number[][], point: [number, nu
|
|
|
43
48
|
}
|
|
44
49
|
return [];
|
|
45
50
|
}
|
|
46
|
-
const polys = normalize(
|
|
47
|
-
if (polys.length === 0) return {
|
|
48
|
-
const lon =
|
|
49
|
-
const lat =
|
|
51
|
+
const polys = normalize(Coordinates);
|
|
52
|
+
if (polys.length === 0) return { Proximity: false, Point: [0, 0], Distance: null };
|
|
53
|
+
const lon = Point[0];
|
|
54
|
+
const lat = Point[1];
|
|
50
55
|
const pointInRing = (pt: [number, number], ring: number[][]): boolean => {
|
|
51
56
|
let x = pt[0], y = pt[1];
|
|
52
57
|
let inside = false;
|
|
@@ -76,13 +81,13 @@ export const GetShapeNearestPoint = (coordinates: number[][], point: [number, nu
|
|
|
76
81
|
for (const poly of polys) {
|
|
77
82
|
const outer = poly[0];
|
|
78
83
|
const holes = poly.slice(1);
|
|
79
|
-
if (pointInRing(
|
|
84
|
+
if (pointInRing(Point, outer)) {
|
|
80
85
|
let inHole = false;
|
|
81
86
|
for (const hole of holes) {
|
|
82
|
-
if (pointInRing(
|
|
87
|
+
if (pointInRing(Point, hole)) { inHole = true; break; }
|
|
83
88
|
}
|
|
84
89
|
if (!inHole) {
|
|
85
|
-
return {
|
|
90
|
+
return { Proximity: true, Point, Distance: 0 };
|
|
86
91
|
}
|
|
87
92
|
}
|
|
88
93
|
for (const ring of poly) {
|
|
@@ -105,10 +110,10 @@ export const GetShapeNearestPoint = (coordinates: number[][], point: [number, nu
|
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
112
|
if (!isFinite(minDistance) || closestPoint == null) {
|
|
108
|
-
return {
|
|
113
|
+
return { Proximity: false, Point: [0,0], Distance: null };
|
|
109
114
|
}
|
|
110
115
|
const distanceMiles = minDistance;
|
|
111
116
|
const distanceKm = Number((distanceMiles * 1.609344).toFixed(3));
|
|
112
117
|
const distanceMeters = Math.round(distanceKm * 1000);
|
|
113
|
-
return {
|
|
118
|
+
return { Proximity: distanceMiles === 0, Point: closestPoint, Distance: distanceMiles, DistanceKm: distanceKm, DistanceMeters: distanceMeters };
|
|
114
119
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { union } from "polygon-clipping";
|
|
21
|
+
|
|
22
|
+
interface GetUnionPolygonOptions {
|
|
23
|
+
Polygons: number[][][][] | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const GetUnionPolygon = ({ Polygons }: GetUnionPolygonOptions): GeoJSON.MultiPolygon | null => {
|
|
27
|
+
if (!Polygons || Polygons.length === 0) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const unionFn = union as unknown as (...polygons: number[][][][]) => number[][][][];
|
|
31
|
+
const unioned = unionFn(...Polygons)
|
|
32
|
+
return {
|
|
33
|
+
type: `MultiPolygon`,
|
|
34
|
+
coordinates: unioned
|
|
35
|
+
}
|
|
36
|
+
};
|