+// Return reverse rwy number
+// eg 01 -> 19
+// 03L -> 21R
+static string GetReverseRunwayNo(string rwyno) {
+ // cout << "Original rwyno = " << rwyNo << '\n';
+
+ // standardize input number
+ string tmp = rwyno.substr(1, 1);
+ if (( tmp == "L" || tmp == "R" || tmp == "C" ) || (rwyno.size() == 1)) {
+ tmp = rwyno;
+ rwyno = "0" + tmp;
+ SG_LOG( SG_GENERAL, SG_INFO, "Standardising rwy number from " << tmp
+ << " to " << rwyno );
+ }
+
+ char buf[4];
+ int rn = atoi(rwyno.substr(0,2).c_str());
+ rn += 18;
+ while(rn > 36) {
+ rn -= 36;
+ }
+ sprintf(buf, "%02i", rn);
+ if(rwyno.size() == 3) {
+ if(rwyno.substr(2,1) == "L") {
+ buf[2] = 'R';
+ buf[3] = '\0';
+ } else if (rwyno.substr(2,1) == "R") {
+ buf[2] = 'L';
+ buf[3] = '\0';
+ } else if (rwyno.substr(2,1) == "C") {
+ buf[2] = 'C';
+ buf[3] = '\0';
+ } else {
+ SG_LOG(SG_GENERAL, SG_ALERT, "Unknown runway code "
+ << rwyno << " passed to GetReverseRunwayNo(...)");
+ }
+ }
+ return((string)buf);
+}
+
+