Tidy up other numeric inputs

to close #39
This commit is contained in:
Dave Conway-Jones 2018-07-17 12:21:01 +01:00
parent d7d6be036a
commit 1914ed3b9c
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
5 changed files with 13 additions and 11 deletions

View File

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap ### 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.4 - Add ISS icon
- v1.3.3 - Bugfix for inline satellite icon - v1.3.3 - Bugfix for inline satellite icon
- v1.3.2 - Bugfix for inline svg icons - v1.3.2 - Bugfix for inline svg icons

View File

@ -9,6 +9,7 @@ map web page for plotting "things" on.
### Updates ### Updates
- v1.3.5 - parse numeric inputs (speed, bearing etc) to remove any extra text.
- v1.3.4 - Add ISS icon - v1.3.4 - Add ISS icon
- v1.3.3 - Bugfix for inline satellite icon - v1.3.3 - Bugfix for inline satellite icon
- v1.3.2 - Bugfix for inline svg icons - v1.3.2 - Bugfix for inline svg icons

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-contrib-web-worldmap", "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.", "description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": { "dependencies": {
"cgi": "0.3.1", "cgi": "0.3.1",

View File

@ -867,7 +867,7 @@ function setMarker(data) {
title: data.name, title: data.name,
color: (data.iconColor || "blue") 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)+'"'; q = 'https://www.bing.com/images/search?q='+data.icon+'%20%2B"'+encodeURIComponent(data.name)+'"';
words += '<a href=\''+q+'\' target="_thingpic">Pictures</a><br>'; words += '<a href=\''+q+'\' target="_thingpic">Pictures</a><br>';
} }
@ -877,7 +877,7 @@ function setMarker(data) {
icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="310px" height="310px" viewBox="0 0 310 310">'; icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="310px" height="310px" viewBox="0 0 310 310">';
icon += '<path d="M134.875,19.74c0.04-22.771,34.363-22.771,34.34,0.642v95.563L303,196.354v35.306l-133.144-43.821v71.424l30.813,24.072v27.923l-47.501-14.764l-47.501,14.764v-27.923l30.491-24.072v-71.424L3,231.66v-35.306l131.875-80.409V19.74z" fill="'+data.iconColor+'"/></svg>'; icon += '<path d="M134.875,19.74c0.04-22.771,34.363-22.771,34.34,0.642v95.563L303,196.354v35.306l-133.144-43.821v71.424l30.813,24.072v27.923l-47.501-14.764l-47.501,14.764v-27.923l30.491-24.072v-71.424L3,231.66v-35.306l131.875-80.409V19.74z" fill="'+data.iconColor+'"/></svg>';
var svgplane = "data:image/svg+xml;base64," + btoa(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({ myMarker = L.divIcon({
className:"planeicon", className:"planeicon",
iconAnchor: [16, 16], iconAnchor: [16, 16],
@ -893,7 +893,7 @@ function setMarker(data) {
icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100">'; icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100">';
icon+= '<path d="M62 82h-8V64h36c0-5-4-9-9-9H54v-8c0-3 4-5 4-11.1 0-4.4-3.6-8-8-8-4.4 0-8 3.6-8 8 0 5.1 4 8.1 4 11.1V55h-27c-5 0-9 4-9 9h36v18H38c-2.4 0-5 2.3-5 5L50 92l17-5C67 84.3 64.4 82 62 82z" fill="'+data.iconColor+'"/></svg>'; icon+= '<path d="M62 82h-8V64h36c0-5-4-9-9-9H54v-8c0-3 4-5 4-11.1 0-4.4-3.6-8-8-8-4.4 0-8 3.6-8 8 0 5.1 4 8.1 4 11.1V55h-27c-5 0-9 4-9 9h36v18H38c-2.4 0-5 2.3-5 5L50 92l17-5C67 84.3 64.4 82 62 82z" fill="'+data.iconColor+'"/></svg>';
var svguav = "data:image/svg+xml;base64," + btoa(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({ myMarker = L.divIcon({
className:"uavicon", className:"uavicon",
iconAnchor: [16, 16], iconAnchor: [16, 16],
@ -906,7 +906,7 @@ function setMarker(data) {
icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="47px" height="47px" viewBox="0 0 47 47">'; icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="47px" height="47px" viewBox="0 0 47 47">';
icon += '<path d="M29.395,0H17.636c-3.117,0-5.643,3.467-5.643,6.584v34.804c0,3.116,2.526,5.644,5.643,5.644h11.759 c3.116,0,5.644-2.527,5.644-5.644V6.584C35.037,3.467,32.511,0,29.395,0z M34.05,14.188v11.665l-2.729,0.351v-4.806L34.05,14.188z M32.618,10.773c-1.016,3.9-2.219,8.51-2.219,8.51H16.631l-2.222-8.51C14.41,10.773,23.293,7.755,32.618,10.773z M15.741,21.713 v4.492l-2.73-0.349V14.502L15.741,21.713z M13.011,37.938V27.579l2.73,0.343v8.196L13.011,37.938z M14.568,40.882l2.218-3.336 h13.771l2.219,3.336H14.568z M31.321,35.805v-7.872l2.729-0.355v10.048L31.321,35.805z" fill="'+data.iconColor+'"/></svg>'; icon += '<path d="M29.395,0H17.636c-3.117,0-5.643,3.467-5.643,6.584v34.804c0,3.116,2.526,5.644,5.643,5.644h11.759 c3.116,0,5.644-2.527,5.644-5.644V6.584C35.037,3.467,32.511,0,29.395,0z M34.05,14.188v11.665l-2.729,0.351v-4.806L34.05,14.188z M32.618,10.773c-1.016,3.9-2.219,8.51-2.219,8.51H16.631l-2.222-8.51C14.41,10.773,23.293,7.755,32.618,10.773z M15.741,21.713 v4.492l-2.73-0.349V14.502L15.741,21.713z M13.011,37.938V27.579l2.73,0.343v8.196L13.011,37.938z M14.568,40.882l2.218-3.336 h13.771l2.219,3.336H14.568z M31.321,35.805v-7.872l2.729-0.355v10.048L31.321,35.805z" fill="'+data.iconColor+'"/></svg>';
var svgcar = "data:image/svg+xml;base64," + btoa(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({ myMarker = L.divIcon({
className:"caricon", className:"caricon",
iconAnchor: [16, 16], iconAnchor: [16, 16],
@ -919,7 +919,7 @@ function setMarker(data) {
icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32px" height="32px" viewBox="0 0 32 32">'; icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32px" height="32px" viewBox="0 0 32 32">';
icon += '<path d="m16.2 0.6l-10.9 31 10.7-11.1 10.5 11.1 -10.3-31z" fill="'+data.iconColor+'"/></svg>'; icon += '<path d="m16.2 0.6l-10.9 31 10.7-11.1 10.5 11.1 -10.3-31z" fill="'+data.iconColor+'"/></svg>';
var svgarrow = "data:image/svg+xml;base64," + btoa(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({ myMarker = L.divIcon({
className:"arrowicon", className:"arrowicon",
iconAnchor: [16, 16], iconAnchor: [16, 16],
@ -932,7 +932,7 @@ function setMarker(data) {
icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32px" height="32px" viewBox="0 0 32 32">'; icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32px" height="32px" viewBox="0 0 32 32">';
icon += '<path d="M16.7 31.7l7-6.9c0.4-0.4 0.4-1 0-1.4 -0.4-0.4-1-0.4-1.4 0l-5.3 5.2V17.3l6.7-6.6c0.2-0.2 0.3-0.5 0.3-0.7v-9c0-0.9-1.1-1.3-1.7-0.7l-6.3 6.2L9.7 0.3C9.1-0.3 8 0.1 8 1.1v8.8c0 0.3 0.1 0.6 0.3 0.8l6.7 6.6v11.3l-5.3-5.2c-0.4-0.4-1-0.4-1.4 0 -0.4 0.4-0.4 1 0 1.4l7 6.9c0.2 0.2 0.5 0.3 0.7 0.3C16.2 32 16.5 31.9 16.7 31.7zM10 9.6V3.4l5 4.9v6.2L10 9.6zM17 8.3l5-4.9v6.2l-5 4.9V8.3z" fill="'+data.iconColor+'"/></svg>'; icon += '<path d="M16.7 31.7l7-6.9c0.4-0.4 0.4-1 0-1.4 -0.4-0.4-1-0.4-1.4 0l-5.3 5.2V17.3l6.7-6.6c0.2-0.2 0.3-0.5 0.3-0.7v-9c0-0.9-1.1-1.3-1.7-0.7l-6.3 6.2L9.7 0.3C9.1-0.3 8 0.1 8 1.1v8.8c0 0.3 0.1 0.6 0.3 0.8l6.7 6.6v11.3l-5.3-5.2c-0.4-0.4-1-0.4-1.4 0 -0.4 0.4-0.4 1 0 1.4l7 6.9c0.2 0.2 0.5 0.3 0.7 0.3C16.2 32 16.5 31.9 16.7 31.7zM10 9.6V3.4l5 4.9v6.2L10 9.6zM17 8.3l5-4.9v6.2l-5 4.9V8.3z" fill="'+data.iconColor+'"/></svg>';
var svgwind = "data:image/svg+xml;base64," + btoa(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({ myMarker = L.divIcon({
className:"windicon", className:"windicon",
iconAnchor: [16, 16], 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.hdg != null) && (data.bearing == null)) { data.bearing = data.hdg; delete data.hdg; }
if (data.bearing != null) { // if there is a heading 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 (data.length != null) {
if (polygons[data.name] != null) { map.removeLayer(polygons[data.name]); } if (polygons[data.name] != null) { map.removeLayer(polygons[data.name]); }
var x = ll.lng; // X coordinate var x = ll.lng; // X coordinate
var y = ll.lat * 1; // Y coordinate var y = ll.lat * 1; // Y coordinate
var ll1 = ll; var ll1 = ll;
var angle = data.bearing * 1; var angle = parseFloat(data.bearing);
var lengthAsDegrees = data.length / 110540; // metres in a degree..ish var lengthAsDegrees = parseFloat(data.length || "0") / 110540; // metres in a degree..ish
var polygon = null; var polygon = null;
if (data.accuracy != null) { if (data.accuracy != null) {
data.accuracy = Number(data.accuracy); data.accuracy = Number(data.accuracy);

View File

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# date: June 30th 2018 - v1.3.4 # date: July 17th 2018 - v1.3.5
CACHE: CACHE:
index.html index.html