#ifndef GERMANAIRLINESVA_GACONNECTOR_GATE_H #define GERMANAIRLINESVA_GACONNECTOR_GATE_H #include #include #include #include #include #include /* * Representation of X-Plane gate * Heading in degrees (0...360) * * Length in bytes: 18 + length of designator * Designator must be null terminated * * UINT8 | CHAR[] | DOUBLE | DOUBLE | UINT8 * ------+------------+--------+--------+------ * LEN | DESIGNATOR | LAT | LON | WIDTH */ class Gate { private: std::string designator; double latitude; double longitude; std::vector file; public: Gate(const std::string &designator, double latitude, double longitude) { this->designator = designator; this->latitude = latitude; this->longitude = longitude; file = std::vector(18 + this->designator.length(), 0); std::uint8_t *bufPtr = file.data(); memset(bufPtr, static_cast(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 this->file.data(); } std::size_t getBinaryLength() { return this->file.size(); } }; #endif