Consts and references
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ namespace germanairlinesva_simdata
|
||||
|
||||
// From database
|
||||
Gate::Gate(std::string designator,
|
||||
germanairlinesva_geodata::point center,
|
||||
struct germanairlinesva_geodata::point center,
|
||||
std::uint8_t radius)
|
||||
{
|
||||
this->designator = designator;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace germanairlinesva_simdata
|
||||
{
|
||||
private:
|
||||
std::string designator;
|
||||
germanairlinesva_geodata::point center;
|
||||
struct germanairlinesva_geodata::point center;
|
||||
std::uint8_t radius;
|
||||
std::vector<std::uint8_t> file;
|
||||
|
||||
@@ -41,13 +41,13 @@ namespace germanairlinesva_simdata
|
||||
std::uint8_t radius);
|
||||
// From database
|
||||
Gate(std::string designator,
|
||||
germanairlinesva_geodata::point center,
|
||||
struct germanairlinesva_geodata::point center,
|
||||
std::uint8_t radius);
|
||||
|
||||
inline std::uint8_t *getBinaryData() { return file.data(); }
|
||||
inline std::size_t getBinaryLength() { return file.size(); }
|
||||
inline const std::uint8_t *getBinaryData() const { return file.data(); }
|
||||
inline std::size_t getBinaryLength() const { return file.size(); }
|
||||
|
||||
std::string to_string() const
|
||||
inline const std::string to_string() const
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << "Gate " << this->designator << " at " << this->center.latitude
|
||||
|
||||
@@ -49,10 +49,10 @@ namespace germanairlinesva_simdata
|
||||
std::uint16_t length,
|
||||
std::uint16_t trueHeading);
|
||||
|
||||
inline std::uint8_t *getBinaryData() { return file.data(); }
|
||||
inline std::size_t getBinaryLength() { return file.size(); }
|
||||
inline const std::uint8_t *getBinaryData() const { return file.data(); }
|
||||
inline std::size_t getBinaryLength() const { return file.size(); }
|
||||
|
||||
std::string to_string() const
|
||||
inline const std::string to_string() const
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << "Runway " << this->designator << " with bounds "
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
namespace germanairlinesva_simdata
|
||||
{
|
||||
int scan(
|
||||
const char *defaultFile,
|
||||
const char *sceneryPack,
|
||||
const char *logFile,
|
||||
const std::string defaultFile,
|
||||
const std::string sceneryPack,
|
||||
const std::string logFile,
|
||||
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
&airports);
|
||||
|
||||
@@ -24,10 +24,12 @@ namespace germanairlinesva_simdata
|
||||
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
&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);
|
||||
void makeGate1300(std::vector<Gate> *gates, std::vector<std::string> fields);
|
||||
void makeGate15(std::vector<Gate> &gates,
|
||||
const std::vector<std::string> &fields);
|
||||
void makeRunway(std::vector<Runway> &runways,
|
||||
const std::vector<std::string> &fields);
|
||||
void makeGate1300(std::vector<Gate> &gates,
|
||||
const std::vector<std::string> &fields);
|
||||
|
||||
} // namespace germanairlinesva_simdata
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace germanairlinesva_simdata
|
||||
static_cast<char *>(calloc(designatorLength + 1, sizeof(char)));
|
||||
in.read(designator, designatorLength + 1);
|
||||
// Center
|
||||
germanairlinesva_geodata::point center;
|
||||
struct germanairlinesva_geodata::point center;
|
||||
in.read(reinterpret_cast<char *>(¢er), sizeof(center));
|
||||
// Radius
|
||||
std::uint8_t radius;
|
||||
@@ -133,7 +133,7 @@ namespace germanairlinesva_simdata
|
||||
static_cast<char *>(calloc(designatorLength + 1, sizeof(char)));
|
||||
in.read(designator, designatorLength + 1);
|
||||
// Bounds
|
||||
germanairlinesva_geodata::box bounds;
|
||||
struct germanairlinesva_geodata::box bounds;
|
||||
in.read(reinterpret_cast<char *>(&bounds), sizeof(bounds));
|
||||
// Width
|
||||
std::uint8_t width;
|
||||
|
||||
+33
-26
@@ -3,9 +3,9 @@
|
||||
namespace germanairlinesva_simdata
|
||||
{
|
||||
int scan(
|
||||
const char *defaultFile,
|
||||
const char *sceneryPack,
|
||||
const char *logFile,
|
||||
const std::string defaultFile,
|
||||
const std::string sceneryPack,
|
||||
const std::string logFile,
|
||||
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
&airports)
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace germanairlinesva_simdata
|
||||
std::string path =
|
||||
germanairlinesva_util::rtrim_copy(line.substr(pos + 13)) +
|
||||
"Earth nav data/apt.dat";
|
||||
packs.push_back(path);
|
||||
packs.emplace_back(path);
|
||||
}
|
||||
}
|
||||
std::reverse(packs.begin(), packs.end());
|
||||
@@ -104,7 +104,7 @@ namespace germanairlinesva_simdata
|
||||
apCount += 1;
|
||||
logfile << "\t<" << kind << "> " << line << std::endl;
|
||||
} else if (currentIcao != nullptr && fields[0] == "15") {
|
||||
makeGate15(&tmpGates, fields);
|
||||
makeGate15(tmpGates, fields);
|
||||
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
|
||||
@@ -122,10 +122,10 @@ namespace germanairlinesva_simdata
|
||||
currentIcao = nullptr;
|
||||
logfile << "\t<" << kind << " SKIPPED> " << line << std::endl;
|
||||
} else if (currentIcao != nullptr && fields[0] == "100") {
|
||||
makeRunway(&tmpRunways, fields);
|
||||
makeRunway(tmpRunways, fields);
|
||||
logfile << "\t\t<RUNWAY> " << line << std::endl;
|
||||
} else if (currentIcao != nullptr && fields[0] == "1300") {
|
||||
makeGate1300(&tmpGates, fields);
|
||||
makeGate1300(tmpGates, fields);
|
||||
logfile << "\t\t<GATE> " << line << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,8 @@ namespace germanairlinesva_simdata
|
||||
<< validCount << " are valid" << std::endl;
|
||||
}
|
||||
|
||||
void makeGate15(std::vector<Gate> *gates, std::vector<std::string> fields)
|
||||
void makeGate15(std::vector<Gate> &gates,
|
||||
const std::vector<std::string> &fields)
|
||||
{
|
||||
std::string gateName;
|
||||
for (size_t j = 4; j < fields.size() - 1; j++) {
|
||||
@@ -148,27 +149,31 @@ namespace germanairlinesva_simdata
|
||||
gateName += fields.back();
|
||||
gateName = std::regex_replace(gateName, std::regex{","}, "0");
|
||||
|
||||
gates->push_back(
|
||||
Gate{gateName, std::stod(fields[1]), std::stod(fields[2]), 40});
|
||||
gates.emplace_back(gateName,
|
||||
std::stod(fields[1]),
|
||||
std::stod(fields[2]),
|
||||
40);
|
||||
}
|
||||
|
||||
void makeRunway(std::vector<Runway> *runways, std::vector<std::string> fields)
|
||||
void makeRunway(std::vector<Runway> &runways,
|
||||
const std::vector<std::string> &fields)
|
||||
{
|
||||
runways->push_back(Runway{fields[8],
|
||||
std::stod(fields[9]),
|
||||
std::stod(fields[10]),
|
||||
std::stod(fields[18]),
|
||||
std::stod(fields[19]),
|
||||
std::stod(fields[1])});
|
||||
runways->push_back(Runway{fields[17],
|
||||
std::stod(fields[18]),
|
||||
std::stod(fields[19]),
|
||||
std::stod(fields[9]),
|
||||
std::stod(fields[10]),
|
||||
std::stod(fields[1])});
|
||||
runways.emplace_back(fields[8],
|
||||
std::stod(fields[9]),
|
||||
std::stod(fields[10]),
|
||||
std::stod(fields[18]),
|
||||
std::stod(fields[19]),
|
||||
std::stod(fields[1]));
|
||||
runways.emplace_back(fields[17],
|
||||
std::stod(fields[18]),
|
||||
std::stod(fields[19]),
|
||||
std::stod(fields[9]),
|
||||
std::stod(fields[10]),
|
||||
std::stod(fields[1]));
|
||||
}
|
||||
|
||||
void makeGate1300(std::vector<Gate> *gates, std::vector<std::string> fields)
|
||||
void makeGate1300(std::vector<Gate> &gates,
|
||||
const std::vector<std::string> &fields)
|
||||
{
|
||||
std::string gateName;
|
||||
for (size_t j = 6; j < fields.size() - 1; j++) {
|
||||
@@ -177,7 +182,9 @@ namespace germanairlinesva_simdata
|
||||
gateName += fields.back();
|
||||
gateName = std::regex_replace(gateName, std::regex{","}, "0");
|
||||
|
||||
gates->push_back(
|
||||
Gate{gateName, std::stod(fields[1]), std::stod(fields[2]), 40});
|
||||
gates.emplace_back(gateName,
|
||||
std::stod(fields[1]),
|
||||
std::stod(fields[2]),
|
||||
40);
|
||||
}
|
||||
} // namespace germanairlinesva_simdata
|
||||
Reference in New Issue
Block a user