int main(int argc, char** argv) { if (!ParseArgs(argc, argv)) return 0; plan_tests(52); Waypoints waypoints; GeoPoint center(Angle::Degrees(51.4), Angle::Degrees(7.85)); // AddSpiralWaypoints creates 151 waypoints from // 0km to 150km distance in 1km steps AddSpiralWaypoints(waypoints, center); ok1(!waypoints.IsEmpty()); ok1(waypoints.size() == 151); TestLookups(waypoints, center); TestNamePrefixVisitor(waypoints); TestRangeVisitor(waypoints, center); TestGetNearest(waypoints, center); TestIterator(waypoints); ok(TestCopy(waypoints), "waypoint copy", 0); ok(TestErase(waypoints, 3), "waypoint erase", 0); ok(TestReplace(waypoints, 4), "waypoint replace", 0); // test clear waypoints.Clear(); ok1(waypoints.IsEmpty()); ok1(waypoints.size() == 0); return exit_status(); }
static bool TestWaypointFile(const TCHAR* filename, Waypoints &way_points, unsigned num_wps) { NullOperationEnvironment operation; if (!ok1(ReadWaypointFile(filename, way_points, WaypointFactory(WaypointOrigin::NONE), operation))) { skip(2, 0, "parsing waypoint file failed"); return false; } way_points.Optimise(); ok1(!way_points.IsEmpty()); ok1(way_points.size() == num_wps); return true; }
void WaypointGlue::SetHome(Waypoints &way_points, const RasterTerrain *terrain, ComputerSettings &settings, const bool reset) { LogStartUp(_T("SetHome")); if (reset) settings.poi.home_waypoint = -1; // check invalid home waypoint or forced reset due to file change const Waypoint *wp = FindHomeId(way_points, settings.poi); if (wp == NULL) { /* fall back to HomeLocation, try to find it in the waypoint database */ wp = FindHomeLocation(way_points, settings.poi); if (wp == NULL) // search for home in waypoint list, if we don't have a home wp = FindFlaggedHome(way_points, settings.poi); } // check invalid task ref waypoint or forced reset due to file change if (reset || way_points.IsEmpty() || !way_points.LookupId(settings.team_code.team_code_reference_waypoint)) // set team code reference waypoint if we don't have one settings.team_code.team_code_reference_waypoint = settings.poi.home_waypoint; if (device_blackboard != NULL) { if (wp != NULL) { // OK, passed all checks now LogStartUp(_T("Start at home waypoint")); device_blackboard->SetStartupLocation(wp->location, wp->altitude); } else if (terrain != NULL) { // no home at all, so set it from center of terrain if available GeoPoint loc = terrain->GetTerrainCenter(); LogStartUp(_T("Start at terrain center")); device_blackboard->SetStartupLocation(loc, fixed(terrain->GetTerrainHeight(loc))); } } }
static bool TestWaypointFile(const TCHAR* filename, Waypoints &way_points, unsigned num_wps) { WaypointReader f(filename, 0); if (!ok1(!f.Error())) { skip(3, 0, "opening waypoint file failed"); return false; } NullOperationEnvironment operation; if(!ok1(f.Parse(way_points, operation))) { skip(2, 0, "parsing waypoint file failed"); return false; } way_points.Optimise(); ok1(!way_points.IsEmpty()); ok1(way_points.size() == num_wps); return true; }
static bool test_replay_retrospective() { Directory::Create(_T("output/results")); std::ofstream f("output/results/res-sample.txt"); Waypoints waypoints; WaypointReader w(waypoint_file.c_str(), 0); if (!ok1(!w.Error())) { printf("# waypoint file %s\n", waypoint_file.c_str()); skip(2, 0, "opening waypoint file failed"); return false; } NullOperationEnvironment operation; if(!ok1(w.Parse(waypoints, operation))) { skip(1, 0, "parsing waypoint file failed"); return false; } waypoints.Optimise(); ok1(!waypoints.IsEmpty()); Retrospective retro(waypoints); retro.search_range = range_threshold; retro.angle_tolerance = Angle::Degrees(autopilot_parms.bearing_noise); FileLineReaderA *reader = new FileLineReaderA(replay_file.c_str()); if (reader->error()) { delete reader; return false; } waypoints.Optimise(); IgcReplay sim(reader); NMEAInfo basic; basic.Reset(); while (sim.Update(basic)) { n_samples++; if (retro.UpdateSample(basic.location)) { std::ofstream g("output/results/res-retro.txt"); // report task auto candidate_list = retro.getNearWaypointList(); for (auto it = candidate_list.begin(); it != candidate_list.end(); ++it) { const Waypoint& wp = it->waypoint; g << (double)wp.location.longitude.Degrees() << " " << (double)wp.location.latitude.Degrees() << " " << "\"" << wp.name << "\"\n"; } } f << (double)basic.time << " " << (double)basic.location.longitude.Degrees() << " " << (double)basic.location.latitude.Degrees() << "\n"; f.flush(); }; double d_ach, d_can; retro.CalcDistances(d_ach, d_can); printf("# distances %f %f\n", (double)d_ach, (double)d_can); printf("# size %d\n", retro.getNearWaypointList().size()); return true; }