Example #1
0
        public static string FormatDayLength(SolarTimes st, SolarPosition sp)
        {
            DateTime? begin = null, end = null;
            if (st.Sunrise != null) {
                begin = st.Sunrise.Value.ExtractLocal();
            }
            if (st.Sunset != null) {
                end = st.Sunset.Value.ExtractLocal();
            }

            double diff = 0;
            if ((begin != null) && (end != null)) {
                diff = (end.Value - begin.Value).TotalSeconds;
            }

            double fullday = 24*3600;
            int h = (int) (diff / 3600.0);
            int m = (int) ((diff - h * 3600.0) / 60.0);
            // can be all day or all night
            if ((diff >= fullday) && (sp.Elevation < 0)) {
                h = 0;
            } else if ((diff == 0) && (sp.Elevation >= 0)) {
                h = 24;
            }
            return string.Format("{0}h {1}m", h, m);
        }
Example #2
0
        public static void Print(SolarPosition sp, SolarTimes sns)
        {
            string template = "{0,-12} : {1}\n";

            string s = String.Empty;
            s += sp.Print(template, true);
            s += "\n";
            s += sns.Print(template, false);
            Console.WriteLine(s);
        }
Example #3
0
        public CaptionInfo(string loc, Position pos, UTCDate udt)
        {
            this.loc = loc;
            this.pos = pos;
            this.dst = udt.GetDST();
            this.udt = udt;
            this.sp = Orbit.CalcSolarPosition(pos, udt);
            this.st = Orbit.CalcSolarTimes(pos, udt);

            SolarTimes st_ss = PointFinder.FindDawnDusk(pos, udt);
            this.dawn = st_ss.Sunrise;
            this.dusk = st_ss.Sunset;
        }