From ebfe2ee6f501a19f4a96f8c5fb59e6207e51d70a Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 4 Jul 2013 10:29:47 +0100 Subject: [PATCH] Bug 1137, handle single-digit runways. rwyprefs.xml sometimes specify runways without a leading '0', which confuses the ident lookup. Print a message, and fix up such idents at load time, so '8' -> '08', '3L' -> '03L' which matches our internal scheme. --- src/Airports/runwayprefs.cxx | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/Airports/runwayprefs.cxx b/src/Airports/runwayprefs.cxx index 4ee6ac7b3..46c9bcb58 100644 --- a/src/Airports/runwayprefs.cxx +++ b/src/Airports/runwayprefs.cxx @@ -29,15 +29,20 @@ #include #include -#include +#include +#include #include +#include + #include
#include #include "runwayprefs.hxx" #include "airport.hxx" +using namespace simgear; + /****************************************************************************** * ScheduleTime ***************e*************************************************************/ @@ -142,19 +147,20 @@ void RunwayList::set(const std::string & tp, const std::string & lst) // timeOffsetInDays = weekday - currTimeDate->getGmt()->tm_wday; // timeCopy = timeCopy.substr(2,timeCopy.length()); type = tp; - std::string rwys = lst; - std::string rwy; - while (rwys.find(",") != std::string::npos) { - rwy = rwys.substr(0, rwys.find(",", 0)); - //cerr << "adding runway [" << rwy << "] to the list " << endl; - preferredRunways.push_back(rwy); - rwys.erase(0, rwys.find(",", 0) + 1); // erase until after the first whitspace - while (rwys[0] == ' ') - rwys.erase(0, 1); // Erase any leading whitespaces. - //cerr << "Remaining runway list " << rwys; + + + + BOOST_FOREACH(std::string s, strutils::split(lst, ",")) { + std::string ident = strutils::strip(s); + + // http://code.google.com/p/flightgear-bugs/issues/detail?id=1137 + if ((ident.size() < 2) || !isdigit(ident[1])) { + SG_LOG(SG_GENERAL, SG_INFO, "RunwayList::set: padding runway ident '" << ident << "'"); + ident = "0" + ident; + } + + preferredRunways.push_back(ident); } - preferredRunways.push_back(rwys); - //exit(1); } void RunwayList::clear() -- 2.39.5