Changeset 19388 for trunk/Mars/mcore/nova.h
 Timestamp:
 Nov 13, 2018, 4:15:06 PM (8 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Mars/mcore/nova.h
r19293 r19388 27 27 #endif 28 28 29 #ifndef PRESET_OBSERVATORY 30 #define PRESET_OBSERVATORY kORM 31 #endif 32 29 33 const static double kSolarStandardHorizon = LN_SOLAR_STANDART_HORIZON; 30 34 … … 36 40 struct LnLatPosn : public ln_lnlat_posn 37 41 { 38 LnLatPosn() { } 39 LnLatPosn(const ln_lnlat_posn &pos) : ln_lnlat_posn(pos) { } 40 LnLatPosn(std::string obs) 42 typedef std::map<std::string, ln_lnlat_posn> LUT; 43 44 bool operator==(const LnLatPosn &eq) const 45 { 46 return lng==eq.lng && lat==eq.lat; 47 } 48 49 static const LUT &lut() 41 50 { 42 51 #ifndef __CINT__ 43 static const std::map<std::string, ln_lnlat_posn>lut =52 static const LUT lut = 44 53 { 45 54 { "ORM", kORM }, … … 48 57 { "RWTH", kRWTH }, 49 58 }; 59 return lut; 60 #else 61 return LUT(); 62 #endif 63 } 64 65 LnLatPosn() { } 66 LnLatPosn(const ln_lnlat_posn &pos) : ln_lnlat_posn(pos) { } 67 LnLatPosn(std::string obs) 68 { 69 #ifndef __CINT__ 70 if (obs.empty()) 71 return PRESET_OBSERVATORY; 50 72 51 73 for (auto it=obs.begin(); it!=obs.end(); it++) 52 74 *it = toupper(*it); 53 75 54 const auto it = lut .find(obs);55 *this = it==lut .end() ? ln_lnlat_posn({std::numeric_limits<double>::quiet_NaN(),std::numeric_limits<double>::quiet_NaN()}) : it>second;76 const auto it = lut().find(obs); 77 *this = it==lut().end() ? ln_lnlat_posn({std::numeric_limits<double>::quiet_NaN(),std::numeric_limits<double>::quiet_NaN()}) : it>second; 56 78 #endif 57 79 } … … 59 81 { 60 82 return std::isfinite(lat) && std::isfinite(lng); 83 } 84 85 const std::string &name() const 86 { 87 for (auto it=lut().begin(); it!=lut().end(); it++) 88 if (LnLatPosn(it>second)==*this) 89 return it>first; 90 91 static const std::string dummy; 92 return dummy; 93 } 94 95 static const std::string preset() 96 { 97 return LnLatPosn(PRESET_OBSERVATORY).name(); 61 98 } 62 99 }; … … 81 118 }; 82 119 83 HrzPosn::HrzPosn(const ZdAzPosn &za) { alt = 90za.zd; az = za.az180; }120 inline HrzPosn::HrzPosn(const ZdAzPosn &za) { alt = 90za.zd; az = za.az180; } 84 121 85 122 … … 103 140 }; 104 141 105 EquPosn::EquPosn(const RaDecPosn &rd) { ra = rd.ra*15; dec = rd.dec; }106 107 HrzPosn GetHrzFromEqu(const EquPosn &equ, const LnLatPosn &obs, const double &jd)142 inline EquPosn::EquPosn(const RaDecPosn &rd) { ra = rd.ra*15; dec = rd.dec; } 143 144 inline HrzPosn GetHrzFromEqu(const EquPosn &equ, const LnLatPosn &obs, const double &jd) 108 145 { 109 146 HrzPosn hrz; … … 111 148 return hrz; 112 149 } 113 HrzPosn GetHrzFromEqu(const EquPosn &equ, const double &jd)114 { 115 return GetHrzFromEqu(equ, kORM, jd);116 } 117 118 EquPosn GetEquFromHrz(const HrzPosn &hrz, const LnLatPosn &obs, const double &jd)150 inline HrzPosn GetHrzFromEqu(const EquPosn &equ, const double &jd) 151 { 152 return GetHrzFromEqu(equ, PRESET_OBSERVATORY, jd); 153 } 154 155 inline EquPosn GetEquFromHrz(const HrzPosn &hrz, const LnLatPosn &obs, const double &jd) 119 156 { 120 157 EquPosn equ; … … 122 159 return equ; 123 160 } 124 EquPosn GetEquFromHrz(const HrzPosn &hrz, const double &jd)125 { 126 return GetEquFromHrz(hrz, kORM, jd);127 } 128 129 RstTime GetSolarRst(const double &jd, const LnLatPosn &obs, const double &hrz=kSolarStandardHorizon)161 inline EquPosn GetEquFromHrz(const HrzPosn &hrz, const double &jd) 162 { 163 return GetEquFromHrz(hrz, PRESET_OBSERVATORY, jd); 164 } 165 166 inline RstTime GetSolarRst(const double &jd, const LnLatPosn &obs, const double &hrz=kSolarStandardHorizon) 130 167 { 131 168 RstTime rst; … … 133 170 return rst; 134 171 } 135 RstTime GetSolarRst(const double &jd, const double &hrz=kSolarStandardHorizon)136 { 137 return GetSolarRst(jd, kORM, hrz);138 } 139 140 RstTime GetLunarRst(const double &jd, const LnLatPosn &obs=kORM)172 inline RstTime GetSolarRst(const double &jd, const double &hrz=kSolarStandardHorizon) 173 { 174 return GetSolarRst(jd, PRESET_OBSERVATORY, hrz); 175 } 176 177 inline RstTime GetLunarRst(const double &jd, const LnLatPosn &obs=PRESET_OBSERVATORY) 141 178 { 142 179 RstTime rst; … … 144 181 return rst; 145 182 } 146 EquPosn GetSolarEquCoords(const double &jd)183 inline EquPosn GetSolarEquCoords(const double &jd) 147 184 { 148 185 EquPosn equ; … … 151 188 } 152 189 153 double GetLunarDisk(const double &jd)190 inline double GetLunarDisk(const double &jd) 154 191 { 155 192 return ln_get_lunar_disk(jd); 156 193 } 157 194 158 double GetLunarSdiam(const double &jd)195 inline double GetLunarSdiam(const double &jd) 159 196 { 160 197 return ln_get_lunar_sdiam(jd); 161 198 } 162 199 163 double GetLunarPhase(const double &jd)200 inline double GetLunarPhase(const double &jd) 164 201 { 165 202 return ln_get_lunar_phase(jd); 166 203 } 167 204 168 EquPosn GetLunarEquCoords(const double &jd, double precision=0)205 inline EquPosn GetLunarEquCoords(const double &jd, double precision=0) 169 206 { 170 207 EquPosn equ; … … 173 210 } 174 211 175 double GetLunarEarthDist(const double &jd)212 inline double GetLunarEarthDist(const double &jd) 176 213 { 177 214 return ln_get_lunar_earth_dist(jd); 178 215 } 179 216 180 double GetAngularSeparation(const EquPosn &p1, const EquPosn &p2)217 inline double GetAngularSeparation(const EquPosn &p1, const EquPosn &p2) 181 218 { 182 219 return ln_get_angular_separation(const_cast<EquPosn*>(&p1), const_cast<EquPosn*>(&p2)); 183 220 } 184 221 185 double GetAngularSeparation(const HrzPosn &h1, const HrzPosn &h2)222 inline double GetAngularSeparation(const HrzPosn &h1, const HrzPosn &h2) 186 223 { 187 224 EquPosn p1; p1.ra=h1.az; p1.dec=h1.alt; … … 203 240 double fEarthDist; 204 241 205 SolarObjects(const double &jd, const LnLatPosn &obs=Nova:: kORM)242 SolarObjects(const double &jd, const LnLatPosn &obs=Nova::PRESET_OBSERVATORY) 206 243 { 207 244 fJD = jd; … … 219 256 } 220 257 }; 221 222 258 } 223 259
Note: See TracChangeset
for help on using the changeset viewer.