177 double maxCross,
stringVec* currentlyActive)
180 int activeRwys = rwyList.size();
188 int bestMatch = 0, bestChoice = 0;
190 if (activeRwys == 0) {
199 nrOfPreferences = rwyList[0].getPreferredRunways().size();
200 bool foundValidSelection =
false;
201 for (
int i = nrOfPreferences - 1;
i >= 0;
i--) {
209 bool validSelection =
true;
211 for (
int j = 0; j < activeRwys; j++) {
212 const auto& currentRunwayPrefs = rwyList.at(j).getPreferredRunways();
217 if ((
int)currentRunwayPrefs.size() <=
i) {
218 validSelection =
false;
222 const auto& ident(currentRunwayPrefs.at(
i));
224 SG_LOG(SG_GENERAL, SG_WARN,
225 "no such runway:" << ident <<
" at " << airport->
ident());
226 validSelection =
false;
233 hdgDiff = fabs(windHeading - rwy->
headingDeg());
234 std::string l_name = rwy->
name();
237 hdgDiff = 360 - hdgDiff;
239 hdgDiff *= ((2 *
M_PI) / 360.0);
240 crossWind = windSpeed * sin(hdgDiff);
241 tailWind = -windSpeed * cos(hdgDiff);
245 if ((tailWind > maxTail) || (crossWind > maxCross)) {
247 validSelection =
false;
253 it != currentlyActive->end(); ++it) {
255 if ((*it) == l_name) {
261 if (validSelection) {
263 foundValidSelection =
true;
264 if (match >= bestMatch) {
272 if (foundValidSelection) {
274 nrActive = activeRwys;
283 for (
int i = activeRwys - 1;
i;
i--) {
284 if (rwyList[
i].getType() ==
"landing"s)
286 if (rwyList[
i].getType() ==
"takeoff"s)
290 nrOfPreferences = rwyList[0].getPreferredRunways().size();
291 for (
int i = 0;
i < nrOfPreferences;
i++) {
292 bool validSelection =
true;
293 for (
int j = 0; j < 2; j++) {
294 const auto& currentRunwayPrefs = rwyList.at(choice[j]).getPreferredRunways();
295 if (
i >= (
int)currentRunwayPrefs.size()) {
296 validSelection =
false;
300 const auto& l_name = currentRunwayPrefs.at(
i);
302 validSelection =
false;
308 hdgDiff = fabs(windHeading - rwy->
headingDeg());
310 hdgDiff = 360 - hdgDiff;
311 hdgDiff *= ((2 *
M_PI) / 360.0);
312 crossWind = windSpeed * sin(hdgDiff);
313 tailWind = -windSpeed * cos(hdgDiff);
314 if ((tailWind > maxTail) || (crossWind > maxCross)) {
315 validSelection =
false;
319 if (validSelection) {
339 SG_LOG(SG_AI, SG_DEV_ALERT,
"RunwayGroup::getActive: invalid index " <<
i);
345 const bool usingFullList = nrActive == (int)rwyList.size();
347 const auto& runways = rwyList.at(
i).getPreferredRunways();
348 name = runways.at(active);
349 type = rwyList[
i].getType();
351 const auto& runways = rwyList.at(choice[
i]).getPreferredRunways();
352 name = runways.at(active);
353 type = rwyList[choice[
i]].getType();
367 comTimes{other.comTimes},
368 genTimes{other.genTimes},
369 milTimes{other.milTimes}
371 initialized = other.initialized;
374 for (
i = other.preferences.begin();
i != other.preferences.end(); ++
i)
375 preferences.push_back(*
i);
void setActive(const FGAirport *airport, double windSpeed, double windHeading, double maxTail, double maxCross, stringVec *curr)