コード例 #1
0
ファイル: CupWriter.cpp プロジェクト: ThomasXBMC/XCSoar
void
WriteCup(TextWriter &writer, const Waypoints &waypoints,
         WaypointOrigin origin)
{
  // Iterate through the waypoint list and save each waypoint with
  // the right file number to the TextWriter
  /// @todo JMW: iteration ordered by ID would be preferred
  for (auto it = waypoints.begin(); it != waypoints.end(); ++it) {
    const Waypoint& wp = *it;
    if (wp.origin == origin)
      WriteCup(writer, wp);
  }
}
コード例 #2
0
void
WayPointFileWinPilot::saveFile(TextWriter &writer, const Waypoints &way_points)
{
  // Iterate through the waypoint list and save each waypoint
  // into the file defined by fp
  /// @todo JMW: iteration ordered by ID would be preferred
  for (Waypoints::WaypointTree::const_iterator it = way_points.begin();
       it != way_points.end(); it++) {
    const Waypoint& wp = it->get_waypoint();
    if (wp.FileNum == file_num)
      composeLine(writer, wp);
  }
}
コード例 #3
0
unsigned test_nearest(const Waypoints& waypoints)
{
    const Waypoint *r = waypoints.lookup_id(3);
    if (r) {
        Waypoints::WaypointTree::const_iterator it = waypoints.find_nearest(r->Location);
        if (it != waypoints.end()) {
            return true;
        } else {
            return false;
        }
    }
    return false;
}
コード例 #4
0
void
CAI302WaypointUploader::Run(OperationEnvironment &env)
{
  Waypoints waypoints;

  env.SetText(_("Loading Waypoints..."));
  if (!reader.Parse(waypoints, env)) {
    env.SetErrorMessage(_("Failed to load file."));
    return;
  }

  if (waypoints.size() > 9999) {
    env.SetErrorMessage(_("Too many waypoints."));
    return;
  }

  env.SetText(_("Uploading Waypoints"));
  env.SetProgressRange(waypoints.size() + 1);
  env.SetProgressPosition(0);

  if (!device.ClearPoints(env)) {
    if (!env.IsCancelled())
      env.SetErrorMessage(_("Failed to erase waypoints."));
    return;
  }

  if (!device.EnableBulkMode(env)) {
    if (!env.IsCancelled())
      env.SetErrorMessage(_("Failed to switch baud rate."));
    return;
  }

  unsigned id = 1;
  for (auto i = waypoints.begin(), end = waypoints.end();
       i != end; ++i, ++id) {
    if (env.IsCancelled())
      break;

    env.SetProgressPosition(id);

    if (!device.WriteNavpoint(id, *i, env)) {
      if (!env.IsCancelled())
        env.SetErrorMessage(_("Failed to write waypoint."));
      break;
    }
  }

  device.DisableBulkMode(env);
}
コード例 #5
0
ファイル: harness_waypoints.cpp プロジェクト: hnpilot/XCSoar
/** 
 * Initialises waypoints with random and non-random waypoints
 * for testing
 *
 * @param waypoints waypoints class to add waypoints to
 */
bool setup_waypoints(Waypoints &waypoints, const unsigned n) 
{

  Waypoint wp = waypoints.create(GeoPoint(Angle::degrees(fixed_zero),
                                          Angle::degrees(fixed_zero)));
  wp.Flags.Airport = true;
  wp.Altitude = fixed(0.25);
  waypoints.append(wp);

  wp = waypoints.create(GeoPoint(Angle::degrees(fixed_zero), 
                                 Angle::degrees(fixed_one)));
  wp.Flags.Airport = true;
  wp.Altitude = fixed(0.25);
  waypoints.append(wp);

  wp = waypoints.create(GeoPoint(Angle::degrees(fixed_one), 
                                 Angle::degrees(fixed_one)));
  wp.Name = _T("Hello");
  wp.Flags.Airport = true;
  wp.Altitude = fixed_half;
  waypoints.append(wp);

  wp = waypoints.create(GeoPoint(Angle::degrees(fixed(0.8)), 
                                 Angle::degrees(fixed(0.5))));
  wp.Name = _T("Unk");
  wp.Flags.Airport = true;
  wp.Altitude = fixed(0.25);
  waypoints.append(wp);

  wp = waypoints.create(GeoPoint(Angle::degrees(fixed_one), 
                                 Angle::degrees(fixed_zero)));
  wp.Flags.Airport = true;
  wp.Altitude = fixed(0.25);
  waypoints.append(wp);

  wp = waypoints.create(GeoPoint(Angle::degrees(fixed_zero), 
                                 Angle::degrees(fixed(0.23))));
  wp.Flags.Airport = true;
  wp.Altitude = fixed(0.25);
  waypoints.append(wp);

  for (unsigned i=0; i<(unsigned)std::max((int)n-6,0); i++) {
    int x = rand()%1200-100;
    int y = rand()%1200-100;
    double z = rand()% std::max(terrain_height,1);
    wp = waypoints.create(GeoPoint(Angle::degrees(fixed(x/1000.0)), 
                                   Angle::degrees(fixed(y/1000.0))));
    wp.Flags.Airport = false;
    wp.Altitude = fixed(z);
    waypoints.append(wp);
  }
  waypoints.optimise();

  if (verbose) {
    std::ofstream fin("results/res-wp-in.txt");
    for (unsigned i=1; i<=waypoints.size(); i++) {
      Waypoints::WaypointTree::const_iterator it = waypoints.find_id(i);
      if (it != waypoints.end()) {
#ifdef DO_PRINT
        fin << it->get_waypoint();
#endif
      }
    }
  }
  return true;
}