@raruto/leaflet-elevation 2.6.0 → 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.
- package/LICENSE +674 -674
- package/README.md +1 -0
- package/dist/leaflet-elevation.css +278 -337
- package/dist/leaflet-elevation.js +1378 -1708
- package/dist/leaflet-elevation.js.map +7 -1
- package/dist/leaflet-elevation.min.css +1 -1
- package/dist/leaflet-elevation.min.js +1 -2
- 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/fullpage.css +13 -13
- package/libs/leaflet-distance-marker.css +8 -8
- package/libs/leaflet-distance-marker.js +314 -314
- package/libs/leaflet-edgescale.js +635 -635
- package/libs/leaflet-ruler.css +41 -41
- package/libs/leaflet-ruler.js +182 -182
- package/package.json +6 -19
- package/src/components/chart.js +6 -0
- package/src/components/marker.js +3 -1
- package/src/components/summary.js +43 -43
- package/src/control.js +5 -0
- package/src/handlers/acceleration.js +64 -64
- package/src/handlers/altitude.js +78 -78
- package/src/handlers/cadence.js +53 -53
- 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/index.css +329 -329
- package/src/index.js +42 -42
- package/src/options.js +1 -1
- package/src/utils.spec.js +48 -50
package/src/index.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2019, GPL-3.0+ Project, Raruto
|
|
3
|
-
*
|
|
4
|
-
* This file is free software: you may copy, redistribute and/or modify it
|
|
5
|
-
* under the terms of the GNU General Public License as published by the
|
|
6
|
-
* Free Software Foundation, either version 2 of the License, or (at your
|
|
7
|
-
* option) any later version.
|
|
8
|
-
*
|
|
9
|
-
* This file is distributed in the hope that it will be useful, but
|
|
10
|
-
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
-
* General Public License for more details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU General Public License
|
|
15
|
-
* along with this program. If not, see .
|
|
16
|
-
*
|
|
17
|
-
* This file incorporates work covered by the following copyright and
|
|
18
|
-
* permission notice:
|
|
19
|
-
*
|
|
20
|
-
* Copyright (c) 2013-2016, MIT License, Felix “MrMufflon” Bache
|
|
21
|
-
*
|
|
22
|
-
* Permission to use, copy, modify, and/or distribute this software
|
|
23
|
-
* for any purpose with or without fee is hereby granted, provided
|
|
24
|
-
* that the above copyright notice and this permission notice appear
|
|
25
|
-
* in all copies.
|
|
26
|
-
*
|
|
27
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
|
28
|
-
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
|
29
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
|
30
|
-
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
|
31
|
-
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
32
|
-
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
|
33
|
-
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
34
|
-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
import * as _ from './utils';
|
|
38
|
-
import { Elevation } from './control';
|
|
39
|
-
|
|
40
|
-
Elevation.Utils = _;
|
|
41
|
-
|
|
42
|
-
L.control.elevation = (options) => new Elevation(options);
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2019, GPL-3.0+ Project, Raruto
|
|
3
|
+
*
|
|
4
|
+
* This file is free software: you may copy, redistribute and/or modify it
|
|
5
|
+
* under the terms of the GNU General Public License as published by the
|
|
6
|
+
* Free Software Foundation, either version 2 of the License, or (at your
|
|
7
|
+
* option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* This file is distributed in the hope that it will be useful, but
|
|
10
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
+
* General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License
|
|
15
|
+
* along with this program. If not, see .
|
|
16
|
+
*
|
|
17
|
+
* This file incorporates work covered by the following copyright and
|
|
18
|
+
* permission notice:
|
|
19
|
+
*
|
|
20
|
+
* Copyright (c) 2013-2016, MIT License, Felix “MrMufflon” Bache
|
|
21
|
+
*
|
|
22
|
+
* Permission to use, copy, modify, and/or distribute this software
|
|
23
|
+
* for any purpose with or without fee is hereby granted, provided
|
|
24
|
+
* that the above copyright notice and this permission notice appear
|
|
25
|
+
* in all copies.
|
|
26
|
+
*
|
|
27
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
|
28
|
+
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
|
29
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
|
30
|
+
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
|
31
|
+
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
32
|
+
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
|
33
|
+
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
34
|
+
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
import * as _ from './utils';
|
|
38
|
+
import { Elevation } from './control';
|
|
39
|
+
|
|
40
|
+
Elevation.Utils = _;
|
|
41
|
+
|
|
42
|
+
L.control.elevation = (options) => new Elevation(options);
|
package/src/options.js
CHANGED
|
@@ -84,5 +84,5 @@ export var Options = {
|
|
|
84
84
|
yAxisMin: undefined,
|
|
85
85
|
|
|
86
86
|
// Prevent CORS issues for relative locations (dynamic import)
|
|
87
|
-
srcFolder: ((document.currentScript && document.currentScript.src) || (import.meta && import.meta.url)).split("/").slice(0,-1).join("/") + '/',
|
|
87
|
+
srcFolder: ((document.currentScript && document.currentScript.src) || (import.meta && import.meta.url) || document.baseURI).split("/").slice(0,-1).join("/") + '/',
|
|
88
88
|
};
|
package/src/utils.spec.js
CHANGED
|
@@ -1,50 +1,48 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/utils.js
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
test('iAvg()', () => {
|
|
15
|
-
let avg;
|
|
16
|
-
avg = iAvg(100, undefined, 1); assert.
|
|
17
|
-
avg = iAvg(100, avg, 2); assert.
|
|
18
|
-
avg = iAvg(200, avg, 3); assert.
|
|
19
|
-
avg = iAvg(200, avg, 4); assert.
|
|
20
|
-
avg = iAvg(NaN, avg, 5); assert.ok(isNaN(avg));
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('iMin()', () => {
|
|
24
|
-
let min;
|
|
25
|
-
min = iMin(100, undefined); assert.
|
|
26
|
-
min = iMin(NaN, min); assert.
|
|
27
|
-
min = iMin(0, min); assert.
|
|
28
|
-
min = iMin(-200, min); assert.
|
|
29
|
-
min = iMin(200, min); assert.
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('iMax()', () => {
|
|
33
|
-
let max;
|
|
34
|
-
max = iMax(100, undefined); assert.
|
|
35
|
-
max = iMax(NaN, max); assert.
|
|
36
|
-
max = iMax(0, max); assert.
|
|
37
|
-
max = iMax(-200, max); assert.
|
|
38
|
-
max = iMax(200, max); assert.
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('iSum()', () => {
|
|
42
|
-
let sum;
|
|
43
|
-
sum = iSum(10.25, undefined); assert.
|
|
44
|
-
sum = iSum(0, sum); assert.
|
|
45
|
-
sum = iSum(-0.25, sum); assert.
|
|
46
|
-
sum = iSum(-10, sum); assert.
|
|
47
|
-
sum = iSum(NaN, sum); assert.ok(isNaN(sum)); // sum for [10.25, 0, -0.25, -10, NaN] is NaN
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test.run();
|
|
1
|
+
/**
|
|
2
|
+
* src/utils.js
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { test } from 'node:test';
|
|
6
|
+
import assert from 'node:assert/strict';
|
|
7
|
+
|
|
8
|
+
// Importing utils requires Leaflet namespaces, but these arithmetic tests do not use them.
|
|
9
|
+
globalThis.L = { DomEvent: {}, Util: {}, DomUtil: {} };
|
|
10
|
+
const { iAvg, iMin, iMax, iSum } = await import('./utils.js');
|
|
11
|
+
|
|
12
|
+
const toFixed = (n) => +n.toFixed(2);
|
|
13
|
+
|
|
14
|
+
test('iAvg()', () => {
|
|
15
|
+
let avg;
|
|
16
|
+
avg = iAvg(100, undefined, 1); assert.strictEqual(toFixed(avg), 100); // average for [100] is 100
|
|
17
|
+
avg = iAvg(100, avg, 2); assert.strictEqual(toFixed(avg), 100); // average for [100, 100] is 100
|
|
18
|
+
avg = iAvg(200, avg, 3); assert.strictEqual(toFixed(avg), 133.33); // average for [100, 100, 200] is 133.33
|
|
19
|
+
avg = iAvg(200, avg, 4); assert.strictEqual(toFixed(avg), 150); // average for [100, 100, 200, 200] is 150
|
|
20
|
+
avg = iAvg(NaN, avg, 5); assert.ok(isNaN(avg)); // average for [100, 100, 200, 200, NaN] is NaN
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('iMin()', () => {
|
|
24
|
+
let min;
|
|
25
|
+
min = iMin(100, undefined); assert.strictEqual(toFixed(min), 100); // min for [100] is 100
|
|
26
|
+
min = iMin(NaN, min); assert.strictEqual(toFixed(min), 100); // min for [100, NaN] is 100
|
|
27
|
+
min = iMin(0, min); assert.strictEqual(toFixed(min), 0); // min for [100, NaN, 0] is 0
|
|
28
|
+
min = iMin(-200, min); assert.strictEqual(toFixed(min), -200); // min for [100, NaN, 0, -200] is -200
|
|
29
|
+
min = iMin(200, min); assert.strictEqual(toFixed(min), -200); // min for [100, NaN, 0, -200, 200] is -200
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('iMax()', () => {
|
|
33
|
+
let max;
|
|
34
|
+
max = iMax(100, undefined); assert.strictEqual(toFixed(max), 100); // max for [100] is 100
|
|
35
|
+
max = iMax(NaN, max); assert.strictEqual(toFixed(max), 100); // max for [100, NaN] is 100
|
|
36
|
+
max = iMax(0, max); assert.strictEqual(toFixed(max), 100); // max for [100, NaN, 0] is 100
|
|
37
|
+
max = iMax(-200, max); assert.strictEqual(toFixed(max), 100); // max for [100, NaN, 0, -200] is 100
|
|
38
|
+
max = iMax(200, max); assert.strictEqual(toFixed(max), 200); // max for [100, NaN, 0, -200, 200] is 200
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('iSum()', () => {
|
|
42
|
+
let sum;
|
|
43
|
+
sum = iSum(10.25, undefined); assert.strictEqual(toFixed(sum), 10.25); // sum for [10.25] is 10.25
|
|
44
|
+
sum = iSum(0, sum); assert.strictEqual(toFixed(sum), 10.25); // sum for [10.25, 0] is 10.25
|
|
45
|
+
sum = iSum(-0.25, sum); assert.strictEqual(toFixed(sum), 10); // sum for [10.25, 0, -0.25] is 10
|
|
46
|
+
sum = iSum(-10, sum); assert.strictEqual(toFixed(sum), 0); // sum for [10.25, 0, -0.25, -10] is 0
|
|
47
|
+
sum = iSum(NaN, sum); assert.ok(isNaN(sum)); // sum for [10.25, 0, -0.25, -10, NaN] is NaN
|
|
48
|
+
});
|