@raruto/leaflet-elevation 2.2.6 → 2.2.8
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/README.md +1 -1
- package/dist/leaflet-elevation.js +32 -35
- 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/libs/leaflet-distance-marker.js +1 -1
- package/libs/leaflet-distance-marker.min.js +1 -1
- package/package.json +6 -6
- package/src/components/d3.js +1 -1
- package/src/control.js +32 -34
- package/src/handlers/acceleration.js +1 -1
- package/src/handlers/altitude.js +0 -1
- package/src/handlers/pace.js +1 -1
- package/src/handlers/slope.js +1 -1
- package/src/handlers/speed.js +1 -1
- package/src/options.js +0 -1
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ _For a working example see one of the following demos:_
|
|
|
63
63
|
|
|
64
64
|
<!-- leaflet-ui -->
|
|
65
65
|
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
|
|
66
|
-
<script src="https://unpkg.com/leaflet-ui@0.5.
|
|
66
|
+
<script src="https://unpkg.com/leaflet-ui@0.5.9/dist/leaflet-ui.js"></script>
|
|
67
67
|
|
|
68
68
|
<!-- leaflet-elevation -->
|
|
69
69
|
<link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation/dist/leaflet-elevation.css" />
|
|
@@ -280,7 +280,6 @@
|
|
|
280
280
|
decimalsY: 0,
|
|
281
281
|
forceAxisBounds: false,
|
|
282
282
|
interpolation: "curveLinear",
|
|
283
|
-
skipNullZCoords: false,
|
|
284
283
|
yAxisMax: undefined,
|
|
285
284
|
yAxisMin: undefined,
|
|
286
285
|
};
|
|
@@ -310,7 +309,7 @@
|
|
|
310
309
|
__LMARKER: '../src/components/marker.js',
|
|
311
310
|
__LSUMMARY: '../src/components/summary.js',
|
|
312
311
|
__modulesFolder: '../src/handlers/',
|
|
313
|
-
__btnIcon: '../images/elevation.svg',
|
|
312
|
+
__btnIcon: baseURL + '../images/elevation.svg',
|
|
314
313
|
|
|
315
314
|
/*
|
|
316
315
|
* Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
|
|
@@ -1273,10 +1272,10 @@
|
|
|
1273
1272
|
}
|
|
1274
1273
|
|
|
1275
1274
|
// prevent excessive variabile instanstations
|
|
1276
|
-
let i, curr, prev, attr;
|
|
1275
|
+
let i, curr, prev, attr = props.attr || props.name;
|
|
1277
1276
|
|
|
1278
1277
|
// save here a reference to last used point
|
|
1279
|
-
let lastValid =
|
|
1278
|
+
let lastValid = {};
|
|
1280
1279
|
|
|
1281
1280
|
// iteration
|
|
1282
1281
|
this.on("elepoint_added", ({index, point}) => {
|
|
@@ -1284,42 +1283,33 @@
|
|
|
1284
1283
|
|
|
1285
1284
|
prev = curr ?? this._data[i]; // same as: this._data[i > 0 ? i - 1 : i]
|
|
1286
1285
|
curr = this._data[i];
|
|
1287
|
-
|
|
1286
|
+
|
|
1287
|
+
// retrieve point value
|
|
1288
|
+
curr[attr] = props.pointToAttr.call(this, point, i);
|
|
1288
1289
|
|
|
1289
1290
|
// check and fix missing data on last added point
|
|
1290
|
-
if (
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
} else if (!isNaN(lastValid)) {
|
|
1298
|
-
prev = lastValid;
|
|
1299
|
-
} else if (!isNaN(curr)) {
|
|
1300
|
-
prev = curr;
|
|
1301
|
-
}
|
|
1302
|
-
if (!isNaN(prev)) return this._data.splice(i - 1, 1);
|
|
1303
|
-
this._data[i - 1][attr] = prev;
|
|
1304
|
-
}
|
|
1291
|
+
if (i > 0 && isNaN(prev[attr])) {
|
|
1292
|
+
if (!isNaN(lastValid[attr]) && !isNaN(curr[attr])) {
|
|
1293
|
+
prev[attr] = (lastValid[attr] + curr[attr]) / 2;
|
|
1294
|
+
} else if (!isNaN(lastValid[attr])) {
|
|
1295
|
+
prev[attr] = lastValid[attr];
|
|
1296
|
+
} else if (!isNaN(curr[attr])) {
|
|
1297
|
+
prev[attr] = curr[attr];
|
|
1305
1298
|
}
|
|
1306
|
-
// update
|
|
1307
|
-
if (
|
|
1308
|
-
|
|
1299
|
+
// update "yAttr" and "xAttr"
|
|
1300
|
+
if (props.meta) {
|
|
1301
|
+
prev[props.meta] = prev[attr];
|
|
1309
1302
|
}
|
|
1310
1303
|
}
|
|
1311
1304
|
|
|
1312
|
-
//
|
|
1313
|
-
curr[attr]
|
|
1314
|
-
|
|
1315
|
-
// update "track_info" stats (min, max, avg, ...)
|
|
1316
|
-
if (props.stats) {
|
|
1317
|
-
for (const key in props.stats) {
|
|
1318
|
-
let sname = (props.statsName || attr) + (key != '' ? '_' : '');
|
|
1319
|
-
this.track_info[sname + key] = props.stats[key].call(this, curr[attr], this.track_info[sname + key], this._data.length);
|
|
1320
|
-
}
|
|
1305
|
+
// skip to next iteration for invalid or missing data (eg. i == 0)
|
|
1306
|
+
if (isNaN(curr[attr])) {
|
|
1307
|
+
return;
|
|
1321
1308
|
}
|
|
1322
1309
|
|
|
1310
|
+
// update reference to last used point
|
|
1311
|
+
lastValid[attr] = curr[attr];
|
|
1312
|
+
|
|
1323
1313
|
// Limit "crazy" delta values.
|
|
1324
1314
|
if (props.deltaMax) {
|
|
1325
1315
|
curr[attr] =wrapDelta(curr[attr], prev[attr], props.deltaMax);
|
|
@@ -1335,8 +1325,16 @@
|
|
|
1335
1325
|
curr[attr] = round(curr[attr], props.decimals);
|
|
1336
1326
|
}
|
|
1337
1327
|
|
|
1328
|
+
// update "track_info" stats (min, max, avg, ...)
|
|
1329
|
+
if (props.stats) {
|
|
1330
|
+
for (const key in props.stats) {
|
|
1331
|
+
let sname = (props.statsName || attr) + (key != '' ? '_' : '');
|
|
1332
|
+
this.track_info[sname + key] = props.stats[key].call(this, curr[attr], this.track_info[sname + key], this._data.length);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1338
1336
|
// update here some mixins (eg. complex "track_info" stuff)
|
|
1339
|
-
if(props.onPointAdded) props.onPointAdded.call(this, curr[attr], i, point);
|
|
1337
|
+
if (props.onPointAdded) props.onPointAdded.call(this, curr[attr], i, point);
|
|
1340
1338
|
});
|
|
1341
1339
|
},
|
|
1342
1340
|
|
|
@@ -1354,7 +1352,6 @@
|
|
|
1354
1352
|
name,
|
|
1355
1353
|
attr,
|
|
1356
1354
|
required,
|
|
1357
|
-
skipNull,
|
|
1358
1355
|
deltaMax,
|
|
1359
1356
|
clampRange,
|
|
1360
1357
|
decimals,
|
|
@@ -1379,7 +1376,7 @@
|
|
|
1379
1376
|
this._registerDataAttribute({
|
|
1380
1377
|
name,
|
|
1381
1378
|
attr,
|
|
1382
|
-
|
|
1379
|
+
meta,
|
|
1383
1380
|
deltaMax,
|
|
1384
1381
|
clampRange,
|
|
1385
1382
|
decimals,
|