@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.
@@ -6,89 +6,93 @@ test('Decode iTAK COT message', (t) => {
6
6
 
7
7
  const cot = new CoT(packet);
8
8
 
9
- t.ok(cot.raw.event.detail['_flow-tags_']);
10
- delete cot.raw.event.detail['_flow-tags_'];
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
- t.deepEquals(cot.raw, {
13
- 'event': {
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
- 'lat': '41.52309645',
26
- 'lon': '-107.72376567',
27
- 'hae': '1681.23725821',
28
- 'ce': '9999999',
29
- 'le': '9999999'
30
- }
31
- },
32
- detail: {
33
- contact: {
34
- _attributes: {
35
- callsign: 'DFPC-iSchmidt',
36
- phone: '7204258729',
37
- endpoint: '*:-1:stcp'
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
- uid: { _attributes: { Droid: 'DFPC-iSchmidt' } },
41
- __group: { _attributes: { name: 'Yellow', role: 'Team Member' } },
42
- precisionlocation: { _attributes: { geopointsrc: 'GPS', altsrc: '???' } },
43
- status: { _attributes: { battery: '100' } },
44
- takv: { _attributes: { device: 'iPhone', platform: 'iTAK', os: '16.5.1', version: '2.7.0.609' } },
45
- track: { _attributes: { speed: '0.00000000', course: '137.23542786' } }
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
- takv: {
80
- "device": "iPhone",
81
- "platform": "iTAK",
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
  });
@@ -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
- t.ok(geo.raw.event.detail['_flow-tags_']);
27
- delete geo.raw.event.detail['_flow-tags_'];
28
-
29
- t.deepEquals(geo.raw.event.detail, {
30
- contact: { _attributes: { callsign: 'UNKNOWN' } },
31
- remarks: { _attributes: {}, _text: '' }
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
- t.ok(geo.raw.event.detail['_flow-tags_']);
66
- delete geo.raw.event.detail['_flow-tags_'];
67
-
68
- t.deepEquals(geo.raw.event.detail, {
69
- contact: { _attributes: { callsign: 'UNKNOWN' } },
70
- link: [
71
- { _attributes: { point: '39.098,-108.587' } },
72
- { _attributes: { point: '39.032,-108.587' } },
73
- { _attributes: { point: '39.032,-108.505' } },
74
- { _attributes: { point: '39.098,-108.505' } },
75
- { _attributes: { point: '39.098,-108.587' } },
76
- ],
77
- labels_on: { _attributes: { value: 'false' } },
78
- tog: { _attributes: { enabled: '0' } },
79
- strokeColor: { _attributes: { value: '-2130706688' } },
80
- strokeWeight: { _attributes: { value: '3' } },
81
- strokeStyle: { _attributes: { value: 'solid' } },
82
- fillColor: { _attributes: { value: '-2130706688' } },
83
- remarks: { _attributes: {}, _text: '' }
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
- t.ok(geo.raw.event.detail['_flow-tags_']);
118
- delete geo.raw.event.detail['_flow-tags_'];
119
-
120
- t.deepEquals(geo.raw.event.detail, {
121
- contact: { _attributes: { callsign: 'UNKNOWN' } },
122
- link: [
123
- { _attributes: { point: '39.098,-108.587' } },
124
- { _attributes: { point: '39.032,-108.587' } },
125
- { _attributes: { point: '39.032,-108.505' } },
126
- { _attributes: { point: '39.098,-108.505' } },
127
- { _attributes: { point: '39.098,-108.587' } }
128
- ],
129
- labels_on: { _attributes: { value: 'false' } },
130
- tog: { _attributes: { enabled: '0' } },
131
- strokeColor: { _attributes: { value: '-2130706688' } },
132
- strokeWeight: { _attributes: { value: '3' } },
133
- strokeStyle: { _attributes: { value: 'solid' } },
134
- remarks: { _attributes: {}, _text: '' }
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
- t.ok(geo.raw.event.detail['_flow-tags_']);
210
- delete geo.raw.event.detail['_flow-tags_'];
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
- t.deepEquals(geo.raw.event.detail, {
213
- contact: { _attributes: { callsign: 'UNKNOWN' } },
214
- usericon: { _attributes: { iconsetpath: '66f14976-4b62-4023-8edb-d8d2ebeaa336/Public Safety Air/EMS_ROTOR.png' } }, remarks: { _attributes: {}, _text: '' }
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
- t.deepEquals(CoT.from_geojson({
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
- }).raw.event.detail.track, {
268
- _attributes: {
269
- 'course': '260',
270
- 'speed': '120'
271
- }
272
- }, 'track');
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
- t.deepEquals(CoT.from_geojson({
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
- }).raw.event.detail.remarks, {
290
- _attributes: {},
291
- _text: 'Test'
292
- }, 'track');
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
  });