@tak-ps/node-cot 2.0.0 → 2.1.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,10 @@
10
10
 
11
11
  ## Version History
12
12
 
13
+ ### v2.1.0
14
+
15
+ - :rocket: Allow setting `type` & `how` from GeoJSON
16
+
13
17
  ### v2.0.0
14
18
 
15
19
  - :rocket: Class based XML CoT approach
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tak-ps/node-cot",
3
3
  "type": "module",
4
- "version": "2.0.0",
4
+ "version": "2.1.0",
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
@@ -14,6 +14,9 @@ export default class Util {
14
14
  * @returns {Object}
15
15
  */
16
16
  static cot_event_attr(type, how) {
17
+ if (!type) throw new Error('type param required');
18
+ if (!how) throw new Error('how param required');
19
+
17
20
  return {
18
21
  ...Util.cot_version(),
19
22
  ...Util.cot_uuid(),
package/src/xml.js CHANGED
@@ -41,12 +41,12 @@ export default class XMLCot {
41
41
 
42
42
  const cot = {
43
43
  'event': {
44
- '_attributes': Util.cot_event_attr('a-f-G', 'm-g'),
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
  }
47
47
  };
48
48
 
49
- for (const key of ['time', 'start', 'stale']) {
49
+ for (const key of ['time', 'start', 'stale', 'type', 'how']) {
50
50
  if (feature.properties[key]) cot.event._attributes[key] = feature.properties[key];
51
51
  }
52
52