parse the B records
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Sun, 22 Jan 2012 17:35:21 +0100
changeset 11 d927333c8ffe
parent 10 e1abdc480485
child 12 84b0f3ca474a
parse the B records
igc.cc
igc.h
--- a/igc.cc	Sun Jan 22 16:31:20 2012 +0100
+++ b/igc.cc	Sun Jan 22 17:35:21 2012 +0100
@@ -11,12 +11,24 @@
 		      QString line  = in.readLine();
 		      QString key   = line.section(':', 0, 0);
 		      QString value = line.section(':', 1, 1).simplified();
-		      qDebug() << key << "--" << value;
-		      if (key == "FPLTPILOT") thePilot = value;
-		      if (key == "FGTYGLIDERTYPE") theGlider = value;
+		      if (key.startsWith("FPLT")) thePilot = value;
+		      if (key.startsWith("FGTY")) theGlider = value;
 		      }
 		      break;
-	    case 'B': points << in.readLine(); break;
+	    case 'B': fixes << in.readLine(); break;
 	}
     }
 }
+
+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;
+
+    qDebug() << theAlt.press << " | " << theAlt.gps;
+}
--- a/igc.h	Sun Jan 22 16:31:20 2012 +0100
+++ b/igc.h	Sun Jan 22 17:35:21 2012 +0100
@@ -3,6 +3,23 @@
 
 #include "pch.h"
 
+class Fix {
+  public: 
+    Fix(const QString&);
+  private:
+    QString theTime, valid;
+    struct {
+	QString lon;
+	QString lat;
+    } gps;
+    struct {
+	int press;
+	int gps;
+    } theAlt;
+};
+
+typedef QList<Fix> Fixes;
+
 class IGC {
   public:
     void read(QTextStream&);
@@ -11,6 +28,7 @@
   private:
     QString theAuthor, thePilot, theGlider;
     QStringList points;
+    Fixes fixes;
 
 };
 #endif