@atmosx/event-product-parser 3.0.4 → 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.
- package/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +1 -1
- package/.github/SUPPORTED_EVENTS.md +370 -0
- package/.github/docs/docs-functions.md +30 -0
- package/.github/docs/docs-general-configurations.md +199 -0
- package/.github/docs/docs-integrations.md +38 -0
- package/.github/docs/docs-listeners.md +28 -0
- package/.github/docs/docs-source-configuration.md +218 -0
- package/.github/docs/docs-technical.md +50 -0
- package/.github/logo.png +0 -0
- package/.github/samples/SAMPLE_EAS_GENERATION.wav +0 -0
- package/.github/samples/SAMPLE_GEOJSON.json +204 -0
- package/.github/samples/SAMPLE_TEXT_PRODUCT.txt +119 -0
- package/README.md +157 -337
- package/dist/cjs/index.cjs +24125 -15815
- package/dist/esm/index.mjs +24144 -15839
- package/package.json +56 -53
- package/pnpm-workspace.yaml +4 -0
- package/src/bootstrap.ts +83 -43
- package/src/building/CreateEvent.ts +54 -0
- package/src/{@building/building.clean.ts → building/GetCleanedEvent.ts} +4 -4
- package/src/building/GetEventAttachments.ts +88 -0
- package/src/building/GetEventDirection.ts +28 -0
- package/src/{@building/building.enhance.ts → building/GetEventEnhancedName.ts} +13 -17
- package/src/{@building/building.geometry.ts → building/GetEventGeometry.ts} +19 -13
- package/src/{@building/building.headers.ts → building/GetEventHeader.ts} +13 -13
- package/src/{@building/building.polygon.ts → building/GetEventNodes.ts} +26 -22
- package/src/{@building/building.office.ts → building/GetEventOffice.ts} +14 -14
- package/src/building/GetEventProperties.ts +105 -0
- package/src/{@building/building.signature.ts → building/GetEventSignature.ts} +16 -17
- package/src/{@core/core.createListener.ts → building/GetEventTags.ts} +11 -6
- package/src/building/GetEventTheme.ts +26 -0
- package/src/building/GetEventTracking.ts +64 -0
- package/src/components/audio/GenerateAudioMessage.ts +149 -0
- package/src/components/audio/components/GetCleanDescription.ts +91 -0
- package/src/{@modules/@eas/eas.getFloatPCM16.ts → components/audio/components/GetFloatPCM16.ts} +3 -3
- package/src/{@modules/@eas/eas.getMergedPCM16.ts → components/audio/components/GetMergedPCM16.ts} +3 -3
- package/src/{@modules/@eas/eas.getPCM16.ts → components/audio/components/GetPCM16.ts} +13 -8
- package/src/{@modules/@eas/eas.getPCMToFloat.ts → components/audio/components/GetPCMToFloat.ts} +3 -3
- package/src/{@modules/@eas/eas.getSampledPCM16.ts → components/audio/components/GetSampledPCM16.ts} +14 -8
- package/src/components/audio/components/GetTTS.ts +61 -0
- package/src/{@modules/@eas/eas.getWavPCM16.ts → components/audio/components/GetWavPCM16.ts} +8 -8
- package/src/{@modules/@eas/eas.setAFSK.ts → components/audio/components/SetAFSK.ts} +12 -8
- package/src/{@modules/@eas/eas.setAsciiToBits.ts → components/audio/components/SetAsciiToBits.ts} +3 -4
- package/src/{@modules/@eas/eas.setAttentionTone.ts → components/audio/components/SetAttentionTone.ts} +11 -6
- package/src/{@modules/@eas/eas.setNoise.ts → components/audio/components/SetNoise.ts} +14 -8
- package/src/{@modules/@eas/eas.setRadioEffect.ts → components/audio/components/SetRadioEffect.ts} +14 -8
- package/src/{@modules/@eas/eas.setSameHeader.ts → components/audio/components/SetSameHeader.ts} +22 -15
- package/src/{@modules/@utilities/utilities.setWarning.ts → components/database/CreateQuery.ts} +18 -13
- package/src/{@modules/@database/database.cache.ts → components/database/GetCachedEvents.ts} +19 -14
- package/src/components/database/ImportBoundaries.ts +168 -0
- package/src/components/database/ImportBroadcastify.ts +60 -0
- package/src/components/database/ImportCities.ts +87 -0
- package/src/{@modules/@database/database.shapefiles.ts → components/database/ImportShapefiles.ts} +31 -37
- package/src/components/database/ImportStanza.ts +43 -0
- package/src/components/database/InitializeDatabase.ts +71 -0
- package/src/components/images/GenerateGraphic.ts +234 -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/stanza.getAwipsType.ts → components/stanza/GetAwipsType.ts} +19 -18
- package/src/components/stanza/ValidateStanza.ts +62 -0
- package/src/components/utilities/CreateHttp.ts +83 -0
- package/src/{@modules/@utilities/utilities.getFormattedTime.ts → components/utilities/GetFormattedTime.ts} +3 -3
- package/src/components/utilities/GetLatestIssuance.ts +32 -0
- package/src/components/utilities/GetMatched.ts +38 -0
- package/src/{@modules/@utilities/utilities.getShapeNearestPoint.ts → components/utilities/GetShapeNearestPoint.ts} +24 -19
- package/src/components/utilities/GetUnionPolygon.ts +36 -0
- package/src/components/utilities/QueueManager.ts +70 -0
- package/src/components/utilities/SetCronSchedule.ts +98 -0
- package/src/{@core/core.clearEvents.ts → components/utilities/SetDebug.ts} +17 -12
- package/src/components/utilities/SetEventEmit.ts +42 -0
- package/src/{@modules/@utilities/utilities.setSettings.ts → components/utilities/SetSettings.ts} +7 -7
- package/src/{@modules/@utilities/utilities.setSleep.ts → 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/xmpp.xDeploy.ts → components/xmpp/DeployXMPP.ts} +26 -27
- package/src/components/xmpp/ErrorXMPP.ts +27 -0
- package/src/{@modules/@xmpp/xmpp.xError.ts → components/xmpp/OfflineXMPP.ts} +17 -9
- package/src/{@modules/@xmpp/xmpp.xOnline.ts → components/xmpp/OnlineXMPP.ts} +21 -20
- package/src/components/xmpp/ReconnectXMPP.ts +64 -0
- package/src/components/xmpp/StanzaXMPP.ts +63 -0
- package/src/{@building/building.tags.ts → core/ClearEvents.ts} +12 -5
- package/src/{@core/core.getVersion.ts → core/GetEvents.ts} +5 -6
- package/src/core/GetNodes.ts +24 -0
- package/src/{@core/core.getNodes.ts → core/GetRandomEvent.ts} +5 -6
- package/src/core/GetVersion.ts +24 -0
- package/src/core/ManualEvent.ts +55 -0
- package/src/core/QueryStanza.ts +40 -0
- package/src/core/SetNode.ts +87 -0
- package/src/core/StartService.ts +62 -0
- package/src/core/StopService.ts +32 -0
- package/src/enums/AWIPS.ts +366 -0
- package/src/{@dictionaries/dictionaries.eventActions.ts → enums/Actions.ts} +3 -3
- package/src/{@dictionaries/dictionaries.eventCancelMessages.ts → enums/Cancellation.ts} +4 -3
- package/src/{@dictionaries/dictionaries.eventCauses.ts → enums/Causes.ts} +3 -3
- package/src/{@dictionaries/dictionaries.statusCorrelationText.ts → enums/Correlations.ts} +3 -3
- package/src/enums/Enhanced.ts +70 -0
- package/src/{@dictionaries/dictionaries.eventTypes.ts → enums/Events.ts} +3 -3
- package/src/{@dictionaries/dictionaries.regExp.ts → enums/Expressions.ts} +5 -4
- package/src/{@core/core.getEvents.ts → enums/GlobalFilter.ts} +7 -8
- package/src/{@dictionaries/dictionaries.hailStrings.ts → enums/Hail.ts} +9 -4
- package/src/{@dictionaries/dictionaries.officeICAOs.ts → enums/ICAO.ts} +5 -3
- package/src/enums/Matches.ts +60 -0
- package/src/{@dictionaries/dictionaries.eventProducts.ts → enums/Products.ts} +3 -3
- package/src/{@dictionaries/dictionaries.eventRecords.ts → enums/Records.ts} +3 -3
- package/src/{@dictionaries/dictionaries.eventSeverity.ts → enums/Severity.ts} +3 -3
- package/src/{@dictionaries/dictionaries.shapefileLinks.ts → enums/Shapefiles.ts} +3 -3
- package/src/enums/States.ts +136 -0
- package/src/{@dictionaries/dictionaries.eventStatus.ts → enums/Status.ts} +3 -3
- package/src/enums/Strings.ts +22 -0
- package/src/enums/Tags.ts +172 -0
- package/src/{@dictionaries/dictionaries.testSignatures.ts → enums/Testing.ts} +5 -4
- package/src/enums/Themes.ts +70 -0
- package/src/events/ParseAPI.ts +129 -0
- package/src/{@events/events.text.ts → events/ParseText.ts} +32 -23
- package/src/{@events/events.ugc.ts → events/ParseUGC.ts} +36 -26
- package/src/events/ParseVTEC.ts +88 -0
- package/src/index.ts +60 -38
- package/src/manager/MakeEvents.ts +110 -0
- package/src/manager/RemoveEvent.ts +74 -0
- package/src/{@manager/manager.setHash.ts → manager/SetHash.ts} +19 -15
- package/src/manager/UpdateEvents.ts +35 -0
- package/src/manager/UpdateNode.ts +62 -0
- package/src/manager/ValidateEvents.ts +144 -0
- package/src/{@parsers/@hvtec/hvtec.extract.ts → parsers/hvtec/HVExtract.ts} +13 -13
- package/src/parsers/text/GetDescriptionFromProduct.ts +59 -0
- package/src/parsers/text/GetEmbededText.ts +57 -0
- package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
- package/src/parsers/text/GetStringText.ts +58 -0
- package/src/{@parsers/@text/text.getTextFromProduct.ts → parsers/text/GetTextFromProduct.ts} +12 -12
- package/src/parsers/ugc/GetCache.ts +24 -0
- package/src/{@parsers/@ugc/ugc.expiry.ts → parsers/ugc/GetExpiry.ts} +3 -3
- package/src/{@parsers/@ugc/ugc.header.ts → parsers/ugc/GetHeader.ts} +6 -6
- package/src/parsers/ugc/GetLocations.ts +57 -0
- package/src/parsers/ugc/GetZonePolygon.ts +73 -0
- package/src/{@parsers/@ugc/ugc.zones.ts → parsers/ugc/GetZones.ts} +3 -3
- package/src/{@modules/@utilities/utilities.setListener.ts → parsers/ugc/SetCache.ts} +13 -10
- package/src/{@parsers/@ugc/ugc.extract.ts → parsers/ugc/UGCExtract.ts} +15 -15
- package/src/{@parsers/@pvtec/pvtec.expires.ts → parsers/vtec/GetExpiry.ts} +3 -3
- package/src/parsers/vtec/VTECExtract.ts +49 -0
- package/src/{@types/types.attributes.ts → static/Attributes.ts} +2 -3
- package/src/{@types/type.event.ts → static/Event.ts} +11 -8
- package/src/{@types/type.properties.ts → static/Properties.ts} +17 -10
- package/src/{@types/types.stanza.ts → static/Stanza.ts} +2 -2
- package/src/tasks/CreateTasks.ts +123 -0
- package/src/{@core/core.stop.ts → tasks/TaskGenerateJSON.ts} +14 -12
- package/src/tasks/TaskGenerateText.ts +34 -0
- package/src/tasks/TaskSendNTFY.ts +97 -0
- package/src/tasks/TaskSendWebhook.ts +107 -0
- package/src/types/Actions.ts +37 -0
- package/src/{@types/types.hvtec.ts → types/HVTEC.ts} +6 -6
- package/src/{@types/types.hash.ts → types/Hash.ts} +5 -5
- package/src/types/Nodes.ts +29 -0
- package/src/{@types/types.settings.ts → types/Settings.ts} +42 -10
- package/src/{@types/types.compiled.ts → types/StanzaCompiled.ts} +15 -14
- package/src/{@types/types.ugc.ts → types/UGC.ts} +5 -5
- package/src/{@modules/@utilities/utilities.getSettings.ts → types/VTEC.ts} +12 -7
- package/tools/build.js +47 -0
- package/tsconfig.json +28 -1
- package/dist/index.d.mts +0 -239
- package/dist/index.d.ts +0 -239
- package/src/@building/building.create.ts +0 -42
- package/src/@building/building.properties.ts +0 -89
- package/src/@building/building.tracking.ts +0 -68
- package/src/@building/building.validate.ts +0 -147
- package/src/@core/core.getRandomEvent.ts +0 -25
- package/src/@core/core.setNode.ts +0 -81
- package/src/@core/core.start.ts +0 -61
- package/src/@dictionaries/dictionaries.betterEventNames.ts +0 -99
- package/src/@dictionaries/dictionaries.eventAwipAbreviations.ts +0 -364
- package/src/@dictionaries/dictionaries.eventTags.ts +0 -93
- package/src/@dictionaries/dictionaries.eventsMatchText.ts +0 -36
- package/src/@dictionaries/dictionaries.transcribedMessageReplacements.ts +0 -68
- package/src/@events/events.api.ts +0 -113
- package/src/@events/events.vtec.ts +0 -87
- package/src/@manager/manager.mkEvent.ts +0 -96
- package/src/@manager/manager.rmEvent.ts +0 -49
- package/src/@manager/manager.updateEvents.ts +0 -35
- package/src/@manager/manager.updateNodes.ts +0 -55
- package/src/@manager/manager.updateWebhooks.ts +0 -50
- package/src/@modules/@database/database.init.ts +0 -45
- package/src/@modules/@database/database.stanza.ts +0 -48
- package/src/@modules/@eas/eas.setEasTone.ts +0 -137
- package/src/@modules/@stanza/stanza.validate.ts +0 -50
- package/src/@modules/@utilities/utilities.createHttp.ts +0 -85
- package/src/@modules/@utilities/utilities.createWebhook.ts +0 -115
- package/src/@modules/@utilities/utilities.setCronSchedule.ts +0 -65
- package/src/@modules/@utilities/utilities.setEventEmit.ts +0 -41
- package/src/@modules/@utilities/utilities.setTimeoutAction.ts +0 -59
- package/src/@modules/@xmpp/xmpp.xOffline.ts +0 -38
- package/src/@modules/@xmpp/xmpp.xReconnect.ts +0 -64
- package/src/@modules/@xmpp/xmpp.xStanza.ts +0 -63
- package/src/@parsers/@pvtec/pvtec.extract.ts +0 -49
- package/src/@parsers/@text/text.getDescriptionFromProduct.ts +0 -53
- package/src/@parsers/@text/text.getPolygonFromProduct.ts +0 -32
- package/src/@parsers/@text/text.getXML.ts +0 -61
- package/src/@parsers/@ugc/ugc.coordinates.ts +0 -110
- package/src/@parsers/@ugc/ugc.locations.ts +0 -29
- package/src/@types/types.pvtec.ts +0 -30
- package/src/@types/types.webhook.ts +0 -27
- package/test.js +0 -91
- package/tsup.config.ts +0 -16
- /package/{CODE_OF_CONDUCT.md → .github/CODE_OF_CONDUCT.md} +0 -0
- /package/{LICENSE → .github/LICENSE} +0 -0
- /package/{SECURITY.md → .github/SECURITY.md} +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
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 { EnumStateFIPS } from "@Enums/States"
|
|
21
|
+
import { Bootstrap } from "@Bootstrap"
|
|
22
|
+
import { CreateHttp } from "@Utilities/CreateHttp"
|
|
23
|
+
import { CreateQuery } from "@Database/CreateQuery"
|
|
24
|
+
import { SetWarning } from "@Utilities/SetWarning"
|
|
25
|
+
import { feature } from "topojson-client"
|
|
26
|
+
|
|
27
|
+
type BoundaryRow = {
|
|
28
|
+
id: string
|
|
29
|
+
type: `state` | `county`
|
|
30
|
+
state: string
|
|
31
|
+
name: string
|
|
32
|
+
geometry: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const ImportBoundaries = async (): Promise<void> => {
|
|
36
|
+
try {
|
|
37
|
+
const existing = CreateQuery({ Query: `SELECT type, COUNT(*) AS count FROM boundaries GROUP BY type`}) as { type: string, count: number }[]
|
|
38
|
+
const existingStates = existing.find(row => row.type === `state`)?.count ?? 0
|
|
39
|
+
const existingCounties = existing.find(row => row.type === `county`)?.count ?? 0
|
|
40
|
+
|
|
41
|
+
if (existingStates > 0 || existingCounties > 0) {
|
|
42
|
+
SetWarning({ Message: `Boundary database already contains ${existingStates} states and ${existingCounties} counties, skipping import` })
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const boundaries = await CreateHttp({
|
|
47
|
+
URL: Bootstrap.Settings.BoundarySettings.BoundaryDatabase,
|
|
48
|
+
Timeout: 5000
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
if (boundaries.error || !boundaries.message) {
|
|
52
|
+
SetWarning({ Message: `Failed to download boundary database` })
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let database: any
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
database = JSON.parse(boundaries.message)
|
|
60
|
+
} catch {
|
|
61
|
+
SetWarning({ Message: `Failed to parse boundary database` })
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (database?.type !== `Topology` || !database?.objects?.states || !database?.objects?.counties) {
|
|
66
|
+
SetWarning({ Message: `Boundary database is missing states or counties` })
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let states: any
|
|
71
|
+
let counties: any
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
states = feature(database, database.objects.states)
|
|
75
|
+
counties = feature(database, database.objects.counties)
|
|
76
|
+
} catch (error: unknown) {
|
|
77
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
78
|
+
SetWarning({ Message: `Failed to convert boundary database: ${message}` })
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!Array.isArray(states?.features) || !Array.isArray(counties?.features)) {
|
|
83
|
+
SetWarning({ Message: `Boundary database contains invalid state or county data` })
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const insert = `INSERT OR REPLACE INTO boundaries (id, type, state, name, geometry) VALUES (?, ?, ?, ?, ?)`
|
|
88
|
+
const stateRows: BoundaryRow[] = []
|
|
89
|
+
const countyRows: BoundaryRow[] = []
|
|
90
|
+
let skippedStates = 0
|
|
91
|
+
let skippedCounties = 0
|
|
92
|
+
|
|
93
|
+
for (const state of states.features) {
|
|
94
|
+
if (!state?.geometry || state.id === undefined || state.id === null) {
|
|
95
|
+
skippedStates++
|
|
96
|
+
continue
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const fips = String(state.id).padStart(2, `0`)
|
|
100
|
+
const abbreviation = EnumStateFIPS[fips]
|
|
101
|
+
|
|
102
|
+
if (!abbreviation) {
|
|
103
|
+
skippedStates++
|
|
104
|
+
continue
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
stateRows.push({
|
|
108
|
+
id: fips,
|
|
109
|
+
type: `state`,
|
|
110
|
+
state: abbreviation,
|
|
111
|
+
name: state.properties?.name ?? abbreviation,
|
|
112
|
+
geometry: JSON.stringify(state.geometry)
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
for (const county of counties.features) {
|
|
117
|
+
if (!county?.geometry || county.id === undefined || county.id === null) {
|
|
118
|
+
skippedCounties++
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const fips = String(county.id).padStart(5, `0`)
|
|
123
|
+
const stateFIPS = fips.slice(0, 2)
|
|
124
|
+
const abbreviation = EnumStateFIPS[stateFIPS]
|
|
125
|
+
|
|
126
|
+
if (!abbreviation) {
|
|
127
|
+
skippedCounties++
|
|
128
|
+
continue
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
countyRows.push({
|
|
132
|
+
id: fips,
|
|
133
|
+
type: `county`,
|
|
134
|
+
state: abbreviation,
|
|
135
|
+
name: county.properties?.name ?? fips,
|
|
136
|
+
geometry: JSON.stringify(county.geometry)
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
SetWarning({ Message: `Importing ${stateRows.length} states and ${countyRows.length} counties` })
|
|
141
|
+
|
|
142
|
+
const transaction = Bootstrap.Database.transaction((rows: BoundaryRow[]) => {
|
|
143
|
+
for (const row of rows) {
|
|
144
|
+
CreateQuery({
|
|
145
|
+
Query: insert,
|
|
146
|
+
Parameters: [row.id, row.type, row.state, row.name, row.geometry]
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
transaction(stateRows)
|
|
152
|
+
transaction(countyRows)
|
|
153
|
+
|
|
154
|
+
const imported = CreateQuery({ Query: `SELECT type, COUNT(*) AS count FROM boundaries GROUP BY type`}) as { type: string, count: number }[]
|
|
155
|
+
const importedStates = imported.find(row => row.type === `state`)?.count ?? 0
|
|
156
|
+
const importedCounties = imported.find(row => row.type === `county`)?.count ?? 0
|
|
157
|
+
|
|
158
|
+
if (importedStates !== stateRows.length || importedCounties !== countyRows.length) {
|
|
159
|
+
SetWarning({ Message: `Boundary import verification failed: ${importedStates} states and ${importedCounties} counties` })
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
SetWarning({ Message: `Imported ${importedStates} states and ${importedCounties} counties` })
|
|
164
|
+
} catch (error: unknown) {
|
|
165
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
166
|
+
SetWarning({ Message: `An error occurred while importing boundaries: ${message}` })
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
import { CreateHttp } from "@Utilities/CreateHttp"
|
|
22
|
+
import { SetWarning } from "@Utilities/SetWarning"
|
|
23
|
+
import { CreateQuery } from "@Database/CreateQuery";
|
|
24
|
+
|
|
25
|
+
export const ImportBroadcastify = async (): Promise<void> => {
|
|
26
|
+
const settings = Bootstrap.Settings;
|
|
27
|
+
const broadcastify = await CreateHttp({
|
|
28
|
+
URL: settings.BroadcastifySettings.BroadcastifyDatabase,
|
|
29
|
+
Timeout: 5000,
|
|
30
|
+
});
|
|
31
|
+
if (!broadcastify.error) {
|
|
32
|
+
const states = JSON.parse(broadcastify.message);
|
|
33
|
+
const insert = `INSERT INTO broadcastify (state, county, feed, type, link) VALUES (?, ?, ?, ?, ?)`;
|
|
34
|
+
const transaction = Bootstrap.Database.transaction((rows: any[]) => {
|
|
35
|
+
for (const row of rows) {
|
|
36
|
+
CreateQuery({ Query: insert, Parameters: row });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const batch: any[] = [];
|
|
40
|
+
for (const state of states) {
|
|
41
|
+
SetWarning({ Message: `Importing ${state.counties.length} counties from ${state.state} for Broadcastify` });
|
|
42
|
+
for (const county of state.counties) {
|
|
43
|
+
const countyName = county.county;
|
|
44
|
+
for (const feed of county.feeds) {
|
|
45
|
+
batch.push([
|
|
46
|
+
state.state,
|
|
47
|
+
countyName,
|
|
48
|
+
feed.name,
|
|
49
|
+
feed.type,
|
|
50
|
+
feed.link
|
|
51
|
+
]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
transaction(batch);
|
|
56
|
+
}
|
|
57
|
+
if (broadcastify.error) {
|
|
58
|
+
SetWarning({ Message: `Error importing Broadcastify data: ${broadcastify.message}` });
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
import { EnumStates } from "@Enums/States"
|
|
20
|
+
import { Bootstrap } from "@Bootstrap"
|
|
21
|
+
import { CreateHttp } from "@Utilities/CreateHttp"
|
|
22
|
+
import { CreateQuery } from "@Database/CreateQuery"
|
|
23
|
+
import { SetWarning } from "@Utilities/SetWarning"
|
|
24
|
+
|
|
25
|
+
interface CityRow {
|
|
26
|
+
id: string
|
|
27
|
+
name: string
|
|
28
|
+
state: string
|
|
29
|
+
county: string
|
|
30
|
+
population: number | string
|
|
31
|
+
lat: number | string
|
|
32
|
+
lon: number | string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const ImportCities = async (): Promise<void> => {
|
|
36
|
+
const cities = await CreateHttp({
|
|
37
|
+
URL: Bootstrap.Settings.BoundarySettings.CityDatabase,
|
|
38
|
+
Timeout: 5000
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
if (cities.error || !cities.message) {
|
|
42
|
+
SetWarning({ Message: `Failed to download city database` })
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let database: unknown
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
database = JSON.parse(cities.message)
|
|
50
|
+
} catch {
|
|
51
|
+
SetWarning({ Message: `Failed to parse city database` })
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!Array.isArray(database)) {
|
|
56
|
+
SetWarning({ Message: `Failed to parse city database` })
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const StateCodes: Record<string, string> = Object.fromEntries(
|
|
61
|
+
Object.entries(EnumStates).map(([code, name]) => [name, code])
|
|
62
|
+
);
|
|
63
|
+
const insert = `INSERT INTO cities (id, name, state, county, population, lat, lon) VALUES (?, ?, ?, ?, ?, ?, ?)`
|
|
64
|
+
const cityRows: CityRow[] = []
|
|
65
|
+
for (const city of database) {
|
|
66
|
+
if (city.country != `US`) continue
|
|
67
|
+
cityRows.push({
|
|
68
|
+
id: city.id,
|
|
69
|
+
name: city.name,
|
|
70
|
+
state: StateCodes[city.admin1] ?? null,
|
|
71
|
+
county: city.admin2,
|
|
72
|
+
population: city.pop ?? null,
|
|
73
|
+
lat: city.lat,
|
|
74
|
+
lon: city.lon
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
SetWarning({ Message: `Importing ${cityRows.length} cities` })
|
|
78
|
+
const transaction = Bootstrap.Database.transaction((rows: CityRow[]) => {
|
|
79
|
+
for (const row of rows) {
|
|
80
|
+
CreateQuery({
|
|
81
|
+
Query: insert,
|
|
82
|
+
Parameters: [row.id, row.name, row.state, row.county, row.population, row.lat, row.lon]
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
transaction(cityRows)
|
|
87
|
+
}
|
package/src/{@modules/@database/database.shapefiles.ts → components/database/ImportShapefiles.ts}
RENAMED
|
@@ -11,55 +11,50 @@
|
|
|
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
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
20
|
+
import { EnumShapefiles } from "@Enums/Shapefiles"
|
|
21
|
+
import { Bootstrap } from "@Bootstrap"
|
|
22
|
+
import { SetSleep } from "@Utilities/SetSleep"
|
|
23
|
+
import { SetWarning } from "@Utilities/SetWarning"
|
|
24
|
+
import { CreateQuery } from "@Database/CreateQuery"
|
|
25
|
+
import { existsSync, mkdirSync, writeFileSync, unlinkSync, rm } from "fs"
|
|
26
|
+
import { resolve, extname} from "path"
|
|
27
|
+
import { loadAsync } from "jszip"
|
|
28
|
+
import { read } from "shapefile"
|
|
29
29
|
|
|
30
|
-
export const
|
|
31
|
-
const settings = bootstrap.settings as TypeSettings;
|
|
30
|
+
export const ImportShapefiles = async (): Promise<void> => {
|
|
32
31
|
try {
|
|
33
|
-
const tShapefiles =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
await setSleep({timeout: 1e3});
|
|
38
|
-
setWarning({ message: `Shapefiles are currently building, please DO NOT close your terminal. The shapefiles will not finish and will remain incomplete. If you do mess up, you will need to delete ${settings.Database} and restart the application.` })
|
|
39
|
-
for (const shapefile of shapefileLinks) {
|
|
32
|
+
const tShapefiles = CreateQuery({ Query: `SELECT COUNT(*) AS count FROM shapefiles` })[0] as { count: number };
|
|
33
|
+
if (tShapefiles.count === 0) {
|
|
34
|
+
await SetSleep({Timeout: 1e3});
|
|
35
|
+
for (const shapefile of EnumShapefiles) {
|
|
40
36
|
const response = await fetch(shapefile.link);
|
|
41
37
|
const arrayBuff = await response.arrayBuffer();
|
|
42
38
|
const content = await loadAsync(arrayBuff);
|
|
43
|
-
const directory = resolve(__dirname,
|
|
44
|
-
if (!
|
|
45
|
-
|
|
39
|
+
const directory = resolve(__dirname, `shapefiles`);
|
|
40
|
+
if (!existsSync(directory)) {
|
|
41
|
+
mkdirSync(directory, { recursive: true });
|
|
46
42
|
}
|
|
47
43
|
for (const file of Object.keys(content.files)) {
|
|
48
44
|
if (file.endsWith('.shp') || file.endsWith('.dbf')) {
|
|
49
45
|
const data = await content.files[file].async(`nodebuffer`)
|
|
50
46
|
const output = resolve(directory, `${shapefile?.name ?? ``}_${shapefile?.id ?? ``}${extname(file)}`)
|
|
51
|
-
|
|
47
|
+
writeFileSync(output, data)
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
|
-
const filepath = resolve(__dirname, '
|
|
50
|
+
const filepath = resolve(__dirname, 'shapefiles', shapefile.name + '_' + shapefile.id)
|
|
55
51
|
const { features } = await read(
|
|
56
52
|
filepath,
|
|
57
53
|
filepath,
|
|
58
54
|
);
|
|
59
|
-
|
|
60
|
-
const insert =
|
|
61
|
-
|
|
62
|
-
const transaction = bootstrap.database.transaction((entries: any[]) => {
|
|
55
|
+
SetWarning({ Message: `Importing ${features.length} features from ${shapefile.name}_${shapefile.id} for Shapefiles` })
|
|
56
|
+
const insert = `INSERT INTO shapefiles (id, location, source, geometry) VALUES (?, ?, ?, ?)`;
|
|
57
|
+
const transaction = Bootstrap.Database.transaction((entries: any[]) => {
|
|
63
58
|
for (const entry of entries) {
|
|
64
59
|
const { properties, geometry } = entry;
|
|
65
60
|
let final: string, location: string;
|
|
@@ -79,18 +74,17 @@ export const importShapefiles = async (): Promise<void> => {
|
|
|
79
74
|
final = properties.ID ?? properties.WFO
|
|
80
75
|
location = properties.NAME;
|
|
81
76
|
}
|
|
82
|
-
insert
|
|
77
|
+
CreateQuery({ Query: insert, Parameters: [final, location, `${shapefile.name}_${shapefile.id}`, JSON.stringify(geometry)] })
|
|
83
78
|
}
|
|
84
79
|
})
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
setWarning({ message: `Cleaned up temporary files for ${shapefile.name}_${shapefile.id}` })
|
|
80
|
+
unlinkSync(`${filepath}.shp`)
|
|
81
|
+
unlinkSync(`${filepath}.dbf`)
|
|
88
82
|
transaction(features)
|
|
89
83
|
}
|
|
90
|
-
|
|
91
|
-
fs.rm(resolve(__dirname, '../../shapefiles'), { recursive: true, force: true }, () => {});
|
|
84
|
+
rm(resolve(__dirname, 'shapefiles'), { recursive: true, force: true }, () => {});
|
|
92
85
|
}
|
|
93
|
-
} catch (error) {
|
|
94
|
-
|
|
86
|
+
} catch (error: unknown) {
|
|
87
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
88
|
+
SetWarning( {Message: `An error occurred while compiling shapefiles: ${message}` })
|
|
95
89
|
}
|
|
96
90
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { TypeSettings } from "Types/Settings"
|
|
21
|
+
import { TypeStanzaCompiled } from "Types/StanzaCompiled"
|
|
22
|
+
import { Bootstrap } from "@Bootstrap"
|
|
23
|
+
import { SetWarning } from "@Utilities/SetWarning"
|
|
24
|
+
import { CreateQuery } from "@Database/CreateQuery"
|
|
25
|
+
|
|
26
|
+
export const ImportStanza = async (Stanza: TypeStanzaCompiled): Promise<void> => {
|
|
27
|
+
const settings = Bootstrap.Settings as TypeSettings;
|
|
28
|
+
try {
|
|
29
|
+
if (!settings.NOAAWeatherWireServiceSettings.CacheSettings.Enabled) { return }
|
|
30
|
+
CreateQuery({ Query: `INSERT OR IGNORE INTO stanzas (type, stanza, issued) VALUES (?, ?, ?)`, Parameters: [Stanza.Type.Type, JSON.stringify(Stanza), Stanza.Attributes.issue] })
|
|
31
|
+
const count = CreateQuery({ Query: `SELECT COUNT(*) as total FROM stanzas` }) as { total: number };
|
|
32
|
+
const max = settings.NOAAWeatherWireServiceSettings.CacheSettings.MaxDatabaseHistory;
|
|
33
|
+
if (count.total > max) {
|
|
34
|
+
const toDelete = count.total - max;
|
|
35
|
+
if (toDelete > 0) {
|
|
36
|
+
CreateQuery({ Query: `DELETE FROM stanzas WHERE id IN (SELECT id FROM stanzas ORDER BY issued ASC LIMIT ?)`, Parameters: [toDelete] })
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} catch (error: unknown) {
|
|
40
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
41
|
+
SetWarning({ Message: `An error occurred while importing stanza: ${message}` })
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -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
|
+
import { TypeSettings } from "Types/Settings"
|
|
21
|
+
import { Bootstrap } from "@Bootstrap"
|
|
22
|
+
import { SetWarning } from "@Utilities/SetWarning"
|
|
23
|
+
import { ImportShapefiles } from "@Database/ImportShapefiles"
|
|
24
|
+
import { ImportBroadcastify } from "@Database/ImportBroadcastify"
|
|
25
|
+
import { ImportBoundaries } from "@Database/ImportBoundaries"
|
|
26
|
+
import { ImportCities } from "@Database/ImportCities"
|
|
27
|
+
import { CreateQuery } from "@Database/CreateQuery"
|
|
28
|
+
import { existsSync, writeFileSync } from "fs"
|
|
29
|
+
import sqlite3 from "better-sqlite3"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
export const InitializeDatabase = async (): Promise<void> => {
|
|
33
|
+
const settings = Bootstrap.Settings as TypeSettings;
|
|
34
|
+
try {
|
|
35
|
+
if (!existsSync(settings.Database)) {
|
|
36
|
+
writeFileSync(settings.Database, '')
|
|
37
|
+
SetWarning({ Message: `Creating new database at ${settings.Database}` })
|
|
38
|
+
}
|
|
39
|
+
Bootstrap.Database = new sqlite3(settings.Database);
|
|
40
|
+
CreateQuery({ Query: `CREATE TABLE IF NOT EXISTS stanzas ( id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT, issued TEXT, stanza TEXT )` })
|
|
41
|
+
const isNeedingShapefiles = CreateQuery({ Query: `SELECT name FROM sqlite_master WHERE type='table' AND name='shapefiles';` }) as { name: string }[];
|
|
42
|
+
const isNeedingBroadcastify = CreateQuery({ Query: `SELECT name FROM sqlite_master WHERE type='table' AND name='broadcastify';` }) as { name: string }[];
|
|
43
|
+
const isNeedingBoundaries = CreateQuery({ Query: `SELECT name FROM sqlite_master WHERE type='table' AND name='boundaries';` }) as { name: string }[];
|
|
44
|
+
const isNeedingCities = CreateQuery({ Query: `SELECT name FROM sqlite_master WHERE type='table' AND name='cities';` }) as { name: string }[];
|
|
45
|
+
|
|
46
|
+
if (isNeedingShapefiles.length === 0 || isNeedingBroadcastify.length === 0 || isNeedingBoundaries.length === 0 || isNeedingCities.length === 0) {
|
|
47
|
+
CreateQuery({ Query: `CREATE TABLE IF NOT EXISTS broadcastify ( state TEXT, county TEXT, feed TEXT, type TEXT, link TEXT)` })
|
|
48
|
+
CreateQuery({ Query: `CREATE TABLE IF NOT EXISTS shapefiles ( id, location TEXT, source TEXT, geometry TEXT )` })
|
|
49
|
+
CreateQuery({ Query: `CREATE INDEX IF NOT EXISTS idx_shapefiles_id ON shapefiles (id)` })
|
|
50
|
+
CreateQuery({ Query: `CREATE TABLE IF NOT EXISTS boundaries (id TEXT PRIMARY KEY, type TEXT NOT NULL, state TEXT, name TEXT, geometry TEXT NOT NULL );` })
|
|
51
|
+
CreateQuery({ Query: `CREATE TABLE IF NOT EXISTS cities ( id TEXT PRIMARY KEY, name TEXT, state TEXT, county TEXT, population TEXT, lat REAL NOT NULL, lon REAL NOT NULL);`});
|
|
52
|
+
SetWarning({Message: `Required database tables are currently building, please ${Bootstrap.Colors.Red}DO NOT${Bootstrap.Colors.Reset} close your terminal. The building will not finish and will remain incomplete. If you do mess up, you will need to delete ${settings.Database} and restart the application.` })
|
|
53
|
+
if (isNeedingCities.length === 0) {
|
|
54
|
+
await ImportCities();
|
|
55
|
+
}
|
|
56
|
+
if (isNeedingBroadcastify.length === 0) {
|
|
57
|
+
await ImportBroadcastify();
|
|
58
|
+
}
|
|
59
|
+
if (isNeedingBoundaries.length === 0) {
|
|
60
|
+
await ImportBoundaries();
|
|
61
|
+
}
|
|
62
|
+
if (isNeedingShapefiles.length === 0) {
|
|
63
|
+
await ImportShapefiles();
|
|
64
|
+
}
|
|
65
|
+
SetWarning({ Message: `Database initialization complete. You may now close your terminal or continue using the application.` })
|
|
66
|
+
}
|
|
67
|
+
} catch (error: unknown) {
|
|
68
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
69
|
+
SetWarning({ Message: `An error occurred while initializing the database: ${message}` })
|
|
70
|
+
}
|
|
71
|
+
}
|