Save object states and ignore non moving track updates
This commit is contained in:
parent
e2e3e439cb
commit
91d5398339
14
worldmap.js
14
worldmap.js
@ -177,6 +177,7 @@ module.exports = function(RED) {
|
||||
node.send(newmsg); // send the track to be deleted
|
||||
return;
|
||||
}
|
||||
if (!msg.payload.hasOwnProperty("lat") || !msg.payload.hasOwnProperty("lon")) { return; }
|
||||
if (!node.pointsarray.hasOwnProperty(msg.payload.name)) {
|
||||
node.pointsarray[msg.payload.name] = [];
|
||||
}
|
||||
@ -190,9 +191,16 @@ module.exports = function(RED) {
|
||||
}
|
||||
if (node.depth < 2) { return; } // if set less than 2 then don't bother.
|
||||
|
||||
node.pointsarray[msg.payload.name].push(msg.payload);
|
||||
if (node.pointsarray[msg.payload.name].length > node.depth) {
|
||||
node.pointsarray[msg.payload.name].shift();
|
||||
var still = false;
|
||||
if (node.pointsarray[msg.payload.name].length > 0) {
|
||||
var oldlat = node.pointsarray[msg.payload.name][node.pointsarray[msg.payload.name].length-1].lat;
|
||||
var oldlon = node.pointsarray[msg.payload.name][node.pointsarray[msg.payload.name].length-1].lon;
|
||||
if (msg.payload.lat === oldlat && msg.payload.lon === oldlon) { still = true; }
|
||||
}
|
||||
if (!still) { node.pointsarray[msg.payload.name].push(msg.payload);
|
||||
if (node.pointsarray[msg.payload.name].length > node.depth) {
|
||||
node.pointsarray[msg.payload.name].shift();
|
||||
}
|
||||
}
|
||||
var line = [];
|
||||
for (var i=0; i<node.pointsarray[msg.payload.name].length; i++) {
|
||||
|
@ -930,6 +930,7 @@ function setMarker(data) {
|
||||
delMarker(data.name);
|
||||
return;
|
||||
}
|
||||
|
||||
var ll;
|
||||
var lli = null;
|
||||
var opt = {};
|
||||
@ -978,6 +979,13 @@ function setMarker(data) {
|
||||
map.addLayer(overlays[lay]);
|
||||
//console.log("ADDED LAYER",lay,layers);
|
||||
}
|
||||
if (!allData.hasOwnProperty(data.name)) { allData[data.name] = {}; }
|
||||
delete data.action;
|
||||
Object.keys(data).forEach(key => {
|
||||
if (data[key] == null) { delete allData[data.name][key]; }
|
||||
else { allData[data.name][key] = data[key]; }
|
||||
});
|
||||
data = Object.assign({},allData[data.name]);
|
||||
}
|
||||
delete data.action;
|
||||
|
||||
@ -1055,12 +1063,6 @@ function setMarker(data) {
|
||||
else if (data.hasOwnProperty("latitude") && data.hasOwnProperty("longitude") && data.hasOwnProperty("intensity")) { lli = new L.LatLng((data.latitude*1), (data.longitude*1), (data.intensity*1)); }
|
||||
else { lli = ll }
|
||||
|
||||
// if (!allData.hasOwnProperty(data.name)) { allData[data.name] = {}; }
|
||||
// var foo = Object.assign(allData[data.name], data);
|
||||
// allData[data.name] = foo;
|
||||
// data = foo;
|
||||
// console.log("A1",foo,allData);
|
||||
|
||||
// Create the icons... handle plane, car, ship, wind, earthquake as specials
|
||||
var marker, myMarker;
|
||||
var icon, q;
|
||||
@ -1373,6 +1375,11 @@ function setMarker(data) {
|
||||
delete data.lon;
|
||||
if (data.layer) { delete data.layer; }
|
||||
if (data.lineColor) { delete data.lineColor; }
|
||||
if (data.color) { delete data.color; }
|
||||
if (data.weight) { delete data.weight; }
|
||||
if (data.tracklength) { delete data.tracklength; }
|
||||
if (data.dashArray) { delete data.dashArray; }
|
||||
if (data.fill) { delete data.fill; }
|
||||
if (data.draggable) { delete data.draggable; }
|
||||
for (var i in data) {
|
||||
if ((i != "name") && (i != "length")) {
|
||||
|
Loading…
Reference in New Issue
Block a user