node-red-contrib-tak-registration 0.8.3 → 0.9.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/package.json +1 -1
- package/tak-registration.js +24 -1
package/package.json
CHANGED
package/tak-registration.js
CHANGED
|
@@ -407,7 +407,7 @@ module.exports = function(RED) {
|
|
|
407
407
|
<point lat="${msg.payload.lat || 0}" lon="${msg.payload.lon || 0}" hae="${parseInt(msg.payload.alt || invalid)}" le="9999999.0" ce="9999999.0"/>
|
|
408
408
|
<detail>
|
|
409
409
|
<takv device="${os.hostname()}" os="${os.platform()}" platform="NRedTAK" version="${ver}"/>
|
|
410
|
-
<track course="${msg.payload.bearing || 0}" speed="${parseInt(msg.payload.speed) || 0}"/>
|
|
410
|
+
<track course="${msg.payload.bearing || 9999999.0}" speed="${parseInt(msg.payload.speed) || 0}"/>
|
|
411
411
|
<contact callsign="${msg.payload.name}"/>
|
|
412
412
|
<remarks source="NRedTAK">${tag}</remarks>
|
|
413
413
|
${shapeXML}
|
|
@@ -418,6 +418,29 @@ module.exports = function(RED) {
|
|
|
418
418
|
node.send(msg);
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
+
// Maybe a simple event json update (eg from an ingest - tweak and send back)
|
|
422
|
+
// Note this is not 100% reverse of the ingest... but seems to work mostly...
|
|
423
|
+
else if (typeof msg.payload === "object" && msg.payload.hasOwnProperty("event") ) {
|
|
424
|
+
const ev = msg.payload.event;
|
|
425
|
+
msg.topic = ev.type;
|
|
426
|
+
msg.payload = `<event version="${ev.version}" uid="${ev.uid}" type="${ev.type}" time="${ev.time}" start="${ev.start}" stale="${ev.stale}" how="${ev.how}">
|
|
427
|
+
<point lat="${ev.point.lat || 0}" lon="${ev.point.lon || 0}" hae="${ev.detail?.height?.value || ev.point.hae || 9999999.0}" le="${ev.point.le}" ce="${ev.point.ce}"/>
|
|
428
|
+
<detail>
|
|
429
|
+
<takv device="${os.hostname()}" os="${os.platform()}" platform="NRedTAK" version="${ver}"/>`
|
|
430
|
+
if (ev.detail?.track) {
|
|
431
|
+
msg.payload += `<track speed="${ev.detail.track.speed}" course="${ev.detail.track.course}"/>`;
|
|
432
|
+
}
|
|
433
|
+
if (ev.detail?.color) {
|
|
434
|
+
msg.payload += `<color argb="${ev.detail.color.argb}"/>`;
|
|
435
|
+
}
|
|
436
|
+
msg.payload += `<contact callsign="${ev.detail?.contact?.callsign}"/>
|
|
437
|
+
<remarks source="${node.callsign}">${msg.remarks || ev.detail?.remarks}</remarks>
|
|
438
|
+
</detail>
|
|
439
|
+
</event>`
|
|
440
|
+
msg.payload = msg.payload.replace(/>\s+</g, "><");
|
|
441
|
+
node.send(msg);
|
|
442
|
+
}
|
|
443
|
+
|
|
421
444
|
// Drop anything we don't handle yet.
|
|
422
445
|
else {
|
|
423
446
|
node.log("Dropped: "+JSON.stringify(msg.payload));
|