1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-19 04:02:09 +01:00

Some more code cleanup

This commit is contained in:
Martin Tůma 2023-12-26 20:05:38 +01:00
parent f9b4cd991f
commit 4a82055867
2 changed files with 9 additions and 6 deletions

View File

@ -13,7 +13,7 @@ QDebug operator<<(QDebug dbg, const SMLParser::Sensors &sensors)
#endif // QT_NO_DEBUG #endif // QT_NO_DEBUG
void SMLParser::sample(SegmentData &segment, QMap<QDateTime, Sensors> &map) void SMLParser::sample(SegmentData &segment, SensorsMap &map)
{ {
QDateTime timestamp; QDateTime timestamp;
Sensors sensors; Sensors sensors;
@ -97,19 +97,20 @@ void SMLParser::sample(SegmentData &segment, QMap<QDateTime, Sensors> &map)
void SMLParser::samples(SegmentData &segment) void SMLParser::samples(SegmentData &segment)
{ {
QMap<QDateTime, Sensors> sensors; SensorsMap map;
QMap<QDateTime, Sensors>::const_iterator it;
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("Sample")) { if (_reader.name() == QLatin1String("Sample")) {
sample(segment, sensors); sample(segment, map);
} else } else
_reader.skipCurrentElement(); _reader.skipCurrentElement();
} }
for (int i = 0; i < segment.size(); i++) { for (int i = 0; i < segment.size(); i++) {
Trackpoint &t = segment[i]; Trackpoint &t = segment[i];
if ((it = sensors.lowerBound(t.timestamp())) != sensors.constEnd()) { SensorsMap::const_iterator it(map.lowerBound(t.timestamp()));
if (it != map.constEnd()) {
t.setCadence(it->cadence * 60); t.setCadence(it->cadence * 60);
t.setTemperature(it->temperature - 273.15); t.setTemperature(it->temperature - 273.15);
t.setHeartRate(it->hr * 60); t.setHeartRate(it->hr * 60);

View File

@ -23,10 +23,12 @@ private:
qreal cadence, temperature, hr, power, speed; qreal cadence, temperature, hr, power, speed;
}; };
typedef QMap<QDateTime, Sensors> SensorsMap;
void sml(QList<TrackData> &tracks); void sml(QList<TrackData> &tracks);
void deviceLog(TrackData &track); void deviceLog(TrackData &track);
void samples(SegmentData &segment); void samples(SegmentData &segment);
void sample(SegmentData &segment, QMap<QDateTime, Sensors> &map); void sample(SegmentData &segment, SensorsMap &map);
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
friend QDebug operator<<(QDebug dbg, const Sensors &sensors); friend QDebug operator<<(QDebug dbg, const Sensors &sensors);