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(); }
void setup_airspaces(Airspaces& airspaces, const unsigned n) { #ifdef DO_PRINT std::ofstream fin("results/res-bb-in.txt"); #endif 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+0.5)); c.Latitude = Angle::degrees(fixed((rand()%1200-600)/1000.0+0.5)); 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+0.5)); c.Latitude = Angle::degrees(fixed((rand()%1200-600)/1000.0+0.5)); 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.insert(as); #ifdef DO_PRINT fin << *as; #endif } // try inserting nothing airspaces.insert(NULL); airspaces.optimise(); }