Fix for route-path when leg 0 is not a runway
Avoid doing turn-computation for the first waypoint, even if it’s not a runway. Add a unit-test to cover this case. Reported by Josh Davidson
This commit is contained in:
parent
7c2a5e9e99
commit
64eaf6fe03
4 changed files with 36 additions and 2 deletions
|
@ -442,6 +442,9 @@ bool FGIO::isMultiplayerRequested()
|
|||
// is easier than checking the raw Options arguments, but works before
|
||||
// this subsytem is actuallyt created.
|
||||
auto channels = globals->get_channel_options_list();
|
||||
if (!channels)
|
||||
return false; // happens running tests
|
||||
|
||||
auto it = std::find_if(channels->begin(), channels->end(),
|
||||
[](const std::string& channelOption)
|
||||
{ return (channelOption.find("multiplay") == 0); });
|
||||
|
|
|
@ -405,8 +405,12 @@ public:
|
|||
legCourseTrue = rwy->headingDeg();
|
||||
flyOver = true;
|
||||
} else {
|
||||
// don't set legCourseValid
|
||||
legCourseValid = true;
|
||||
legCourseTrue = next.legCourseTrue;
|
||||
turnExitAngle = 0.0;
|
||||
turnExitPos = pos;
|
||||
flyOver = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <Navaids/navlist.hxx>
|
||||
#include <Navaids/navrecord.hxx>
|
||||
#include <Navaids/airways.hxx>
|
||||
#include <Navaids/fix.hxx>
|
||||
|
||||
#include <Airports/airport.hxx>
|
||||
|
||||
|
@ -149,6 +150,30 @@ void FlightplanTests::testRoutePathTrivialFlightPlan()
|
|||
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, fp1->totalDistanceNm(), 1e-9);
|
||||
}
|
||||
|
||||
void FlightplanTests::testRoutPathWpt0Midflight()
|
||||
{
|
||||
// test behaviour of RoutePath when WP0 is not a runway
|
||||
// happens for the Airbus ND which removes past wpts when sequencing
|
||||
|
||||
FlightPlanRef fp1 = makeTestFP("KNUQ", "14L", "PHNL", "22R",
|
||||
"ROKME WOVAB");
|
||||
RoutePath rtepath(fp1);
|
||||
|
||||
SGGeodVec vec = rtepath.pathForIndex(0);
|
||||
|
||||
FGAirportRef ksfo = FGAirport::findByIdent("KSFO");
|
||||
FGFixRef rokme = fgpositioned_cast<FGFix>(FGPositioned::findClosestWithIdent("ROKME", ksfo->geod()));
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(rokme->geod().getLongitudeDeg(), vec.front().getLongitudeDeg(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(rokme->geod().getLatitudeDeg(), vec.front().getLatitudeDeg(), 0.01);
|
||||
|
||||
SGGeodVec vec2 = rtepath.pathForIndex(1);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(rokme->geod().getLongitudeDeg(), vec2.front().getLongitudeDeg(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(rokme->geod().getLatitudeDeg(), vec2.front().getLatitudeDeg(), 0.01);
|
||||
|
||||
//CPPUNIT_ASSERT(vec.front()
|
||||
}
|
||||
|
||||
void FlightplanTests::testBasicAirways()
|
||||
{
|
||||
Airway* awy = Airway::findByIdent("J547", Airway::HighLevel);
|
||||
|
|
|
@ -38,7 +38,8 @@ class FlightplanTests : public CppUnit::TestFixture
|
|||
CPPUNIT_TEST(testBasicAirways);
|
||||
CPPUNIT_TEST(testAirwayNetworkRoute);
|
||||
CPPUNIT_TEST(testBug1814);
|
||||
|
||||
CPPUNIT_TEST(testRoutPathWpt0Midflight);
|
||||
|
||||
// CPPUNIT_TEST(testParseICAORoute);
|
||||
// CPPUNIT_TEST(testParseICANLowLevelRoute);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
@ -60,6 +61,7 @@ public:
|
|||
void testParseICAORoute();
|
||||
void testParseICANLowLevelRoute();
|
||||
void testBug1814();
|
||||
void testRoutPathWpt0Midflight();
|
||||
};
|
||||
|
||||
#endif // FG_FLIGHTPLAN_UNIT_TESTS_HXX
|
||||
|
|
Loading…
Reference in a new issue