]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/runways.cxx
- adjusted for no-value constructor for FGPanel
[flightgear.git] / src / Airports / runways.cxx
index 85639eb0ed001acee7dcb3dc8cadc03ee3be5266..89ca91e684a6c9b7b1e730959d769cabcd85ef2f 100644 (file)
@@ -31,9 +31,7 @@
 #include <simgear/compiler.h>
 
 #include <simgear/debug/logstream.hxx>
-#include <simgear/misc/fgstream.hxx>
-
-#include <Main/options.hxx>
+#include <simgear/misc/sgstream.hxx>
 
 #include STL_STRING
 #include STL_FUNCTIONAL
@@ -41,7 +39,7 @@
 
 #include "runways.hxx"
 
-FG_USING_NAMESPACE(std);
+SG_USING_NAMESPACE(std);
 
 
 FGRunway::FGRunway() {
@@ -57,7 +55,7 @@ FGRunways::FGRunways( const string& file ) {
     storage = new c4_Storage( file.c_str(), false );
 
     if ( !storage->Strategy().IsValid() ) {
-       FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << file );
+       SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << file );
        exit(-1);
     }
 
@@ -69,8 +67,8 @@ FGRunways::FGRunways( const string& file ) {
 }
 
 
-// search for the specified id
-bool FGRunways::search( const string& id, FGRunway* r ) {
+// search for the specified apt id
+bool FGRunways::search( const string& aptid, FGRunway* r ) {
     c4_StringProp pID ("ID");
     c4_StringProp pRwy ("Rwy");
     c4_FloatProp pLon ("Longitude");
@@ -82,7 +80,7 @@ bool FGRunways::search( const string& id, FGRunway* r ) {
     c4_StringProp pEnd1 ("End1Flags");
     c4_StringProp pEnd2 ("End2Flags");
 
-    int index = vRunway->Find(pID[id.c_str()]);
+    int index = vRunway->Find(pID[aptid.c_str()]);
     cout << "index = " << index << endl;
 
     if ( index == -1 ) {
@@ -108,9 +106,61 @@ bool FGRunways::search( const string& id, FGRunway* r ) {
 }
 
 
-FGRunway FGRunways::search( const string& id ) {
+// search for the specified apt id and runway no
+bool FGRunways::search( const string& aptid, const string& rwyno, 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 index = vRunway->Find(pID[aptid.c_str()]);
+    cout << "index = " << index << endl;
+
+    if ( index == -1 ) {
+       return false;
+    }
+
+    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 == rwyno ) {
+            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;
+        }
+
+        index++;
+        c4_RowRef row = vRunway->GetAt(index);
+        string rowid = (const char *) pID(row);
+        string rowrwyno = (const char *) pRwy(row);
+    }
+
+    return false;
+}
+
+
+FGRunway FGRunways::search( const string& aptid ) {
     FGRunway a;
-    search( id, &a );
+    search( aptid, &a );
     return a;
 }
 
@@ -159,7 +209,7 @@ bool FGRunways::next( FGRunway* r ) {
 
 // Destructor
 FGRunways::~FGRunways( void ) {
-    // gdbm_close( dbf );
+    delete storage;
 }
 
 
@@ -175,9 +225,9 @@ int FGRunwaysUtil::load( const string& file ) {
 
     runways.erase( runways.begin(), runways.end() );
 
-    fg_gzifstream in( file );
+    sg_gzifstream in( file );
     if ( !in.is_open() ) {
-       FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << file );
+       SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << file );
        exit(-1);
     }