Exemplo n.º 1
0
bool
WayPointFileWinPilot::parseLine(const TCHAR* line, const unsigned linenum,
                                Waypoints &way_points, 
                                const RasterTerrain *terrain)
{
  TCHAR ctemp[255];
  const TCHAR *params[20];
  size_t n_params;

  // If (end-of-file or comment)
  if (line[0] == '\0' || line[0] == 0x1a ||
      _tcsstr(line, _T("**")) == line ||
      _tcsstr(line, _T("*")) == line)
    // -> return without error condition
    return true;

  if (_tcslen(line) >= sizeof(ctemp) / sizeof(ctemp[0]))
    /* line too long for buffer */
    return false;

  GeoPoint location;

  // Get fields
  n_params = extractParameters(line, ctemp, params, 20);
  if (n_params < 6)
    return false;

  // Latitude (e.g. 51:15.900N)
  if (!parseAngle(params[1], location.Latitude, true))
    return false;

  // Longitude (e.g. 00715.900W)
  if (!parseAngle(params[2], location.Longitude, false))
    return false;

  Waypoint new_waypoint(location);
  new_waypoint.FileNum = file_num;

  // Name (e.g. KAMPLI)
  if (!parseString(params[5], new_waypoint.Name))
    return false;

  // Altitude (e.g. 458M)
  /// @todo configurable behaviour
  bool alt_ok = parseAltitude(params[3], new_waypoint.Altitude);
  check_altitude(new_waypoint, terrain, alt_ok);

  if (n_params > 6) {
    // Description (e.g. 119.750 Airport)
    parseString(params[6], new_waypoint.Comment);
  }

  // Waypoint Flags (e.g. AT)
  parseFlags(params[4], new_waypoint.Flags);

  add_waypoint(way_points, new_waypoint);
  return true;
}
Exemplo n.º 2
0
bool
WaypointReaderZander::ParseLine(const TCHAR* line, const unsigned linenum,
                                Waypoints &way_points)
{
    // If (end-of-file or comment)
    if (line[0] == '\0' || line[0] == 0x1a ||
            _tcsstr(line, _T("**")) == line ||
            _tcsstr(line, _T("*")) == line)
        // -> return without error condition
        return true;

    // Determine the length of the line
    size_t len = _tcslen(line);
    // If less then 34 characters -> something is wrong -> cancel
    if (len < 34)
        return false;

    GeoPoint location;

    // Latitude (Characters 13-20 // DDMMSS(N/S))
    if (!parseAngle(line + 13, location.Latitude, true))
        return false;

    // Longitude (Characters 21-29 // DDDMMSS(E/W))
    if (!parseAngle(line + 21, location.Longitude, false))
        return false;

    location.normalize(); // ensure longitude is within -180:180

    Waypoint new_waypoint(location);
    new_waypoint.file_num = file_num;
    new_waypoint.original_id = 0;

    // Name (Characters 0-12)
    if (!parseString(line, new_waypoint.name, 12))
        return false;

    // Altitude (Characters 30-34 // e.g. 1561 (in meters))
    /// @todo configurable behaviour
    if (!parseAltitude(line + 30, new_waypoint.altitude))
        CheckAltitude(new_waypoint);

    // Description (Characters 35-44)
    if (len > 35)
        parseString(line + 35, new_waypoint.comment, 9);

    // Flags (Characters 45-49)
    if (len < 46 || !parseFlags(line + 45, new_waypoint))
        if (len < 36 || !parseFlagsFromDescription(line + 35, new_waypoint))
            new_waypoint.flags.turn_point = true;

    way_points.append(new_waypoint);
    return true;
}
Exemplo n.º 3
0
bool
WayPointFileZander::parseLine(const TCHAR* line, const unsigned linenum,
                              Waypoints &way_points,
                              const RasterTerrain *terrain)
{
  // If (end-of-file or comment)
  if (line[0] == '\0' || line[0] == 0x1a ||
      _tcsstr(line, _T("**")) == line ||
      _tcsstr(line, _T("*")) == line)
    // -> return without error condition
    return true;

  // Determine the length of the line
  size_t len = _tcslen(line);
  // If less then 34 characters -> something is wrong -> cancel
  if (len < 34)
    return false;

  GeoPoint location;

  // Latitude (Characters 13-20 // DDMMSS(N/S))
  if (!parseAngle(line + 13, location.Latitude, true))
    return false;

  // Longitude (Characters 21-29 // DDDMMSS(E/W))
  if (!parseAngle(line + 21, location.Longitude, false))
    return false;

  Waypoint new_waypoint(location);
  new_waypoint.FileNum = file_num;

  // Name (Characters 0-12)
  if (!parseString(line, new_waypoint.Name))
    return false;

  // Altitude (Characters 30-34 // e.g. 1561 (in meters))
  /// @todo configurable behaviour
  bool alt_ok = parseAltitude(line + 30, new_waypoint.Altitude);
  check_altitude(new_waypoint, terrain, alt_ok);

  // Description (Characters 35-44)
  if (len > 35)
    parseString(line + 35, new_waypoint.Comment);

  // Flags (Characters 45-49)
  if (len > 45)
    parseFlags(line + 45, new_waypoint.Flags);

  add_waypoint(way_points, new_waypoint);
  return true;
}
Exemplo n.º 4
0
      inline static void
      parseCoordinate(Parsers::Config& parser, std::string section, T& msg)
      {
        std::string ref;

        parser.get(section, "Reference", section, ref);
        parseAngle(parser, ref, "Latitude (degrees)", msg.lat, 0.0);
        parseAngle(parser, ref, "Longitude (degrees)", msg.lon, 0.0);

        // See if there are N-E offsets
        double n, e;

        parser.get(section, "Offset North (meters)", "0.0", n);
        parser.get(section, "Offset East (meters)", "0.0", e);

        Coordinates::WGS84::displace(n, e, &msg.lat, &msg.lon);
      }
Exemplo n.º 5
0
 void
 PlanConfigParser::parse(Parsers::Config& cfg, std::string id, IMC::Rows& man)
 {
   // Get configurable parameters
   parseCoordinate(cfg, id, man);
   parseSpeed(cfg, id, man);
   parseZ(cfg, id, man);
   parseZUnits(cfg, id, man);
   parseAngle(cfg, id, "Bearing (degrees)", man.bearing, 0.0);
   parseAngle(cfg, id, "Cross Angle (degrees)", man.cross_angle, 0.0);
   cfg.get(id, "Width (meters)", "150", man.width);
   cfg.get(id, "Length (meters)", "100", man.length);
   cfg.get(id, "Curve Offset (meters)", "15", man.coff);
   cfg.get(id, "Alternation (%)", "100", man.alternation);
   cfg.get(id, "Horizontal Step (meters)", "30", man.hstep);
   cfg.get(id, "Flags", "3", man.flags);
 }
Exemplo n.º 6
0
 void
 PlanConfigParser::parse(Parsers::Config& cfg, std::string section, IMC::YoYo& man)
 {
   parseCoordinate(cfg, section, man);
   parseZ(cfg, section, man);
   parseZUnits(cfg, section, man);
   cfg.get(section, "Amplitude (meters)", "0.0", man.amplitude);
   parseAngle(cfg, section, "Pitch (degrees)", man.pitch, (fp32_t)15.0);
   parseSpeed(cfg, section, man);
 }
Exemplo n.º 7
0
    void
    PlanConfigParser::parse(Parsers::Config& cfg, std::string id, IMC::Loiter& man)
    {
      // Get configurable parameters
      parseCoordinate(cfg, id, man);
      parseSpeed(cfg, id, man);
      parseTimeout(cfg, id, man);
      parseDuration(cfg, id, man);
      parseZ(cfg, id, man);
      parseZUnits(cfg, id, man);

      int8_t type;
      cfg.get(id, "Loiter Type", "0", type);

      switch (type)
      {
        case 1:
          man.type = IMC::Loiter::LT_RACETRACK; break;
        case 2:
          man.type = IMC::Loiter::LT_HOVER; break;
        case 3:
          man.type = IMC::Loiter::LT_EIGHT; break;
        case 0:
        default:
          man.type = IMC::Loiter::LT_CIRCULAR; break;
      }

      std::string ldir;
      cfg.get(id, "Loiter Direction", "Clock", ldir);

      if (ldir == "Clockwise")
        man.direction = IMC::Loiter::LD_CLOCKW;
      else
        man.direction = IMC::Loiter::LD_CCLOCKW;

      cfg.get(id, "Radius (meters)", "50", man.radius);
      parseAngle(cfg, id, "Bearing (degrees)", man.bearing, 0.0);
      cfg.get(id, "Length (meters)", "100", man.length);
    }
Exemplo n.º 8
0
    void
    PlanConfigParser::parse(Parsers::Config& cfg, std::string id, IMC::CompassCalibration& man)
    {
      // Get configurable parameters
      parseCoordinate(cfg, id, man);
      parseSpeed(cfg, id, man);
      parseTimeout(cfg, id, man);
      parseDuration(cfg, id, man);
      parseZ(cfg, id, man);
      parseZUnits(cfg, id, man);

      std::string ldir;
      cfg.get(id, "Loiter Direction", "Clock", ldir);

      if (ldir == "Clockwise")
        man.direction = IMC::Loiter::LD_CLOCKW;
      else
        man.direction = IMC::Loiter::LD_CCLOCKW;

      cfg.get(id, "Radius (meters)", "50", man.radius);
      cfg.get(id, "Amplitude (meters)", "1", man.amplitude);
      parseAngle(cfg, id, "Pitch (degrees)", man.pitch, (fp32_t)0.0);
    }
Exemplo n.º 9
0
void MythUIAnimation::ParseSection(const QDomElement &element,
                                   MythUIType* parent, Trigger trigger)
{
    int duration = element.attribute("duration", "500").toInt();
    QString centre = element.attribute("centre", "Middle");
    for (QDomNode child = element.firstChild(); !child.isNull();
         child = child.nextSibling())
    {
        QDomElement effect = child.toElement();
        if (effect.isNull())
            continue;

        Type type = Alpha;
        int effectduration = duration;
        // override individual durations
        QString effect_duration = effect.attribute("duration", "");
        if (!effect_duration.isEmpty())
            effectduration = effect_duration.toInt();

        bool looped = parseBool(effect.attribute("looped", "false"));
        bool reversible = parseBool(effect.attribute("reversible", "false"));
        QString easingcurve = effect.attribute("easingcurve", "Linear");
        QVariant start;
        QVariant end;

        QString fxtype = effect.tagName();
        if (fxtype == "alpha")
        {
            type = Alpha;
            parseAlpha(effect, start, end);
        }
        else if (fxtype == "position")
        {
            type = Position;
            parsePosition(effect, start, end, parent);
        }
        else if (fxtype == "angle")
        {
            type = Angle;
            parseAngle(effect, start, end);
        }
        else if (fxtype == "zoom")
        {
            type = Zoom;
            parseZoom(effect, start, end);
        }
        else if (fxtype == "horizontalzoom")
        {
            type = HorizontalZoom;
            parseZoom(effect, start, end);
        }
        else if (fxtype == "verticalzoom")
        {
            type = VerticalZoom;
            parseZoom(effect, start, end);
        }
        else
            continue;

        MythUIAnimation* a = new MythUIAnimation(parent, trigger, type);
        a->setStartValue(start);
        a->setEndValue(end);
        a->setDuration(effectduration);
        a->SetEasingCurve(easingcurve);
        a->SetCentre(centre);
        a->SetLooped(looped);
        a->SetReversible(reversible);
        if (looped)
            a->setLoopCount(-1);
        parent->GetAnimations()->append(a);
    }
}
Exemplo n.º 10
0
bool
WayPointFileSeeYou::parseLine(const TCHAR* line, const unsigned linenum,
                              Waypoints &way_points, 
                              const RasterTerrain *terrain)
{
  TCHAR ctemp[255];
  const TCHAR *params[20];
  size_t n_params;

  static unsigned iName = 0, iCode = 1, iCountry = 2;
  static unsigned iLatitude = 3, iLongitude = 4, iElevation = 5;
  static unsigned iStyle = 6, iRWDir = 7, iRWLen = 8;
  static unsigned iFrequency = 9, iDescription = 10;

  static bool ignore_following = false;

  // If (end-of-file or comment)
  if (line[0] == '\0' || line[0] == 0x1a ||
      _tcsstr(line, _T("**")) == line ||
      _tcsstr(line, _T("*")) == line)
    // -> return without error condition
    return true;

  if (_tcslen(line) >= sizeof(ctemp) / sizeof(ctemp[0]))
    /* line too long for buffer */
    return false;

  // Parse first line holding field order
  /// @todo linenum == 0 should be the first
  /// (not ignored) line, not just line 0
  if (linenum == 0) {
    // Get fields
    n_params = extractParameters(line, ctemp, params, 20);

    // Iterate through fields and save the field order
    for (unsigned i = 0; i < n_params; i++) {
      const TCHAR* value = params[i];

      if (!_tcscmp(value, _T("name")))
        iName = i;
      else if (!_tcscmp(value, _T("code")))
        iCode = i;
      else if (!_tcscmp(value, _T("country")))
        iCountry = i;
      else if (!_tcscmp(value, _T("lat")))
        iLatitude = i;
      else if (!_tcscmp(value, _T("lon")))
        iLongitude = i;
      else if (!_tcscmp(value, _T("elev")))
        iElevation = i;
      else if (!_tcscmp(value, _T("style")))
        iStyle = i;
      else if (!_tcscmp(value, _T("rwdir")))
        iRWDir = i;
      else if (!_tcscmp(value, _T("rwlen")))
        iRWLen = i;
      else if (!_tcscmp(value, _T("freq")))
        iFrequency = i;
      else if (!_tcscmp(value, _T("desc")))
        iDescription = i;
    }
    ignore_following = false;

    return true;
  }

  // If task marker is reached ignore all following lines
  if (_tcsstr(line, _T("-----Related Tasks-----")) == line)
    ignore_following = true;
  if (ignore_following)
    return true;

  // Get fields
  n_params = extractParameters(line, ctemp, params, 20);

  // Check if the basic fields are provided
  if (iName >= n_params)
    return false;
  if (iLatitude >= n_params)
    return false;
  if (iLongitude >= n_params)
    return false;

  GeoPoint location;

  // Latitude (e.g. 5115.900N)
  if (!parseAngle(params[iLatitude], location.Latitude, true))
    return false;

  // Longitude (e.g. 00715.900W)
  if (!parseAngle(params[iLongitude], location.Longitude, false))
    return false;

  Waypoint new_waypoint(location);
  new_waypoint.FileNum = file_num;

  // Name (e.g. "Some Turnpoint", with quotes)
  if (!parseString(params[iName], new_waypoint.Name))
    return false;

  // Elevation (e.g. 458.0m)
  /// @todo configurable behaviour
  bool alt_ok = iElevation < n_params &&
    parseAltitude(params[iElevation], new_waypoint.Altitude);
  check_altitude(new_waypoint, terrain, alt_ok);

  // Description (e.g. "Some Turnpoint", with quotes)
  /// @todo include frequency and rwdir/len
  if (iDescription < n_params)
    parseString(params[iDescription], new_waypoint.Comment);

  // Style (e.g. 5)
  /// @todo include peaks with peak symbols etc.
  if (iStyle < n_params)
    parseStyle(params[iStyle], new_waypoint.Flags);

  // If the Style attribute did not state that this is an airport
  if (!new_waypoint.Flags.Airport) {
    // -> parse the runway length
    fixed rwlen;
    // Runway length (e.g. 546.0m)
    if (iRWLen < n_params && parseAltitude(params[iRWLen], rwlen)) {
      // If runway length is between 100m and 300m -> landpoint
      if (rwlen > fixed(100) && rwlen <= fixed(300))
        new_waypoint.Flags.LandPoint = true;
      // If runway length is higher then 300m -> airport
      if (rwlen > fixed(300))
        new_waypoint.Flags.Airport = true;
    }
  }

  add_waypoint(way_points, new_waypoint);
  return true;
}