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  2014 Michael F. Henry
// 2014-07-04
//
#include "stdafx.h"

// These header files provide access to the main functionality
// of the OrbitTools software libraries.
#include "coreLib.h"
#include "orbitLib.h"
#include "trackLib.h"

using namespace Zeptomoby::OrbitTools::Track::Pass;

int main(int argc, char* argv[])
{
   // Create a TLE object, and a satellite object
   string line0 = "ISS (ZARYA)";
   string line1 = "1 25544U 98067A   12029.45261574  .00018555  00000-0  24183-3 0  9106";
   string line2 = "2 25544  51.6405 102.9912 0020420 341.7052 197.0608 15.58534999756228";

   cTle tle(line0, line1, line2);
   cSatellite sat(tle, cWgs84::Instance());

   // Create a Site object for Seattle, Washington, USA
   cSite site(47.61, -122.32, 0.1, cWgs84::Instance());

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

   t2.AddDay(2.0);

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

   // Set class cPassData's ToString() method to report times converted
   // to Pacific Time. Without this call, the times would be shown in UTC.
   cPassData::SetTimeZoneInfo("PST+8");

   // Show the calculated passes.
   for (const cPassData& pass : passList)
   {
      // Each call to ToString() 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.
      string info = pass.ToString(sat);
      printf("%s\n", info.c_str());
   }
   
   return 0;

// 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  2014 Michael F. Henry.