CalculateLunarEclipse() public static method

public static CalculateLunarEclipse ( DateTime d, CoordinateSharp.Coordinate coord ) : List>
d DateTime
coord CoordinateSharp.Coordinate
return List>
Ejemplo n.º 1
0
        /// <summary>
        /// Returns a List containing solar eclipse data for the century at the specified location.
        /// Century return is based on the date passed.
        /// </summary>
        /// <param name="lat">latitude</param>
        /// <param name="longi">longitude</param>
        /// <param name="date">DateTime</param>
        /// <returns>List&gt;LunarEclipseDetails&gt;</returns>
        ///  /// <example>
        /// The following example gets a Lunar Eclipse table for the 20th century at N 39, W 72
        /// and displays each type of eclipse and occurrence date in that century.
        /// <code>
        /// List&gt;LunarEclipseDetails&gt; leList = Celestial.Get_Lunar_Eclipse_Table(39, -72, new DateTime(1950, 1, 1));
        ///
        /// foreach(LunarEclipseDetails ld in leList)
        /// {
        ///	    Console.WriteLine(ld.Type + " " + ld.Date.ToShortDateString());
        /// }
        ///
        /// //Total 10/17/1902
        /// //Partial 4/11/1903
        /// //Penumbral 3/2/1904
        /// //Partial 8/15/1905
        /// //Total 2/9/1906
        /// //Partial 1/29/1907
        /// //Partial 7/25/1907
        /// ...
        /// </code>
        /// </example>
        public static List <LunarEclipseDetails> Get_Lunar_Eclipse_Table(double lat, double longi, DateTime date)
        {
            //Convert to Radians
            double latR  = lat * Math.PI / 180;
            double longR = longi * Math.PI / 180;

            //Get solar data based on date
            double[] events = Eclipse.LunarData.LunarDateData_100Year(date);
            //Return list of solar data.
            return(LunarEclipseCalc.CalculateLunarEclipse(date, latR, longR, events));
        }
        public static void CalculateLunarEclipse(DateTime date, double lat, double longi, Celestial c)
        {
            //Convert to Radian
            double latR              = lat * Math.PI / 180;
            double longR             = longi * Math.PI / 180;
            List <List <string> > se = LunarEclipseCalc.CalculateLunarEclipse(date, latR, longR);

            //RETURN FIRST AND LAST
            if (se.Count == 0)
            {
                return;
            }
            //FIND LAST AND NEXT ECLIPSE
            int      lastE    = -1;
            int      nextE    = -1;
            int      currentE = 0;
            DateTime lastDate = new DateTime();
            DateTime nextDate = new DateTime(3300, 1, 1);

            //Iterate to get last and next eclipse

            foreach (List <string> values in se)
            {
                DateTime ld = Convert.ToDateTime(values[0]);
                if (ld < date && ld > lastDate)
                {
                    lastDate = ld; lastE = currentE;
                }
                if (ld >= date && ld < nextDate)
                {
                    nextDate = ld; nextE = currentE;
                }
                currentE++;
            }
            //SET ECLIPSE DATA
            if (lastE >= 0)
            {
                c.LunarEclipse.LastEclipse = new LunarEclipseDetails(se[lastE]);
            }
            if (nextE >= 0)
            {
                c.LunarEclipse.NextEclipse = new LunarEclipseDetails(se[nextE]);
            }
        }