示例#1
0
        public void LocateStarsAreas()
        {
            HabHYGCsvReader reader = new HabHYGCsvReader();

            reader.Load(Path.Combine(TestingUtilities.Config["DataPath"], "HabHYG.csv"));

            double length = 20;

            var records = reader.Catalogue.Where <HabHygRecord>(c => c.Distance < (2 * length / 3.261633));
            IList <HabHygRecord> stars = records.ToList <HabHygRecord>();

            CubeAreaStarLocation areaLocations = new CubeAreaStarLocation();
            IDictionary <string, IList <HabHygRecord> > areaMappings = areaLocations.GetAreaMappings(length, stars);

            string outfile = Path.Combine(TestingUtilities.Config["DataPath"], $"Areas{length}.csv");

            if (File.Exists(outfile))
            {
                File.Delete(outfile);
            }

            using (StreamWriter sw = new StreamWriter(outfile))
            {
                foreach (var area in areaMappings)
                {
                    sw.WriteLine("\"" + area.Key + "\",,");

                    foreach (HabHygRecord rec in area.Value)
                    {
                        sw.Write("\"");
                        sw.Write(rec.DisplayName);
                        sw.Write("\",\"(");
                        sw.Write(rec.Xg);
                        sw.Write(",");
                        sw.Write(rec.Yg);
                        sw.Write(",");
                        sw.Write(rec.Zg);
                        sw.WriteLine(")\",");
                    }
                    sw.WriteLine("");
                }
            }
        }
示例#2
0
        public static void LocateStarsInCube(int ly)
        {
            string outfile       = Path.Combine(dataDir, "AreasForStars_" + ly.ToString() + "LY.txt");
            string catalogueFile = Path.Combine(dataDir, "HabHYG.csv");

            HabHYGCsvReader reader = new HabHYGCsvReader();

            reader.Load(catalogueFile);

            var records = reader.Catalogue.Where <HabHygRecord>(c => c.Distance < ((1.5 * ly) / 3.261633));
            IList <HabHygRecord> stars = records.ToList <HabHygRecord>();

            CubeAreaStarLocation areaLocations = new CubeAreaStarLocation();
            IDictionary <string, IList <HabHygRecord> > areaMappings = areaLocations.GetAreaMappings(ly, stars);

            if (File.Exists(outfile))
            {
                File.Delete(outfile);
            }

            using StreamWriter sw = new StreamWriter(outfile);
            foreach (var area in areaMappings)
            {
                sw.Write("Area ");
                sw.Write(area.Key);
                sw.WriteLine(":");

                foreach (HabHygRecord rec in area.Value)
                {
                    sw.Write(rec.DisplayName);
                    sw.Write(" -- (");
                    sw.Write(rec.Xg);
                    sw.Write(",");
                    sw.Write(rec.Yg);
                    sw.Write(",");
                    sw.Write(rec.Zg);
                    sw.WriteLine(")");
                }
                sw.WriteLine("-------");
            }
        }