52 lines
1.8 KiB
C++
52 lines
1.8 KiB
C++
#include "gate.h"
|
|
|
|
namespace germanairlinesva_simdata
|
|
{
|
|
Gate::Gate(const std::string &designator,
|
|
double latitude,
|
|
double longitude,
|
|
std::uint8_t radius)
|
|
{
|
|
this->designator = designator;
|
|
this->center = {latitude, longitude};
|
|
this->radius = radius;
|
|
|
|
file = std::vector<std::uint8_t>(1 + this->designator.length() + 1 +
|
|
sizeof(center) + sizeof(radius),
|
|
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->center, sizeof(this->center));
|
|
bufPtr += sizeof(this->center);
|
|
memcpy(bufPtr, &this->radius, sizeof(this->radius));
|
|
}
|
|
|
|
// From database
|
|
Gate::Gate(const std::string &designator,
|
|
germanairlinesva_geodata::point center,
|
|
std::uint8_t radius)
|
|
{
|
|
this->designator = designator;
|
|
this->center = center;
|
|
this->radius = radius;
|
|
|
|
file = std::vector<std::uint8_t>(1 + this->designator.length() + 1 +
|
|
sizeof(center) + sizeof(radius),
|
|
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->center, sizeof(this->center));
|
|
bufPtr += sizeof(this->center);
|
|
memcpy(bufPtr, &this->radius, sizeof(this->radius));
|
|
}
|
|
} // namespace germanairlinesva_simdata
|