27 namespace except = lsst::pex::exceptions;
58 namespace ut = lsst::utils;
61 const long double pi = 3.141592653589793115997963468544;
62 return angleInRadians * 180./pi;
67 const long double pi = 3.141592653589793115997963468544;
68 return angleInDegrees * pi / 180.;
83 ra = round(ra*1e6)/1e6;
86 int hr = (int) floor(ra/3600.);
89 int mn = (int) floor(ra/60.);
92 return boost::str( boost::format(
"%02i:%02i:%05.2f") % hr % mn % ra);
105 std::string sgn = (dec<0) ?
"-" :
"+";
109 dec = fabs(round(dec*1e6)/1e6);
111 int degrees = (int) floor(dec);
114 int min = (int) floor(dec*60);
117 double sec = dec*3600;
118 sec = floor(sec*100)/100.;
120 std::string str = sgn;
121 return boost::str(boost::format(
"%s%02i:%02i:%05.2f") % sgn % degrees % min % sec);
158 std::string delimiter
161 std::string regexStr =
"(\\d+)";
162 regexStr.append(delimiter);
163 regexStr.append(
"(\\d+)");
164 regexStr.append(delimiter);
165 regexStr.append(
"([\\d\\.]+)");
167 const boost::regex re(regexStr);
171 if(! boost::regex_search(inStr.c_str(), what, re)) {
172 std::string msg= boost::str(boost::format(
173 "Failed to parse %s as a right ascension or declination with regex %s")
175 throw LSST_EXCEPT(except::RuntimeError, msg);
179 double hh_or_dd = std::stod(std::string(what[1].first, what[1].second));
180 double mm = std::stod(std::string(what[2].first, what[2].second));
181 double ss = std::stod(std::string(what[3].first, what[3].second));
183 hh_or_dd += (mm + ss/60.0)/60.0;
186 std::string pmStr =
"^-";
187 static const boost::regex pm(pmStr);
188 if(boost::regex_search(inStr, pm))
202 std::string msg= boost::str(boost::format(
"Right ascension %s is negative!") % raStr);
203 throw LSST_EXCEPT(except::RuntimeError, msg);
206 return ra_hours * (360.0/24.0);
double decStrToDeg(std::string decStr, std::string delimiter=":")
std::string raDecDegToStr(double raDeg, double decDeg)
std::string decRadToStr(double decRad)
std::string raDecRadToStr(double raRad, double decRad)
double sexagesimalStrToDecimal(std::string inStr, std::string delimiter)
Convert a sexagesimal string to a decimal double.
double decStrToRad(std::string decStr, std::string delimiter=":")
double raStrToDeg(std::string raStr, std::string delimiter=":")
double raStrToRad(std::string raStr, std::string delimiter=":")
double radToDeg(long double angleInRadians)
double degToRad(long double angleInDegrees)
std::string raRadToStr(double raRad)
Convert a right ascension in radians to a string format.
std::string raDegToStr(double raDeg)
std::string decDegToStr(double decDeg)