X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNavaids%2Fpoidb.cxx;h=15da16813305dbfc13a4acbe8a56e320d73a3639;hb=b30408b862ae0a300ff32ef90b20cdde9efdd499;hp=bfc7c81ef4fcff54130b977d5ea87de75b52b008;hpb=723654183327ba59c1038120407a272e2c022269;p=flightgear.git diff --git a/src/Navaids/poidb.cxx b/src/Navaids/poidb.cxx index bfc7c81ef..15da16813 100644 --- a/src/Navaids/poidb.cxx +++ b/src/Navaids/poidb.cxx @@ -22,6 +22,8 @@ # include "config.h" #endif +#include "poidb.hxx" + #include #include #include @@ -30,7 +32,7 @@ #include #include -#include "poidb.hxx" + using std::string; @@ -47,22 +49,24 @@ mapPOITypeToFGPType(int aTy) } } - - namespace flightgear { -static PositionedID readPOIFromStream(std::istream& aStream, +static PositionedID readPOIFromStream(std::istream& aStream, NavDataCache* cache, FGPositioned::Type type = FGPositioned::INVALID) { - NavDataCache* cache = NavDataCache::instance(); + if (aStream.eof()) { + return 0; + } + aStream >> skipws; + if (aStream.peek() == '#') { + aStream >> skipeol; + return 0; + } + int rawType; aStream >> rawType; - if (aStream.eof() || (rawType == '#')) { - return 0; - } - double lat, lon; std::string name; aStream >> lat >> lon; @@ -80,8 +84,7 @@ static PositionedID readPOIFromStream(std::istream& aStream, return 0; } - PositionedID r = cache->createPOI(type, name, pos); - return r; + return cache->createPOI(type, name, pos); } // load and initialize the POI database @@ -93,14 +96,12 @@ bool poiDBInit(const SGPath& path) return false; } - in >> skipcomment; - + NavDataCache* cache = NavDataCache::instance(); while (!in.eof()) { - readPOIFromStream(in); - in >> skipcomment; + readPOIFromStream(in, cache); } // of stream data loop - return true; + return true; } } // of namespace flightgear