node-red-contrib-web-worldmap 4.9.0 → 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.
- package/CHANGELOG.md +1 -0
- package/README.md +6 -3
- package/examples/{feedback.json → Feedback.json} +1 -9
- package/examples/MouseCoordinates.json +159 -0
- package/examples/sidcEdgeIcon.json +158 -0
- package/node_modules/@turf/bezier-spline/README.md +15 -21
- package/node_modules/@turf/bezier-spline/dist/cjs/index.cjs +165 -0
- package/node_modules/@turf/bezier-spline/dist/cjs/index.cjs.map +1 -0
- package/node_modules/@turf/bezier-spline/dist/{es/index.js → cjs/index.d.cts} +9 -30
- package/node_modules/@turf/bezier-spline/dist/{js → esm}/index.d.ts +5 -3
- package/node_modules/@turf/bezier-spline/dist/esm/index.js +165 -0
- package/node_modules/@turf/bezier-spline/dist/esm/index.js.map +1 -0
- package/node_modules/@turf/bezier-spline/package.json +33 -25
- package/node_modules/@turf/helpers/README.md +231 -219
- package/node_modules/@turf/helpers/dist/cjs/index.cjs +308 -0
- package/node_modules/@turf/helpers/dist/cjs/index.cjs.map +1 -0
- package/node_modules/@turf/helpers/dist/{es/index.js → cjs/index.d.cts} +103 -303
- package/node_modules/@turf/helpers/dist/{js → esm}/index.d.ts +67 -53
- package/node_modules/@turf/helpers/dist/esm/index.js +308 -0
- package/node_modules/@turf/helpers/dist/esm/index.js.map +1 -0
- package/node_modules/@turf/helpers/package.json +32 -22
- package/node_modules/@turf/invariant/README.md +47 -58
- package/node_modules/@turf/invariant/dist/cjs/index.cjs +127 -0
- package/node_modules/@turf/invariant/dist/cjs/index.cjs.map +1 -0
- package/node_modules/@turf/invariant/dist/cjs/index.d.cts +108 -0
- package/node_modules/@turf/invariant/dist/{js → esm}/index.d.ts +12 -9
- package/node_modules/@turf/invariant/dist/esm/index.js +127 -0
- package/node_modules/@turf/invariant/dist/esm/index.js.map +1 -0
- package/node_modules/@turf/invariant/package.json +31 -22
- package/node_modules/@types/geojson/LICENSE +21 -0
- package/node_modules/@types/geojson/README.md +15 -0
- package/node_modules/@types/geojson/index.d.ts +165 -0
- package/node_modules/@types/geojson/package.json +45 -0
- package/node_modules/body-parser/HISTORY.md +7 -0
- package/node_modules/body-parser/README.md +11 -0
- package/node_modules/body-parser/lib/types/urlencoded.js +30 -7
- package/node_modules/body-parser/package.json +2 -2
- package/node_modules/encodeurl/README.md +19 -38
- package/node_modules/encodeurl/index.js +1 -1
- package/node_modules/encodeurl/package.json +7 -7
- package/node_modules/express/History.md +27 -0
- package/node_modules/express/Readme.md +100 -6
- package/node_modules/express/lib/response.js +11 -10
- package/node_modules/express/package.json +11 -11
- package/node_modules/finalhandler/HISTORY.md +15 -0
- package/node_modules/finalhandler/README.md +2 -2
- package/node_modules/finalhandler/index.js +7 -2
- package/node_modules/finalhandler/package.json +8 -7
- package/node_modules/merge-descriptors/README.md +4 -3
- package/node_modules/merge-descriptors/index.js +3 -3
- package/node_modules/merge-descriptors/package.json +14 -7
- package/node_modules/mime-db/HISTORY.md +14 -0
- package/node_modules/mime-db/README.md +27 -24
- package/node_modules/mime-db/db.json +646 -62
- package/node_modules/mime-db/package.json +9 -13
- package/node_modules/mime-types/node_modules/mime-db/HISTORY.md +507 -0
- package/node_modules/mime-types/node_modules/mime-db/LICENSE +23 -0
- package/node_modules/mime-types/node_modules/mime-db/README.md +100 -0
- package/node_modules/mime-types/node_modules/mime-db/db.json +8519 -0
- package/node_modules/mime-types/node_modules/mime-db/index.js +12 -0
- package/node_modules/mime-types/node_modules/mime-db/package.json +60 -0
- package/node_modules/object-inspect/CHANGELOG.md +15 -0
- package/node_modules/object-inspect/index.js +4 -1
- package/node_modules/object-inspect/package.json +14 -9
- package/node_modules/object-inspect/readme.markdown +9 -11
- package/node_modules/path-to-regexp/index.js +57 -40
- package/node_modules/path-to-regexp/package.json +2 -2
- package/node_modules/qs/.editorconfig +3 -0
- package/node_modules/qs/.eslintrc +2 -2
- package/node_modules/qs/CHANGELOG.md +59 -5
- package/node_modules/qs/README.md +133 -49
- package/node_modules/qs/dist/qs.js +56 -2020
- package/node_modules/qs/lib/parse.js +46 -13
- package/node_modules/qs/lib/stringify.js +53 -28
- package/node_modules/qs/lib/utils.js +47 -34
- package/node_modules/qs/package.json +26 -12
- package/node_modules/qs/test/empty-keys-cases.js +267 -0
- package/node_modules/qs/test/parse.js +347 -32
- package/node_modules/qs/test/stringify.js +436 -47
- package/node_modules/send/HISTORY.md +5 -0
- package/node_modules/send/index.js +1 -2
- package/node_modules/send/node_modules/encodeurl/LICENSE +22 -0
- package/node_modules/send/node_modules/encodeurl/README.md +128 -0
- package/node_modules/send/node_modules/encodeurl/index.js +60 -0
- package/node_modules/send/node_modules/encodeurl/package.json +40 -0
- package/node_modules/send/package.json +1 -1
- package/node_modules/serve-static/HISTORY.md +16 -0
- package/node_modules/serve-static/index.js +1 -2
- package/node_modules/serve-static/package.json +3 -3
- package/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/node_modules/tslib/LICENSE.txt +12 -0
- package/node_modules/tslib/README.md +164 -0
- package/node_modules/tslib/SECURITY.md +41 -0
- package/node_modules/tslib/modules/index.d.ts +37 -0
- package/node_modules/tslib/modules/index.js +68 -0
- package/node_modules/tslib/modules/package.json +3 -0
- package/node_modules/tslib/package.json +47 -0
- package/node_modules/tslib/tslib.d.ts +453 -0
- package/node_modules/tslib/tslib.es6.html +1 -0
- package/node_modules/tslib/tslib.es6.js +379 -0
- package/node_modules/tslib/tslib.es6.mjs +378 -0
- package/node_modules/tslib/tslib.html +1 -0
- package/node_modules/tslib/tslib.js +429 -0
- package/package.json +5 -5
- package/worldmap/index.html +1 -1
- package/worldmap/leaflet/leaflet.mousecoordinate.js +3 -3
- package/worldmap/worldmap.js +123 -36
- package/worldmap.html +1 -1
- package/worldmap.js +23 -4
- package/node_modules/@turf/bezier-spline/dist/es/lib/spline.js +0 -158
- package/node_modules/@turf/bezier-spline/dist/es/package.json +0 -1
- package/node_modules/@turf/bezier-spline/dist/js/index.js +0 -65
- package/node_modules/@turf/bezier-spline/dist/js/lib/spline.d.ts +0 -62
- package/node_modules/@turf/bezier-spline/dist/js/lib/spline.js +0 -160
- package/node_modules/@turf/helpers/dist/es/lib/geojson.js +0 -7
- package/node_modules/@turf/helpers/dist/es/package.json +0 -1
- package/node_modules/@turf/helpers/dist/js/index.js +0 -724
- package/node_modules/@turf/helpers/dist/js/lib/geojson.d.ts +0 -193
- package/node_modules/@turf/helpers/dist/js/lib/geojson.js +0 -9
- package/node_modules/@turf/invariant/dist/es/index.js +0 -223
- package/node_modules/@turf/invariant/dist/es/package.json +0 -1
- package/node_modules/@turf/invariant/dist/js/index.js +0 -233
- package/node_modules/path-to-regexp/History.md +0 -36
- /package/node_modules/{encodeurl → send/node_modules/encodeurl}/HISTORY.md +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
### Change Log for Node-RED Worldmap
|
|
2
2
|
|
|
3
|
+
- v5.0.0 - Feedback cleanup PR#281, edgeicons option PR#287, bump libs for vuln fixes.
|
|
3
4
|
- v4.9.0 - If payload.flag is two char ISO code replace it with flag emoji. Revert part of PR #271
|
|
4
5
|
- v4.8.1 - Slight tidy of some of the geojson handling
|
|
5
6
|
- v4.8.0 - Merged PR for feedback functionality cleanup and example. PR #271 and #272
|
package/README.md
CHANGED
|
@@ -13,7 +13,8 @@ Feel free to [ - `{"command":{"showlayer":"foo"}}` or `{"command":{"showlayer":["foo","bar"]}}`
|
|
385
386
|
- **hidelayer** - hide the named overlay(s) - `{"command":{"hidelayer":"bar"}}` or `{"command":{"hidelayer":["bar","another"]}}`
|
|
387
|
+
- **clearlayer** - layer name - to clear a complete layer and remove from layer menu - `{"command":{"clearlayer":"myOldLayer"}}` or `{"command":{"clearlayer":["oldLayer1","oldLayer2","etc,etc"]}}`
|
|
386
388
|
- **side** - add a second map alongside with slide between them. Use the name of a *baselayer* to add - or "none" to remove the control. - `{"command":{"side":"Esri Satellite"}}`
|
|
387
389
|
- **split** - once you have split the screen with the *side* command - the split value is then the % across the screen of the split line. - `{"command":{"split":50}}`
|
|
388
390
|
- **map** - Object containing details of a new map layer:
|
|
@@ -394,7 +396,6 @@ Optional properties for **msg.payload.command** include
|
|
|
394
396
|
- **delete** - name or array of names of base layers and/or overlays to delete and remove from layer menu.
|
|
395
397
|
- **heatmap** - set heatmap latlngs array object see https://github.com/Leaflet/Leaflet.heat#reference
|
|
396
398
|
- **options** - if heatmap set, then use this to set heatmap options object see https://github.com/Leaflet/Leaflet.heat#reference
|
|
397
|
-
- **clear** - layer name - to clear a complete layer and remove from layer menu - `{"command":{"clear":"myOldLayer"}}`
|
|
398
399
|
- **panlock** - lock the map area to the current visible area. - `{"command":{"panlock":true}}`
|
|
399
400
|
- **panit** - auto pan to the latest marker updated. - `{"command":{"panit":true}}`
|
|
400
401
|
- **zoomlock** - locks the zoom control to the current value and removes zoom control - `{"command":{"zoomlock":true}}`
|
|
@@ -410,6 +411,7 @@ Optional properties for **msg.payload.command** include
|
|
|
410
411
|
- **trackme** - Turns on/off the browser self locating. Boolean false = off, true = cyan circle showing accuracy error, or an object like `{"command":{"trackme":{"name":"Dave","icon":"car","iconColor":"blue","layer":"mytrack","accuracy":false}}}`. Usual marker options can be applied.
|
|
411
412
|
- **showmenu** - Show or hide the display of the hamberger menu control in the top right . Values can be "show" or "hide". - `{"command":{"showmenu": "hide"}}`
|
|
412
413
|
- **showlayers** - Show or hide the display of selectable layers. Does not control the display of an individual layer, rather a users ability to interact with them. Values can be "show" or "hide". - `{"command":{"showlayers": "hide"}}`
|
|
414
|
+
- **edgeenabled** - Show or hide small sidc icons around edge of map for things just outside of view. Values can be true or false (default is true). - `{"command":{"edgeenabled": false}}`
|
|
413
415
|
|
|
414
416
|
#### To switch layer, move map and zoom
|
|
415
417
|
|
|
@@ -421,7 +423,8 @@ You can also use the name "none" to completely remove the base layer,
|
|
|
421
423
|
|
|
422
424
|
#### To clear all markers from a layer, or an overlay from the map
|
|
423
425
|
|
|
424
|
-
msg.payload = { "command": { "
|
|
426
|
+
msg.payload = { "command": { "clearlayer: "name of the layer/overlay you wish to clear" }};
|
|
427
|
+
msg.payload = { "command": { "clearlayer: ["array","ofLayer","names","toClear"] }};
|
|
425
428
|
|
|
426
429
|
Feeding this into the tracks node will also remove the tracks stored for that layer.
|
|
427
430
|
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
[
|
|
2
|
-
{
|
|
3
|
-
"id": "46f4b9ae1c66c1ba",
|
|
4
|
-
"type": "tab",
|
|
5
|
-
"label": "Flow 4",
|
|
6
|
-
"disabled": false,
|
|
7
|
-
"info": "",
|
|
8
|
-
"env": []
|
|
9
|
-
},
|
|
10
2
|
{
|
|
11
3
|
"id": "c643e022.1816c",
|
|
12
4
|
"type": "worldmap",
|
|
@@ -63,7 +55,7 @@
|
|
|
63
55
|
"type": "function",
|
|
64
56
|
"z": "46f4b9ae1c66c1ba",
|
|
65
57
|
"name": "add new rectangle",
|
|
66
|
-
"func": "\nmsg.payload = {\"command\":{\"bounds\":[[49.83682820280039,-4.019763692204326],[51.4723362586149,1.1741268015945219]]}};\nnode.send(msg);\nmsg.payload = {\"command\":{\"zoom\":9.7}};\nnode.send(msg);\n\n\nvar popup = \"<button name=\\\"B1name\\\" onclick='feedback(\\\"${name}\\\"
|
|
58
|
+
"func": "\nmsg.payload = {\"command\":{\"bounds\":[[49.83682820280039,-4.019763692204326],[51.4723362586149,1.1741268015945219]]}};\nnode.send(msg);\nmsg.payload = {\"command\":{\"zoom\":9.7}};\nnode.send(msg);\n\n\nvar popup = \"<button name=\\\"B1name\\\" onclick='feedback(\\\"${name}\\\", this.name + \\\" sends {x} Hellow\\\",\\\"myAction\\\",true);'>Hellow1 from ${name}</button>\";\npopup += \"<button name=\\\"B2name\\\" onclick='feedback(\\\"${name}\\\", this.name + \\\" sends {x} Hellow\\\",\\\"myAction\\\",true);'>Hellow2 from ${name}</button>\";\n\nvar points = [ { \"lat\": 50.66, \"lng\": -1.59 }, { \"lat\": 50.60, \"lng\": -1.47 } ] ;\nmsg.payload = {\n popup: popup.replace(/\\{x\\}/g,\"popup\"),\n contextmenu: popup.replace(/\\{x\\}/g, \"context\"),\n name: \"myShape\",\n area: points,\n clickable:true,\n };\nnode.send(msg);\n\nmsg.payload = {\n popup: popup.replace(/\\{x\\}/g,\"popup\"),\n contextmenu: popup.replace(/\\{x\\}/g, \"context\"),\n name: \"myMarker\",\n lat: 50.40,\n lon: -1.0,\n weight: 1,\n};\nnode.send(msg);\nmsg.payload.command = {\n contextmenu: popup.replace(/\\{x\\}/g,\"context\")\n};\nnode.send(msg);\nreturn msg;",
|
|
67
59
|
"outputs": 1,
|
|
68
60
|
"timeout": "",
|
|
69
61
|
"noerr": 0,
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "c643e022.1816c",
|
|
4
|
+
"type": "worldmap",
|
|
5
|
+
"z": "f6f2187d.f17ca8",
|
|
6
|
+
"name": "",
|
|
7
|
+
"lat": "30",
|
|
8
|
+
"lon": "0",
|
|
9
|
+
"zoom": "3",
|
|
10
|
+
"layer": "OSMG",
|
|
11
|
+
"cluster": "",
|
|
12
|
+
"maxage": "",
|
|
13
|
+
"usermenu": "show",
|
|
14
|
+
"layers": "show",
|
|
15
|
+
"panit": "false",
|
|
16
|
+
"panlock": "false",
|
|
17
|
+
"zoomlock": "false",
|
|
18
|
+
"hiderightclick": "false",
|
|
19
|
+
"coords": "deg",
|
|
20
|
+
"showgrid": "false",
|
|
21
|
+
"showruler": "false",
|
|
22
|
+
"allowFileDrop": "false",
|
|
23
|
+
"path": "worldmap",
|
|
24
|
+
"overlist": "DR,CO,RA,DN",
|
|
25
|
+
"maplist": "OSMG,OSMH,EsriS",
|
|
26
|
+
"mapname": "",
|
|
27
|
+
"mapurl": "",
|
|
28
|
+
"mapopt": "",
|
|
29
|
+
"mapwms": false,
|
|
30
|
+
"x": 1480,
|
|
31
|
+
"y": 700,
|
|
32
|
+
"wires": []
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "32d7cc4d4db67f66",
|
|
36
|
+
"type": "worldmap in",
|
|
37
|
+
"z": "f6f2187d.f17ca8",
|
|
38
|
+
"name": "",
|
|
39
|
+
"path": "/worldmap",
|
|
40
|
+
"events": "connect,disconnect,point,layer,bounds,files,draw,other",
|
|
41
|
+
"x": 900,
|
|
42
|
+
"y": 700,
|
|
43
|
+
"wires": [
|
|
44
|
+
[
|
|
45
|
+
"32a2b83008623990"
|
|
46
|
+
]
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "32a2b83008623990",
|
|
51
|
+
"type": "debug",
|
|
52
|
+
"z": "f6f2187d.f17ca8",
|
|
53
|
+
"name": "debug 14",
|
|
54
|
+
"active": true,
|
|
55
|
+
"tosidebar": true,
|
|
56
|
+
"console": false,
|
|
57
|
+
"tostatus": false,
|
|
58
|
+
"complete": "false",
|
|
59
|
+
"statusVal": "",
|
|
60
|
+
"statusType": "auto",
|
|
61
|
+
"x": 1060,
|
|
62
|
+
"y": 620,
|
|
63
|
+
"wires": []
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "34ad8daae96efd3e",
|
|
67
|
+
"type": "debug",
|
|
68
|
+
"z": "f6f2187d.f17ca8",
|
|
69
|
+
"name": "debug 15",
|
|
70
|
+
"active": true,
|
|
71
|
+
"tosidebar": true,
|
|
72
|
+
"console": false,
|
|
73
|
+
"tostatus": false,
|
|
74
|
+
"complete": "false",
|
|
75
|
+
"statusVal": "",
|
|
76
|
+
"statusType": "auto",
|
|
77
|
+
"x": 1480,
|
|
78
|
+
"y": 620,
|
|
79
|
+
"wires": []
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"id": "4cf111b68098072d",
|
|
83
|
+
"type": "inject",
|
|
84
|
+
"z": "f6f2187d.f17ca8",
|
|
85
|
+
"name": "Deg + DMS + UTM",
|
|
86
|
+
"props": [
|
|
87
|
+
{
|
|
88
|
+
"p": "payload"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"repeat": "",
|
|
92
|
+
"crontab": "",
|
|
93
|
+
"once": false,
|
|
94
|
+
"onceDelay": "0.5",
|
|
95
|
+
"topic": "",
|
|
96
|
+
"payload": " {\"command\": {\"coords\" : \"deg,dms,utm\"}}",
|
|
97
|
+
"payloadType": "json",
|
|
98
|
+
"x": 1270,
|
|
99
|
+
"y": 700,
|
|
100
|
+
"wires": [
|
|
101
|
+
[
|
|
102
|
+
"c643e022.1816c",
|
|
103
|
+
"34ad8daae96efd3e"
|
|
104
|
+
]
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "610e6795facbc3b7",
|
|
109
|
+
"type": "inject",
|
|
110
|
+
"z": "f6f2187d.f17ca8",
|
|
111
|
+
"name": "Deg + UTM",
|
|
112
|
+
"props": [
|
|
113
|
+
{
|
|
114
|
+
"p": "payload"
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
"repeat": "",
|
|
118
|
+
"crontab": "",
|
|
119
|
+
"once": false,
|
|
120
|
+
"onceDelay": "0.5",
|
|
121
|
+
"topic": "",
|
|
122
|
+
"payload": " {\"command\": {\"coords\" : \"deg,utm\"}}",
|
|
123
|
+
"payloadType": "json",
|
|
124
|
+
"x": 1250,
|
|
125
|
+
"y": 760,
|
|
126
|
+
"wires": [
|
|
127
|
+
[
|
|
128
|
+
"c643e022.1816c",
|
|
129
|
+
"34ad8daae96efd3e"
|
|
130
|
+
]
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"id": "9a238dc42949cb17",
|
|
135
|
+
"type": "inject",
|
|
136
|
+
"z": "f6f2187d.f17ca8",
|
|
137
|
+
"name": "None",
|
|
138
|
+
"props": [
|
|
139
|
+
{
|
|
140
|
+
"p": "payload"
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
"repeat": "",
|
|
144
|
+
"crontab": "",
|
|
145
|
+
"once": false,
|
|
146
|
+
"onceDelay": "0.5",
|
|
147
|
+
"topic": "",
|
|
148
|
+
"payload": " {\"command\": {\"coords\" : \"\"}}",
|
|
149
|
+
"payloadType": "json",
|
|
150
|
+
"x": 1230,
|
|
151
|
+
"y": 820,
|
|
152
|
+
"wires": [
|
|
153
|
+
[
|
|
154
|
+
"c643e022.1816c",
|
|
155
|
+
"34ad8daae96efd3e"
|
|
156
|
+
]
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
]
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "3e0aaa7abbebfb76",
|
|
4
|
+
"type": "inject",
|
|
5
|
+
"z": "5ffb0f06dfc7e99e",
|
|
6
|
+
"name": "",
|
|
7
|
+
"repeat": "",
|
|
8
|
+
"crontab": "",
|
|
9
|
+
"once": false,
|
|
10
|
+
"topic": "",
|
|
11
|
+
"payload": "",
|
|
12
|
+
"payloadType": "str",
|
|
13
|
+
"x": 630,
|
|
14
|
+
"y": 440,
|
|
15
|
+
"wires": [
|
|
16
|
+
[
|
|
17
|
+
"1b0f9c61acc853d8"
|
|
18
|
+
]
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "1b0f9c61acc853d8",
|
|
23
|
+
"type": "function",
|
|
24
|
+
"z": "5ffb0f06dfc7e99e",
|
|
25
|
+
"name": "Add SIDC object to map",
|
|
26
|
+
"func": "msg.payload = {\n \"name\": \"Emergency Medical Operation\",\n \"lat\": 51.05,\n \"lon\": -1.35,\n \"SIDC\": \"ENOPA-------\",\n \"options\": { \"fillOpacity\": 0.8, \"additionalInformation\": \"Extra info\" }\n}\nreturn msg;",
|
|
27
|
+
"outputs": 1,
|
|
28
|
+
"timeout": "",
|
|
29
|
+
"noerr": 0,
|
|
30
|
+
"initialize": "",
|
|
31
|
+
"finalize": "",
|
|
32
|
+
"libs": [],
|
|
33
|
+
"x": 840,
|
|
34
|
+
"y": 440,
|
|
35
|
+
"wires": [
|
|
36
|
+
[
|
|
37
|
+
"e12fb3cdb87416ed"
|
|
38
|
+
]
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "cbeb8daf52cb3088",
|
|
43
|
+
"type": "comment",
|
|
44
|
+
"z": "5ffb0f06dfc7e99e",
|
|
45
|
+
"name": "Simple map - click inject to send point to map.",
|
|
46
|
+
"info": "Adds a map at http://(your-server-ip):1880/worldmap. \n\nThe `function` node creates a SIDC object with some basic properties required to add to a map.",
|
|
47
|
+
"x": 830,
|
|
48
|
+
"y": 380,
|
|
49
|
+
"wires": []
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "e12fb3cdb87416ed",
|
|
53
|
+
"type": "worldmap",
|
|
54
|
+
"z": "5ffb0f06dfc7e99e",
|
|
55
|
+
"name": "",
|
|
56
|
+
"lat": "",
|
|
57
|
+
"lon": "",
|
|
58
|
+
"zoom": "",
|
|
59
|
+
"layer": "OSMG",
|
|
60
|
+
"cluster": "",
|
|
61
|
+
"maxage": "",
|
|
62
|
+
"usermenu": "show",
|
|
63
|
+
"layers": "show",
|
|
64
|
+
"panit": "false",
|
|
65
|
+
"panlock": "false",
|
|
66
|
+
"zoomlock": "false",
|
|
67
|
+
"hiderightclick": "false",
|
|
68
|
+
"coords": "none",
|
|
69
|
+
"showgrid": "false",
|
|
70
|
+
"showruler": "true",
|
|
71
|
+
"allowFileDrop": "false",
|
|
72
|
+
"path": "/worldmap",
|
|
73
|
+
"overlist": "DR,CO,RA,DN,HM",
|
|
74
|
+
"maplist": "OSMG,OSMC,EsriC,EsriS,EsriT,EsriO,EsriDG,NatGeo,UKOS,OpTop",
|
|
75
|
+
"mapname": "",
|
|
76
|
+
"mapurl": "",
|
|
77
|
+
"mapopt": "",
|
|
78
|
+
"mapwms": false,
|
|
79
|
+
"x": 1060,
|
|
80
|
+
"y": 440,
|
|
81
|
+
"wires": []
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"id": "c5da3e3241f2bfcc",
|
|
85
|
+
"type": "inject",
|
|
86
|
+
"z": "5ffb0f06dfc7e99e",
|
|
87
|
+
"name": "Disable Edge Icon",
|
|
88
|
+
"props": [
|
|
89
|
+
{
|
|
90
|
+
"p": "payload"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"repeat": "",
|
|
94
|
+
"crontab": "",
|
|
95
|
+
"once": false,
|
|
96
|
+
"onceDelay": 0.1,
|
|
97
|
+
"topic": "",
|
|
98
|
+
"payload": "{\"command\" : {\"sidcEdgeIcon\" : false}}",
|
|
99
|
+
"payloadType": "json",
|
|
100
|
+
"x": 850,
|
|
101
|
+
"y": 480,
|
|
102
|
+
"wires": [
|
|
103
|
+
[
|
|
104
|
+
"e12fb3cdb87416ed"
|
|
105
|
+
]
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"id": "017d2569f2c8a046",
|
|
110
|
+
"type": "inject",
|
|
111
|
+
"z": "5ffb0f06dfc7e99e",
|
|
112
|
+
"name": "Enable Edge Icon",
|
|
113
|
+
"props": [
|
|
114
|
+
{
|
|
115
|
+
"p": "payload"
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"repeat": "",
|
|
119
|
+
"crontab": "",
|
|
120
|
+
"once": false,
|
|
121
|
+
"onceDelay": 0.1,
|
|
122
|
+
"topic": "",
|
|
123
|
+
"payload": "{\"command\" : {\"sidcEdgeIcon\" : true}}",
|
|
124
|
+
"payloadType": "json",
|
|
125
|
+
"x": 850,
|
|
126
|
+
"y": 520,
|
|
127
|
+
"wires": [
|
|
128
|
+
[
|
|
129
|
+
"e12fb3cdb87416ed"
|
|
130
|
+
]
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"id": "a6cfecb5747ff649",
|
|
135
|
+
"type": "inject",
|
|
136
|
+
"z": "5ffb0f06dfc7e99e",
|
|
137
|
+
"name": "Error Edge Icon (=1)",
|
|
138
|
+
"props": [
|
|
139
|
+
{
|
|
140
|
+
"p": "payload"
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
"repeat": "",
|
|
144
|
+
"crontab": "",
|
|
145
|
+
"once": false,
|
|
146
|
+
"onceDelay": 0.1,
|
|
147
|
+
"topic": "",
|
|
148
|
+
"payload": "{\"command\" : {\"sidcEdgeIcon\" : 1 }}",
|
|
149
|
+
"payloadType": "json",
|
|
150
|
+
"x": 850,
|
|
151
|
+
"y": 560,
|
|
152
|
+
"wires": [
|
|
153
|
+
[
|
|
154
|
+
"e12fb3cdb87416ed"
|
|
155
|
+
]
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
]
|
|
@@ -10,15 +10,16 @@ algorithm.
|
|
|
10
10
|
|
|
11
11
|
The bezier spline implementation is by [Leszek Rybicki][3].
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### Parameters
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- `options.properties` **[Object][6]** Translate properties to output (optional, default `{}`)
|
|
18
|
-
- `options.resolution` **[number][7]** time in milliseconds between points (optional, default `10000`)
|
|
19
|
-
- `options.sharpness` **[number][7]** a measure of how curvy the path should be between splines (optional, default `0.85`)
|
|
15
|
+
* `line` **[Feature][4]<[LineString][1]>** input LineString
|
|
16
|
+
* `options` **[Object][5]** Optional parameters (optional, default `{}`)
|
|
20
17
|
|
|
21
|
-
**
|
|
18
|
+
* `options.properties` **[Object][5]** Translate properties to output (optional, default `{}`)
|
|
19
|
+
* `options.resolution` **[number][6]** time in milliseconds between points (optional, default `10000`)
|
|
20
|
+
* `options.sharpness` **[number][6]** a measure of how curvy the path should be between splines (optional, default `0.85`)
|
|
21
|
+
|
|
22
|
+
### Examples
|
|
22
23
|
|
|
23
24
|
```javascript
|
|
24
25
|
var line = turf.lineString([
|
|
@@ -37,7 +38,7 @@ var addToMap = [line, curved]
|
|
|
37
38
|
curved.properties = { stroke: '#0F0' };
|
|
38
39
|
```
|
|
39
40
|
|
|
40
|
-
Returns **[Feature][4]
|
|
41
|
+
Returns **[Feature][4]<[LineString][1]>** curved line
|
|
41
42
|
|
|
42
43
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
|
|
43
44
|
|
|
@@ -47,32 +48,25 @@ Returns **[Feature][4]<[LineString][5]>** curved line
|
|
|
47
48
|
|
|
48
49
|
[4]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
49
50
|
|
|
50
|
-
[5]: https://
|
|
51
|
-
|
|
52
|
-
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
51
|
+
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
53
52
|
|
|
54
|
-
[
|
|
53
|
+
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
55
54
|
|
|
56
|
-
<!-- This file is automatically generated. Please don't edit it directly
|
|
57
|
-
if you find an error, edit the source file (likely index.js), and re-run
|
|
58
|
-
./scripts/generate-readmes in the turf project. -->
|
|
55
|
+
<!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
|
|
59
56
|
|
|
60
57
|
---
|
|
61
58
|
|
|
62
|
-
This module is part of the [Turfjs project](
|
|
63
|
-
module collection dedicated to geographic algorithms. It is maintained in the
|
|
64
|
-
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
65
|
-
PRs and issues.
|
|
59
|
+
This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
|
|
66
60
|
|
|
67
61
|
### Installation
|
|
68
62
|
|
|
69
|
-
Install this module individually:
|
|
63
|
+
Install this single module individually:
|
|
70
64
|
|
|
71
65
|
```sh
|
|
72
66
|
$ npm install @turf/bezier-spline
|
|
73
67
|
```
|
|
74
68
|
|
|
75
|
-
Or install the
|
|
69
|
+
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
|
76
70
|
|
|
77
71
|
```sh
|
|
78
72
|
$ npm install @turf/turf
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
2
|
+
var _helpers = require('@turf/helpers');
|
|
3
|
+
var _invariant = require('@turf/invariant');
|
|
4
|
+
|
|
5
|
+
// lib/spline.ts
|
|
6
|
+
var Spline = class {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.points = options.points || [];
|
|
9
|
+
this.duration = options.duration || 1e4;
|
|
10
|
+
this.sharpness = options.sharpness || 0.85;
|
|
11
|
+
this.centers = [];
|
|
12
|
+
this.controls = [];
|
|
13
|
+
this.stepLength = options.stepLength || 60;
|
|
14
|
+
this.length = this.points.length;
|
|
15
|
+
this.delay = 0;
|
|
16
|
+
for (let i = 0; i < this.length; i++) {
|
|
17
|
+
this.points[i].z = this.points[i].z || 0;
|
|
18
|
+
}
|
|
19
|
+
for (let i = 0; i < this.length - 1; i++) {
|
|
20
|
+
const p1 = this.points[i];
|
|
21
|
+
const p2 = this.points[i + 1];
|
|
22
|
+
this.centers.push({
|
|
23
|
+
x: (p1.x + p2.x) / 2,
|
|
24
|
+
y: (p1.y + p2.y) / 2,
|
|
25
|
+
z: (p1.z + p2.z) / 2
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
this.controls.push([this.points[0], this.points[0]]);
|
|
29
|
+
for (let i = 0; i < this.centers.length - 1; i++) {
|
|
30
|
+
const dx = this.points[i + 1].x - (this.centers[i].x + this.centers[i + 1].x) / 2;
|
|
31
|
+
const dy = this.points[i + 1].y - (this.centers[i].y + this.centers[i + 1].y) / 2;
|
|
32
|
+
const dz = this.points[i + 1].z - (this.centers[i].y + this.centers[i + 1].z) / 2;
|
|
33
|
+
this.controls.push([
|
|
34
|
+
{
|
|
35
|
+
x: (1 - this.sharpness) * this.points[i + 1].x + this.sharpness * (this.centers[i].x + dx),
|
|
36
|
+
y: (1 - this.sharpness) * this.points[i + 1].y + this.sharpness * (this.centers[i].y + dy),
|
|
37
|
+
z: (1 - this.sharpness) * this.points[i + 1].z + this.sharpness * (this.centers[i].z + dz)
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
x: (1 - this.sharpness) * this.points[i + 1].x + this.sharpness * (this.centers[i + 1].x + dx),
|
|
41
|
+
y: (1 - this.sharpness) * this.points[i + 1].y + this.sharpness * (this.centers[i + 1].y + dy),
|
|
42
|
+
z: (1 - this.sharpness) * this.points[i + 1].z + this.sharpness * (this.centers[i + 1].z + dz)
|
|
43
|
+
}
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
this.controls.push([
|
|
47
|
+
this.points[this.length - 1],
|
|
48
|
+
this.points[this.length - 1]
|
|
49
|
+
]);
|
|
50
|
+
this.steps = this.cacheSteps(this.stepLength);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Caches an array of equidistant (more or less) points on the curve.
|
|
55
|
+
*/
|
|
56
|
+
cacheSteps(mindist) {
|
|
57
|
+
const steps = [];
|
|
58
|
+
let laststep = this.pos(0);
|
|
59
|
+
steps.push(0);
|
|
60
|
+
for (let t = 0; t < this.duration; t += 10) {
|
|
61
|
+
const step = this.pos(t);
|
|
62
|
+
const dist = Math.sqrt(
|
|
63
|
+
(step.x - laststep.x) * (step.x - laststep.x) + (step.y - laststep.y) * (step.y - laststep.y) + (step.z - laststep.z) * (step.z - laststep.z)
|
|
64
|
+
);
|
|
65
|
+
if (dist > mindist) {
|
|
66
|
+
steps.push(t);
|
|
67
|
+
laststep = step;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return steps;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* returns angle and speed in the given point in the curve
|
|
74
|
+
*/
|
|
75
|
+
vector(t) {
|
|
76
|
+
const p1 = this.pos(t + 10);
|
|
77
|
+
const p2 = this.pos(t - 10);
|
|
78
|
+
return {
|
|
79
|
+
angle: 180 * Math.atan2(p1.y - p2.y, p1.x - p2.x) / 3.14,
|
|
80
|
+
speed: Math.sqrt(
|
|
81
|
+
(p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y) + (p2.z - p1.z) * (p2.z - p1.z)
|
|
82
|
+
)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Gets the position of the point, given time.
|
|
87
|
+
*
|
|
88
|
+
* WARNING: The speed is not constant. The time it takes between control points is constant.
|
|
89
|
+
*
|
|
90
|
+
* For constant speed, use Spline.steps[i];
|
|
91
|
+
*/
|
|
92
|
+
pos(time) {
|
|
93
|
+
let t = time - this.delay;
|
|
94
|
+
if (t < 0) {
|
|
95
|
+
t = 0;
|
|
96
|
+
}
|
|
97
|
+
if (t > this.duration) {
|
|
98
|
+
t = this.duration - 1;
|
|
99
|
+
}
|
|
100
|
+
const t2 = t / this.duration;
|
|
101
|
+
if (t2 >= 1) {
|
|
102
|
+
return this.points[this.length - 1];
|
|
103
|
+
}
|
|
104
|
+
const n = Math.floor((this.points.length - 1) * t2);
|
|
105
|
+
const t1 = (this.length - 1) * t2 - n;
|
|
106
|
+
return bezier(
|
|
107
|
+
t1,
|
|
108
|
+
this.points[n],
|
|
109
|
+
this.controls[n][1],
|
|
110
|
+
this.controls[n + 1][0],
|
|
111
|
+
this.points[n + 1]
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
function bezier(t, p1, c1, c2, p2) {
|
|
116
|
+
const b = B(t);
|
|
117
|
+
const pos = {
|
|
118
|
+
x: p2.x * b[0] + c2.x * b[1] + c1.x * b[2] + p1.x * b[3],
|
|
119
|
+
y: p2.y * b[0] + c2.y * b[1] + c1.y * b[2] + p1.y * b[3],
|
|
120
|
+
z: p2.z * b[0] + c2.z * b[1] + c1.z * b[2] + p1.z * b[3]
|
|
121
|
+
};
|
|
122
|
+
return pos;
|
|
123
|
+
}
|
|
124
|
+
function B(t) {
|
|
125
|
+
const t2 = t * t;
|
|
126
|
+
const t3 = t2 * t;
|
|
127
|
+
return [
|
|
128
|
+
t3,
|
|
129
|
+
3 * t2 * (1 - t),
|
|
130
|
+
3 * t * (1 - t) * (1 - t),
|
|
131
|
+
(1 - t) * (1 - t) * (1 - t)
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// index.ts
|
|
136
|
+
function bezierSpline(line, options = {}) {
|
|
137
|
+
const resolution = options.resolution || 1e4;
|
|
138
|
+
const sharpness = options.sharpness || 0.85;
|
|
139
|
+
const coords = [];
|
|
140
|
+
const points = _invariant.getGeom.call(void 0, line).coordinates.map((pt) => {
|
|
141
|
+
return { x: pt[0], y: pt[1] };
|
|
142
|
+
});
|
|
143
|
+
const spline = new Spline({
|
|
144
|
+
duration: resolution,
|
|
145
|
+
points,
|
|
146
|
+
sharpness
|
|
147
|
+
});
|
|
148
|
+
const pushCoord = (time) => {
|
|
149
|
+
var pos = spline.pos(time);
|
|
150
|
+
if (Math.floor(time / 100) % 2 === 0) {
|
|
151
|
+
coords.push([pos.x, pos.y]);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
for (var i = 0; i < spline.duration; i += 10) {
|
|
155
|
+
pushCoord(i);
|
|
156
|
+
}
|
|
157
|
+
pushCoord(spline.duration);
|
|
158
|
+
return _helpers.lineString.call(void 0, coords, options.properties);
|
|
159
|
+
}
|
|
160
|
+
var turf_bezier_spline_default = bezierSpline;
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
exports.bezierSpline = bezierSpline; exports.default = turf_bezier_spline_default;
|
|
165
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts","../../lib/spline.ts"],"names":[],"mappings":";AACA,SAAS,kBAAkB;AAC3B,S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AED,QAAM,YAAY,CAAC,SAAiB;AAClC,QAAI,MAAM,OAAO,IAAI,IAAI;AACzB,QAAI,KAAK,MAAM,OAAO,GAAG,IAAI,MAAM,GAAG;AACpC,aAAO,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAAA,IAC5B;AAAA,EACF;AAEA,WAAS,IAAI,GAAG,IAAI,OAAO,UAAU,KAAK,IAAI;AAC5C,cAAU,CAAC;AAAA,EACb;AACA,YAAU,OAAO,QAAQ;AAEzB,SAAO,WAAW,QAAQ,QAAQ,UAAU;AAC9C;AAGA,IAAO,6BAAQ","sourcesContent":["import { Feature, LineString, GeoJsonProperties } from \"geojson\";\nimport { lineString } from \"@turf/helpers\";\nimport { getGeom } from \"@turf/invariant\";\nimport { Spline } from \"./lib/spline.js\";\n\n/**\n * Takes a {@link LineString|line} and returns a curved version\n * by applying a [Bezier spline](http://en.wikipedia.org/wiki/B%C3%A9zier_spline)\n * algorithm.\n *\n * The bezier spline implementation is by [Leszek Rybicki](http://leszek.rybicki.cc/).\n *\n * @name bezierSpline\n * @param {Feature<LineString>} line input LineString\n * @param {Object} [options={}] Optional parameters\n * @param {Object} [options.properties={}] Translate properties to output\n * @param {number} [options.resolution=10000] time in milliseconds between points\n * @param {number} [options.sharpness=0.85] a measure of how curvy the path should be between splines\n * @returns {Feature<LineString>} curved line\n * @example\n * var line = turf.lineString([\n * [-76.091308, 18.427501],\n * [-76.695556, 18.729501],\n * [-76.552734, 19.40443],\n * [-74.61914, 19.134789],\n * [-73.652343, 20.07657],\n * [-73.157958, 20.210656]\n * ]);\n *\n * var curved = turf.bezierSpline(line);\n *\n * //addToMap\n * var addToMap = [line, curved]\n * curved.properties = { stroke: '#0F0' };\n */\nfunction bezierSpline<P extends GeoJsonProperties = GeoJsonProperties>(\n line: Feature<LineString> | LineString,\n options: {\n properties?: P;\n resolution?: number;\n sharpness?: number;\n } = {}\n): Feature<LineString, P> {\n // Optional params\n const resolution = options.resolution || 10000;\n const sharpness = options.sharpness || 0.85;\n\n const coords: [number, number][] = [];\n const points = getGeom(line).coordinates.map((pt) => {\n return { x: pt[0], y: pt[1] };\n });\n const spline = new Spline({\n duration: resolution,\n points,\n sharpness,\n });\n\n const pushCoord = (time: number) => {\n var pos = spline.pos(time);\n if (Math.floor(time / 100) % 2 === 0) {\n coords.push([pos.x, pos.y]);\n }\n };\n\n for (var i = 0; i < spline.duration; i += 10) {\n pushCoord(i);\n }\n pushCoord(spline.duration);\n\n return lineString(coords, options.properties);\n}\n\nexport { bezierSpline };\nexport default bezierSpline;\n","interface Point {\n x: number;\n y: number;\n z: number;\n}\n\n/**\n * BezierSpline\n * https://github.com/leszekr/bezier-spline-js\n *\n * @private\n * @copyright\n * Copyright (c) 2013 Leszek Rybicki\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nclass Spline {\n public duration: number;\n public points: Point[];\n public sharpness: number;\n public centers: Point[];\n public controls: Array<[Point, Point]>;\n public stepLength: number;\n public length: number;\n public delay: number;\n public steps: number[];\n\n constructor(options?: any) {\n this.points = options.points || [];\n this.duration = options.duration || 10000;\n this.sharpness = options.sharpness || 0.85;\n this.centers = [];\n this.controls = [];\n this.stepLength = options.stepLength || 60;\n this.length = this.points.length;\n this.delay = 0;\n\n // this is to ensure compatibility with the 2d version\n for (let i = 0; i < this.length; i++) {\n this.points[i].z = this.points[i].z || 0;\n }\n for (let i = 0; i < this.length - 1; i++) {\n const p1 = this.points[i];\n const p2 = this.points[i + 1];\n this.centers.push({\n x: (p1.x + p2.x) / 2,\n y: (p1.y + p2.y) / 2,\n z: (p1.z + p2.z) / 2,\n });\n }\n this.controls.push([this.points[0], this.points[0]]);\n for (let i = 0; i < this.centers.length - 1; i++) {\n const dx =\n this.points[i + 1].x - (this.centers[i].x + this.centers[i + 1].x) / 2;\n const dy =\n this.points[i + 1].y - (this.centers[i].y + this.centers[i + 1].y) / 2;\n const dz =\n this.points[i + 1].z - (this.centers[i].y + this.centers[i + 1].z) / 2;\n this.controls.push([\n {\n x:\n (1.0 - this.sharpness) * this.points[i + 1].x +\n this.sharpness * (this.centers[i].x + dx),\n y:\n (1.0 - this.sharpness) * this.points[i + 1].y +\n this.sharpness * (this.centers[i].y + dy),\n z:\n (1.0 - this.sharpness) * this.points[i + 1].z +\n this.sharpness * (this.centers[i].z + dz),\n },\n {\n x:\n (1.0 - this.sharpness) * this.points[i + 1].x +\n this.sharpness * (this.centers[i + 1].x + dx),\n y:\n (1.0 - this.sharpness) * this.points[i + 1].y +\n this.sharpness * (this.centers[i + 1].y + dy),\n z:\n (1.0 - this.sharpness) * this.points[i + 1].z +\n this.sharpness * (this.centers[i + 1].z + dz),\n },\n ]);\n }\n this.controls.push([\n this.points[this.length - 1],\n this.points[this.length - 1],\n ]);\n this.steps = this.cacheSteps(this.stepLength);\n return this;\n }\n /**\n * Caches an array of equidistant (more or less) points on the curve.\n */\n public cacheSteps(mindist: number) {\n const steps = [];\n let laststep = this.pos(0);\n steps.push(0);\n for (let t = 0; t < this.duration; t += 10) {\n const step = this.pos(t);\n const dist = Math.sqrt(\n (step.x - laststep.x) * (step.x - laststep.x) +\n (step.y - laststep.y) * (step.y - laststep.y) +\n (step.z - laststep.z) * (step.z - laststep.z)\n );\n if (dist > mindist) {\n steps.push(t);\n laststep = step;\n }\n }\n return steps;\n }\n\n /**\n * returns angle and speed in the given point in the curve\n */\n public vector(t: number) {\n const p1 = this.pos(t + 10);\n const p2 = this.pos(t - 10);\n return {\n angle: (180 * Math.atan2(p1.y - p2.y, p1.x - p2.x)) / 3.14,\n speed: Math.sqrt(\n (p2.x - p1.x) * (p2.x - p1.x) +\n (p2.y - p1.y) * (p2.y - p1.y) +\n (p2.z - p1.z) * (p2.z - p1.z)\n ),\n };\n }\n\n /**\n * Gets the position of the point, given time.\n *\n * WARNING: The speed is not constant. The time it takes between control points is constant.\n *\n * For constant speed, use Spline.steps[i];\n */\n public pos(time: number) {\n let t = time - this.delay;\n if (t < 0) {\n t = 0;\n }\n if (t > this.duration) {\n t = this.duration - 1;\n }\n // t = t-this.delay;\n const t2 = t / this.duration;\n if (t2 >= 1) {\n return this.points[this.length - 1];\n }\n\n const n = Math.floor((this.points.length - 1) * t2);\n const t1 = (this.length - 1) * t2 - n;\n return bezier(\n t1,\n this.points[n],\n this.controls[n][1],\n this.controls[n + 1][0],\n this.points[n + 1]\n );\n }\n}\n\nfunction bezier(t: number, p1: Point, c1: Point, c2: Point, p2: Point) {\n const b = B(t);\n const pos = {\n x: p2.x * b[0] + c2.x * b[1] + c1.x * b[2] + p1.x * b[3],\n y: p2.y * b[0] + c2.y * b[1] + c1.y * b[2] + p1.y * b[3],\n z: p2.z * b[0] + c2.z * b[1] + c1.z * b[2] + p1.z * b[3],\n };\n return pos;\n}\nfunction B(t: number) {\n const t2 = t * t;\n const t3 = t2 * t;\n return [\n t3,\n 3 * t2 * (1 - t),\n 3 * t * (1 - t) * (1 - t),\n (1 - t) * (1 - t) * (1 - t),\n ];\n}\n\nexport { Spline, Point };\nexport default Spline;\n"]}
|