예제 #1
0
파일: DeepSkyCalc.cs 프로젝트: t9mike/ADK
        private DeepSkyInfo ReadDeepSkyDetails(SkyContext c, DeepSky ds)
        {
            try
            {
                var details = new DeepSkyInfo();
                using (StreamReader sr = new StreamReader(NGCIC_FILE, Encoding.UTF8))
                {
                    sr.BaseStream.Seek((ds.RecordNumber - 1) * RecordLength, SeekOrigin.Begin);
                    string line = sr.ReadLine();

                    string sb = line.Substring(56, 4).Trim();
                    if (!string.IsNullOrEmpty(sb))
                    {
                        details.SurfaceBrightness = Convert.ToSingle(sb, CultureInfo.InvariantCulture);
                    }

                    string bmag = line.Substring(43, 4).Trim();

                    if (!string.IsNullOrEmpty(bmag))
                    {
                        details.PhotoMagnitude = Convert.ToSingle(bmag, CultureInfo.InvariantCulture);
                    }

                    details.ObjectType = line.Substring(78, 8).Trim();

                    string pgc = line.Substring(86, 8).Trim();

                    if (!string.IsNullOrEmpty(pgc))
                    {
                        details.PGC = Convert.ToInt64(pgc);
                    }

                    List <string> ids = new List <string>();
                    ids.Add(line.Substring(96, 16).Trim());
                    ids.Add(line.Substring(112, 16).Trim());
                    ids.Add(line.Substring(128, 16).Trim());

                    details.Identifiers = ids.Where(id => !string.IsNullOrEmpty(id)).ToArray();
                    details.Remarks     = line.Substring(144).Trim();

                    return(details);
                }
            }
            catch
            {
                return(null);
            }
        }
예제 #2
0
파일: DeepSkyCalc.cs 프로젝트: t9mike/ADK
        public void GetInfo(CelestialObjectInfo <DeepSky> info)
        {
            DeepSky     ds            = info.Body;
            SkyContext  c             = info.Context;
            DeepSkyInfo details       = c.Get(ReadDeepSkyDetails, ds);
            string      constellation = Constellations.FindConstellation(c.Get(Equatorial, ds), c.JulianDay);

            info.SetSubtitle(ds.Status.ToString())
            .SetTitle(string.Join(" / ", ds.Names))
            .AddRow("Constellation", constellation)

            .AddHeader("Equatorial coordinates (current epoch)")
            .AddRow("Equatorial.Alpha", ds.Equatorial.Alpha)
            .AddRow("Equatorial.Delta", ds.Equatorial.Delta)

            .AddHeader("Equatorial coordinates (J2000.0 epoch)")
            .AddRow("Equatorial0.Alpha", ds.Equatorial0.Alpha)
            .AddRow("Equatorial0.Delta", ds.Equatorial0.Delta)

            .AddHeader("Horizontal coordinates")
            .AddRow("Horizontal.Azimuth", ds.Horizontal.Azimuth)
            .AddRow("Horizontal.Altitude", ds.Horizontal.Altitude)

            .AddHeader("Visibility")
            .AddRow("RTS.Rise")
            .AddRow("RTS.Transit")
            .AddRow("RTS.Set")
            .AddRow("RTS.Duration")

            .AddHeader("Properties");

            info.AddRow("DeepSky.Type", details.ObjectType);
            if (ds.Mag != null)
            {
                info.AddRow("VisualMagnitude", ds.Mag, Formatters.Magnitude);
            }
            if (details.PhotoMagnitude != null)
            {
                info.AddRow("PhotoMagnitude", details.PhotoMagnitude, Formatters.Magnitude);
            }
            if (details.SurfaceBrightness != null)
            {
                info.AddRow("Brightness", details.SurfaceBrightness, Formatters.SurfaceBrightness);
            }

            if (ds.SizeA > 0)
            {
                string size = $"{Formatters.AngularDiameter.Format(ds.SizeA / 60)}";
                if (ds.SizeB > 0)
                {
                    size += $" x {Formatters.AngularDiameter.Format(ds.SizeB / 60)}";
                }
                info.AddRow("AngularDiameter", size, Formatters.Simple);
            }
            if (ds.PA > 0)
            {
                info.AddRow("Position angle", ds.PA, Formatters.RotationAxis);
            }

            if (details.Identifiers.Any() || details.PGC != null)
            {
                info.AddHeader("Designations");
                if (details.Identifiers.Any())
                {
                    info.AddRow("Other catalogs identifiers", string.Join(", ", details.Identifiers));
                }
                if (details.PGC != null)
                {
                    info.AddRow("PGC catalog number", string.Join(", ", details.PGC));
                }
            }

            if (!string.IsNullOrEmpty(details.Remarks))
            {
                info.AddRow("Remarks", details.Remarks);
            }
        }
예제 #3
0
        public void GetInfo(CelestialObjectInfo <DeepSky> info)
        {
            DeepSky     ds            = info.Body;
            SkyContext  c             = info.Context;
            DeepSkyInfo details       = c.Get(ReadDeepSkyDetails, ds);
            string      constellation = Constellations.FindConstellation(c.Get(Equatorial, ds), c.JulianDay);

            info
            .SetSubtitle(Text.Get("DeepSky.Status." + ds.Status.ToString()))
            .SetTitle(string.Join(" / ", ds.Names))
            .AddRow("Constellation", constellation)

            .AddHeader(Text.Get("DeepSky.Equatorial"))
            .AddRow("Equatorial.Alpha", ds.Equatorial.Alpha)
            .AddRow("Equatorial.Delta", ds.Equatorial.Delta)

            .AddHeader(Text.Get("DeepSky.Equatorial0"))
            .AddRow("Equatorial0.Alpha", ds.Equatorial0.Alpha)
            .AddRow("Equatorial0.Delta", ds.Equatorial0.Delta)

            .AddHeader(Text.Get("DeepSky.Horizontal"))
            .AddRow("Horizontal.Azimuth", ds.Horizontal.Azimuth)
            .AddRow("Horizontal.Altitude", ds.Horizontal.Altitude)

            .AddHeader(Text.Get("DeepSky.RTS"))
            .AddRow("RTS.Rise")
            .AddRow("RTS.Transit")
            .AddRow("RTS.Set")
            .AddRow("RTS.Duration")

            .AddHeader(Text.Get("DeepSky.Properties"));

            info.AddRow("Type", details.ObjectType);
            if (ds.Mag != null)
            {
                info.AddRow("VisualMagnitude", ds.Mag, Formatters.Magnitude);
            }
            if (details.PhotoMagnitude != null)
            {
                info.AddRow("PhotoMagnitude", details.PhotoMagnitude, Formatters.Magnitude);
            }
            if (details.SurfaceBrightness != null)
            {
                info.AddRow("SurfaceBrightness", details.SurfaceBrightness, new Formatters.SignedDoubleFormatter(2, " mag/sq.arcsec"));
            }

            if (ds.SizeA > 0)
            {
                string size = $"{Formatters.Angle.Format(ds.SizeA / 60)}";
                if (ds.SizeB > 0)
                {
                    size += $" x {Formatters.Angle.Format(ds.SizeB / 60)}";
                }
                info.AddRow("AngularDiameter", size, Formatters.Simple);
            }
            if (ds.PA > 0)
            {
                info.AddRow("PositionAngle", ds.PA, new Formatters.UnsignedDoubleFormatter(2, "\u00B0"));
            }

            if (details.Identifiers.Any() || details.PGC != null)
            {
                info.AddHeader(Text.Get("DeepSky.Designations"));
                if (details.Identifiers.Any())
                {
                    info.AddRow("OtherCatalogsIdentifiers", string.Join(", ", details.Identifiers));
                }
                if (details.PGC != null)
                {
                    info.AddRow("PGCCatalogNumber", string.Join(", ", details.PGC));
                }
            }

            if (!string.IsNullOrEmpty(details.Remarks))
            {
                info.AddRow("Remarks", details.Remarks);
            }
        }