Ejemplo n.º 1
0
void
IGCFileVisitor::Visit(Path path, Path filename)
{
  Error error;
  FileLineReaderA reader(path, error);
  if (reader.error()) {
    fprintf(stderr, "%s\n", error.GetMessage());
    return;
  }

  IGCExtensions extensions;
  extensions.clear();

  FlightCheck flight(filename.c_str());
  char *line;
  while ((line = reader.ReadLine()) != NULL) {
    unsigned day, month, year;

    IGCFix fix;
    if (IGCParseFix(line, extensions, fix))
      flight.fix(fix);
    else if (sscanf(line, "HFDTE%02u%02u%02u", &day, &month, &year)) {
      /* damn you, Y2K bug! */
      if (year > 80)
        year += 1900;
      else
        year += 2000;

      flight.date(year, month, day);
    }
  }

  flight.finish();
}
Ejemplo n.º 2
0
void
IGCFileVisitor::Visit(const TCHAR *path, const TCHAR *filename)
{
  FileLineReaderA reader(path);
  if (reader.error()) {
    _ftprintf(stderr, _T("Failed to open %s\n"), path);
    return;
  }

  IGCExtensions extensions;
  extensions.clear();

  FlightCheck flight(filename);
  char *line;
  while ((line = reader.ReadLine()) != NULL) {
    unsigned day, month, year;

    IGCFix fix;
    if (IGCParseFix(line, extensions, fix))
      flight.fix(fix);
    else if (sscanf(line, "HFDTE%02u%02u%02u", &day, &month, &year)) {
      /* damn you, Y2K bug! */
      if (year > 80)
        year += 1900;
      else
        year += 2000;

      flight.date(year, month, day);
    }
  }

  flight.finish();
}
Ejemplo n.º 3
0
static bool
TestTrace(Path filename, unsigned ntrace, bool output=false)
{
  FileLineReaderA reader(filename);

  printf("# %d", ntrace);  
  Trace trace(1000, ntrace);

  IGCExtensions extensions;
  extensions.clear();

  char *line;
  int i = 0;
  for (; (line = reader.ReadLine()) != NULL; i++) {
    if (output && (i % 500 == 0)) {
      putchar('.');
      fflush(stdout);
    }

    IGCFix fix;
    if (!IGCParseFix(line, extensions, fix) || !fix.gps_valid)
      continue;

    OnAdvance(trace,
               fix.location,
               fix.gps_altitude,
               fix.time.GetSecondOfDay());
  }
  putchar('\n');
  printf("# samples %d\n", i);
  return true;
}
Ejemplo n.º 4
0
static void
TestFix()
{
  IGCExtensions extensions;
  extensions.clear();

  IGCFix fix;
  ok1(!IGCParseFix("", extensions, fix));
  ok1(!IGCParseFix("B1122385103117N00742367EA", extensions, fix));

  ok1(!IGCParseFix("B1122385103117X00742367EA0049000487", extensions, fix));
  ok1(!IGCParseFix("B1122385103117N00742367XA0049000487", extensions, fix));
  ok1(!IGCParseFix("B1122389003117N00742367EA0049000487", extensions, fix));
  ok1(!IGCParseFix("B1122385103117N18042367EA0049000487", extensions, fix));
  ok1(!IGCParseFix("B1122385163117N00742367EA0049000487", extensions, fix));
  ok1(!IGCParseFix("B1122385103117N00762367EA0049000487", extensions, fix));

  ok1(IGCParseFix("B1122385103117N00742367EA0049000487", extensions, fix));
  ok1(fix.time == BrokenTime(11, 22, 38));
  ok1(equals(fix.location, 51.05195, 7.70611667));
  ok1(fix.gps_valid);
  ok1(fix.pressure_altitude == 490);
  ok1(fix.gps_altitude == 487);

  ok1(IGCParseFix("B1122385103117N00742367EV0049000487", extensions, fix));
  ok1(fix.time == BrokenTime(11, 22, 38));
  ok1(equals(fix.location, 51.05195, 7.70611667));
  ok1(!fix.gps_valid);
  ok1(fix.pressure_altitude == 490);
  ok1(fix.gps_altitude == 487);

  ok1(!IGCParseFix("B1122385103117N00742367EX0049000487", extensions, fix));

  ok1(IGCParseFix("B1122435103117N00742367EA004900000000000",
                  extensions, fix));
  ok1(fix.time == BrokenTime(11, 22, 43));
  ok1(fix.gps_valid);
  ok1(fix.pressure_altitude == 490);
  ok1(fix.gps_altitude == 0);

  ok1(IGCParseFix("B1122535103117S00742367WA104900000700000",
                  extensions, fix));
  ok1(fix.time == BrokenTime(11, 22, 53));
  ok1(fix.gps_valid);
  ok1(equals(fix.location, -51.05195, -7.70611667));
  ok1(fix.pressure_altitude == 10490);
  ok1(fix.gps_altitude == 7);
}
Ejemplo n.º 5
0
bool
IGCParseExtensions(const char *buffer, IGCExtensions &extensions)
{
  if (*buffer++ != 'I')
    return false;

  int count = ParseTwoDigits(buffer);
  if (count < 0)
    return false;

  buffer += 2;

  extensions.clear();

  while (count-- > 0) {
    const int start = ParseTwoDigits(buffer);
    if (start < 8)
      return false;

    buffer += 2;

    const int finish = ParseTwoDigits(buffer);
    if (finish < start)
      return false;

    buffer += 2;

    if (!CheckThreeAlphaNumeric(buffer))
      return false;

    IGCExtension &x = extensions.append();
    x.start = start;
    x.finish = finish;
    memcpy(x.code, buffer, 3);
    x.code[3] = 0;

    buffer += 3;
  }

  return true;
}
Ejemplo n.º 6
0
 DebugReplayIGC(FileLineReaderA *_reader)
   : DebugReplayFile(_reader) {
   extensions.clear();
 }
Ejemplo n.º 7
0
 DebugReplayIGC(NLineReader *reader)
   :DebugReplay(reader), day(0) {
   extensions.clear();
 }