@raruto/leaflet-elevation 2.2.5 → 2.2.6
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/LICENSE +674 -674
- package/dist/leaflet-elevation.css +337 -337
- package/dist/leaflet-elevation.js +281 -280
- package/dist/leaflet-elevation.js.map +1 -1
- package/dist/leaflet-elevation.min.js +1 -1
- package/dist/leaflet-elevation.min.js.map +1 -1
- package/images/elevation-position.svg +1 -1
- package/images/elevation-pushpin.svg +1 -1
- package/images/elevation.svg +1 -1
- package/libs/leaflet-distance-marker.css +8 -8
- package/libs/leaflet-distance-marker.js +314 -314
- package/package.json +71 -71
- package/src/components/chart.js +783 -783
- package/src/components/d3.js +641 -641
- package/src/components/marker.js +96 -96
- package/src/components/summary.js +43 -43
- package/src/control.js +3 -2
- package/src/handlers/acceleration.js +64 -64
- package/src/handlers/heart.js +52 -52
- package/src/handlers/pace.js +65 -65
- package/src/handlers/slope.js +79 -79
- package/src/handlers/speed.js +66 -66
- package/src/handlers/time.js +102 -102
- package/src/index.css +329 -329
- package/src/index.js +42 -42
- package/src/options.js +85 -85
- package/src/utils.js +158 -158
package/src/components/marker.js
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import * as D3 from './d3.js';
|
|
2
|
-
|
|
3
|
-
const _ = L.Control.Elevation.Utils;
|
|
4
|
-
|
|
5
|
-
export var Marker = L.Class.extend({
|
|
6
|
-
|
|
7
|
-
initialize: function(options, control) {
|
|
8
|
-
this.options = options;
|
|
9
|
-
this.control = control
|
|
10
|
-
|
|
11
|
-
switch(this.options.marker) {
|
|
12
|
-
case 'elevation-line':
|
|
13
|
-
// this._container = d3.create("g").attr("class", "height-focus-group");
|
|
14
|
-
break;
|
|
15
|
-
case 'position-marker':
|
|
16
|
-
// this._marker = L.circleMarker([0, 0], { pane: 'overlayPane', radius: 6, fillColor: '#fff', fillOpacity:1, color: '#000', weight:1, interactive: false });
|
|
17
|
-
this._marker = L.marker([0, 0], { icon: this.options.markerIcon, zIndexOffset: 1000000, interactive: false });
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
this._labels = {};
|
|
22
|
-
|
|
23
|
-
return this;
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
addTo: function(map) {
|
|
27
|
-
this._map = map;
|
|
28
|
-
switch(this.options.marker) {
|
|
29
|
-
case 'elevation-line': this._container = d3.select(map.getPane('elevationPane')).select("svg > g").call(D3.PositionMarker({})); break;
|
|
30
|
-
case 'position-marker': this._marker.addTo(map, { pane: 'overlayPane' }); break;
|
|
31
|
-
}
|
|
32
|
-
return this;
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Update position marker ("leaflet-marker").
|
|
37
|
-
*/
|
|
38
|
-
update: function(props) {
|
|
39
|
-
if (props) this._props = props;
|
|
40
|
-
else props = this._props;
|
|
41
|
-
|
|
42
|
-
if(!props) return;
|
|
43
|
-
|
|
44
|
-
if (props.options) this.options = props.options;
|
|
45
|
-
if (!this._map) this.addTo(props.map);
|
|
46
|
-
|
|
47
|
-
this._latlng = props.item.latlng;
|
|
48
|
-
|
|
49
|
-
switch(this.options.marker) {
|
|
50
|
-
case 'elevation-line':
|
|
51
|
-
if (this._container) {
|
|
52
|
-
let point = this._map.latLngToLayerPoint(this._latlng);
|
|
53
|
-
point = L.extend({}, props.item, this._map._rotate ? this._map.rotatedPointToMapPanePoint(point) : point);
|
|
54
|
-
|
|
55
|
-
let yMax = (this.control._height() / props.yCoordMax * point[this.options.yAttr]);
|
|
56
|
-
|
|
57
|
-
if(!isFinite(yMax) || isNaN(yMax)) yMax = 0;
|
|
58
|
-
|
|
59
|
-
this._container.classed("leaflet-hidden", false);
|
|
60
|
-
this._container.call(D3.PositionMarker({
|
|
61
|
-
theme : this.options.theme,
|
|
62
|
-
xCoord: point.x,
|
|
63
|
-
yCoord: point.y,
|
|
64
|
-
length: point.y - yMax, // normalized Y
|
|
65
|
-
labels: this._labels,
|
|
66
|
-
item: point,
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
break;
|
|
70
|
-
case 'position-marker':
|
|
71
|
-
_.removeClass(this._marker.getElement(), 'leaflet-hidden');
|
|
72
|
-
this._marker.setLatLng(this._latlng);
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
/*
|
|
78
|
-
* Hides the position/height indicator marker drawn onto the map
|
|
79
|
-
*/
|
|
80
|
-
remove: function() {
|
|
81
|
-
this._props = null;
|
|
82
|
-
switch(this.options.marker) {
|
|
83
|
-
case 'elevation-line': this._container && this._container.classed("leaflet-hidden", true); break;
|
|
84
|
-
case 'position-marker': _.addClass(this._marker.getElement(), 'leaflet-hidden'); break;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
getLatLng: function() {
|
|
89
|
-
return this._latlng;
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
_registerTooltip: function(props) {
|
|
93
|
-
this._labels[props.name] = props;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
});
|
|
1
|
+
import * as D3 from './d3.js';
|
|
2
|
+
|
|
3
|
+
const _ = L.Control.Elevation.Utils;
|
|
4
|
+
|
|
5
|
+
export var Marker = L.Class.extend({
|
|
6
|
+
|
|
7
|
+
initialize: function(options, control) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
this.control = control
|
|
10
|
+
|
|
11
|
+
switch(this.options.marker) {
|
|
12
|
+
case 'elevation-line':
|
|
13
|
+
// this._container = d3.create("g").attr("class", "height-focus-group");
|
|
14
|
+
break;
|
|
15
|
+
case 'position-marker':
|
|
16
|
+
// this._marker = L.circleMarker([0, 0], { pane: 'overlayPane', radius: 6, fillColor: '#fff', fillOpacity:1, color: '#000', weight:1, interactive: false });
|
|
17
|
+
this._marker = L.marker([0, 0], { icon: this.options.markerIcon, zIndexOffset: 1000000, interactive: false });
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
this._labels = {};
|
|
22
|
+
|
|
23
|
+
return this;
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
addTo: function(map) {
|
|
27
|
+
this._map = map;
|
|
28
|
+
switch(this.options.marker) {
|
|
29
|
+
case 'elevation-line': this._container = d3.select(map.getPane('elevationPane')).select("svg > g").call(D3.PositionMarker({})); break;
|
|
30
|
+
case 'position-marker': this._marker.addTo(map, { pane: 'overlayPane' }); break;
|
|
31
|
+
}
|
|
32
|
+
return this;
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Update position marker ("leaflet-marker").
|
|
37
|
+
*/
|
|
38
|
+
update: function(props) {
|
|
39
|
+
if (props) this._props = props;
|
|
40
|
+
else props = this._props;
|
|
41
|
+
|
|
42
|
+
if(!props) return;
|
|
43
|
+
|
|
44
|
+
if (props.options) this.options = props.options;
|
|
45
|
+
if (!this._map) this.addTo(props.map);
|
|
46
|
+
|
|
47
|
+
this._latlng = props.item.latlng;
|
|
48
|
+
|
|
49
|
+
switch(this.options.marker) {
|
|
50
|
+
case 'elevation-line':
|
|
51
|
+
if (this._container) {
|
|
52
|
+
let point = this._map.latLngToLayerPoint(this._latlng);
|
|
53
|
+
point = L.extend({}, props.item, this._map._rotate ? this._map.rotatedPointToMapPanePoint(point) : point);
|
|
54
|
+
|
|
55
|
+
let yMax = (this.control._height() / props.yCoordMax * point[this.options.yAttr]);
|
|
56
|
+
|
|
57
|
+
if(!isFinite(yMax) || isNaN(yMax)) yMax = 0;
|
|
58
|
+
|
|
59
|
+
this._container.classed("leaflet-hidden", false);
|
|
60
|
+
this._container.call(D3.PositionMarker({
|
|
61
|
+
theme : this.options.theme,
|
|
62
|
+
xCoord: point.x,
|
|
63
|
+
yCoord: point.y,
|
|
64
|
+
length: point.y - yMax, // normalized Y
|
|
65
|
+
labels: this._labels,
|
|
66
|
+
item: point,
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case 'position-marker':
|
|
71
|
+
_.removeClass(this._marker.getElement(), 'leaflet-hidden');
|
|
72
|
+
this._marker.setLatLng(this._latlng);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
* Hides the position/height indicator marker drawn onto the map
|
|
79
|
+
*/
|
|
80
|
+
remove: function() {
|
|
81
|
+
this._props = null;
|
|
82
|
+
switch(this.options.marker) {
|
|
83
|
+
case 'elevation-line': this._container && this._container.classed("leaflet-hidden", true); break;
|
|
84
|
+
case 'position-marker': _.addClass(this._marker.getElement(), 'leaflet-hidden'); break;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
getLatLng: function() {
|
|
89
|
+
return this._latlng;
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
_registerTooltip: function(props) {
|
|
93
|
+
this._labels[props.name] = props;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
});
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
const _ = L.Control.Elevation.Utils;
|
|
2
|
-
|
|
3
|
-
export var Summary = L.Class.extend({
|
|
4
|
-
initialize: function(opts, control) {
|
|
5
|
-
this.options = opts;
|
|
6
|
-
this.control = control;
|
|
7
|
-
this.labels = {};
|
|
8
|
-
|
|
9
|
-
let summary = this._container = _.create("div", "elevation-summary " + (opts.summary ? opts.summary + "-summary" : ''));
|
|
10
|
-
_.style(summary, 'max-width', opts.width ? opts.width + 'px' : '');
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
render: function() {
|
|
14
|
-
return container => container.append(() => this._container);
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
reset: function() {
|
|
18
|
-
this._container.innerHTML = '';
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
append: function(className, label, value) {
|
|
22
|
-
this._container.innerHTML += `<span class="${className}"><span class="summarylabel">${label}</span><span class="summaryvalue">${value}</span></span>`;
|
|
23
|
-
return this;
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
update: function() {
|
|
27
|
-
Object
|
|
28
|
-
.keys(this.labels)
|
|
29
|
-
.sort((a, b) => this.labels[a].order - this.labels[b].order) // TODO: any performance issues?
|
|
30
|
-
.forEach((i)=> {
|
|
31
|
-
let value = typeof this.labels[i].value !== "function" ? this.labels[i].value : this.labels[i].value(this.control.track_info, this.labels[i].unit || '');
|
|
32
|
-
this.append(i /*+ " order-" + this.labels[i].order*/, L._(this.labels[i].label), value, this.labels[i].order);
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
_registerSummary: function(data) {
|
|
37
|
-
for (let i in data) {
|
|
38
|
-
data[i].order = data[i].order ?? 1000;
|
|
39
|
-
this.labels[i] = data[i];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
});
|
|
1
|
+
const _ = L.Control.Elevation.Utils;
|
|
2
|
+
|
|
3
|
+
export var Summary = L.Class.extend({
|
|
4
|
+
initialize: function(opts, control) {
|
|
5
|
+
this.options = opts;
|
|
6
|
+
this.control = control;
|
|
7
|
+
this.labels = {};
|
|
8
|
+
|
|
9
|
+
let summary = this._container = _.create("div", "elevation-summary " + (opts.summary ? opts.summary + "-summary" : ''));
|
|
10
|
+
_.style(summary, 'max-width', opts.width ? opts.width + 'px' : '');
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
render: function() {
|
|
14
|
+
return container => container.append(() => this._container);
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
reset: function() {
|
|
18
|
+
this._container.innerHTML = '';
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
append: function(className, label, value) {
|
|
22
|
+
this._container.innerHTML += `<span class="${className}"><span class="summarylabel">${label}</span><span class="summaryvalue">${value}</span></span>`;
|
|
23
|
+
return this;
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
update: function() {
|
|
27
|
+
Object
|
|
28
|
+
.keys(this.labels)
|
|
29
|
+
.sort((a, b) => this.labels[a].order - this.labels[b].order) // TODO: any performance issues?
|
|
30
|
+
.forEach((i)=> {
|
|
31
|
+
let value = typeof this.labels[i].value !== "function" ? this.labels[i].value : this.labels[i].value(this.control.track_info, this.labels[i].unit || '');
|
|
32
|
+
this.append(i /*+ " order-" + this.labels[i].order*/, L._(this.labels[i].label), value, this.labels[i].order);
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
_registerSummary: function(data) {
|
|
37
|
+
for (let i in data) {
|
|
38
|
+
data[i].order = data[i].order ?? 1000;
|
|
39
|
+
this.labels[i] = data[i];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
});
|
package/src/control.js
CHANGED
|
@@ -181,8 +181,8 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
|
|
|
181
181
|
this._hotline = L.featureGroup();
|
|
182
182
|
this._circleMarkers = L.featureGroup();
|
|
183
183
|
this._markedSegments = L.polyline([]);
|
|
184
|
-
this._start = (opts.trkStart || Options.trkStart);
|
|
185
|
-
this._end = (opts.trkEnd || Options.trkEnd);
|
|
184
|
+
this._start = L.circleMarker([0,0], (opts.trkStart || Options.trkStart));
|
|
185
|
+
this._end = L.circleMarker([0,0], (opts.trkEnd || Options.trkEnd));
|
|
186
186
|
this._chartEnabled = true;
|
|
187
187
|
this._yCoordMax = -Infinity;
|
|
188
188
|
this.track_info = {};
|
|
@@ -428,6 +428,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
|
|
|
428
428
|
if(trkseg.feature.geometry.type != "Point") {
|
|
429
429
|
let geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], coords[2] * (this.options.altitudeFactor || 1))});
|
|
430
430
|
let line = L.hotline(geo.toGeoJSON().features[0].geometry.coordinates, {
|
|
431
|
+
renderer: L.Hotline.renderer(),
|
|
431
432
|
min: isFinite(this.track_info[prop + '_min']) ? this.track_info[prop + '_min'] : 0,
|
|
432
433
|
max: isFinite(this.track_info[prop + '_max']) ? this.track_info[prop + '_max'] : 1,
|
|
433
434
|
palette: {
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
export function Acceleration() {
|
|
2
|
-
|
|
3
|
-
const _ = L.Control.Elevation.Utils;
|
|
4
|
-
|
|
5
|
-
let opts = this.options;
|
|
6
|
-
let acceleration = {};
|
|
7
|
-
|
|
8
|
-
acceleration.label = opts.accelerationLabel || L._(opts.imperial ? 'ft/s²' : 'm/s²');
|
|
9
|
-
opts.accelerationFactor = opts.accelerationFactor || 1;
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
name: 'acceleration',
|
|
13
|
-
unit: acceleration.label,
|
|
14
|
-
deltaMax: this.options.accelerationDeltaMax,
|
|
15
|
-
clampRange: this.options.accelerationRange,
|
|
16
|
-
decimals: 2,
|
|
17
|
-
pointToAttr: (_, i) => {
|
|
18
|
-
let dv = (this._data[i].speed - this._data[i > 0 ? i - 1 : i].speed) * (1000 / opts.timeFactor);
|
|
19
|
-
let dt = (this._data[i].time - this._data[i > 0 ? i - 1 : i].time) / 1000;
|
|
20
|
-
return dt > 0 ? Math.abs((dv / dt)) * opts.accelerationFactor : 0;
|
|
21
|
-
},
|
|
22
|
-
stats: { max: _.iMax, min: _.iMin, avg: _.iAvg },
|
|
23
|
-
scale: {
|
|
24
|
-
axis : "y",
|
|
25
|
-
position : "right",
|
|
26
|
-
scale : { min: 0, max: +1 },
|
|
27
|
-
tickPadding: 16,
|
|
28
|
-
labelX : 25,
|
|
29
|
-
labelY : -8,
|
|
30
|
-
},
|
|
31
|
-
path: {
|
|
32
|
-
label : 'Acceleration',
|
|
33
|
-
yAttr : 'acceleration',
|
|
34
|
-
scaleX : 'distance',
|
|
35
|
-
scaleY : 'acceleration',
|
|
36
|
-
color : '#050402',
|
|
37
|
-
strokeColor : '#000',
|
|
38
|
-
strokeOpacity: "0.5",
|
|
39
|
-
fillOpacity : "0.25",
|
|
40
|
-
},
|
|
41
|
-
tooltip: {
|
|
42
|
-
chart: (item) => L._("a: ") + item.acceleration + " " + acceleration.label,
|
|
43
|
-
marker: (item) => Math.round(item.acceleration) + " " + acceleration.label,
|
|
44
|
-
order: 60,
|
|
45
|
-
},
|
|
46
|
-
summary: {
|
|
47
|
-
"minacceleration" : {
|
|
48
|
-
label: "Min Acceleration: ",
|
|
49
|
-
value: (track, unit) => Math.round(track.acceleration_min || 0) + ' ' + unit,
|
|
50
|
-
order: 60
|
|
51
|
-
},
|
|
52
|
-
"maxacceleration" : {
|
|
53
|
-
label: "Max Acceleration: ",
|
|
54
|
-
value: (track, unit) => Math.round(track.acceleration_max || 0) + ' ' + unit,
|
|
55
|
-
order: 61
|
|
56
|
-
},
|
|
57
|
-
"avgacceleration": {
|
|
58
|
-
label: "Avg Acceleration: ",
|
|
59
|
-
value: (track, unit) => Math.round(track.acceleration_avg || 0) + ' ' + unit,
|
|
60
|
-
order: 62
|
|
61
|
-
},
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
1
|
+
export function Acceleration() {
|
|
2
|
+
|
|
3
|
+
const _ = L.Control.Elevation.Utils;
|
|
4
|
+
|
|
5
|
+
let opts = this.options;
|
|
6
|
+
let acceleration = {};
|
|
7
|
+
|
|
8
|
+
acceleration.label = opts.accelerationLabel || L._(opts.imperial ? 'ft/s²' : 'm/s²');
|
|
9
|
+
opts.accelerationFactor = opts.accelerationFactor || 1;
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
name: 'acceleration',
|
|
13
|
+
unit: acceleration.label,
|
|
14
|
+
deltaMax: this.options.accelerationDeltaMax,
|
|
15
|
+
clampRange: this.options.accelerationRange,
|
|
16
|
+
decimals: 2,
|
|
17
|
+
pointToAttr: (_, i) => {
|
|
18
|
+
let dv = (this._data[i].speed - this._data[i > 0 ? i - 1 : i].speed) * (1000 / opts.timeFactor);
|
|
19
|
+
let dt = (this._data[i].time - this._data[i > 0 ? i - 1 : i].time) / 1000;
|
|
20
|
+
return dt > 0 ? Math.abs((dv / dt)) * opts.accelerationFactor : 0;
|
|
21
|
+
},
|
|
22
|
+
stats: { max: _.iMax, min: _.iMin, avg: _.iAvg },
|
|
23
|
+
scale: {
|
|
24
|
+
axis : "y",
|
|
25
|
+
position : "right",
|
|
26
|
+
scale : { min: 0, max: +1 },
|
|
27
|
+
tickPadding: 16,
|
|
28
|
+
labelX : 25,
|
|
29
|
+
labelY : -8,
|
|
30
|
+
},
|
|
31
|
+
path: {
|
|
32
|
+
label : 'Acceleration',
|
|
33
|
+
yAttr : 'acceleration',
|
|
34
|
+
scaleX : 'distance',
|
|
35
|
+
scaleY : 'acceleration',
|
|
36
|
+
color : '#050402',
|
|
37
|
+
strokeColor : '#000',
|
|
38
|
+
strokeOpacity: "0.5",
|
|
39
|
+
fillOpacity : "0.25",
|
|
40
|
+
},
|
|
41
|
+
tooltip: {
|
|
42
|
+
chart: (item) => L._("a: ") + item.acceleration + " " + acceleration.label,
|
|
43
|
+
marker: (item) => Math.round(item.acceleration) + " " + acceleration.label,
|
|
44
|
+
order: 60,
|
|
45
|
+
},
|
|
46
|
+
summary: {
|
|
47
|
+
"minacceleration" : {
|
|
48
|
+
label: "Min Acceleration: ",
|
|
49
|
+
value: (track, unit) => Math.round(track.acceleration_min || 0) + ' ' + unit,
|
|
50
|
+
order: 60
|
|
51
|
+
},
|
|
52
|
+
"maxacceleration" : {
|
|
53
|
+
label: "Max Acceleration: ",
|
|
54
|
+
value: (track, unit) => Math.round(track.acceleration_max || 0) + ' ' + unit,
|
|
55
|
+
order: 61
|
|
56
|
+
},
|
|
57
|
+
"avgacceleration": {
|
|
58
|
+
label: "Avg Acceleration: ",
|
|
59
|
+
value: (track, unit) => Math.round(track.acceleration_avg || 0) + ' ' + unit,
|
|
60
|
+
order: 62
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
package/src/handlers/heart.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
export function Heart() {
|
|
2
|
-
|
|
3
|
-
const _ = L.Control.Elevation.Utils;
|
|
4
|
-
|
|
5
|
-
return {
|
|
6
|
-
name: 'heart', // <-- Your custom option name (eg. "heart: true")
|
|
7
|
-
unit: 'bpm',
|
|
8
|
-
meta: 'hr', // <-- point.meta.hr
|
|
9
|
-
coordinateProperties: ["heart", "heartRates", "heartRate"], // List of GPX Extensions ("coordinateProperties") to be handled by "@tmcw/toGeoJSON"
|
|
10
|
-
pointToAttr: (point, i) => (point.hr ?? point.meta.hr ?? point.prev('heart')) || 0,
|
|
11
|
-
stats: { max: _.iMax, min: _.iMin, avg: _.iAvg },
|
|
12
|
-
scale: {
|
|
13
|
-
axis : "y",
|
|
14
|
-
position : "left",
|
|
15
|
-
scale : { min: -1, max: +1 },
|
|
16
|
-
tickPadding: 25,
|
|
17
|
-
labelX : -30,
|
|
18
|
-
labelY : -8,
|
|
19
|
-
},
|
|
20
|
-
path: {
|
|
21
|
-
label : 'ECG',
|
|
22
|
-
yAttr : 'heart',
|
|
23
|
-
scaleX : 'distance',
|
|
24
|
-
scaleY : 'heart',
|
|
25
|
-
color : 'white',
|
|
26
|
-
strokeColor : 'red',
|
|
27
|
-
strokeOpacity: "0.85",
|
|
28
|
-
fillOpacity : "0.1",
|
|
29
|
-
},
|
|
30
|
-
tooltip: {
|
|
31
|
-
chart: (item) => L._("hr: ") + item.heart + " " + 'bpm',
|
|
32
|
-
marker: (item) => Math.round(item.heart) + " " + 'bpm',
|
|
33
|
-
order: 1
|
|
34
|
-
},
|
|
35
|
-
summary: {
|
|
36
|
-
"minbpm": {
|
|
37
|
-
label: "Min BPM: ",
|
|
38
|
-
value: (track, unit) => Math.round(track.heart_min || 0) + ' ' + unit,
|
|
39
|
-
// order: 30
|
|
40
|
-
},
|
|
41
|
-
"maxbpm": {
|
|
42
|
-
label: "Max BPM: ",
|
|
43
|
-
value: (track, unit) => Math.round(track.heart_max || 0) + ' ' + unit,
|
|
44
|
-
// order: 30
|
|
45
|
-
},
|
|
46
|
-
"avgbpm": {
|
|
47
|
-
label: "Avg BPM: ",
|
|
48
|
-
value: (track, unit) => Math.round(track.heart_avg || 0) + ' ' + unit,
|
|
49
|
-
// order: 20
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
};
|
|
1
|
+
export function Heart() {
|
|
2
|
+
|
|
3
|
+
const _ = L.Control.Elevation.Utils;
|
|
4
|
+
|
|
5
|
+
return {
|
|
6
|
+
name: 'heart', // <-- Your custom option name (eg. "heart: true")
|
|
7
|
+
unit: 'bpm',
|
|
8
|
+
meta: 'hr', // <-- point.meta.hr
|
|
9
|
+
coordinateProperties: ["heart", "heartRates", "heartRate"], // List of GPX Extensions ("coordinateProperties") to be handled by "@tmcw/toGeoJSON"
|
|
10
|
+
pointToAttr: (point, i) => (point.hr ?? point.meta.hr ?? point.prev('heart')) || 0,
|
|
11
|
+
stats: { max: _.iMax, min: _.iMin, avg: _.iAvg },
|
|
12
|
+
scale: {
|
|
13
|
+
axis : "y",
|
|
14
|
+
position : "left",
|
|
15
|
+
scale : { min: -1, max: +1 },
|
|
16
|
+
tickPadding: 25,
|
|
17
|
+
labelX : -30,
|
|
18
|
+
labelY : -8,
|
|
19
|
+
},
|
|
20
|
+
path: {
|
|
21
|
+
label : 'ECG',
|
|
22
|
+
yAttr : 'heart',
|
|
23
|
+
scaleX : 'distance',
|
|
24
|
+
scaleY : 'heart',
|
|
25
|
+
color : 'white',
|
|
26
|
+
strokeColor : 'red',
|
|
27
|
+
strokeOpacity: "0.85",
|
|
28
|
+
fillOpacity : "0.1",
|
|
29
|
+
},
|
|
30
|
+
tooltip: {
|
|
31
|
+
chart: (item) => L._("hr: ") + item.heart + " " + 'bpm',
|
|
32
|
+
marker: (item) => Math.round(item.heart) + " " + 'bpm',
|
|
33
|
+
order: 1
|
|
34
|
+
},
|
|
35
|
+
summary: {
|
|
36
|
+
"minbpm": {
|
|
37
|
+
label: "Min BPM: ",
|
|
38
|
+
value: (track, unit) => Math.round(track.heart_min || 0) + ' ' + unit,
|
|
39
|
+
// order: 30
|
|
40
|
+
},
|
|
41
|
+
"maxbpm": {
|
|
42
|
+
label: "Max BPM: ",
|
|
43
|
+
value: (track, unit) => Math.round(track.heart_max || 0) + ' ' + unit,
|
|
44
|
+
// order: 30
|
|
45
|
+
},
|
|
46
|
+
"avgbpm": {
|
|
47
|
+
label: "Avg BPM: ",
|
|
48
|
+
value: (track, unit) => Math.round(track.heart_avg || 0) + ' ' + unit,
|
|
49
|
+
// order: 20
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
53
|
};
|
package/src/handlers/pace.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
export function Pace() {
|
|
2
|
-
|
|
3
|
-
const _ = L.Control.Elevation.Utils;
|
|
4
|
-
|
|
5
|
-
let opts = this.options;
|
|
6
|
-
let pace = {};
|
|
7
|
-
|
|
8
|
-
pace.label = opts.paceLabel || L._(opts.imperial ? 'min/mi' : 'min/km');
|
|
9
|
-
opts.paceFactor = opts.paceFactor || 60; // 1 min = 60 sec
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
name: 'pace',
|
|
13
|
-
unit: pace.label,
|
|
14
|
-
deltaMax: this.options.paceDeltaMax,
|
|
15
|
-
clampRange: this.options.paceRange,
|
|
16
|
-
decimals: 2,
|
|
17
|
-
pointToAttr: (_, i) => {
|
|
18
|
-
let dx = (this._data[i].dist - this._data[i > 0 ? i - 1 : i].dist) * 1000;
|
|
19
|
-
let dt = this._data[i].time - this._data[ i > 0 ? i - 1 : i].time;
|
|
20
|
-
return dx > 0 ? Math.abs((dt / dx) / opts.paceFactor) : 0;
|
|
21
|
-
},
|
|
22
|
-
stats: { max: _.iMax, min: _.iMin, avg: _.iAvg },
|
|
23
|
-
scale : (this.options.pace && this.options.pace != "summary") && {
|
|
24
|
-
axis : "y",
|
|
25
|
-
position : "right",
|
|
26
|
-
scale : { min : 0, max : +1 },
|
|
27
|
-
tickPadding: 16,
|
|
28
|
-
labelX : 25,
|
|
29
|
-
labelY : -8,
|
|
30
|
-
},
|
|
31
|
-
path: (this.options.pace && this.options.pace != "summary") && {
|
|
32
|
-
// name : 'pace',
|
|
33
|
-
label : 'Pace',
|
|
34
|
-
yAttr : "pace",
|
|
35
|
-
scaleX : 'distance',
|
|
36
|
-
scaleY : 'pace',
|
|
37
|
-
color : '#03ffff',
|
|
38
|
-
strokeColor : '#000',
|
|
39
|
-
strokeOpacity: "0.5",
|
|
40
|
-
fillOpacity : "0.25",
|
|
41
|
-
},
|
|
42
|
-
tooltip: (this.options.pace) && {
|
|
43
|
-
chart: (item) => L._('pace: ') + item.pace + " " + pace.label,
|
|
44
|
-
marker: (item) => Math.round(item.pace) + " " + pace.label,
|
|
45
|
-
order: 50,
|
|
46
|
-
},
|
|
47
|
-
summary: (this.options.pace) && {
|
|
48
|
-
"minpace" : {
|
|
49
|
-
label: "Min Pace: ",
|
|
50
|
-
value: (track, unit) => Math.round(track.pace_min || 0) + ' ' + unit,
|
|
51
|
-
order: 51
|
|
52
|
-
},
|
|
53
|
-
"maxpace" : {
|
|
54
|
-
label: "Max Pace: ",
|
|
55
|
-
value: (track, unit) => Math.round(track.pace_max || 0) + ' ' + unit,
|
|
56
|
-
order: 51
|
|
57
|
-
},
|
|
58
|
-
"avgpace": {
|
|
59
|
-
label: "Avg Pace: ",
|
|
60
|
-
value: (track, unit) => Math.round(track.pace_avg || 0) + ' ' + unit,
|
|
61
|
-
order: 52
|
|
62
|
-
},
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
1
|
+
export function Pace() {
|
|
2
|
+
|
|
3
|
+
const _ = L.Control.Elevation.Utils;
|
|
4
|
+
|
|
5
|
+
let opts = this.options;
|
|
6
|
+
let pace = {};
|
|
7
|
+
|
|
8
|
+
pace.label = opts.paceLabel || L._(opts.imperial ? 'min/mi' : 'min/km');
|
|
9
|
+
opts.paceFactor = opts.paceFactor || 60; // 1 min = 60 sec
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
name: 'pace',
|
|
13
|
+
unit: pace.label,
|
|
14
|
+
deltaMax: this.options.paceDeltaMax,
|
|
15
|
+
clampRange: this.options.paceRange,
|
|
16
|
+
decimals: 2,
|
|
17
|
+
pointToAttr: (_, i) => {
|
|
18
|
+
let dx = (this._data[i].dist - this._data[i > 0 ? i - 1 : i].dist) * 1000;
|
|
19
|
+
let dt = this._data[i].time - this._data[ i > 0 ? i - 1 : i].time;
|
|
20
|
+
return dx > 0 ? Math.abs((dt / dx) / opts.paceFactor) : 0;
|
|
21
|
+
},
|
|
22
|
+
stats: { max: _.iMax, min: _.iMin, avg: _.iAvg },
|
|
23
|
+
scale : (this.options.pace && this.options.pace != "summary") && {
|
|
24
|
+
axis : "y",
|
|
25
|
+
position : "right",
|
|
26
|
+
scale : { min : 0, max : +1 },
|
|
27
|
+
tickPadding: 16,
|
|
28
|
+
labelX : 25,
|
|
29
|
+
labelY : -8,
|
|
30
|
+
},
|
|
31
|
+
path: (this.options.pace && this.options.pace != "summary") && {
|
|
32
|
+
// name : 'pace',
|
|
33
|
+
label : 'Pace',
|
|
34
|
+
yAttr : "pace",
|
|
35
|
+
scaleX : 'distance',
|
|
36
|
+
scaleY : 'pace',
|
|
37
|
+
color : '#03ffff',
|
|
38
|
+
strokeColor : '#000',
|
|
39
|
+
strokeOpacity: "0.5",
|
|
40
|
+
fillOpacity : "0.25",
|
|
41
|
+
},
|
|
42
|
+
tooltip: (this.options.pace) && {
|
|
43
|
+
chart: (item) => L._('pace: ') + item.pace + " " + pace.label,
|
|
44
|
+
marker: (item) => Math.round(item.pace) + " " + pace.label,
|
|
45
|
+
order: 50,
|
|
46
|
+
},
|
|
47
|
+
summary: (this.options.pace) && {
|
|
48
|
+
"minpace" : {
|
|
49
|
+
label: "Min Pace: ",
|
|
50
|
+
value: (track, unit) => Math.round(track.pace_min || 0) + ' ' + unit,
|
|
51
|
+
order: 51
|
|
52
|
+
},
|
|
53
|
+
"maxpace" : {
|
|
54
|
+
label: "Max Pace: ",
|
|
55
|
+
value: (track, unit) => Math.round(track.pace_max || 0) + ' ' + unit,
|
|
56
|
+
order: 51
|
|
57
|
+
},
|
|
58
|
+
"avgpace": {
|
|
59
|
+
label: "Avg Pace: ",
|
|
60
|
+
value: (track, unit) => Math.round(track.pace_avg || 0) + ' ' + unit,
|
|
61
|
+
order: 52
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|