@tak-ps/node-cot 2.1.2 → 2.1.3

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 CHANGED
@@ -10,6 +10,10 @@
10
10
 
11
11
  ## Version History
12
12
 
13
+ ### v2.1.3
14
+
15
+ - :bug: Continue squashing a ton of small expectation issues to get an MVP of a point on TAK
16
+
13
17
  ### v2.1.2
14
18
 
15
19
  - :bug: Parse GeoJSON Point coords into COT
package/index.js CHANGED
@@ -1,5 +1,3 @@
1
1
  import XML from './src/xml.js';
2
2
 
3
- export {
4
- XML
5
- };
3
+ export { XML };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tak-ps/node-cot",
3
3
  "type": "module",
4
- "version": "2.1.2",
4
+ "version": "2.1.3",
5
5
  "description": "Lightweight JavaScript library for parsing and manipulating TAK messages",
6
6
  "main": "index.js",
7
7
  "scripts": {
package/src/util.js CHANGED
@@ -26,6 +26,21 @@ export default class Util {
26
26
  };
27
27
  }
28
28
 
29
+ /**
30
+ * Return an event.display object with as many defaults as possible
31
+ *
32
+ * @param {String} [callsign=UNKNOWN] Display Callsign
33
+ *
34
+ * @returns {Object}
35
+ */
36
+ static cot_event_display(callsign = 'UNKNOWN') {
37
+ return {
38
+ contact: {
39
+ _attributes: { callsign }
40
+ }
41
+ };
42
+ }
43
+
29
44
  /**
30
45
  * Generate a random UUID
31
46
  *
package/src/xml.js CHANGED
@@ -40,12 +40,16 @@ export default class XMLCot {
40
40
  if (!feature.properties) throw new Error('Feature must have properties');
41
41
 
42
42
  const cot = {
43
- 'event': {
44
- '_attributes': Util.cot_event_attr(feature.properties.type || 'a-f-G', feature.properties.how || 'm-g'),
45
- 'point': Util.cot_point()
43
+ event: {
44
+ _attributes: Util.cot_event_attr(feature.properties.type || 'a-f-G', feature.properties.how || 'm-g'),
45
+ point: Util.cot_point(),
46
+ display: Util.cot_event_display(feature.properties.callsign)
46
47
  }
47
48
  };
48
49
 
50
+ if (feature.id) cot.event._attributes.uid = feature.id;
51
+ if (feature.properties.callsign && !feature.id) cot.event._attributes.uid = feature.properties.callsign;
52
+
49
53
  for (const key of ['time', 'start', 'stale', 'type', 'how']) {
50
54
  if (feature.properties[key]) cot.event._attributes[key] = feature.properties[key];
51
55
  }
@@ -66,6 +70,7 @@ export default class XMLCot {
66
70
  id: this.raw.event._attributes.uid,
67
71
  type: 'Feature',
68
72
  properties: {
73
+ callsign: this.raw.event.display.contact._attributes.callsign || 'UNKNOWN',
69
74
  time: this.raw.event._attributes.time,
70
75
  start: this.raw.event._attributes.start,
71
76
  stale: this.raw.event._attributes.stale