This commit is contained in:
2022-09-07 03:04:26 +02:00
parent 910afad3b5
commit 25c4d8474d
4 changed files with 37 additions and 45 deletions
+3 -3
View File
@@ -20,10 +20,10 @@ namespace germanairlinesva_simdata
void makeAirport(
const std::string &kind,
std::ifstream *infile,
std::ifstream &infile,
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
*airports,
std::ofstream *logfile);
&airports,
std::ofstream &logfile);
void makeGate15(std::vector<Gate> *gates, std::vector<std::string> fields);
void makeRunway(std::vector<Runway> *runways,
std::vector<std::string> fields);
+23 -25
View File
@@ -27,7 +27,7 @@ namespace germanairlinesva_simdata
// Default
logfile << "<FILE> " << defaultFile << std::endl;
makeAirport("DEFAULT", &base, &airports, &logfile);
makeAirport("DEFAULT", base, airports, logfile);
base.close();
std::string line;
@@ -47,7 +47,7 @@ namespace germanairlinesva_simdata
std::ifstream pack(path);
if (pack.good()) {
logfile << "<FILE> " << path << std::endl;
makeAirport("CUSTOM", &pack, &airports, &logfile);
makeAirport("CUSTOM", pack, airports, logfile);
pack.close();
} else {
pack.close();
@@ -66,10 +66,10 @@ namespace germanairlinesva_simdata
void makeAirport(
const std::string &kind,
std::ifstream *infile,
std::ifstream &infile,
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
*airports,
std::ofstream *logfile)
&airports,
std::ofstream &logfile)
{
std::string line;
std::string *currentIcao = nullptr;
@@ -79,7 +79,7 @@ namespace germanairlinesva_simdata
int apCount = 0;
int validCount = 0;
while (std::getline(*infile, line)) {
while (std::getline(infile, line)) {
std::vector<std::string> fields = germanairlinesva_util::split(line, ' ');
fields = germanairlinesva_util::select_T<std::string>(
fields,
@@ -91,54 +91,52 @@ namespace germanairlinesva_simdata
// Write to file if ICAO is valid, and we have gates and runways
if (currentIcao != nullptr && !tmpRunways.empty() &&
!tmpGates.empty()) {
(*airports)[*currentIcao] = {tmpGates, tmpRunways};
airports[*currentIcao] = {tmpGates, tmpRunways};
validCount += 1;
*logfile << "\t<STATUS> " << *currentIcao << " committed"
<< std::endl;
logfile << "\t<STATUS> " << *currentIcao << " committed" << std::endl;
} else if (currentIcao != nullptr) {
*logfile << "\t<STATUS> " << *currentIcao
<< " had no gates or runways" << std::endl;
logfile << "\t<STATUS> " << *currentIcao << " had no gates or runways"
<< std::endl;
}
tmpGates = std::vector<Gate>();
tmpRunways = std::vector<Runway>();
currentIcao = new std::string(fields[4]);
apCount += 1;
*logfile << "\t<" << kind << "> " << line << std::endl;
logfile << "\t<" << kind << "> " << line << std::endl;
} else if (currentIcao != nullptr && fields[0] == "15") {
makeGate15(&tmpGates, fields);
*logfile << "\t\t<GATE OLD> " << line << std::endl;
logfile << "\t\t<GATE OLD> " << line << std::endl;
} else if (fields[0] == "16" || fields[0] == "17") {
// Write to file if ICAO is valid, and we have gates and runways
if (currentIcao != nullptr && !tmpRunways.empty() &&
!tmpGates.empty()) {
(*airports)[*currentIcao] = {tmpGates, tmpRunways};
airports[*currentIcao] = {tmpGates, tmpRunways};
validCount += 1;
*logfile << "\t<STATUS> " << *currentIcao << " committed"
<< std::endl;
logfile << "\t<STATUS> " << *currentIcao << " committed" << std::endl;
} else if (currentIcao != nullptr) {
*logfile << "\t<STATUS> " << *currentIcao
<< " had no gates or runways" << std::endl;
logfile << "\t<STATUS> " << *currentIcao << " had no gates or runways"
<< std::endl;
}
tmpGates = std::vector<Gate>();
tmpRunways = std::vector<Runway>();
currentIcao = nullptr;
*logfile << "\t<" << kind << " SKIPPED> " << line << std::endl;
logfile << "\t<" << kind << " SKIPPED> " << line << std::endl;
} else if (currentIcao != nullptr && fields[0] == "100") {
makeRunway(&tmpRunways, fields);
*logfile << "\t\t<RUNWAY> " << line << std::endl;
logfile << "\t\t<RUNWAY> " << line << std::endl;
} else if (currentIcao != nullptr && fields[0] == "1300") {
makeGate1300(&tmpGates, fields);
*logfile << "\t\t<GATE> " << line << std::endl;
logfile << "\t\t<GATE> " << line << std::endl;
}
}
if (currentIcao != nullptr && !tmpRunways.empty() && !tmpGates.empty()) {
(*airports)[*currentIcao] = {tmpGates, tmpRunways};
airports[*currentIcao] = {tmpGates, tmpRunways};
validCount += 1;
*logfile << "\t<STATUS> " << *currentIcao << " committed" << std::endl;
logfile << "\t<STATUS> " << *currentIcao << " committed" << std::endl;
}
*logfile << "<STATUS> " << apCount << " airports found, of which "
<< validCount << " are valid" << std::endl;
logfile << "<STATUS> " << apCount << " airports found, of which "
<< validCount << " are valid" << std::endl;
}
void makeGate15(std::vector<Gate> *gates, std::vector<std::string> fields)