public void CalculateEvents(GPLocationProvider loc, GPGregorianTime vcStart, GPGregorianTime vcEnd) { GPCoreEventResults inEvents = this; GPLocationProvider earth = loc; GPGregorianTime vc = new GPGregorianTime(loc); GPSun sun = new GPSun(); //int ndst = 0; int nData; inEvents.clear(); inEvents.m_location = loc; inEvents.m_vcStart = vcStart; inEvents.m_vcEnd = vcEnd; GPGregorianTime vcAdd = new GPGregorianTime(loc); GPGregorianTime vcTemp = null; GPGregorianTime vcNext = new GPGregorianTime(loc); vc.Copy(vcStart); if (GPDisplays.CoreEvents.Sunrise()) { vcAdd.Copy(vc); while (vcAdd.IsBeforeThis(vcEnd)) { sun.SunCalc(vcAdd, earth); vcTemp = new GPGregorianTime(sun.arunodaya); inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_ARUN, 0); //GPJulianTime tr, tt, ts; //GPAstroEngine.CalculateTimeSun(vcTemp, vcTemp.getLocation(), out tr, out tt, out ts); vcTemp = new GPGregorianTime(sun.rise); //vcTemp = new GPGregorianTime(vcTemp.getLocation(), tr); inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_RISE, 0); vcTemp = new GPGregorianTime(sun.noon); //vcTemp = new GPGregorianTime(vcTemp.getLocation(), tt); inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_NOON, 0); vcTemp = new GPGregorianTime(sun.set); //vcTemp = new GPGregorianTime(vcTemp.getLocation(), ts); inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_SET, 0); vcAdd.NextDay(); } } if (GPDisplays.CoreEvents.Tithi()) { GPTithi te = new GPTithi(); te.setStartDate(vc); vcAdd = te.getNext(); while (vcAdd.IsBeforeThis(vcEnd)) { nData = te.getCurrentPosition(); //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext); inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_TITHI, nData); vcAdd = te.getNext(); } } if (GPDisplays.CoreEvents.Naksatra()) { GPNaksatra te = new GPNaksatra(); te.setStartDate(vc); vcAdd = te.getNext(); while (vcAdd.IsBeforeThis(vcEnd)) { nData = te.getCurrentNaksatra(); //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext); inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_NAKS, nData); vcAdd = te.getNext(); } } if (GPDisplays.CoreEvents.Sankranti()) { GPSankranti te = new GPSankranti(); te.setStartDate(vc); vcAdd = te.getNext(); while (vcAdd.IsBeforeThis(vcEnd)) { nData = te.getCurrentPosition(); //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext); inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_SANK, nData); vcAdd = te.getNext(); } } if (GPDisplays.CoreEvents.Conjunction()) { double[] times = null; GPConjunction te = new GPConjunction(); te.setStartDate(vc); vcAdd = te.getNext(); while (vcAdd.IsBeforeThis(vcEnd)) { nData = te.getCurrentPosition(); //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext); inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_CONJ, nData); if (GPDisplays.CoreEvents.SunEclipse()) { GPAstroEngine.CalculateTimesSunEclipse(vcAdd.getJulianGreenwichTime(), vcAdd.getLocation(), out times); if (times != null && times[2] > 0) { for (int i = 0; i < 5; i++) { if (times[i] > 0) { GPGregorianTime gt = new GPGregorianTime(vcAdd.getLocation()); gt.setJulianGreenwichTime(new GPJulianTime(times[i], 0.0)); inEvents.AddEvent(gt, GPConstants.SUNECLIPSE_CONSTS[i], 0); } } } } vcAdd = te.getNext(); } } // moon eclipses if (GPDisplays.CoreEvents.MoonEclipse()) { double[] times = null; GPConjunction te = new GPConjunction(); te.setOpositeConjunction(true); te.setStartDate(vc); vcAdd = te.getNext(); while (vcAdd.IsBeforeThis(vcEnd)) { GPAstroEngine.CalculateTimesMoonEclipse(vcAdd.getJulianGreenwichTime(), vcAdd.getLocation(), out times); if (times != null && times[4] > 0) { for (int i = 0; i < 9; i++) { if (times[i] > 0 && GPConstants.MOONECLIPSE_CONSTS[i] > 0) { GPGregorianTime gt = new GPGregorianTime(vcAdd.getLocation()); gt.setJulianGreenwichTime(new GPJulianTime(times[i], 0.0)); inEvents.AddEvent(gt, GPConstants.MOONECLIPSE_CONSTS[i], 0); } } } vcAdd = te.getNext(); } } // rise and set of the moon if (GPDisplays.CoreEvents.Moonrise()) { GPJulianTime julian = vc.getJulian(); GPJulianTime julianEnd = vcEnd.getJulian(); GPJulianTime nextJulian; TRiseSet kind; while (julian.getGreenwichJulianDay() < julianEnd.getGreenwichJulianDay()) { nextJulian = GPAstroEngine.GetNextMoonEvent(julian, vc.getLocationProvider(), out kind); if (kind == TRiseSet.RISE) { inEvents.AddEvent(new GPGregorianTime(loc, nextJulian), GPConstants.CoreEventMoonRise, 0); } else if (kind == TRiseSet.SET) { inEvents.AddEvent(new GPGregorianTime(loc, nextJulian), GPConstants.CoreEventMoonSet, 0); } julian.setGreenwichJulianDay(nextJulian.getGreenwichJulianDay() + 10.0 / 1440.0); } } // travellings { GPJulianTime julian = vc.getJulian(); GPJulianTime julianEnd = vcEnd.getJulian(); double start, end; start = julian.getGreenwichJulianDay(); end = julianEnd.getGreenwichJulianDay(); for (int i = 0; i < loc.getChangeCount(); i++) { GPLocationChange chn = loc.getChangeAtIndex(i); if ((chn.julianStart >= start && chn.julianStart <= end) || (chn.julianStart >= start && chn.julianEnd <= end)) { GPGregorianTime startTime = new GPGregorianTime(chn.LocationA); startTime.setJulianGreenwichTime(new GPJulianTime(chn.julianStart, 0)); GPGregorianTime endTime = new GPGregorianTime(chn.LocationB); endTime.setJulianGreenwichTime(new GPJulianTime(chn.julianEnd, 0)); inEvents.AddEvent(startTime, GPConstants.CCTYPE_TRAVELLING_START, 0); inEvents.AddEvent(endTime, GPConstants.CCTYPE_TRAVELLING_END, 0); } } } // eventual sorting inEvents.Sort(GPDisplays.CoreEvents.Sort()); }
public static void AvcGetTodayInfo(GPGregorianTime vc, GPLocationProvider loc, StringBuilder str) { string str2; GPCalendarResults db = new GPCalendarResults(); GPGregorianTime vc2 = new GPGregorianTime(vc); vc2.AddDays(-4); db.CalculateCalendar(vc2, 9); int i = db.FindDate(vc); GPCalendarDay p = db.get(i); if (p == null) { return; } str.AppendFormat("{0}, {1} {2}", loc.getFullName(), loc.getLocation(0).getLatitudeString(), loc.getLocation(0).getLongitudeString()); str.AppendLine(); str.AppendFormat("{0}: {1}", getSharedStringPlain(12), loc.getLocation(0).getTimeZoneString()); str.AppendLine(); str.AppendLine(); str.AppendFormat("[{0} - {1}]", vc, getSharedStringPlain(vc.getDayOfWeek())); str.AppendLine(); str.AppendFormat(" {0}, {1} {2}", GPTithi.getName(p.astrodata.nTithi), GPPaksa.getName(p.astrodata.nPaksa), getSharedStringPlain(20)); str.AppendLine(); str.Append(" "); str.AppendFormat("{0}, {1}", p.getMasaLongName(), p.getGaurabdaYearLongString()); str.AppendLine(); str.AppendLine(); if (p.hasEkadasiParana()) { str.AppendLine(p.getEkadasiParanaString()); } // adding mahadvadasi // adding spec festivals foreach (GPCalendarDay.Festival fest in p.CompleteFestivalList(db.get(i - 1), db.get(i + 1))) { if (GPUserDefaults.BoolForKey(fest.ShowSettingItem, true)) { if (fest.ShowSettingItem == GPDisplays.Keys.CalendarSankranti) { str.AppendLine(GPAppHelper.CenterString(fest.Text, 80, '-')); } else { str.AppendFormat(" {0}", fest.Text); str.AppendLine(); } } } str.AppendLine(); if (GPDisplays.Today.BrahmaMuhurtaVisible()) { str.AppendLine(); str.AppendFormat("{0} {1}", getSharedStringPlain(988), p.astrodata.sun.arunodaya.getShortMuhurtaRange(0)); } if (GPDisplays.Today.SunriseVisible()) { str.AppendLine(); str2 = string.Format("{0} {1} ", getSharedStringPlain(51), p.astrodata.sun.rise.getShortTimeString()); str.Append(str2); if (GPDisplays.Today.SandhyaTimesVisible()) { str.AppendFormat(" {0} {1}", getSharedStringPlain(989), p.astrodata.sun.rise.getShortSandhyaRange()); } str.AppendFormat(" ({0})", GPAppHelper.GetDSTSignature(p.isDaylightInEffect())); str.AppendLine(); } if (GPDisplays.Today.NoonVisible()) { str2 = string.Format("{0} {1} ", getSharedStringPlain(857), p.astrodata.sun.noon.getShortTimeString()); str.Append(str2); if (GPDisplays.Today.SandhyaTimesVisible()) { str.AppendFormat(" {0} {1} ", getSharedStringPlain(989), p.astrodata.sun.noon.getShortSandhyaRange()); } str2 = string.Format(" ({0})", GPAppHelper.GetDSTSignature(p.isDaylightInEffect())); str.Append(str2); str.AppendLine(); } if (GPDisplays.Today.SunsetVisible()) { str2 = string.Format("{0} {1} ", getSharedStringPlain(52), p.astrodata.sun.set.getShortTimeString()); str.Append(str2); if (GPDisplays.Today.SandhyaTimesVisible()) { str.AppendFormat(" {0} {1} ", getSharedStringPlain(989), p.astrodata.sun.set.getShortSandhyaRange()); } str.AppendFormat(" ({0})", GPAppHelper.GetDSTSignature(p.isDaylightInEffect())); str.AppendLine(); } if (GPDisplays.Today.SunriseInfo()) { str.AppendLine(); str.AppendLine(getSharedStringPlain(990)); str.AppendLine(); str.AppendFormat(" {0} {1}", GPNaksatra.getName(p.astrodata.nNaksatra), getSharedStringPlain(15)); if (GPDisplays.Today.NaksatraPadaVisible()) { str.AppendFormat(", {0} {1} ({2})", p.getNaksatraElapsedString(), getSharedStringPlain(993), getSharedStringPlain(811 + p.getNaksatraPada())); } if (GPDisplays.Today.RasiOfMoonVisible()) { str.AppendFormat(", {0}: {1}", getSharedStringPlain(991), GPSankranti.getName(p.astrodata.nMoonRasi), getSharedStringPlain(105)); } str.AppendFormat(", {0} {1}", GPYoga.getName(p.astrodata.nYoga), getSharedStringPlain(104)); str.AppendLine(); str.AppendFormat(" {0}: {1}.", getSharedStringPlain(992), GPSankranti.getName(p.astrodata.nSunRasi)); str.AppendLine(); } AddNoteText(str); }
public GPLocalizedTithi(GPLocationProvider loc, GPGregorianTime start, int nTithi) { p_tithi = nTithi; p_initDate = new GPGregorianTime(start); p_location = loc; }
public void setLocation(GPLocation value) { p_locationProvider = new GPLocationProvider(); p_locationProvider.setDefaultLocation(value); }
public void setLocationProvider(GPLocationProvider value) { p_locationProvider = value; }
public GPGregorianTime(GPLocationProvider loc, GPJulianTime julianTime) { p_locationProvider = loc; setJulianGreenwichTime(julianTime); }
public GPGregorianTime(GPLocationProvider loc) { p_locationProvider = loc; Today(); setDayHours(0.0); }
public static int WriteXML_GaurabdaNextTithi(StringBuilder doc, GPLocationProvider loc, GPGregorianTime vcStart, GPVedicTime vaStart) { int gmasa, gpaksa, gtithi; gmasa = vaStart.masa; gpaksa = vaStart.tithi / 15; gtithi = vaStart.tithi % 15; doc.Append("<xml>\n"); doc.Append("\t<request name=\"Tithi\" version=\"" + GPFileHelper.FileVersion + "\">\n"); doc.Append("\t\t<arg name=\"longitude\" val=\"" + loc.GetLongitudeEastPositive() + "\" />\n"); doc.Append("\t\t<arg name=\"latitude\" val=\"" + loc.GetLatitudeNorthPositive() + "\" />\n"); doc.Append("\t\t<arg name=\"timezone\" val=\"" + loc.getTimeZone().OffsetSeconds / 60 + "\" />\n"); doc.Append("\t\t<arg name=\"start date\" val=\"" + vcStart + "\" />\n"); doc.Append("\t\t<arg name=\"masa\" val=\"" + gmasa + "\" />\n"); doc.Append("\t\t<arg name=\"paksa\" val=\"" + gpaksa + "\" />\n"); doc.Append("\t\t<arg name=\"tithi\" val=\"" + gtithi + "\" />\n"); doc.Append("\t</request>\n"); doc.Append("\t<result name=\"Tithi\">\n"); GPGregorianTime vcs = new GPGregorianTime(loc); GPGregorianTime vce = new GPGregorianTime(loc); GPGregorianTime today = new GPGregorianTime(loc); GPSun sun = new GPSun(); int A; double sunrise; GPAstroData day = new GPAstroData(); int oTithi, oPaksa, oMasa, oYear; today.Copy(vcStart); today.PreviousDay(); vcStart.SubDays(15); for (A = 0; A <= 3; A++) { vcs = GPTithi.CalcTithiEndEx(vcStart, 0, gmasa, gpaksa, gtithi, loc, out vce); if (!vcs.IsBeforeThis(today)) { oTithi = gpaksa * 15 + gtithi; oMasa = gmasa; oPaksa = gpaksa; oYear = 0; doc.Append("\t<celebration\n"); // doc.Append( "\t\t<tithi\n"); doc.Append("\t\trtithi=\"" + GPTithi.getName(oTithi) + "\"\n"); doc.Append("\t\trmasa=\"" + GPMasa.GetName(oMasa) + "\"\n"); doc.Append("\t\trpaksa=\"" + GPPaksa.getName(oPaksa) + "\"\n"); // test ci je ksaya today.Copy(vcs); today.setDayHours(0.5); sun.SunCalc(today, loc); sunrise = sun.getSunriseDayHours(); if (sunrise < vcs.getDayHours()) { today.Copy(vce); sun.SunCalc(today, loc); sunrise = sun.getSunriseDayHours(); if (sunrise < vce.getDayHours()) { // normal type vcs.NextDay(); doc.Append("\t\ttype=\"normal\"\n"); } else { // ksaya vcs.NextDay(); day.calculateDayData(vcs, loc); oTithi = day.nTithi; oPaksa = day.nPaksa; oMasa = day.determineMasa(vcs, out oYear); doc.Append("\t\ttype=\"ksaya\"\n"); } } else { // normal, alebo prvy den vriddhi today.Copy(vce); sun.SunCalc(today, loc); if (sun.getSunriseDayHours() < vce.getDayHours()) { // first day of vriddhi type doc.Append("\t\ttype=\"vriddhi\"\n"); } else { // normal doc.Append("\t\ttype=\"normal\"\n"); } } doc.Append("\t\tdate=\"" + vcs + "\"\n"); doc.Append("\t\totithi=\"" + GPTithi.getName(oTithi) + "\"\n"); doc.Append("\t\tomasa=\"" + GPMasa.GetName(oMasa) + "\"\n"); doc.Append("\t\topaksa=\"" + GPPaksa.getName(oPaksa) + "\"\n"); doc.Append("\t/>\n"); break; } else { vcStart.Copy(vcs); vcs.NextDay(); } } doc.Append("\t</result>\n"); doc.Append("</xml>\n"); return(1); }
public static int WriteXML_GaurabdaTithi(StringBuilder doc, GPLocationProvider loc, GPVedicTime vaStart, GPVedicTime vaEnd) { int gyearA = vaStart.gyear; int gyearB = vaEnd.gyear; int gmasa = vaStart.masa; int gpaksa = vaStart.tithi / 15; int gtithi = vaStart.tithi % 15; if (gyearB < gyearA) { gyearB = gyearA; } doc.Append("<xml>\n"); doc.Append("\t<request name=\"Tithi\" version=\"" + GPFileHelper.FileVersion + "\">\n"); doc.Append("\t\t<arg name=\"longitude\" val=\"" + loc.getLocation(0).GetLongitudeEastPositive() + "\" />\n"); doc.Append("\t\t<arg name=\"latitude\" val=\"" + loc.getLocation(0).GetLatitudeNorthPositive() + "\" />\n"); doc.Append("\t\t<arg name=\"timezone\" val=\"" + loc.getLocation(0).getTimeZone().OffsetSeconds / 60 + "\" />\n"); if (gyearA > 1500) { doc.Append("\t\t<arg name=\"year-start\" val=\"" + gyearA + "\" />\n"); doc.Append("\t\t<arg name=\"year-end\" val=\"" + gyearB + "\" />\n"); } else { doc.Append("\t\t<arg name=\"gaurabdayear-start\" val=\"" + gyearA + "\" />\n"); doc.Append("\t\t<arg name=\"gaurabdayear-end\" val=\"" + gyearB + "\" />\n"); } doc.Append("\t\t<arg name=\"masa\" val=\"" + gmasa + "\" />\n"); doc.Append("\t\t<arg name=\"paksa\" val=\"" + gpaksa + "\" />\n"); doc.Append("\t\t<arg name=\"tithi\" val=\"" + gtithi + "\" />\n"); doc.Append("\t</request>\n"); doc.Append("\t<result name=\"Tithi\">\n"); GPGregorianTime vcs = new GPGregorianTime(loc), vce = new GPGregorianTime(loc), today = new GPGregorianTime(loc); GPSun sun = new GPSun(); int A, B; double sunrise; GPAstroData day = new GPAstroData(); int oTithi, oPaksa, oMasa, oYear; if (gyearA > 1500) { A = gyearA - 1487; B = gyearB - 1485; } else { A = gyearA; B = gyearB; } for (; A <= B; A++) { vcs = GPTithi.CalcTithiEnd(A, gmasa, gpaksa, gtithi, loc, out vce); if (gyearA > 1500) { if ((vcs.getYear() < gyearA) || (vcs.getYear() > gyearB)) { continue; } } oTithi = gpaksa * 15 + gtithi; oMasa = gmasa; oPaksa = gpaksa; oYear = 0; doc.Append("\t<celebration\n"); doc.Append("\t\trtithi=\"" + GPTithi.getName(oTithi) + "\"\n"); doc.Append("\t\trmasa=\"" + GPMasa.GetName(oMasa) + "\"\n"); doc.Append("\t\trpaksa=\"" + GPPaksa.getName(oPaksa) + "\"\n"); // test ci je ksaya today.Copy(vcs); today.setDayHours(0.5); sun.SunCalc(today, loc); sunrise = sun.getSunriseDayHours(); if (sunrise < vcs.getDayHours()) { today.Copy(vce); sun.SunCalc(today, loc); sunrise = sun.getSunriseDayHours(); if (sunrise < vce.getDayHours()) { // normal type vcs.NextDay(); doc.Append("\t\ttype=\"normal\"\n"); } else { // ksaya vcs.NextDay(); day.calculateDayData(vcs, loc); oTithi = day.nTithi; oPaksa = day.nPaksa; oMasa = day.determineMasa(vcs, out oYear); doc.Append("\t\ttype=\"ksaya\"\n"); } } else { // normal, alebo prvy den vriddhi today.Copy(vce); sun.SunCalc(today, loc); if (sun.getSunriseDayHours() < vce.getDayHours()) { // first day of vriddhi type doc.Append("\t\ttype=\"vriddhi\"\n"); } else { // normal doc.Append("\t\ttype=\"normal\"\n"); } } doc.Append("\t\tdate=\"" + vcs + "\"\n"); doc.Append("\t\totithi=\"" + GPTithi.getName(oTithi) + "\"\n"); doc.Append("\t\tomasa=\"" + GPMasa.GetName(oMasa) + "\"\n"); doc.Append("\t\topaksa=\"" + GPPaksa.getName(oPaksa) + "\"\n"); doc.Append("\t/>\n"); // doc.Append( "\t\t</celebration>\n"); } doc.Append("\t</result>\n"); doc.Append("</xml>\n"); return(1); }
public static XmlDocument GetSankrantiXml(GPLocationProvider loc, GPGregorianTime vcStart, GPGregorianTime vcEnd) { XmlDocument doc = new XmlDocument(); XmlElement e1, e2, e3, eday, e5, e6; GPGregorianTime d = new GPGregorianTime(loc); int zodiac; d.Copy(vcStart); e1 = doc.CreateElement("xml"); doc.AppendChild(e1); e2 = doc.CreateElement("request"); e1.AppendChild(e2); e2.SetAttribute("name", "Sankranti"); e2.SetAttribute("version", GPFileHelper.FileVersion); e3 = doc.CreateElement("arg"); e2.AppendChild(e3); e3.SetAttribute("name", "longitude"); e3.SetAttribute("val", loc.GetLongitudeEastPositive().ToString()); e3 = doc.CreateElement("arg"); e2.AppendChild(e3); e3.SetAttribute("name", "latitude"); e3.SetAttribute("val", loc.GetLatitudeNorthPositive().ToString()); e3 = doc.CreateElement("arg"); e2.AppendChild(e3); e3.SetAttribute("name", "timezone"); e3.SetAttribute("val", (loc.getTimeZone().OffsetSeconds / 60).ToString()); e3 = doc.CreateElement("arg"); e2.AppendChild(e3); e3.SetAttribute("name", "startdate"); e3.SetAttribute("val", vcStart.ToString()); e3 = doc.CreateElement("arg"); e2.AppendChild(e3); e3.SetAttribute("name", "enddate"); e3.SetAttribute("val", vcEnd.ToString()); e2 = doc.CreateElement("result"); e1.AppendChild(e2); e2.SetAttribute("name", "SankrantiList"); while (d.IsBeforeThis(vcEnd)) { d = GPSankranti.GetNextSankranti(d, out zodiac); eday = doc.CreateElement("sank"); e2.AppendChild(eday); eday.SetAttribute("date", d.getLongDateString()); eday.SetAttribute("time", d.getLongTimeString()); eday.SetAttribute("dayweekid", d.getDayOfWeek().ToString()); eday.SetAttribute("dayweek", getSharedStringHtml(d.getDayOfWeek())); e5 = doc.CreateElement("zodiac"); eday.AppendChild(e5); e5.SetAttribute("sans", GPSankranti.GetNameSan(zodiac)); e5.SetAttribute("eng", GPSankranti.GetNameEng(zodiac)); e5.SetAttribute("id", zodiac.ToString()); d.NextDay(); d.NextDay(); } return(doc); }