@tak-ps/node-cot 5.0.5 → 5.0.6
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/CHANGELOG.md +4 -0
- package/dist/lib/chat.js +2 -0
- package/dist/lib/chat.js.map +1 -1
- package/dist/lib/cot.js +24 -19
- package/dist/lib/cot.js.map +1 -1
- package/dist/lib/schema.json +0 -1
- package/dist/package.json +1 -1
- package/dist/test/chat.test.js +64 -60
- package/dist/test/chat.test.js.map +1 -1
- package/dist/test/cot-itak.test.js +79 -74
- package/dist/test/cot-itak.test.js.map +1 -1
- package/dist/test/flow-tags.test.js +2 -2
- package/dist/test/flow-tags.test.js.map +1 -1
- package/dist/test/from_geojson.test.js +93 -61
- package/dist/test/from_geojson.test.js.map +1 -1
- package/lib/chat.ts +2 -0
- package/lib/cot.ts +24 -20
- package/lib/schema.json +0 -1
- package/lib/types.ts +1 -1
- package/package.json +1 -1
- package/test/chat.test.ts +63 -60
- package/test/cot-itak.test.ts +79 -75
- package/test/flow-tags.test.ts +2 -2
- package/test/from_geojson.test.ts +92 -64
package/test/cot-itak.test.ts
CHANGED
|
@@ -6,89 +6,93 @@ test('Decode iTAK COT message', (t) => {
|
|
|
6
6
|
|
|
7
7
|
const cot = new CoT(packet);
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
if (!cot.raw.event.detail) {
|
|
10
|
+
t.fail('No Detail Section')
|
|
11
|
+
} else {
|
|
12
|
+
t.ok(cot.raw.event.detail['_flow-tags_']);
|
|
13
|
+
delete cot.raw.event.detail['_flow-tags_'];
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'_attributes': {
|
|
15
|
-
'version': '2.0',
|
|
16
|
-
'uid': 'C94B9215-9BD4-4DBE-BDE1-83625F09153F',
|
|
17
|
-
'type': 'a-f-G-E-V-C',
|
|
18
|
-
'time': '2023-07-18T15:23:09.00Z',
|
|
19
|
-
'start': '2023-07-18T15:23:09.00Z',
|
|
20
|
-
'stale': '2023-07-18T15:25:09.00Z',
|
|
21
|
-
'how': 'm-g',
|
|
22
|
-
},
|
|
23
|
-
'point': {
|
|
15
|
+
t.deepEquals(cot.raw, {
|
|
16
|
+
'event': {
|
|
24
17
|
'_attributes': {
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
_attributes: {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
18
|
+
'version': '2.0',
|
|
19
|
+
'uid': 'C94B9215-9BD4-4DBE-BDE1-83625F09153F',
|
|
20
|
+
'type': 'a-f-G-E-V-C',
|
|
21
|
+
'time': '2023-07-18T15:23:09.00Z',
|
|
22
|
+
'start': '2023-07-18T15:23:09.00Z',
|
|
23
|
+
'stale': '2023-07-18T15:25:09.00Z',
|
|
24
|
+
'how': 'm-g',
|
|
25
|
+
},
|
|
26
|
+
'point': {
|
|
27
|
+
'_attributes': {
|
|
28
|
+
'lat': '41.52309645',
|
|
29
|
+
'lon': '-107.72376567',
|
|
30
|
+
'hae': '1681.23725821',
|
|
31
|
+
'ce': '9999999',
|
|
32
|
+
'le': '9999999'
|
|
38
33
|
}
|
|
39
34
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
detail: {
|
|
36
|
+
contact: {
|
|
37
|
+
_attributes: {
|
|
38
|
+
callsign: 'DFPC-iSchmidt',
|
|
39
|
+
phone: '7204258729',
|
|
40
|
+
endpoint: '*:-1:stcp'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
uid: { _attributes: { Droid: 'DFPC-iSchmidt' } },
|
|
44
|
+
__group: { _attributes: { name: 'Yellow', role: 'Team Member' } },
|
|
45
|
+
precisionlocation: { _attributes: { geopointsrc: 'GPS', altsrc: '???' } },
|
|
46
|
+
status: { _attributes: { battery: '100' } },
|
|
47
|
+
takv: { _attributes: { device: 'iPhone', platform: 'iTAK', os: '16.5.1', version: '2.7.0.609' } },
|
|
48
|
+
track: { _attributes: { speed: '0.00000000', course: '137.23542786' } }
|
|
49
|
+
}
|
|
46
50
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
t.deepEquals(cot.to_geojson(), {
|
|
54
|
+
id: 'C94B9215-9BD4-4DBE-BDE1-83625F09153F',
|
|
55
|
+
type: 'Feature',
|
|
56
|
+
properties: {
|
|
57
|
+
callsign: 'DFPC-iSchmidt',
|
|
58
|
+
droid: "DFPC-iSchmidt",
|
|
59
|
+
type: 'a-f-G-E-V-C',
|
|
60
|
+
how: 'm-g',
|
|
61
|
+
center: [ -107.72376567, 41.52309645, 1681.23725821 ],
|
|
62
|
+
time: '2023-07-18T15:23:09.00Z',
|
|
63
|
+
start: '2023-07-18T15:23:09.00Z',
|
|
64
|
+
stale: '2023-07-18T15:25:09.00Z',
|
|
65
|
+
course: 137.23542786,
|
|
66
|
+
speed: 0,
|
|
67
|
+
contact: {
|
|
68
|
+
"phone": "7204258729",
|
|
69
|
+
"endpoint": "*:-1:stcp"
|
|
70
|
+
},
|
|
71
|
+
group: {
|
|
72
|
+
name: 'Yellow',
|
|
73
|
+
role: 'Team Member'
|
|
74
|
+
},
|
|
75
|
+
precisionlocation: {
|
|
76
|
+
"geopointsrc": "GPS",
|
|
77
|
+
"altsrc": "???"
|
|
78
|
+
},
|
|
79
|
+
status: {
|
|
80
|
+
"battery": "100"
|
|
81
|
+
},
|
|
82
|
+
takv: {
|
|
83
|
+
"device": "iPhone",
|
|
84
|
+
"platform": "iTAK",
|
|
85
|
+
"os": "16.5.1",
|
|
86
|
+
"version": "2.7.0.609"
|
|
87
|
+
}
|
|
49
88
|
|
|
50
|
-
t.deepEquals(cot.to_geojson(), {
|
|
51
|
-
id: 'C94B9215-9BD4-4DBE-BDE1-83625F09153F',
|
|
52
|
-
type: 'Feature',
|
|
53
|
-
properties: {
|
|
54
|
-
callsign: 'DFPC-iSchmidt',
|
|
55
|
-
droid: "DFPC-iSchmidt",
|
|
56
|
-
type: 'a-f-G-E-V-C',
|
|
57
|
-
how: 'm-g',
|
|
58
|
-
center: [ -107.72376567, 41.52309645, 1681.23725821 ],
|
|
59
|
-
time: '2023-07-18T15:23:09.00Z',
|
|
60
|
-
start: '2023-07-18T15:23:09.00Z',
|
|
61
|
-
stale: '2023-07-18T15:25:09.00Z',
|
|
62
|
-
course: 137.23542786,
|
|
63
|
-
speed: 0,
|
|
64
|
-
contact: {
|
|
65
|
-
"phone": "7204258729",
|
|
66
|
-
"endpoint": "*:-1:stcp"
|
|
67
|
-
},
|
|
68
|
-
group: {
|
|
69
|
-
name: 'Yellow',
|
|
70
|
-
role: 'Team Member'
|
|
71
|
-
},
|
|
72
|
-
precisionlocation: {
|
|
73
|
-
"geopointsrc": "GPS",
|
|
74
|
-
"altsrc": "???"
|
|
75
|
-
},
|
|
76
|
-
status: {
|
|
77
|
-
"battery": "100"
|
|
78
89
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"os": "16.5.1",
|
|
83
|
-
"version": "2.7.0.609"
|
|
90
|
+
geometry: {
|
|
91
|
+
type: 'Point',
|
|
92
|
+
coordinates: [ -107.72376567, 41.52309645, 1681.23725821 ]
|
|
84
93
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
geometry: {
|
|
88
|
-
type: 'Point',
|
|
89
|
-
coordinates: [ -107.72376567, 41.52309645, 1681.23725821 ]
|
|
90
|
-
}
|
|
91
|
-
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
92
96
|
|
|
93
97
|
t.end();
|
|
94
98
|
});
|
package/test/flow-tags.test.ts
CHANGED
|
@@ -11,8 +11,8 @@ test('FlowTags - Basic', (t) => {
|
|
|
11
11
|
message: 'Direct Message Test'
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
if (!cot.raw.event.detail['_flow-tags_']) {
|
|
15
|
-
t.fail()
|
|
14
|
+
if (!cot.raw.event.detail || !cot.raw.event.detail['_flow-tags_']) {
|
|
15
|
+
t.fail('No Detail Section')
|
|
16
16
|
} else {
|
|
17
17
|
t.equals(typeof cot.raw.event.detail['_flow-tags_'][`NodeCoT-${pkg.version}`], 'string');
|
|
18
18
|
}
|
|
@@ -23,13 +23,17 @@ test('CoT.from_geojson - Point', (t) => {
|
|
|
23
23
|
_attributes: { lat: '2.2', lon: '1.1', hae: '0.0', ce: '9999999.0', le: '9999999.0' }
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
if (!geo.raw.event.detail || !geo.raw.event.detail.remarks) {
|
|
27
|
+
t.fail('No Detail Section')
|
|
28
|
+
} else {
|
|
29
|
+
t.ok(geo.raw.event.detail['_flow-tags_']);
|
|
30
|
+
delete geo.raw.event.detail['_flow-tags_'];
|
|
31
|
+
|
|
32
|
+
t.deepEquals(geo.raw.event.detail, {
|
|
33
|
+
contact: { _attributes: { callsign: 'UNKNOWN' } },
|
|
34
|
+
remarks: { _attributes: {}, _text: '' }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
33
37
|
|
|
34
38
|
t.end();
|
|
35
39
|
});
|
|
@@ -62,26 +66,30 @@ test('CoT.from_geojson - Polygon', (t) => {
|
|
|
62
66
|
_attributes: { lat: '39.065', lon: '-108.54599999999999', hae: '0.0', ce: '9999999.0', le: '9999999.0' }
|
|
63
67
|
});
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{ _attributes: {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
if (!geo.raw.event.detail || !geo.raw.event.detail.remarks) {
|
|
70
|
+
t.fail('No Detail Section')
|
|
71
|
+
} else {
|
|
72
|
+
t.ok(geo.raw.event.detail['_flow-tags_']);
|
|
73
|
+
delete geo.raw.event.detail['_flow-tags_'];
|
|
74
|
+
|
|
75
|
+
t.deepEquals(geo.raw.event.detail, {
|
|
76
|
+
contact: { _attributes: { callsign: 'UNKNOWN' } },
|
|
77
|
+
link: [
|
|
78
|
+
{ _attributes: { point: '39.098,-108.587' } },
|
|
79
|
+
{ _attributes: { point: '39.032,-108.587' } },
|
|
80
|
+
{ _attributes: { point: '39.032,-108.505' } },
|
|
81
|
+
{ _attributes: { point: '39.098,-108.505' } },
|
|
82
|
+
{ _attributes: { point: '39.098,-108.587' } },
|
|
83
|
+
],
|
|
84
|
+
labels_on: { _attributes: { value: 'false' } },
|
|
85
|
+
tog: { _attributes: { enabled: '0' } },
|
|
86
|
+
strokeColor: { _attributes: { value: '-2130706688' } },
|
|
87
|
+
strokeWeight: { _attributes: { value: '3' } },
|
|
88
|
+
strokeStyle: { _attributes: { value: 'solid' } },
|
|
89
|
+
fillColor: { _attributes: { value: '-2130706688' } },
|
|
90
|
+
remarks: { _attributes: {}, _text: '' }
|
|
91
|
+
});
|
|
92
|
+
}
|
|
85
93
|
|
|
86
94
|
t.end();
|
|
87
95
|
});
|
|
@@ -114,25 +122,29 @@ test('CoT.from_geojson - LineString', (t) => {
|
|
|
114
122
|
_attributes: { lat: '39.098', lon: '-108.505', hae: '0.0', ce: '9999999.0', le: '9999999.0' }
|
|
115
123
|
});
|
|
116
124
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{ _attributes: {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
125
|
+
if (!geo.raw.event.detail || !geo.raw.event.detail.remarks) {
|
|
126
|
+
t.fail('No Detail Section')
|
|
127
|
+
} else {
|
|
128
|
+
t.ok(geo.raw.event.detail['_flow-tags_']);
|
|
129
|
+
delete geo.raw.event.detail['_flow-tags_'];
|
|
130
|
+
|
|
131
|
+
t.deepEquals(geo.raw.event.detail, {
|
|
132
|
+
contact: { _attributes: { callsign: 'UNKNOWN' } },
|
|
133
|
+
link: [
|
|
134
|
+
{ _attributes: { point: '39.098,-108.587' } },
|
|
135
|
+
{ _attributes: { point: '39.032,-108.587' } },
|
|
136
|
+
{ _attributes: { point: '39.032,-108.505' } },
|
|
137
|
+
{ _attributes: { point: '39.098,-108.505' } },
|
|
138
|
+
{ _attributes: { point: '39.098,-108.587' } }
|
|
139
|
+
],
|
|
140
|
+
labels_on: { _attributes: { value: 'false' } },
|
|
141
|
+
tog: { _attributes: { enabled: '0' } },
|
|
142
|
+
strokeColor: { _attributes: { value: '-2130706688' } },
|
|
143
|
+
strokeWeight: { _attributes: { value: '3' } },
|
|
144
|
+
strokeStyle: { _attributes: { value: 'solid' } },
|
|
145
|
+
remarks: { _attributes: {}, _text: '' }
|
|
146
|
+
});
|
|
147
|
+
}
|
|
136
148
|
|
|
137
149
|
t.end();
|
|
138
150
|
});
|
|
@@ -206,13 +218,17 @@ test('CoT.from_geojson - Icon', (t) => {
|
|
|
206
218
|
}
|
|
207
219
|
});
|
|
208
220
|
|
|
209
|
-
|
|
210
|
-
|
|
221
|
+
if (!geo.raw.event.detail || !geo.raw.event.detail.remarks) {
|
|
222
|
+
t.fail('No Detail Section')
|
|
223
|
+
} else {
|
|
224
|
+
t.ok(geo.raw.event.detail['_flow-tags_']);
|
|
225
|
+
delete geo.raw.event.detail['_flow-tags_'];
|
|
211
226
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
227
|
+
t.deepEquals(geo.raw.event.detail, {
|
|
228
|
+
contact: { _attributes: { callsign: 'UNKNOWN' } },
|
|
229
|
+
usericon: { _attributes: { iconsetpath: '66f14976-4b62-4023-8edb-d8d2ebeaa336/Public Safety Air/EMS_ROTOR.png' } }, remarks: { _attributes: {}, _text: '' }
|
|
230
|
+
});
|
|
231
|
+
}
|
|
216
232
|
|
|
217
233
|
t.end();
|
|
218
234
|
});
|
|
@@ -254,7 +270,7 @@ test('CoT.from_geojson - Height Above Earth', (t) => {
|
|
|
254
270
|
});
|
|
255
271
|
|
|
256
272
|
test('CoT.from_geojson - Course & Speed', (t) => {
|
|
257
|
-
|
|
273
|
+
const cot = CoT.from_geojson({
|
|
258
274
|
type: 'Feature',
|
|
259
275
|
properties: {
|
|
260
276
|
course: 260,
|
|
@@ -264,18 +280,24 @@ test('CoT.from_geojson - Course & Speed', (t) => {
|
|
|
264
280
|
type: 'Point',
|
|
265
281
|
coordinates: [1.1, 2.2]
|
|
266
282
|
}
|
|
267
|
-
})
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
if (!cot.raw.event.detail || !cot.raw.event.detail.remarks) {
|
|
286
|
+
t.fail('No Detail Section')
|
|
287
|
+
} else {
|
|
288
|
+
t.deepEquals(cot.raw.event.detail.track, {
|
|
289
|
+
_attributes: {
|
|
290
|
+
'course': '260',
|
|
291
|
+
'speed': '120'
|
|
292
|
+
}
|
|
293
|
+
}, 'track');
|
|
294
|
+
}
|
|
273
295
|
|
|
274
296
|
t.end();
|
|
275
297
|
});
|
|
276
298
|
|
|
277
299
|
test('CoT.from_geojson - Remarks', (t) => {
|
|
278
|
-
|
|
300
|
+
const cot = CoT.from_geojson({
|
|
279
301
|
type: 'Feature',
|
|
280
302
|
properties: {
|
|
281
303
|
course: 260,
|
|
@@ -286,10 +308,16 @@ test('CoT.from_geojson - Remarks', (t) => {
|
|
|
286
308
|
type: 'Point',
|
|
287
309
|
coordinates: [1.1, 2.2]
|
|
288
310
|
}
|
|
289
|
-
})
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
if (!cot.raw.event.detail || !cot.raw.event.detail.remarks) {
|
|
314
|
+
t.fail('No Detail Section')
|
|
315
|
+
} else {
|
|
316
|
+
t.deepEquals(cot.raw.event.detail.remarks, {
|
|
317
|
+
_attributes: {},
|
|
318
|
+
_text: 'Test'
|
|
319
|
+
}, 'track');
|
|
320
|
+
}
|
|
293
321
|
|
|
294
322
|
t.end();
|
|
295
323
|
});
|