Here is the code used to add Total Elevation Gain. The main code is in Track.java in the UpdateSpeedandElevation? method.
private transient float lastElevation = Float.NaN;
private transient float currentGain = Float.NaN;
private transient float totalGain = Float.NaN;
if (Float.isNaN(totalGain)){
totalGain = 0;
lastElevation = elevation;
}
if (!Float.isNaN(totalGain)) {
if (elevation > lastElevation){
currentGain = elevation - lastElevation;
totalGain += currentGain;
lastElevation = elevation;
} else {
lastElevation = elevation;
}
}
I think it goes without saying that you need to add a method in Track.java to getTotalGain and add it to the Summary Tile that I provided which I know needs know explanation as I largely learned from your code how to do this anyway. Hopefully, if you choose to implement the SummaryTile? or something similar that this will help round off the requests for what should be included in that view.