/// <summary>
        /// Tries to download from AGI's server a list of TLEs describing the satellite which has the given string
        /// NORAD identifier for the 24 hour period following the given date.  If AGI's server is unavailable
        /// (i.e. if the machine on which the demo is running is not connected to the internet),
        /// pulls the list of TLEs from the local Data directory.
        /// </summary>
        public static List <TwoLineElementSet> GetTles(string satelliteIdentifier, JulianDate date)
        {
            try
            {
                return(TwoLineElementSet.DownloadTles(satelliteIdentifier, date, date.AddDays(1.0)));
            }
            catch (DataUnavailableException)
            {
                // Read from local data if the machine does not have access to the internet.
                string dataPath          = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.RelativeSearchPath ?? "", "Data");
                var    satelliteDatabase = new StkSatelliteDatabase(Path.Combine(dataPath, "SatelliteDatabase"), "stkSatDb");
                var    query             = new StkSatelliteDatabaseQuery
                {
                    SatelliteNumber = new Regex(satelliteIdentifier)
                };

                foreach (var entry in satelliteDatabase.GetEntries(query))
                {
                    return(new List <TwoLineElementSet> {
                        entry.TwoLineElementSet
                    });
                }

                throw new DataUnavailableException("TLE data for " + satelliteIdentifier + " could not be found in local SatelliteDatabase");
            }
        }
        /// <summary>
        /// Load TLEs from a satellite database and create marker primitives for each satellite
        /// </summary>
        private void CreateSatellites(string fileName)
        {
            m_satellites.Clear();

            JulianDate?epoch = null;

            StkSatelliteDatabase db = new StkSatelliteDatabase(GetDataFilePath("SatelliteDatabase"), fileName);

            foreach (StkSatelliteDatabaseEntry entry in db.GetEntries())
            {
                if (entry.TwoLineElementSet != null)
                {
                    Sgp4Propagator propagator = new Sgp4Propagator(entry.TwoLineElementSet);

                    if (epoch == null)
                    {
                        epoch = propagator.InitialConditions.Epoch;
                    }

                    Duration epochDifference = epoch.Value - propagator.InitialConditions.Epoch;
                    if (epochDifference < Duration.FromDays(1))
                    {
                        m_satellites.Add(propagator.GetEvaluator(), entry.TwoLineElementSet.Epoch);
                    }
                }
            }

            SetText(m_satellites.Count);

            JulianDate time = epoch.Value.ToTimeStandard(TimeStandard.InternationalAtomicTime);

            // Set epoch time
            m_animation.Pause();
            m_animation.StartTime = time;
            m_animation.EndTime   = time.AddDays(1.0);
            m_animation.Time      = time;
            m_animation.PlayForward();
        }