Esempio n. 1
0
bool TcxLap::isEmpty() {
    vector<TcxTrack*>::iterator it;
    for ( it=trackList.begin() ; it < trackList.end(); ++it )
    {
        TcxTrack* track = *it;
        if (!track->isEmpty()) {
            return false;
        }
    }
    return true;
}
Esempio n. 2
0
string TcxLap::getStartTime() {
    vector<TcxTrack*>::iterator it;
    for ( it=trackList.begin() ; it < trackList.end(); it++ )
    {
        TcxTrack* track = *it;
        string startTime = track->getStartTime();
        if (startTime.length() > 0) {
            return startTime;
        }
    }
    return "1970-01-01T00:00:00Z";
}
Esempio n. 3
0
string TcxLap::getEndTime() {
    string endTime="";
    vector<TcxTrack*>::reverse_iterator it;
    for ( it=trackList.rbegin() ; it != trackList.rend(); ++it )
    {
        TcxTrack* track = *it;
        endTime = track->getEndTime();
        if (endTime.length() > 0) {
            return endTime;
        }
    }
    return this->startTime;
}
Esempio n. 4
0
string TcxLap::getStartTime() {
    vector<TcxTrack*>::iterator it;
    for ( it=trackList.begin() ; it < trackList.end(); ++it )
    {
        TcxTrack* track = *it;
        string startTime = track->getStartTime();
        if (startTime.length() > 0) {
            this->startTime = startTime;
            return startTime;
        }
    }
    return this->startTime;
}
Esempio n. 5
0
void TcxLap::calculateDistanceMeters() {
    double totalDistanceMeters = 0;

    vector<TcxTrack*>::iterator it;
    for ( it=trackList.begin() ; it < trackList.end(); ++it )
    {
        TcxTrack* track = *it;
        totalDistanceMeters += track->calculateDistanceMeters();
    }
    char totalDistanceBuf[50];
    snprintf(&totalDistanceBuf[0], sizeof(totalDistanceBuf), "%.2f", totalDistanceMeters);
    this->distanceMeters=totalDistanceBuf;
}
Esempio n. 6
0
void TcxLap::calculateTotalTimeSeconds() {
    double totalTime = 0;

    vector<TcxTrack*>::iterator it;
    for ( it=trackList.begin() ; it < trackList.end(); ++it )
    {
        TcxTrack* track = *it;
        totalTime += track->calculateTotalTime();
    }
    char totalTimeBuf[50];
    snprintf(&totalTimeBuf[0], sizeof(totalTimeBuf), "%.2f", totalTime);
    this->totalTimeSeconds=totalTimeBuf;
}
Esempio n. 7
0
void TcxLap::calculateMaximumHeartRateBpm() {
    vector<TcxTrack*>::iterator it;
    int maxHeartRate = 0;
    for ( it=trackList.begin() ; it < trackList.end(); ++it )
    {
        TcxTrack* track = *it;
        int currentMaxHeartRate = track->getMaxHeartRate();
        maxHeartRate = (currentMaxHeartRate > maxHeartRate) ? currentMaxHeartRate : maxHeartRate;
    }
    if (maxHeartRate > 0) {
    	stringstream ss;
    	ss << maxHeartRate;
    	this->maximumHeartRateBpm=ss.str();
    }
}
Esempio n. 8
0
TiXmlElement * TcxLap::getGpxTiXml() {
    TiXmlElement * segment = new TiXmlElement("trkseg");

    vector<TcxTrack*>::iterator it;
    for ( it=trackList.begin() ; it < trackList.end(); ++it )
    {
        TcxTrack* track = *it;
        vector<TiXmlElement *> trkPointList = track->getGpxTiXml();
        vector<TiXmlElement *>::iterator it;
        for ( it=trkPointList.begin() ; it < trkPointList.end(); ++it ) {
            TiXmlElement * elem = *it;
            segment->LinkEndChild(elem);
        }
    }

    return segment;
}
Esempio n. 9
0
TiXmlElement * TcxLap::getTiXml(bool readTrackData) {
    TiXmlElement * xmlLap = new TiXmlElement("Lap");

    xmlLap->SetAttribute("StartTime",getStartTime());

    if (this->totalTimeSeconds.length() == 0) {
        calculateTotalTimeSeconds();
    }
    TiXmlElement * xmlTotalTimeSeconds = new TiXmlElement("TotalTimeSeconds");
    xmlTotalTimeSeconds->LinkEndChild(new TiXmlText(this->totalTimeSeconds));
    xmlLap->LinkEndChild(xmlTotalTimeSeconds);

    if (this->distanceMeters.length() == 0) {
        calculateDistanceMeters();
    }
    TiXmlElement * xmlDistanceMeters = new TiXmlElement("DistanceMeters");
    xmlDistanceMeters->LinkEndChild(new TiXmlText(this->distanceMeters));
    xmlLap->LinkEndChild(xmlDistanceMeters);

    if (this->maximumSpeed.length() > 0) {
        TiXmlElement * xmlMaxSpeed = new TiXmlElement("MaximumSpeed");
        xmlMaxSpeed->LinkEndChild(new TiXmlText(this->maximumSpeed));
        xmlLap->LinkEndChild(xmlMaxSpeed);
    }

    if (this->calories.length() == 0) {
        calculateCalories();
    }
    TiXmlElement * xmlCalories = new TiXmlElement("Calories");
    xmlCalories->LinkEndChild(new TiXmlText(this->calories));
    xmlLap->LinkEndChild(xmlCalories);

    if (this->averageHeartRateBpm.length() > 0) {
        //TODO: Think about calculating averageHeartRateBpm value
        TiXmlElement * xmlAvgHeart = new TiXmlElement("AverageHeartRateBpm");
        //xmlAvgHeart->SetAttribute("xsi:type","HeartRateInBeatsPerMinute_t");
        TiXmlElement * xmlValue = new TiXmlElement("Value");
        this->averageHeartRateBpm = TrainingCenterDatabase::limitIntValue(this->averageHeartRateBpm, 0,255);
        xmlValue->LinkEndChild(new TiXmlText(this->averageHeartRateBpm));
        xmlAvgHeart->LinkEndChild(xmlValue);
        xmlLap->LinkEndChild(xmlAvgHeart);
    }

    if (this->maximumHeartRateBpm.length() == 0) {
    	calculateMaximumHeartRateBpm();
    }

    if (this->maximumHeartRateBpm.length() > 0) {
        TiXmlElement * xmlAvgHeart = new TiXmlElement("MaximumHeartRateBpm");
        //xmlAvgHeart->SetAttribute("xsi:type","HeartRateInBeatsPerMinute_t");
        TiXmlElement * xmlValue = new TiXmlElement("Value");
        this->maximumHeartRateBpm = TrainingCenterDatabase::limitIntValue(this->maximumHeartRateBpm, 0,255);
        xmlValue->LinkEndChild(new TiXmlText(this->maximumHeartRateBpm));
        xmlAvgHeart->LinkEndChild(xmlValue);
        xmlLap->LinkEndChild(xmlAvgHeart);
    }

    TiXmlElement * xmlIntensity = new TiXmlElement("Intensity");
    xmlIntensity->LinkEndChild(new TiXmlText(getIntensity(this->intensity)));
    xmlLap->LinkEndChild(xmlIntensity);

    if ((this->cadence.length() > 0) && (this->cadenceSensorType != TrainingCenterDatabase::UndefinedCadenceType)) {
        this->cadence = TrainingCenterDatabase::limitIntValue(this->cadence, 0,255);
        if (this->cadence != "255") {
            if (this->cadenceSensorType == TrainingCenterDatabase::Bike) {
                TiXmlElement * xmlCadence = new TiXmlElement("Cadence");
                xmlCadence->LinkEndChild(new TiXmlText(this->cadence));
                xmlLap->LinkEndChild(xmlCadence);
            }
        }
    }

    TiXmlElement * xmlTriggerMethod = new TiXmlElement("TriggerMethod");
    xmlTriggerMethod->LinkEndChild(new TiXmlText(getTriggerMethod(this->triggerMethod)));
    xmlLap->LinkEndChild(xmlTriggerMethod);

    if (readTrackData) {
        vector<TcxTrack*>::iterator it;
        for ( it=trackList.begin() ; it < trackList.end(); ++it )
        {
            TcxTrack* track = *it;
            if (!track->isEmpty()) {
                xmlLap->LinkEndChild(track->getTiXml());
            }
        }
    }

    TiXmlElement * xmlLapExtensions = NULL;
    if ((this->cadence.length() > 0) && (this->cadenceSensorType != TrainingCenterDatabase::UndefinedCadenceType)) {
        if (this->cadence != "255") {
            if (this->cadenceSensorType != TrainingCenterDatabase::Bike) {
                if (xmlLapExtensions == NULL) {
                    xmlLapExtensions = new TiXmlElement("Extensions");
                    xmlLap->LinkEndChild(xmlLapExtensions);
                }

                TiXmlElement * xmlLX = new TiXmlElement("LX");
                xmlLX->SetAttribute("xmlns","http://www.garmin.com/xmlschemas/ActivityExtension/v2");
                xmlLapExtensions->LinkEndChild(xmlLX);
                TiXmlElement * xmlAvgRunCadence = new TiXmlElement("AvgRunCadence");
                xmlAvgRunCadence->LinkEndChild(new TiXmlText(this->cadence));
                xmlLX->LinkEndChild(xmlAvgRunCadence);
            }
        }
    }

    if ((this->maxCadence.length() > 0) && (this->maxCadence != "255")) {
        if (xmlLapExtensions == NULL) {
            xmlLapExtensions = new TiXmlElement("Extensions");
            xmlLap->LinkEndChild(xmlLapExtensions);
        }

        string name = "MaxBikeCadence";
        if (this->cadenceSensorType == TrainingCenterDatabase::Footpod) {
        	name = "MaxRunCadence";
        }

        TiXmlElement * xmlLX = new TiXmlElement("LX");
        xmlLX->SetAttribute("xmlns","http://www.garmin.com/xmlschemas/ActivityExtension/v2");
        xmlLapExtensions->LinkEndChild(xmlLX);
        TiXmlElement * xmlMaxCadence = new TiXmlElement(name);
        xmlMaxCadence->LinkEndChild(new TiXmlText(this->maxCadence));
        xmlLX->LinkEndChild(xmlMaxCadence);
    }

    if (this->avgSpeed.length() > 0) {
        if (xmlLapExtensions == NULL) {
            xmlLapExtensions = new TiXmlElement("Extensions");
            xmlLap->LinkEndChild(xmlLapExtensions);
        }

        TiXmlElement * xmlLX = new TiXmlElement("LX");
        xmlLX->SetAttribute("xmlns","http://www.garmin.com/xmlschemas/ActivityExtension/v2");
        xmlLapExtensions->LinkEndChild(xmlLX);
        TiXmlElement * xmlAvgSpeed = new TiXmlElement("AvgSpeed");
        xmlAvgSpeed->LinkEndChild(new TiXmlText(this->avgSpeed));
        xmlLX->LinkEndChild(xmlAvgSpeed);
    }

    if ((this->avgPower.length() > 0) && (this->avgPower != "65535")) {
        if (xmlLapExtensions == NULL) {
            xmlLapExtensions = new TiXmlElement("Extensions");
            xmlLap->LinkEndChild(xmlLapExtensions);
        }

        TiXmlElement * xmlLX = new TiXmlElement("LX");
        xmlLX->SetAttribute("xmlns","http://www.garmin.com/xmlschemas/ActivityExtension/v2");
        xmlLapExtensions->LinkEndChild(xmlLX);

        TiXmlElement * xmlAvgPower = new TiXmlElement("AvgWatts");
        xmlAvgPower->LinkEndChild(new TiXmlText(this->avgPower));
        xmlLX->LinkEndChild(xmlAvgPower);
    }

    if ((this->maxPower.length() > 0) && (this->maxPower != "65535")) {
        if (xmlLapExtensions == NULL) {
            xmlLapExtensions = new TiXmlElement("Extensions");
            xmlLap->LinkEndChild(xmlLapExtensions);
        }

        TiXmlElement * xmlLX = new TiXmlElement("LX");
        xmlLX->SetAttribute("xmlns","http://www.garmin.com/xmlschemas/ActivityExtension/v2");
        xmlLapExtensions->LinkEndChild(xmlLX);

        TiXmlElement * xmlMaxPower = new TiXmlElement("MaxWatts");
        xmlMaxPower->LinkEndChild(new TiXmlText(this->maxPower));
        xmlLX->LinkEndChild(xmlMaxPower);
    }

    if (this->steps.length() > 0) {
        if (xmlLapExtensions == NULL) {
            xmlLapExtensions = new TiXmlElement("Extensions");
            xmlLap->LinkEndChild(xmlLapExtensions);
        }

        TiXmlElement * xmlLX = new TiXmlElement("LX");
        xmlLX->SetAttribute("xmlns","http://www.garmin.com/xmlschemas/ActivityExtension/v2");
        xmlLapExtensions->LinkEndChild(xmlLX);
        TiXmlElement * xmlSteps = new TiXmlElement("Steps");
        xmlSteps->LinkEndChild(new TiXmlText(this->steps));
        xmlLX->LinkEndChild(xmlSteps);
    }

    return xmlLap;
}