@@ -1962,7 +1962,9 @@ Copyright (c) 2016 Dominik Moritz */
1962
1962
this.track_info = L.extend({}, this.track_info, {
1963
1963
distance: this._distance,
1964
1964
elevation_max: this._maxElevation,
1965
- elevation_min: this._minElevation
1965
+ elevation_min: this._minElevation,
1966
+ ascent : this._ascent,
1967
+ descent : this._descent
1966
1968
});
1967
1969
1968
1970
this._layers = this._layers || {};
@@ -2428,6 +2430,19 @@ Copyright (c) 2016 Dominik Moritz */
2428
2430
if (!isNaN(z)) {
2429
2431
eleMax = eleMax < z ? z : eleMax;
2430
2432
eleMin = eleMin > z ? z : eleMin;
2433
+
2434
+ // calculate new ascent or descent
2435
+ let dz = z - this._lastValidZ ;
2436
+ if (dz > 0){
2437
+ this.track_info.ascent = (this.track_info.ascent || 0) + dz; // Total Ascent
2438
+ this._ascent = this.track_info.ascent;
2439
+ }
2440
+ else if (dz < 0){
2441
+ this.track_info.descent = (this.track_info.descent || 0) - dz; // Total Descent
2442
+ this._descent = this.track_info.descent;
2443
+ }
2444
+
2445
+ // set up last valid z value
2431
2446
this._lastValidZ = z;
2432
2447
}
2433
2448
@@ -3549,9 +3564,11 @@ Copyright (c) 2016 Dominik Moritz */
3549
3564
this.track_info.distance = this._distance || 0;
3550
3565
this.track_info.elevation_max = this._maxElevation || 0;
3551
3566
this.track_info.elevation_min = this._minElevation || 0;
3567
+ this.track_info.ascent = this._ascent || 0;
3568
+ this.track_info.descent = this._descent || 0;
3552
3569
3553
3570
if (this.options.summary) {
3554
- this.summaryDiv.innerHTML += '<span class="totlen"><span class="summarylabel">' + L._("Total Length: ") + '</span><span class="summaryvalue">' + this.track_info.distance.toFixed(2) + ' ' + this._xLabel + '</span></span><span class="maxele"><span class="summarylabel">' + L._("Max Elevation: ") + '</span><span class="summaryvalue">' + this.track_info.elevation_max.toFixed(2) + ' ' + this._yLabel + '</span></span><span class="minele"><span class="summarylabel">' + L._("Min Elevation: ") + '</span><span class="summaryvalue">' + this.track_info.elevation_min.toFixed(2) + ' ' + this._yLabel + '</span></span>';
3571
+ this.summaryDiv.innerHTML += '<span class="totlen"><span class="summarylabel">' + L._("Total Length: ") + '</span><span class="summaryvalue">' + this.track_info.distance.toFixed(2) + ' ' + this._xLabel + '</span></span><span class="maxele"><span class="summarylabel">' + L._("Max Elevation: ") + '</span><span class="summaryvalue">' + this.track_info.elevation_max.toFixed(2) + ' ' + this._yLabel + '</span></span><span class="minele"><span class="summarylabel">' + L._("Min Elevation: ") + '</span><span class="summaryvalue">' + this.track_info.elevation_min.toFixed(2) + ' ' + this._yLabel + '</span></span><span class="totasc"><span class="summarylabel">' + L._("Total Ascent: ") + '</span><span class="summaryvalue">' + this.track_info.ascent.toFixed(0) + ' ' + this._yLabel + '</span></span><span class="totdesc"><span class="summarylabel">' + L._("Total Descent: ") + '</span><span class="summaryvalue">' + this.track_info.descent.toFixed(0) + ' ' + this._yLabel + '</span></span> ';
3555
3572
}
3556
3573
if (this.options.downloadLink && this._downloadURL) { // TODO: generate dynamically file content instead of using static file urls.
3557
3574
this.summaryDiv.innerHTML += '<span class="download"><a href="#">' + L._('Download') + '</a></span>';
@@ -5848,62 +5865,62 @@ function interpolateBetweenPoints(ptA, ptB, ratio) {
5848
5865
};
5849
5866
}
5850
5867
5851
- (function() {
5852
- // save these original methods before they are overwritten
5853
- var proto_initIcon = Waymark_L.Marker.prototype._initIcon;
5854
- var proto_setPos = Waymark_L.Marker.prototype._setPos;
5855
-
5856
- var oldIE = (Waymark_L.DomUtil.TRANSFORM === 'msTransform');
5857
-
5858
- Waymark_L.Marker.addInitHook(function () {
5859
- var iconOptions = this.options.icon && this.options.icon.options;
5860
- var iconAnchor = iconOptions && this.options.icon.options.iconAnchor;
5861
- if (iconAnchor) {
5862
- iconAnchor = (iconAnchor[0] + 'px ' + iconAnchor[1] + 'px');
5863
- }
5864
- this.options.rotationOrigin = this.options.rotationOrigin || iconAnchor || 'center bottom' ;
5865
- this.options.rotationAngle = this.options.rotationAngle || 0;
5866
-
5867
- // Ensure marker keeps rotated during dragging
5868
- this.on('drag', function(e) { e.target._applyRotation(); });
5869
- });
5870
-
5871
- Waymark_L.Marker.include({
5872
- _initIcon: function() {
5873
- proto_initIcon.call(this);
5874
- },
5875
-
5876
- _setPos: function (pos) {
5877
- proto_setPos.call(this, pos);
5878
- this._applyRotation();
5879
- },
5880
-
5881
- _applyRotation: function () {
5882
- if(this.options.rotationAngle) {
5883
- this._icon.style[Waymark_L.DomUtil.TRANSFORM+'Origin'] = this.options.rotationOrigin;
5884
-
5885
- if(oldIE) {
5886
- // for IE 9, use the 2D rotation
5887
- this._icon.style[Waymark_L.DomUtil.TRANSFORM] = 'rotate(' + this.options.rotationAngle + 'deg)';
5888
- } else {
5889
- // for modern browsers, prefer the 3D accelerated version
5890
- this._icon.style[Waymark_L.DomUtil.TRANSFORM] += ' rotateZ(' + this.options.rotationAngle + 'deg)';
5891
- }
5892
- }
5893
- },
5894
-
5895
- setRotationAngle: function(angle) {
5896
- this.options.rotationAngle = angle;
5897
- this.update();
5898
- return this;
5899
- },
5900
-
5901
- setRotationOrigin: function(origin) {
5902
- this.options.rotationOrigin = origin;
5903
- this.update();
5904
- return this;
5905
- }
5906
- });
5868
+ (function() {
5869
+ // save these original methods before they are overwritten
5870
+ var proto_initIcon = Waymark_L.Marker.prototype._initIcon;
5871
+ var proto_setPos = Waymark_L.Marker.prototype._setPos;
5872
+
5873
+ var oldIE = (Waymark_L.DomUtil.TRANSFORM === 'msTransform');
5874
+
5875
+ Waymark_L.Marker.addInitHook(function () {
5876
+ var iconOptions = this.options.icon && this.options.icon.options;
5877
+ var iconAnchor = iconOptions && this.options.icon.options.iconAnchor;
5878
+ if (iconAnchor) {
5879
+ iconAnchor = (iconAnchor[0] + 'px ' + iconAnchor[1] + 'px');
5880
+ }
5881
+ this.options.rotationOrigin = this.options.rotationOrigin || iconAnchor || 'center bottom' ;
5882
+ this.options.rotationAngle = this.options.rotationAngle || 0;
5883
+
5884
+ // Ensure marker keeps rotated during dragging
5885
+ this.on('drag', function(e) { e.target._applyRotation(); });
5886
+ });
5887
+
5888
+ Waymark_L.Marker.include({
5889
+ _initIcon: function() {
5890
+ proto_initIcon.call(this);
5891
+ },
5892
+
5893
+ _setPos: function (pos) {
5894
+ proto_setPos.call(this, pos);
5895
+ this._applyRotation();
5896
+ },
5897
+
5898
+ _applyRotation: function () {
5899
+ if(this.options.rotationAngle) {
5900
+ this._icon.style[Waymark_L.DomUtil.TRANSFORM+'Origin'] = this.options.rotationOrigin;
5901
+
5902
+ if(oldIE) {
5903
+ // for IE 9, use the 2D rotation
5904
+ this._icon.style[Waymark_L.DomUtil.TRANSFORM] = 'rotate(' + this.options.rotationAngle + 'deg)';
5905
+ } else {
5906
+ // for modern browsers, prefer the 3D accelerated version
5907
+ this._icon.style[Waymark_L.DomUtil.TRANSFORM] += ' rotateZ(' + this.options.rotationAngle + 'deg)';
5908
+ }
5909
+ }
5910
+ },
5911
+
5912
+ setRotationAngle: function(angle) {
5913
+ this.options.rotationAngle = angle;
5914
+ this.update();
5915
+ return this;
5916
+ },
5917
+
5918
+ setRotationOrigin: function(origin) {
5919
+ this.options.rotationOrigin = origin;
5920
+ this.update();
5921
+ return this;
5922
+ }
5923
+ });
5907
5924
})();
5908
5925
5909
5926
L$1.Symbol = L$1.Symbol || {};
@@ -7387,6 +7404,8 @@ var waymark_js_localize = {
7387
7404
label_total_length: "Total Length: ",
7388
7405
label_max_elevation: "Max. Elevation: ",
7389
7406
label_min_elevation: "Min. Elevation: ",
7407
+ label_ascent: "Total Ascent: ",
7408
+ label_descent: "Total Descent: ",
7390
7409
//Editor
7391
7410
add_line_title: "Draw a Line",
7392
7411
add_photo_title: "Upload an Image",
@@ -9213,6 +9232,8 @@ function Waymark_Map_Viewer() {
9213
9232
"Total Length: ": waymark_js.lang.label_total_length,
9214
9233
"Max Elevation: ": waymark_js.lang.label_max_elevation,
9215
9234
"Min Elevation: ": waymark_js.lang.label_min_elevation,
9235
+ "Total Ascent: ": waymark_js.lang.label_ascent,
9236
+ "Total Descent: ": waymark_js.lang.label_descent,
9216
9237
});
9217
9238
Waymark_L.setLocale("waymark");
9218
9239
0 commit comments