node-red-contrib-web-worldmap 4.8.1 → 5.0.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.
Files changed (124) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +6 -2
  3. package/examples/{feedback.json → Feedback.json} +1 -9
  4. package/examples/MouseCoordinates.json +159 -0
  5. package/examples/sidcEdgeIcon.json +158 -0
  6. package/node_modules/@turf/bezier-spline/README.md +15 -21
  7. package/node_modules/@turf/bezier-spline/dist/cjs/index.cjs +165 -0
  8. package/node_modules/@turf/bezier-spline/dist/cjs/index.cjs.map +1 -0
  9. package/node_modules/@turf/bezier-spline/dist/{es/index.js → cjs/index.d.cts} +9 -30
  10. package/node_modules/@turf/bezier-spline/dist/{js → esm}/index.d.ts +5 -3
  11. package/node_modules/@turf/bezier-spline/dist/esm/index.js +165 -0
  12. package/node_modules/@turf/bezier-spline/dist/esm/index.js.map +1 -0
  13. package/node_modules/@turf/bezier-spline/package.json +33 -25
  14. package/node_modules/@turf/helpers/README.md +231 -219
  15. package/node_modules/@turf/helpers/dist/cjs/index.cjs +308 -0
  16. package/node_modules/@turf/helpers/dist/cjs/index.cjs.map +1 -0
  17. package/node_modules/@turf/helpers/dist/{es/index.js → cjs/index.d.cts} +103 -303
  18. package/node_modules/@turf/helpers/dist/{js → esm}/index.d.ts +67 -53
  19. package/node_modules/@turf/helpers/dist/esm/index.js +308 -0
  20. package/node_modules/@turf/helpers/dist/esm/index.js.map +1 -0
  21. package/node_modules/@turf/helpers/package.json +32 -22
  22. package/node_modules/@turf/invariant/README.md +47 -58
  23. package/node_modules/@turf/invariant/dist/cjs/index.cjs +127 -0
  24. package/node_modules/@turf/invariant/dist/cjs/index.cjs.map +1 -0
  25. package/node_modules/@turf/invariant/dist/cjs/index.d.cts +108 -0
  26. package/node_modules/@turf/invariant/dist/{js → esm}/index.d.ts +12 -9
  27. package/node_modules/@turf/invariant/dist/esm/index.js +127 -0
  28. package/node_modules/@turf/invariant/dist/esm/index.js.map +1 -0
  29. package/node_modules/@turf/invariant/package.json +31 -22
  30. package/node_modules/@types/geojson/LICENSE +21 -0
  31. package/node_modules/@types/geojson/README.md +15 -0
  32. package/node_modules/@types/geojson/index.d.ts +165 -0
  33. package/node_modules/@types/geojson/package.json +45 -0
  34. package/node_modules/body-parser/HISTORY.md +7 -0
  35. package/node_modules/body-parser/README.md +11 -0
  36. package/node_modules/body-parser/lib/types/urlencoded.js +30 -7
  37. package/node_modules/body-parser/package.json +2 -2
  38. package/node_modules/encodeurl/README.md +19 -38
  39. package/node_modules/encodeurl/index.js +1 -1
  40. package/node_modules/encodeurl/package.json +7 -7
  41. package/node_modules/express/History.md +27 -0
  42. package/node_modules/express/Readme.md +100 -6
  43. package/node_modules/express/lib/response.js +11 -10
  44. package/node_modules/express/package.json +11 -11
  45. package/node_modules/finalhandler/HISTORY.md +15 -0
  46. package/node_modules/finalhandler/README.md +2 -2
  47. package/node_modules/finalhandler/index.js +7 -2
  48. package/node_modules/finalhandler/package.json +8 -7
  49. package/node_modules/merge-descriptors/README.md +4 -3
  50. package/node_modules/merge-descriptors/index.js +3 -3
  51. package/node_modules/merge-descriptors/package.json +14 -7
  52. package/node_modules/mime-db/HISTORY.md +14 -0
  53. package/node_modules/mime-db/README.md +27 -24
  54. package/node_modules/mime-db/db.json +646 -62
  55. package/node_modules/mime-db/package.json +9 -13
  56. package/node_modules/mime-types/node_modules/mime-db/HISTORY.md +507 -0
  57. package/node_modules/mime-types/node_modules/mime-db/LICENSE +23 -0
  58. package/node_modules/mime-types/node_modules/mime-db/README.md +100 -0
  59. package/node_modules/mime-types/node_modules/mime-db/db.json +8519 -0
  60. package/node_modules/mime-types/node_modules/mime-db/index.js +12 -0
  61. package/node_modules/mime-types/node_modules/mime-db/package.json +60 -0
  62. package/node_modules/object-inspect/CHANGELOG.md +15 -0
  63. package/node_modules/object-inspect/index.js +4 -1
  64. package/node_modules/object-inspect/package.json +14 -9
  65. package/node_modules/object-inspect/readme.markdown +9 -11
  66. package/node_modules/path-to-regexp/index.js +57 -40
  67. package/node_modules/path-to-regexp/package.json +2 -2
  68. package/node_modules/qs/.editorconfig +3 -0
  69. package/node_modules/qs/.eslintrc +2 -2
  70. package/node_modules/qs/CHANGELOG.md +59 -5
  71. package/node_modules/qs/README.md +133 -49
  72. package/node_modules/qs/dist/qs.js +56 -2020
  73. package/node_modules/qs/lib/parse.js +46 -13
  74. package/node_modules/qs/lib/stringify.js +53 -28
  75. package/node_modules/qs/lib/utils.js +47 -34
  76. package/node_modules/qs/package.json +26 -12
  77. package/node_modules/qs/test/empty-keys-cases.js +267 -0
  78. package/node_modules/qs/test/parse.js +347 -32
  79. package/node_modules/qs/test/stringify.js +436 -47
  80. package/node_modules/send/HISTORY.md +5 -0
  81. package/node_modules/send/index.js +1 -2
  82. package/node_modules/send/node_modules/encodeurl/LICENSE +22 -0
  83. package/node_modules/send/node_modules/encodeurl/README.md +128 -0
  84. package/node_modules/send/node_modules/encodeurl/index.js +60 -0
  85. package/node_modules/send/node_modules/encodeurl/package.json +40 -0
  86. package/node_modules/send/package.json +1 -1
  87. package/node_modules/serve-static/HISTORY.md +16 -0
  88. package/node_modules/serve-static/index.js +1 -2
  89. package/node_modules/serve-static/package.json +3 -3
  90. package/node_modules/tslib/CopyrightNotice.txt +15 -0
  91. package/node_modules/tslib/LICENSE.txt +12 -0
  92. package/node_modules/tslib/README.md +164 -0
  93. package/node_modules/tslib/SECURITY.md +41 -0
  94. package/node_modules/tslib/modules/index.d.ts +37 -0
  95. package/node_modules/tslib/modules/index.js +68 -0
  96. package/node_modules/tslib/modules/package.json +3 -0
  97. package/node_modules/tslib/package.json +47 -0
  98. package/node_modules/tslib/tslib.d.ts +453 -0
  99. package/node_modules/tslib/tslib.es6.html +1 -0
  100. package/node_modules/tslib/tslib.es6.js +379 -0
  101. package/node_modules/tslib/tslib.es6.mjs +378 -0
  102. package/node_modules/tslib/tslib.html +1 -0
  103. package/node_modules/tslib/tslib.js +429 -0
  104. package/package.json +5 -5
  105. package/worldmap/index.html +1 -1
  106. package/worldmap/leaflet/leaflet.mousecoordinate.js +3 -3
  107. package/worldmap/worldmap.js +148 -44
  108. package/worldmap.html +1 -1
  109. package/worldmap.js +23 -4
  110. package/node_modules/@turf/bezier-spline/dist/es/lib/spline.js +0 -158
  111. package/node_modules/@turf/bezier-spline/dist/es/package.json +0 -1
  112. package/node_modules/@turf/bezier-spline/dist/js/index.js +0 -65
  113. package/node_modules/@turf/bezier-spline/dist/js/lib/spline.d.ts +0 -62
  114. package/node_modules/@turf/bezier-spline/dist/js/lib/spline.js +0 -160
  115. package/node_modules/@turf/helpers/dist/es/lib/geojson.js +0 -7
  116. package/node_modules/@turf/helpers/dist/es/package.json +0 -1
  117. package/node_modules/@turf/helpers/dist/js/index.js +0 -724
  118. package/node_modules/@turf/helpers/dist/js/lib/geojson.d.ts +0 -193
  119. package/node_modules/@turf/helpers/dist/js/lib/geojson.js +0 -9
  120. package/node_modules/@turf/invariant/dist/es/index.js +0 -223
  121. package/node_modules/@turf/invariant/dist/es/package.json +0 -1
  122. package/node_modules/@turf/invariant/dist/js/index.js +0 -233
  123. package/node_modules/path-to-regexp/History.md +0 -36
  124. /package/node_modules/{encodeurl → send/node_modules/encodeurl}/HISTORY.md +0 -0
@@ -438,9 +438,9 @@ var Lgrid = L.latlngGraticule({
438
438
  // Add small sidc icons around edge of map for things just outside of view
439
439
  // This function based heavily on Game Aware code from Måns Beckman
440
440
  // Copyright (c) 2013 Måns Beckman, All rights reserved.
441
- var edgeAware = function() {
441
+ var edgeAware = function () {
442
+ map.removeLayer(edgeLayer);
442
443
  if (!edgeEnabled) { return; }
443
- map.removeLayer(edgeLayer)
444
444
  edgeLayer = new L.layerGroup();
445
445
  var mapBounds = map.getBounds();
446
446
  var mapBoundsCenter = mapBounds.getCenter();
@@ -599,6 +599,30 @@ function setCluster(v) {
599
599
  showMapCurrentZoom();
600
600
  }
601
601
 
602
+ var typingTimer;
603
+ document.getElementById('search').addEventListener('keyup', () => {
604
+ clearTimeout(typingTimer);
605
+ if (document.getElementById('search').value.length >= 4) {
606
+ typingTimer = setTimeout(doneTyping, 700);
607
+ }
608
+ });
609
+
610
+ function doneTyping () { doSearch(); }
611
+
612
+ async function readPhoton(url) {
613
+ const response = await fetch(url);
614
+ const reader = response.body.getReader();
615
+ let v = "";
616
+ while (true) {
617
+ const { done, value } = await reader.read();
618
+ if (done) {
619
+ if (value !== undefined) { v += new TextDecoder().decode(value); }
620
+ return v;
621
+ }
622
+ v += new TextDecoder().decode(value)
623
+ }
624
+ }
625
+
602
626
  // Search for markers with names of ... or icons of ...
603
627
  function doSearch() {
604
628
  var value = document.getElementById('search').value;
@@ -615,17 +639,21 @@ function doSearch() {
615
639
  moveToMarks();
616
640
  if (marks.length === 0) {
617
641
  // If no markers found let's try a geolookup...
642
+
618
643
  var protocol = location.protocol;
619
644
  if (protocol == "file:") { protocol = "https:"; }
620
- var searchUrl = protocol + "//nominatim.openstreetmap.org/search?format=json&limit=1&q=";
645
+ var searchUrl = protocol + "//nominatim.openstreetmap.org/search?format=json&limit=5&q=";
621
646
 
622
647
  fetch(searchUrl + value) // Call the fetch function passing the url of the API as a parameter
623
648
  .then(function(resp) { return resp.json(); })
624
649
  .then(function(data) {
625
650
  if (data.length > 0) {
651
+ // var l = data.map((x) => x.display_name);
652
+ // console.log("LIST",l)
626
653
  var bb = data[0].boundingbox;
627
654
  map.fitBounds([ [bb[0],bb[2]], [bb[1],bb[3]] ]);
628
655
  map.panTo([data[0].lat, data[0].lon]);
656
+ document.getElementById('searchResult').innerHTML = "";
629
657
  }
630
658
  else {
631
659
  document.getElementById('searchResult').innerHTML = "&nbsp;<font color='#ff0'>Not Found</font>";
@@ -636,6 +664,35 @@ function doSearch() {
636
664
  document.getElementById('searchResult').innerHTML = "&nbsp;<font color='#ff0'>Not Found</font>";
637
665
  }
638
666
  });
667
+
668
+ // var searchUrl = 'https://photon.komoot.io/api?limit=5&q=';
669
+ // readPhoton(searchUrl + value).then(
670
+ // function(value) {
671
+ // if (value.length > 0 && typeof value === "string") {
672
+ // var s = JSON.parse(value);
673
+ // if (s?.features) {
674
+ // var l = s.features.map((x) => x.properties.name +', ' + x.properties.countrycode);
675
+ // console.log("LIST",l)
676
+ // if (s.features.length > 0) {
677
+ // if (s.features[0].properties?.extent) {
678
+ // var bb = s.features[0].properties.extent;
679
+ // map.fitBounds([ [bb[3],bb[0]], [bb[1],bb[2]] ]);
680
+ // }
681
+ // else {
682
+ // map.panTo([s.features[0].geometry.coordinates[1], s.features[0].geometry.coordinates[0]]);
683
+ // }
684
+ // document.getElementById('searchResult').innerHTML = "";
685
+ // }
686
+ // else {
687
+ // document.getElementById('searchResult').innerHTML = "&nbsp;<font color='#ff0'>Not Found</font>";}
688
+ // }
689
+ // }
690
+ // },
691
+ // function(error) {
692
+ // document.getElementById('searchResult').innerHTML = "&nbsp;<font color='#ff0'>Search Error</font>";
693
+ // }
694
+ // );
695
+
639
696
  }
640
697
  else {
641
698
  if (lockit) {
@@ -864,36 +921,51 @@ var addThing = function() {
864
921
 
865
922
  var form = {};
866
923
  var addToForm = function(n,v) { form[n] = v; }
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
- //
924
+ var feedback = function(n = "map",v,a = "feedback",c) {
872
925
  if (v === "_form") { v = form; }
873
- if (markers[n]) {
874
- console.log("FB1",n,v,a,c)
875
- allData[n].action = a || "feedback";
926
+ // undefined is handled directly in the function declaration, but null/"" also requires explicit handling within the function.
927
+ n = (n === null || n === "") ? "map" : n;
928
+ var dataToSend = { "name": n, "action": a, "value": v };
929
+ //Kept only for backward compatibility, as the context menu should handle the click position values internally.
930
+ if (n == "map") {
931
+ dataToSend.lat = rclk.lat;
932
+ dataToSend.lon = rclk.lng;
933
+ }
934
+ ws.send(JSON.stringify(dataToSend));
935
+
936
+ //** The following lines left just to verify reasoning and clarifying why it was removed
937
+
938
+ //** the reasong to seperate entities uncleare
939
+ //if (markers[n]) {
940
+ // console.log("FB1",n,v,a,c)
941
+ //** Why are we even modifying `allData`?
942
+ // allData[n].action = a || "feedback";
876
943
  //if (v !== undefined) { allData[n][a||"value"] = v; }
877
- if (v !== undefined) { allData[n]["value"] = v; }
878
- ws.send(JSON.stringify(allData[n]));
879
- setMarker(allData[n]);
880
- }
881
- else if (polygons[n]) {
882
- console.log("FB2", n, v, a);
883
- const polyData = { "name": n, "action": a || "feedback", "value": v || null };
944
+ // if (v !== undefined) { allData[n]["value"] = v; }
945
+ //** Why are we sending back the `allData` object at all?
946
+ // ws.send(JSON.stringify(allData[n]));
947
+ ///** Why are we updating the markers array from a feedback function?
948
+ // setMarker(allData[n]);
949
+ //}
950
+
951
+ //** what is so sppecial about feedback fomr polygons?
952
+ //else if (polygons[n]) {
953
+ // console.log("FB2", n, v, a);
954
+ // const polyData = { "name": n, "action": a || "feedback", "value": v || null };
884
955
  //sendDrawing(n,v,a)
885
- ws.send(JSON.stringify(polyData));
886
- }
887
- else {
888
- if (n === undefined) { n = "map"; }
889
- console.log("FB3",n,v,a,c)
890
- rmenudata = v;
891
- ws.send(JSON.stringify({action:a||"feedback", name:n, value:v, lat:rclk.lat, lon:rclk.lng}));
892
- }
893
- */
894
-
895
- const dataToSend = { "name": n, "action": a || "feedback", "value": v || null };
896
- ws.send(JSON.stringify(dataToSend));
956
+ // ws.send(JSON.stringify(polyData));
957
+ //}
958
+ //** If neither a polygon nor a marker is found, assume it's a map and send the same data?
959
+ //else {
960
+ // if (n === undefined) { n = "map"; }
961
+ // console.log("FB3",n,v,a,c)
962
+ //** Modifying menu content inside feedback function is a bug!
963
+ // rmenudata = v;
964
+ // ws.send(JSON.stringify({action:a||"feedback", name:n, value:v, lat:rclk.lat, lon:rclk.lng}));
965
+ //}
966
+ //** Sending the same data again is redundant, as it could result in feedback being sent twice (except for the markers where we sent unnecessary data).
967
+ //const dataToSend = { "name": n, "action": a || "feedback", "value": v || null };
968
+ //ws.send(JSON.stringify(dataToSend));
897
969
  if (c === true) { map.closePopup(); }
898
970
  }
899
971
 
@@ -1353,18 +1425,18 @@ var addOverlays = function(overlist) {
1353
1425
  }
1354
1426
 
1355
1427
  // Add Air Corridors
1356
- if (overlist.indexOf("AC")!==-1) {
1357
- overlays["air corridors"] = L.tileLayer('https://{s}.tile.maps.openaip.net/geowebcache/service/tms/1.0.0/openaip_basemap@EPSG%3A900913@png/{z}/{x}/{y}.{ext}', {
1358
- attribution: '<a href="https://www.openaip.net/">openAIP Data</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-NC-SA</a>)',
1359
- ext: 'png',
1360
- minZoom: 4,
1361
- maxZoom: 15,
1362
- maxNativeZoom: 14,
1363
- tms: true,
1364
- detectRetina: true,
1365
- subdomains: '12'
1366
- });
1367
- }
1428
+ // if (overlist.indexOf("AC")!==-1) {
1429
+ // overlays["air corridors"] = L.tileLayer('https://api.tiles.openaip.net/api/data/openaip/{z}/{x}/{y}.png', {
1430
+ // attribution: '<a href="https://www.openaip.net/">openAIP Data</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-NC-SA</a>)',
1431
+ // ext: 'png',
1432
+ // minZoom: 4,
1433
+ // maxZoom: 15,
1434
+ // maxNativeZoom: 14,
1435
+ // tms: true,
1436
+ // detectRetina: true,
1437
+ // subdomains: '12'
1438
+ // });
1439
+ // }
1368
1440
 
1369
1441
  // Add the OpenSea markers layer
1370
1442
  if (overlist.indexOf("SN")!==-1) {
@@ -1514,6 +1586,15 @@ var rangerings = function(latlng, options) {
1514
1586
  return rings;
1515
1587
  }
1516
1588
 
1589
+ // 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"}
1590
+
1591
+ // var mmsiToCountry = function(str) {
1592
+ // if (!str) { return ''; }
1593
+ // var co = mmsiList[("M"+str).substr(0,4)];
1594
+ // if (co.length === 2) { return co; }
1595
+ // else { return str; }
1596
+ // };
1597
+
1517
1598
  // the MAIN add marker or shape to map function
1518
1599
  function setMarker(data) {
1519
1600
  var rightmenu = function(m) {
@@ -2075,6 +2156,12 @@ function setMarker(data) {
2075
2156
  }
2076
2157
  opts.size = opts.size || sz;
2077
2158
  opts.size = opts.size * (opts.scale || 1);
2159
+ if (data.SIDC.length > 12) {
2160
+ var cc = data.SIDC.substr(12,2).toLowerCase();
2161
+ opts.country = cc.toUpperCase();
2162
+ opts.staffComments = emojify(":flag-"+cc+":") + " " + (opts?.staffComments || "");
2163
+ data.flag = emojify(":flag-"+cc+":");
2164
+ }
2078
2165
  // escape out any isocodes eg flag symbols
2079
2166
  var optfields = ["additionalInformation","higherFormation","specialHeadquarters","staffComments","type","uniqueDesignation","speed","country"];
2080
2167
  //const regex = /\p{Extended_Pictographic}/ug;
@@ -2169,6 +2256,14 @@ function setMarker(data) {
2169
2256
  if (data.hasOwnProperty("icon")) { delete data.icon; }
2170
2257
  if (data.hasOwnProperty("iconSize")) { delete data.iconSize; }
2171
2258
  if (data.hasOwnProperty("iconColor")) { delete data.iconColor; }
2259
+
2260
+ // if (data?.MMSI && !data?.flag) {
2261
+ // data.flag = mmsiToCountry(data.MMSI)
2262
+ // }
2263
+ if (data?.flag && data.flag.length == 2) {
2264
+ const tflg = emojify(":flag-"+data.flag.toLowerCase()+":");
2265
+ if (!tflg.includes("flag-")) { data.flag = tflg; }
2266
+ }
2172
2267
  if (data.hasOwnProperty("photourl")) {
2173
2268
  words += "<img src=\"" + data.photourl + "\" style=\"max-width:100%; max-height:250px; margin-top:10px;\"><br/>";
2174
2269
  delete data.photourl;
@@ -2435,8 +2530,10 @@ function doCommand(cmd) {
2435
2530
  document.getElementById("toplink").setAttribute("style", "pointer-events:none");
2436
2531
  }
2437
2532
  }
2438
- if (cmd.hasOwnProperty("clear")) {
2439
- doTidyUp(cmd.clear);
2533
+ if (cmd.hasOwnProperty("clearlayer") || cmd.hasOwnProperty("clear")) {
2534
+ var clr = cmd.clearlayer || cmd.clear;
2535
+ if (!isArray(clr)) { clr = [ clr ]; }
2536
+ clr.forEach((el) => doTidyUp(el));
2440
2537
  }
2441
2538
  if (cmd.hasOwnProperty("panit")) {
2442
2539
  if (cmd.panit == true || cmd.panit === "true") { panit = true; }
@@ -3049,6 +3146,13 @@ function doCommand(cmd) {
3049
3146
  document.getElementById("maxage").value = cmd.maxage;
3050
3147
  setMaxAge();
3051
3148
  }
3149
+ if (cmd.hasOwnProperty("sidcEdgeIcon")) {
3150
+ if (typeof cmd.sidcEdgeIcon === 'boolean') {
3151
+ edgeEnabled = cmd.sidcEdgeIcon;
3152
+ } else {
3153
+ console.log("ERR - invalid sidcEdgeIcon command: ", cmd.sidcEdgeIcon);
3154
+ }
3155
+ }
3052
3156
  // Replace heatmap layer with new array (and optionally options)
3053
3157
  if (cmd.hasOwnProperty("heatmap") && heat) {
3054
3158
  if (cmd.hasOwnProperty("options")) { heat.setOptions(cmd.options); }
package/worldmap.html CHANGED
@@ -345,7 +345,7 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
345
345
  { value: "BU", label: "Buildings" },
346
346
  { value: "RW", label: "Railways" },
347
347
  { value: "SN", label: "Ship Navigation" },
348
- { value: "AC", label: "Air Corridors" },
348
+ // { value: "AC", label: "Air Corridors" },
349
349
  { value: "TL", label: "Place Labels" },
350
350
  { value: "HM", label: "Heatmap" }
351
351
  ]
package/worldmap.js CHANGED
@@ -493,13 +493,32 @@ module.exports = function(RED) {
493
493
  }
494
494
  }
495
495
  if (msg?.payload?.command?.clear) {
496
- for (let p in node.pointsarray) {
497
- if (node.pointsarray.hasOwnProperty(p)) {
498
- if (node.pointsarray[p][0].layer === msg.payload.command.clear) {
499
- delete node.pointsarray[p];
496
+ if (!isArray(msg?.payload?.command?.clear)) {
497
+ msg.payload.command.clear = [ msg.payload.command.clear ]
498
+ }
499
+ msg.payload.command.clear.forEach(function(el) {
500
+ for (let p in node.pointsarray) {
501
+ if (node.pointsarray.hasOwnProperty(p)) {
502
+ if (node.pointsarray[p][0].layer === el) {
503
+ delete node.pointsarray[p];
504
+ }
500
505
  }
501
506
  }
507
+ })
508
+ }
509
+ if (msg?.payload?.command?.clearlayer) {
510
+ if (!isArray(msg?.payload?.command?.clearlayer)) {
511
+ msg.payload.command.clearlayer = [ msg.payload.command.clearlayer ]
502
512
  }
513
+ msg.payload.command.clearlayer.forEach(function(el) {
514
+ for (let p in node.pointsarray) {
515
+ if (node.pointsarray.hasOwnProperty(p)) {
516
+ if (node.pointsarray[p][0].layer === el) {
517
+ delete node.pointsarray[p];
518
+ }
519
+ }
520
+ }
521
+ })
503
522
  }
504
523
  }
505
524
 
@@ -1,158 +0,0 @@
1
- /**
2
- * BezierSpline
3
- * https://github.com/leszekr/bezier-spline-js
4
- *
5
- * @private
6
- * @copyright
7
- * Copyright (c) 2013 Leszek Rybicki
8
- *
9
- * Permission is hereby granted, free of charge, to any person obtaining a copy
10
- * of this software and associated documentation files (the "Software"), to deal
11
- * in the Software without restriction, including without limitation the rights
12
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
- * copies of the Software, and to permit persons to whom the Software is
14
- * furnished to do so, subject to the following conditions:
15
- *
16
- * The above copyright notice and this permission notice shall be included in all
17
- * copies or substantial portions of the Software.
18
- *
19
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
- * SOFTWARE.
26
- */
27
- var Spline = /** @class */ (function () {
28
- function Spline(options) {
29
- this.points = options.points || [];
30
- this.duration = options.duration || 10000;
31
- this.sharpness = options.sharpness || 0.85;
32
- this.centers = [];
33
- this.controls = [];
34
- this.stepLength = options.stepLength || 60;
35
- this.length = this.points.length;
36
- this.delay = 0;
37
- // this is to ensure compatibility with the 2d version
38
- for (var i = 0; i < this.length; i++) {
39
- this.points[i].z = this.points[i].z || 0;
40
- }
41
- for (var i = 0; i < this.length - 1; i++) {
42
- var p1 = this.points[i];
43
- var p2 = this.points[i + 1];
44
- this.centers.push({
45
- x: (p1.x + p2.x) / 2,
46
- y: (p1.y + p2.y) / 2,
47
- z: (p1.z + p2.z) / 2,
48
- });
49
- }
50
- this.controls.push([this.points[0], this.points[0]]);
51
- for (var i = 0; i < this.centers.length - 1; i++) {
52
- var dx = this.points[i + 1].x - (this.centers[i].x + this.centers[i + 1].x) / 2;
53
- var dy = this.points[i + 1].y - (this.centers[i].y + this.centers[i + 1].y) / 2;
54
- var dz = this.points[i + 1].z - (this.centers[i].y + this.centers[i + 1].z) / 2;
55
- this.controls.push([
56
- {
57
- x: (1.0 - this.sharpness) * this.points[i + 1].x +
58
- this.sharpness * (this.centers[i].x + dx),
59
- y: (1.0 - this.sharpness) * this.points[i + 1].y +
60
- this.sharpness * (this.centers[i].y + dy),
61
- z: (1.0 - this.sharpness) * this.points[i + 1].z +
62
- this.sharpness * (this.centers[i].z + dz),
63
- },
64
- {
65
- x: (1.0 - this.sharpness) * this.points[i + 1].x +
66
- this.sharpness * (this.centers[i + 1].x + dx),
67
- y: (1.0 - this.sharpness) * this.points[i + 1].y +
68
- this.sharpness * (this.centers[i + 1].y + dy),
69
- z: (1.0 - this.sharpness) * this.points[i + 1].z +
70
- this.sharpness * (this.centers[i + 1].z + dz),
71
- },
72
- ]);
73
- }
74
- this.controls.push([
75
- this.points[this.length - 1],
76
- this.points[this.length - 1],
77
- ]);
78
- this.steps = this.cacheSteps(this.stepLength);
79
- return this;
80
- }
81
- /**
82
- * Caches an array of equidistant (more or less) points on the curve.
83
- */
84
- Spline.prototype.cacheSteps = function (mindist) {
85
- var steps = [];
86
- var laststep = this.pos(0);
87
- steps.push(0);
88
- for (var t = 0; t < this.duration; t += 10) {
89
- var step = this.pos(t);
90
- var dist = Math.sqrt((step.x - laststep.x) * (step.x - laststep.x) +
91
- (step.y - laststep.y) * (step.y - laststep.y) +
92
- (step.z - laststep.z) * (step.z - laststep.z));
93
- if (dist > mindist) {
94
- steps.push(t);
95
- laststep = step;
96
- }
97
- }
98
- return steps;
99
- };
100
- /**
101
- * returns angle and speed in the given point in the curve
102
- */
103
- Spline.prototype.vector = function (t) {
104
- var p1 = this.pos(t + 10);
105
- var p2 = this.pos(t - 10);
106
- return {
107
- angle: (180 * Math.atan2(p1.y - p2.y, p1.x - p2.x)) / 3.14,
108
- speed: Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) +
109
- (p2.y - p1.y) * (p2.y - p1.y) +
110
- (p2.z - p1.z) * (p2.z - p1.z)),
111
- };
112
- };
113
- /**
114
- * Gets the position of the point, given time.
115
- *
116
- * WARNING: The speed is not constant. The time it takes between control points is constant.
117
- *
118
- * For constant speed, use Spline.steps[i];
119
- */
120
- Spline.prototype.pos = function (time) {
121
- var t = time - this.delay;
122
- if (t < 0) {
123
- t = 0;
124
- }
125
- if (t > this.duration) {
126
- t = this.duration - 1;
127
- }
128
- // t = t-this.delay;
129
- var t2 = t / this.duration;
130
- if (t2 >= 1) {
131
- return this.points[this.length - 1];
132
- }
133
- var n = Math.floor((this.points.length - 1) * t2);
134
- var t1 = (this.length - 1) * t2 - n;
135
- return bezier(t1, this.points[n], this.controls[n][1], this.controls[n + 1][0], this.points[n + 1]);
136
- };
137
- return Spline;
138
- }());
139
- export default Spline;
140
- function bezier(t, p1, c1, c2, p2) {
141
- var b = B(t);
142
- var pos = {
143
- x: p2.x * b[0] + c2.x * b[1] + c1.x * b[2] + p1.x * b[3],
144
- y: p2.y * b[0] + c2.y * b[1] + c1.y * b[2] + p1.y * b[3],
145
- z: p2.z * b[0] + c2.z * b[1] + c1.z * b[2] + p1.z * b[3],
146
- };
147
- return pos;
148
- }
149
- function B(t) {
150
- var t2 = t * t;
151
- var t3 = t2 * t;
152
- return [
153
- t3,
154
- 3 * t2 * (1 - t),
155
- 3 * t * (1 - t) * (1 - t),
156
- (1 - t) * (1 - t) * (1 - t),
157
- ];
158
- }
@@ -1 +0,0 @@
1
- {"type":"module"}
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var helpers_1 = require("@turf/helpers");
7
- var invariant_1 = require("@turf/invariant");
8
- var spline_1 = __importDefault(require("./lib/spline"));
9
- /**
10
- * Takes a {@link LineString|line} and returns a curved version
11
- * by applying a [Bezier spline](http://en.wikipedia.org/wiki/B%C3%A9zier_spline)
12
- * algorithm.
13
- *
14
- * The bezier spline implementation is by [Leszek Rybicki](http://leszek.rybicki.cc/).
15
- *
16
- * @name bezierSpline
17
- * @param {Feature<LineString>} line input LineString
18
- * @param {Object} [options={}] Optional parameters
19
- * @param {Object} [options.properties={}] Translate properties to output
20
- * @param {number} [options.resolution=10000] time in milliseconds between points
21
- * @param {number} [options.sharpness=0.85] a measure of how curvy the path should be between splines
22
- * @returns {Feature<LineString>} curved line
23
- * @example
24
- * var line = turf.lineString([
25
- * [-76.091308, 18.427501],
26
- * [-76.695556, 18.729501],
27
- * [-76.552734, 19.40443],
28
- * [-74.61914, 19.134789],
29
- * [-73.652343, 20.07657],
30
- * [-73.157958, 20.210656]
31
- * ]);
32
- *
33
- * var curved = turf.bezierSpline(line);
34
- *
35
- * //addToMap
36
- * var addToMap = [line, curved]
37
- * curved.properties = { stroke: '#0F0' };
38
- */
39
- function bezier(line, options) {
40
- if (options === void 0) { options = {}; }
41
- // Optional params
42
- var resolution = options.resolution || 10000;
43
- var sharpness = options.sharpness || 0.85;
44
- var coords = [];
45
- var points = invariant_1.getGeom(line).coordinates.map(function (pt) {
46
- return { x: pt[0], y: pt[1] };
47
- });
48
- var spline = new spline_1.default({
49
- duration: resolution,
50
- points: points,
51
- sharpness: sharpness,
52
- });
53
- var pushCoord = function (time) {
54
- var pos = spline.pos(time);
55
- if (Math.floor(time / 100) % 2 === 0) {
56
- coords.push([pos.x, pos.y]);
57
- }
58
- };
59
- for (var i = 0; i < spline.duration; i += 10) {
60
- pushCoord(i);
61
- }
62
- pushCoord(spline.duration);
63
- return helpers_1.lineString(coords, options.properties);
64
- }
65
- exports.default = bezier;
@@ -1,62 +0,0 @@
1
- export interface Point {
2
- x: number;
3
- y: number;
4
- z: number;
5
- }
6
- /**
7
- * BezierSpline
8
- * https://github.com/leszekr/bezier-spline-js
9
- *
10
- * @private
11
- * @copyright
12
- * Copyright (c) 2013 Leszek Rybicki
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- * copies of the Software, and to permit persons to whom the Software is
19
- * furnished to do so, subject to the following conditions:
20
- *
21
- * The above copyright notice and this permission notice shall be included in all
22
- * copies or substantial portions of the Software.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- * SOFTWARE.
31
- */
32
- export default class Spline {
33
- duration: number;
34
- points: Point[];
35
- sharpness: number;
36
- centers: Point[];
37
- controls: Array<[Point, Point]>;
38
- stepLength: number;
39
- length: number;
40
- delay: number;
41
- steps: number[];
42
- constructor(options?: any);
43
- /**
44
- * Caches an array of equidistant (more or less) points on the curve.
45
- */
46
- cacheSteps(mindist: number): number[];
47
- /**
48
- * returns angle and speed in the given point in the curve
49
- */
50
- vector(t: number): {
51
- angle: number;
52
- speed: number;
53
- };
54
- /**
55
- * Gets the position of the point, given time.
56
- *
57
- * WARNING: The speed is not constant. The time it takes between control points is constant.
58
- *
59
- * For constant speed, use Spline.steps[i];
60
- */
61
- pos(time: number): Point;
62
- }