public SolarEclipseCitiesListTableItem(SolarEclipseLocalCircumstances local, string visibility)
        {
            Location = local.Location;

            const string empty = "—";

            LocationName      = local.Location.LocationName;
            Coordinates       = local.Location;
            CoordinatesString = Format.Geo.Format(local.Location);

            double offset = local.Location.UtcOffset;
            string tz     = local.Location.UtcOffset != 0 ? $"UTC{(offset < 0 ? "-" : "+")}{TimeSpan.FromHours(offset):h\\:mm}" : "UTC";

            TimeZone       = offset;
            TimeZoneString = tz;

            MaxMagString = local.MaxMagnitude > 0 ? Format.Mag.Format(local.MaxMagnitude) : empty;
            MaxMag       = local.MaxMagnitude;

            MoonSunRatioString = local.MoonToSunDiameterRatio > 0 ? Format.Ratio.Format(local.MoonToSunDiameterRatio) : empty;
            MoonSunRatio       = local.MoonToSunDiameterRatio;

            PartialDurString = local.PartialDuration > 0 ? Format.Time.Format(local.PartialDuration) : empty;
            PartialDur       = local.PartialDuration;

            TotalDurString = local.TotalDuration > 0 ? Format.Time.Format(local.TotalDuration) : empty;
            TotalDur       = local.TotalDuration;

            ShadowWidthString = local.PathWidth > 0 ? Format.PathWidth.Format(local.PathWidth) : empty;
            ShadowWidth       = local.PathWidth;

            C1TimeString = local.PartialBegin != null ? $"{Format.Time.Format(new Date(local.PartialBegin.JulianDay, offset))}" : empty;
            C1Time       = local.PartialBegin?.JulianDay;

            C2TimeString = local.TotalBegin != null ? $"{Format.Time.Format(new Date(local.TotalBegin.JulianDay, offset))}" : empty;
            C2Time       = local.TotalBegin?.JulianDay;

            MaxTimeString = local.Maximum?.JulianDay != null ? $"{Format.Time.Format(new Date(local.Maximum.JulianDay, offset))}" : empty;
            MaxTime       = local.Maximum?.JulianDay;

            C3TimeString = local.TotalEnd != null ? $"{Format.Time.Format(new Date(local.TotalEnd.JulianDay, offset))}" : empty;
            C3Time       = local.TotalEnd?.JulianDay;

            C4TimeString = local.PartialEnd != null ? $"{Format.Time.Format(new Date(local.PartialEnd.JulianDay, offset)) }" : empty;
            C4Time       = local.PartialEnd?.JulianDay;

            Visibility = visibility;
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public string GetLocalVisibilityString(SolarEclipse eclipse, SolarEclipseLocalCircumstances localCirc)
        {
            string localVisibility = Text.Get("SolarEclipse.LocalVisibility.Invisible");

            if (localCirc.MaxMagnitude > 0)
            {
                string localMag  = Formatters.Phase.Format(localCirc.MaxMagnitude);
                string asPartial = eclipse.EclipseType != SolarEclipseType.Partial ? $" {Text.Get("SolarEclipse.LocalVisibility.AsPartial")}" : "";

                // max instant not visible
                if (localCirc.Maximum.SolarAltitude <= 0)
                {
                    if ((localCirc.TotalEnd != null && localCirc.TotalEnd.SolarAltitude < 0) || localCirc.PartialEnd.SolarAltitude < 0)
                    {
                        localVisibility = Text.Get("SolarEclipse.LocalVisibility.VisibleOnSunset", ("asPartial", asPartial), ("localMag", localMag));
                    }
                    else if (localCirc.PartialBegin.SolarAltitude < 0 || (localCirc.TotalBegin != null && localCirc.TotalBegin.SolarAltitude < 0))
                    {
                        localVisibility = Text.Get("SolarEclipse.LocalVisibility.VisibleOnSunrise", ("asPartial", asPartial), ("localMag", localMag));
                    }
                }
                // max instant visible
                else
                {
                    if (localCirc.TotalDuration > 0)
                    {
                        localVisibility = Text.Get("SolarEclipse.LocalVisibility.VisibleTotally");
                    }
                    else
                    {
                        localVisibility = Text.Get("SolarEclipse.LocalVisibility.Visible", ("asPartial", asPartial), ("localMag", localMag));
                    }
                }
            }

            return(localVisibility);
        }