/** * 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.type = Waypoint::Type::AIRFIELD; wp.elevation = fixed(0.25); waypoints.Append(wp); wp = waypoints.Create(GeoPoint(Angle::Degrees(fixed_zero), Angle::Degrees(fixed_one))); wp.type = Waypoint::Type::AIRFIELD; wp.elevation = fixed(0.25); waypoints.Append(wp); wp = waypoints.Create(GeoPoint(Angle::Degrees(fixed_one), Angle::Degrees(fixed_one))); wp.name = _T("Hello"); wp.type = Waypoint::Type::AIRFIELD; wp.elevation = fixed_half; waypoints.Append(wp); wp = waypoints.Create(GeoPoint(Angle::Degrees(fixed(0.8)), Angle::Degrees(fixed(0.5)))); wp.name = _T("Unk"); wp.type = Waypoint::Type::AIRFIELD; wp.elevation = fixed(0.25); waypoints.Append(wp); wp = waypoints.Create(GeoPoint(Angle::Degrees(fixed_one), Angle::Degrees(fixed_zero))); wp.type = Waypoint::Type::AIRFIELD; wp.elevation = fixed(0.25); waypoints.Append(wp); wp = waypoints.Create(GeoPoint(Angle::Degrees(fixed_zero), Angle::Degrees(fixed(0.23)))); wp.type = Waypoint::Type::AIRFIELD; wp.elevation = 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.type = Waypoint::Type::NORMAL; wp.elevation = 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++) { const Waypoint *wp = waypoints.LookupId(i); if (wp != NULL) fin << *wp; } } return true; }
/** * Initialises waypoints with random and non-random waypoints * for testing * * @param waypoints waypoints class to add waypoints to */ bool SetupWaypoints(Waypoints &waypoints, const unsigned n) { Waypoint wp = waypoints.Create(GeoPoint(Angle::Zero(), Angle::Zero())); wp.type = Waypoint::Type::AIRFIELD; wp.elevation = fixed(0.25); waypoints.Append(std::move(wp)); wp = waypoints.Create(GeoPoint(Angle::Zero(), Angle::Degrees(1))); wp.type = Waypoint::Type::AIRFIELD; wp.elevation = fixed(0.25); waypoints.Append(std::move(wp)); wp = waypoints.Create(GeoPoint(Angle::Degrees(1), Angle::Degrees(1))); wp.name = _T("Hello"); wp.type = Waypoint::Type::AIRFIELD; wp.elevation = fixed(0.5); waypoints.Append(std::move(wp)); wp = waypoints.Create(GeoPoint(Angle::Degrees(0.8), Angle::Degrees(0.5))); wp.name = _T("Unk"); wp.type = Waypoint::Type::AIRFIELD; wp.elevation = fixed(0.25); waypoints.Append(std::move(wp)); wp = waypoints.Create(GeoPoint(Angle::Degrees(1), Angle::Zero())); wp.type = Waypoint::Type::AIRFIELD; wp.elevation = fixed(0.25); waypoints.Append(std::move(wp)); wp = waypoints.Create(GeoPoint(Angle::Zero(), Angle::Degrees(0.23))); wp.type = Waypoint::Type::AIRFIELD; wp.elevation = fixed(0.25); waypoints.Append(std::move(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(x / 1000.0), Angle::Degrees(y / 1000.0))); wp.type = Waypoint::Type::NORMAL; wp.elevation = fixed(z); waypoints.Append(std::move(wp)); } waypoints.Optimise(); if (verbose) { Directory::Create(Path(_T("output/results"))); std::ofstream fin("output/results/res-wp-in.txt"); for (unsigned i=1; i<=waypoints.size(); i++) { const Waypoint *wpt = waypoints.LookupId(i); if (wpt != NULL) fin << *wpt; } } return true; }