From 1914ed3b9ce4e8a496049849a93282730b4fff02 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Tue, 17 Jul 2018 12:21:01 +0100 Subject: [PATCH] Tidy up other numeric inputs to close #39 --- CHANGELOG.md | 1 + README.md | 1 + package.json | 2 +- worldmap/index.html | 18 +++++++++--------- worldmap/worldmap.appcache | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a040250..f80811a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### Change Log for Node-RED Worldmap + - v1.3.5 - parse numeric inputs (speed, bearing etc) to remove any extra text. - v1.3.4 - Add ISS icon - v1.3.3 - Bugfix for inline satellite icon - v1.3.2 - Bugfix for inline svg icons diff --git a/README.md b/README.md index d7d38f8..ef55aaa 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ map web page for plotting "things" on. ### Updates +- v1.3.5 - parse numeric inputs (speed, bearing etc) to remove any extra text. - v1.3.4 - Add ISS icon - v1.3.3 - Bugfix for inline satellite icon - v1.3.2 - Bugfix for inline svg icons diff --git a/package.json b/package.json index 17578b6..b8c5273 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-web-worldmap", - "version": "1.3.4", + "version": "1.3.5", "description": "A Node-RED node to provide a web page of a world map for plotting things on.", "dependencies": { "cgi": "0.3.1", diff --git a/worldmap/index.html b/worldmap/index.html index 9c52394..f41306e 100644 --- a/worldmap/index.html +++ b/worldmap/index.html @@ -867,7 +867,7 @@ function setMarker(data) { title: data.name, color: (data.iconColor || "blue") }); - marker.setHeading(data.hdg||data.bearing); + marker.setHeading(parseFloat(data.hdg || data.bearing || "0")); q = 'https://www.bing.com/images/search?q='+data.icon+'%20%2B"'+encodeURIComponent(data.name)+'"'; words += 'Pictures
'; } @@ -877,7 +877,7 @@ function setMarker(data) { icon = ''; icon += ''; var svgplane = "data:image/svg+xml;base64," + btoa(icon); - var dir = data.hdg || data.bearing; + var dir = parseFloat(data.hdg || data.bearing || "0"); myMarker = L.divIcon({ className:"planeicon", iconAnchor: [16, 16], @@ -893,7 +893,7 @@ function setMarker(data) { icon = ''; icon+= ''; var svguav = "data:image/svg+xml;base64," + btoa(icon); - var dir = data.hdg || data.bearing; + var dir = parseFloat(data.hdg || data.bearing || "0"); myMarker = L.divIcon({ className:"uavicon", iconAnchor: [16, 16], @@ -906,7 +906,7 @@ function setMarker(data) { icon = ''; icon += ''; var svgcar = "data:image/svg+xml;base64," + btoa(icon); - var dir = data.hdg || data.bearing; + var dir = parseFloat(data.hdg || data.bearing || "0"); myMarker = L.divIcon({ className:"caricon", iconAnchor: [16, 16], @@ -919,7 +919,7 @@ function setMarker(data) { icon = ''; icon += ''; var svgarrow = "data:image/svg+xml;base64," + btoa(icon); - var dir = data.hdg || data.bearing; + var dir = parseFloat(data.hdg || data.bearing || "0"); myMarker = L.divIcon({ className:"arrowicon", iconAnchor: [16, 16], @@ -932,7 +932,7 @@ function setMarker(data) { icon = ''; icon += ''; var svgwind = "data:image/svg+xml;base64," + btoa(icon); - var dir = data.hdg || data.bearing; + var dir = parseFloat(data.hdg || data.bearing || "0"); myMarker = L.divIcon({ className:"windicon", iconAnchor: [16, 16], @@ -1115,14 +1115,14 @@ function setMarker(data) { if ((data.hdg != null) && (data.bearing == null)) { data.bearing = data.hdg; delete data.hdg; } if (data.bearing != null) { // if there is a heading - if (data.speed != null) { data.length = data.speed * 50; } // and a speed + if (data.speed != null) { data.length = parseFloat(data.speed || "0") * 50; } // and a speed if (data.length != null) { if (polygons[data.name] != null) { map.removeLayer(polygons[data.name]); } var x = ll.lng; // X coordinate var y = ll.lat * 1; // Y coordinate var ll1 = ll; - var angle = data.bearing * 1; - var lengthAsDegrees = data.length / 110540; // metres in a degree..ish + var angle = parseFloat(data.bearing); + var lengthAsDegrees = parseFloat(data.length || "0") / 110540; // metres in a degree..ish var polygon = null; if (data.accuracy != null) { data.accuracy = Number(data.accuracy); diff --git a/worldmap/worldmap.appcache b/worldmap/worldmap.appcache index 4a8d88f..7d91ce5 100644 --- a/worldmap/worldmap.appcache +++ b/worldmap/worldmap.appcache @@ -1,5 +1,5 @@ CACHE MANIFEST -# date: June 30th 2018 - v1.3.4 +# date: July 17th 2018 - v1.3.5 CACHE: index.html