igc.cc
changeset 12 84b0f3ca474a
parent 11 d927333c8ffe
child 13 c5ee81217f70
equal deleted inserted replaced
11:d927333c8ffe 12:84b0f3ca474a
     4 {
     4 {
     5     while (!in.atEnd()) {
     5     while (!in.atEnd()) {
     6 	char c;
     6 	char c;
     7 	in >> c;
     7 	in >> c;
     8 	switch (c) {
     8 	switch (c) {
     9 	    case 'A': theAuthor = in.readLine(); break;
     9 	    case 'A': 
       
    10 		if (device_.isEmpty()) device_ = in.readLine(); 
       
    11 		break;
    10 	    case 'H': {
    12 	    case 'H': {
    11 		      QString line  = in.readLine();
    13 		QString line  = in.readLine();
    12 		      QString key   = line.section(':', 0, 0);
    14 		QString key   = line.section(':', 0, 0);
    13 		      QString value = line.section(':', 1, 1).simplified();
    15 		QString value = line.section(':', 1, 1).simplified();
    14 		      if (key.startsWith("FPLT")) thePilot = value;
    16 
    15 		      if (key.startsWith("FGTY")) theGlider = value;
    17 		if (key.startsWith("FPLT")) pilot_ = value;
    16 		      }
    18 		else if (key.startsWith("FGTY")) glider_ = value;
    17 		      break;
    19 		else if (key.startsWith("FDTE")) {
    18 	    case 'B': fixes << in.readLine(); break;
    20 		    QString s = line.mid(4);
       
    21 		    if (s.length() == 6) 
       
    22 			s.insert(4, "20"); // FIXME: current year?
       
    23 		    date_ = QDate::fromString(s, "ddMMyyyy");
       
    24 		}
       
    25 	    }
       
    26 	    break;
       
    27 	    case 'B': fixes_ << in.readLine(); break;
    19 	}
    28 	}
    20     }
    29     }
    21 }
    30 }
    22 
    31 
    23 Fix::Fix(const QString &s)
    32 Fix::Fix(const QString &s)
    24 {
    33 {
    25     int pos = 0;
    34     int pos = 0;
    26     theTime = s.mid(pos, 6); pos += 6;
       
    27     gps.lat = s.mid(pos, 8); pos += 8;
       
    28     gps.lon = s.mid(pos, 9); pos += 9;
       
    29     valid = s.mid(pos, 1); pos += 1;
       
    30     theAlt.press = s.mid(pos, 5).toInt(); pos += 5;
       
    31     theAlt.gps = s.mid(pos, 5).toInt(); pos += 5;
       
    32 
    35 
    33     qDebug() << theAlt.press << " | " << theAlt.gps;
    36     time_ = QTime::fromString(s.mid(pos, 6), "hhmmss"); 
       
    37     pos += 6;	
       
    38 
       
    39     gps_.lat = s.mid(pos, 8); pos += 8;	// DDMMmmm[NS]
       
    40     gps_.lon = s.mid(pos, 9); pos += 9;	// DDDMMmmm[EW]
       
    41 
       
    42     fix3d_ = s.mid(pos, 1) == "A"; 
       
    43     pos += 1;
       
    44 
       
    45     alt_.baro = s.mid(pos, 5).toInt(); pos += 5;
       
    46     alt_.gps = s.mid(pos, 5).toInt(); pos += 5;
    34 }
    47 }