@tak-ps/node-cot 2.1.3 → 2.2.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/CHANGELOG.md +9 -0
- package/package.json +1 -1
- package/src/util.js +2 -2
- package/src/xml.js +17 -10
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,15 @@
|
|
|
10
10
|
|
|
11
11
|
## Version History
|
|
12
12
|
|
|
13
|
+
### v2.2.1
|
|
14
|
+
|
|
15
|
+
- :bug: `event.display` => `event.detail`
|
|
16
|
+
|
|
17
|
+
### v2.2.0
|
|
18
|
+
|
|
19
|
+
- :bug: Bugfixes in default values
|
|
20
|
+
- :bug: Ensure `to_geojson` is a function call that doesn't modify underlying message
|
|
21
|
+
|
|
13
22
|
### v2.1.3
|
|
14
23
|
|
|
15
24
|
- :bug: Continue squashing a ton of small expectation issues to get an MVP of a point on TAK
|
package/package.json
CHANGED
package/src/util.js
CHANGED
|
@@ -27,13 +27,13 @@ export default class Util {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Return an event.
|
|
30
|
+
* Return an event.detail object with as many defaults as possible
|
|
31
31
|
*
|
|
32
32
|
* @param {String} [callsign=UNKNOWN] Display Callsign
|
|
33
33
|
*
|
|
34
34
|
* @returns {Object}
|
|
35
35
|
*/
|
|
36
|
-
static
|
|
36
|
+
static cot_event_detail(callsign = 'UNKNOWN') {
|
|
37
37
|
return {
|
|
38
38
|
contact: {
|
|
39
39
|
_attributes: { callsign }
|
package/src/xml.js
CHANGED
|
@@ -43,7 +43,7 @@ export default class XMLCot {
|
|
|
43
43
|
event: {
|
|
44
44
|
_attributes: Util.cot_event_attr(feature.properties.type || 'a-f-G', feature.properties.how || 'm-g'),
|
|
45
45
|
point: Util.cot_point(),
|
|
46
|
-
|
|
46
|
+
detail: Util.cot_event_detail(feature.properties.callsign)
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
|
|
@@ -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:
|
|
75
|
+
id: raw.event._attributes.uid,
|
|
71
76
|
type: 'Feature',
|
|
72
77
|
properties: {
|
|
73
|
-
callsign:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
82
|
-
|
|
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
|
}
|