commit 0cc3dff544e67195d99f557ec1fbba012311258f
parent ab871f83ed130b84abb5eb083e9cfcdae3027fb9
Author: Sergej Orlov <wladimirych@gmail.com>
Date: Thu, 3 Aug 2017 00:15:51 +0300
[elevation profile] fixed error in grid lines values calculation when elevation range is abnormally big
Diffstat:
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/lib/leaflet.control.elevation-profile/index.js b/src/lib/leaflet.control.elevation-profile/index.js
@@ -479,7 +479,9 @@ const ElevationProfile = L.Class.extend({
var ticksNs = [3, 4, 5],
tickSteps = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000],
ticks = [],
- i, j, k, ticksN, tickStep, tick1, tick2;
+ i, j, k, ticksN, tickStep, tick1, tick2,
+ matchFound=false;
+
for (i = 0; i < tickSteps.length; i++) {
tickStep = tickSteps[i];
for (j = 0; j < ticksNs.length; j++) {
@@ -487,13 +489,19 @@ const ElevationProfile = L.Class.extend({
tick1 = Math.floor(minValue / tickStep);
tick2 = Math.ceil(maxValue / tickStep);
if ((tick2 - tick1) < ticksN) {
- for (k = tick1; k < tick1 + ticksN; k++) {
- ticks.push(k * tickStep);
- }
- return ticks;
+ matchFound = true;
+ break
}
}
+ if (matchFound) {
+ break;
+ }
}
+ for (k = tick1; k < tick1 + ticksN; k++) {
+ ticks.push(k * tickStep);
+ }
+ return ticks;
+
},
filterElevations: function(values, tolerance) {