@ham2k/lib-cqmag-data 0.0.1

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/src/index.js ADDED
@@ -0,0 +1,7 @@
1
+ const CQZONES = require("../data/cqzones.json")
2
+ const CQZONES_FOR_STATES = require("../data/cqz-for-states.json")
3
+
4
+ module.exports = {
5
+ CQZONES,
6
+ CQZONES_FOR_STATES,
7
+ }
@@ -0,0 +1,33 @@
1
+ // const { parse } = require("csv/dist/cjs/sync.cjs") // Use this line when running tests
2
+
3
+ const CTYData = require("../../../country-file/src/data/bigcty.json")
4
+ const WAE = require("../../data/wae.json")
5
+
6
+ function preprocessCQWWData(dxcc) {
7
+ const cqww = {}
8
+
9
+ Object.keys(dxcc).forEach((code) => {
10
+ if (!dxcc[code].deleted) {
11
+ if (cqww[dxcc[code].entityPrefix])
12
+ console.log("Duplicate prefix", dxcc[code].entityPrefix, code, cqww[dxcc[code].entityPrefix])
13
+ cqww[dxcc[code].entityPrefix] = dxcc[code]
14
+ }
15
+ })
16
+
17
+ Object.keys(WAE).forEach((prefix) => {
18
+ let entity = WAE[prefix]
19
+ if (dxcc[entity.dxccCode]) entity = { ...entity, ...dxcc[entity.dxccCode] }
20
+
21
+ if (CTYData.entities[entity.entityPrefix]) entity = { ...entity, ...CTYData.entities[entity.entityPrefix] }
22
+
23
+ entity = { ...entity, ...WAE[prefix] }
24
+
25
+ cqww[entity.entityPrefix] = entity
26
+ })
27
+
28
+ return cqww
29
+ }
30
+
31
+ module.exports = {
32
+ preprocessCQWWData,
33
+ }
@@ -0,0 +1,31 @@
1
+ const { preprocessCQWWData } = require("./preprocessing")
2
+ const dxcc = require("../../../dxcc/src/data/dxccByCode.json") // @ham2k/data-dxcc")
3
+
4
+ describe("preprocessCQWWData", () => {
5
+ it("should work", () => {
6
+ const cqww = preprocessCQWWData(dxcc)
7
+
8
+ expect(Object.values(cqww).length).toEqual(346)
9
+
10
+ expect(cqww["VE"].dxccName).toEqual("Canada")
11
+ expect(cqww["K"].dxccName).toEqual("United States of America")
12
+
13
+ expect(cqww["*IG9"].dxccName).toEqual("Italy")
14
+ expect(cqww["*IG9"].name).toEqual("African Italy")
15
+ expect(cqww["*IG9"].continent).toEqual("AF")
16
+
17
+ expect(cqww["*JW/b"].dxccName).toEqual("Svalbard")
18
+ expect(cqww["*JW/b"].name).toEqual("Bear I.")
19
+
20
+ expect(cqww["*TA1"].dxccName).toEqual("Turkey")
21
+ expect(cqww["*TA1"].name).toEqual("European Turkey")
22
+ expect(cqww["*TA1"].continent).toEqual("EU")
23
+ expect(cqww["TA"].continent).toEqual("AS")
24
+
25
+ expect(cqww["*4U1V"].dxccName).toEqual("Austria")
26
+ expect(cqww["*4U1V"].name).toEqual("UN Vienna Int. Center")
27
+
28
+ expect(cqww["*GM/s"].dxccName).toEqual("Scotland")
29
+ expect(cqww["*GM/s"].name).toEqual("Shetland Is.")
30
+ })
31
+ })