@tak-ps/node-cot 2.1.3 → 2.2.0

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,11 @@
10
10
 
11
11
  ## Version History
12
12
 
13
+ ### v2.2.0
14
+
15
+ - :bug: Bugfixes in default values
16
+ - :bug: Ensure `to_geojson` is a function call that doesn't modify underlying message
17
+
13
18
  ### v2.1.3
14
19
 
15
20
  - :bug: Continue squashing a ton of small expectation issues to get an MVP of a point on TAK
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.3",
4
+ "version": "2.2.0",
5
5
  "description": "Lightweight JavaScript library for parsing and manipulating TAK messages",
6
6
  "main": "index.js",
7
7
  "scripts": {
package/src/xml.js CHANGED
@@ -66,20 +66,27 @@ export default class XMLCot {
66
66
  * @returns {Object}
67
67
  */
68
68
  to_geojson() {
69
+ const raw = JSON.parse(JSON.stringify(this.raw));
70
+ if (!raw.event.detail) raw.event.detail = {};
71
+ if (!raw.event.detail.contact) raw.event.detail.contact = {};
72
+ if (!raw.event.detail.contact._attributes) raw.event.detail.contact._attributes = {};
73
+
69
74
  const geojson = {
70
- id: this.raw.event._attributes.uid,
75
+ id: raw.event._attributes.uid,
71
76
  type: 'Feature',
72
77
  properties: {
73
- callsign: this.raw.event.display.contact._attributes.callsign || 'UNKNOWN',
74
- time: this.raw.event._attributes.time,
75
- start: this.raw.event._attributes.start,
76
- stale: this.raw.event._attributes.stale
78
+ callsign: raw.event.detail.contact._attributes.callsign || 'UNKNOWN',
79
+ type: raw.event._attributes.type,
80
+ how: raw.event._attributes.how,
81
+ time: raw.event._attributes.time,
82
+ start: raw.event._attributes.start,
83
+ stale: raw.event._attributes.stale
77
84
  },
78
85
  geometry: {
79
86
  type: 'Point',
80
87
  coordinates: [
81
- this.raw.event.point._attributes.lon,
82
- this.raw.event.point._attributes.lon
88
+ raw.event.point._attributes.lon,
89
+ raw.event.point._attributes.lon
83
90
  ]
84
91
  }
85
92
  };
@@ -99,11 +106,11 @@ export default class XMLCot {
99
106
  * @returns {XMLCot}
100
107
  */
101
108
  static ping() {
102
- return {
109
+ return new XMLCot({
103
110
  event: {
104
111
  _attributes: Util.cot_event_attr('t-x-c-t', 'h-g-i-g-o'),
105
112
  point: Util.cot_point()
106
113
  }
107
- };
114
+ });
108
115
  }
109
116
  }