@raruto/leaflet-elevation 2.2.4 → 2.2.5

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 Altitude() {
2
-
3
- const _ = L.Control.Elevation.Utils;
4
-
5
- let opts = this.options;
6
- let altitude = {};
7
-
8
- let theme = opts.theme.split(' ')[0].replace('-theme', '');
9
- let color = _.Colors[theme] || {};
10
-
11
- opts.altitudeFactor = opts.imperial ? this.__footFactor : (opts.altitudeFactor || 1); // 1 m = (1 m)
12
- altitude.label = opts.imperial ? "ft" : opts.yLabel;
13
-
14
- return {
15
- name: 'altitude',
16
- required: this.options.slope,
17
- meta: 'z',
18
- unit: altitude.label,
19
- statsName: 'elevation',
20
- skipNull: this.options.skipNullZCoords,
21
- deltaMax: this.options.altitudeDeltaMax,
22
- clampRange: this.options.altitudeRange,
23
- // init: ({point}) => {
24
- // // "alt" property is generated inside "leaflet"
25
- // if ("alt" in point) point.meta.ele = point.alt;
26
- // },
27
- pointToAttr: (point, i) => {
28
- if ("alt" in point) point.meta.ele = point.alt; // "alt" property is generated inside "leaflet"
29
- return this._data[i].z * opts.altitudeFactor;
30
- },
31
- stats: { max: _.iMax, min: _.iMin, avg: _.iAvg },
32
- grid: {
33
- axis : "y",
34
- position : "left",
35
- scale : "y" // this._chart._y,
36
- },
37
- scale: {
38
- axis : "y",
39
- position: "left",
40
- scale : "y", // this._chart._y,
41
- labelX : -3,
42
- labelY : -8,
43
- },
44
- path: {
45
- label : 'Altitude',
46
- scaleX : 'distance',
47
- scaleY : 'altitude',
48
- className : 'area',
49
- color : color.area || theme,
50
- strokeColor : opts.detached ? color.stroke : '#000',
51
- strokeOpacity: "1",
52
- fillOpacity : opts.detached ? (color.alpha || '0.8') : 1,
53
- preferCanvas : opts.preferCanvas,
54
- },
55
- tooltip: {
56
- name: 'y',
57
- chart: (item) => L._("y: ") + _.round(item[opts.yAttr], opts.decimalsY) + " " + altitude.label,
58
- marker: (item) => _.round(item[opts.yAttr], opts.decimalsY) + " " + altitude.label,
59
- order: 10,
60
- },
61
- summary: {
62
- "minele" : {
63
- label: "Min Elevation: ",
64
- value: (track, unit) => (track.elevation_min || 0).toFixed(2) + ' ' + unit,
65
- order: 30,
66
- },
67
- "maxele" : {
68
- label: "Max Elevation: ",
69
- value: (track, unit) => (track.elevation_max || 0).toFixed(2) + ' ' + unit,
70
- order: 31,
71
- },
72
- "avgele" : {
73
- label: "Avg Elevation: ",
74
- value: (track, unit) => (track.elevation_avg || 0).toFixed(2) + ' ' + unit,
75
- order: 32,
76
- },
77
- }
78
- };
79
- }
1
+ export function Altitude() {
2
+
3
+ const _ = L.Control.Elevation.Utils;
4
+
5
+ let opts = this.options;
6
+ let altitude = {};
7
+
8
+ let theme = opts.theme.split(' ')[0].replace('-theme', '');
9
+ let color = _.Colors[theme] || {};
10
+
11
+ opts.altitudeFactor = opts.imperial ? this.__footFactor : (opts.altitudeFactor || 1); // 1 m = (1 m)
12
+ altitude.label = opts.imperial ? "ft" : opts.yLabel;
13
+
14
+ return {
15
+ name: 'altitude',
16
+ required: this.options.slope,
17
+ meta: 'z',
18
+ unit: altitude.label,
19
+ statsName: 'elevation',
20
+ skipNull: this.options.skipNullZCoords,
21
+ deltaMax: this.options.altitudeDeltaMax,
22
+ clampRange: this.options.altitudeRange,
23
+ // init: ({point}) => {
24
+ // // "alt" property is generated inside "leaflet"
25
+ // if ("alt" in point) point.meta.ele = point.alt;
26
+ // },
27
+ pointToAttr: (point, i) => {
28
+ if ("alt" in point) point.meta.ele = point.alt; // "alt" property is generated inside "leaflet"
29
+ return this._data[i].z *= opts.altitudeFactor;
30
+ },
31
+ stats: { max: _.iMax, min: _.iMin, avg: _.iAvg },
32
+ grid: {
33
+ axis : "y",
34
+ position : "left",
35
+ scale : "y" // this._chart._y,
36
+ },
37
+ scale: {
38
+ axis : "y",
39
+ position: "left",
40
+ scale : "y", // this._chart._y,
41
+ labelX : -3,
42
+ labelY : -8,
43
+ },
44
+ path: {
45
+ label : 'Altitude',
46
+ scaleX : 'distance',
47
+ scaleY : 'altitude',
48
+ className : 'area',
49
+ color : color.area || theme,
50
+ strokeColor : opts.detached ? color.stroke : '#000',
51
+ strokeOpacity: "1",
52
+ fillOpacity : opts.detached ? (color.alpha || '0.8') : 1,
53
+ preferCanvas : opts.preferCanvas,
54
+ },
55
+ tooltip: {
56
+ name: 'y',
57
+ chart: (item) => L._("y: ") + _.round(item[opts.yAttr], opts.decimalsY) + " " + altitude.label,
58
+ marker: (item) => _.round(item[opts.yAttr], opts.decimalsY) + " " + altitude.label,
59
+ order: 10,
60
+ },
61
+ summary: {
62
+ "minele" : {
63
+ label: "Min Elevation: ",
64
+ value: (track, unit) => (track.elevation_min || 0).toFixed(2) + ' ' + unit,
65
+ order: 30,
66
+ },
67
+ "maxele" : {
68
+ label: "Max Elevation: ",
69
+ value: (track, unit) => (track.elevation_max || 0).toFixed(2) + ' ' + unit,
70
+ order: 31,
71
+ },
72
+ "avgele" : {
73
+ label: "Avg Elevation: ",
74
+ value: (track, unit) => (track.elevation_avg || 0).toFixed(2) + ' ' + unit,
75
+ order: 32,
76
+ },
77
+ }
78
+ };
79
+ }
@@ -1,45 +1,46 @@
1
- export function Distance() {
2
-
3
- const _ = L.Control.Elevation.Utils;
4
-
5
- let opts = this.options;
6
- let distance = {};
7
-
8
- opts.distanceFactor = opts.imperial ? this.__mileFactor : (opts.distanceFactor || 1); // 1 km = (1000 m)
9
- distance.label = opts.imperial ? "mi" : opts.xLabel;
10
-
11
- return {
12
- name: 'distance',
13
- attr: 'dist',
14
- unit: distance.label,
15
- decimals: 5,
16
- pointToAttr: (_, i) => (i > 0 ? this._data[i - 1].dist : 0) + (this._data[i].latlng.distanceTo(this._data[i > 0 ? i - 1 : i].latlng) * opts.distanceFactor) / 1000, // convert back km to meters
17
- // stats: { total: _.iSum },
18
- onPointAdded: (distance, i) => this.track_info.distance = distance,
19
- scale: {
20
- axis : "x",
21
- position: "bottom",
22
- scale : "x", // this._chart._x,
23
- labelY : 25,
24
- labelX : () => this._width() + 6,
25
- ticks : () => _.clamp(this._chart._xTicks() / 2, [4, +Infinity]),
26
- },
27
- grid: {
28
- axis : "x",
29
- position : "bottom",
30
- scale : "x" // this._chart._x,
31
- },
32
- tooltip: {
33
- name: 'x',
34
- chart: (item) => L._("x: ") + _.round(item[opts.xAttr], opts.decimalsX) + " " + distance.label,
35
- order: 20
36
- },
37
- summary: {
38
- "totlen" : {
39
- label: "Total Length: ",
40
- value: (track) => (track.distance || 0).toFixed(2) + ' ' + distance.label,
41
- order: 10
42
- }
43
- }
44
- };
45
- }
1
+ export function Distance() {
2
+
3
+ const _ = L.Control.Elevation.Utils;
4
+
5
+ let opts = this.options;
6
+ let distance = {};
7
+
8
+ opts.distanceFactor = opts.imperial ? this.__mileFactor : (opts.distanceFactor || 1); // 1 km = (1000 m)
9
+ distance.label = opts.imperial ? "mi" : opts.xLabel;
10
+
11
+ return {
12
+ name: 'distance',
13
+ required: true,
14
+ attr: 'dist',
15
+ unit: distance.label,
16
+ decimals: 5,
17
+ pointToAttr: (_, i) => (i > 0 ? this._data[i - 1].dist : 0) + (this._data[i].latlng.distanceTo(this._data[i > 0 ? i - 1 : i].latlng) * opts.distanceFactor) / 1000, // convert back km to meters
18
+ // stats: { total: _.iSum },
19
+ onPointAdded: (distance, i) => this.track_info.distance = distance,
20
+ scale: opts.distance && {
21
+ axis : "x",
22
+ position: "bottom",
23
+ scale : "x", // this._chart._x,
24
+ labelY : 25,
25
+ labelX : () => this._width() + 6,
26
+ ticks : () => _.clamp(this._chart._xTicks() / 2, [4, +Infinity]),
27
+ },
28
+ grid: opts.distance && {
29
+ axis : "x",
30
+ position : "bottom",
31
+ scale : "x" // this._chart._x,
32
+ },
33
+ tooltip: opts.distance && {
34
+ name: 'x',
35
+ chart: (item) => L._("x: ") + _.round(item[opts.xAttr], opts.decimalsX) + " " + distance.label,
36
+ order: 20
37
+ },
38
+ summary: opts.distance && {
39
+ "totlen" : {
40
+ label: "Total Length: ",
41
+ value: (track) => (track.distance || 0).toFixed(2) + ' ' + distance.label,
42
+ order: 10
43
+ }
44
+ }
45
+ };
46
+ }