Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 92159b0669 | |||
| 115e4d9265 | |||
| 07487e9e51 | |||
| 46a0607b55 | |||
| de8b282ab1 |
Vendored
+22
-1
@@ -64,6 +64,27 @@
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"valarray": "cpp",
|
||||
"__threading_support": "cpp"
|
||||
"__threading_support": "cpp",
|
||||
"__bit_reference": "cpp",
|
||||
"__bits": "cpp",
|
||||
"__config": "cpp",
|
||||
"__debug": "cpp",
|
||||
"__errc": "cpp",
|
||||
"__hash_table": "cpp",
|
||||
"__locale": "cpp",
|
||||
"__mutex_base": "cpp",
|
||||
"__node_handle": "cpp",
|
||||
"__nullptr": "cpp",
|
||||
"__split_buffer": "cpp",
|
||||
"__string": "cpp",
|
||||
"__tree": "cpp",
|
||||
"__tuple": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"ios": "cpp",
|
||||
"locale": "cpp",
|
||||
"queue": "cpp",
|
||||
"stack": "cpp",
|
||||
"variant": "cpp"
|
||||
},
|
||||
}
|
||||
@@ -1,5 +1,2 @@
|
||||
- Reverse engineer FSUIPC .NET onRunway Check
|
||||
- Update OSXCross Docker image to SDK 11
|
||||
- Implement ARM64 arch for Plugin
|
||||
- Refactor SimDatabase to be a class
|
||||
- Requires new Airport class
|
||||
+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") {
|
||||
|
||||
+14
-4
@@ -7,7 +7,18 @@ namespace file
|
||||
namespace simdata
|
||||
{
|
||||
Gate::Gate(std::string designator,
|
||||
struct germanairlinesva::geodata::point center,
|
||||
double latitude,
|
||||
double longitude,
|
||||
std::uint8_t radius)
|
||||
{
|
||||
this->designator = designator;
|
||||
this->center = {geodata::toRadians(latitude),
|
||||
geodata::toRadians(longitude)};
|
||||
this->radius = radius;
|
||||
}
|
||||
|
||||
Gate::Gate(std::string designator,
|
||||
struct geodata::point center,
|
||||
std::uint8_t radius)
|
||||
{
|
||||
this->designator = designator;
|
||||
@@ -22,10 +33,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
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSGEODATA_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSGEODATA_H
|
||||
|
||||
#include "FsLatLonPoint.h"
|
||||
#include "FsLatLonQuadrilateral.h"
|
||||
#include "FsLatitude.h"
|
||||
#include "FsLatitudeSpan.h"
|
||||
#include "FsLongitude.h"
|
||||
#include "FsLongitudeSpan.h"
|
||||
|
||||
#include "FsLatLonPointImpl.h"
|
||||
#include "FsLatLonQuadrilateralImpl.h"
|
||||
#include "FsLatitudeImpl.h"
|
||||
#include "FsLatitudeSpanImpl.h"
|
||||
#include "FsLongitudeImpl.h"
|
||||
#include "FsLongitudeSpanImpl.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSLATLONPOINT_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSLATLONPOINT_H
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "FsLatitude.h"
|
||||
#include "FsLatitudeSpan.h"
|
||||
#include "FsLongitude.h"
|
||||
#include "FsLongitudeSpan.h"
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace FSUIPC
|
||||
{
|
||||
class FsLatLonPoint
|
||||
{
|
||||
private:
|
||||
FsLatitude lat;
|
||||
FsLongitude lon;
|
||||
|
||||
public:
|
||||
inline FsLatLonPoint();
|
||||
inline FsLatLonPoint(FsLatitude Latitude, FsLongitude Longitude);
|
||||
|
||||
inline const FsLongitude Longitude() const;
|
||||
inline const FsLatitude Latitude() const;
|
||||
|
||||
inline double DistanceFromInFeet(const FsLatLonPoint &Point) const;
|
||||
inline double
|
||||
DistanceFromInNauticalMiles(const FsLatLonPoint &Point) const;
|
||||
inline double DistanceFromInMetres(const FsLatLonPoint &Point) const;
|
||||
|
||||
inline double BearingTo(const FsLatLonPoint &Point) const;
|
||||
inline double BearingFrom(const FsLatLonPoint &Point) const;
|
||||
|
||||
inline FsLatLonPoint OffsetByFeet(double Bearing,
|
||||
double Distance) const;
|
||||
inline FsLatLonPoint OffsetByMetres(double Bearing,
|
||||
double Distance) const;
|
||||
inline FsLatLonPoint OffsetByNauticalMiles(double Bearing,
|
||||
double Distance) const;
|
||||
|
||||
inline const std::string to_string(bool HemisphereAsText,
|
||||
char DetailLevel) const;
|
||||
inline const std::string to_string() const;
|
||||
};
|
||||
} // namespace FSUIPC
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,145 @@
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSLATLONPOINTIMPL_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSLATLONPOINTIMPL_H
|
||||
|
||||
#include "FsLatLonPoint.h"
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace FSUIPC
|
||||
{
|
||||
inline FsLatLonPoint::FsLatLonPoint() = default;
|
||||
inline FsLatLonPoint::FsLatLonPoint(FsLatitude Latitude,
|
||||
FsLongitude Longitude)
|
||||
{
|
||||
this->lon = Longitude;
|
||||
this->lat = Latitude;
|
||||
}
|
||||
|
||||
inline const FsLongitude FsLatLonPoint::Longitude() const
|
||||
{
|
||||
return this->lon;
|
||||
}
|
||||
inline const FsLatitude FsLatLonPoint::Latitude() const
|
||||
{
|
||||
return this->lat;
|
||||
}
|
||||
|
||||
inline double
|
||||
FsLatLonPoint::DistanceFromInFeet(const FsLatLonPoint &Point) const
|
||||
{
|
||||
FsLongitudeSpan fsLongitudeSpan =
|
||||
FsLongitudeSpan::BetweenTwoLongitudes(Point.Longitude(), this->lon);
|
||||
double num = (fsLongitudeSpan.ToFeet(this->lat) +
|
||||
fsLongitudeSpan.ToFeet(Point.lat)) /
|
||||
2.0;
|
||||
double feet = FsLatitudeSpan(Point.Latitude().DecimalDegrees() -
|
||||
this->lat.DecimalDegrees())
|
||||
.ToFeet();
|
||||
return sqrt(num * num + feet * feet);
|
||||
}
|
||||
inline double FsLatLonPoint::DistanceFromInNauticalMiles(
|
||||
const FsLatLonPoint &Point) const
|
||||
{
|
||||
return this->DistanceFromInFeet(Point) / 6076.1155;
|
||||
}
|
||||
inline double
|
||||
FsLatLonPoint::DistanceFromInMetres(const FsLatLonPoint &Point) const
|
||||
{
|
||||
return this->DistanceFromInFeet(Point) / 3.2808;
|
||||
}
|
||||
|
||||
inline double FsLatLonPoint::BearingTo(const FsLatLonPoint &Point) const
|
||||
{
|
||||
double num1 = 0.0;
|
||||
double num2 = abs(FsLatitudeSpan(this->lat.DecimalDegrees() -
|
||||
Point.Latitude().DecimalDegrees())
|
||||
.ToFeet());
|
||||
double num3 = abs((FsLongitudeSpan(Point.Longitude().DecimalDegrees() -
|
||||
this->lon.DecimalDegrees())
|
||||
.ToFeet(this->lat) +
|
||||
FsLongitudeSpan(Point.Longitude().DecimalDegrees() -
|
||||
this->lon.DecimalDegrees())
|
||||
.ToFeet(Point.lat)) /
|
||||
2.0);
|
||||
if (num2 == 0.0)
|
||||
num1 = this->lon.DecimalDegrees() > Point.Longitude().DecimalDegrees()
|
||||
? 270.0
|
||||
: 90.0;
|
||||
else if (this->lat.DecimalDegrees() < Point.Latitude().DecimalDegrees() &&
|
||||
this->lon.DecimalDegrees() < Point.Longitude().DecimalDegrees())
|
||||
num1 = atan(num3 / num2) * 180.0 / M_PI;
|
||||
else if (this->lat.DecimalDegrees() > Point.Latitude().DecimalDegrees() &&
|
||||
this->lon.DecimalDegrees() < Point.Longitude().DecimalDegrees())
|
||||
num1 = atan(num2 / num3) * 180.0 / M_PI + 90.0;
|
||||
else if (this->lat.DecimalDegrees() > Point.Latitude().DecimalDegrees() &&
|
||||
this->lon.DecimalDegrees() > Point.Longitude().DecimalDegrees())
|
||||
num1 = atan(num3 / num2) * 180.0 / M_PI + 180.0;
|
||||
else if (this->lat.DecimalDegrees() < Point.Latitude().DecimalDegrees() &&
|
||||
this->lon.DecimalDegrees() > Point.Longitude().DecimalDegrees())
|
||||
num1 = atan(num2 / num3) * 180.0 / M_PI + 270.0;
|
||||
return num1;
|
||||
}
|
||||
inline double FsLatLonPoint::BearingFrom(const FsLatLonPoint &Point) const
|
||||
{
|
||||
double num = 180.0 + this->BearingTo(Point);
|
||||
if (num >= 360.0)
|
||||
num -= 360.0;
|
||||
if (num < 0.0)
|
||||
num += 360.0;
|
||||
return num;
|
||||
}
|
||||
|
||||
inline FsLatLonPoint FsLatLonPoint::OffsetByFeet(double Bearing,
|
||||
double Distance) const
|
||||
{
|
||||
double Feet1 = sin(M_PI * Bearing / 180.0) * Distance;
|
||||
double Feet2 = cos(M_PI * Bearing / 180.0) * Distance;
|
||||
FsLatLonPoint fsLatLonPoint = FsLatLonPoint();
|
||||
fsLatLonPoint.lat = this->lat.Add(FsLatitudeSpan::FromFeet(Feet2));
|
||||
fsLatLonPoint.lon =
|
||||
this->lon.Add(FsLongitudeSpan::FromFeet(Feet1, fsLatLonPoint.lat));
|
||||
return fsLatLonPoint;
|
||||
}
|
||||
inline FsLatLonPoint FsLatLonPoint::OffsetByMetres(double Bearing,
|
||||
double Distance) const
|
||||
{
|
||||
double Metres1 = sin(M_PI * Bearing / 180.0) * Distance;
|
||||
double Metres2 = cos(M_PI * Bearing / 180.0) * Distance;
|
||||
FsLatLonPoint fsLatLonPoint = FsLatLonPoint();
|
||||
fsLatLonPoint.lat = this->lat.Add(FsLatitudeSpan::FromMetres(Metres2));
|
||||
fsLatLonPoint.lon = this->lon.Add(
|
||||
FsLongitudeSpan::FromMetres(Metres1, fsLatLonPoint.lat));
|
||||
return fsLatLonPoint;
|
||||
}
|
||||
inline FsLatLonPoint
|
||||
FsLatLonPoint::OffsetByNauticalMiles(double Bearing,
|
||||
double Distance) const
|
||||
{
|
||||
double NauticalMiles1 = sin(M_PI * Bearing / 180.0) * Distance;
|
||||
double NauticalMiles2 = cos(M_PI * Bearing / 180.0) * Distance;
|
||||
FsLatLonPoint fsLatLonPoint = FsLatLonPoint();
|
||||
fsLatLonPoint.lat =
|
||||
this->lat.Add(FsLatitudeSpan::FromNauticalMiles(NauticalMiles2));
|
||||
fsLatLonPoint.lon =
|
||||
this->lon.Add(FsLongitudeSpan::FromNauticalMiles(NauticalMiles1,
|
||||
fsLatLonPoint.lat));
|
||||
return fsLatLonPoint;
|
||||
}
|
||||
|
||||
inline const std::string FsLatLonPoint::to_string(bool HemisphereAsText,
|
||||
char DetailLevel) const
|
||||
{
|
||||
return this->lat.to_string(HemisphereAsText, DetailLevel) + ", " +
|
||||
this->lon.to_string(HemisphereAsText, DetailLevel);
|
||||
}
|
||||
inline const std::string FsLatLonPoint::to_string() const
|
||||
{
|
||||
return this->to_string(true, 'm');
|
||||
}
|
||||
} // namespace FSUIPC
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSLATLONQUADRILATERAL_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSLATLONQUADRILATERAL_H
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace FSUIPC
|
||||
{
|
||||
class FsLatitude;
|
||||
class FsLatitudeSpan;
|
||||
class FsLongitude;
|
||||
class FsLongitudeSpan;
|
||||
class FsLatLonPoint;
|
||||
class FsLatLonQuadrilateral
|
||||
{
|
||||
private:
|
||||
FsLatLonPoint ne;
|
||||
FsLatLonPoint se;
|
||||
FsLatLonPoint sw;
|
||||
FsLatLonPoint nw;
|
||||
|
||||
public:
|
||||
inline FsLatLonQuadrilateral();
|
||||
inline FsLatLonQuadrilateral(FsLatLonPoint P0,
|
||||
FsLatLonPoint P1,
|
||||
FsLatLonPoint P2,
|
||||
FsLatLonPoint P3);
|
||||
|
||||
inline FsLatLonPoint NE() const;
|
||||
inline FsLatLonPoint SE() const;
|
||||
inline FsLatLonPoint SW() const;
|
||||
inline FsLatLonPoint NW() const;
|
||||
|
||||
inline bool ContainsPoint(FsLatLonPoint point) const;
|
||||
|
||||
inline const std::string to_string(bool HemisphereAsText,
|
||||
char DetailLevel) const;
|
||||
inline const std::string to_string() const;
|
||||
|
||||
inline static FsLatLonQuadrilateral
|
||||
ForRunway(FsLatLonPoint &ThresholdCentre,
|
||||
double HeadingTrue,
|
||||
double WidthInFeet,
|
||||
double LengthInFeet);
|
||||
};
|
||||
} // namespace FSUIPC
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,166 @@
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSLATLONQUADRILATERALIMPL_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSLATLONQUADRILATERALIMPL_H
|
||||
|
||||
#include "FsLatLonQuadrilateral.h"
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace FSUIPC
|
||||
{
|
||||
inline FsLatLonQuadrilateral::FsLatLonQuadrilateral() = default;
|
||||
inline FsLatLonQuadrilateral::FsLatLonQuadrilateral(FsLatLonPoint P0,
|
||||
FsLatLonPoint P1,
|
||||
FsLatLonPoint P2,
|
||||
FsLatLonPoint P3)
|
||||
{
|
||||
std::vector<FsLatLonPoint> fsLatLonPointList1;
|
||||
std::vector<FsLatLonPoint> fsLatLonPointList2;
|
||||
fsLatLonPointList1.push_back(P0);
|
||||
fsLatLonPointList1.push_back(P1);
|
||||
fsLatLonPointList1.push_back(P2);
|
||||
fsLatLonPointList1.push_back(P3);
|
||||
for (int index1 = 0; index1 < 3; ++index1) {
|
||||
double num = 0.0;
|
||||
int index2 = 0;
|
||||
for (size_t index3 = 0; index3 < fsLatLonPointList1.size(); ++index3) {
|
||||
if (fsLatLonPointList1[index3].Latitude().UDegrees() > num) {
|
||||
num = fsLatLonPointList1[index3].Latitude().UDegrees();
|
||||
index2 = index3;
|
||||
}
|
||||
}
|
||||
fsLatLonPointList2.push_back(fsLatLonPointList1[index2]);
|
||||
fsLatLonPointList1.erase(fsLatLonPointList1.begin() + index2);
|
||||
}
|
||||
fsLatLonPointList2.push_back(fsLatLonPointList1[0]);
|
||||
if (fsLatLonPointList2[1].Longitude().UDegrees() >
|
||||
fsLatLonPointList2[0].Longitude().UDegrees()) {
|
||||
this->ne = fsLatLonPointList2[1];
|
||||
this->nw = fsLatLonPointList2[0];
|
||||
} else {
|
||||
this->ne = fsLatLonPointList2[0];
|
||||
this->nw = fsLatLonPointList2[1];
|
||||
}
|
||||
if (fsLatLonPointList2[3].Longitude().UDegrees() >
|
||||
fsLatLonPointList2[2].Longitude().UDegrees()) {
|
||||
this->se = fsLatLonPointList2[3];
|
||||
this->sw = fsLatLonPointList2[2];
|
||||
} else {
|
||||
this->se = fsLatLonPointList2[2];
|
||||
this->sw = fsLatLonPointList2[3];
|
||||
}
|
||||
}
|
||||
|
||||
inline FsLatLonPoint FsLatLonQuadrilateral::NE() const { return this->ne; }
|
||||
inline FsLatLonPoint FsLatLonQuadrilateral::SE() const { return this->se; }
|
||||
inline FsLatLonPoint FsLatLonQuadrilateral::SW() const { return this->sw; }
|
||||
inline FsLatLonPoint FsLatLonQuadrilateral::NW() const { return this->nw; }
|
||||
|
||||
inline bool FsLatLonQuadrilateral::ContainsPoint(FsLatLonPoint point) const
|
||||
{
|
||||
bool flag = false;
|
||||
double udegrees1 = this->nw.Latitude().UDegrees();
|
||||
double udegrees2 = this->sw.Latitude().UDegrees();
|
||||
double udegrees3 = this->se.Latitude().UDegrees();
|
||||
double udegrees4 = this->ne.Latitude().UDegrees();
|
||||
double udegrees5 = this->nw.Longitude().UDegrees();
|
||||
double udegrees6 = this->sw.Longitude().UDegrees();
|
||||
double udegrees7 = this->se.Longitude().UDegrees();
|
||||
double udegrees8 = this->ne.Longitude().UDegrees();
|
||||
double udegrees9 = point.Longitude().UDegrees();
|
||||
double udegrees10 = point.Latitude().UDegrees();
|
||||
if (udegrees9 > udegrees5 + (udegrees6 - udegrees5) /
|
||||
(udegrees1 - udegrees2) *
|
||||
(udegrees1 - udegrees10) &&
|
||||
udegrees9 < udegrees8 + (udegrees7 - udegrees8) /
|
||||
(udegrees4 - udegrees3) *
|
||||
(udegrees4 - udegrees10) &&
|
||||
udegrees10 > udegrees2 + (udegrees3 - udegrees2) /
|
||||
(udegrees7 - udegrees6) *
|
||||
(udegrees9 - udegrees6))
|
||||
flag = udegrees10 < udegrees1 + (udegrees4 - udegrees1) /
|
||||
(udegrees8 - udegrees5) *
|
||||
(udegrees9 - udegrees5);
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string
|
||||
FsLatLonQuadrilateral::to_string(bool HemisphereAsText,
|
||||
char DetailLevel) const
|
||||
{
|
||||
return this->ne.to_string(HemisphereAsText, DetailLevel) + ", " +
|
||||
this->nw.to_string(HemisphereAsText, DetailLevel) + ", " +
|
||||
this->sw.to_string(HemisphereAsText, DetailLevel) + ", " +
|
||||
this->se.to_string(HemisphereAsText, DetailLevel);
|
||||
}
|
||||
inline const std::string FsLatLonQuadrilateral::to_string() const
|
||||
{
|
||||
return this->to_string(true, 'm');
|
||||
}
|
||||
|
||||
inline FsLatLonQuadrilateral
|
||||
FsLatLonQuadrilateral::ForRunway(FsLatLonPoint &ThresholdCentre,
|
||||
double HeadingTrue,
|
||||
double WidthInFeet,
|
||||
double LengthInFeet)
|
||||
{
|
||||
double num = M_PI * HeadingTrue / 180.0;
|
||||
double Feet = cos(num) * WidthInFeet / 2.0;
|
||||
|
||||
double decimalDegrees1 =
|
||||
FsLatitudeSpan::FromFeet(sin(num) * WidthInFeet / 2.0)
|
||||
.DecimalDegrees();
|
||||
FsLatitude fsLatitude1 = FsLatitude(
|
||||
ThresholdCentre.Latitude().DecimalDegrees() - decimalDegrees1);
|
||||
|
||||
double decimalDegrees2 =
|
||||
FsLongitudeSpan::FromFeet(Feet, fsLatitude1).DecimalDegrees();
|
||||
FsLongitude Longitude1 = FsLongitude(
|
||||
ThresholdCentre.Longitude().DecimalDegrees() + decimalDegrees2);
|
||||
FsLatLonPoint P1 = FsLatLonPoint(fsLatitude1, Longitude1);
|
||||
fsLatitude1 = FsLatitude(ThresholdCentre.Latitude().DecimalDegrees() +
|
||||
decimalDegrees1);
|
||||
|
||||
double decimalDegrees3 =
|
||||
FsLongitudeSpan::FromFeet(Feet, fsLatitude1).DecimalDegrees();
|
||||
Longitude1 = FsLongitude(ThresholdCentre.Longitude().DecimalDegrees() -
|
||||
decimalDegrees3);
|
||||
FsLatLonPoint P0 = FsLatLonPoint(fsLatitude1, Longitude1);
|
||||
|
||||
double decimalDegrees4 =
|
||||
FsLatitudeSpan::FromFeet(cos(num) * LengthInFeet).DecimalDegrees();
|
||||
FsLatitude fsLatitude2 = FsLatitude(
|
||||
ThresholdCentre.Latitude().DecimalDegrees() + decimalDegrees4);
|
||||
|
||||
double decimalDegrees5 =
|
||||
FsLongitudeSpan ::FromFeet(sin(num) * LengthInFeet, fsLatitude2)
|
||||
.DecimalDegrees();
|
||||
FsLongitude Longitude2 = FsLongitude(
|
||||
ThresholdCentre.Longitude().DecimalDegrees() + decimalDegrees5);
|
||||
FsLatLonPoint fsLatLonPoint = FsLatLonPoint(fsLatitude2, Longitude2);
|
||||
fsLatitude1 = FsLatitude(fsLatLonPoint.Latitude().DecimalDegrees() -
|
||||
decimalDegrees1);
|
||||
|
||||
double decimalDegrees6 =
|
||||
FsLongitudeSpan::FromFeet(Feet, fsLatitude1).DecimalDegrees();
|
||||
Longitude1 = FsLongitude(fsLatLonPoint.Longitude().DecimalDegrees() +
|
||||
decimalDegrees6);
|
||||
FsLatLonPoint P3 = FsLatLonPoint(fsLatitude1, Longitude1);
|
||||
fsLatitude1 = FsLatitude(fsLatLonPoint.Latitude().DecimalDegrees() +
|
||||
decimalDegrees1);
|
||||
|
||||
double decimalDegrees7 =
|
||||
FsLongitudeSpan::FromFeet(Feet, fsLatitude1).DecimalDegrees();
|
||||
Longitude1 = FsLongitude(fsLatLonPoint.Longitude().DecimalDegrees() -
|
||||
decimalDegrees7);
|
||||
FsLatLonPoint P2 = FsLatLonPoint(fsLatitude1, Longitude1);
|
||||
|
||||
return FsLatLonQuadrilateral(P0, P1, P2, P3);
|
||||
}
|
||||
} // namespace FSUIPC
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSLATITUDE_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSLATITUDE_H
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace FSUIPC
|
||||
{
|
||||
class FsLatitudeSpan;
|
||||
class FsLatitude
|
||||
{
|
||||
private:
|
||||
double pos;
|
||||
|
||||
public:
|
||||
inline FsLatitude();
|
||||
inline FsLatitude(double DecimalDegrees);
|
||||
inline FsLatitude(std::int64_t FSUnits);
|
||||
inline FsLatitude(std::int32_t FSUnits);
|
||||
inline FsLatitude(std::int32_t Degrees, double DecimalMinutes);
|
||||
inline FsLatitude(std::int32_t Degrees,
|
||||
std::int32_t Minutes,
|
||||
double DecimalSeconds);
|
||||
|
||||
inline std::int64_t ToFSUnits8() const;
|
||||
inline std::int32_t ToFSUnits4() const;
|
||||
|
||||
inline double DecimalDegrees() const;
|
||||
inline double DecimalMinutes() const;
|
||||
inline double DecimalSeconds() const;
|
||||
|
||||
inline std::int32_t Degree() const;
|
||||
inline std::int32_t Minute() const;
|
||||
inline std::int32_t Second() const;
|
||||
|
||||
inline double UDegrees() const;
|
||||
|
||||
inline const std::string to_string(bool HemisphereAsText,
|
||||
char DetailLevel) const;
|
||||
inline const std::string to_string() const;
|
||||
|
||||
inline FsLatitude Add(const FsLatitudeSpan &Distance) const;
|
||||
inline FsLatitude Subtract(const FsLatitudeSpan &Distance) const;
|
||||
|
||||
inline FsLatitude AddDegrees(double Degrees) const;
|
||||
inline FsLatitude AddMinutes(double Minutes) const;
|
||||
inline FsLatitude AddSeconds(double Seconds) const;
|
||||
};
|
||||
|
||||
} // namespace FSUIPC
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,129 @@
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSLATITUDEIMPL_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSLATITUDEIMPL_H
|
||||
|
||||
#include "FsLatitude.h"
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace FSUIPC
|
||||
{
|
||||
inline FsLatitude::FsLatitude() = default;
|
||||
inline FsLatitude::FsLatitude(double DecimalDegrees)
|
||||
{
|
||||
this->pos = DecimalDegrees;
|
||||
while (this->pos > 90.0 || this->pos < -90.0) {
|
||||
if (this->pos > 90.0)
|
||||
this->pos = 180.0 - this->pos;
|
||||
if (this->pos < -90.0)
|
||||
this->pos = -180.0 - this->pos;
|
||||
}
|
||||
}
|
||||
|
||||
inline FsLatitude::FsLatitude(std::int64_t FSUnits)
|
||||
: FsLatitude(FSUnits * 90.0 / 4.2957189152768E+16)
|
||||
{
|
||||
}
|
||||
inline FsLatitude::FsLatitude(std::int32_t FSUnits)
|
||||
: FsLatitude(FSUnits * 90.0 / 10001750.0)
|
||||
{
|
||||
}
|
||||
inline FsLatitude::FsLatitude(std::int32_t Degrees, double DecimalMinutes)
|
||||
: FsLatitude(Degrees + DecimalMinutes / 60.0)
|
||||
{
|
||||
}
|
||||
inline FsLatitude::FsLatitude(std::int32_t Degrees,
|
||||
std::int32_t Minutes,
|
||||
double DecimalSeconds)
|
||||
: FsLatitude(Degrees + Minutes / 60.0 + DecimalSeconds / 3600.0)
|
||||
{
|
||||
}
|
||||
|
||||
inline std::int64_t FsLatitude::ToFSUnits8() const
|
||||
{
|
||||
return this->pos * 4.2957189152768E+16 / 90.0;
|
||||
}
|
||||
inline std::int32_t FsLatitude::ToFSUnits4() const
|
||||
{
|
||||
return this->pos * 10001750.0 / 90.0;
|
||||
}
|
||||
|
||||
inline double FsLatitude::DecimalDegrees() const { return this->pos; }
|
||||
inline double FsLatitude::DecimalMinutes() const
|
||||
{
|
||||
return (this->pos - trunc(this->pos)) * 60.0;
|
||||
}
|
||||
inline double FsLatitude::DecimalSeconds() const
|
||||
{
|
||||
double decimalMinutes = this->DecimalMinutes();
|
||||
return (decimalMinutes - trunc(decimalMinutes)) * 60.0;
|
||||
}
|
||||
|
||||
inline std::int32_t FsLatitude::Degree() const { return trunc(this->pos); }
|
||||
inline std::int32_t FsLatitude::Minute() const
|
||||
{
|
||||
return trunc(this->DecimalMinutes());
|
||||
}
|
||||
inline std::int32_t FsLatitude::Second() const
|
||||
{
|
||||
return trunc(this->DecimalSeconds());
|
||||
}
|
||||
|
||||
inline double FsLatitude::UDegrees() const { return this->pos + 90.0; }
|
||||
|
||||
inline const std::string FsLatitude::to_string(bool HemisphereAsText,
|
||||
char DetailLevel) const
|
||||
{
|
||||
std::ostringstream str;
|
||||
if (!HemisphereAsText) {
|
||||
str << (this->pos < 0.0 ? "-" : "");
|
||||
} else {
|
||||
str << (this->pos < 0.0 ? "S" : "N");
|
||||
}
|
||||
|
||||
switch (DetailLevel) {
|
||||
case 'm':
|
||||
str << this->Degree() << "° " << this->DecimalMinutes() << "'";
|
||||
break;
|
||||
case 's':
|
||||
str << this->Degree() << "° " << this->Minute() << "' "
|
||||
<< this->DecimalSeconds() << "\"";
|
||||
break;
|
||||
default:
|
||||
str << this->pos << "*";
|
||||
break;
|
||||
}
|
||||
return str.str();
|
||||
}
|
||||
inline const std::string FsLatitude::to_string() const
|
||||
{
|
||||
return this->to_string(true, 'm');
|
||||
}
|
||||
|
||||
inline FsLatitude FsLatitude::Add(const FsLatitudeSpan &Distance) const
|
||||
{
|
||||
return FsLatitude(this->pos + Distance.DecimalDegrees());
|
||||
}
|
||||
inline FsLatitude FsLatitude::Subtract(const FsLatitudeSpan &Distance) const
|
||||
{
|
||||
return FsLatitude(this->pos - Distance.DecimalDegrees());
|
||||
}
|
||||
|
||||
inline FsLatitude FsLatitude::AddDegrees(double Degrees) const
|
||||
{
|
||||
return FsLatitude(this->pos + Degrees);
|
||||
}
|
||||
inline FsLatitude FsLatitude::AddMinutes(double Minutes) const
|
||||
{
|
||||
return FsLatitude(this->pos + Minutes / 60.0);
|
||||
}
|
||||
inline FsLatitude FsLatitude::AddSeconds(double Seconds) const
|
||||
{
|
||||
return FsLatitude(this->pos + Seconds / 3600.0);
|
||||
}
|
||||
} // namespace FSUIPC
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSLATITUDESPAN_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSLATITUDESPAN_H
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace FSUIPC
|
||||
{
|
||||
class FsLatitude;
|
||||
class FsLatitudeSpan
|
||||
{
|
||||
private:
|
||||
double span;
|
||||
|
||||
public:
|
||||
inline FsLatitudeSpan();
|
||||
inline FsLatitudeSpan(double DecimalDegrees);
|
||||
inline FsLatitudeSpan(std::int32_t Degrees, double DecimalMinutes);
|
||||
inline FsLatitudeSpan(std::int32_t Degrees,
|
||||
std::int32_t Minutes,
|
||||
double DecimalSeconds);
|
||||
|
||||
inline static FsLatitudeSpan FromFeet(double Feet);
|
||||
inline static FsLatitudeSpan FromNauticalMiles(double NauticalMiles);
|
||||
inline static FsLatitudeSpan FromMetres(double Metres);
|
||||
inline static FsLatitudeSpan
|
||||
BetweenTwoLatitides(const FsLatitude &Lat1, const FsLatitude &Lat2);
|
||||
|
||||
inline double DecimalDegrees() const;
|
||||
inline double DecimalMinutes() const;
|
||||
inline double DecimalSeconds() const;
|
||||
|
||||
inline std::int32_t Degrees() const;
|
||||
inline std::int32_t Minutes() const;
|
||||
inline std::int32_t Seconds() const;
|
||||
|
||||
inline double TotalMinutes() const;
|
||||
inline double TotalSeconds() const;
|
||||
|
||||
inline double ToFeet() const;
|
||||
inline double ToNauticalMiles() const;
|
||||
inline double ToMetres() const;
|
||||
|
||||
inline const std::string to_string(char DetailLevel) const;
|
||||
inline const std::string to_string();
|
||||
};
|
||||
} // namespace FSUIPC
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,121 @@
|
||||
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSLATITUDESPANIMPL_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSLATITUDESPANIMPL_H
|
||||
|
||||
#include "FsLatitudeSpan.h"
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace FSUIPC
|
||||
{
|
||||
inline FsLatitudeSpan::FsLatitudeSpan() = default;
|
||||
inline FsLatitudeSpan::FsLatitudeSpan(double DecimalDegrees)
|
||||
{
|
||||
this->span = DecimalDegrees;
|
||||
}
|
||||
inline FsLatitudeSpan::FsLatitudeSpan(std::int32_t Degrees,
|
||||
double DecimalMinutes)
|
||||
: FsLatitudeSpan(Degrees + DecimalMinutes / 60.0)
|
||||
{
|
||||
}
|
||||
inline FsLatitudeSpan::FsLatitudeSpan(std::int32_t Degrees,
|
||||
std::int32_t Minutes,
|
||||
double DecimalSeconds)
|
||||
: FsLatitudeSpan(Degrees + Minutes / 60.0 + DecimalSeconds / 3600.0)
|
||||
{
|
||||
}
|
||||
|
||||
inline FsLatitudeSpan FsLatitudeSpan::FromFeet(double Feet)
|
||||
{
|
||||
return FsLatitudeSpan(Feet / 364601.4567);
|
||||
}
|
||||
inline FsLatitudeSpan
|
||||
FsLatitudeSpan::FromNauticalMiles(double NauticalMiles)
|
||||
{
|
||||
return FsLatitudeSpan::FromFeet(NauticalMiles * 6076.1155);
|
||||
}
|
||||
inline FsLatitudeSpan FsLatitudeSpan::FromMetres(double Metres)
|
||||
{
|
||||
return FsLatitudeSpan::FromFeet(Metres * 3.2808);
|
||||
}
|
||||
inline FsLatitudeSpan
|
||||
FsLatitudeSpan::BetweenTwoLatitides(const FsLatitude &Lat1,
|
||||
const FsLatitude &Lat2)
|
||||
{
|
||||
return FsLatitudeSpan(abs(Lat2.UDegrees() - Lat1.UDegrees()));
|
||||
}
|
||||
|
||||
inline double FsLatitudeSpan::DecimalDegrees() const { return this->span; }
|
||||
inline double FsLatitudeSpan::DecimalMinutes() const
|
||||
{
|
||||
return (this->span - trunc(this->span)) * 60.0;
|
||||
}
|
||||
inline double FsLatitudeSpan::DecimalSeconds() const
|
||||
{
|
||||
double decimalMinutes = this->DecimalMinutes();
|
||||
return (decimalMinutes - trunc(decimalMinutes)) * 60.0;
|
||||
}
|
||||
|
||||
inline std::int32_t FsLatitudeSpan::Degrees() const
|
||||
{
|
||||
return trunc(this->span);
|
||||
}
|
||||
inline std::int32_t FsLatitudeSpan::Minutes() const
|
||||
{
|
||||
return trunc(this->DecimalMinutes());
|
||||
}
|
||||
inline std::int32_t FsLatitudeSpan::Seconds() const
|
||||
{
|
||||
return trunc(this->DecimalSeconds());
|
||||
}
|
||||
|
||||
inline double FsLatitudeSpan::TotalMinutes() const
|
||||
{
|
||||
return this->span * 60.0;
|
||||
}
|
||||
inline double FsLatitudeSpan::TotalSeconds() const
|
||||
{
|
||||
return this->span * 3600.0;
|
||||
}
|
||||
|
||||
inline double FsLatitudeSpan::ToFeet() const
|
||||
{
|
||||
return 364601.4567 * this->span;
|
||||
}
|
||||
inline double FsLatitudeSpan::ToNauticalMiles() const
|
||||
{
|
||||
return this->ToFeet() / 6076.1155;
|
||||
}
|
||||
inline double FsLatitudeSpan::ToMetres() const
|
||||
{
|
||||
return this->ToFeet() / 3.2808;
|
||||
}
|
||||
|
||||
inline const std::string FsLatitudeSpan::to_string(char DetailLevel) const
|
||||
{
|
||||
std::ostringstream str;
|
||||
switch (DetailLevel) {
|
||||
case 'm':
|
||||
str << this->Degrees() << "* " << this->DecimalMinutes() << "'";
|
||||
break;
|
||||
case 's':
|
||||
str << this->Degrees() << "* " << this->Minutes() << "' "
|
||||
<< this->DecimalSeconds() << "\"";
|
||||
break;
|
||||
default:
|
||||
str << this->span << "*";
|
||||
break;
|
||||
}
|
||||
return str.str();
|
||||
}
|
||||
inline const std::string FsLatitudeSpan::to_string()
|
||||
{
|
||||
return this->to_string('m');
|
||||
}
|
||||
} // namespace FSUIPC
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSLONGITUDE_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSLONGITUDE_H
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace FSUIPC
|
||||
{
|
||||
class FsLongitudeSpan;
|
||||
class FsLongitude
|
||||
{
|
||||
private:
|
||||
double pos;
|
||||
|
||||
public:
|
||||
inline FsLongitude();
|
||||
inline FsLongitude(double DecimalDegrees);
|
||||
inline FsLongitude(std::int64_t FSUnits);
|
||||
inline FsLongitude(std::int32_t FSUnits);
|
||||
inline FsLongitude(std::int32_t Degrees, double DecimalMinutes);
|
||||
inline FsLongitude(std::int32_t Degrees,
|
||||
std::int32_t Minutes,
|
||||
double DecimalSeconds);
|
||||
|
||||
inline long ToFSUnits8() const;
|
||||
inline std::int32_t ToFSUnits4() const;
|
||||
|
||||
inline double DecimalDegrees() const;
|
||||
|
||||
inline double DecimalMinutes() const;
|
||||
inline double DecimalSeconds() const;
|
||||
|
||||
inline std::int32_t Degree() const;
|
||||
inline std::int32_t Minute() const;
|
||||
inline std::int32_t Second() const;
|
||||
|
||||
inline double UDegrees() const;
|
||||
|
||||
inline const std::string to_string(bool HemisphereAsText,
|
||||
char DetailLevel) const;
|
||||
inline const std::string to_string() const;
|
||||
inline FsLongitude Add(const FsLongitudeSpan &Distance) const;
|
||||
inline FsLongitude Subtract(const FsLongitudeSpan &Distance) const;
|
||||
|
||||
inline FsLongitude AddDegrees(double Degrees) const;
|
||||
inline FsLongitude AddMinutes(double Minutes) const;
|
||||
inline FsLongitude AddSeconds(double Seconds) const;
|
||||
};
|
||||
} // namespace FSUIPC
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,133 @@
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSLONGITUDEIMPL_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSLONGITUDEIMPL_H
|
||||
|
||||
#include "FsLongitude.h"
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace FSUIPC
|
||||
{
|
||||
inline FsLongitude::FsLongitude() = default;
|
||||
inline FsLongitude::FsLongitude(double DecimalDegrees)
|
||||
{
|
||||
this->pos = DecimalDegrees;
|
||||
while (this->pos < -180.0 || this->pos > 180.0) {
|
||||
if (this->pos > 180.0)
|
||||
this->pos -= 360.0;
|
||||
if (this->pos < -180.0)
|
||||
this->pos += 360.0;
|
||||
}
|
||||
}
|
||||
inline FsLongitude::FsLongitude(std::int64_t FSUnits)
|
||||
: FsLongitude(FSUnits * 360.0 / 1.8446744073709552E+19)
|
||||
{
|
||||
}
|
||||
inline FsLongitude::FsLongitude(std::int32_t FSUnits)
|
||||
: FsLongitude(FSUnits * 360.0 / 4294967296.0)
|
||||
{
|
||||
}
|
||||
inline FsLongitude::FsLongitude(std::int32_t Degrees, double DecimalMinutes)
|
||||
: FsLongitude(Degrees + DecimalMinutes / 60.0)
|
||||
{
|
||||
}
|
||||
inline FsLongitude::FsLongitude(std::int32_t Degrees,
|
||||
std::int32_t Minutes,
|
||||
double DecimalSeconds)
|
||||
: FsLongitude(Degrees + Minutes / 60.0 + DecimalSeconds / 3600.0)
|
||||
{
|
||||
}
|
||||
|
||||
inline long FsLongitude::ToFSUnits8() const
|
||||
{
|
||||
return this->pos * 1.8446744073709552E+19 / 360.0;
|
||||
}
|
||||
inline std::int32_t FsLongitude::ToFSUnits4() const
|
||||
{
|
||||
return this->pos * 4294967296.0 / 360.0;
|
||||
}
|
||||
|
||||
inline double FsLongitude::DecimalDegrees() const { return this->pos; }
|
||||
|
||||
inline double FsLongitude::DecimalMinutes() const
|
||||
{
|
||||
return (this->pos - trunc(this->pos)) * 60.0;
|
||||
}
|
||||
inline double FsLongitude::DecimalSeconds() const
|
||||
{
|
||||
double decimalMinutes = this->DecimalMinutes();
|
||||
return (decimalMinutes - trunc(decimalMinutes)) * 60.0;
|
||||
}
|
||||
|
||||
inline std::int32_t FsLongitude::Degree() const
|
||||
{
|
||||
return trunc(this->DecimalDegrees());
|
||||
}
|
||||
inline std::int32_t FsLongitude::Minute() const
|
||||
{
|
||||
return trunc(this->DecimalMinutes());
|
||||
}
|
||||
inline std::int32_t FsLongitude::Second() const
|
||||
{
|
||||
return trunc(this->DecimalSeconds());
|
||||
}
|
||||
|
||||
inline double FsLongitude::UDegrees() const { return this->pos + 180.0; }
|
||||
|
||||
inline const std::string FsLongitude::to_string(bool HemisphereAsText,
|
||||
char DetailLevel) const
|
||||
{
|
||||
std::ostringstream str;
|
||||
if (!HemisphereAsText) {
|
||||
str << (this->pos < 0.0 ? "-" : "");
|
||||
} else {
|
||||
str << (this->pos < 0.0 ? "W" : "E");
|
||||
}
|
||||
|
||||
switch (DetailLevel) {
|
||||
case 'm':
|
||||
str << this->Degree() << "° " << this->DecimalMinutes() << "'";
|
||||
break;
|
||||
case 's':
|
||||
str << this->Degree() << "° " << this->Minute() << "' "
|
||||
<< this->DecimalSeconds() << "\"";
|
||||
break;
|
||||
default:
|
||||
str << this->pos << "*";
|
||||
break;
|
||||
}
|
||||
return str.str();
|
||||
}
|
||||
inline const std::string FsLongitude::to_string() const
|
||||
{
|
||||
return this->to_string(true, 'm');
|
||||
}
|
||||
|
||||
inline FsLongitude FsLongitude::Add(const FsLongitudeSpan &Distance) const
|
||||
{
|
||||
return FsLongitude(this->pos + Distance.DecimalDegrees());
|
||||
}
|
||||
inline FsLongitude
|
||||
FsLongitude::Subtract(const FsLongitudeSpan &Distance) const
|
||||
{
|
||||
return FsLongitude(this->pos - Distance.DecimalDegrees());
|
||||
}
|
||||
|
||||
inline FsLongitude FsLongitude::AddDegrees(double Degrees) const
|
||||
{
|
||||
return FsLongitude(this->pos + Degrees);
|
||||
}
|
||||
inline FsLongitude FsLongitude::AddMinutes(double Minutes) const
|
||||
{
|
||||
return FsLongitude(this->pos + Minutes / 60.0);
|
||||
}
|
||||
inline FsLongitude FsLongitude::AddSeconds(double Seconds) const
|
||||
{
|
||||
return FsLongitude(this->pos + Seconds / 3600.0);
|
||||
}
|
||||
} // namespace FSUIPC
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSLONGITUDESPAN_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSLONGITUDESPAN_H
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace FSUIPC
|
||||
{
|
||||
class FsLongitude;
|
||||
class FsLatitude;
|
||||
class FsLongitudeSpan
|
||||
{
|
||||
private:
|
||||
double span;
|
||||
|
||||
public:
|
||||
inline FsLongitudeSpan();
|
||||
inline FsLongitudeSpan(double DecimalDegrees);
|
||||
inline FsLongitudeSpan(std::int32_t Degrees, double DecimalMinutes);
|
||||
inline FsLongitudeSpan(std::int32_t Degrees,
|
||||
std::int32_t Minutes,
|
||||
double DecimalSeconds);
|
||||
inline static FsLongitudeSpan FromFeet(double Feet,
|
||||
const FsLatitude &AtLatitude);
|
||||
inline static FsLongitudeSpan
|
||||
FromNauticalMiles(double NauticalMiles,
|
||||
const FsLatitude &AtLatitude);
|
||||
inline static FsLongitudeSpan FromMetres(double Metres,
|
||||
const FsLatitude &AtLatitude);
|
||||
inline static FsLongitudeSpan
|
||||
BetweenTwoLongitudes(const FsLongitude &Lon1,
|
||||
const FsLongitude &Lon2);
|
||||
|
||||
inline double DecimalDegrees() const;
|
||||
inline double DecimalMinutes() const;
|
||||
inline double DecimalSeconds() const;
|
||||
|
||||
inline std::int32_t Degrees() const;
|
||||
inline std::int32_t Minutes() const;
|
||||
inline std::int32_t Seconds() const;
|
||||
|
||||
inline double TotalMinutes() const;
|
||||
inline double TotalSeconds() const;
|
||||
|
||||
inline double ToFeet(const FsLatitude &AtLatitude) const;
|
||||
inline double ToNauticalMiles(const FsLatitude &AtLatitude) const;
|
||||
inline double ToMetres(const FsLatitude &AtLatitude) const;
|
||||
|
||||
inline const std::string to_string(char DetailLevel) const;
|
||||
inline const std::string to_string();
|
||||
};
|
||||
} // namespace FSUIPC
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,133 @@
|
||||
|
||||
#ifndef GERMANAIRLINESVA_FILE_FSUIPC_FSLONGITUDESPANIMPL_H
|
||||
#define GERMANAIRLINESVA_FILE_FSUIPC_FSLONGITUDESPANIMPL_H
|
||||
|
||||
#include "FsLongitudeSpan.h"
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace FSUIPC
|
||||
{
|
||||
inline FsLongitudeSpan::FsLongitudeSpan() = default;
|
||||
inline FsLongitudeSpan::FsLongitudeSpan(double DecimalDegrees)
|
||||
{
|
||||
this->span = DecimalDegrees;
|
||||
}
|
||||
inline FsLongitudeSpan::FsLongitudeSpan(std::int32_t Degrees,
|
||||
double DecimalMinutes)
|
||||
: FsLongitudeSpan(Degrees + DecimalMinutes / 60.0)
|
||||
{
|
||||
}
|
||||
inline FsLongitudeSpan::FsLongitudeSpan(std::int32_t Degrees,
|
||||
std::int32_t Minutes,
|
||||
double DecimalSeconds)
|
||||
: FsLongitudeSpan(Degrees + Minutes / 60.0 + DecimalSeconds / 3600.0)
|
||||
{
|
||||
}
|
||||
|
||||
inline FsLongitudeSpan
|
||||
FsLongitudeSpan::FromFeet(double Feet, const FsLatitude &AtLatitude)
|
||||
{
|
||||
double num =
|
||||
cos(M_PI * AtLatitude.DecimalDegrees() / 180.0) * 131479672.3 / 360.0;
|
||||
return FsLongitudeSpan(Feet / num);
|
||||
}
|
||||
inline FsLongitudeSpan
|
||||
FsLongitudeSpan::FromNauticalMiles(double NauticalMiles,
|
||||
const FsLatitude &AtLatitude)
|
||||
{
|
||||
return FsLongitudeSpan::FromFeet(NauticalMiles * 6076.1155, AtLatitude);
|
||||
}
|
||||
inline FsLongitudeSpan
|
||||
FsLongitudeSpan::FromMetres(double Metres, const FsLatitude &AtLatitude)
|
||||
{
|
||||
return FsLongitudeSpan::FromFeet(Metres * 3.2808, AtLatitude);
|
||||
}
|
||||
inline FsLongitudeSpan
|
||||
FsLongitudeSpan::BetweenTwoLongitudes(const FsLongitude &Lon1,
|
||||
const FsLongitude &Lon2)
|
||||
{
|
||||
return fmod(Lon2.UDegrees() - Lon1.UDegrees(), 360.0) <
|
||||
fmod(Lon1.UDegrees() - Lon2.UDegrees(), 360.0)
|
||||
? FsLongitudeSpan(
|
||||
fmod(Lon2.UDegrees() - Lon1.UDegrees(), 360.0))
|
||||
: FsLongitudeSpan(
|
||||
fmod(Lon1.UDegrees() - Lon2.UDegrees(), 360.0));
|
||||
}
|
||||
|
||||
inline double FsLongitudeSpan::DecimalDegrees() const { return this->span; }
|
||||
inline double FsLongitudeSpan::DecimalMinutes() const
|
||||
{
|
||||
return (this->span - trunc(this->span)) * 60.0;
|
||||
}
|
||||
inline double FsLongitudeSpan::DecimalSeconds() const
|
||||
{
|
||||
double decimalMinutes = this->DecimalMinutes();
|
||||
return (decimalMinutes - trunc(decimalMinutes)) * 60.0;
|
||||
}
|
||||
|
||||
inline std::int32_t FsLongitudeSpan::Degrees() const
|
||||
{
|
||||
return trunc(this->span);
|
||||
}
|
||||
inline std::int32_t FsLongitudeSpan::Minutes() const
|
||||
{
|
||||
return trunc(this->DecimalMinutes());
|
||||
}
|
||||
inline std::int32_t FsLongitudeSpan::Seconds() const
|
||||
{
|
||||
return trunc(this->DecimalSeconds());
|
||||
}
|
||||
|
||||
inline double FsLongitudeSpan::TotalMinutes() const
|
||||
{
|
||||
return this->span * 60.0;
|
||||
}
|
||||
inline double FsLongitudeSpan::TotalSeconds() const
|
||||
{
|
||||
return this->span * 3600.0;
|
||||
}
|
||||
|
||||
inline double FsLongitudeSpan::ToFeet(const FsLatitude &AtLatitude) const
|
||||
{
|
||||
return cos(M_PI * AtLatitude.DecimalDegrees() / 180.0) * 131479672.3 /
|
||||
360.0 * this->span;
|
||||
}
|
||||
inline double
|
||||
FsLongitudeSpan::ToNauticalMiles(const FsLatitude &AtLatitude) const
|
||||
{
|
||||
return this->ToFeet(AtLatitude) / 6076.1155;
|
||||
}
|
||||
inline double FsLongitudeSpan::ToMetres(const FsLatitude &AtLatitude) const
|
||||
{
|
||||
return this->ToFeet(AtLatitude) / 3.2808;
|
||||
}
|
||||
|
||||
inline const std::string FsLongitudeSpan::to_string(char DetailLevel) const
|
||||
{
|
||||
std::ostringstream str;
|
||||
switch (DetailLevel) {
|
||||
case 'm':
|
||||
str << this->Degrees() << "* " << this->DecimalMinutes() << "'";
|
||||
break;
|
||||
case 's':
|
||||
str << this->Degrees() << "* " << this->Minutes() << "' "
|
||||
<< this->DecimalSeconds() << "\"";
|
||||
break;
|
||||
default:
|
||||
str << this->span << "*";
|
||||
break;
|
||||
}
|
||||
return str.str();
|
||||
}
|
||||
inline const std::string FsLongitudeSpan::to_string()
|
||||
{
|
||||
return this->to_string('m');
|
||||
}
|
||||
} // namespace FSUIPC
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -21,11 +21,9 @@ namespace file
|
||||
{
|
||||
/*
|
||||
* Representation of gate
|
||||
* Heading in degrees (0...360)
|
||||
* Center in lat/lon radians
|
||||
* Radius in metres
|
||||
*
|
||||
* Designator must be null terminated
|
||||
*
|
||||
* UINT8 | CHAR[] | POINT | UINT8
|
||||
* -------+------------+--------+-------
|
||||
* STRLEN | DESIGNATOR | CENTER | RADIUS
|
||||
@@ -34,22 +32,29 @@ namespace file
|
||||
{
|
||||
private:
|
||||
std::string designator;
|
||||
struct germanairlinesva::geodata::point center;
|
||||
struct geodata::point center;
|
||||
std::uint8_t radius;
|
||||
|
||||
public:
|
||||
// From X-Plane or MakeRwys
|
||||
Gate(std::string designator,
|
||||
struct germanairlinesva::geodata::point center,
|
||||
double latitude,
|
||||
double longitude,
|
||||
std::uint8_t radius);
|
||||
// From Database
|
||||
Gate(std::string designator,
|
||||
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
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << "Gate " << this->designator << " at " << this->center.latitude
|
||||
<< "N " << this->center.longitude << "E, Radius "
|
||||
str << "Gate " << this->designator << " at "
|
||||
<< geodata::toDegrees(this->center.latitude) << "N "
|
||||
<< geodata::toDegrees(this->center.longitude) << "E, Radius "
|
||||
<< (int)this->radius;
|
||||
return str.str();
|
||||
}
|
||||
|
||||
@@ -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,56 +22,93 @@ namespace file
|
||||
{
|
||||
/*
|
||||
* Representation of one runway with supplementary information
|
||||
* Heading in degrees (0...360) true
|
||||
* Width and length in meters
|
||||
* Heading in degrees true
|
||||
* Threshold center in lat/lon degrees
|
||||
* Width and length in feet
|
||||
*
|
||||
* Designator must be null terminated
|
||||
*
|
||||
* UINT8 | CHAR[] | BOX | UINT8 | UINT16 | UINT16
|
||||
* UINT8 | CHAR[] | POINT | UINT8 | UINT16 | DOUBLE
|
||||
* -------+------------+--------+-------+--------+-------
|
||||
* STRLEN | DESIGNATOR | BOUNDS | WIDTH | LENGTH | TRUHDG
|
||||
* STRLEN | DESIGNATOR | CENTER | WIDTH | LENGTH | TRUHDG
|
||||
*/
|
||||
class Runway
|
||||
{
|
||||
private:
|
||||
std::string designator;
|
||||
struct germanairlinesva::geodata::box bounds;
|
||||
struct geodata::point center;
|
||||
std::uint8_t width;
|
||||
std::uint16_t length;
|
||||
std::uint16_t trueHeading;
|
||||
std::vector<std::uint8_t> file;
|
||||
double trueHeading;
|
||||
|
||||
// QUAD TEST
|
||||
FSUIPC::FsLatLonQuadrilateral quad;
|
||||
|
||||
public:
|
||||
// From X-Plane or MakeRwys
|
||||
Runway(std::string designator,
|
||||
inline Runway(std::string designator,
|
||||
double latitudeStart,
|
||||
double longitudeStart,
|
||||
double latitudeEnd,
|
||||
double longitudeEnd,
|
||||
double width);
|
||||
double width)
|
||||
{
|
||||
this->designator = designator;
|
||||
this->width = width * 33.280839895;
|
||||
|
||||
|
||||
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
|
||||
Runway(std::string designator,
|
||||
struct germanairlinesva::geodata::box bounds,
|
||||
inline Runway(std::string designator,
|
||||
struct geodata::point center,
|
||||
std::uint8_t width,
|
||||
std::uint16_t length,
|
||||
std::uint16_t trueHeading);
|
||||
double trueHeading)
|
||||
{
|
||||
this->designator = designator;
|
||||
this->center = center;
|
||||
this->width = width;
|
||||
this->length = length;
|
||||
this->trueHeading = trueHeading;
|
||||
|
||||
void toFile(std::ofstream &out) const;
|
||||
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 bounds "
|
||||
<< this->bounds.topLeft.latitude << "N "
|
||||
<< this->bounds.topLeft.longitude << "E, "
|
||||
<< this->bounds.topRight.latitude << "N "
|
||||
<< this->bounds.topRight.longitude << "E, "
|
||||
<< this->bounds.bottomRight.latitude << "N "
|
||||
<< this->bounds.bottomRight.longitude << "E, "
|
||||
<< this->bounds.bottomLeft.latitude << "N "
|
||||
<< this->bounds.bottomLeft.longitude << "E, "
|
||||
<< "Width " << (int)this->width << "m, Length " << this->length
|
||||
<< "m, True Heading " << this->trueHeading << "°";
|
||||
str << "Runway " << this->designator << " with threshold center "
|
||||
<< 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();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,10 +42,7 @@ namespace file
|
||||
class SimDatabase
|
||||
{
|
||||
private:
|
||||
std::map<
|
||||
std::string,
|
||||
std::pair<std::vector<const germanairlinesva::file::simdata::Gate>,
|
||||
std::vector<const germanairlinesva::file::simdata::Runway>>>
|
||||
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
airports;
|
||||
|
||||
void fromFile();
|
||||
@@ -60,13 +57,15 @@ namespace file
|
||||
void toFile() const;
|
||||
|
||||
inline std::size_t getCount() const { return this->airports.size(); }
|
||||
inline const std::pair<const std::vector<const Gate>, const std::vector<const Runway>>
|
||||
inline const std::pair<const std::vector<Gate>,
|
||||
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<const Gate>, const std::vector<const 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>>();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,20 +16,24 @@ namespace file
|
||||
{
|
||||
namespace simdata
|
||||
{
|
||||
int scan(const std::string defaultFile,
|
||||
int scan(
|
||||
const std::string defaultFile,
|
||||
const std::string sceneryPack,
|
||||
const std::string logFile,
|
||||
SimDatabase &airports);
|
||||
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
&airports);
|
||||
|
||||
void makeAirport(const std::string &kind,
|
||||
void makeAirport(
|
||||
const std::string &kind,
|
||||
std::ifstream &infile,
|
||||
SimDatabase &airports,
|
||||
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
&airports,
|
||||
std::ofstream &logfile);
|
||||
void makeGate15(std::vector<Gate> &gates,
|
||||
const std::vector<std::string> &fields);
|
||||
void makeRunway(std::vector<const Runway> &runways,
|
||||
void makeRunway(std::vector<Runway> &runways,
|
||||
const std::vector<std::string> &fields);
|
||||
void makeGate1300(std::vector<const Gate> &gates,
|
||||
void makeGate1300(std::vector<Gate> &gates,
|
||||
const std::vector<std::string> &fields);
|
||||
} // namespace simdata
|
||||
} // namespace file
|
||||
|
||||
+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,
|
||||
RecordingEntry::RecordingEntry(std::uint32_t time,
|
||||
std::uint16_t altitude,
|
||||
std::uint16_t groundSpeed,
|
||||
struct germanairlinesva::geodata::point coordinates)
|
||||
struct geodata::point coordinates)
|
||||
{
|
||||
this->time = time;
|
||||
this->altitude = altitude;
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#include "simdata/runway.h"
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace simdata
|
||||
{
|
||||
Runway::Runway(std::string designator,
|
||||
double latitudeStart,
|
||||
double longitudeStart,
|
||||
double latitudeEnd,
|
||||
double longitudeEnd,
|
||||
double width)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
Runway::Runway(std::string designator,
|
||||
germanairlinesva::geodata::box bounds,
|
||||
std::uint8_t width,
|
||||
std::uint16_t length,
|
||||
std::uint16_t trueHeading)
|
||||
{
|
||||
this->designator = designator;
|
||||
this->bounds = bounds;
|
||||
this->width = width;
|
||||
this->length = length;
|
||||
this->trueHeading = trueHeading;
|
||||
}
|
||||
|
||||
void Runway::toFile(std::ofstream &out) const
|
||||
{
|
||||
writeString(out, this->designator);
|
||||
write<decltype(this->bounds)>(out, this->bounds);
|
||||
write<decltype(this->width)>(out, this->width);
|
||||
write<decltype(this->length)>(out, this->length);
|
||||
write<decltype(this->trueHeading)>(out, this->trueHeading);
|
||||
}
|
||||
} // namespace simdata
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
+10
-10
@@ -25,6 +25,8 @@ namespace file
|
||||
toLog("Sim Database updated");
|
||||
} else {
|
||||
this->fromFile();
|
||||
|
||||
toLog("Sim Database loaded");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,8 +58,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);
|
||||
@@ -66,15 +67,14 @@ namespace file
|
||||
std::uint8_t numRunways = read<std::uint8_t>(in);
|
||||
for (int j = 0; j < numRunways; j++) {
|
||||
std::string designator = readString(in);
|
||||
// Bounds
|
||||
struct germanairlinesva::geodata::box bounds =
|
||||
read<struct germanairlinesva::geodata::box>(in);
|
||||
// Center
|
||||
struct geodata::point center = read<struct geodata::point>(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);
|
||||
double trueHeading = read<double>(in);
|
||||
|
||||
this->airports[icao].second.emplace_back(designator,
|
||||
bounds,
|
||||
center,
|
||||
width,
|
||||
length,
|
||||
trueHeading);
|
||||
@@ -96,11 +96,11 @@ namespace file
|
||||
write<std::uint16_t>(out, airports.size());
|
||||
// Airport
|
||||
for (const std::pair<const std::string,
|
||||
std::pair<std::vector<const Gate>, std::vector<const Runway>>>
|
||||
std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
&airport : airports) {
|
||||
std::string icao = airport.first;
|
||||
const std::vector<const Gate> gates = airport.second.first;
|
||||
const std::vector<const Runway> runways = airport.second.second;
|
||||
const std::vector<Gate> gates = airport.second.first;
|
||||
const std::vector<Runway> runways = airport.second.second;
|
||||
// ICAO
|
||||
writeString(out, icao);
|
||||
// Gates
|
||||
|
||||
+36
-35
@@ -6,10 +6,12 @@ namespace file
|
||||
{
|
||||
namespace simdata
|
||||
{
|
||||
int scan(const std::string defaultFile,
|
||||
int scan(
|
||||
const std::string defaultFile,
|
||||
const std::string sceneryPack,
|
||||
const std::string logFile,
|
||||
SimDatabase &database)
|
||||
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
&airports)
|
||||
{
|
||||
std::ifstream base(defaultFile);
|
||||
if (!base.good()) {
|
||||
@@ -29,7 +31,7 @@ namespace file
|
||||
|
||||
// Default
|
||||
logfile << "<FILE> " << defaultFile << std::endl;
|
||||
makeAirport("DEFAULT", base, database, logfile);
|
||||
makeAirport("DEFAULT", base, airports, logfile);
|
||||
base.close();
|
||||
|
||||
std::string line;
|
||||
@@ -37,8 +39,7 @@ 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)) +
|
||||
std::string path = util::rtrim_copy(line.substr(pos + 13)) +
|
||||
"Earth nav data/apt.dat";
|
||||
packs.emplace_back(path);
|
||||
}
|
||||
@@ -49,7 +50,7 @@ namespace file
|
||||
std::ifstream pack(path);
|
||||
if (pack.good()) {
|
||||
logfile << "<FILE> " << path << std::endl;
|
||||
makeAirport("CUSTOM", pack, database, logfile);
|
||||
makeAirport("CUSTOM", pack, airports, logfile);
|
||||
pack.close();
|
||||
} else {
|
||||
pack.close();
|
||||
@@ -59,33 +60,33 @@ namespace file
|
||||
}
|
||||
|
||||
logfile << std::endl
|
||||
<< "<STATUS> Total airports: " << database.numAirports()
|
||||
<< std::endl;
|
||||
<< "<STATUS> Total airports: " << airports.size() << std::endl;
|
||||
|
||||
custom.close();
|
||||
logfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void makeAirport(const std::string &kind,
|
||||
void makeAirport(
|
||||
const std::string &kind,
|
||||
std::ifstream &infile,
|
||||
SimDatabase &database,
|
||||
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
&airports,
|
||||
std::ofstream &logfile)
|
||||
{
|
||||
std::string line;
|
||||
std::string *currentIcao = nullptr;
|
||||
std::vector<const Gate> tmpGates;
|
||||
std::vector<const Runway> tmpRunways;
|
||||
std::vector<Gate> tmpGates;
|
||||
std::vector<Runway> tmpRunways;
|
||||
|
||||
int apCount = 0;
|
||||
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;
|
||||
@@ -93,7 +94,7 @@ namespace file
|
||||
// Write to file if ICAO is valid, and we have gates and runways
|
||||
if (currentIcao != nullptr && !tmpRunways.empty() &&
|
||||
!tmpGates.empty()) {
|
||||
database.addAirport(*currentIcao, tmpGates, tmpRunways);
|
||||
airports[*currentIcao] = {tmpGates, tmpRunways};
|
||||
validCount += 1;
|
||||
logfile << "\t<STATUS> " << *currentIcao << " committed"
|
||||
<< std::endl;
|
||||
@@ -101,8 +102,8 @@ namespace file
|
||||
logfile << "\t<STATUS> " << *currentIcao
|
||||
<< " had no gates or runways" << std::endl;
|
||||
}
|
||||
tmpGates = std::vector<const Gate>();
|
||||
tmpRunways = std::vector<const Runway>();
|
||||
tmpGates = std::vector<Gate>();
|
||||
tmpRunways = std::vector<Runway>();
|
||||
currentIcao = new std::string(fields[4]);
|
||||
apCount += 1;
|
||||
logfile << "\t<" << kind << "> " << line << std::endl;
|
||||
@@ -113,7 +114,7 @@ namespace file
|
||||
// Write to file if ICAO is valid, and we have gates and runways
|
||||
if (currentIcao != nullptr && !tmpRunways.empty() &&
|
||||
!tmpGates.empty()) {
|
||||
database.addAirport(*currentIcao, tmpGates, tmpRunways);
|
||||
airports[*currentIcao] = {tmpGates, tmpRunways};
|
||||
validCount += 1;
|
||||
logfile << "\t<STATUS> " << *currentIcao << " committed"
|
||||
<< std::endl;
|
||||
@@ -121,8 +122,8 @@ namespace file
|
||||
logfile << "\t<STATUS> " << *currentIcao
|
||||
<< " had no gates or runways" << std::endl;
|
||||
}
|
||||
tmpGates = std::vector<const Gate>();
|
||||
tmpRunways = std::vector<const Runway>();
|
||||
tmpGates = std::vector<Gate>();
|
||||
tmpRunways = std::vector<Runway>();
|
||||
currentIcao = nullptr;
|
||||
logfile << "\t<" << kind << " SKIPPED> " << line << std::endl;
|
||||
} else if (currentIcao != nullptr && fields[0] == "100") {
|
||||
@@ -135,7 +136,7 @@ namespace file
|
||||
}
|
||||
|
||||
if (currentIcao != nullptr && !tmpRunways.empty() && !tmpGates.empty()) {
|
||||
database.addAirport(*currentIcao, tmpGates, tmpRunways);
|
||||
airports[*currentIcao] = {tmpGates, tmpRunways};
|
||||
validCount += 1;
|
||||
logfile << "\t<STATUS> " << *currentIcao << " committed" << std::endl;
|
||||
}
|
||||
@@ -143,7 +144,7 @@ namespace file
|
||||
<< validCount << " are valid" << std::endl;
|
||||
}
|
||||
|
||||
void makeGate15(std::vector<const Gate> &gates,
|
||||
void makeGate15(std::vector<Gate> &gates,
|
||||
const std::vector<std::string> &fields)
|
||||
{
|
||||
std::string gateName;
|
||||
@@ -152,13 +153,13 @@ namespace file
|
||||
}
|
||||
gateName += fields.back();
|
||||
gateName = std::regex_replace(gateName, std::regex{","}, "0");
|
||||
struct germanairlinesva::geodata::point pt {
|
||||
std::stod(fields[1]), std::stod(fields[2])
|
||||
};
|
||||
gates.emplace_back(gateName, pt, 40);
|
||||
gates.emplace_back(gateName,
|
||||
std::stod(fields[1]),
|
||||
std::stod(fields[2]),
|
||||
40);
|
||||
}
|
||||
|
||||
void makeRunway(std::vector<const Runway> &runways,
|
||||
void makeRunway(std::vector<Runway> &runways,
|
||||
const std::vector<std::string> &fields)
|
||||
{
|
||||
runways.emplace_back(fields[8],
|
||||
@@ -175,7 +176,7 @@ namespace file
|
||||
std::stod(fields[1]));
|
||||
}
|
||||
|
||||
void makeGate1300(std::vector<const Gate> &gates,
|
||||
void makeGate1300(std::vector<Gate> &gates,
|
||||
const std::vector<std::string> &fields)
|
||||
{
|
||||
std::string gateName;
|
||||
@@ -185,10 +186,10 @@ namespace file
|
||||
gateName += fields.back();
|
||||
gateName = std::regex_replace(gateName, std::regex{","}, "0");
|
||||
|
||||
struct germanairlinesva::geodata::point pt {
|
||||
std::stod(fields[1]), std::stod(fields[2])
|
||||
};
|
||||
gates.emplace_back(gateName, pt, 40);
|
||||
gates.emplace_back(gateName,
|
||||
std::stod(fields[1]),
|
||||
std::stod(fields[2]),
|
||||
40);
|
||||
}
|
||||
} // namespace simdata
|
||||
} // namespace file
|
||||
|
||||
@@ -41,11 +41,16 @@ namespace geodata
|
||||
|
||||
static inline double toRadians(double value) { return value * M_PI / 180; }
|
||||
|
||||
static inline double normalize(double value)
|
||||
static inline double normalizeD(double value)
|
||||
{
|
||||
return fmod(value + 360, 360);
|
||||
}
|
||||
|
||||
static inline double normalizeR(double value)
|
||||
{
|
||||
return value < 0 ? 2 * M_PI + value : value;
|
||||
}
|
||||
|
||||
// Input and Output in degrees
|
||||
static inline double bearingDD(double fromLatitude,
|
||||
double fromLongitude,
|
||||
@@ -58,7 +63,22 @@ namespace geodata
|
||||
sin(toRadians(fromLatitude)) * cos(toRadians(toLatitude)) *
|
||||
cos(toRadians(toLongitude) - toRadians(fromLongitude));
|
||||
|
||||
return normalize(toDegrees(atan2(y, x)));
|
||||
return normalizeD(toDegrees(atan2(y, x)));
|
||||
}
|
||||
|
||||
// Input in degrees, Output in radians
|
||||
static inline double bearingDR(double fromLatitude,
|
||||
double fromLongitude,
|
||||
double toLatitude,
|
||||
double toLongitude)
|
||||
{
|
||||
double y = sin(toRadians(toLongitude) - toRadians(fromLongitude)) *
|
||||
cos(toRadians(toLatitude));
|
||||
double x = cos(toRadians(fromLatitude)) * sin(toRadians(toLatitude)) -
|
||||
sin(toRadians(fromLatitude)) * cos(toRadians(toLatitude)) *
|
||||
cos(toRadians(toLongitude) - toRadians(fromLongitude));
|
||||
|
||||
return normalizeR(atan2(y, x));
|
||||
}
|
||||
|
||||
// Input in degrees, Output in metres
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace germanairlinesva_websocket
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace websocket
|
||||
{
|
||||
#pragma pack(push) /* push current alignment to stack */
|
||||
#pragma pack(1) /* set alignment to 1 byte boundary */
|
||||
@@ -44,6 +45,7 @@ namespace germanairlinesva_websocket
|
||||
};
|
||||
|
||||
#pragma pack(pop) /* restore original alignment from stack */
|
||||
} // namespace germanairlinesva_websocket
|
||||
} // namespace websocket
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace germanairlinesva_websocket
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace websocket
|
||||
{
|
||||
class Websocket
|
||||
{
|
||||
@@ -38,6 +40,7 @@ namespace germanairlinesva_websocket
|
||||
void onClientMessageCallback(const ix::WebSocketMessagePtr &msg);
|
||||
void sendData(data &d);
|
||||
};
|
||||
} // namespace germanairlinesva_websocket
|
||||
} // namespace websocket
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
+18
-17
@@ -1,12 +1,14 @@
|
||||
#include "include/websocket.h"
|
||||
|
||||
namespace germanairlinesva_websocket
|
||||
namespace germanairlinesva
|
||||
{
|
||||
Websocket::Websocket(std::string host,
|
||||
namespace websocket
|
||||
{
|
||||
Websocket::Websocket(std::string host,
|
||||
std::string user,
|
||||
std::function<void(const std::string)> toLog)
|
||||
: host(host), user(user), toLog(std::move(toLog))
|
||||
{
|
||||
{
|
||||
#ifdef IBM
|
||||
// Required on Windows
|
||||
ix::initNetSystem();
|
||||
@@ -20,20 +22,20 @@ Websocket::Websocket(std::string host,
|
||||
this->onClientMessageCallback(msg);
|
||||
});
|
||||
this->webSocket->start();
|
||||
}
|
||||
}
|
||||
|
||||
Websocket::~Websocket()
|
||||
{
|
||||
Websocket::~Websocket()
|
||||
{
|
||||
this->webSocket->stop();
|
||||
this->toLog("WebSocket stopped");
|
||||
#ifdef IBM
|
||||
// Required on Windows
|
||||
ix::uninitNetSystem();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void Websocket::onClientMessageCallback(const ix::WebSocketMessagePtr &msg)
|
||||
{
|
||||
void Websocket::onClientMessageCallback(const ix::WebSocketMessagePtr &msg)
|
||||
{
|
||||
if (msg->type == ix::WebSocketMessageType::Open) {
|
||||
std::stringstream debug_msg;
|
||||
|
||||
@@ -80,15 +82,13 @@ void Websocket::onClientMessageCallback(const ix::WebSocketMessagePtr &msg)
|
||||
this->toLog(msg->str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Websocket::sendData(data &d)
|
||||
{
|
||||
void Websocket::sendData(data &d)
|
||||
{
|
||||
if (strcmp(d.path, this->lastPath) != 0) {
|
||||
strcpy(this->lastPath, d.path);
|
||||
if (germanairlinesva::util::generateMD5(d.path,
|
||||
this->lastHash,
|
||||
this->toLog)) {
|
||||
if (util::generateMD5(d.path, this->lastHash, this->toLog)) {
|
||||
strcpy(this->lastHash, "NOT SET");
|
||||
}
|
||||
}
|
||||
@@ -109,5 +109,6 @@ void Websocket::sendData(data &d)
|
||||
msg << "SEND:" << user << ":" << json.dump();
|
||||
this->webSocket->send(msg.str(), false);
|
||||
}
|
||||
}
|
||||
} // namespace germanairlinesva_websocket
|
||||
}
|
||||
} // namespace websocket
|
||||
} // namespace germanairlinesva
|
||||
+60
-17
@@ -12,7 +12,7 @@ std::atomic<bool> wantsExit;
|
||||
|
||||
std::unique_ptr<germanairlinesva::file::config::Config> configuration;
|
||||
std::unique_ptr<germanairlinesva::file::simdata::SimDatabase> database;
|
||||
std::unique_ptr<germanairlinesva_websocket::Websocket> connector;
|
||||
std::unique_ptr<germanairlinesva::websocket::Websocket> connector;
|
||||
int xplaneVersion;
|
||||
|
||||
/* Datarefs */
|
||||
@@ -43,7 +43,7 @@ XPLMDataRef pitch;
|
||||
XPLMDataRef roll;
|
||||
XPLMDataRef quaternion;
|
||||
|
||||
struct germanairlinesva_websocket::data toSend;
|
||||
struct germanairlinesva::websocket::data toSend;
|
||||
germanairlinesva::file::recording::Recording p;
|
||||
|
||||
/*
|
||||
@@ -114,16 +114,12 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
|
||||
configuration = std::make_unique<germanairlinesva::file::config::Config>();
|
||||
toLog("Config loaded");
|
||||
|
||||
try {
|
||||
connector = std::make_unique<germanairlinesva_websocket::Websocket>(
|
||||
connector = std::make_unique<germanairlinesva::websocket::Websocket>(
|
||||
"wss://ws.hofmannnet.myhome-server.de:8000",
|
||||
configuration->getUser(),
|
||||
toLog);
|
||||
} catch (const std::invalid_argument &e) {
|
||||
toLog(e.what());
|
||||
return 0;
|
||||
}
|
||||
toLog("WebSocket started");
|
||||
|
||||
char hash[2 * MD5LEN + 1] = "";
|
||||
if (germanairlinesva::util::generateMD5(XPLANE_CUSTOM_SCENERY, hash, toLog) ==
|
||||
0) {
|
||||
@@ -132,6 +128,7 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
|
||||
hash,
|
||||
configuration,
|
||||
toLog);
|
||||
}
|
||||
|
||||
toLog("Readback test of sim database using EDDF");
|
||||
auto ap = (*database)["EDDF"];
|
||||
@@ -144,11 +141,57 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
|
||||
toLog("Readback test of sim database using XXXX");
|
||||
auto ap2 = (*database)["XXXX"];
|
||||
ap2.first.size() == 0 ? toLog(" SUCCESS") : toLog(" ERROR");
|
||||
}
|
||||
|
||||
delete connector.release();
|
||||
delete database.release();
|
||||
delete configuration.release();
|
||||
|
||||
// Thread for sending data to websocket
|
||||
serverThread = std::thread(&serverWorker);
|
||||
recordingThread = std::thread(&recordingWorker);
|
||||
toLog("Workers started");
|
||||
|
||||
toLog("Logbook Test");
|
||||
germanairlinesva::file::logbook::Logbook logbook;
|
||||
logbook.addEntry("08.09.2022",
|
||||
"1000",
|
||||
"L049",
|
||||
"D-ALFA",
|
||||
"John F. Kennedy International Aiport / EDDF",
|
||||
"A1",
|
||||
"14L",
|
||||
"Gander International Airport / CYQX",
|
||||
"10",
|
||||
"03",
|
||||
"10:00",
|
||||
"10:20",
|
||||
"13:20",
|
||||
"13:30",
|
||||
210.5,
|
||||
20.1,
|
||||
5012.4156,
|
||||
8.87,
|
||||
5041.3856,
|
||||
7.1,
|
||||
971.14,
|
||||
2.41,
|
||||
980.65,
|
||||
-165.23,
|
||||
1,
|
||||
1.2012,
|
||||
"2022-09-08_VGA1000",
|
||||
5.5,
|
||||
1);
|
||||
logbook.toFile();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
PLUGIN_API void XPluginStop(void)
|
||||
{
|
||||
/* Flight Loop */
|
||||
XPLMUnregisterFlightLoopCallback(flightLoop, nullptr);
|
||||
/* End threads */
|
||||
wantsExit = true;
|
||||
serverThread.join();
|
||||
recordingThread.join();
|
||||
|
||||
delete connector.release();
|
||||
delete database.release();
|
||||
@@ -177,7 +220,7 @@ float flightLoop(float elapsedMe, float elapsedSim, int counter, void *refcon)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
std::memset(&toSend, 0, sizeof(germanairlinesva_websocket::data));
|
||||
std::memset(&toSend, 0, sizeof(germanairlinesva::websocket::data));
|
||||
|
||||
toSend.pause = XPLMGetDatai(pauseIndicator);
|
||||
toSend.pBrake = XPLMGetDataf(parkingBrake);
|
||||
@@ -218,11 +261,11 @@ void serverWorker()
|
||||
germanairlinesva::util::setThreadName("GAServerWorker");
|
||||
|
||||
while (!wantsExit) {
|
||||
struct germanairlinesva_websocket::data copy;
|
||||
struct germanairlinesva::websocket::data copy;
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
std::memcpy(©, &toSend, sizeof(germanairlinesva_websocket::data));
|
||||
std::memcpy(©, &toSend, sizeof(germanairlinesva::websocket::data));
|
||||
}
|
||||
|
||||
connector->sendData(copy);
|
||||
@@ -241,11 +284,11 @@ void recordingWorker()
|
||||
std::uint32_t segment = 0;
|
||||
|
||||
while (!wantsExit) {
|
||||
germanairlinesva_websocket::data copy;
|
||||
germanairlinesva::websocket::data copy;
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
std::memcpy(©, &toSend, sizeof(germanairlinesva_websocket::data));
|
||||
std::memcpy(©, &toSend, sizeof(germanairlinesva::websocket::data));
|
||||
}
|
||||
|
||||
germanairlinesva::file::recording::RecordingEntry currentPath(
|
||||
|
||||
Reference in New Issue
Block a user