18#define M_PI std::numbers::pi
24constexpr double D2R = M_PI / 180.;
30constexpr double F_WGS84 = 0.003352810664747;
36#define MPS2KNOT (3600. / NM2M)
37#define USFOOT2M (1200. / 3937.)
40constexpr double MAS = M_PI / (180 * 3600000.);
45constexpr double operator"" _ftUS (
long double ftus)
50constexpr double operator"" _ftUS (
unsigned long long ftus)
58constexpr double operator"" _nmi (
long double nmi)
63constexpr double operator"" _nmi (
unsigned long long nmi)
74constexpr double DEG (
double dd)
80constexpr double D2rad (
double dd)
86constexpr double rad2D (
double r)
94constexpr double DM (
double dd,
double mm)
96 return (dd + mm / 60.) *
D2R;
102 int sign = (ddmm >= 0) ? 1 : -1;
105 int deg = (int)(ddmm / 100.);
106 ddmm -= (double)deg * 100.;
107 return sign * (deg + ddmm / 60.);
114 return (dd - deg) * 60. + deg * 100.;
132constexpr double DMS (
double dd,
double mm,
double ss)
134 return (dd + mm / 60. + ss / 3600.) *
D2R;
140 int sign = (dms >= 0) ? 1 : -1;
143 int deg = (int)(dms / 10000.);
144 dms -= (double)deg * 10000;
145 int min = (int)(dms / 100.);
146 dms -= (double)min * 100.;
147 return sign * (deg + min / 60. + dms / 3600.);
160constexpr double operator"" _deg (
long double deg)
165constexpr double operator"" _deg (
unsigned long long deg)
173constexpr double operator"" _arcmin (
long double min)
175 return min/60. *
D2R;
178constexpr double operator"" _arcmin (
unsigned long long min)
180 return min/60. *
D2R;
186constexpr double operator ""_dm (
long double val)
191constexpr double operator ""_dm (
unsigned long long val)
193 return DM2rad ((
double)val);
199constexpr double operator ""_dms (
long double val)
204constexpr double operator ""_dms (
unsigned long long val)
212constexpr double operator"" _arcsec (
long double sec)
214 return sec/3600. *
D2R;
217constexpr double operator"" _arcsec (
unsigned long long sec)
219 return sec/3600. *
D2R;
226constexpr double operator"" _mas (
long double mas)
231constexpr double operator"" _mas (
unsigned long long mas)
254double atodeg (
const std::string& str);
constexpr double rad2DM(double rad)
Convert from radians to degrees, minutes (DDMM.mmm)
Definition convert.h:118
constexpr double DM2rad(double val)
Convert degrees, minutes (DDMM.mmm) to radians.
Definition convert.h:124
constexpr double DMS2rad(double dms)
Convert degrees, minutes, seconds (DDMMSS.sss) to radians.
Definition convert.h:151
constexpr double DMS2deg(double dms)
Convert degrees, minutes, seconds (DDMMSS.sss) to decimal degrees.
Definition convert.h:138
constexpr double F_WGS84
Flattening of WGS84 ellipsoid.
Definition convert.h:30
#define USFOOT2M
US Survey foot to meters conversion factor.
Definition convert.h:37
constexpr double MAS
milli-arcsecond
Definition convert.h:40
double atodeg(const std::string &str)
Conversion from string to decimal degrees.
Definition convert.cpp:116
constexpr double DM(double dd, double mm)
Convert degrees, minutes to radians.
Definition convert.h:94
#define NM2M
Nautical mile to meters conversion factor.
Definition convert.h:35
constexpr double DEG(double dd)
Convert decimal degrees to radians.
Definition convert.h:74
constexpr double F1_WGS84
Inverse of flattening for WGS84 ellipsoid.
Definition convert.h:33
constexpr double D2R
Degrees to radians conversion factor.
Definition convert.h:24
constexpr double D2rad(double dd)
Convert decimal degrees to radians.
Definition convert.h:80
constexpr double deg2DM(double dd)
Convert decimal degrees to degrees, minutes (DDMM.mmm)
Definition convert.h:111
constexpr double rad2D(double r)
Convert radians to decimal degrees.
Definition convert.h:86
constexpr double DM2deg(double ddmm)
Convert degrees, minutes (DDMM.mmm) to decimal degrees.
Definition convert.h:100
std::string degtoa(double degrees, deg_fmt format, bool latitude, int precision)
Conversion from degrees to a string.
Definition convert.cpp:62
deg_fmt
Formatting options for degtoa() function.
Definition convert.h:244
double deg_reduce(double value)
Reduces a degrees value to [0,360) interval.
Definition convert.cpp:39
constexpr double A_WGS84
Semimajor axis of WGS84 ellipsoid.
Definition convert.h:27
constexpr double DMS(double dd, double mm, double ss)
Convert degrees, minutes seconds to radians.
Definition convert.h:132
@ minutes
Degrees, minutes format (DD°MM.mmmm')
Definition convert.h:246
@ degrees
Decimal degrees (DD.dddd°)
Definition convert.h:245
@ seconds
Degrees, minutes, seconds format (DD°MM'SS.sss")
Definition convert.h:247