#include <Airports/runways.hxx>
#include "runwayprefs.hxx"
+#include "simple.hxx"
/******************************************************************************
* ScheduleTime
// preference, however, we don't want to stop right there, because we also
// don't want to randomly swap runway preferences, unless there is a need to.
//
-
+ validSelection = true;
for (int j = 0; j < activeRwys; j++)
{
- validSelection = true;
+
name = rwyList[j].getRwyList(i);
- //cerr << "Name of Runway: " << name << endl;
+ //cerr << "Name of Runway: " << name;
if (globals->get_runways()->search( aptId,
name,
&rwy))
hdgDiff *= ((2*M_PI)/360.0); // convert to radians
crossWind = windSpeed * sin(hdgDiff);
tailWind = -windSpeed * cos(hdgDiff);
- //cerr << "Tailwind : " << tailWind << endl;
- //cerr << "Crosswnd : " << crossWind << endl;
+ //cerr << ". Tailwind : " << tailWind;
+ //cerr << ". Crosswnd : " << crossWind;
if ((tailWind > maxTail) || (crossWind > maxCross))
{
- //cerr << "Invalid : ";
+ //cerr << ". [Invalid] " << endl;
validSelection = false;
}
else
{
- //cerr << "Valid : ";
+ //cerr << ". [Valid] ";
}
}else {
SG_LOG( SG_GENERAL, SG_INFO, "Failed to find runway " << name << " at " << aptId );
exit(1);
}
+ //cerr << endl;
}
if (validSelection)
{
- //cerr << "Valid : ";
+ //cerr << "Valid selection : " << i << endl;;
foundValidSelection = true;
for (stringVecIterator it = currentlyActive->begin();
it != currentlyActive->end(); it++)
{
if ((*it) == name)
match++;
- if (match >= bestMatch) {
- bestMatch = match;
- bestChoice = i;
- }
}
+ if (match >= bestMatch) {
+ bestMatch = match;
+ bestChoice = i;
+ }
}
//cerr << "Preference " << i << " bestMatch " << bestMatch << " choice " << bestChoice << endl;
}
/*****************************************************************************
* FGRunway preference
****************************************************************************/
-FGRunwayPreference::FGRunwayPreference()
+FGRunwayPreference::FGRunwayPreference(FGAirport* ap) :
+ _ap(ap)
{
//cerr << "Running default Constructor" << endl;
initialized = false;
FGRunwayPreference::FGRunwayPreference(const FGRunwayPreference &other)
{
initialized = other.initialized;
- value = other.value;
- scheduleName = other.scheduleName;
comTimes = other.comTimes; // Commercial Traffic;
genTimes = other.genTimes; // General Aviation;
milTimes = other.milTimes; // Military Traffic;
- currTimes= other.currTimes; // Needed for parsing;
- rwyList = other.rwyList;
- rwyGroup = other.rwyGroup;
PreferenceListConstIterator i;
for (i = other.preferences.begin(); i != other.preferences.end(); i++)
preferences.push_back(*i);
FGRunwayPreference & FGRunwayPreference::operator= (const FGRunwayPreference &other)
{
initialized = other.initialized;
- value = other.value;
- scheduleName = other.scheduleName;
comTimes = other.comTimes; // Commercial Traffic;
genTimes = other.genTimes; // General Aviation;
milTimes = other.milTimes; // Military Traffic;
- currTimes= other.currTimes; // Needed for parsing;
- rwyList = other.rwyList;
- rwyGroup = other.rwyGroup;
PreferenceListConstIterator i;
preferences.clear();
for (i = other.preferences.begin(); i != other.preferences.end(); i++)
return 0;
}
-void FGRunwayPreference::startXML () {
- // cout << "Start XML" << endl;
-}
-
-void FGRunwayPreference::endXML () {
- cout << "End XML" << endl;
-}
-
-void FGRunwayPreference::startElement (const char * name, const XMLAttributes &atts) {
- //cout << "StartElement " << name << endl;
- value = string("");
- if (!(strcmp(name, "wind"))) {
- //cerr << "Will be processing Wind" << endl;
- for (int i = 0; i < atts.size(); i++)
- {
- //cout << " " << atts.getName(i) << '=' << atts.getValue(i) << endl;
- //attname = atts.getName(i);
- if (atts.getName(i) == string("tail")) {
- //cerr << "Tail Wind = " << atts.getValue(i) << endl;
- currTimes.setTailWind(atof(atts.getValue(i)));
- }
- if (atts.getName(i) == string("cross")) {
- //cerr << "Cross Wind = " << atts.getValue(i) << endl;
- currTimes.setCrossWind(atof(atts.getValue(i)));
- }
- }
- }
- if (!(strcmp(name, "time"))) {
- //cerr << "Will be processing time" << endl;
- for (int i = 0; i < atts.size(); i++)
- {
- if (atts.getName(i) == string("start")) {
- //cerr << "Start Time = " << atts.getValue(i) << endl;
- currTimes.addStartTime(processTime(atts.getValue(i)));
- }
- if (atts.getName(i) == string("end")) {
- //cerr << "End time = " << atts.getValue(i) << endl;
- currTimes.addEndTime(processTime(atts.getValue(i)));
- }
- if (atts.getName(i) == string("schedule")) {
- //cerr << "Schedule Name = " << atts.getValue(i) << endl;
- currTimes.addScheduleName(atts.getValue(i));
- }
- }
- }
- if (!(strcmp(name, "takeoff"))) {
- rwyList.clear();
- }
- if (!(strcmp(name, "landing")))
- {
- rwyList.clear();
- }
- if (!(strcmp(name, "schedule"))) {
- for (int i = 0; i < atts.size(); i++)
- {
- //cout << " " << atts.getName(i) << '=' << atts.getValue(i) << endl;
- //attname = atts.getName(i);
- if (atts.getName(i) == string("name")) {
- //cerr << "Schedule name = " << atts.getValue(i) << endl;
- scheduleName = atts.getValue(i);
- }
- }
- }
-}
-
-//based on a string containing hour and minute, return nr seconds since day start.
-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());
-
- //cerr << "hour = " << hour << " Minute = " << minute << endl;
- return (atoi(hour.c_str()) * 3600 + atoi(minute.c_str()) * 60);
-}
-
-void FGRunwayPreference::endElement (const char * name) {
- //cout << "End element " << name << endl;
- if (!(strcmp(name, "rwyuse"))) {
- initialized = true;
- }
- if (!(strcmp(name, "com"))) { // Commercial Traffic
- //cerr << "Setting time table for commerical traffic" << endl;
- comTimes = currTimes;
- currTimes.clear();
- }
- if (!(strcmp(name, "gen"))) { // General Aviation
- //cerr << "Setting time table for general aviation" << endl;
- genTimes = currTimes;
- currTimes.clear();
- }
- if (!(strcmp(name, "mil"))) { // Military Traffic
- //cerr << "Setting time table for military traffic" << endl;
- genTimes = currTimes;
- currTimes.clear();
- }
-
- if (!(strcmp(name, "takeoff"))) {
- //cerr << "Adding takeoff: " << value << endl;
- rwyList.set(name, value);
- rwyGroup.add(rwyList);
- }
- if (!(strcmp(name, "landing"))) {
- //cerr << "Adding landing: " << value << endl;
- rwyList.set(name, value);
- rwyGroup.add(rwyList);
- }
- if (!(strcmp(name, "schedule"))) {
- //cerr << "Adding schedule" << scheduleName << endl;
- rwyGroup.setName(scheduleName);
- //rwyGroup.addRunways(rwyList);
- preferences.push_back(rwyGroup);
- rwyGroup.clear();
- //exit(1);
- }
-}
-
-void FGRunwayPreference::data (const char * s, int len) {
- string token = string(s,len);
- //cout << "Character data " << string(s,len) << endl;
- //if ((token.find(" ") == string::npos && (token.find('\n')) == string::npos))
- // value += token;
- //else
- // value = string("");
- value += token;
-}
-
-void FGRunwayPreference::pi (const char * target, const char * data) {
- //cout << "Processing instruction " << target << ' ' << data << endl;
-}
-
-void FGRunwayPreference::warning (const char * message, int line, int column) {
- cout << "Warning: " << message << " (" << line << ',' << column << ')'
- << endl;
-}
-
-void FGRunwayPreference::error (const char * message, int line, int column) {
- cout << "Error: " << message << " (" << line << ',' << column << ')'
- << endl;
-}
+ string FGRunwayPreference::getId() {
+ return _ap->getId();
+ };