133 lines
4.1 KiB
C++

#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