Allow TTS Files for VideoSync. (#3354)

Rewrite TTSReader Stream Merge

Add gpi reset.
This commit is contained in:
ericchristoffersen
2020-02-27 07:56:42 -08:00
committed by GitHub
parent cee6f0329a
commit da3e8212cf
7 changed files with 360 additions and 259 deletions

View File

@@ -135,6 +135,8 @@ void ErgFile::parseZwift()
Points.clear();
Laps.clear();
gpi.Reset();
// parse the file
QFile zwo(filename);
QXmlInputSource source(&zwo);
@@ -194,6 +196,8 @@ void ErgFile::parseErg2(QString p)
Points.clear();
Laps.clear();
gpi.Reset();
// open the file
if (p == "" && ergFile.open(QIODevice::ReadOnly | QIODevice::Text) == false) {
valid = false;
@@ -259,6 +263,8 @@ void ErgFile::parseTacx()
Points.clear();
Laps.clear();
gpi.Reset();
// running totals
double rdist = 0; // running total for distance
double ralt = 200; // always start at 200 meters just to prettify the graph
@@ -705,6 +711,8 @@ void ErgFile::parseGpx()
Points.clear();
Laps.clear();
gpi.Reset();
// TTS File Gradient Should be smoothly interpolated from Altitude.
StrictGradient = false;
@@ -832,6 +840,8 @@ void ErgFile::parseTTS()
Points.clear();
Laps.clear();
gpi.Reset();
// TTS File Gradient Should be smoothly interpolated from Altitude.
StrictGradient = false;
@@ -861,8 +871,7 @@ void ErgFile::parseTTS()
// Enumerate the data types that are available.
bool fHasKm = ttsReader.hasKm();
bool fHasLat = ttsReader.hasLatitude();
bool fHasLon = ttsReader.hasLongitude();
bool fHasGPS = ttsReader.hasGPS();
bool fHasAlt = ttsReader.hasElevation();
bool fHasSlope = ttsReader.hasGradient();
@@ -877,20 +886,19 @@ void ErgFile::parseTTS()
prevPoint = NULL;
point = NULL;
nextPoint = &ttsPoints[1];
nextPoint = &ttsPoints[0];
double alt = 0;
if (fHasAlt) {
// Start with altitude of second point.
alt = ttsPoints[1].getElevation();
alt = ttsPoints[0].getElevation();
}
for (int i = 1; i <= pointCount; i++) { // first data point is actually the last...
for (int i = 0; i <= pointCount; i++) { // first data point is actually the last...
ErgFilePoint add;
prevPoint = point;
point = nextPoint;
nextPoint = ((i + 1) >= pointCount) ? &ttsPoints[0] : &ttsPoints[i + 1];
nextPoint = ((i + 1) >= pointCount) ? &ttsPoints[i] : &ttsPoints[i + 1];
// Determine slope to next point
double slope = 0.0;
@@ -922,8 +930,11 @@ void ErgFile::parseTTS()
add.y = alt;
add.val = slope;
if (fHasLat) add.lat = point->getLatitude();
if (fHasLon) add.lon = point->getLongitude();
if (fHasGPS) {
add.lat = point->getLatitude();
add.lon = point->getLongitude();
}
if (add.y > MaxWatts) MaxWatts = add.y;
Points.append(add);