コード例 #1
0
        public static GCHourTime CalcSunrise(GregorianDateTime vct, GCEarthData earth)
        {
            double    tempSunrise = 180.0;
            GCSunData sun         = new GCSunData();

            for (int i = 0; i < 3; i++)
            {
                sun.SunPosition(vct, earth, tempSunrise - 180.0);

                double x;
                // definition of event
                double eventdef = 0.01454;

                /*	switch(ed.obs)
                 *  {
                 *  case 1:	// civil twilight
                 *      eventdef = 0.10453;
                 *      break;
                 *  case 2:	// nautical twilight
                 *      eventdef = 0.20791;
                 *      break;
                 *  case 3:	// astronomical twilight
                 *      eventdef = 0.30902;
                 *      break;
                 *  default:// center of the sun on the horizont
                 *      eventdef = 0.01454;
                 *      break;
                 *  }*/

                eventdef = (eventdef / GCMath.cosDeg(earth.latitudeDeg)) / GCMath.cosDeg(sun.declinationDeg);

                x = GCMath.tanDeg(earth.latitudeDeg) * GCMath.tanDeg(sun.declinationDeg) + eventdef;

                if ((x >= -1.0) && (x <= 1.0))
                {
                    // time of sunrise
                    tempSunrise = 90.0 - earth.longitudeDeg - GCMath.arcSinDeg(x) + sun.equationOfTime;
                }
                else
                {
                    // initial values for the case
                    // that no rise no set for that day
                    tempSunrise = -360.0;
                    break;
                }
            }

            GCHourTime result = new GCHourTime();

            result.longitude = sun.longitudeDeg;
            result.SetDegTime(tempSunrise + earth.OffsetUtcHours * 15.0);
            return(result);
        }
コード例 #2
0
        public static GCHourTime CalcSunset(GregorianDateTime vct, GCEarthData earth)
        {
            double    tempSunset = 180.0;
            GCSunData sun        = new GCSunData();

            for (int i = 0; i < 3; i++)
            {
                sun.SunPosition(vct, earth, tempSunset - 180.0);

                double x;
                // definition of event
                double eventdef = GCSunData.RiseAngleLevel;

                eventdef = (eventdef / GCMath.cosDeg(earth.latitudeDeg)) / GCMath.cosDeg(sun.declinationDeg);

                x = GCMath.tanDeg(earth.latitudeDeg) * GCMath.tanDeg(sun.declinationDeg) + eventdef;


                if ((x >= -1.0) && (x <= 1.0))
                {
                    // time of sunset
                    tempSunset = 270.0 - earth.longitudeDeg + GCMath.arcSinDeg(x) + sun.equationOfTime;
                }
                else
                {
                    // initial values for the case
                    // that no rise no set for that day
                    tempSunset = -360.0;
                    break;
                }
            }

            GCHourTime result = new GCHourTime();

            result.longitude = sun.longitudeDeg;
            result.SetDegTime(tempSunset + earth.OffsetUtcHours * 15.0);
            return(result);
        }
コード例 #3
0
        public static int writeXml(string fileName, GCLocation loc, GregorianDateTime vc)
        {
            String            str;
            GregorianDateTime date;

            using (StreamWriter xml = new StreamWriter(fileName))
            {
                xml.Write("<xml>\n");
                xml.Write("\t<request name=\"Tithi\" version=\"");
                xml.Write(GCStrings.getString(130));
                xml.Write("\">\n");
                xml.Write("\t\t<arg name=\"longitude\" val=\"");
                xml.Write(loc.Longitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"latitude\" val=\"");
                xml.Write(loc.Latitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"timezone\" val=\"");
                xml.Write(loc.OffsetUtcHours);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"startdate\" val=\"");
                xml.Write(vc);
                xml.Write("\" />\n");
                xml.Write("\t</request>\n");
                xml.Write("\t<result name=\"Tithi\">\n");

                GregorianDateTime d = new GregorianDateTime();
                d.Set(vc);
                GregorianDateTime d1, d2;
                d.TimezoneHours = loc.OffsetUtcHours;
                GregorianDateTime dn;
                GCHourTime        dt    = new GCHourTime();
                GCEarthData       earth = loc.GetEarthData();


                GCAstroData day = new GCAstroData();

                day.DayCalc(vc, earth);

                d.shour = day.sunRise.TotalDays;

                GCTithi.GetPrevTithiStart(earth, d, out d1);
                GCTithi.GetNextTithiStart(earth, d, out d2);

                {
                    dt.SetDegTime(d1.shour * 360);
                    // start tithi at t[0]
                    xml.Write("\t\t<tithi\n\t\t\tid=\"");
                    xml.Write(day.sunRise.Tithi);
                    xml.Write("\"\n");
                    xml.Write("\t\t\tname=\"");
                    xml.Write(GCTithi.GetName(day.sunRise.Tithi));
                    xml.Write("\"\n");
                    xml.Write("\t\t\tstartdate=\"");
                    xml.Write(d1);
                    xml.Write("\"\n");
                    xml.Write("\t\t\tstarttime=\"");
                    xml.Write(dt);
                    xml.Write("\"\n");

                    dt.SetDegTime(d2.shour * 360);
                    xml.Write("\t\t\tenddate=\"");
                    xml.Write(d2);
                    xml.Write("\"\n");
                    xml.Write("\t\t\tendtime=\"");
                    xml.Write(dt);
                    xml.Write("\"\n />");
                }

                xml.Write("\t</result>\n");
                xml.Write("</xml>\n");
            }
            return(1);
        }
コード例 #4
0
ファイル: GCNaksatra.cs プロジェクト: icfsoft/GCAL-NET-Core
        public static int writeXml(string fileName, GCLocation loc, GregorianDateTime vc, int nDaysCount)
        {
            using (StreamWriter xml = new StreamWriter(fileName))
            {
                xml.Write("<xml>\n");
                xml.Write("\t<request name=\"Naksatra\" version=\"");
                xml.Write(GCStrings.getString(130));
                xml.Write("\">\n");
                xml.Write("\t\t<arg name=\"longitude\" val=\"");
                xml.Write(loc.Longitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"latitude\" val=\"");
                xml.Write(loc.Latitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"timezone\" val=\"");
                xml.Write(loc.OffsetUtcHours);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"startdate\" val=\"");
                xml.Write(vc);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"daycount\" val=\"");
                xml.Write(nDaysCount);
                xml.Write("\" />\n");
                xml.Write("\t</request>\n");
                xml.Write("\t<result name=\"Naksatra\">\n");

                GregorianDateTime d = new GregorianDateTime();
                d.Set(vc);
                d.TimezoneHours = loc.OffsetUtcHours;
                GregorianDateTime dn;
                GCHourTime        dt = new GCHourTime();
                int         nak;
                GCEarthData earth = loc.GetEarthData();

                for (int i = 0; i < 30; i++)
                {
                    nak = GCNaksatra.GetNextNaksatra(earth, d, out dn);
                    d.Set(dn);
                    xml.Write("\t\t<day date=\"");
                    xml.Write(d);
                    xml.Write("\">\n");
                    //str.Format("%d.%d.%d", d.day, d.month, d.year);
                    //n = m_list.InsertItem(50, GetNaksatraName(nak));
                    //m_list.SetItemText(n, 1, str);
                    xml.Write("\t\t\t<naksatra id=\"");
                    xml.Write(nak);
                    xml.Write("\" name=\"");
                    xml.Write(GCNaksatra.GetName(nak));
                    xml.Write("\"\n");
                    dt.SetDegTime(d.shour * 360);
                    //time_print(str, dt);
                    xml.Write("\t\t\t\tstarttime=\"");
                    xml.Write(dt);
                    xml.Write("\" />\n");
                    //m_list.SetItemText(n, 2, str);

                    //time_print(str, sun.rise);
                    //m_list.SetItemText(n, 3, str);
                    xml.Write("\t\t\t<sunrise time=\"");
                    xml.Write(GCSunData.CalcSunrise(d, earth));
                    xml.Write("\" />\n");

                    xml.Write("\t\t</day>\n");
                    // increment for non-duplication of naksatra
                    d.Set(dn);
                    d.shour += 1.0 / 8.0;
                }


                xml.Write("\t</result>\n");
                xml.Write("</xml>\n");
            }

            return(1);
        }