File indexing completed on 2025-01-05 03:58:41
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2012 Gerhard HOLTKAMP 0004 // 0005 0006 #if !defined(__eclsolar_h) 0007 #define __eclsolar_h 0008 0009 #include "attlib.h" 0010 #include "digikam_export.h" 0011 0012 const int GBL_ECLBUF = 12; // maximum number of eclipses allowed 0013 const int MAXLUN = 15; 0014 0015 typedef double PMJD[MAXLUN]; // array of MJD's of the respective phase 0016 0017 class DIGIKAM_EXPORT EclSolar // Calculate Solar Eclipses 0018 { 0019 public: 0020 EclSolar(); 0021 ~EclSolar(); 0022 0023 int getYear() const; // the year currently used by EclSolar 0024 void putYear(int yr); // set the year to be used by EclSolar 0025 int getNumberEclYear(); // get the number of eclipses of the currently selected year 0026 void setLunarEcl(bool lecl); // include lunar eclipses 0027 void setStepWidth(double s); // set the step width (minutes) 0028 void setTimezone(double d); // set timezone for I/O 0029 void setDeltaTAI_UTC(double d); // set IERS Parameter TAI - UTC 0030 void setAutoTAI_UTC(); // IERS Parameter TAI - UTC to auto 0031 void setLocalPos(double lat, double lng, double hgt); // set local geographic coordinates 0032 void getLocalDetails(char *otxt); // provide eclipse details for local position 0033 void setCurrentMJD(int year, int month, int day, int hour, int min, double sec); // set current time 0034 void getDatefromMJD(double mjd, int &year, int &month, int &day, 0035 int &hour, int &min, double &sec) const; // convert MJD into date and time 0036 int getLocalVisibility(double &mjd_start, double &mjd_stop); // local start and stop times for eclipse 0037 int getLocalTotal(double &mjd_start, double &mjd_stop); // local start and stop times for totality/annularity 0038 int getLocalMax(double &mjdmax, double &magmax, double &elmax); // get local (solar) eclipse maximum 0039 int getPenumbra(double &mjd_start, double &mjd_stop); // start and stop times for penumbral eclipse of Moon 0040 int getPartial(double &mjd_start, double &mjd_stop); // (global) start and stop times for partial phase 0041 int getTotal(double &mjd_start, double &mjd_stop); // (global) start and stop times for totality/annularity 0042 void getEclYearInfo(char* wbuf); // list of eclipses of the year 0043 int getEclYearInfo(int k, int &yr, int &month, int &day, 0044 int &hour, int &min, double &sec, double &tzone, double &magn); 0045 int getEclTxt (int j, char* jtxt); // get text for j-th eclipse 0046 void putEclSelect(int es); // select particular eclipse for details 0047 void nextEcl(); // select the next eclipse for details 0048 void previousEcl(); // select the previous eclipse for details 0049 double getLastMJD() const; // get the MJD last used in calculations 0050 void getMaxPos(double &lat, double &lng); // get position of maximum eclipse 0051 int eclPltCentral(bool firstc, double &lat, double &lng); // calc central eclipse line 0052 int GNSBound(bool firstc, bool north, double& lat, double& lng); // northern or southern boundary 0053 int GRSBound(bool firstc, double& lat1, double& lng1, double& lat2, double& lng2); 0054 // Rise / Set Boundary 0055 int centralBound(bool firstc, double& lat1, double& lng1, double& lat2, double& lng2); 0056 void getShadowCone(double mjd, bool umbra, int numpts, double* lat, double* lng); 0057 void setPenumbraAngle(double pa, int mode); 0058 0059 private: 0060 void esinit(); // initialize EclSolar 0061 static double atan23 (double y, double x); // atan without singularity for x,y=0 0062 void DefTime (); // Get System Time and Date 0063 void calcMaxPos(double &lat, double &lng); // get position of maximum eclipse 0064 static void GetMonth (int mm, char* mchr); 0065 static double phmjd (double yearf, double phase, double tdut, 0066 int& eph, double& ejd, double& emag); 0067 void ckphase (double minmjd, double maxmjd, double yr, 0068 double deltdut, int &mp, PMJD p, double phase); 0069 static void dtmstr(double jdmoon, char *dts); 0070 void moonph(); // calculate phases of the Moon 0071 void eclStart(); // initialize detailed calcs for selected eclipse 0072 static double getlocmag(double jd, double ep2, double phi, double lamda, 0073 double height, const Vec3& rs, const Vec3& rm, int& totflg); 0074 static int iscrs(double vrc0, double vrc1, double dpn, 0075 double& vrx0, double& vrx1, double& vrx20, double& vrx21); 0076 void InitBound(); // initialize boundary calcs 0077 void InRSBound(); // initialize Sunrise/Sunset boundaries 0078 static double DegFDms (double h); 0079 int localStart(int j, double *spt, double *ept, int *spp, 0080 int p, char *otxt); 0081 static double navCourse (double lat1, double lng1, double lat2, double lng2); // navigation course from p1 to p2 0082 static void navNewPos (double d, double an, double lat1, double lng1, double &lat2, double &lng2); 0083 static double sunObscure(double l1, double l2, double m); // get the Obscuration of the Sun 0084 0085 // data fields 0086 0087 bool eb_start_called; // true if eclStart() has already been called for eclipse 0088 bool eb_moonph_called; // true if moonph has already been called for year 0089 bool eb_lunecl; // true if lunar eclipses are to be included 0090 bool eb_lunactive; // true if current eclipse is a lunar eclipse 0091 bool eb_local_called; // true if local circumstances calculated 0092 0093 int eb_day; // date 0094 int eb_month; 0095 int eb_year; 0096 int eb_hour; 0097 int eb_minute; 0098 int eb_second; 0099 double eb_time; 0100 double eb_tzone; // timezone in hours 0101 double eb_del_tdut; // TDT - UT in sec 0102 int eb_del_auto; // 1 = automatic del_tdut, 0 = manual 0103 double eb_geolat; // geographic coordinates (angles in degrees) 0104 double eb_geolong; 0105 double eb_geoheight; // in meters 0106 int eb_lstcall; // 1 = last call moonph; 2 = caldisp; 0 = no call 0107 int eb_locecl; // 1 = local eclipse call; 0 = normal (global) call 0108 0109 bool eb_finished; // true if the loop run on consecutive calls is finished 0110 bool eb_finished2; 0111 int eb_numecl; // number of eclipses of the year; 0112 int eb_eclselect; // eclipse selected for detailed calculation 0113 int eb_lastyear; // last year for which moon phases were calculated 0114 double eb_lasttz; // last used timezone 0115 double eb_lastdlt; // last delta-t used 0116 double eb_cstep; // step width in minutes used for central eclipse output 0117 double eb_eclmjd [GBL_ECLBUF]; // the MJD's of the middle of the eclipses 0118 double eb_magnitude [GBL_ECLBUF]; // magnitude of respective eclipse 0119 int eb_phase [GBL_ECLBUF]; // phase of the eclipse. 0 if no eclipse, 0120 // 1 partial Sun, 2 non-central annular, 3 non-central total, 0121 // 4 annular, 5 total, 6 annual/total Sun 0122 // -1 partial penumbral Moon, -2 penumbral Moon, 0123 // -3 partial Moon, -4 total Moon. 0124 int eb_nphase; // number of phases for eclipse details 0125 int eb_spp[4]; // kind of eclipse phase i 0126 double eb_spt[4]; // start time in MJD for phase i 0127 double eb_ept[4]; // end time in MJD for phase i 0128 int eb_lccnt; // = 0 not visible, 1,2 = first rise/set; 3,4 second r/s 0129 double eb_lcb1, eb_lcb2, eb_lce1, eb_lce2; // rise and set times (up to 2 possible) 0130 double eb_jdmaxps; // MJD of maximum phase 0131 double eb_maxps; // value of maximum phase 0132 double eb_maxelv; // elevation at maximum phase 0133 double eb_ltotb; // begin of totality/annularity at local position 0134 double eb_ltote; // end of totality/annularity at local position 0135 int eb_cphs; // phase of the central eclipse for center line plotting 0136 double eb_clat; // current latitude of center line (in decimal degrees) 0137 double eb_clng; // current longitude of center line (in decimal degrees) 0138 double eb_cmxlat; // latitude of maximum eclipse (in decimal degrees) 0139 double eb_cmxlng; // longitude of maximum eclipse (in decimal degrees) 0140 double eb_jdstart; // (global) start jd of eclipse 0141 double eb_jdstop; // (global) end jd of eclipse 0142 double eb_lastjd; // last used MJD for eclipse calcs 0143 double eb_dpb; // Base value for diameter of penumbra 0144 double eb_dpd; // delta value for diameter of penumbra 0145 double eb_penangle; // factor for multiplying the penumbra angle (1.0 for normal borders) 0146 int eb_penamode; // mode for using eb_penangle 0147 Vec3 eb_ubm; // Penumbra (or Umbra or Moon) base vector 0148 Vec3 eb_ube; // Shadow base vector for upper boundary 0149 Vec3 eb_udm; // Penumbra base delta vector 0150 Vec3 eb_ude; // Shadow delta vector for upper boundary 0151 Vec3 eb_lbe; // Shadod base vector for lower boundary 0152 Vec3 eb_lde; // Shadow delta vector for lower boundary 0153 0154 }; 0155 0156 #endif // __eclsolar_h sentry. 0157