@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 +4 -0
- package/index.js +1 -3
- package/package.json +1 -1
- package/src/util.js +15 -0
- package/src/xml.js +8 -3
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|