The OrbitTools Libraries
NORAD SGP4/SDP4 Implementations in C++ and C#
by
Michael F. Henry

Track Library C# Source Code Example #1
 

//
// This program illustrates how to use the OrbitTools Track Library to
// determine when a satellite is above a local horizon. 
// 
// In this example, the times that the International Space Station is 
// over Seattle during a two-day period are shown.
// 
// Copyright © 2012-2014 Michael F. Henry
// 2014-07-07
//
using System;
using System.Collections.Generic;
using Zeptomoby.OrbitTools;
using Zeptomoby.OrbitTools.Pro;
using Zeptomoby.OrbitTools.Track;

namespace TrackExample1
{
   class Program
   {
      static void Main(string[] args)
      {
         // Create the TLE object, and the corresponding Orbit object
         Tle tle = new Tle(
            "ISS (ZARYA)",
            "1 25544U 98067A   12029.45261574  .00018555  00000-0  24183-3 0  9106",
            "2 25544  51.6405 102.9912 0020420 341.7052 197.0608 15.58534999756228");

         Satellite sat = new Satellite(tle, new Wgs84());

         // Create a Site object for Seattle, Washington, USA
         Site site = new Site(47.61, -122.32, 0.1, new Wgs84());

         // t1 and t2 are used to determine the time window over which
         // to search for satellite passes.
         DateTime t1 = new DateTime(2012, 01, 30, 12, 0, 0); // UTC: 2012-01-30 12:00
         DateTime t2 = t1 + TimeSpan.FromDays(2);

         // CalcPassData() returns a list of PassData objects. Each object in
         // the list represents a single pass of the satellite.
         // Note: CalcPassData() can throw PropagationException exceptions; for 
         // brevity error handling is not shown here.
         IList<PassData> passList = site.CalcPassData(sat, t1, t2, true);

         // Show the calculated passes
         foreach (PassData pass in passList)
         {
            // Each call to ToStringLocal() prints:
            //    The time that the satellite rises above the horizon (AOS), 
            //       and the degrees azimuth;
            //    The time that the satellite obtains its maximum elevation
            //       (MAX) above the horizon, the degrees azimuth, and degrees
            //        elevation;
            //    The time that the satellite sets below the horizon (LOS),
            //       and the degrees azimuth.
            Console.WriteLine(pass.ToStringLocal(sat.Orbit, "PST", "PDT"));
         }

// Program output:
//
// 2012-01-30 04:35:00 PST AOS [AZ 287] 04:40:12 PST MAX [AZ 008 EL 40.9] 04:45:28 PST LOS [AZ 088]
// 2012-01-30 06:11:17 PST AOS [AZ 293] 06:16:35 PST MAX [AZ 207 EL 74.5] 06:21:54 PST LOS [AZ 121]
// 2012-01-30 07:47:46 PST AOS [AZ 284] 07:52:20 PST MAX [AZ 224 EL 13.9] 07:56:54 PST LOS [AZ 165]
// 2012-01-30 22:53:26 PST AOS [AZ 155] 22:55:54 PST MAX [AZ 126 EL  2.5] 22:58:22 PST LOS [AZ 097]
// 2012-01-31 00:26:13 PST AOS [AZ 215] 00:31:09 PST MAX [AZ 142 EL 27.2] 00:36:09 PST LOS [AZ 070]
// 2012-01-31 02:01:58 PST AOS [AZ 255] 02:07:10 PST MAX [AZ 341 EL 63.7] 02:12:28 PST LOS [AZ 067]
// 2012-01-31 03:38:31 PST AOS [AZ 282] 03:43:41 PST MAX [AZ 001 EL 37.7] 03:48:55 PST LOS [AZ 080]
// 2012-01-31 05:14:54 PST AOS [AZ 293] 05:20:12 PST MAX [AZ 020 EL 70.1] 05:25:31 PST LOS [AZ 108]
// 2012-01-31 06:51:11 PST AOS [AZ 289] 06:56:11 PST MAX [AZ 219 EL 24.7] 07:01:12 PST LOS [AZ 148]
// 2012-01-31 08:29:13 PST AOS [AZ 259] 08:31:25 PST MAX [AZ 235 EL  1.8] 08:33:36 PST LOS [AZ 210]
// 2012-01-31 23:30:27 PST AOS [AZ 198] 23:34:58 PST MAX [AZ 136 EL 15.2] 23:39:34 PST LOS [AZ 075]
// 2012-02-01 01:05:33 PST AOS [AZ 242] 01:10:44 PST MAX [AZ 155 EL 83.0] 01:16:02 PST LOS [AZ 067]
// 2012-02-01 02:41:59 PST AOS [AZ 274] 02:47:09 PST MAX [AZ 354 EL 39.4] 02:52:22 PST LOS [AZ 074]
//

      }
   }
}


Return to Track Library Resources

Copyright  © 2012 Michael F. Henry.