예제 #1
0
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();

}
예제 #2
0
 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);
 }
예제 #3
0
 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);
 }
예제 #4
0
  void
  AddPolygon(Airspaces &airspace_database)
  {
    if (points.size() < 3)
      return;

    AbstractAirspace *as = new AirspacePolygon(points);
    as->SetProperties(std::move(name), type, base, top);
    as->SetRadio(radio);
    as->SetDays(days_of_operation);
    airspace_database.Add(as);
  }
예제 #5
0
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;
}