Style, Analyze
This commit is contained in:
+24
-23
@@ -22,34 +22,35 @@
|
||||
class Gate
|
||||
{
|
||||
private:
|
||||
std::string designator;
|
||||
double latitude;
|
||||
double longitude;
|
||||
std::vector<std::uint8_t> file;
|
||||
std::string designator;
|
||||
double latitude;
|
||||
double longitude;
|
||||
std::vector<std::uint8_t> file;
|
||||
|
||||
public:
|
||||
Gate(const std::string &designator, double latitude, double longitude)
|
||||
{
|
||||
Gate(const std::string &designator, double latitude, double longitude)
|
||||
{
|
||||
|
||||
this->designator = designator;
|
||||
this->latitude = latitude;
|
||||
this->longitude = longitude;
|
||||
this->designator = designator;
|
||||
this->latitude = latitude;
|
||||
this->longitude = longitude;
|
||||
|
||||
file = std::vector<std::uint8_t>(18 + this->designator.length(), 0);
|
||||
std::uint8_t *bufPtr = file.data();
|
||||
memset(bufPtr,
|
||||
static_cast<std::uint8_t>(this->designator.length()),
|
||||
sizeof(std::uint8_t));
|
||||
bufPtr++; // Designator length
|
||||
memcpy(bufPtr, this->designator.c_str(), this->designator.length());
|
||||
bufPtr += this->designator.length() + 1; // Designator plus null termination
|
||||
memcpy(bufPtr, &this->latitude, sizeof(this->latitude));
|
||||
bufPtr += 8; // Latitude
|
||||
memcpy(bufPtr, &this->longitude, sizeof(this->longitude));
|
||||
}
|
||||
file = std::vector<std::uint8_t>(18 + this->designator.length(), 0);
|
||||
std::uint8_t *bufPtr = file.data();
|
||||
memset(bufPtr,
|
||||
static_cast<std::uint8_t>(this->designator.length()),
|
||||
sizeof(std::uint8_t));
|
||||
bufPtr++; // Designator length
|
||||
memcpy(bufPtr, this->designator.c_str(), this->designator.length());
|
||||
bufPtr +=
|
||||
this->designator.length() + 1; // Designator plus null termination
|
||||
memcpy(bufPtr, &this->latitude, sizeof(this->latitude));
|
||||
bufPtr += 8; // Latitude
|
||||
memcpy(bufPtr, &this->longitude, sizeof(this->longitude));
|
||||
}
|
||||
|
||||
std::uint8_t *getBinaryData() { return file.data(); }
|
||||
std::size_t getBinaryLength() { return file.size(); }
|
||||
std::uint8_t *getBinaryData() { return file.data(); }
|
||||
std::size_t getBinaryLength() { return file.size(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -24,90 +24,91 @@
|
||||
class Runway
|
||||
{
|
||||
private:
|
||||
std::string designator;
|
||||
double latitudeStart;
|
||||
double longitudeStart;
|
||||
std::uint8_t width;
|
||||
std::uint16_t length;
|
||||
std::uint16_t trueHeading;
|
||||
std::vector<std::uint8_t> file;
|
||||
std::string designator;
|
||||
double latitudeStart;
|
||||
double longitudeStart;
|
||||
std::uint8_t width;
|
||||
std::uint16_t length;
|
||||
std::uint16_t trueHeading;
|
||||
std::vector<std::uint8_t> file;
|
||||
|
||||
public:
|
||||
Runway(std::string designator,
|
||||
double latitudeStart,
|
||||
double longitudeStart,
|
||||
double latitudeEnd,
|
||||
double longitudeEnd,
|
||||
double width)
|
||||
{
|
||||
this->designator = std::move(designator);
|
||||
this->latitudeStart = latitudeStart;
|
||||
this->longitudeStart = longitudeStart;
|
||||
this->width = (std::uint8_t)std::round(util::to_feet(width));
|
||||
double dist = util::distanceEarth(latitudeStart,
|
||||
longitudeStart,
|
||||
latitudeEnd,
|
||||
longitudeEnd);
|
||||
this->length = (std::uint16_t)std::round(util::to_feet(dist));
|
||||
this->trueHeading = (std::uint16_t)std::round(util::bearing(latitudeStart,
|
||||
longitudeStart,
|
||||
latitudeEnd,
|
||||
longitudeEnd));
|
||||
Runway(std::string designator,
|
||||
double latitudeStart,
|
||||
double longitudeStart,
|
||||
double latitudeEnd,
|
||||
double longitudeEnd,
|
||||
double width)
|
||||
{
|
||||
this->designator = std::move(designator);
|
||||
this->latitudeStart = latitudeStart;
|
||||
this->longitudeStart = longitudeStart;
|
||||
this->width = (std::uint8_t)std::round(util::to_feet(width));
|
||||
double dist = util::distanceEarth(latitudeStart,
|
||||
longitudeStart,
|
||||
latitudeEnd,
|
||||
longitudeEnd);
|
||||
this->length = (std::uint16_t)std::round(util::to_feet(dist));
|
||||
this->trueHeading =
|
||||
(std::uint16_t)std::round(util::bearing(latitudeStart,
|
||||
longitudeStart,
|
||||
latitudeEnd,
|
||||
longitudeEnd));
|
||||
|
||||
file = std::vector<std::uint8_t>(23 + this->designator.length(), 0);
|
||||
std::uint8_t *bufPtr = file.data();
|
||||
memset(bufPtr,
|
||||
static_cast<std::uint8_t>(this->designator.length()),
|
||||
sizeof(std::uint8_t));
|
||||
bufPtr++;
|
||||
memcpy(bufPtr, this->designator.c_str(), this->designator.length());
|
||||
bufPtr += this->designator.length() + 1;
|
||||
memcpy(bufPtr, &this->latitudeStart, sizeof(this->latitudeStart));
|
||||
bufPtr += sizeof(this->latitudeStart);
|
||||
memcpy(bufPtr, &this->longitudeStart, sizeof(this->longitudeStart));
|
||||
bufPtr += sizeof(this->longitudeStart);
|
||||
memcpy(bufPtr, &this->width, sizeof(this->width));
|
||||
bufPtr += sizeof(this->width);
|
||||
memcpy(bufPtr, &this->length, sizeof(this->length));
|
||||
bufPtr += sizeof(this->length);
|
||||
memcpy(bufPtr, &this->trueHeading, sizeof(this->trueHeading));
|
||||
}
|
||||
file = std::vector<std::uint8_t>(23 + this->designator.length(), 0);
|
||||
std::uint8_t *bufPtr = file.data();
|
||||
memset(bufPtr,
|
||||
static_cast<std::uint8_t>(this->designator.length()),
|
||||
sizeof(std::uint8_t));
|
||||
bufPtr++;
|
||||
memcpy(bufPtr, this->designator.c_str(), this->designator.length());
|
||||
bufPtr += this->designator.length() + 1;
|
||||
memcpy(bufPtr, &this->latitudeStart, sizeof(this->latitudeStart));
|
||||
bufPtr += sizeof(this->latitudeStart);
|
||||
memcpy(bufPtr, &this->longitudeStart, sizeof(this->longitudeStart));
|
||||
bufPtr += sizeof(this->longitudeStart);
|
||||
memcpy(bufPtr, &this->width, sizeof(this->width));
|
||||
bufPtr += sizeof(this->width);
|
||||
memcpy(bufPtr, &this->length, sizeof(this->length));
|
||||
bufPtr += sizeof(this->length);
|
||||
memcpy(bufPtr, &this->trueHeading, sizeof(this->trueHeading));
|
||||
}
|
||||
|
||||
Runway(std::string designator,
|
||||
double latitudeStart,
|
||||
double longitudeStart,
|
||||
std::uint8_t width,
|
||||
std::uint16_t length,
|
||||
std::uint16_t trueHeading)
|
||||
{
|
||||
this->designator = std::move(designator);
|
||||
this->latitudeStart = latitudeStart;
|
||||
this->longitudeStart = longitudeStart;
|
||||
this->width = width;
|
||||
this->length = length;
|
||||
this->trueHeading = trueHeading;
|
||||
Runway(std::string designator,
|
||||
double latitudeStart,
|
||||
double longitudeStart,
|
||||
std::uint8_t width,
|
||||
std::uint16_t length,
|
||||
std::uint16_t trueHeading)
|
||||
{
|
||||
this->designator = std::move(designator);
|
||||
this->latitudeStart = latitudeStart;
|
||||
this->longitudeStart = longitudeStart;
|
||||
this->width = width;
|
||||
this->length = length;
|
||||
this->trueHeading = trueHeading;
|
||||
|
||||
file = std::vector<std::uint8_t>(23 + this->designator.length(), 0);
|
||||
std::uint8_t *bufPtr = file.data();
|
||||
memset(bufPtr,
|
||||
static_cast<std::uint8_t>(this->designator.length()),
|
||||
sizeof(std::uint8_t));
|
||||
bufPtr++;
|
||||
memcpy(bufPtr, this->designator.c_str(), this->designator.length());
|
||||
bufPtr += this->designator.length() + 1;
|
||||
memcpy(bufPtr, &this->latitudeStart, sizeof(this->latitudeStart));
|
||||
bufPtr += sizeof(this->latitudeStart);
|
||||
memcpy(bufPtr, &this->longitudeStart, sizeof(this->longitudeStart));
|
||||
bufPtr += sizeof(this->longitudeStart);
|
||||
memcpy(bufPtr, &this->width, sizeof(this->width));
|
||||
bufPtr += sizeof(this->width);
|
||||
memcpy(bufPtr, &this->length, sizeof(this->length));
|
||||
bufPtr += sizeof(this->length);
|
||||
memcpy(bufPtr, &this->trueHeading, sizeof(this->trueHeading));
|
||||
}
|
||||
file = std::vector<std::uint8_t>(23 + this->designator.length(), 0);
|
||||
std::uint8_t *bufPtr = file.data();
|
||||
memset(bufPtr,
|
||||
static_cast<std::uint8_t>(this->designator.length()),
|
||||
sizeof(std::uint8_t));
|
||||
bufPtr++;
|
||||
memcpy(bufPtr, this->designator.c_str(), this->designator.length());
|
||||
bufPtr += this->designator.length() + 1;
|
||||
memcpy(bufPtr, &this->latitudeStart, sizeof(this->latitudeStart));
|
||||
bufPtr += sizeof(this->latitudeStart);
|
||||
memcpy(bufPtr, &this->longitudeStart, sizeof(this->longitudeStart));
|
||||
bufPtr += sizeof(this->longitudeStart);
|
||||
memcpy(bufPtr, &this->width, sizeof(this->width));
|
||||
bufPtr += sizeof(this->width);
|
||||
memcpy(bufPtr, &this->length, sizeof(this->length));
|
||||
bufPtr += sizeof(this->length);
|
||||
memcpy(bufPtr, &this->trueHeading, sizeof(this->trueHeading));
|
||||
}
|
||||
|
||||
std::uint8_t *getBinaryData() { return file.data(); }
|
||||
std::size_t getBinaryLength() { return file.size(); }
|
||||
std::uint8_t *getBinaryData() { return file.data(); }
|
||||
std::size_t getBinaryLength() { return file.size(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user