static void Main(string[] args) { Location location = new Location(DateTime.Now, 52.015, 4.356667); Database database = new Database("..\\..\\..\\hygfull.csv"); double maxMag = 4.5; Plot plot = new Plot(1600, 900,30, 30, maxMag); try { while (true) { Star s = database.getStar(location); if (s.isVisible(maxMag)) { plot.addStar(s.x, s.y, s.mag); } } } catch (NoMoreRecordException) { plot.draw(); } }
/// <summary> /// This method initializes the star object and saves the ra, dec and mag values. /// </summary> /// <param name="ra">Right ascension in hours</param> /// <param name="dec">Declination in degrees</param> /// <param name="mag">Magnitude in degrees</param> public Star(double ra, double dec, double mag, Location loc) { this.ra = ra * 15; this.dec = dec; this.mag = mag; this.location = loc; }
/// <summary> /// This method gets the next star in the csv file. If there are no more records left an exception is thrown. /// </summary> /// <param name="location"></param> /// <returns>Star object</returns> public Star getStar(Location location) { string line = file.ReadLine(); if (line == null) { this.file.Close(); throw new NoMoreRecordException(); } NumberStyles styles; styles = NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign; string[] fields = line.Split(','); string name = fields[6]; double ra = double.Parse(fields[7], styles); double dec = double.Parse(fields[8], styles); double mag = double.Parse(fields[10], styles); Star s = new Star(ra, dec, mag, location); return s; }