- // standardize input number
- string tmp = runwayno.substr(1, 1);
- if (( tmp == "L" || tmp == "R" || tmp == "C" ) || (runwayno.size() == 1)) {
- tmp = runwayno;
- cout << "Standardising rwy number from " << tmp;
- runwayno = "0" + tmp;
- cout << " to " << runwayno << '\n';
- }
-
- c4_RowRef row = vRunway->GetAt(index);
- string rowid = (const char *) pID(row);
- string rowrwyno = (const char *) pRwy(row);
- while ( rowid == aptid ) {
- next_index = index + 1;
-
- if ( rowrwyno == runwayno ) {
- r->id = (const char *) pID(row);
- r->rwy_no = (const char *) pRwy(row);
- r->lon = (double) pLon(row);
- r->lat = (double) pLat(row);
- r->heading = (double) pHdg(row);
- r->length = (double) pLen(row);
- r->width = (double) pWid(row);
- r->surface_flags = (const char *) pSurf(row);
- r->end1_flags = (const char *) pEnd1(row);
- r->end2_flags = (const char *) pEnd2(row);
-
- return true;
- }
-
- // Search again with the other-end runway number
- // Remember we have to munge the heading and rwy_no results if this one matches
- rowrwyno = GetReverseRunwayNo(rowrwyno);
- // cout << "New rowrwyno = " << rowrwyno << '\n';
- if ( rowrwyno == runwayno ) {
- r->id = (const char *) pID(row);
- r->rwy_no = rowrwyno;
- r->lon = (double) pLon(row);
- r->lat = (double) pLat(row);
- r->heading = (double) pHdg(row) + 180.0;
- r->length = (double) pLen(row);
- r->width = (double) pWid(row);
- r->surface_flags = (const char *) pSurf(row);
- r->end1_flags = (const char *) pEnd2(row);
- r->end2_flags = (const char *) pEnd1(row);
- // I've swapped the end flags as well
-
- return true;
- }
-
- index++;
- row = vRunway->GetAt(index);
- rowid = (const char *) pID(row);
- rowrwyno = (const char *) pRwy(row);
- }
-
- return false;
-}
-
-
-FGRunway FGRunways::search( const string& aptid ) {
- FGRunway a;
- search( aptid, &a );
- return a;
-}
-
-
-// search for the specified id
-bool FGRunways::next( FGRunway* r ) {
- c4_StringProp pID ("ID");
- c4_StringProp pRwy ("Rwy");
- c4_FloatProp pLon ("Longitude");
- c4_FloatProp pLat ("Latitude");
- c4_FloatProp pHdg ("Heading");
- c4_FloatProp pLen ("Length");
- c4_FloatProp pWid ("Width");
- c4_StringProp pSurf ("SurfaceFlags");
- c4_StringProp pEnd1 ("End1Flags");
- c4_StringProp pEnd2 ("End2Flags");
-
- int size = vRunway->GetSize();
- // cout << "total records = " << size << endl;
-
- int index = next_index;
- // cout << "index = " << index << endl;
-
- if ( index == -1 || index >= size ) {
- return false;
- }
-
- next_index = index + 1;
-
- c4_RowRef row = vRunway->GetAt(index);
-
- r->id = (const char *) pID(row);
- r->rwy_no = (const char *) pRwy(row);
- r->lon = (double) pLon(row);
- r->lat = (double) pLat(row);
- r->heading = (double) pHdg(row);
- r->length = (double) pLen(row);
- r->width = (double) pWid(row);
- r->surface_flags = (const char *) pSurf(row);
- r->end1_flags = (const char *) pEnd1(row);
- r->end2_flags = (const char *) pEnd2(row);
-
- return true;