166 lines
7.2 KiB
C++
166 lines
7.2 KiB
C++
#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 |