diff --git a/CHANGELOG.md b/CHANGELOG.md index 7417710..ac59962 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### Change Log for Node-RED Worldmap + - v2.5.6 - Let node accept plain text payload kml or nvg input - v2.5.5 - Fix NVG import to handle symbols for points - v2.5.4 - Fix delete of hulls - v2.5.3 - Swap default satellite layer diff --git a/README.md b/README.md index 7b9bfb9..394901e 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ map web page for plotting "things" on. ### Updates +- v2.5.6 - Let node accept plain text payload kml or nvg input - v2.5.5 - Fix NVG import to handle symbols for points - v2.5.4 - Fix delete of hulls - v2.5.3 - Swap default satellite layer diff --git a/package.json b/package.json index 19501e7..768b44a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-web-worldmap", - "version": "2.5.5", + "version": "2.5.6", "description": "A Node-RED node to provide a web page of a world map for plotting things on.", "dependencies": { "cgi": "0.3.1", @@ -8,6 +8,9 @@ "express": "^4.16.4", "sockjs": "~0.3.21" }, + "bundledDependencies": [ + "cgi","compression","express","sockjs" + ], "repository": { "type": "git", "url": "https://github.com/dceejay/RedMap" diff --git a/worldmap.js b/worldmap.js index ce47d68..7526ffb 100644 --- a/worldmap.js +++ b/worldmap.js @@ -269,13 +269,13 @@ module.exports = function(RED) { if (msg.payload.name.substr(-1) === '_') { var a = node.pointsarray[msg.payload.name.substr(0,msg.payload.name.length-1)].pop(); node.pointsarray[msg.payload.name.substr(0,msg.payload.name.length-1)] = [ a ]; - node.send(newmsg); + node.send(newmsg); } else { delete node.pointsarray[msg.payload.name]; } //newmsg.payload.name = msg.payload.name + "_"; - node.send(newmsg); + node.send(newmsg); return; } if (!msg.payload.hasOwnProperty("lat") || !msg.payload.hasOwnProperty("lon")) { return; } @@ -356,7 +356,7 @@ module.exports = function(RED) { }); } else { - doTrack(m); + doTrack(m); } }); @@ -379,25 +379,25 @@ module.exports = function(RED) { for (const val of Object.values(points)) { arr.push(val); } - + arr.sort(function (a, b) { return a.lat != b.lat ? a.lat - b.lat : a.lon - b.lon; }); - + var n = arr.length; var hull = []; - + for (var i = 0; i < 2 * n; i++) { var j = i < n ? i : 2 * n - 1 - i; while (hull.length >= 2 && removeMiddle(hull[hull.length - 2], hull[hull.length - 1], arr[j])) hull.pop(); hull.push(arr[j]); } - + hull.pop(); return hull; } - + var removeMiddle = function(a, b, c) { var cross = (a.lat- b.lat) * (c.lon - b.lon) - (a.lon - b.lon) * (c.lat- b.lat); var dot = (a.lat- b.lat) * (c.lat- b.lat) + (a.lon - b.lon) * (c.lon - b.lon); @@ -427,27 +427,27 @@ module.exports = function(RED) { newmsg.payload.name = newmsg.payload[node.prop]; newmsg.payload.clickable = true; - if (leafletHull.length === 1 && oldl === 2) { + if (leafletHull.length === 1 && oldl === 2) { newmsg.payload.deleted = true; node.send(newmsg); } - if (leafletHull.length === 2 && (oldl === 1 || oldl ===3)) { + if (leafletHull.length === 2 && (oldl === 1 || oldl ===3)) { newmsg.payload.deleted = true; node.send(newmsg); delete newmsg.payload.deleted; - newmsg.payload.line = leafletHull; + newmsg.payload.line = leafletHull; node.send(newmsg); } - if (leafletHull.length === 3 && oldl === 2) { + if (leafletHull.length === 3 && oldl === 2) { newmsg.payload.deleted = true; node.send(newmsg); delete newmsg.payload.deleted; } if (leafletHull.length >= 3) { - newmsg.payload.area = leafletHull; + newmsg.payload.area = leafletHull; node.send(newmsg); } - + oldl = leafletHull.length; } } @@ -461,7 +461,7 @@ module.exports = function(RED) { }); } else { - doHull(m); + doHull(m); } }); @@ -471,6 +471,7 @@ module.exports = function(RED) { } RED.nodes.registerType("worldmap-hull",WorldMapHull); + RED.httpNode.get("/.ui-worldmap", function(req, res) { res.send(ui ? "true": "false"); }); diff --git a/worldmap/worldmap.js b/worldmap/worldmap.js index 0062d21..0fa398b 100644 --- a/worldmap/worldmap.js +++ b/worldmap/worldmap.js @@ -93,7 +93,7 @@ var connect = function() { }; ws.onmessage = function(e) { var data = JSON.parse(e.data); - //console.log("DATA" typeof data,data); + // console.log("DATA",typeof data,data); if (data) { if (Array.isArray(data)) { //console.log("ARRAY"); @@ -110,6 +110,14 @@ var connect = function() { // map.fitBounds(bnds.pad(0.25)); } else { + if (typeof data === "string" && data.indexOf("