/// <summary> /// Returns a List containing solar eclipse data for the century at the specified location. /// Century returned is based on the date passed. /// </summary> /// <param name="lat">latitude</param> /// <param name="longi">longitude</param> /// <param name="date">DateTime</param> /// <returns>List>SolarEclipseDetails></returns> /// <example> /// The following example gets a Solar 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>SolarEclipseDetails> seList = Celestial.Get_Solar_Eclipse_Table(39, -72, new DateTime(1950, 1, 1)); /// /// foreach(SolarEclipseDetails sd in seList) /// { /// Console.WriteLine(sd.Type + " " + sd.Date.ToShortDateString()); /// } /// /// //Partial 8/30/1905 /// //Partial 6/28/1908 /// //Partial 6/18/1909 /// //Partial 4/17/1912 /// //Partial 2/3/1916 /// //Partial 6/7/1918 /// //Partial 11/22/1919 /// ... /// </code> /// </example> public static List <SolarEclipseDetails> Get_Solar_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.SolarData.SolarDateData_100Year(date); //Return list of solar data. return(SolarEclipseCalc.CalculateSolarEclipse(date, latR, longR, events)); }
public static void CalculateSolarEclipse(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 = SolarEclipseCalc.CalculateSolarEclipse(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 = DateTime.ParseExact(values[0], "yyyy-MMM-dd", System.Globalization.CultureInfo.InvariantCulture); 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.SolarEclipse.LastEclipse = new SolarEclipseDetails(se[lastE]); } if (nextE >= 0) { c.SolarEclipse.NextEclipse = new SolarEclipseDetails(se[nextE]); } }