static void TestSimpleTask() { OrderedTask task(task_behaviour); const StartPoint tp1(new LineSectorZone(wp1.location), wp1, task_behaviour, ordered_task_behaviour.start_constraints); task.Append(tp1); const FinishPoint tp2(new LineSectorZone(wp3.location), wp3, task_behaviour, ordered_task_behaviour.finish_constraints, false); task.Append(tp2); ok1(task.CheckTask()); AircraftState aircraft; aircraft.Reset(); aircraft.location = MakeGeoPoint(0, 44.5); aircraft.altitude = fixed(1700); task.Update(aircraft, aircraft, glide_polar); const GeoVector tp1_to_tp2 = wp1.location.DistanceBearing(wp3.location); const TaskStats &stats = task.GetStats(); ok1(stats.task_valid); ok1(!stats.task_started); ok1(!stats.task_finished); ok1(!stats.flight_mode_final_glide); ok1(equals(stats.distance_nominal, tp1_to_tp2.distance)); ok1(equals(stats.distance_min, tp1_to_tp2.distance)); ok1(equals(stats.distance_max, tp1_to_tp2.distance)); CheckLeg(tp1, aircraft, stats); CheckTotal(aircraft, stats, tp1, tp1, tp2); }
static Waypoint MakeWaypoint(double longitude, double latitude, double altitude) { return MakeWaypoint(Waypoint(MakeGeoPoint(longitude, latitude)), altitude); }
static void TestAATPoint() { OrderedTask task(task_behaviour); task.Append(StartPoint(new CylinderZone(wp1->location, 500), WaypointPtr(wp1), task_behaviour, ordered_task_settings.start_constraints)); task.Append(AATPoint(new CylinderZone(wp2->location, 10000), WaypointPtr(wp2), task_behaviour)); task.Append(FinishPoint(new CylinderZone(wp3->location, 500), WaypointPtr(wp3), task_behaviour, ordered_task_settings.finish_constraints)); task.SetActiveTaskPoint(1); task.UpdateGeometry(); ok1(task.CheckTask()); AATPoint &ap = (AATPoint &)task.GetPoint(1); ok1(!ap.IsTargetLocked()); ok1(equals(ap.GetTargetLocation(), wp2->location)); ap.LockTarget(true); ok1(ap.IsTargetLocked()); ok1(equals(ap.GetTargetLocation(), wp2->location)); GeoPoint target = MakeGeoPoint(0, 45.31); ap.SetTarget(target); ok1(ap.IsTargetLocked()); ok1(equals(ap.GetTargetLocation(), wp2->location)); ap.SetTarget(target, true); ok1(ap.IsTargetLocked()); ok1(equals(ap.GetTargetLocation(), target)); RangeAndRadial rar = ap.GetTargetRangeRadial(); ok1(equals(rar.range, 0.1112, 1000)); ok1(equals(rar.radial.Degrees(), 0, 200)); target = MakeGeoPoint(0, 45.29); ap.SetTarget(target, true); rar = ap.GetTargetRangeRadial(); ok1(equals(rar.range, -0.1112, 1000)); ok1(equals(rar.radial.Degrees(), 180, 200) || equals(rar.radial.Degrees(), -180, 200)); target = MakeGeoPoint(-0.05, 45.3); ap.SetTarget(target, true); rar = ap.GetTargetRangeRadial(); ok1(equals(rar.range, 0.39217)); ok1(equals(rar.radial.Degrees(), -89.98)); target = MakeGeoPoint(0.05, 45.3); ap.SetTarget(target, true); rar = ap.GetTargetRangeRadial(); ok1(equals(rar.range, 0.39217)); ok1(equals(rar.radial.Degrees(), 89.98)); for (int radial = -170; radial <= 170; radial += 10) { const Angle radial2 = Angle::Degrees(radial); for (int range = 10; range <= 100; range += 10) { const double range2((radial >= -90 && radial <= 90 ? range : -range) / 100.); ap.SetTarget(RangeAndRadial{range2, radial2}, task.GetTaskProjection()); rar = ap.GetTargetRangeRadial(); ok1(equals(rar.range, range2, 100)); ok1(equals(rar.radial.Degrees(), radial2.Degrees(), 100)); } } }