node-red-contrib-web-worldmap 4.8.0 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,8 @@
1
1
  ### Change Log for Node-RED Worldmap
2
2
 
3
- - v4.8.0 - Merged PR for feedback functioanlity cleanup and example. PR #271 and #272
3
+ - v4.9.0 - If payload.flag is two char ISO code replace it with flag emoji. Revert part of PR #271
4
+ - v4.8.1 - Slight tidy of some of the geojson handling
5
+ - v4.8.0 - Merged PR for feedback functionality cleanup and example. PR #271 and #272
4
6
  - v4.7.0 - Update pmtiles library, fix feedback function inconsistency. Issue #270
5
7
  - v4.6.5 - Let geojson allow for generic overrides with .icon and .layer.
6
8
  - v4.6.4 - Fix deletion of layers logic to actually fully remove points.
package/README.md CHANGED
@@ -13,7 +13,9 @@ Feel free to [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%
13
13
 
14
14
  ### Updates
15
15
 
16
- - v4.8.0 - Merged PR for feedback functioanlity cleanup and example. PR #271 and #272
16
+ - v4.9.0 - If payload.flag is two char ISO code replace it with flag emoji. Revert part of PR #271
17
+ - v4.8.1 - Slight tidy of some of the geojson handling
18
+ - v4.8.0 - Merged PR for feedback functionality cleanup and example. PR #271 and #272
17
19
  - v4.7.0 - Update pmtiles library, fix feedback function inconsistency. Issue #270
18
20
  - v4.6.5 - Let geojson allow for generic overrides with .icon and .layer.
19
21
  - v4.6.4 - Fix deletion of layers logic to actually fully remove points.
@@ -397,7 +399,7 @@ Optional properties for **msg.payload.command** include
397
399
  - **panit** - auto pan to the latest marker updated. - `{"command":{"panit":true}}`
398
400
  - **zoomlock** - locks the zoom control to the current value and removes zoom control - `{"command":{"zoomlock":true}}`
399
401
  - **hiderightclick** - disables the right click that allows adding or deleting points on the map - `{"command":{"hiderightclick":true}}`
400
- - **coords** - turns on and off a display of the current mouse co-ordinates. Values can be "deg", "dms", or "none" (default). - `{"command":{"coords":"deg"}}`
402
+ - **coords** - turns on and off a display of the current mouse co-ordinates. Values can be "deg", "dms", "utm", "mgrs", "qth" or "none" (default). - `{"command":{"coords":"deg"}}` , `{"command":{"coords":"deg,dms,utm"}}`
401
403
  - **showruler** - turns on and off a display of the ruler control. Values can be "true" or "false". - `{"command": {"ruler": {"showruler": true}}}`
402
404
  - **button** - if supplied with a `name` and `icon` property - adds a button to provide user input - sends
403
405
  a msg `{"action":"button", "name":"the_button_name"}` to the worldmap in node. If supplied with a `name` property only, it will remove the button. Optional `position` property can be 'bottomright', 'bottomleft', 'topleft' or 'topright' (default). button can also be an array of button objects.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-web-worldmap",
3
- "version": "4.8.0",
3
+ "version": "4.9.0",
4
4
  "description": "A Node-RED node to provide a web page of a world map for plotting things on.",
5
5
  "dependencies": {
6
6
  "@turf/bezier-spline": "~6.5.0",
@@ -865,13 +865,9 @@ var addThing = function() {
865
865
  var form = {};
866
866
  var addToForm = function(n,v) { form[n] = v; }
867
867
  var feedback = function(n,v,a,c) {
868
- /*
869
- // suggest to reove all the special handling for simplification, no reason to send information
870
- // about entities that the backend generaed, the need is only to get recognizable actions from the frontend
871
- //
872
868
  if (v === "_form") { v = form; }
873
869
  if (markers[n]) {
874
- console.log("FB1",n,v,a,c)
870
+ // console.log("FB1",n,v,a,c)
875
871
  allData[n].action = a || "feedback";
876
872
  //if (v !== undefined) { allData[n][a||"value"] = v; }
877
873
  if (v !== undefined) { allData[n]["value"] = v; }
@@ -879,19 +875,17 @@ var feedback = function(n,v,a,c) {
879
875
  setMarker(allData[n]);
880
876
  }
881
877
  else if (polygons[n]) {
882
- console.log("FB2", n, v, a);
878
+ // console.log("FB2", n, v, a);
883
879
  const polyData = { "name": n, "action": a || "feedback", "value": v || null };
884
880
  //sendDrawing(n,v,a)
885
881
  ws.send(JSON.stringify(polyData));
886
882
  }
887
883
  else {
888
884
  if (n === undefined) { n = "map"; }
889
- console.log("FB3",n,v,a,c)
885
+ // console.log("FB3",n,v,a,c)
890
886
  rmenudata = v;
891
887
  ws.send(JSON.stringify({action:a||"feedback", name:n, value:v, lat:rclk.lat, lon:rclk.lng}));
892
888
  }
893
- */
894
-
895
889
  const dataToSend = { "name": n, "action": a || "feedback", "value": v || null };
896
890
  ws.send(JSON.stringify(dataToSend));
897
891
  if (c === true) { map.closePopup(); }
@@ -1514,6 +1508,15 @@ var rangerings = function(latlng, options) {
1514
1508
  return rings;
1515
1509
  }
1516
1510
 
1511
+ // var mmsiList = {"M201":"AL","M202":"AD","M203":"AT","M204":"PT","M205":"BE","M206":"BY","M207":"BG","M208":"VA","M209":"CY","M210":"CY","M211":"DE","M212":"CY","M213":"GE","M214":"MD","M215":"MT","M216":"AM","M218":"DE","M219":"DK","M220":"DK","M224":"ES","M225":"ES","M226":"FR","M227":"FR","M228":"FR","M229":"MT","M230":"FI","M231":"FO","M232":"GB","M233":"GB","M234":"GB","M235":"GB","M236":"GI","M237":"GR","M238":"HR","M239":"GR","M240":"GR","M241":"GR","M242":"MA","M243":"HU","M244":"NL","M245":"NL","M246":"NL","M247":"IT","M248":"MT","M249":"MT","M250":"IE","M251":"IS","M252":"LI","M253":"LU","M254":"MC","M255":"PT","M256":"MT","M257":"NO","M258":"NO","M259":"NO","M261":"PL","M262":"ME","M263":"PT","M264":"RO","M265":"SE","M266":"SE","M267":"SK","M268":"SM","M269":"CH","M270":"CZ","M271":"TR","M272":"UA","M273":"RU","M274":"MK","M275":"LV","M276":"EE","M277":"LT","M278":"SI","M279":"RS","M301":"AI","M303":"US","M304":"AG","M305":"AG","M306":"CW","M307":"AW","M308":"BS","M309":"BS","M310":"BM","M311":"BS","M312":"BZ","M314":"BB","M316":"CA","M319":"KY","M321":"CR","M323":"CU","M325":"DM","M327":"DO","M329":"GP","M330":"GD","M331":"GL","M332":"GT","M334":"HN","M336":"HT","M338":"US","M339":"JM","M341":"KN","M343":"LC","M345":"MX","M347":"MQ","M348":"MS","M350":"NI","M351":"PA","M352":"PA","M353":"PA","M354":"PA","M355":"PA","M356":"PA","M357":"PA","M358":"PR","M359":"SV","M361":"PM","M362":"TT","M364":"TC","M366":"US","M367":"US","M368":"US","M369":"US","M370":"PA","M371":"PA","M372":"PA","M373":"PA","M374":"PA","M375":"VC","M376":"VC","M377":"VC","M378":"VG","M379":"VI","M401":"AF","M403":"SA","M405":"BD","M408":"BH","M410":"BT","M412":"CN","M413":"CN","M414":"CN","M416":"TW","M417":"LK","M419":"IN","M422":"IR","M423":"AZ","M425":"IQ","M428":"IL","M431":"JP","M432":"JP","M434":"TM","M436":"KZ","M437":"UZ","M438":"JO","M440":"KR","M441":"KR","M443":"PS","M445":"KP","M447":"KW","M450":"LB","M451":"KG","M453":"MO","M455":"MV","M457":"MN","M459":"NP","M461":"OM","M463":"PK","M466":"QA","M468":"SY","M470":"AE","M471":"AE","M472":"TJ","M473":"YE","M475":"YE","M477":"HK","M478":"BA","M501":"AQ","M503":"AU","M506":"MM","M508":"BN","M510":"FM","M511":"PW","M512":"NZ","M514":"KH","M515":"KH","M516":"CX","M518":"CK","M520":"FJ","M523":"CC","M525":"ID","M529":"KI","M531":"LA","M533":"MY","M536":"MP","M538":"MH","M540":"NC","M542":"NU","M544":"NR","M546":"PF","M548":"PH","M553":"PG","M555":"PN","M557":"SB","M559":"AS","M561":"WS","M563":"SG","M564":"SG","M565":"SG","M566":"SG","M567":"TH","M570":"TO","M572":"TV","M574":"VN","M576":"VU","M577":"VU","M578":"WF","M601":"ZA","M603":"AO","M605":"DZ","M607":"TF","M608":"IO","M609":"BI","M610":"BJ","M611":"BW","M612":"CF","M613":"CM","M615":"CG","M616":"KM","M617":"CV","M618":"AQ","M619":"CI","M620":"KM","M621":"DJ","M622":"EG","M624":"ET","M625":"ER","M626":"GA","M627":"GH","M629":"GM","M630":"GW","M631":"GQ","M632":"GN","M633":"BF","M634":"KE","M635":"AQ","M636":"LR","M637":"LR","M642":"LY","M644":"LS","M645":"MU","M647":"MG","M649":"ML","M650":"MZ","M654":"MR","M655":"MW","M656":"NE","M657":"NG","M659":"NA","M660":"RE","M661":"RW","M662":"SD","M663":"SN","M664":"SC","M665":"SH","M666":"SO","M667":"SL","M668":"ST","M669":"SZ","M670":"TD","M671":"TG","M672":"TN","M674":"TZ","M675":"UG","M676":"CD","M677":"TZ","M678":"ZM","M679":"ZW","M701":"AR","M710":"BR","M720":"BO","M725":"CL","M730":"CO","M735":"EC","M740":"UK","M745":"GF","M750":"GY","M755":"PY","M760":"PE","M765":"SR","M770":"UY","M775":"VE"}
1512
+
1513
+ // var mmsiToCountry = function(str) {
1514
+ // if (!str) { return ''; }
1515
+ // var co = mmsiList[("M"+str).substr(0,4)];
1516
+ // if (co.length === 2) { return co; }
1517
+ // else { return str; }
1518
+ // };
1519
+
1517
1520
  // the MAIN add marker or shape to map function
1518
1521
  function setMarker(data) {
1519
1522
  var rightmenu = function(m) {
@@ -2075,6 +2078,12 @@ function setMarker(data) {
2075
2078
  }
2076
2079
  opts.size = opts.size || sz;
2077
2080
  opts.size = opts.size * (opts.scale || 1);
2081
+ if (data.SIDC.length > 12) {
2082
+ var cc = data.SIDC.substr(12,2).toLowerCase();
2083
+ opts.country = cc.toUpperCase();
2084
+ opts.staffComments = emojify(":flag-"+cc+":") + " " + (opts?.staffComments || "");
2085
+ data.flag = emojify(":flag-"+cc+":");
2086
+ }
2078
2087
  // escape out any isocodes eg flag symbols
2079
2088
  var optfields = ["additionalInformation","higherFormation","specialHeadquarters","staffComments","type","uniqueDesignation","speed","country"];
2080
2089
  //const regex = /\p{Extended_Pictographic}/ug;
@@ -2169,6 +2178,14 @@ function setMarker(data) {
2169
2178
  if (data.hasOwnProperty("icon")) { delete data.icon; }
2170
2179
  if (data.hasOwnProperty("iconSize")) { delete data.iconSize; }
2171
2180
  if (data.hasOwnProperty("iconColor")) { delete data.iconColor; }
2181
+
2182
+ // if (data?.MMSI && !data?.flag) {
2183
+ // data.flag = mmsiToCountry(data.MMSI)
2184
+ // }
2185
+ if (data?.flag && data.flag.length == 2) {
2186
+ const tflg = emojify(":flag-"+data.flag.toLowerCase()+":");
2187
+ if (!tflg.includes("flag-")) { data.flag = tflg; }
2188
+ }
2172
2189
  if (data.hasOwnProperty("photourl")) {
2173
2190
  words += "<img src=\"" + data.photourl + "\" style=\"max-width:100%; max-height:250px; margin-top:10px;\"><br/>";
2174
2191
  delete data.photourl;
@@ -2558,11 +2575,11 @@ function doCommand(cmd) {
2558
2575
  try { coords.removeFrom(map); }
2559
2576
  catch(e) {}
2560
2577
  var opts = {gps:false, gpsLong:false, utm:false, utmref:false, position:"bottomleft"}
2561
- if (cmd.coords == "deg") { opts.gps = true; }
2562
- if (cmd.coords == "dms") { opts.gpsLong = true; }
2563
- if (cmd.coords == "utm") { opts.utm = true; }
2564
- if (cmd.coords == "mgrs") { opts.utmref = true; }
2565
- if (cmd.coords == "qth") { opts.qth = true; }
2578
+ if (cmd.coords.includes("deg")) { opts.gps = true; }
2579
+ if (cmd.coords.includes("dms")) { opts.gpsLong = true; }
2580
+ if (cmd.coords.includes("utm")) { opts.utm = true; }
2581
+ if (cmd.coords.includes("mgrs")) { opts.utmref = true; }
2582
+ if (cmd.coords.includes("qth")) { opts.qth = true; }
2566
2583
  coords.options = opts;
2567
2584
  coords.addTo(map);
2568
2585
  }
@@ -3111,12 +3128,16 @@ function doGeojson(n,g,l,o,i) { // name, geojson, layer, options, icon
3111
3128
  st.weight = feature.properties["stroke-width"] ?? st.weight;
3112
3129
  st.fillColor = feature.properties["fill-color"] ?? feature.properties["fill"] ?? st.fillColor;
3113
3130
  st.fillOpacity = feature.properties["fill-opacity"] ?? st.fillOpacity;
3131
+ st.fontColor = feature.properties["font-color"] ?? st.fontColor ?? "#000000";
3132
+ st.fontOpacity = feature.properties["font-opacity"] ?? st.fontOpacity;
3114
3133
  delete feature.properties["stroke"];
3115
3134
  delete feature.properties["stroke-width"];
3116
- delete feature.properties["fill-color"];
3135
+ delete feature.properties["stroke-opacity"];
3117
3136
  delete feature.properties["fill"];
3137
+ delete feature.properties["fill-color"];
3118
3138
  delete feature.properties["fill-opacity"];
3119
- delete feature.properties["stroke-opacity"];
3139
+ delete feature.properties["font-color"];
3140
+ delete feature.properties["font-opacity"];
3120
3141
  }
3121
3142
  if (feature.hasOwnProperty("style")) {
3122
3143
  //console.log("GSTYLE", feature.style)
@@ -3141,17 +3162,17 @@ function doGeojson(n,g,l,o,i) { // name, geojson, layer, options, icon
3141
3162
  }
3142
3163
  if (feature.properties.hasOwnProperty("SIDC")) {
3143
3164
  myMarker = new ms.Symbol( feature.properties.SIDC.toUpperCase(), {
3144
- uniqueDesignation:unescape(encodeURIComponent(feature.properties.title||feature.properties.unit)),
3165
+ uniqueDesignation:unescape(encodeURIComponent(feature.properties.title||feature.properties.unit||'')),
3145
3166
  country:feature.properties.country,
3146
3167
  direction:feature.properties.bearing,
3147
3168
  additionalInformation:feature.properties.modifier,
3148
- size:25
3169
+ size:20
3149
3170
  });
3150
3171
  var anc = myMarker.getAnchor();
3151
- if (myMarker.hasOwnProperty("metadata") && myMarker.metadata.hasOwnProperty("echelon")) {
3152
- var sz = iconSz[myMarker.metadata.echelon];
3153
- myMarker.setOptions({size:sz});
3154
- }
3172
+ // if (myMarker.hasOwnProperty("metadata") && myMarker.metadata.hasOwnProperty("echelon")) {
3173
+ // var sz = iconSz[myMarker.metadata.echelon];
3174
+ // myMarker.setOptions({size:sz});
3175
+ // }
3155
3176
  myMarker = L.icon({
3156
3177
  iconUrl: myMarker.toDataURL(),
3157
3178
  iconAnchor: [anc.x, anc.y],
@@ -3178,8 +3199,10 @@ function doGeojson(n,g,l,o,i) { // name, geojson, layer, options, icon
3178
3199
  iconColor: 'white'
3179
3200
  });
3180
3201
  }
3181
- if (!feature.properties.hasOwnProperty("title")) {
3182
- feature.properties.title = feature.properties["marker-symbol"];
3202
+ if (!feature.properties.hasOwnProperty("title") && feature.properties.hasOwnProperty("marker-symbol")) {
3203
+ if (!feature.properties["marker-symbol"].indexOf('fa-') === 0) {
3204
+ feature.properties.title = feature.properties["marker-symbol"];
3205
+ }
3183
3206
  }
3184
3207
  if (feature.properties.hasOwnProperty("url")) {
3185
3208
  feature.properties.url = "<a target='_new' href='"+feature.properties.url+"'>"+feature.properties.url+"</a>";