Format
This commit is contained in:
+3
-4
@@ -20,11 +20,10 @@ namespace file
|
||||
std::ifstream in(XPLANE_PLUGIN_DIRECTORY CONFIG);
|
||||
std::string line;
|
||||
while (std::getline(in, line)) {
|
||||
std::vector<std::string> fields =
|
||||
germanairlinesva::util::split(line, '=');
|
||||
std::vector<std::string> fields = util::split(line, '=');
|
||||
if (fields.size() >= 2) {
|
||||
germanairlinesva::util::trim(fields[0]);
|
||||
germanairlinesva::util::trim(fields[1]);
|
||||
util::trim(fields[0]);
|
||||
util::trim(fields[1]);
|
||||
if (fields[0] == "scenery") {
|
||||
this->scenery = fields[1];
|
||||
} else if (fields[0] == "user") {
|
||||
|
||||
+3
-4
@@ -7,7 +7,7 @@ namespace file
|
||||
namespace simdata
|
||||
{
|
||||
Gate::Gate(std::string designator,
|
||||
struct germanairlinesva::geodata::point center,
|
||||
struct geodata::point center,
|
||||
std::uint8_t radius)
|
||||
{
|
||||
this->designator = designator;
|
||||
@@ -22,10 +22,9 @@ namespace file
|
||||
write<decltype(this->radius)>(out, this->radius);
|
||||
}
|
||||
|
||||
bool Gate::contains(germanairlinesva::geodata::point coordinates) const
|
||||
bool Gate::contains(geodata::point coordinates) const
|
||||
{
|
||||
return germanairlinesva::geodata::distanceEarthP(this->center,
|
||||
coordinates);
|
||||
return geodata::distanceEarthP(this->center, coordinates);
|
||||
}
|
||||
} // namespace simdata
|
||||
} // namespace file
|
||||
|
||||
@@ -26,14 +26,16 @@ namespace file
|
||||
std::uint32_t time;
|
||||
std::uint16_t altitude = 0;
|
||||
std::uint16_t groundSpeed = 0;
|
||||
struct germanairlinesva::geodata::point coordinates{NAN, NAN};
|
||||
struct geodata::point coordinates {
|
||||
NAN, NAN
|
||||
};
|
||||
|
||||
public:
|
||||
RecordingEntry() = default;
|
||||
RecordingEntry(std::uint32_t time,
|
||||
std::uint16_t altitude,
|
||||
std::uint16_t groundSpeed,
|
||||
struct germanairlinesva::geodata::point coordinates);
|
||||
struct geodata::point coordinates);
|
||||
|
||||
void toFile(std::ofstream &out) const;
|
||||
|
||||
|
||||
@@ -34,16 +34,16 @@ namespace file
|
||||
{
|
||||
private:
|
||||
std::string designator;
|
||||
struct germanairlinesva::geodata::point center;
|
||||
struct geodata::point center;
|
||||
std::uint8_t radius;
|
||||
|
||||
public:
|
||||
Gate(std::string designator,
|
||||
struct germanairlinesva::geodata::point center,
|
||||
struct geodata::point center,
|
||||
std::uint8_t radius);
|
||||
|
||||
void toFile(std::ofstream &out) const;
|
||||
bool contains(germanairlinesva::geodata::point coordinates) const;
|
||||
bool contains(geodata::point coordinates) const;
|
||||
|
||||
inline const std::string to_string() const
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace file
|
||||
{
|
||||
private:
|
||||
std::string designator;
|
||||
struct germanairlinesva::geodata::box bounds;
|
||||
struct geodata::box bounds;
|
||||
std::uint8_t width;
|
||||
std::uint16_t length;
|
||||
std::uint16_t trueHeading;
|
||||
@@ -50,7 +50,7 @@ namespace file
|
||||
double width);
|
||||
// From database
|
||||
Runway(std::string designator,
|
||||
struct germanairlinesva::geodata::box bounds,
|
||||
struct geodata::box bounds,
|
||||
std::uint8_t width,
|
||||
std::uint16_t length,
|
||||
std::uint16_t trueHeading);
|
||||
|
||||
@@ -42,10 +42,7 @@ namespace file
|
||||
class SimDatabase
|
||||
{
|
||||
private:
|
||||
std::map<
|
||||
std::string,
|
||||
std::pair<std::vector<germanairlinesva::file::simdata::Gate>,
|
||||
std::vector<germanairlinesva::file::simdata::Runway>>>
|
||||
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
airports;
|
||||
|
||||
void fromFile();
|
||||
@@ -64,11 +61,11 @@ namespace file
|
||||
const std::vector<Runway>>
|
||||
operator[](std::string key)
|
||||
{
|
||||
try {
|
||||
return this->airports.at(key);
|
||||
} catch (std::out_of_range &ex) {
|
||||
return std::pair<const std::vector<Gate>,
|
||||
const std::vector<Runway>>();
|
||||
auto it = this->airports.find(key);
|
||||
if (it != this->airports.end()) {
|
||||
return this->airports[key];
|
||||
} else {
|
||||
return std::pair<std::vector<Gate>, std::vector<Runway>>();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,15 +20,13 @@ namespace file
|
||||
const std::string defaultFile,
|
||||
const std::string sceneryPack,
|
||||
const std::string logFile,
|
||||
std::map<std::string,
|
||||
std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
&airports);
|
||||
|
||||
void makeAirport(
|
||||
const std::string &kind,
|
||||
std::ifstream &infile,
|
||||
std::map<std::string,
|
||||
std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
&airports,
|
||||
std::ofstream &logfile);
|
||||
void makeGate15(std::vector<Gate> &gates,
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ namespace file
|
||||
{
|
||||
Logbook::Logbook()
|
||||
{
|
||||
if (germanairlinesva::util::fileExists(XPLANE_PLUGIN_DIRECTORY LOGBOOK)) {
|
||||
if (util::fileExists(XPLANE_PLUGIN_DIRECTORY LOGBOOK)) {
|
||||
this->fromFile();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,10 @@ namespace file
|
||||
{
|
||||
namespace recording
|
||||
{
|
||||
RecordingEntry::RecordingEntry(
|
||||
std::uint32_t time,
|
||||
std::uint16_t altitude,
|
||||
std::uint16_t groundSpeed,
|
||||
struct germanairlinesva::geodata::point coordinates)
|
||||
RecordingEntry::RecordingEntry(std::uint32_t time,
|
||||
std::uint16_t altitude,
|
||||
std::uint16_t groundSpeed,
|
||||
struct geodata::point coordinates)
|
||||
{
|
||||
this->time = time;
|
||||
this->altitude = altitude;
|
||||
|
||||
+14
-15
@@ -15,24 +15,23 @@ namespace file
|
||||
{
|
||||
this->designator = designator;
|
||||
this->width = width;
|
||||
this->length = germanairlinesva::geodata::distanceEarthD(latitudeStart,
|
||||
longitudeStart,
|
||||
latitudeEnd,
|
||||
longitudeEnd);
|
||||
this->trueHeading = (std::uint16_t)std::round(
|
||||
germanairlinesva::geodata::bearingDD(latitudeStart,
|
||||
longitudeStart,
|
||||
latitudeEnd,
|
||||
longitudeEnd));
|
||||
this->bounds = germanairlinesva::geodata::calculateBoxDD(
|
||||
{latitudeStart, longitudeStart},
|
||||
{latitudeEnd, longitudeEnd},
|
||||
this->trueHeading,
|
||||
this->width);
|
||||
this->length = geodata::distanceEarthD(latitudeStart,
|
||||
longitudeStart,
|
||||
latitudeEnd,
|
||||
longitudeEnd);
|
||||
this->trueHeading =
|
||||
(std::uint16_t)std::round(geodata::bearingDD(latitudeStart,
|
||||
longitudeStart,
|
||||
latitudeEnd,
|
||||
longitudeEnd));
|
||||
this->bounds = geodata::calculateBoxDD({latitudeStart, longitudeStart},
|
||||
{latitudeEnd, longitudeEnd},
|
||||
this->trueHeading,
|
||||
this->width);
|
||||
}
|
||||
|
||||
Runway::Runway(std::string designator,
|
||||
germanairlinesva::geodata::box bounds,
|
||||
geodata::box bounds,
|
||||
std::uint8_t width,
|
||||
std::uint16_t length,
|
||||
std::uint16_t trueHeading)
|
||||
|
||||
@@ -56,8 +56,7 @@ namespace file
|
||||
std::uint16_t numGates = read<std::uint16_t>(in);
|
||||
for (int j = 0; j < numGates; j++) {
|
||||
std::string designator = readString(in);
|
||||
struct germanairlinesva::geodata::point center =
|
||||
read<struct germanairlinesva::geodata::point>(in);
|
||||
struct geodata::point center = read<struct geodata::point>(in);
|
||||
std::uint8_t radius = read<std::uint8_t>(in);
|
||||
|
||||
this->airports[icao].first.emplace_back(designator, center, radius);
|
||||
@@ -67,8 +66,7 @@ namespace file
|
||||
for (int j = 0; j < numRunways; j++) {
|
||||
std::string designator = readString(in);
|
||||
// Bounds
|
||||
struct germanairlinesva::geodata::box bounds =
|
||||
read<struct germanairlinesva::geodata::box>(in);
|
||||
struct geodata::box bounds = read<struct geodata::box>(in);
|
||||
std::uint8_t width = read<std::uint8_t>(in);
|
||||
std::uint16_t length = read<std::uint16_t>(in);
|
||||
std::uint16_t trueHeading = read<std::uint16_t>(in);
|
||||
|
||||
+8
-10
@@ -39,9 +39,8 @@ namespace file
|
||||
std::vector<std::string> packs;
|
||||
while (std::getline(custom, line)) {
|
||||
if ((pos = line.find("SCENERY_PACK")) != std::string::npos) {
|
||||
std::string path =
|
||||
germanairlinesva::util::rtrim_copy(line.substr(pos + 13)) +
|
||||
"Earth nav data/apt.dat";
|
||||
std::string path = util::rtrim_copy(line.substr(pos + 13)) +
|
||||
"Earth nav data/apt.dat";
|
||||
packs.emplace_back(path);
|
||||
}
|
||||
}
|
||||
@@ -84,11 +83,10 @@ namespace file
|
||||
int validCount = 0;
|
||||
|
||||
while (std::getline(infile, line)) {
|
||||
std::vector<std::string> fields =
|
||||
germanairlinesva::util::split(line, ' ');
|
||||
fields = germanairlinesva::util::select_T<std::string>(
|
||||
fields,
|
||||
[](const std::string &s) { return s.length() > 0; });
|
||||
std::vector<std::string> fields = util::split(line, ' ');
|
||||
fields = util::select_T<std::string>(fields, [](const std::string &s) {
|
||||
return s.length() > 0;
|
||||
});
|
||||
|
||||
if (fields.empty())
|
||||
continue;
|
||||
@@ -155,7 +153,7 @@ namespace file
|
||||
}
|
||||
gateName += fields.back();
|
||||
gateName = std::regex_replace(gateName, std::regex{","}, "0");
|
||||
struct germanairlinesva::geodata::point pt {
|
||||
struct geodata::point pt {
|
||||
std::stod(fields[1]), std::stod(fields[2])
|
||||
};
|
||||
gates.emplace_back(gateName, pt, 40);
|
||||
@@ -188,7 +186,7 @@ namespace file
|
||||
gateName += fields.back();
|
||||
gateName = std::regex_replace(gateName, std::regex{","}, "0");
|
||||
|
||||
struct germanairlinesva::geodata::point pt {
|
||||
struct geodata::point pt {
|
||||
std::stod(fields[1]), std::stod(fields[2])
|
||||
};
|
||||
gates.emplace_back(gateName, pt, 40);
|
||||
|
||||
Reference in New Issue
Block a user