@tak-ps/node-cot 2.1.1 → 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 +8 -0
- package/index.js +1 -3
- package/package.json +1 -1
- package/src/util.js +15 -0
- package/src/xml.js +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,14 @@
|
|
|
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
|
+
|
|
17
|
+
### v2.1.2
|
|
18
|
+
|
|
19
|
+
- :bug: Parse GeoJSON Point coords into COT
|
|
20
|
+
|
|
13
21
|
### v2.1.1
|
|
14
22
|
|
|
15
23
|
- :bug: Parse GeoJSON Point coords into COT
|
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,18 +40,22 @@ 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
|
}
|
|
52
56
|
|
|
53
|
-
cot.event.point.lon = feature.geometry.coordinates[0];
|
|
54
|
-
cot.event.point.lat = feature.geometry.coordinates[1];
|
|
57
|
+
cot.event.point._attributes.lon = feature.geometry.coordinates[0];
|
|
58
|
+
cot.event.point._attributes.lat = feature.geometry.coordinates[1];
|
|
55
59
|
|
|
56
60
|
return new XMLCot(cot);
|
|
57
61
|
}
|
|
@@ -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
|