let speed have units

pull/174/head
Dave Conway-Jones 3 years ago
parent 3a5022e360
commit ae359e37d0
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF

@ -1,6 +1,7 @@
### Change Log for Node-RED Worldmap
- v2.14.0 - Let geojson features be clickable if added as overlay
- v2.15.0 - let speed be text and specify units if required (kt,kn,knots,mph,kmh,kph) default m/s.
- v2.14.0 - Let geojson features be clickable if added as overlay.
- v2.13.4 - Fix list of map choices to be in sync. Fix popup auto sizing.
- v2.13.3 - Fix unchanged layer propagation.
- v2.13.2 - Add mayflower icon.

@ -11,14 +11,15 @@ map web page for plotting "things" on.
### Updates
- v2.14.0 - Let geojson features be clickable if added as overlay
- v2.15.0 - let speed be text and specify units if required (kt,kn,knots,mph,kmh,kph) default m/s.
- v2.14.0 - Let geojson features be clickable if added as overlay.
- v2.13.4 - Fix list of map choices to be in sync. Fix popup auto sizing.
- v2.13.3 - Fix unchanged layer propagation.
- v2.13.2 - Add mayflower icon.
- v2.13.0 - Tidy velocity layer. Feedback any url parameters.
- v2.12.1 - Only show online layer options if we are online.
- v2.12.0 - Add live rainfall radar data layer. Remove some non-loading overlays.
- v2.11.2 - Allow thicknesss of arc to be specified by weight
- v2.11.2 - Allow thicknesss of arc to be specified by weight.
- v2.11.1 - Better handle KML point info - add popup.
- v2.11.0 - Add option to smooth tracks using bezier curves.
- v2.10.0 - Save latest position to browser for refresh if in iframe/dashboard. Allow fractional Zoom levels.

@ -1,6 +1,6 @@
{
"name": "node-red-contrib-web-worldmap",
"version": "2.14.0",
"version": "2.15.0",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": {
"cgi": "0.3.1",

@ -94,7 +94,7 @@ var connect = function() {
};
ws.onmessage = function(e) {
try { var data = JSON.parse(e.data); handleData(data); }
catch (e) { console.log("BAD DATA"); return; }
catch (e) { if (data) { console.log("BAD DATA",data); } }
// console.log("DATA",typeof data,data);
};
}
@ -1750,7 +1750,7 @@ function setMarker(data) {
// remove icon from list of properties, then add all others to popup
if (data.hasOwnProperty("alt")) { data.alt = (1*data.alt).toFixed(2); }
if (data.hasOwnProperty("speed")) { data.speed = (1*data.speed).toFixed(2); }
//if (data.hasOwnProperty("speed")) { data.speed = parseFloat(data.speed).toFixed(2); }
if (data.hasOwnProperty("SIDC") && data.hasOwnProperty("options")) { delete data.options; }
if (data.hasOwnProperty("icon")) { delete data.icon; }
if (data.hasOwnProperty("iconColor")) { delete data.iconColor; }
@ -1856,7 +1856,7 @@ function setMarker(data) {
else { words = words + marker.getLatLng().toString().replace('LatLng(','lat, lon : ').replace(')',''); }
words = "<b>"+data.name+"</b><br/>" + words; //"<button style=\"border-radius:4px; float:right; background-color:lightgrey;\" onclick='popped=false;popmark.closePopup();'>X</button><br/>" + words;
var wopt = {autoClose:false, closeButton:true, closeOnClick:false, minWidth:200};
if (words.indexOf('<video ') >=0 || words.indexOf('<img ') >=0 ) { wopt.maxWidth="auto"; }
if (words.indexOf('<video ') >=0 || words.indexOf('<img ') >=0 ) { wopt.maxWidth="640"; }
marker.bindPopup(words, wopt);
marker._popup.dname = data.name;
marker.lay = lay; // and the layer it is on
@ -1875,7 +1875,15 @@ function setMarker(data) {
else if (data.heading !== undefined) { track = data.heading; }
else if (data.bearing !== undefined) { track = data.bearing; }
if (track != undefined) { // if there is a heading
if (data.speed != null) { data.length = parseFloat(data.speed || "0") * 60; } // and a speed
if (data.speed != null && !data.length) { // and a speed - lets convert to a leader length
data.length = parseFloat(data.speed || "0") * 60;
var re1 = new RegExp('kn|knot|kt','i');
var re2 = new RegExp('kph|kmh','i');
var re3 = new RegExp('mph','i');
if ( re1.test(""+data.speed) ) { data.length = data.length * 0.514444; }
else if ( re2.test(""+data.speed) ) { data.length = data.length * 0.44704; }
else if ( re3.test(""+data.speed) ) { data.length = data.length * 0.277778; }
}
if (data.length != null) {
if (polygons[data.name] != null && !polygons[data.name].hasOwnProperty("_layers")) {
map.removeLayer(polygons[data.name]);

Loading…
Cancel
Save