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

Track Library Source Code Example #2
 

//
//
// This program illustrates how to use the OrbitTools Track Library
// to determine the LAT/LON ground track of a satellite.
// 
// Copyright © 2012 Michael F. Henry
// 2012-12-16
//
using System;
using System.Collections.Generic;
using Zeptomoby.OrbitTools;
using Zeptomoby.OrbitTools.Track;

namespace TrackExample2
{
   class Program
   {
      static void Main(string[] args)
      {
         // Create the TLE object, and the corresponding Orbit object
         Tle tle = new Tle(
           "GPS BIIF-2 (PRN 01)",
           "1 37753U 11036A 12043.26600496 .00000050 00000-0 00000+0 0 1793",
           "2 37753 55.0122 178.4391 0003903 34.9135 325.0832 2.00565114 4219");

         Orbit orbit = new Orbit(tle, new Wgs84());

         // The times t1 and t2 are the start/stop times of the ground track.
         DateTime t1 = new DateTime(2012, 02, 14, 1, 30, 0); // UTC: 2012-02-14 01:30
         DateTime t2 = t1 + orbit.Period;

         // There are several overloads of the GroundTrack() method, to allow:
         // - Specifying times with DateTime objects;
         // - Specifying times with minutes-past-epoch values;
         // - Obtaining LAT/LON points that are equally-spaced in distance;
         // - Obtaining LAT/LON points that are equally-spaced in time.
         // In this example a list of ground track points are created for the
         // time window t1..t2 with a distance spacing of 100 kilometers.
         IList<GeoTime> points = orbit.GroundTrack(t1, t2, 100.0);
         
         Console.WriteLine("Total number of ground track points: {0}", points.Count);

         foreach (GeoTime pt in points)
         {
            double lat = pt.LatitudeDeg;  // negative values = south
            double lon = pt.LongitudeDeg; // negative values = west

            Console.WriteLine("{0:F3}, {1:F3}", lat, lon);
         }

 // Program output:
 //
 // Total number of ground track points: 309
 // -29.767, 215.922
 // -30.633, 216.230
 // -31.489, 216.553
 // -32.341, 216.892
 // -33.188, 217.250
 // ( output truncated... )
 // -26.768, 34.984
 // -27.639, 35.239
 // -28.507, 35.507
 // -29.372, 35.790
 // -29.776, 35.928
 //
      }
   }
}


Back to Track Library Resources

Copyright  © 2012 Michael F. Henry.