当前位置: 首页>>代码示例>>C++>>正文


C++ Airspaces类代码示例

本文整理汇总了C++中Airspaces的典型用法代码示例。如果您正苦于以下问题:C++ Airspaces类的具体用法?C++ Airspaces怎么用?C++ Airspaces使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Airspaces类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
  Args args(argc, argv, "PATH");
  const char *path = args.ExpectNext();
  args.ExpectEnd();

  FileLineReader reader(path, ConvertLineReader::AUTO);
  if (reader.error()) {
    fprintf(stderr, "Failed to open input file\n");
    return 1;
  }

  Airspaces airspaces;
  AirspaceParser parser(airspaces);

  NullOperationEnvironment operation;
  if (!parser.Parse(reader, operation)) {
    fprintf(stderr, "Failed to parse input file\n");
    return 1;
  }

  airspaces.Optimise();

  printf("OK\n");

  return 0;
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:27,代码来源:RunAirspaceParser.cpp

示例2: scan_airspaces

void scan_airspaces(const AircraftState state,
                    const Airspaces& airspaces,
                    const AirspaceAircraftPerformance& perf,
                    bool do_report,
                    const GeoPoint &target)
{
    const fixed range(20000.0);

    Directory::Create(Path(_T("output/results")));

    {
        AirspaceVisitorPrint pvisitor("output/results/res-bb-range.txt",
                                      do_report);
        for (const auto &i : airspaces.QueryWithinRange(state.location, range)) {
            const AbstractAirspace &airspace = i.GetAirspace();
            pvisitor.Visit(airspace);
        }
    }

    {
        AirspaceVisitorClosest pvisitor("output/results/res-bb-closest.txt",
                                        airspaces.GetProjection(), state, perf);
        for (const auto &i : airspaces.QueryWithinRange(state.location, range)) {
            const AbstractAirspace &airspace = i.GetAirspace();
            pvisitor.Visit(airspace);
        }
    }

    {
        AirspaceVisitorPrint pvi("output/results/res-bb-inside.txt",
                                 do_report);
        for (const auto &a : airspaces.QueryInside(state))
            pvi.Visit(a.GetAirspace());
    }

    {
        AirspaceIntersectionVisitorPrint ivisitor("output/results/res-bb-intersects.txt",
                "output/results/res-bb-intersected.txt",
                "output/results/res-bb-intercepts.txt",
                do_report,
                state, perf);
        airspaces.VisitIntersecting(state.location, target, ivisitor);
    }

    {
        const auto *as = FindSoonestAirspace(airspaces, state, perf,
                                             AirspacePredicateTrue());
        if (do_report) {
            std::ofstream fout("output/results/res-bb-sortedsoonest.txt");
            if (as) {
                fout << *as << "\n";
            } else {
                fout << "# no soonest found\n";
            }
        }
    }
}
开发者ID:kwtskran,项目名称:XCSoar,代码行数:57,代码来源:harness_airspace.cpp

示例3: test_airspace_extra

bool test_airspace_extra(Airspaces &airspaces) {
    // try adding a null polygon

    AbstractAirspace* as;
    std::vector<GeoPoint> pts;
    as = new AirspacePolygon(pts);
    airspaces.Add(as);

    // try clearing now (we haven't called optimise())

    airspaces.Clear();
    return true;
}
开发者ID:kwtskran,项目名称:XCSoar,代码行数:13,代码来源:harness_airspace.cpp

示例4: scan_airspaces

void scan_airspaces(const AircraftState state, 
                    const Airspaces& airspaces,
                    const AirspaceAircraftPerformance& perf,
                    bool do_report,
                    const GeoPoint &target) 
{
  const fixed range(20000.0);

  Directory::Create(Path(_T("output/results")));

  {
    AirspaceVisitorPrint pvisitor("output/results/res-bb-range.txt",
                                  do_report);
    airspaces.VisitWithinRange(state.location, range, pvisitor);
  }

  {
    AirspaceVisitorClosest pvisitor("output/results/res-bb-closest.txt",
                                    airspaces.GetProjection(), state, perf);
    airspaces.VisitWithinRange(state.location, range, pvisitor);
  }

  {
    const std::vector<Airspace> vi = airspaces.FindInside(state);
    AirspaceVisitorPrint pvi("output/results/res-bb-inside.txt",
                             do_report);
    std::for_each(vi.begin(), vi.end(), CallVisitor<AirspaceVisitor>(pvi));
  }
  
  {
    AirspaceIntersectionVisitorPrint ivisitor("output/results/res-bb-intersects.txt",
                                              "output/results/res-bb-intersected.txt",
                                              "output/results/res-bb-intercepts.txt",
                                              do_report,
                                              state, perf);
    airspaces.VisitIntersecting(state.location, target, ivisitor);
  }

  {
    const auto *as = FindSoonestAirspace(airspaces, state, perf,
                                         AirspacePredicateTrue());
    if (do_report) {
      std::ofstream fout("output/results/res-bb-sortedsoonest.txt");
      if (as) {
        fout << *as << "\n";
      } else {
        fout << "# no soonest found\n";
      }
    }
  }
}
开发者ID:Andy-1954,项目名称:XCSoar,代码行数:51,代码来源:harness_airspace.cpp

示例5: setup_airspaces

void setup_airspaces(Airspaces& airspaces, const GeoPoint& center, const unsigned n) {
    std::ofstream *fin = NULL;

    if (verbose) {
        Directory::Create(Path(_T("output/results")));
        fin = new std::ofstream("output/results/res-bb-in.txt");
    }

    for (unsigned i=0; i<n; i++) {
        AbstractAirspace* as;
        if (rand()%4!=0) {
            GeoPoint c;
            c.longitude = Angle::Degrees(fixed((rand()%1200-600)/1000.0))+center.longitude;
            c.latitude = Angle::Degrees(fixed((rand()%1200-600)/1000.0))+center.latitude;
            fixed radius(10000.0*(0.2+(rand()%12)/12.0));
            as = new AirspaceCircle(c,radius);
        } else {

            // just for testing, create a random polygon from a convex hull around
            // random points
            const unsigned num = rand()%10+5;
            GeoPoint c;
            c.longitude = Angle::Degrees(fixed((rand()%1200-600)/1000.0))+center.longitude;
            c.latitude = Angle::Degrees(fixed((rand()%1200-600)/1000.0))+center.latitude;

            std::vector<GeoPoint> pts;
            for (unsigned j=0; j<num; j++) {
                GeoPoint p=c;
                p.longitude += Angle::Degrees(fixed((rand()%200)/1000.0));
                p.latitude += Angle::Degrees(fixed((rand()%200)/1000.0));
                pts.push_back(p);
            }
            as = new AirspacePolygon(pts,true);
        }
        airspace_random_properties(*as);
        airspaces.Add(as);
        if (fin)
            *fin << *as;
    }

    delete fin;

    // try inserting nothing
    airspaces.Add(NULL);

    airspaces.Optimise();

}
开发者ID:kwtskran,项目名称:XCSoar,代码行数:48,代码来源:harness_airspace.cpp

示例6:

bool
Airspaces::SynchroniseInRange(const Airspaces &master,
                              const GeoPoint &location,
                              const double range,
                              const AirspacePredicate &condition)
{
  qnh = master.qnh;
  activity_mask = master.activity_mask;
  task_projection = master.task_projection;

  AirspaceVector contents_master;
  for (const auto &i : master.QueryWithinRange(location, range))
    if (condition(i.GetAirspace()))
      contents_master.push_back(i);

  if (CompareAirspaceVectors(contents_master, AsVector()))
    return false;

  for (auto &i : QueryAll())
    i.ClearClearance();
  airspace_tree.clear();

  for (const auto &i : contents_master)
    airspace_tree.insert(i);

  ++serial;

  return true;
}
开发者ID:rkohel,项目名称:XCSoar,代码行数:29,代码来源:Airspaces.cpp

示例7: AddPolygon

 void
 AddPolygon(Airspaces &airspace_database)
 {
   AbstractAirspace *as = new AirspacePolygon(points);
   as->set_properties(Name, Type, Base, Top);
   airspace_database.insert(as);
 }
开发者ID:Plantain,项目名称:XCSoar,代码行数:7,代码来源:AirspaceParser.cpp

示例8: predicate

void
MapItemListBuilder::AddVisibleAirspace(
    const Airspaces &airspaces,
    const ProtectedAirspaceWarningManager *warning_manager,
    const AirspaceComputerSettings &computer_settings,
    const AirspaceRendererSettings &renderer_settings,
    const MoreData &basic, const DerivedInfo &calculated)
{
  AirspaceWarningList warnings;
  if (warning_manager != nullptr)
    warnings.Fill(*warning_manager);

  const AircraftState aircraft = ToAircraftState(basic, calculated);
  AirspaceAtPointPredicate predicate(computer_settings, renderer_settings,
                                     aircraft,
                                     warnings, location);

  for (const auto &i : airspaces.QueryWithinRange(location, 100)) {
    if (list.full())
      break;

    const AbstractAirspace &airspace = i.GetAirspace();
    if (predicate(airspace))
      list.append(new AirspaceMapItem(airspace));
  }
}
开发者ID:rkohel,项目名称:XCSoar,代码行数:26,代码来源:Builder.cpp

示例9: AddCircle

 void
 AddCircle(Airspaces &airspace_database)
 {
   AbstractAirspace *as = new AirspaceCircle(Center, Radius);
   as->set_properties(Name, Type, Base, Top);
   airspace_database.insert(as);
 }
开发者ID:Plantain,项目名称:XCSoar,代码行数:7,代码来源:AirspaceParser.cpp

示例10: Add

bool
Airspaces::SynchroniseInRange(const Airspaces& master,
                                const GeoPoint &location,
                                const fixed range,
                                const AirspacePredicate &condition)
{
  bool changed = false;
  const AirspaceVector contents_master = master.ScanRange(location, range, condition);
  AirspaceVector contents_self;
  contents_self.reserve(std::max(airspace_tree.size(), contents_master.size()));

  task_projection = master.task_projection; // ensure these are up to date

  for (const auto &v : airspace_tree)
    contents_self.push_back(v);

  // find items to add
  for (const auto &v : contents_master) {
    const AbstractAirspace* other = v.GetAirspace();

    bool found = false;
    for (auto s = contents_self.begin(); s != contents_self.end(); ++s) {
      const AbstractAirspace* self = s->GetAirspace();
      if (self == other) {
        found = true;
        contents_self.erase(s);
        break;
      }
    }
    if (!found && other->IsActive()) {
      Add(v.GetAirspace());
      changed = true;
    }
  }

  // anything left in the self list are items that were not in the query,
  // so delete them --- including the clearances!
  for (auto v = contents_self.begin(); v != contents_self.end();) {
    bool found = false;
    for (auto t = airspace_tree.begin(); t != airspace_tree.end(); ) {
      if (t->GetAirspace() == v->GetAirspace()) {
        AirspaceTree::const_iterator new_t = t;
        ++new_t;
        airspace_tree.erase_exact(*t);
        t = new_t;
        found = true;
      } else {
        ++t;
      }
    }
    assert(found);
    v->ClearClearance();
    v = contents_self.erase(v);
    changed = true;
  }
  if (changed)
    Optimise();
  return changed;
}
开发者ID:StefanL74,项目名称:XCSoar,代码行数:59,代码来源:Airspaces.cpp

示例11: AddPolygon

 void
 AddPolygon(Airspaces &airspace_database)
 {
   AbstractAirspace *as = new AirspacePolygon(points);
   as->set_properties(Name, Type, Base, Top);
   as->set_radio(Radio);
   as->set_days(days_of_operation);
   airspace_database.insert(as);
 }
开发者ID:Mrdini,项目名称:XCSoar,代码行数:9,代码来源:AirspaceParser.cpp

示例12: AddPolygon

 void
 AddPolygon(Airspaces &airspace_database)
 {
   AbstractAirspace *as = new AirspacePolygon(points);
   as->SetProperties(name, type, base, top);
   as->SetRadio(radio);
   as->SetDays(days_of_operation);
   airspace_database.Add(as);
 }
开发者ID:DRIZO,项目名称:xcsoar,代码行数:9,代码来源:AirspaceParser.cpp

示例13: AddCircle

 void
 AddCircle(Airspaces &airspace_database)
 {
   AbstractAirspace *as = new AirspaceCircle(center, radius);
   as->SetProperties(std::move(name), type, base, top);
   as->SetRadio(radio);
   as->SetDays(days_of_operation);
   airspace_database.Add(as);
 }
开发者ID:Adrien81,项目名称:XCSoar,代码行数:9,代码来源:AirspaceParser.cpp

示例14: FilterAirspaces

AirspaceSelectInfoVector
FilterAirspaces(const Airspaces &airspaces, const GeoPoint &location,
                const AirspaceFilterData &filter)
{
  AirspaceFilterVisitor visitor(location, airspaces.GetProjection(), filter);

  if (!negative(filter.distance))
    airspaces.VisitWithinRange(location, filter.distance, visitor);
  else
    for (const auto &i : airspaces)
      visitor.Visit(i.GetAirspace());

  if (filter.direction.IsNegative() && negative(filter.distance))
    SortByName(visitor.result);
  else
    SortByDistance(visitor.result, location, airspaces.GetProjection());

  return visitor.result;
}
开发者ID:ThomasXBMC,项目名称:XCSoar,代码行数:19,代码来源:AirspaceSorter.cpp

示例15: metric

void
AirspaceNearestSort::populate_queue(const Airspaces &airspaces,
                                    const fixed range)
{
  AirspacesInterface::AirspaceVector vectors =
    airspaces.ScanRange(m_location,
                        range,
                        m_condition);

  for (const Airspace &airspace : vectors) {
    const AbstractAirspace &as = airspace.GetAirspace();
    const AirspaceInterceptSolution ais =
      solve_intercept(as, airspaces.GetProjection());
    const fixed value = metric(ais);
    if (!negative(value))
      m_q.push(std::make_pair(value,
                              std::make_pair(ais, &as)));
  }
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:19,代码来源:AirspaceNearestSort.cpp


注:本文中的Airspaces类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。