add bezier smoothing to tracks
This commit is contained in:
parent
2d2ef08ce2
commit
1934c7ccbe
@ -1,5 +1,6 @@
|
|||||||
### Change Log for Node-RED Worldmap
|
### Change Log for Node-RED Worldmap
|
||||||
|
|
||||||
|
- v2.11.0 - Add option to smooth tracks using bezier curves.
|
||||||
- v2.10.0 - Save latest position to browser for refresh if in iframe/dashboard. Allow fractional Zoom levels.
|
- v2.10.0 - Save latest position to browser for refresh if in iframe/dashboard. Allow fractional Zoom levels.
|
||||||
- v2.9.0 - Let weblinks be an array of links. Add more info to readme about Mapservers.
|
- v2.9.0 - Let weblinks be an array of links. Add more info to readme about Mapservers.
|
||||||
- v2.8.9 - Only load cgi module if we have a local mapserv file
|
- v2.8.9 - Only load cgi module if we have a local mapserv file
|
||||||
|
@ -11,6 +11,7 @@ map web page for plotting "things" on.
|
|||||||
|
|
||||||
### Updates
|
### Updates
|
||||||
|
|
||||||
|
- v2.11.0 - Add option to smooth tracks using bezier curves.
|
||||||
- v2.10.0 - Save latest position to browser for refresh if in iframe/dashboard. Allow fractional Zoom levels.
|
- v2.10.0 - Save latest position to browser for refresh if in iframe/dashboard. Allow fractional Zoom levels.
|
||||||
- v2.9.0 - Let weblinks be an array of links. Add more info to readme about Mapservers.
|
- v2.9.0 - Let weblinks be an array of links. Add more info to readme about Mapservers.
|
||||||
- v2.8.9 - Only load cgi module if we have a local mapserv file.
|
- v2.8.9 - Only load cgi module if we have a local mapserv file.
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-contrib-web-worldmap",
|
"name": "node-red-contrib-web-worldmap",
|
||||||
"version": "2.10.0",
|
"version": "2.11.0",
|
||||||
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
|
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cgi": "0.3.1",
|
"cgi": "0.3.1",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
"sockjs": "~0.3.21"
|
"sockjs": "~0.3.21",
|
||||||
|
"@turf/bezier-spline": "*"
|
||||||
},
|
},
|
||||||
"bundledDependencies": [
|
"bundledDependencies": [
|
||||||
"cgi",
|
"cgi",
|
||||||
|
@ -528,6 +528,11 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
|
|||||||
<option value="single">single Track layer</option>
|
<option value="single">single Track layer</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label> </label>
|
||||||
|
<input type="checkbox" id="node-input-smooth" style="display:inline-block; width:auto; vertical-align:top;">
|
||||||
|
<label for="node-input-smooth" style="width:70%;">Smooth tracks using bezier curves.</label>
|
||||||
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="fa fa-file"></i> Name</label>
|
<label for="node-input-name"><i class="fa fa-file"></i> Name</label>
|
||||||
<input type="text" id="node-input-name" placeholder="name">
|
<input type="text" id="node-input-name" placeholder="name">
|
||||||
@ -553,7 +558,8 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
|
|||||||
defaults: {
|
defaults: {
|
||||||
name: {value:""},
|
name: {value:""},
|
||||||
depth: {value:20},
|
depth: {value:20},
|
||||||
layer: {value:"combined"}
|
layer: {value:"combined"},
|
||||||
|
smooth: {value:false}
|
||||||
},
|
},
|
||||||
inputs:1,
|
inputs:1,
|
||||||
outputs:1,
|
outputs:1,
|
||||||
|
@ -273,7 +273,9 @@ module.exports = function(RED) {
|
|||||||
this.depth = parseInt(Number(n.depth) || 20);
|
this.depth = parseInt(Number(n.depth) || 20);
|
||||||
this.pointsarray = {};
|
this.pointsarray = {};
|
||||||
this.layer = n.layer || "combined"; // separate, single
|
this.layer = n.layer || "combined"; // separate, single
|
||||||
|
this.smooth = n.smooth || false;
|
||||||
var node = this;
|
var node = this;
|
||||||
|
var bezierSpline = require("@turf/bezier-spline").default;
|
||||||
|
|
||||||
var doTrack = function(msg) {
|
var doTrack = function(msg) {
|
||||||
if (msg.hasOwnProperty("payload") && msg.payload.hasOwnProperty("name")) {
|
if (msg.hasOwnProperty("payload") && msg.payload.hasOwnProperty("name")) {
|
||||||
@ -335,7 +337,13 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (line.length > 1) { // only send track if two points or more
|
if (line.length > 1) { // only send track if two points or more
|
||||||
|
if (node.smooth) {
|
||||||
|
var curved = bezierSpline({"type":"Feature", "properties":{}, "geometry":{"type":"LineString", "coordinates":line }});
|
||||||
|
newmsg.payload.line = curved.geometry.coordinates;
|
||||||
|
}
|
||||||
|
else {
|
||||||
newmsg.payload.line = line;
|
newmsg.payload.line = line;
|
||||||
|
}
|
||||||
newmsg.payload.name = msg.payload.name + "_";
|
newmsg.payload.name = msg.payload.name + "_";
|
||||||
if (node.layer === "separate") {
|
if (node.layer === "separate") {
|
||||||
newmsg.payload.layer = msg.payload.layer + " tracks";
|
newmsg.payload.layer = msg.payload.layer + " tracks";
|
||||||
|
Loading…
Reference in New Issue
Block a user