diff -r d927333c8ffe -r 84b0f3ca474a igc.cc --- a/igc.cc Sun Jan 22 17:35:21 2012 +0100 +++ b/igc.cc Sun Jan 22 20:46:02 2012 +0100 @@ -6,16 +6,25 @@ char c; in >> c; switch (c) { - case 'A': theAuthor = in.readLine(); break; + case 'A': + if (device_.isEmpty()) device_ = in.readLine(); + break; case 'H': { - QString line = in.readLine(); - QString key = line.section(':', 0, 0); - QString value = line.section(':', 1, 1).simplified(); - if (key.startsWith("FPLT")) thePilot = value; - if (key.startsWith("FGTY")) theGlider = value; - } - break; - case 'B': fixes << in.readLine(); break; + QString line = in.readLine(); + QString key = line.section(':', 0, 0); + QString value = line.section(':', 1, 1).simplified(); + + if (key.startsWith("FPLT")) pilot_ = value; + else if (key.startsWith("FGTY")) glider_ = value; + else if (key.startsWith("FDTE")) { + QString s = line.mid(4); + if (s.length() == 6) + s.insert(4, "20"); // FIXME: current year? + date_ = QDate::fromString(s, "ddMMyyyy"); + } + } + break; + case 'B': fixes_ << in.readLine(); break; } } } @@ -23,12 +32,16 @@ Fix::Fix(const QString &s) { int pos = 0; - theTime = s.mid(pos, 6); pos += 6; - gps.lat = s.mid(pos, 8); pos += 8; - gps.lon = s.mid(pos, 9); pos += 9; - valid = s.mid(pos, 1); pos += 1; - theAlt.press = s.mid(pos, 5).toInt(); pos += 5; - theAlt.gps = s.mid(pos, 5).toInt(); pos += 5; + + time_ = QTime::fromString(s.mid(pos, 6), "hhmmss"); + pos += 6; + + gps_.lat = s.mid(pos, 8); pos += 8; // DDMMmmm[NS] + gps_.lon = s.mid(pos, 9); pos += 9; // DDDMMmmm[EW] - qDebug() << theAlt.press << " | " << theAlt.gps; + fix3d_ = s.mid(pos, 1) == "A"; + pos += 1; + + alt_.baro = s.mid(pos, 5).toInt(); pos += 5; + alt_.gps = s.mid(pos, 5).toInt(); pos += 5; }