@tak-ps/node-cot 2.0.0 → 2.1.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 +8 -0
- package/package.json +1 -1
- package/src/util.js +3 -0
- package/src/xml.js +5 -2
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
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,15 +41,18 @@ 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
|
|
|
53
|
+
cot.event.point.lon = feature.geometry.coordinates[0];
|
|
54
|
+
cot.event.point.lat = feature.geometry.coordinates[1];
|
|
55
|
+
|
|
53
56
|
return new XMLCot(cot);
|
|
54
57
|
}
|
|
55
58
|
|