Fixed problems with gulp-uglify
This commit is contained in:
parent
023e30073d
commit
544aab0716
2 changed files with 44 additions and 45 deletions
|
|
@ -15,7 +15,7 @@ BR.RoutingPathQuality = L.Control.extend({
|
||||||
incline: {
|
incline: {
|
||||||
title: i18next.t('map.route-quality-incline'),
|
title: i18next.t('map.route-quality-incline'),
|
||||||
icon: 'fa-line-chart',
|
icon: 'fa-line-chart',
|
||||||
provider: new HotlineProvider({
|
provider: new HotLineQualityProvider({
|
||||||
hotlineOptions: {
|
hotlineOptions: {
|
||||||
min: -15,
|
min: -15,
|
||||||
max: 15,
|
max: 15,
|
||||||
|
|
@ -27,7 +27,7 @@ BR.RoutingPathQuality = L.Control.extend({
|
||||||
renderer: renderer
|
renderer: renderer
|
||||||
},
|
},
|
||||||
valueFunction: function(latLng, prevLatLng) {
|
valueFunction: function(latLng, prevLatLng) {
|
||||||
var deltaAltitude = latLng.alt - prevLatLng.alt, // in m
|
const deltaAltitude = latLng.alt - prevLatLng.alt, // in m
|
||||||
distance = prevLatLng.distanceTo(latLng); // in m
|
distance = prevLatLng.distanceTo(latLng); // in m
|
||||||
if (distance === 0) {
|
if (distance === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -39,12 +39,11 @@ BR.RoutingPathQuality = L.Control.extend({
|
||||||
altitude: {
|
altitude: {
|
||||||
title: i18next.t('map.route-quality-altitude'),
|
title: i18next.t('map.route-quality-altitude'),
|
||||||
icon: 'fa-area-chart',
|
icon: 'fa-area-chart',
|
||||||
provider: new HotlineProvider({
|
provider: new HotLineQualityProvider({
|
||||||
hotlineOptions: {
|
hotlineOptions: {
|
||||||
renderer: renderer
|
renderer: renderer
|
||||||
},
|
},
|
||||||
valueFunction: function(latLng) {
|
valueFunction: function(latLng) {
|
||||||
feature = latLng.feature;
|
|
||||||
return latLng.alt;
|
return latLng.alt;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -52,12 +51,12 @@ BR.RoutingPathQuality = L.Control.extend({
|
||||||
cost: {
|
cost: {
|
||||||
title: i18next.t('map.route-quality-cost'),
|
title: i18next.t('map.route-quality-cost'),
|
||||||
icon: 'fa-usd',
|
icon: 'fa-usd',
|
||||||
provider: new HotlineProvider({
|
provider: new HotLineQualityProvider({
|
||||||
hotlineOptions: {
|
hotlineOptions: {
|
||||||
renderer: renderer
|
renderer: renderer
|
||||||
},
|
},
|
||||||
valueFunction: function(latLng) {
|
valueFunction: function(latLng) {
|
||||||
let feature = latLng.feature;
|
const feature = latLng.feature;
|
||||||
return (
|
return (
|
||||||
feature.cost.perKm +
|
feature.cost.perKm +
|
||||||
feature.cost.elev +
|
feature.cost.elev +
|
||||||
|
|
@ -77,14 +76,14 @@ BR.RoutingPathQuality = L.Control.extend({
|
||||||
this._map = map;
|
this._map = map;
|
||||||
this._routingSegments.addTo(map);
|
this._routingSegments.addTo(map);
|
||||||
|
|
||||||
let states = [];
|
var states = [],
|
||||||
var i,
|
i,
|
||||||
keys = Object.keys(this.providers),
|
keys = Object.keys(this.providers),
|
||||||
l = keys.length;
|
l = keys.length;
|
||||||
|
|
||||||
for (i = 0; i < l; ++i) {
|
for (i = 0; i < l; ++i) {
|
||||||
let provider = this.providers[keys[i]];
|
const provider = this.providers[keys[i]];
|
||||||
let nextState = keys[(i + 1) % l];
|
const nextState = keys[(i + 1) % l];
|
||||||
states.push({
|
states.push({
|
||||||
stateName: keys[i],
|
stateName: keys[i],
|
||||||
icon: provider.icon,
|
icon: provider.icon,
|
||||||
|
|
@ -119,56 +118,56 @@ BR.RoutingPathQuality = L.Control.extend({
|
||||||
|
|
||||||
_update: function(segments) {
|
_update: function(segments) {
|
||||||
this._routingSegments.clearLayers();
|
this._routingSegments.clearLayers();
|
||||||
let layers = this.providers[this.selectedProvider].provider.computeLayers(segments);
|
const layers = this.providers[this.selectedProvider].provider.computeLayers(segments);
|
||||||
if (layers) {
|
if (layers) {
|
||||||
for (let i = 0; i < layers.length; i++) {
|
for (var i = 0; i < layers.length; i++) {
|
||||||
this._routingSegments.addLayer(layers[i]);
|
this._routingSegments.addLayer(layers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
class HotlineProvider {
|
var HotLineQualityProvider = L.Class.extend({
|
||||||
constructor(options) {
|
initialize: function(options) {
|
||||||
this.hotlineOptions = options.hotlineOptions;
|
this.hotlineOptions = options.hotlineOptions;
|
||||||
this.valueFunction = options.valueFunction;
|
this.valueFunction = options.valueFunction;
|
||||||
}
|
},
|
||||||
|
|
||||||
computeLayers(segments) {
|
computeLayers: function(segments) {
|
||||||
let layers = [];
|
var layers = [];
|
||||||
if (segments) {
|
if (segments) {
|
||||||
let segmentLatLngs = [];
|
var segmentLatLngs = [];
|
||||||
for (let i = 0; segments && i < segments.length; i++) {
|
for (var i = 0; segments && i < segments.length; i++) {
|
||||||
let segment = segments[i];
|
const segment = segments[i];
|
||||||
segmentLatLngs.push(this._computeLatLngVals(segment));
|
segmentLatLngs.push(this._computeLatLngVals(segment));
|
||||||
}
|
}
|
||||||
let flatLines = segmentLatLngs.flat();
|
const flatLines = segmentLatLngs.flat();
|
||||||
|
|
||||||
if (flatLines.length > 0) {
|
if (flatLines.length > 0) {
|
||||||
let hotlineOptions = Object.assign(new Object(), this.hotlineOptions);
|
const hotlineOptions = Object.assign(new Object(), this.hotlineOptions);
|
||||||
if (!hotlineOptions.min && !hotlineOptions.max) {
|
if (!hotlineOptions.min && !hotlineOptions.max) {
|
||||||
let minMax = this._calcMinMaxValues(flatLines);
|
const minMax = this._calcMinMaxValues(flatLines);
|
||||||
hotlineOptions.min = minMax.min;
|
hotlineOptions.min = minMax.min;
|
||||||
hotlineOptions.max = minMax.max;
|
hotlineOptions.max = minMax.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < segmentLatLngs.length; i++) {
|
for (var i = 0; i < segmentLatLngs.length; i++) {
|
||||||
const line = segmentLatLngs[i];
|
const line = segmentLatLngs[i];
|
||||||
let hotline = L.hotline(line, hotlineOptions);
|
const hotline = L.hotline(line, hotlineOptions);
|
||||||
layers.push(hotline);
|
layers.push(hotline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return layers;
|
return layers;
|
||||||
}
|
},
|
||||||
|
|
||||||
_computeLatLngVals(segment) {
|
_computeLatLngVals: function(segment) {
|
||||||
let latLngVals = [],
|
var latLngVals = [],
|
||||||
segmentLatLngs = segment.getLatLngs(),
|
segmentLatLngs = segment.getLatLngs(),
|
||||||
segmentLength = segmentLatLngs.length;
|
segmentLength = segmentLatLngs.length;
|
||||||
|
|
||||||
for (let i = 0; i < segmentLength; i++) {
|
for (var i = 0; i < segmentLength; i++) {
|
||||||
var val = this.valueFunction.call(
|
const val = this.valueFunction.call(
|
||||||
this,
|
this,
|
||||||
segmentLatLngs[i],
|
segmentLatLngs[i],
|
||||||
segmentLatLngs[Math.max(i - 1, 0)],
|
segmentLatLngs[Math.max(i - 1, 0)],
|
||||||
|
|
@ -178,17 +177,17 @@ class HotlineProvider {
|
||||||
latLngVals.push(this._convertToArray(segmentLatLngs[i], val));
|
latLngVals.push(this._convertToArray(segmentLatLngs[i], val));
|
||||||
}
|
}
|
||||||
return latLngVals;
|
return latLngVals;
|
||||||
}
|
},
|
||||||
|
|
||||||
_convertToArray(latLng, val) {
|
_convertToArray: function(latLng, val) {
|
||||||
return [latLng.lat, latLng.lng, val];
|
return [latLng.lat, latLng.lng, val];
|
||||||
}
|
},
|
||||||
|
|
||||||
_calcMinMaxValues(lines) {
|
_calcMinMaxValues: function(lines) {
|
||||||
let min = lines[0][2],
|
var min = lines[0][2],
|
||||||
max = min;
|
max = min;
|
||||||
for (let i = 1; lines && i < lines.length; i++) {
|
for (var i = 1; lines && i < lines.length; i++) {
|
||||||
let line = lines[i];
|
const line = lines[i];
|
||||||
max = Math.max(max, line[2]);
|
max = Math.max(max, line[2]);
|
||||||
min = Math.min(min, line[2]);
|
min = Math.min(min, line[2]);
|
||||||
}
|
}
|
||||||
|
|
@ -200,4 +199,4 @@ class HotlineProvider {
|
||||||
max: max
|
max: max
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
|
||||||
|
|
@ -192,16 +192,16 @@ L.BRouter = L.Class.extend({
|
||||||
|
|
||||||
_assignFeatures: function(segment) {
|
_assignFeatures: function(segment) {
|
||||||
if (segment.feature.properties.messages) {
|
if (segment.feature.properties.messages) {
|
||||||
let featureMessages = segment.feature.properties.messages,
|
const featureMessages = segment.feature.properties.messages,
|
||||||
segmentLatLngs = segment.getLatLngs(),
|
segmentLatLngs = segment.getLatLngs(),
|
||||||
segmentLength = segmentLatLngs.length,
|
segmentLength = segmentLatLngs.length;
|
||||||
featureSegmentIndex = 0;
|
var featureSegmentIndex = 0;
|
||||||
|
|
||||||
for (let mi = 1; mi < featureMessages.length; mi++) {
|
for (var mi = 1; mi < featureMessages.length; mi++) {
|
||||||
var featureLatLng = this._getFeatureLatLng(featureMessages[mi]);
|
const featureLatLng = this._getFeatureLatLng(featureMessages[mi]);
|
||||||
|
|
||||||
for (let fi = featureSegmentIndex; fi < segmentLength; fi++) {
|
for (var fi = featureSegmentIndex; fi < segmentLength; fi++) {
|
||||||
let segmentLatLng = segmentLatLngs[fi],
|
const segmentLatLng = segmentLatLngs[fi],
|
||||||
featureMessage = featureMessages[mi];
|
featureMessage = featureMessages[mi];
|
||||||
|
|
||||||
segmentLatLng.feature = this._getFeature(featureMessage);
|
segmentLatLng.feature = this._getFeature(featureMessage);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue