129 lines
3.7 KiB
C++
129 lines
3.7 KiB
C++
#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 |