summaryrefslogtreecommitdiff
path: root/assets/static/vendor/leaflet-elevation/src/handlers/acceleration.js
diff options
context:
space:
mode:
authorDennis Fink2026-07-23 00:18:21 +0200
committerDennis Fink2026-07-23 00:18:21 +0200
commit1fe1d13c600b7dfe421b3b99b833b7d5d1232724 (patch)
tree2e8636160cc1719c907be56f5ef8cbc7e0f10a53 /assets/static/vendor/leaflet-elevation/src/handlers/acceleration.js
parentca77de06be474dfd712402c327dc436864d233a3 (diff)
downloaddennisfink.me-1fe1d13c600b7dfe421b3b99b833b7d5d1232724.tar.gz
dennisfink.me-1fe1d13c600b7dfe421b3b99b833b7d5d1232724.zip
Add GPX trail maps to blog posts
This adds a trail flow block so posts can include attached GPX files as interactive maps with route display, elevation charts, activity summaries, and start/finish markers. The trail assets are loaded only when needed, keeping the shared templates clean while vendoring the Leaflet dependencies required for offline, self-hosted map rendering.
Diffstat (limited to 'assets/static/vendor/leaflet-elevation/src/handlers/acceleration.js')
-rw-r--r--assets/static/vendor/leaflet-elevation/src/handlers/acceleration.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/assets/static/vendor/leaflet-elevation/src/handlers/acceleration.js b/assets/static/vendor/leaflet-elevation/src/handlers/acceleration.js
new file mode 100644
index 0000000..9b31b5c
--- /dev/null
+++ b/assets/static/vendor/leaflet-elevation/src/handlers/acceleration.js
@@ -0,0 +1,64 @@
+export function Acceleration() {
+
+ const _ = L.Control.Elevation.Utils;
+
+ let opts = this.options;
+ let acceleration = {};
+
+ acceleration.label = opts.accelerationLabel || L._(opts.imperial ? 'ft/s²' : 'm/s²');
+ opts.accelerationFactor = opts.accelerationFactor || 1;
+
+ return {
+ name: 'acceleration',
+ unit: acceleration.label,
+ deltaMax: this.options.accelerationDeltaMax,
+ clampRange: this.options.accelerationRange,
+ decimals: 2,
+ pointToAttr: (_, i) => {
+ let dv = (this._data[i].speed - this._data[i > 0 ? i - 1 : i].speed) * (1000 / opts.timeFactor);
+ let dt = (this._data[i].time - this._data[i > 0 ? i - 1 : i].time) / 1000;
+ return dt > 0 ? Math.abs((dv / dt)) * opts.accelerationFactor : NaN;
+ },
+ stats: { max: _.iMax, min: _.iMin, avg: _.iAvg },
+ scale: {
+ axis : "y",
+ position : "right",
+ scale : { min: 0, max: +1 },
+ tickPadding: 16,
+ labelX : 25,
+ labelY : -8,
+ },
+ path: {
+ label : 'Acceleration',
+ yAttr : 'acceleration',
+ scaleX : 'distance',
+ scaleY : 'acceleration',
+ color : '#050402',
+ strokeColor : '#000',
+ strokeOpacity: "0.5",
+ fillOpacity : "0.25",
+ },
+ tooltip: {
+ chart: (item) => L._("a: ") + item.acceleration + " " + acceleration.label,
+ marker: (item) => Math.round(item.acceleration) + " " + acceleration.label,
+ order: 60,
+ },
+ summary: {
+ "minacceleration" : {
+ label: "Min Acceleration: ",
+ value: (track, unit) => Math.round(track.acceleration_min || 0) + ' ' + unit,
+ order: 60
+ },
+ "maxacceleration" : {
+ label: "Max Acceleration: ",
+ value: (track, unit) => Math.round(track.acceleration_max || 0) + ' ' + unit,
+ order: 61
+ },
+ "avgacceleration": {
+ label: "Avg Acceleration: ",
+ value: (track, unit) => Math.round(track.acceleration_avg || 0) + ' ' + unit,
+ order: 62
+ },
+ }
+ };
+}