Пример #1
0
        public static void setMyLocation(GPLocationProvider value)
        {
            if (value != null)
            {
                myLocation = value;

                GPUserDefaults.SetStringForKey("myloc.city", value.getCity());
                GPUserDefaults.SetStringForKey("myloc.country", value.getLocation(0).getCountryCode());
                GPUserDefaults.SetStringForKey("myloc.lat", value.GetLatitudeNorthPositive().ToString());
                GPUserDefaults.SetStringForKey("myloc.lon", value.GetLongitudeEastPositive().ToString());
                GPUserDefaults.SetStringForKey("myloc.tzname", value.getLocation(0).getTimeZoneName());
            }
        }
Пример #2
0
        public static int WriteXML_Naksatra(StringBuilder doc, GPLocationProvider loc, GPGregorianTime vc, int nDaysCount)
        {
            doc.Append("<xml>\n");
            doc.Append("\t<request name=\"Naksatra\" 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=\"startdate\" val=\"" + vc + "\" />\n");
            doc.Append("\t\t<arg name=\"daycount\" val=\"" + nDaysCount + "\" />\n");
            doc.Append("\t</request>\n");
            doc.Append("\t<result name=\"Naksatra\">\n");

            GPGregorianTime d   = new GPGregorianTime(vc);
            GPGregorianTime dn  = new GPGregorianTime(loc);
            GPSun           sun = new GPSun();
            int             nak;

            for (int i = 0; i < 30; i++)
            {
                nak = GPNaksatra.GetNextNaksatra(d, out dn);
                d.Copy(dn);
                doc.Append("\t\t<day date=\"" + d + "\">\n");
                //str = string.Format("{}.{}.{}", d.day, d.month, d.year);
                //n = m_list.InsertItem(50, GPNaksatra.GetName(nak));
                //m_list.SetItemText(n, 1, str);
                doc.Append("\t\t\t<naksatra id=\"" + nak + "\" name=\"" + GPNaksatra.getName(nak) + "\"\n");
                //dt.SetDegTime(d.getDayHours() * 360);
                //time_print(str, dt);
                doc.Append("\t\t\t\tstarttime=\"" + d.getShortTimeString() + "\" />\n");
                //m_list.SetItemText(n, 2, str);

                // sunrise time get
                sun.SunCalc(d, loc);
                //time_print(str, sun.rise);
                //m_list.SetItemText(n, 3, str);
                doc.Append("\t\t\t<sunrise time=\"" + sun.rise + "\" />\n");

                doc.Append("\t\t</day>\n");
                // increment for non-duplication of naksatra
                d.Copy(dn);
                d.setDayHours(d.getDayHours() + 1.0 / 8.0);
            }


            doc.Append("\t</result>\n");
            doc.Append("</xml>\n");


            return(1);
        }
Пример #3
0
        private void calculateRiseSetMethodM(double D, GPLocationProvider ed)
        {
            GPLocation obs = ed.getLocation(D);
            double     a1, a2, a3;
            double     d1, d2, d3;
            double     siderealTime = GPAstroEngine.GetSiderealTime(D);
            double     h0           = -0.833333;

            calculateCoordinatesMethodM(D - 1);
            a1 = rightAscession;
            d1 = declination;
            calculateCoordinatesMethodM(D);
            a2 = rightAscession;
            d2 = declination;
            calculateCoordinatesMethodM(D + 1);
            a3 = rightAscession;
            d3 = declination;
            double longitude = -ed.GetLongitudeEastPositive();
            double latitude  = ed.GetLatitudeNorthPositive();
            double cosH0     = (GPMath.sinDeg(h0) - GPMath.sinDeg(latitude) * GPMath.sinDeg(d2))
                               / (GPMath.cosDeg(latitude) * GPMath.cosDeg(d2));
            double H0 = GPMath.arccosDeg(cosH0);

            H0 = GPMath.putIn180(H0);

            double m0     = (a2 + longitude - siderealTime) / 360;
            double m1     = m0 - H0 / 360;
            double m2     = m0 + H0 / 360;
            double deltaM = 0;

            deltaM = getCorrection(D, a1, a2, a3, d1, d2, d3, siderealTime, h0, longitude, latitude, m0, true);
            m0    += deltaM;
            deltaM = getCorrection(D, a1, a2, a3, d1, d2, d3, siderealTime, h0, longitude, latitude, m1, false);
            m1    += deltaM;
            deltaM = getCorrection(D, a1, a2, a3, d1, d2, d3, siderealTime, h0, longitude, latitude, m2, false);
            m2    += deltaM;

            julianDayRise = julianDay + m1;
            julianDayNoon = julianDay + m0;
            julianDaySet  = julianDay + m2;

            sunrise_deg = GPMath.putIn360(m1 * 360);
            noon_deg    = GPMath.putIn360(m0 * 360);
            sunset_deg  = GPMath.putIn360(m2 * 360);
        }
Пример #4
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);
        }
Пример #5
0
        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);
        }