// ----------------------------------------------------------------------- // position_related.cc: General utility functions related to WCS positions // ----------------------------------------------------------------------- // Copyright (C) 2006, Matthew Whiting, ATNF // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the // Free Software Foundation; either version 2 of the License, or (at your // option) any later version. // // Duchamp is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. // // You should have received a copy of the GNU General Public License // along with Duchamp; if not, write to the Free Software Foundation, // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA // // Correspondence concerning Duchamp may be directed to: // Internet email: Matthew.Whiting [at] atnf.csiro.au // Postal address: Dr. Matthew Whiting // Australia Telescope National Facility, CSIRO // PO Box 76 // Epping NSW 1710 // AUSTRALIA // ----------------------------------------------------------------------- #include #include #include #include #include #include #include using std::setw; using std::setfill; using std::setprecision; std::string getIAUNameEQ(double ra, double dec, float equinox) { /** * std::string getIAUNameEQ(double, double, float) * both ra and dec are assumed to be in degrees. * returns name of the form J123456-654321 for equinox = 2000, * and B1234-4321 otherwise */ std::string rastr=decToDMS(ra,"RA",0); rastr.erase(rastr.begin()+2); rastr.erase(rastr.begin()+4); if(equinox==2000.) rastr.erase(rastr.begin()+6,rastr.end()); else rastr.erase(rastr.begin()+4,rastr.end()); std::string decstr=decToDMS(dec,"DEC",0); decstr.erase(decstr.begin()+3); decstr.erase(decstr.begin()+5); if(equinox==2000.) decstr.erase(decstr.begin()+7,decstr.end()); else decstr.erase(decstr.begin()+5,decstr.end()); std::stringstream ss; if(equinox==2000.) ss<<"J"; else ss<<"B"; ss<= 360.) { thisDec -= 360.; } if(type=="RA") thisDec /= degPerHour; // Convert to hours. } else if((type=="DEC")||(type=="GLAT")){ if(thisDec<0.) sign = "-"; else sign = "+"; } else { // UNKNOWN TYPE -- DEFAULT TO RA. std::cerr << "WARNING : Unknown axis type (" << type << "). Defaulting to using RA.\n"; while (thisDec < 0.) { thisDec += 360.; } while (thisDec >= 360.) { thisDec -= 360.; } thisDec /= degPerHour; } dec_abs = fabs(thisDec); minD = modf(dec_abs, °D) * minPerHour; sec = modf(minD, &minDint) * minPerHour; deg = int(degD); min = int(minDint); if(fabs(sec-minPerHour)0) ss<