@raruto/leaflet-elevation 2.6.1 → 2.7.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.
@@ -1,79 +1,79 @@
1
- export function Slope() {
2
-
3
- const _ = L.Control.Elevation.Utils;
4
-
5
- let opts = this.options;
6
- let slope = {};
7
-
8
- slope.label = opts.slopeLabel || '%';
9
-
10
- return {
11
- name: 'slope',
12
- meta: 'slope',
13
- unit: slope.label,
14
- deltaMax: this.options.slopedDeltaMax,
15
- clampRange: this.options.slopeRange,
16
- decimals: 2,
17
- pointToAttr: (_, i) => { // slope in % = ( dy / dx ) * 100;
18
- let dx = (this._data[i].dist - this._data[i > 0 ? i - 1 : i].dist) * 1000;
19
- let dy = this._data[i][this.options.yAttr] - this._data[i > 0 ? i - 1 : i][this.options.yAttr];
20
- return dx !== 0 ? (dy / dx) * 100 : NaN;
21
- },
22
- onPointAdded: (_, i) => {
23
- let dz = this._data[i][this.options.yAttr] - this._data[i > 0 ? i - 1 : i][this.options.yAttr];
24
- if (dz > 0) this.track_info.ascent = (this.track_info.ascent || 0) + dz; // Total Ascent
25
- else if (dz < 0) this.track_info.descent = (this.track_info.descent || 0) - dz; // Total Descent
26
- },
27
- stats: { max: _.iMax, min: _.iMin, avg: _.iAvg, },
28
- scale: {
29
- axis : "y",
30
- position : "right",
31
- scale : { min: -1, max: +1 },
32
- tickPadding: 16,
33
- labelX : 25,
34
- labelY : -8,
35
- },
36
- path: {
37
- label : 'Slope',
38
- yAttr : 'slope',
39
- scaleX : 'distance',
40
- scaleY : 'slope',
41
- color : '#F00',
42
- strokeColor : '#000',
43
- strokeOpacity: "0.5",
44
- fillOpacity : "0.25",
45
- },
46
- tooltip: {
47
- chart: (item) => L._("m: ") + item.slope + slope.label,
48
- marker: (item) => Math.round(item.slope) + slope.label,
49
- order: 40,
50
- },
51
- summary: {
52
- "minslope": {
53
- label: "Min Slope: ",
54
- value: (track, unit) => Math.round(track.slope_min || 0) + '&nbsp;' + unit,
55
- order: 40
56
- },
57
- "maxslope": {
58
- label: "Max Slope: ",
59
- value: (track, unit) => Math.round(track.slope_max || 0) + '&nbsp;' + unit,
60
- order: 41
61
- },
62
- "avgslope": {
63
- label: "Avg Slope: ",
64
- value: (track, unit) => Math.round(track.slope_avg || 0) + '&nbsp;' + unit,
65
- order: 42
66
- },
67
- "ascent" : {
68
- label: "Total Ascent: ",
69
- value: (track, unit) => Math.round(track.ascent || 0) + '&nbsp;' + (this.options.imperial ? 'ft' : 'm'),
70
- order: 43
71
- },
72
- "descent" : {
73
- label: "Total Descent: ",
74
- value: (track, unit) => Math.round(track.descent || 0) + '&nbsp;' + (this.options.imperial ? 'ft' : 'm'),
75
- order: 45
76
- },
77
- }
78
- };
79
- }
1
+ export function Slope() {
2
+
3
+ const _ = L.Control.Elevation.Utils;
4
+
5
+ let opts = this.options;
6
+ let slope = {};
7
+
8
+ slope.label = opts.slopeLabel || '%';
9
+
10
+ return {
11
+ name: 'slope',
12
+ meta: 'slope',
13
+ unit: slope.label,
14
+ deltaMax: this.options.slopedDeltaMax,
15
+ clampRange: this.options.slopeRange,
16
+ decimals: 2,
17
+ pointToAttr: (_, i) => { // slope in % = ( dy / dx ) * 100;
18
+ let dx = (this._data[i].dist - this._data[i > 0 ? i - 1 : i].dist) * 1000;
19
+ let dy = this._data[i][this.options.yAttr] - this._data[i > 0 ? i - 1 : i][this.options.yAttr];
20
+ return dx !== 0 ? (dy / dx) * 100 : NaN;
21
+ },
22
+ onPointAdded: (_, i) => {
23
+ let dz = this._data[i][this.options.yAttr] - this._data[i > 0 ? i - 1 : i][this.options.yAttr];
24
+ if (dz > 0) this.track_info.ascent = (this.track_info.ascent || 0) + dz; // Total Ascent
25
+ else if (dz < 0) this.track_info.descent = (this.track_info.descent || 0) - dz; // Total Descent
26
+ },
27
+ stats: { max: _.iMax, min: _.iMin, avg: _.iAvg, },
28
+ scale: {
29
+ axis : "y",
30
+ position : "right",
31
+ scale : { min: -1, max: +1 },
32
+ tickPadding: 16,
33
+ labelX : 25,
34
+ labelY : -8,
35
+ },
36
+ path: {
37
+ label : 'Slope',
38
+ yAttr : 'slope',
39
+ scaleX : 'distance',
40
+ scaleY : 'slope',
41
+ color : '#F00',
42
+ strokeColor : '#000',
43
+ strokeOpacity: "0.5",
44
+ fillOpacity : "0.25",
45
+ },
46
+ tooltip: {
47
+ chart: (item) => L._("m: ") + item.slope + slope.label,
48
+ marker: (item) => Math.round(item.slope) + slope.label,
49
+ order: 40,
50
+ },
51
+ summary: {
52
+ "minslope": {
53
+ label: "Min Slope: ",
54
+ value: (track, unit) => Math.round(track.slope_min || 0) + '&nbsp;' + unit,
55
+ order: 40
56
+ },
57
+ "maxslope": {
58
+ label: "Max Slope: ",
59
+ value: (track, unit) => Math.round(track.slope_max || 0) + '&nbsp;' + unit,
60
+ order: 41
61
+ },
62
+ "avgslope": {
63
+ label: "Avg Slope: ",
64
+ value: (track, unit) => Math.round(track.slope_avg || 0) + '&nbsp;' + unit,
65
+ order: 42
66
+ },
67
+ "ascent" : {
68
+ label: "Total Ascent: ",
69
+ value: (track, unit) => Math.round(track.ascent || 0) + '&nbsp;' + (this.options.imperial ? 'ft' : 'm'),
70
+ order: 43
71
+ },
72
+ "descent" : {
73
+ label: "Total Descent: ",
74
+ value: (track, unit) => Math.round(track.descent || 0) + '&nbsp;' + (this.options.imperial ? 'ft' : 'm'),
75
+ order: 45
76
+ },
77
+ }
78
+ };
79
+ }
@@ -1,66 +1,66 @@
1
- export function Speed() {
2
-
3
- const _ = L.Control.Elevation.Utils;
4
-
5
- let opts = this.options;
6
- let speed = {};
7
-
8
- speed.label = opts.speedLabel || L._(opts.imperial ? 'mph' : 'km/h');
9
- opts.speedFactor = opts.speedFactor || 1;
10
-
11
- return {
12
- name: 'speed',
13
- required: (this.options.acceleration),
14
- unit: speed.label,
15
- deltaMax: this.options.speedDeltaMax,
16
- clampRange: this.options.speedRange,
17
- decimals: 2,
18
- pointToAttr: (_, i) => {
19
- let dx = (this._data[i].dist - this._data[i > 0 ? i - 1 : i].dist) * 1000;
20
- let dt = this._data[i].time - this._data[ i > 0 ? i - 1 : i].time;
21
- return dt > 0 ? Math.abs((dx / dt) * opts.timeFactor) * opts.speedFactor : NaN;
22
- },
23
- stats: { max: _.iMax, min: _.iMin, avg: _.iAvg },
24
- scale : (this.options.speed && this.options.speed != "summary") && {
25
- axis : "y",
26
- position : "right",
27
- scale : { min : 0, max : +1 },
28
- tickPadding: 16,
29
- labelX : 25,
30
- labelY : -8,
31
- },
32
- path: (this.options.speed && this.options.speed != "summary") && {
33
- // name : 'speed',
34
- label : 'Speed',
35
- yAttr : "speed",
36
- scaleX : 'distance',
37
- scaleY : 'speed',
38
- color : '#03ffff',
39
- strokeColor : '#000',
40
- strokeOpacity: "0.5",
41
- fillOpacity : "0.25",
42
- },
43
- tooltip: (this.options.speed) && {
44
- chart: (item) => L._('v: ') + item.speed + " " + speed.label,
45
- marker: (item) => Math.round(item.speed) + " " + speed.label,
46
- order: 50,
47
- },
48
- summary: (this.options.speed) && {
49
- "minspeed" : {
50
- label: "Min Speed: ",
51
- value: (track, unit) => Math.round(track.speed_min || 0) + '&nbsp;' + unit,
52
- order: 51
53
- },
54
- "maxspeed" : {
55
- label: "Max Speed: ",
56
- value: (track, unit) => Math.round(track.speed_max || 0) + '&nbsp;' + unit,
57
- order: 51
58
- },
59
- "avgspeed": {
60
- label: "Avg Speed: ",
61
- value: (track, unit) => Math.round(track.speed_avg || 0) + '&nbsp;' + unit,
62
- order: 52
63
- },
64
- }
65
- };
66
- }
1
+ export function Speed() {
2
+
3
+ const _ = L.Control.Elevation.Utils;
4
+
5
+ let opts = this.options;
6
+ let speed = {};
7
+
8
+ speed.label = opts.speedLabel || L._(opts.imperial ? 'mph' : 'km/h');
9
+ opts.speedFactor = opts.speedFactor || 1;
10
+
11
+ return {
12
+ name: 'speed',
13
+ required: (this.options.acceleration),
14
+ unit: speed.label,
15
+ deltaMax: this.options.speedDeltaMax,
16
+ clampRange: this.options.speedRange,
17
+ decimals: 2,
18
+ pointToAttr: (_, i) => {
19
+ let dx = (this._data[i].dist - this._data[i > 0 ? i - 1 : i].dist) * 1000;
20
+ let dt = this._data[i].time - this._data[ i > 0 ? i - 1 : i].time;
21
+ return dt > 0 ? Math.abs((dx / dt) * opts.timeFactor) * opts.speedFactor : NaN;
22
+ },
23
+ stats: { max: _.iMax, min: _.iMin, avg: _.iAvg },
24
+ scale : (this.options.speed && this.options.speed != "summary") && {
25
+ axis : "y",
26
+ position : "right",
27
+ scale : { min : 0, max : +1 },
28
+ tickPadding: 16,
29
+ labelX : 25,
30
+ labelY : -8,
31
+ },
32
+ path: (this.options.speed && this.options.speed != "summary") && {
33
+ // name : 'speed',
34
+ label : 'Speed',
35
+ yAttr : "speed",
36
+ scaleX : 'distance',
37
+ scaleY : 'speed',
38
+ color : '#03ffff',
39
+ strokeColor : '#000',
40
+ strokeOpacity: "0.5",
41
+ fillOpacity : "0.25",
42
+ },
43
+ tooltip: (this.options.speed) && {
44
+ chart: (item) => L._('v: ') + item.speed + " " + speed.label,
45
+ marker: (item) => Math.round(item.speed) + " " + speed.label,
46
+ order: 50,
47
+ },
48
+ summary: (this.options.speed) && {
49
+ "minspeed" : {
50
+ label: "Min Speed: ",
51
+ value: (track, unit) => Math.round(track.speed_min || 0) + '&nbsp;' + unit,
52
+ order: 51
53
+ },
54
+ "maxspeed" : {
55
+ label: "Max Speed: ",
56
+ value: (track, unit) => Math.round(track.speed_max || 0) + '&nbsp;' + unit,
57
+ order: 51
58
+ },
59
+ "avgspeed": {
60
+ label: "Avg Speed: ",
61
+ value: (track, unit) => Math.round(track.speed_avg || 0) + '&nbsp;' + unit,
62
+ order: 52
63
+ },
64
+ }
65
+ };
66
+ }