From 02def51a97fcfaf96a313ae961d7eb80a42edde6 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 20 Sep 2000 23:26:17 +0000 Subject: [PATCH] Tweaks to handle latest airport data file from Robin Peel. --- src/Airports/Makefile.am | 2 +- src/Airports/genrunways.cxx | 1 + src/Airports/simple.cxx | 46 ++++++++++++++++++++++++------------- src/Airports/simple.hxx | 2 +- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/Airports/Makefile.am b/src/Airports/Makefile.am index 9fcdb33e4..5a28f0710 100644 --- a/src/Airports/Makefile.am +++ b/src/Airports/Makefile.am @@ -12,4 +12,4 @@ gensimple_LDADD = libAirports.a -lsgdebug -lsgmisc -lmk4 -lz genrunways_SOURCES = genrunways.cxx genrunways_LDADD = libAirports.a -lsgdebug -lsgmisc -lmk4 -lz -INCLUDES += -I$(top_builddir) -I$(top_builddir)/src +INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/src diff --git a/src/Airports/genrunways.cxx b/src/Airports/genrunways.cxx index 97516eab0..d81f7474c 100644 --- a/src/Airports/genrunways.cxx +++ b/src/Airports/genrunways.cxx @@ -11,6 +11,7 @@ int main( int argc, char **argv ) { runways.dump_mk4( argv[2] ); } else { cout << "usage: " << argv[0] << " " << endl; + exit(-1); } cout << endl; diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx index 70c59ba94..6915132c7 100644 --- a/src/Airports/simple.cxx +++ b/src/Airports/simple.cxx @@ -125,34 +125,47 @@ int FGAirportsUtil::load( const string& file ) { exit(-1); } - /* - // We can use the STL copy algorithm because the input - // file doesn't contain and comments or blank lines. - copy( istream_iterator(in.stream()), - istream_iterator(), - inserter( airports, airports.begin() ) ); - */ + // skip first line of file + char tmp[256]; + in.getline( tmp, 256 ); + // read in each line of the file #ifdef __MWERKS__ - in >> skipcomment; + in >> ::skipws; char c = 0; while ( in.get(c) && c != '\0' ) { - in.putback(c); - in >> a; - airports.insert(a); - in >> skipcomment; + if ( c == 'A' ) { + in >> a; + in >> skipeol; + airports.insert(a); + } else if ( c == 'R' ) { + in >> skipeol; + } else { + in >> skipeol; + } + in >> ::skipws; } #else - in >> skipcomment; + in >> skipws; while ( ! in.eof() ) { - in >> a; - airports.insert(a); - in >> skipcomment; + char c = 0; + in.get(c); + if ( c == 'A' ) { + in >> a; + cout << "in <- " << a.id << endl; + in >> skipeol; + airports.insert(a); + } else if ( c == 'R' ) { + in >> skipeol; + } else { + in >> skipeol; + } + in >> skipws; } #endif @@ -185,6 +198,7 @@ bool FGAirportsUtil::dump_mk4( const string& file ) { const_iterator end = airports.end(); while ( current != end ) { // add each airport record + cout << "out -> " << current->id << endl; pID (row) = current->id.c_str(); pLon (row) = current->longitude; pLat (row) = current->latitude; diff --git a/src/Airports/simple.hxx b/src/Airports/simple.hxx index 2de3535dc..a3c757993 100644 --- a/src/Airports/simple.hxx +++ b/src/Airports/simple.hxx @@ -94,7 +94,7 @@ public: inline istream& operator >> ( istream& in, FGAirport& a ) { - return in >> a.id >> a.longitude >> a.latitude >> a.elevation; + return in >> a.id >> a.latitude >> a.longitude >> a.elevation; } -- 2.39.5