Ejemplo n.º 1
0
        private void CalculateMoonTimes(GregorianDateTime vcEnd, GregorianDateTime vcAdd, GCEarthData earth, GCConfigRatedEvents rec)
        {
            GregorianDateTime vcNext = new GregorianDateTime();

            vcAdd.SubtractDays(2);
            while (vcAdd.IsBeforeThis(vcEnd))
            {
                vcNext.Set(GCMoonData.GetNextRise(earth, vcAdd, true));
                vcNext.AddHours(earth.TimeZone.GetBiasMinutesForDay(vcNext) / 60.0);
                //AddEvent(vcNext, CoreEventType.CCTYPE_M_RISE, 0, ndst);
                AddRating(vcNext, rec.rateMoonTime[0], rec.rateMoonTime[1]);

                vcNext.Set(GCMoonData.GetNextRise(earth, vcNext, false));
                vcNext.AddHours(earth.TimeZone.GetBiasMinutesForDay(vcNext) / 60.0);
                //AddEvent(vcNext, CoreEventType.CCTYPE_M_SET, 0, ndst);
                AddRating(vcNext, rec.rateMoonTime[1], rec.rateMoonTime[0]);

                vcNext.shour += 0.05;
                vcNext.NormalizeValues();
                vcAdd.Set(vcNext);
            }
        }
Ejemplo n.º 2
0
        public void CalculateEvents(GCLocation loc, GregorianDateTime vcStart, GregorianDateTime vcEnd)
        {
            //GCSunData sun = new GCSunData();
            DstTypeChange ndst = 0;
            int           nData;

            TResultEvents inEvents = this;

            this.Clear();
            this.EarthLocation = loc;
            this.StartDateTime = new GregorianDateTime(vcStart);
            this.EndDateTime   = new GregorianDateTime(vcEnd);

            GregorianDateTime vc = new GregorianDateTime();
            GregorianDateTime vcAdd = new GregorianDateTime(), vcNext = new GregorianDateTime();
            GCEarthData       earth = loc.GetEarthData();

            vc.Set(vcStart);
            vc.TimezoneHours = loc.OffsetUtcHours;
            vcAdd.Set(vc);
            vcAdd.InitWeekDay();

            GCHourTime sunriseData, sunsetData;
            double     sunRise, sunSet;
            double     r1, r2;

            while (vcAdd.IsBeforeThis(vcEnd))
            {
                sunriseData = GCSunData.CalcSunrise(vcAdd, earth);
                sunsetData  = GCSunData.CalcSunset(vcAdd, earth);
                sunRise     = sunriseData.TotalDays;
                sunSet      = sunsetData.TotalDays;
                ndst        = loc.TimeZone.DetermineDaylightChange(vcAdd);

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SUN) != 0)
                {
                    ndst = loc.TimeZone.DetermineDaylightChange(vcAdd);

                    vcAdd.shour = sunriseData.TotalDays - 96.0 / 1440.0;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_ARUN, 0, ndst);

                    vcAdd.shour = sunRise;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_RISE, 0, ndst);

                    vcAdd.shour = (sunRise + sunSet) / 2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_NOON, 0, ndst);

                    vcAdd.shour = sunSet;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_SET, 0, ndst);
                }

                /*if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0)
                 * {
                 *  todayLongitude = sun.longitude_deg;
                 *  vcAdd.shour = sunRise;
                 *  todaySunriseHour = sunRise;
                 *  if (previousLongitude < -10)
                 *  {
                 *      GregorianDateTime prevSunrise = new GregorianDateTime();
                 *      prevSunrise.Set(vcAdd);
                 *      prevSunrise.PreviousDay();
                 *      sun.SunCalc(prevSunrise, earth);
                 *      previousSunriseHour = sun.rise.GetDayTime() - 1;
                 *      previousLongitude = sun.longitude_deg;
                 *      fromTimeLimit = 0;
                 *  }
                 *
                 *  double a, b;
                 *  double jd = vcAdd.GetJulianComplete();
                 *  double ayan = GCAyanamsha.GetAyanamsa(jd);
                 *  r1 = GCMath.putIn360(previousLongitude - ayan) / 30;
                 *  r2 = GCMath.putIn360(todayLongitude - ayan) / 30;
                 *
                 *  while (r2 > r1 + 13)
                 *  {
                 *      r2 -= 12.0;
                 *  }
                 *  while (r2 < r1 + 11)
                 *  {
                 *      r2 += 12.0;
                 *  }
                 *
                 *  a = (r2 - r1) / (todaySunriseHour - previousSunriseHour);
                 *  b = r2 - a * todaySunriseHour;
                 *
                 *  for (double tr = Math.Floor(r1) + 1.0; tr < r2; tr += 1.0)
                 *  {
                 *      double tm = (tr - b) / a;
                 *      if (tm > fromTimeLimit)
                 *      {
                 *          vcNext.Set(vcAdd);
                 *          vcNext.shour = tm;
                 *          vcNext.NormalizeValues();
                 *          inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_ASCENDENT, (int)tr, ndst);
                 *      }
                 *  }
                 *
                 *  previousLongitude = todayLongitude;
                 *  previousSunriseHour = todaySunriseHour - 1;
                 *  fromTimeLimit = previousSunriseHour;
                 * }*/

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_RAHUKALAM) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_RAHU_KALAM);

                    vcAdd.shour = r1;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_RAHU_KALAM, ndst);

                    vcAdd.shour = r2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_RAHU_KALAM, ndst);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YAMAGHANTI) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_YAMA_GHANTI);

                    vcAdd.shour = r1;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_YAMA_GHANTI, ndst);

                    vcAdd.shour = r2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_YAMA_GHANTI, ndst);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_GULIKALAM) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_GULI_KALAM);

                    vcAdd.shour = r1;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_GULI_KALAM, ndst);

                    vcAdd.shour = r2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_GULI_KALAM, ndst);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ABHIJIT_MUHURTA) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_ABHIJIT);

                    if (r1 > 0 && r2 > 0)
                    {
                        vcAdd.shour = r1;
                        inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_ABHIJIT, ndst);

                        vcAdd.shour = r2;
                        inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_ABHIJIT, ndst);
                    }
                }

                vcAdd.NextDay();
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0)
            {
                GCAscendant asc = new GCAscendant();
                asc.Earth           = EarthLocation.GetEarthData();
                asc.CurrentDateTime = new GregorianDateTime(vc);
                while (asc.GetNextAscendantBefore(vcEnd))
                {
                    ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                    inEvents.AddEvent(asc.CurrentDateTime, CoreEventType.CCTYPE_ASCENDENT, asc.CurrentSign, ndst);
                    asc.CurrentDateTime.AddHours(0.5);
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_TITHI) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCTithi.GetNextTithiStart(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_TITHI, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_NAKSATRA) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCNaksatra.GetNextNaksatra(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_NAKS, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YOGA) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCYoga.GetNextYogaStart(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_YOGA, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SANKRANTI) != 0)
            {
                vcNext = new GregorianDateTime();
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    vcNext.Set(GCSankranti.GetNextSankranti(vcAdd, earth, out nData));
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_SANK, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.NextDay();
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOONRASI) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCMoonData.GetNextMoonRasi(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RASI, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.5;
                    vcAdd.NormalizeValues();
                }
            }
            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_CONJUNCTION) != 0)
            {
                double dlong;
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    dlong = GCConjunction.GetNextConjunction(vcAdd, out vcNext, true, earth);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_CONJ, GCRasi.GetRasi(dlong, GCAyanamsha.GetAyanamsa(vcNext.GetJulianComplete())), ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.NextDay();
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOON) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    vcNext.Set(GCMoonData.GetNextRise(earth, vcAdd, true));
                    inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RISE, 0, ndst);

                    vcNext.Set(GCMoonData.GetNextRise(earth, vcNext, false));
                    inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_SET, 0, ndst);

                    vcNext.shour += 0.05;
                    vcNext.NormalizeValues();
                    vcAdd.Set(vcNext);
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0)
            {/*
              *         vcAdd = vc;
              *         vcAdd.shour = 0.0;
              *         while(vcAdd.IsBeforeThis(vcEnd))
              *         {
              *                 nData = earth.GetNextAscendentStart(vcAdd, vcNext);
              *                 if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
              *                 {
              *                         vcNext.InitWeekDay();
              *                         ndst = TTimeZone.determineDaylightChange(vcNext, loc.m_nDST);
              *                         inEvents.AddEvent(vcNext, CCTYPE_ASCENDENT, nData, ndst);
              *                 }
              *                 else
              *                 {
              *                         break;
              *                 }
              *                 vcAdd = vcNext;
              *                 vcAdd.shour += 1/24.0;
              *                 if (vcAdd.shour >= 1.0)
              *                 {
              *                         vcAdd.shour -= 1.0;
              *                         vcAdd.NextDay();
              *                 }
              *         }
              *
              */
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SORT) != 0)
            {
                inEvents.Sort(SORTING_BY_DATE);
            }
            else
            {
                inEvents.Sort(SORTING_BY_TYPE);
            }
        }