本文整理汇总了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;
}
示例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";
}
}
}
}
示例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;
}
示例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";
}
}
}
}
示例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();
}
示例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;
}
示例7: AddPolygon
void
AddPolygon(Airspaces &airspace_database)
{
AbstractAirspace *as = new AirspacePolygon(points);
as->set_properties(Name, Type, Base, Top);
airspace_database.insert(as);
}
示例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));
}
}
示例9: AddCircle
void
AddCircle(Airspaces &airspace_database)
{
AbstractAirspace *as = new AirspaceCircle(Center, Radius);
as->set_properties(Name, Type, Base, Top);
airspace_database.insert(as);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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)));
}
}