Implement FSUIPC FSData Classes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#ifndef GERMANAIRLINESVA_FILE_RUNWAY_H
|
||||
#define GERMANAIRLINESVA_FILE_RUNWAY_H
|
||||
#ifndef GERMANAIRLINESVA_FILE_SIMDATA_RUNWAY_H
|
||||
#define GERMANAIRLINESVA_FILE_SIMDATA_RUNWAY_H
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "FSUIPC/FsGeoData.h"
|
||||
#include "geodata.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "util.hpp"
|
||||
@@ -21,9 +22,9 @@ namespace file
|
||||
{
|
||||
/*
|
||||
* Representation of one runway with supplementary information
|
||||
* Heading in radians true
|
||||
* Threshold center in lat/lon radians
|
||||
* Width and length in meters
|
||||
* Heading in degrees true
|
||||
* Threshold center in lat/lon degrees
|
||||
* Width and length in feet
|
||||
*
|
||||
* UINT8 | CHAR[] | POINT | UINT8 | UINT16 | DOUBLE
|
||||
* -------+------------+--------+-------+--------+-------
|
||||
@@ -38,32 +39,76 @@ namespace file
|
||||
std::uint16_t length;
|
||||
double trueHeading;
|
||||
|
||||
// QUAD TEST
|
||||
FSUIPC::FsLatLonQuadrilateral quad;
|
||||
|
||||
public:
|
||||
// From X-Plane or MakeRwys
|
||||
Runway(std::string designator,
|
||||
double latitudeStart,
|
||||
double longitudeStart,
|
||||
double latitudeEnd,
|
||||
double longitudeEnd,
|
||||
double width);
|
||||
// From database
|
||||
Runway(std::string designator,
|
||||
struct geodata::point center,
|
||||
std::uint8_t width,
|
||||
std::uint16_t length,
|
||||
double trueHeading);
|
||||
inline Runway(std::string designator,
|
||||
double latitudeStart,
|
||||
double longitudeStart,
|
||||
double latitudeEnd,
|
||||
double longitudeEnd,
|
||||
double width)
|
||||
{
|
||||
this->designator = designator;
|
||||
this->width = width * 33.280839895;
|
||||
|
||||
void toFile(std::ofstream &out) const;
|
||||
|
||||
this->length = geodata::distanceEarthD(latitudeStart,
|
||||
longitudeStart,
|
||||
latitudeEnd,
|
||||
longitudeEnd) *
|
||||
3.280839895;
|
||||
this->trueHeading = geodata::bearingDD(latitudeStart,
|
||||
longitudeStart,
|
||||
latitudeEnd,
|
||||
longitudeEnd);
|
||||
this->center = {latitudeStart, longitudeStart};
|
||||
|
||||
FSUIPC::FsLatLonPoint threshold(latitudeStart, longitudeStart);
|
||||
quad = FSUIPC::FsLatLonQuadrilateral::ForRunway(threshold,
|
||||
this->trueHeading,
|
||||
this->width,
|
||||
this->length);
|
||||
}
|
||||
// From database
|
||||
inline Runway(std::string designator,
|
||||
struct geodata::point center,
|
||||
std::uint8_t width,
|
||||
std::uint16_t length,
|
||||
double trueHeading)
|
||||
{
|
||||
this->designator = designator;
|
||||
this->center = center;
|
||||
this->width = width;
|
||||
this->length = length;
|
||||
this->trueHeading = trueHeading;
|
||||
|
||||
FSUIPC::FsLatLonPoint threshold(center.latitude, center.longitude);
|
||||
quad = FSUIPC::FsLatLonQuadrilateral::ForRunway(threshold,
|
||||
trueHeading,
|
||||
width,
|
||||
length);
|
||||
}
|
||||
|
||||
inline void toFile(std::ofstream &out) const
|
||||
{
|
||||
writeString(out, this->designator);
|
||||
write<decltype(this->center)>(out, this->center);
|
||||
write<decltype(this->width)>(out, this->width);
|
||||
write<decltype(this->length)>(out, this->length);
|
||||
write<decltype(this->trueHeading)>(out, this->trueHeading);
|
||||
}
|
||||
|
||||
inline const std::string to_string() const
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << "Runway " << this->designator << " with threshold center "
|
||||
<< geodata::toDegrees(this->center.latitude) << "N "
|
||||
<< geodata::toDegrees(this->center.longitude) << "E, Width "
|
||||
<< (int)this->width << "m, Length " << this->length
|
||||
<< "m, True Heading " << geodata::toDegrees(this->trueHeading)
|
||||
<< "°";
|
||||
<< this->center.latitude << "N " << this->center.longitude
|
||||
<< "E, Width " << (int)this->width << "ft, Length "
|
||||
<< this->length << "ft, True Heading " << this->trueHeading
|
||||
<< "°, Quad " << quad.to_string(true, ' ');
|
||||
return str.str();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user