SG_USING_STD(sort);
SG_USING_STD(random_shuffle);
+
/******************************************************************************
* ScheduleTime
***************e*************************************************************/
{
if ((start.size() != end.size()) || (start.size() != scheduleNames.size()))
{
- cerr << "Unable to parse schedule times" << endl;
+ SG_LOG( SG_GENERAL, SG_INFO, "Unable to parse schedule times" );
exit(1);
}
else
}
//couldn't find one so return 0;
//cerr << "Returning 0 " << endl;
- return string(0);
}
+ return string(0);
}
/******************************************************************************
* RunwayList
preferredRunways.push_back(*i);
return *this;
}
-void RunwayList::set(string tp, string lst)
+void RunwayList::set(const string &tp, const string &lst)
{
//weekday = atoi(timeCopy.substr(0,1).c_str());
// timeOffsetInDays = weekday - currTimeDate->getGmt()->tm_wday;
return *this;
}
-void RunwayGroup::setActive(string aptId,
+void RunwayGroup::setActive(const string &aptId,
double windSpeed,
double windHeading,
double maxTail,
if ((tailWind > maxTail) || (crossWind > maxCross))
validSelection = false;
}else {
- cerr << "Failed to find runway " << name << " at " << aptId << endl;
+ SG_LOG( SG_GENERAL, SG_INFO, "Failed to find runway " << name << " at " << aptId );
exit(1);
}
if ((tailWind > maxTail) || (crossWind > maxCross))
validSelection = false;
}else {
- cerr << "Failed to find runway " << name << " at " << aptId << endl;
+ SG_LOG( SG_GENERAL, SG_INFO, "Failed to find runway " << name << " at " << aptId );
exit(1);
}
}
-void RunwayGroup::getActive(int i, string *name, string *type)
+void RunwayGroup::getActive(int i, string &name, string &type)
{
if (i == -1)
{
}
if (nrActive == (int)rwyList.size())
{
- *name = rwyList[i].getRwyList(active);
- *type = rwyList[i].getType();
+ name = rwyList[i].getRwyList(active);
+ type = rwyList[i].getType();
}
else
{
- *name = rwyList[choice[i]].getRwyList(active);
- *type = rwyList[choice[i]].getType();
+ name = rwyList[choice[i]].getRwyList(active);
+ type = rwyList[choice[i]].getType();
}
}
/*****************************************************************************
return 0;
}
-RunwayGroup *FGRunwayPreference::getGroup(const string groupName)
+RunwayGroup *FGRunwayPreference::getGroup(const string &groupName)
{
PreferenceListIterator i = preferences.begin();
if (preferences.begin() == preferences.end())
}
//based on a string containing hour and minute, return nr seconds since day start.
-time_t FGRunwayPreference::processTime(string tme)
+time_t FGRunwayPreference::processTime(const string &tme)
{
string hour = tme.substr(0, tme.find(":",0));
string minute = tme.substr(tme.find(":",0)+1, tme.length());
/*****************************************************************************
* Helper function for parsing position string
****************************************************************************/
-double processPosition(string pos)
+double processPosition(const string &pos)
{
string prefix;
string subs;
double hdg,
double rad,
int idx,
- string name,
- string tpe,
- string codes)
+ const string &name,
+ const string &tpe,
+ const string &codes)
{
latitude = lat;
longitude = lon;
}
}
-FGAirport::FGAirport(string id, double lon, double lat, double elev, string name, bool has_metar)
+FGAirport::FGAirport(const string &id, double lon, double lat, double elev, const string &name, bool has_metar)
{
_id = id;
_longitude = lon;
groundNetwork.init();
}
-bool FGAirport::getAvailableParking(double *lat, double *lon, double *heading, int *gateId, double rad, string flType, string acType, string airline)
+bool FGAirport::getAvailableParking(double *lat, double *lon, double *heading, int *gateId, double rad, const string &flType, const string &acType, const string &airline)
{
bool found = false;
bool available = false;
<< endl;
}
-void FGAirport::setRwyUse(FGRunwayPreference& ref)
+void FGAirport::setRwyUse(const FGRunwayPreference& ref)
{
rwyPrefs = ref;
//cerr << "Exiting due to not implemented yet" << endl;
//exit(1);
}
-void FGAirport::getActiveRunway(string trafficType, int action, string *runway)
+void FGAirport::getActiveRunway(const string &trafficType, int action, string &runway)
{
double windSpeed;
double windHeading;
if (!(rwyPrefs.available()))
{
- chooseRunwayFallback(runway);
+ runway = chooseRunwayFallback();
return; // generic fall back goes here
}
else
for (int i = 0; i < nrActiveRunways; i++)
{
type = "unknown"; // initialize to something other than landing or takeoff
- currRunwayGroup->getActive(i, &name, &type);
+ currRunwayGroup->getActive(i, name, type);
if (type == "landing")
{
landing.push_back(name);
int nr = takeoff.size();
if (nr)
{
- *runway = takeoff[(rand() % nr)];
+ runway = takeoff[(rand() % nr)];
}
else
{ // Fallback
- chooseRunwayFallback(runway);
+ runway = chooseRunwayFallback();
}
}
if (action == 2) // landing
int nr = landing.size();
if (nr)
{
- *runway = landing[(rand() % nr)];
+ runway = landing[(rand() % nr)];
}
else
{ //fallback
- chooseRunwayFallback(runway);
+ runway = chooseRunwayFallback();
}
}
- //*runway = globals->get_runways()->search(_id, int(windHeading));
- //cerr << "Seleceted runway: " << *runway << endl;
+ //runway = globals->get_runways()->search(_id, int(windHeading));
+ //cerr << "Seleceted runway: " << runway << endl;
}
}
-void FGAirport::chooseRunwayFallback(string *runway)
+string FGAirport::chooseRunwayFallback()
{
FGEnvironment
stationweather = ((FGEnvironmentMgr *) globals->get_subsystem("environment"))
//which is consistent with Flightgear's initial setup.
}
- *runway = globals->get_runways()->search(_id, int(windHeading));
- return; // generic fall back goes here
+ return globals->get_runways()->search(_id, int(windHeading));
}
hasNetwork = false;
}
-void FGGroundNetwork::addSegment(FGTaxiSegment seg)
+void FGGroundNetwork::addSegment(const FGTaxiSegment &seg)
{
segments.push_back(seg);
}
-void FGGroundNetwork::addNode(FGTaxiNode node)
+void FGGroundNetwork::addNode(const FGTaxiNode &node)
{
nodes.push_back(node);
}
int FGGroundNetwork::findNearestNode(double lat, double lon)
{
- double minDist = HUGE;
+ double minDist = HUGE_VAL;
double course, dist;
int index;
SGWayPoint first (lon,
if (!foundRoute)
{
- cerr << "Failed to find route from waypoint " << start << " to " << end << endl;
+ SG_LOG( SG_GENERAL, SG_INFO, "Failed to find route from waypoint " << start << " to " << end );
exit(1);
}
sort(routes.begin(), routes.end());
}
else
{
- cerr << "4" << endl;
+ SG_LOG( SG_GENERAL, SG_DEBUG, "4" );
}
traceStack.pop_back();
totalDistance -= distance;
if((d = ulOpenDir(aid.c_str())) == NULL)
return;
while((dent = ulReadDir(d)) != NULL) {
- cerr << "Dent: " << dent->d_name; // DEBUG
+ SG_LOG( SG_GENERAL, SG_DEBUG, "Dent: " << dent->d_name );
ai_dirs.insert(dent->d_name);
}
ulCloseDir(d);
// add an entry to the list
-void FGAirportList::add( const string id, const double longitude,
+void FGAirportList::add( const string &id, const double longitude,
const double latitude, const double elevation,
- const string name, const bool has_metar )
+ const string &name, const bool has_metar )
{
FGRunwayPreference rwyPrefs;
FGAirport* a = new FGAirport(id, longitude, latitude, elevation, name, has_metar);