27 namespace except = lsst::pex::exceptions;
59 namespace ut = lsst::utils;
62 const long double pi = 3.141592653589793115997963468544;
63 return angleInRadians * 180./pi;
68 const long double pi = 3.141592653589793115997963468544;
69 return angleInDegrees * pi / 180.;
84 ra = round(ra*1e6)/1e6;
87 int hr = (int)
floor(ra/3600.);
90 int mn = (int)
floor(ra/60.);
93 return str(
boost::format(
"%02i:%02i:%05.2f") % hr % mn % ra);
106 string sgn = (dec<0) ?
"-" :
"+";
110 dec = fabs(round(dec*1e6)/1e6);
115 int min = (int)
floor(dec*60);
118 double sec = dec*3600;
119 sec =
floor(sec*100)/100.;
122 return boost::str(
boost::format(
"%s%02i:%02i:%05.2f") % sgn % degrees % min % sec);
158 string regexStr =
"(\\d+)";
159 regexStr.append(delimiter);
160 regexStr.append(
"(\\d+)");
161 regexStr.append(delimiter);
162 regexStr.append(
"([\\d\\.]+)");
164 static const boost::regex re(regexStr);
168 if(! boost::regex_match(raStr.c_str(), what, re)) {
169 string msg= boost::str(
boost::format(
"Failed to parse %s as a declination") % raStr);
175 double hours = boost::lexical_cast<
double>(string(what[1].first, what[1].second));
176 double mins = boost::lexical_cast<
double>(string(what[2].first, what[2].second));
177 double secs = boost::lexical_cast<
double>(string(what[3].first, what[3].second));
179 double raDeg = secs/3600.;
198 string regexStr =
"([\\d]+)";
199 regexStr.append(delimiter);
200 regexStr.append(
"(\\d+)");
201 regexStr.append(delimiter);
202 regexStr.append(
"([\\d\\.]+)");
205 static const boost::regex re(regexStr);
208 if(! boost::regex_search(decStr.c_str(), what, re)) {
209 string msg= boost::str(
boost::format(
"Failed to parse %s as a declination") % decStr);
214 double degrees = boost::lexical_cast<
double>(string(what[1].first, what[1].second));
215 double mins = boost::lexical_cast<
double>(string(what[2].first, what[2].second));
216 double secs = boost::lexical_cast<
double>(string(what[3].first, what[3].second));
218 degrees += ((secs/60.) +mins)/60.;
222 static const boost::regex pm(pmStr);
223 if(boost::regex_search(decStr, pm)) {
double decStrToDeg(std::string decStr, std::string delimiter=":")
std::string decRadToStr(double decRad)
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)
std::string raRadToStr(double raRad)
double degToRad(long double angleInDegrees)
#define LSST_EXCEPT(type,...)
std::string raDecDegToStr(double raDeg, double decDeg)
Extent< int, N > floor(Extent< double, N > const &input)
std::string raDegToStr(double raDeg)
std::string decDegToStr(double decDeg)
std::string raDecRadToStr(double raRad, double decRad)