node-red-contrib-web-worldmap 4.3.3 → 4.5.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.
@@ -0,0 +1,50 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # ESLint is a tool for identifying and reporting on patterns
6
+ # found in ECMAScript/JavaScript code.
7
+ # More details at https://github.com/eslint/eslint
8
+ # and https://eslint.org
9
+
10
+ name: ESLint
11
+
12
+ on:
13
+ push:
14
+ branches: [ "master" ]
15
+ pull_request:
16
+ # The branches below must be a subset of the branches above
17
+ branches: [ "master" ]
18
+ schedule:
19
+ - cron: '38 2 * * 4'
20
+
21
+ jobs:
22
+ eslint:
23
+ name: Run eslint scanning
24
+ runs-on: ubuntu-latest
25
+ permissions:
26
+ contents: read
27
+ security-events: write
28
+ actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
29
+ steps:
30
+ - name: Checkout code
31
+ uses: actions/checkout@v3
32
+
33
+ - name: Install ESLint
34
+ run: |
35
+ npm install eslint@8.10.0
36
+ npm install @microsoft/eslint-formatter-sarif@2.1.7
37
+
38
+ - name: Run ESLint
39
+ run: npx eslint .
40
+ --config .eslintrc.js
41
+ --ext .js,.jsx,.ts,.tsx
42
+ --format @microsoft/eslint-formatter-sarif
43
+ --output-file eslint-results.sarif
44
+ continue-on-error: true
45
+
46
+ - name: Upload analysis results to GitHub
47
+ uses: github/codeql-action/upload-sarif@v2
48
+ with:
49
+ sarif_file: eslint-results.sarif
50
+ wait-for-processing: true
package/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  ### Change Log for Node-RED Worldmap
2
2
 
3
+ - v4.5.0 - Fix pmtiles to look for maps in userdir rather than modules
4
+ - v4.4.0 - Add quad(copter) drone icon.
3
5
  - v4.3.3 - Fix for objects changing layers.
4
6
  - v4.3.2 - Fix geojson popup missing label name.
5
7
  - v4.3.1 - Small fix to icon transparency, and routing detail.
package/README.md CHANGED
@@ -13,6 +13,8 @@ Feel free to [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%
13
13
 
14
14
  ### Updates
15
15
 
16
+ - v4.5.0 - Fix pmtiles to look for maps in userdir rather than modules
17
+ - v4.4.0 - Add quad(copter) drone icon.
16
18
  - v4.3.3 - Fix for objects changing layers.
17
19
  - v4.3.2 - Fix geojson popup missing label name.
18
20
  - v4.3.1 - Small fix to icon transparency, and routing detail.
@@ -106,7 +108,8 @@ There are also several special icons...
106
108
  - **ship** : a ship icon that aligns with the heading of travel.
107
109
  - **car** : a car icon that aligns with the heading of travel.
108
110
  - **bus** : a bus/coach icon that aligns with the heading of travel.
109
- - **uav** : a small uav like icon that aligns with the heading of travel.
111
+ - **uav** : a small drone uav like icon that aligns with the heading of travel.
112
+ - **quad** : a small quadcopter uav like icon that aligns with the heading of travel.
110
113
  - **helicopter** : a small helicopter icon that aligns with the heading of travel.
111
114
  - **sensor** : a camera icon that points to the heading angle.
112
115
  - **arrow** : a map GPS arrow type pointer that aligns with the heading of travel.
@@ -718,7 +721,7 @@ You can use a PMtiles format map archive file from [Protomaps](https://docs.prot
718
721
 
719
722
  **Note**: the whole planet file is over 100GB so be warned both for local storage and your download speed. You can download or extract just a portion of it if you use the **pmtiles** command line with the extract option. Use `pmtiles extract --help` to see the options.
720
723
 
721
- Copy, or create an alias to, your .pmtiles file(s) into your `~/.node-red/node_modules/node-red-contrib-web-worldmap/worldmap/` directory. On re-starting Node-RED the node will detect the file(s) and add them to the base map layer menu, using the file name as the layer name.
724
+ Copy your .pmtiles file(s) into your `~/.node-red` user directory. On re-starting Node-RED the node will detect the file(s) and add them to the base map layer menu, using the file name as the layer name.
722
725
 
723
726
  ### Using a Docker Map Server
724
727
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-web-worldmap",
3
- "version": "4.3.3",
3
+ "version": "4.5.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",
@@ -1845,6 +1845,18 @@ function setMarker(data) {
1845
1845
  });
1846
1846
  marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
1847
1847
  }
1848
+ else if (data.icon === "quad") {
1849
+ data.iconColor = data.iconColor || "black";
1850
+ icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 22 22">';
1851
+ icon+= '<path d="m6 3a3 3 0 0 0 -3 3 3 3 0 0 0 3 3 3 3 0 0 0 1.0859375-.2070312c.5392711.8209481.9140625 1.6424172.9140625 2.2070312 0 .563623-.3724493 1.384498-.9101562 2.205078a3 3 0 0 0 -1.0898438-.205078 3 3 0 0 0 -3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0 -.2050781-1.080078c.8233483-.542436 1.6446221-.919922 2.2050781-.919922.55949 0 1.37815.375313 2.201172.916016a3 3 0 0 0 -.201172 1.083984 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0 -3-3 3 3 0 0 0 -1.085938.207031c-.539273-.820943-.914062-1.642417-.914062-2.207031 0-.563623.372445-1.3844956.910156-2.2050781a3 3 0 0 0 .002.00195 3 3 0 0 0 1.087844.2031281 3 3 0 0 0 3-3 3 3 0 0 0 -3-3 3 3 0 0 0 -3 3 3 3 0 0 0 .205078 1.0800781c-.823351.5424443-1.644622.9199219-2.205078.9199219-.55949 0-1.3781473-.3753084-2.2011719-.9160156a3 3 0 0 0 .2011719-1.0839844 3 3 0 0 0 -3-3zm0 1a2 2 0 0 1 2 2 2 2 0 0 1 -.0527344.453125c-.4577913-.368834-.8926099-.7589139-1.2402344-1.1601562a1 1 0 0 0 -.6933593-.2929688 1 1 0 0 0 -.7207031.2929688 1 1 0 0 0 0 1.4140624 1 1 0 0 0 .058594.054688c.3824613.333788.7551689.7476371 1.1074216 1.1835933a2 2 0 0 1 -.4589844.0546875 2 2 0 0 1 -2-2 2 2 0 0 1 2-2zm10 0a2 2 0 0 1 2 2 2 2 0 0 1 -2 2 2 2 0 0 1 -.457031-.054687c.37051-.4592027.761959-.8951713 1.164062-1.2382813a1 1 0 0 0 0-1.4140624 1 1 0 0 0 -1.414062 0 1 1 0 0 0 -.05274.054687c-.337606.3818392-.750702.7543351-1.185541 1.1054687a2 2 0 0 1 -.054688-.453125 2 2 0 0 1 2-2zm-10 10a2 2 0 0 1 .4570312.05469c-.3705108.459203-.7619484.895165-1.1640624 1.238281a1 1 0 0 0 0 1.414062 1 1 0 0 0 1.4140624 0 1 1 0 0 0 .052734-.05469c.3376223-.381857.7507063-.754333 1.1855473-1.105468a2 2 0 0 1 .0546875.453125 2 2 0 0 1 -2 2 2 2 0 0 1 -2-2 2 2 0 0 1 2-2zm10 0a2 2 0 0 1 2 2 2 2 0 0 1 -2 2 2 2 0 0 1 -2-2 2 2 0 0 1 .05273-.453125c.457792.368835.892604.758903 1.240235 1.160156a1 1 0 0 0 1.414062 0 1 1 0 0 0 0-1.414062c-.01717-.01465-.0336-.03387-.05078-.04883a1 1 0 0 0 -.0078-.0059c-.382475-.333732-.755177-.747602-1.107431-1.183551a2 2 0 0 1 .458984-.054688z" fill="'+data.iconColor+'"/></svg>';
1852
+ var svgquad = "data:image/svg+xml;base64," + btoa(icon);
1853
+ myMarker = L.divIcon({
1854
+ className:"quadicon",
1855
+ iconAnchor: [16, 16],
1856
+ html:'<img src="'+svgquad+'" style="width:32px; height:32px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>',
1857
+ });
1858
+ marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
1859
+ }
1848
1860
  else if (data.icon === "car") {
1849
1861
  data.iconColor = data.iconColor || "black";
1850
1862
  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">';
@@ -2262,6 +2274,15 @@ function setMarker(data) {
2262
2274
  marker.bindPopup(words, wopt);
2263
2275
  marker._popup.dname = data["name"];
2264
2276
  }
2277
+
2278
+ if (data.hasOwnProperty("clickURL")) {
2279
+ marker.on('click', function () {
2280
+ console.log("Click URL - ",data.clickURL)
2281
+ window.open(data.clickURL.replace('@',''), 'newwindow', 'width=640, height=480');
2282
+ return false;
2283
+ });
2284
+ }
2285
+
2265
2286
  marker.lay = lay; // and the layer it is on
2266
2287
 
2267
2288
  // marker.on('click', function(e) {
package/worldmap.html CHANGED
@@ -1,4 +1,8 @@
1
1
  <script type="text/html" data-template-name="worldmap">
2
+ <div class="form-row">
3
+ <label for="node-input-name"><i class="fa fa-file"></i> Name</label>
4
+ <input type="text" id="node-input-name" placeholder="name">
5
+ </div>
2
6
  <div class="form-row">
3
7
  <table border="0" width="96%">
4
8
  <tr><td width="100px"><i class="fa fa-globe"></i> Start<td>Latitude</td><td>Longitude</td><td width="60px">Zoom</td></tr>
@@ -108,10 +112,6 @@
108
112
  <option value="true">Enable</option>
109
113
  </select>
110
114
  </div>
111
- <div class="form-row">
112
- <label for="node-input-name"><i class="fa fa-file"></i> Name</label>
113
- <input type="text" id="node-input-name" placeholder="name">
114
- </div>
115
115
  <div class="form-tips">Set <i>Cluster when</i> to 0 to disable clustering of points.<br/>
116
116
  If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the map in a new tab.</div>
117
117
  </script>
@@ -155,6 +155,10 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
155
155
 
156
156
 
157
157
  <script type="text/html" data-template-name="ui_worldmap">
158
+ <div class="form-row">
159
+ <label for="node-input-name"><i class="fa fa-file"></i> Name</label>
160
+ <input type="text" id="node-input-name" placeholder="name">
161
+ </div>
158
162
  <div class="form-row" id="template-row-group">
159
163
  <label for="node-input-group"><i class="fa fa-table"></i> Group</span></label>
160
164
  <input type="text" id="node-input-group">
@@ -274,10 +278,6 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
274
278
  <option value="true">Enable</option>
275
279
  </select>
276
280
  </div>
277
- <div class="form-row">
278
- <label for="node-input-name"><i class="fa fa-file"></i> Name</label>
279
- <input type="text" id="node-input-name" placeholder="name">
280
- </div>
281
281
  <div class="form-tips">Set <i>Cluster when</i> to 0 to disable clustering of points.<br/>
282
282
  If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the map in a new tab.</div>
283
283
  </script>
@@ -593,6 +593,10 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
593
593
 
594
594
 
595
595
  <script type="text/html" data-template-name="worldmap in">
596
+ <div class="form-row">
597
+ <label for="node-input-name"><i class="fa fa-file"></i> Name</label>
598
+ <input type="text" id="node-input-name" placeholder="name">
599
+ </div>
596
600
  <div class="form-row">
597
601
  <label for="node-input-path"><i class="fa fa-globe"></i> Web Path</label>
598
602
  <input type="text" id="node-input-path" placeholder="worldmap">
@@ -601,10 +605,6 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
601
605
  <label for="node-input-events"><i class="fa fa-sign-out"></i> Events</label>
602
606
  <input type="text" id="node-input-events" placeholder="select events">
603
607
  </div>
604
- <div class="form-row">
605
- <label for="node-input-name"><i class="fa fa-file"></i> Name</label>
606
- <input type="text" id="node-input-name" placeholder="name">
607
- </div>
608
608
  </script>
609
609
 
610
610
  <script type="text/html" data-help-name="worldmap in">
@@ -679,6 +679,10 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
679
679
 
680
680
 
681
681
  <script type="text/html" data-template-name="worldmap-tracks">
682
+ <div class="form-row">
683
+ <label for="node-input-name"><i class="fa fa-file"></i> Name</label>
684
+ <input type="text" id="node-input-name" placeholder="name">
685
+ </div>
682
686
  <div class="form-row">
683
687
  <label for="node-input-depth"><i class="fa fa-map-marker"></i> Number of</label>
684
688
  points in track <input type="text" id="node-input-depth" style="width:50%" placeholder="number - default 20">
@@ -696,10 +700,6 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
696
700
  <input type="checkbox" id="node-input-smooth" style="display:inline-block; width:auto; vertical-align:top;">
697
701
  <label for="node-input-smooth" style="width:70%;">Smooth tracks using bezier curves.</label>
698
702
  </div>
699
- <div class="form-row">
700
- <label for="node-input-name"><i class="fa fa-file"></i> Name</label>
701
- <input type="text" id="node-input-name" placeholder="name">
702
- </div>
703
703
  </script>
704
704
 
705
705
  <script type="text/html" data-help-name="worldmap-tracks">
@@ -739,14 +739,14 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
739
739
 
740
740
 
741
741
  <script type="text/html" data-template-name="worldmap-hull">
742
- <div class="form-row">
743
- <label for="node-input-prop"><i class="fa fa-ellipsis-h"></i> Property</label>
744
- <input type="text" id="node-input-prop" placeholder="payload property to group">
745
- </div>
746
742
  <div class="form-row">
747
743
  <label for="node-input-name"><i class="fa fa-file"></i> Name</label>
748
744
  <input type="text" id="node-input-name" placeholder="name">
749
745
  </div>
746
+ <div class="form-row">
747
+ <label for="node-input-prop"><i class="fa fa-ellipsis-h"></i> Property</label>
748
+ <input type="text" id="node-input-prop" placeholder="payload property to group">
749
+ </div>
750
750
  </script>
751
751
 
752
752
  <script type="text/html" data-help-name="worldmap-hull">
package/worldmap.js CHANGED
@@ -13,7 +13,8 @@ module.exports = function(RED) {
13
13
  if (fs.existsSync((__dirname + '/mapserv'))) {
14
14
  RED.httpNode.use("/cgi-bin/mapserv", require('cgi')(__dirname + '/mapserv'));
15
15
  }
16
- var pmtiles = fs.readdirSync(__dirname + '/worldmap').filter(fn => fn.endsWith('.pmtiles'));
16
+ //var pmtiles = fs.readdirSync(__dirname + '/worldmap').filter(fn => fn.endsWith('.pmtiles'));
17
+ var pmtiles = fs.readdirSync(RED.settings.userDir).filter(fn => fn.endsWith('.pmtiles'));
17
18
 
18
19
  function worldMap(node, n) {
19
20
  var allPoints = {};
@@ -121,7 +122,14 @@ module.exports = function(RED) {
121
122
  //console.log("INIT",c)
122
123
  client.write(JSON.stringify({command:c}));
123
124
  for (var p=0; p<pmtiles.length; p++) {
124
- client.write(JSON.stringify({command: {map: {name:pmtiles[p].split('.')[0], pmtiles:pmtiles[p] }}}));
125
+ fs.symlink(RED.settings.userDir+'/'+pmtiles[p], __dirname+'/worldmap/'+pmtiles[p], 'file', (err) => {
126
+ if (err) {
127
+ if (err.code !== "EEXIST") { console.log(err); }
128
+ }
129
+ else {
130
+ client.write(JSON.stringify({command: {map: {name:pmtiles[p].split('.')[0], pmtiles:pmtiles[p] }}}));
131
+ }
132
+ })
125
133
  }
126
134
  var o = Object.values(allPoints);
127
135
  o.map(v => delete v.tout);