@raruto/leaflet-elevation 2.2.3 → 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/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
@@ -1,85 +1,85 @@
1
- import * as _ from './utils';
2
-
3
- export var Options = {
4
- autofitBounds: true,
5
- autohide: false,
6
- autohideMarker: true,
7
- almostover: true,
8
- altitude: true,
9
- closeBtn: true,
10
- collapsed: false,
11
- detached: true,
12
- distance: true,
13
- distanceMarkers: { lazy: true, distance: true, direction: true },
14
- dragging: !L.Browser.mobile,
15
- downloadLink: 'link',
16
- elevationDiv: "#elevation-div",
17
- followMarker: true,
18
- imperial: false,
19
- legend: true,
20
- handlers: ["Distance", "Time", "Altitude", "Slope", "Speed", "Acceleration"],
21
- hotline: 'elevation',
22
- marker: 'elevation-line',
23
- markerIcon: L.divIcon({
24
- className: 'elevation-position-marker',
25
- html: '<i class="elevation-position-icon"></i>',
26
- iconSize: [32, 32],
27
- iconAnchor: [16, 16],
28
- }),
29
- position: "topright",
30
- polyline: {
31
- className: 'elevation-polyline',
32
- color: '#000',
33
- opacity: 0.75,
34
- weight: 5,
35
- lineCap: 'round'
36
- },
37
- polylineSegments: {
38
- className: 'elevation-polyline-segments',
39
- color: '#F00',
40
- interactive: false,
41
- },
42
- preferCanvas: false,
43
- reverseCoords: false,
44
- ruler: true,
45
- theme: "lightblue-theme",
46
- summary: 'inline',
47
- slope: false,
48
- speed: false,
49
- time: true,
50
- timeFactor: 3600,
51
- timestamps: false,
52
- trkStart: L.circleMarker([0,0], { className: 'start-marker', radius: 6, weight: 2, color: '#fff', fillColor: '#00d800', fillOpacity: 1, interactive: false }),
53
- trkEnd: L.circleMarker([0,0], { className: 'end-marker', radius: 6, weight: 2, color: '#fff', fillColor: '#ff0606', fillOpacity: 1, interactive: false }),
54
- waypoints: true,
55
- wptIcons: {
56
- '': L.divIcon({
57
- className: 'elevation-waypoint-marker',
58
- html: '<i class="elevation-waypoint-icon default"></i>',
59
- iconSize: [30, 30],
60
- iconAnchor: [8, 30],
61
- }),
62
- },
63
- wptLabels: true,
64
- xAttr: "dist",
65
- xLabel: "km",
66
- yAttr: "z",
67
- yLabel: "m",
68
- zFollow: false,
69
- zooming: !L.Browser.Mobile,
70
-
71
- // Quite uncommon and undocumented options
72
- margins: { top: 30, right: 30, bottom: 30, left: 40 },
73
- height: (screen.height * 0.3) || 200,
74
- width: (screen.width * 0.6) || 600,
75
- xTicks: undefined,
76
- yTicks: undefined,
77
-
78
- decimalsX: 2,
79
- decimalsY: 0,
80
- forceAxisBounds: false,
81
- interpolation: "curveLinear",
82
- skipNullZCoords: false,
83
- yAxisMax: undefined,
84
- yAxisMin: undefined,
85
- };
1
+ import * as _ from './utils';
2
+
3
+ export var Options = {
4
+ autofitBounds: true,
5
+ autohide: false,
6
+ autohideMarker: true,
7
+ almostover: true,
8
+ altitude: true,
9
+ closeBtn: true,
10
+ collapsed: false,
11
+ detached: true,
12
+ distance: true,
13
+ distanceMarkers: { lazy: true, distance: true, direction: true },
14
+ dragging: !L.Browser.mobile,
15
+ downloadLink: 'link',
16
+ elevationDiv: "#elevation-div",
17
+ followMarker: true,
18
+ imperial: false,
19
+ legend: true,
20
+ handlers: ["Distance", "Time", "Altitude", "Slope", "Speed", "Acceleration"],
21
+ hotline: 'elevation',
22
+ marker: 'elevation-line',
23
+ markerIcon: L.divIcon({
24
+ className: 'elevation-position-marker',
25
+ html: '<i class="elevation-position-icon"></i>',
26
+ iconSize: [32, 32],
27
+ iconAnchor: [16, 16],
28
+ }),
29
+ position: "topright",
30
+ polyline: {
31
+ className: 'elevation-polyline',
32
+ color: '#000',
33
+ opacity: 0.75,
34
+ weight: 5,
35
+ lineCap: 'round'
36
+ },
37
+ polylineSegments: {
38
+ className: 'elevation-polyline-segments',
39
+ color: '#F00',
40
+ interactive: false,
41
+ },
42
+ preferCanvas: false,
43
+ reverseCoords: false,
44
+ ruler: true,
45
+ theme: "lightblue-theme",
46
+ summary: 'inline',
47
+ slope: false,
48
+ speed: false,
49
+ time: true,
50
+ timeFactor: 3600,
51
+ timestamps: false,
52
+ trkStart: { className: 'start-marker', radius: 6, weight: 2, color: '#fff', fillColor: '#00d800', fillOpacity: 1, interactive: false },
53
+ trkEnd: { className: 'end-marker', radius: 6, weight: 2, color: '#fff', fillColor: '#ff0606', fillOpacity: 1, interactive: false },
54
+ waypoints: true,
55
+ wptIcons: {
56
+ '': L.divIcon({
57
+ className: 'elevation-waypoint-marker',
58
+ html: '<i class="elevation-waypoint-icon default"></i>',
59
+ iconSize: [30, 30],
60
+ iconAnchor: [8, 30],
61
+ }),
62
+ },
63
+ wptLabels: true,
64
+ xAttr: "dist",
65
+ xLabel: "km",
66
+ yAttr: "z",
67
+ yLabel: "m",
68
+ zFollow: false,
69
+ zooming: !L.Browser.Mobile,
70
+
71
+ // Quite uncommon and undocumented options
72
+ margins: { top: 30, right: 30, bottom: 30, left: 40 },
73
+ height: (screen.height * 0.3) || 200,
74
+ width: (screen.width * 0.6) || 600,
75
+ xTicks: undefined,
76
+ yTicks: undefined,
77
+
78
+ decimalsX: 2,
79
+ decimalsY: 0,
80
+ forceAxisBounds: false,
81
+ interpolation: "curveLinear",
82
+ skipNullZCoords: false,
83
+ yAxisMax: undefined,
84
+ yAxisMin: undefined,
85
+ };
package/src/utils.js CHANGED
@@ -1,159 +1,159 @@
1
- /**
2
- * TODO: exget computed styles of theese values from actual "CSS vars"
3
- **/
4
- export const Colors = {
5
- 'lightblue': { area: '#3366CC', alpha: 0.45, stroke: '#3366CC' },
6
- 'magenta' : { area: '#FF005E' },
7
- 'yellow' : { area: '#FF0' },
8
- 'purple' : { area: '#732C7B' },
9
- 'steelblue': { area: '#4682B4' },
10
- 'red' : { area: '#F00' },
11
- 'lime' : { area: '#9CC222', line: '#566B13' }
12
- };
13
-
14
- const SEC = 1000;
15
- const MIN = SEC * 60;
16
- const HOUR = MIN * 60;
17
- const DAY = HOUR * 24;
18
-
19
- /**
20
- * Convert a time (millis) to a human readable duration string (%Dd %H:%M'%S")
21
- */
22
- export function formatTime(t) {
23
- let d = Math.floor(t / DAY);
24
- let h = Math.floor( (t - d * DAY) / HOUR);
25
- let m = Math.floor( (t - d * DAY - h * HOUR) / MIN);
26
- let s = Math.round( (t - d * DAY - h * HOUR - m * MIN) / SEC);
27
- if ( s === 60 ) { m++; s = 0; }
28
- if ( m === 60 ) { h++; m = 0; }
29
- if ( h === 24 ) { d++; h = 0; }
30
- return (d ? d + "d " : '') + h.toString().padStart(2, 0) + ':' + m.toString().padStart(2, 0) + "'" + s.toString().padStart(2, 0) + '"';
31
- }
32
-
33
- /**
34
- * Convert a time (millis) to human readable date string (dd-mm-yyyy hh:mm:ss)
35
- */
36
- export function formatDate(format) {
37
- if (!format) {
38
- return (time) => (new Date(time)).toLocaleString().replaceAll('/', '-').replaceAll(',', ' ');
39
- } else if (format == 'time') {
40
- return (time) => (new Date(time)).toLocaleTimeString();
41
- } else if (format == 'date') {
42
- return (time) => (new Date(time)).toLocaleDateString();
43
- }
44
- return (time) => format(time);
45
- }
46
-
47
- /**
48
- * Generate download data event.
49
- */
50
- export function saveFile(dataURI, fileName) {
51
- let a = create('a', '', { href: dataURI, target: '_new', download: fileName || "", style: "display:none;" });
52
- let b = document.body;
53
- b.appendChild(a);
54
- a.click();
55
- b.removeChild(a);
56
- }
57
-
58
-
59
- /**
60
- * Convert SVG Path into Path2D and then update canvas
61
- */
62
- export function drawCanvas(ctx, path) {
63
- path.classed('canvas-path', true);
64
-
65
- ctx.beginPath();
66
- ctx.moveTo(0, 0);
67
- let p = new Path2D(path.attr('d'));
68
-
69
- ctx.strokeStyle = path.attr('stroke');
70
- ctx.fillStyle = path.attr('fill');
71
- ctx.lineWidth = 1.25;
72
- ctx.globalCompositeOperation = 'source-over';
73
-
74
- // stroke opacity
75
- ctx.globalAlpha = path.attr('stroke-opacity') || 0.3;
76
- ctx.stroke(p);
77
-
78
- // fill opacity
79
- ctx.globalAlpha = path.attr('fill-opacity') || 0.45;
80
- ctx.fill(p);
81
-
82
- ctx.globalAlpha = 1;
83
-
84
- ctx.closePath();
85
- }
86
-
87
- /**
88
- * Loop and extract GPX Extensions handled by "@tmcw/toGeoJSON" (eg. "coordinateProperties" > "times")
89
- */
90
- export function coordPropsToMeta(coordProps, name, parser) {
91
- return coordProps && (({props, point, id, isMulti }) => {
92
- if (props) {
93
- for (const key of coordProps) {
94
- if (key in props) {
95
- point.meta[name] = (parser || parseNumeric).call(this, (isMulti ? props[key][isMulti] : props[key]), id);
96
- break;
97
- }
98
- }
99
- }
100
- });
101
- }
102
-
103
- /**
104
- * Extract numeric property (id) from GeoJSON object
105
- */
106
- export const parseNumeric = (property, id) => parseInt((typeof property === 'object' ? property[id] : property));
107
-
108
- /**
109
- * Extract datetime property (id) from GeoJSON object
110
- */
111
- export const parseDate = (property, id) => new Date(Date.parse((typeof property === 'object' ? property[id] : property)));
112
-
113
- /**
114
- * A little bit shorter than L.DomUtil
115
- */
116
- export const addClass = (n, str) => n && str.split(" ").every(s => s && L.DomUtil.addClass(n, s));
117
- export const removeClass = (n, str) => n && str.split(" ").every(s => s && L.DomUtil.removeClass(n, s));
118
- export const toggleClass = (n, str, cond) => (cond ? addClass : removeClass)(n, str);
119
- export const replaceClass = (n, rem, add) => (rem && removeClass(n, rem)) || (add && addClass(n, add));
120
- export const style = (n, k, v) => (typeof v === "undefined" && L.DomUtil.getStyle(n, k)) || n.style.setProperty(k, v);
121
- export const toggleStyle = (n, k, v, cond) => style(n, k, cond ? v : '');
122
- export const setAttributes = (n, attrs) => { for (let k in attrs) { n.setAttribute(k, attrs[k]); } };
123
- export const toggleEvent = (el, e, fn, cond) => el[cond ? 'on' : 'off'](e, fn);
124
- export const create = (tag, str, attrs, n) => { let elem = L.DomUtil.create(tag, str || ""); if (attrs) setAttributes(elem, attrs); if (n) append(n, elem); return elem; };
125
- export const append = (n, c) => n.appendChild(c);
126
- export const insert = (n, c, pos) => n.insertAdjacentElement(pos, c);
127
- export const select = (str, n) => (n || document).querySelector(str);
128
- export const each = (obj, fn) => { for (let i in obj) fn(obj[i], i); };
129
- export const randomId = () => Math.random().toString(36).substr(2, 9);
130
-
131
- /**
132
- * TODO: use generators instead? (ie. "yield")
133
- */
134
- export const iMax = (iVal, max = -Infinity) => (iVal > max ? iVal : max);
135
- export const iMin = (iVal, min = +Infinity) => (iVal < min ? iVal : min);
136
- export const iAvg = (iVal, avg = 0, idx = 1) => (iVal + avg * (idx - 1)) / idx;
137
- export const iSum = (iVal, sum = 0) => iVal + sum;
138
-
139
- /**
140
- * Alias for some leaflet core functions
141
- */
142
- export const { on, off } = L.DomEvent;
143
- export const { throttle, wrapNum } = L.Util;
144
- export const { hasClass } = L.DomUtil;
145
-
146
- /**
147
- * Limit floating point precision
148
- */
149
- export const round = L.Util.formatNum;
150
-
151
- /**
152
- * Limit a number between min / max values
153
- */
154
- export const clamp = (val, range) => range ? (val < range[0] ? range[0] : val > range[1] ? range[1] : val) : val;
155
-
156
- /**
157
- * Limit a delta difference between two values
158
- */
1
+ /**
2
+ * TODO: exget computed styles of theese values from actual "CSS vars"
3
+ **/
4
+ export const Colors = {
5
+ 'lightblue': { area: '#3366CC', alpha: 0.45, stroke: '#3366CC' },
6
+ 'magenta' : { area: '#FF005E' },
7
+ 'yellow' : { area: '#FF0' },
8
+ 'purple' : { area: '#732C7B' },
9
+ 'steelblue': { area: '#4682B4' },
10
+ 'red' : { area: '#F00' },
11
+ 'lime' : { area: '#9CC222', line: '#566B13' }
12
+ };
13
+
14
+ const SEC = 1000;
15
+ const MIN = SEC * 60;
16
+ const HOUR = MIN * 60;
17
+ const DAY = HOUR * 24;
18
+
19
+ /**
20
+ * Convert a time (millis) to a human readable duration string (%Dd %H:%M'%S")
21
+ */
22
+ export function formatTime(t) {
23
+ let d = Math.floor(t / DAY);
24
+ let h = Math.floor( (t - d * DAY) / HOUR);
25
+ let m = Math.floor( (t - d * DAY - h * HOUR) / MIN);
26
+ let s = Math.round( (t - d * DAY - h * HOUR - m * MIN) / SEC);
27
+ if ( s === 60 ) { m++; s = 0; }
28
+ if ( m === 60 ) { h++; m = 0; }
29
+ if ( h === 24 ) { d++; h = 0; }
30
+ return (d ? d + "d " : '') + h.toString().padStart(2, 0) + ':' + m.toString().padStart(2, 0) + "'" + s.toString().padStart(2, 0) + '"';
31
+ }
32
+
33
+ /**
34
+ * Convert a time (millis) to human readable date string (dd-mm-yyyy hh:mm:ss)
35
+ */
36
+ export function formatDate(format) {
37
+ if (!format) {
38
+ return (time) => (new Date(time)).toLocaleString().replaceAll('/', '-').replaceAll(',', ' ');
39
+ } else if (format == 'time') {
40
+ return (time) => (new Date(time)).toLocaleTimeString();
41
+ } else if (format == 'date') {
42
+ return (time) => (new Date(time)).toLocaleDateString();
43
+ }
44
+ return (time) => format(time);
45
+ }
46
+
47
+ /**
48
+ * Generate download data event.
49
+ */
50
+ export function saveFile(dataURI, fileName) {
51
+ let a = create('a', '', { href: dataURI, target: '_new', download: fileName || "", style: "display:none;" });
52
+ let b = document.body;
53
+ b.appendChild(a);
54
+ a.click();
55
+ b.removeChild(a);
56
+ }
57
+
58
+
59
+ /**
60
+ * Convert SVG Path into Path2D and then update canvas
61
+ */
62
+ export function drawCanvas(ctx, path) {
63
+ path.classed('canvas-path', true);
64
+
65
+ ctx.beginPath();
66
+ ctx.moveTo(0, 0);
67
+ let p = new Path2D(path.attr('d'));
68
+
69
+ ctx.strokeStyle = path.attr('stroke');
70
+ ctx.fillStyle = path.attr('fill');
71
+ ctx.lineWidth = 1.25;
72
+ ctx.globalCompositeOperation = 'source-over';
73
+
74
+ // stroke opacity
75
+ ctx.globalAlpha = path.attr('stroke-opacity') || 0.3;
76
+ ctx.stroke(p);
77
+
78
+ // fill opacity
79
+ ctx.globalAlpha = path.attr('fill-opacity') || 0.45;
80
+ ctx.fill(p);
81
+
82
+ ctx.globalAlpha = 1;
83
+
84
+ ctx.closePath();
85
+ }
86
+
87
+ /**
88
+ * Loop and extract GPX Extensions handled by "@tmcw/toGeoJSON" (eg. "coordinateProperties" > "times")
89
+ */
90
+ export function coordPropsToMeta(coordProps, name, parser) {
91
+ return coordProps && (({props, point, id, isMulti }) => {
92
+ if (props) {
93
+ for (const key of coordProps) {
94
+ if (key in props) {
95
+ point.meta[name] = (parser || parseNumeric).call(this, (isMulti ? props[key][isMulti] : props[key]), id);
96
+ break;
97
+ }
98
+ }
99
+ }
100
+ });
101
+ }
102
+
103
+ /**
104
+ * Extract numeric property (id) from GeoJSON object
105
+ */
106
+ export const parseNumeric = (property, id) => parseInt((typeof property === 'object' ? property[id] : property));
107
+
108
+ /**
109
+ * Extract datetime property (id) from GeoJSON object
110
+ */
111
+ export const parseDate = (property, id) => new Date(Date.parse((typeof property === 'object' ? property[id] : property)));
112
+
113
+ /**
114
+ * A little bit shorter than L.DomUtil
115
+ */
116
+ export const addClass = (n, str) => n && str.split(" ").every(s => s && L.DomUtil.addClass(n, s));
117
+ export const removeClass = (n, str) => n && str.split(" ").every(s => s && L.DomUtil.removeClass(n, s));
118
+ export const toggleClass = (n, str, cond) => (cond ? addClass : removeClass)(n, str);
119
+ export const replaceClass = (n, rem, add) => (rem && removeClass(n, rem)) || (add && addClass(n, add));
120
+ export const style = (n, k, v) => (typeof v === "undefined" && L.DomUtil.getStyle(n, k)) || n.style.setProperty(k, v);
121
+ export const toggleStyle = (n, k, v, cond) => style(n, k, cond ? v : '');
122
+ export const setAttributes = (n, attrs) => { for (let k in attrs) { n.setAttribute(k, attrs[k]); } };
123
+ export const toggleEvent = (el, e, fn, cond) => el[cond ? 'on' : 'off'](e, fn);
124
+ export const create = (tag, str, attrs, n) => { let elem = L.DomUtil.create(tag, str || ""); if (attrs) setAttributes(elem, attrs); if (n) append(n, elem); return elem; };
125
+ export const append = (n, c) => n.appendChild(c);
126
+ export const insert = (n, c, pos) => n.insertAdjacentElement(pos, c);
127
+ export const select = (str, n) => (n || document).querySelector(str);
128
+ export const each = (obj, fn) => { for (let i in obj) fn(obj[i], i); };
129
+ export const randomId = () => Math.random().toString(36).substr(2, 9);
130
+
131
+ /**
132
+ * TODO: use generators instead? (ie. "yield")
133
+ */
134
+ export const iMax = (iVal, max = -Infinity) => (iVal > max ? iVal : max);
135
+ export const iMin = (iVal, min = +Infinity) => (iVal < min ? iVal : min);
136
+ export const iAvg = (iVal, avg = 0, idx = 1) => (iVal + avg * (idx - 1)) / idx;
137
+ export const iSum = (iVal, sum = 0) => iVal + sum;
138
+
139
+ /**
140
+ * Alias for some leaflet core functions
141
+ */
142
+ export const { on, off } = L.DomEvent;
143
+ export const { throttle, wrapNum } = L.Util;
144
+ export const { hasClass } = L.DomUtil;
145
+
146
+ /**
147
+ * Limit floating point precision
148
+ */
149
+ export const round = L.Util.formatNum;
150
+
151
+ /**
152
+ * Limit a number between min / max values
153
+ */
154
+ export const clamp = (val, range) => range ? (val < range[0] ? range[0] : val > range[1] ? range[1] : val) : val;
155
+
156
+ /**
157
+ * Limit a delta difference between two values
158
+ */
159
159
  export const wrapDelta = (curr, prev, deltaMax) => Math.abs(curr - prev) > deltaMax ? prev + deltaMax * Math.sign(curr - prev) : curr;