Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
boyinchen committed Apr 4, 2020
1 parent e329155 commit ec6ea65
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
31 changes: 14 additions & 17 deletions Library/DataSet/DataSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ static inline void TruncateNB(string &s)
std::set<int> bf::InternalStruct::ParseSID(int vid, std::ifstream &is, GraphHelper *gh)
{
std::set<int> v;
static auto vertices = gh->GetVertices();
const static int bufferSize = 1024;
auto vertices = gh->GetVertices();
constexpr int bufferSize = 1024;
char buffer[bufferSize];
string s, fix;
while (is >> s)
Expand Down Expand Up @@ -70,8 +70,8 @@ std::set<int> bf::InternalStruct::ParseSID(int vid, std::ifstream &is, GraphHelp
std::set<int> bf::InternalStruct::ParseSTAR(int vid, std::ifstream &is, GraphHelper *gh)
{
std::set<int> v;
static auto vertices = gh->GetVertices();
const static int bufferSize = 1024;
auto vertices = gh->GetVertices();
constexpr int bufferSize = 1024;
char buffer[bufferSize];
string s, fix;
while (is.getline(buffer, bufferSize))
Expand Down Expand Up @@ -121,8 +121,7 @@ bf::DataSet::~DataSet(void)

void bf::DataSet::InitializeAirports(void)
{
static bool done = false;
if (done)
if (bIsAirportsInitialized)
return;
std::ifstream ifs(path + "/NAVDATA/airports.dat");
if (!ifs.is_open())
Expand All @@ -139,13 +138,12 @@ void bf::DataSet::InitializeAirports(void)
graph->graphHelper->AddVertex(icao, (float) atof(latitude.c_str()), (float) atof(longitude.c_str()));
}
ifs.close();
done = true;
bIsAirportsInitialized = true;
}

void bf::DataSet::InitializeFixes(void)
{
static bool done = false;
if (done)
if (bIsFixesInitialized)
return;
std::ifstream ifs(path + "/NAVDATA/wpNavRTE.txt");
if (!ifs.is_open())
Expand All @@ -168,13 +166,12 @@ void bf::DataSet::InitializeFixes(void)
ifs.close();
graph->SetMaxVertices(graph->graphHelper->GetVertices().size());
graph->AllocateEdges();
done = true;
bIsFixesInitialized = true;
}

void bf::DataSet::InitializeRoutes(void)
{
static bool done = false;
if (done)
if (bIsRoutesInitialized)
return;
std::ifstream ifs(path + "/NAVDATA/wpNavRTE.txt");
if (!ifs.is_open())
Expand Down Expand Up @@ -219,7 +216,7 @@ void bf::DataSet::InitializeRoutes(void)
lastLat = lat;
}
ifs.close();
done = true;
bIsRoutesInitialized = true;
}

void bf::DataSet::Initialize(void)
Expand All @@ -236,10 +233,10 @@ void bf::DataSet::InitializeAirport(string s)
i = (char) toupper(i);
if (is->initializedAirports.find(s) != is->initializedAirports.end())
return;
// static auto DCT_ID = graph->graphHelper->GetRouteIndex("DCT");
static auto SID_ID = graph->graphHelper->GetRouteIndex("SID");
static auto STAR_ID = graph->graphHelper->GetRouteIndex("STAR");
static auto vertices = graph->graphHelper->GetVertices();
// auto DCT_ID = graph->graphHelper->GetRouteIndex("DCT");
auto SID_ID = graph->graphHelper->GetRouteIndex("SID");
auto STAR_ID = graph->graphHelper->GetRouteIndex("STAR");
auto vertices = graph->graphHelper->GetVertices();
std::ostringstream oss;
oss << path << "/SIDSTARS/" << s << ".txt";
std::ifstream ifs(oss.str());
Expand Down
4 changes: 4 additions & 0 deletions Library/DataSet/DataSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ namespace bf
string path;
Graph *graph;
InternalStruct *is;
bool bIsAirportsInitialized;
bool bIsFixesInitialized;
bool bIsRoutesInitialized;


void InitializeFixes(void);

Expand Down

0 comments on commit ec6ea65

Please sign in to comment.