Example #1
0
        // ///////////////////////////////////////////////////////////////////
        public Orbit(Tle tle)
        {
            m_NoradModel = null;
            m_tle = tle;
            m_tle.Initialize();

            int epochYear = (int)m_tle.getField(Tle.eField.FLD_EPOCHYEAR);
            double epochDay = m_tle.getField(Tle.eField.FLD_EPOCHDAY);

            if (epochYear < 57)
                epochYear += 2000;
            else
                epochYear += 1900;

            m_jdEpoch = new Julian(epochYear, epochDay);

            m_secPeriod = -1.0;

            // Recover the original mean motion and semimajor axis from the
            // input elements.
            double mm = mnMotion();
            double rpmin = mm * 2 * Globals.PI / Globals.MIN_PER_DAY;   // rads per minute

            double a1 = Math.Pow(Globals.XKE / rpmin, Globals.TWOTHRD);
            double e = Eccentricity();
            double i = Inclination();
            double temp = (1.5 * Globals.CK2 * (3.0 * Globals.Sqr(Math.Cos(i)) - 1.0) /
                            Math.Pow(1.0 - e * e, 1.5));
            double delta1 = temp / (a1 * a1);
            double a0 = a1 *
                           (1.0 - delta1 *
                           ((1.0 / 3.0) + delta1 *
                           (1.0 + 134.0 / 81.0 * delta1)));

            double delta0 = temp / (a0 * a0);

            m_mnMotionRec = rpmin / (1.0 + delta0);
            m_aeAxisSemiMinorRec = a0 / (1.0 - delta0);
            m_aeAxisSemiMajorRec = m_aeAxisSemiMinorRec / Math.Sqrt(1.0 - (e * e));
            m_kmPerigeeRec = Globals.XKMPER * (m_aeAxisSemiMinorRec * (1.0 - e) - Globals.AE);

            if (2.0 * Globals.PI / m_mnMotionRec >= 225.0)
            {
                // SDP4 : period >= 225 minutes.
                m_NoradModel = new NoradSDP4(this);
            }
            else
            {
                // SGP4 : period < 225 minutes
                m_NoradModel = new NoradSGP4(this);
            }
        }
		public SatelliteTrack( string meshFilePath, OrbitTools.Tle tle ) : base(tle.Name)
		{
			this.meshFilePath = meshFilePath;
			this.RenderPriority = RenderPriority.Icons;
			this.TwoLineElement = tle;
			LayerName = this.TwoLineElement.Name;
			m_orbitColor = Color.FromArgb(m_opacity,255,255,22).ToArgb();
		}
		// //////////////////////////////////////////////////////////////////////////
		public Tle(Tle tle) :
			this(tle.Name, tle.Line1, tle.Line2)
		{
		}
		// ///////////////////////////////////////////////////////////////////
		protected double degGet(Tle.Field fld)
		{
			return m_tle.getField(fld, Tle.Unit.Degrees);
		}
		// ///////////////////////////////////////////////////////////////////
		protected double radGet(Tle.Field fld)
		{
			return m_tle.getField(fld, Tle.Unit.Radians);
		}
		// ///////////////////////////////////////////////////////////////////
		public Orbit(Tle tle)
		{
			m_NoradModel = null;
			m_tle        = tle;
			m_jdEpoch    = m_tle.EpochJulian;
			m_secPeriod  = -1.0;

			// Recover the original mean motion and semimajor axis from the
			// input elements.
			double mm     = mnMotion;
			double rpmin  = mm * 2 * Globals.PI / Globals.MIN_PER_DAY;   // rads per minute

			double a1     = Math.Pow(Globals.XKE / rpmin, Globals.TWOTHRD);
			double e      = Eccentricity;
			double i      = Inclination;
			double temp   = (1.5 * Globals.CK2 * (3.0 * Globals.Sqr(Math.Cos(i)) - 1.0) /
				Math.Pow(1.0 - e * e, 1.5));
			double delta1 = temp / (a1 * a1);
			double a0     = a1 *
				(1.0 - delta1 *
				((1.0 / 3.0) + delta1 *
				(1.0 + 134.0 / 81.0 * delta1)));

			double delta0 = temp / (a0 * a0);

			m_mnMotionRec        = rpmin / (1.0 + delta0);
			m_aeAxisSemiMinorRec = a0 / (1.0 - delta0);
			m_aeAxisSemiMajorRec = m_aeAxisSemiMinorRec / Math.Sqrt(1.0 - (e * e));
			m_kmPerigeeRec       = Globals.XKMPER * (m_aeAxisSemiMajorRec * (1.0 - e) - Globals.AE);
			m_kmApogeeRec        = Globals.XKMPER * (m_aeAxisSemiMajorRec * (1.0 + e) - Globals.AE);

			if (2.0 * Globals.PI / m_mnMotionRec >= 225.0)
			{
				// SDP4 - period >= 225 minutes.
				m_NoradModel = new NoradSDP4(this);
			}
			else
			{
				// SGP4 - period < 225 minutes
				m_NoradModel = new NoradSGP4(this);
			}
		}
		/// <summary>
		/// Returns an array of satellite Tles from the input URL
		/// </summary>
		/// <param name="url"></param>
		/// <returns></returns>
		public ArrayList GetFromWeb(string url )
		{
			string line1=null,line2=null;
			bool useLocalFile = false;
			ArrayList satTles = new ArrayList();
			string saveto =Path.Combine( this.Plugin.PluginDirectory,this.Name +".txt");
			//Get the TLE data
			using( WebDownload dl = new WebDownload(url) )
			{
				try
				{
					dl.DownloadMemory();
					dl.SaveMemoryDownloadToFile(saveto);
				}
				catch(System.Net.WebException)
				{
					useLocalFile = true;
				}
				if(useLocalFile)
					using(TextReader tr = new StreamReader( saveto ))
					{
						string[] line = tr.ReadToEnd().Split('\n');
						string NumFormat = GetNumberFormat(line);
						for(int i=0;i<line.Length-1-2;i = i + 3)
						{
							if(line[i].Trim().Length == 0)
								break;
							line1 = line[i+1].Trim();
							line2 = line[i+2].Trim();
							Tle tle = new Tle(FormatTrailingNumber(line[i].Trim(), NumFormat), line1, line2);
							satTles.Add(tle);
						}
					}
				else
					using(TextReader tr = new StreamReader( dl.ContentStream ))
					{
						string[] line = tr.ReadToEnd().Split('\n');
						string NumFormat = GetNumberFormat(line);
						for(int i=0;i<line.Length-1-2;i = i + 3)
						{
							if(line[i].Trim().Length == 0)
								break;
							line1 = line[i+1].Trim();
							line2 = line[i+2].Trim();
							Tle tle = new Tle(FormatTrailingNumber(line[i].Trim(), NumFormat), line1, line2);
							satTles.Add(tle);
						}
					}
			}
			return satTles;
		}
Example #8
0
 // ///////////////////////////////////////////////////////////////////
 protected double radGet(Tle.eField fld)
 {
     string strTemp = null;
     return m_tle.getField(fld, Tle.eUnits.U_RAD, ref strTemp, false);
 }
        private Dictionary<string, Satellite2> Parse(string tles)
        {
            Dictionary<string, Satellite2> ret = new Dictionary<string, Satellite2>();

            StringReader sr = new StringReader(tles);
            try
            {
                while (true)
                {
                    string s1 = sr.ReadLine();
                    if (s1 == null)
                        break;
                    string s2 = sr.ReadLine();
                    if (s2 == null)
                        break;
                    string s3 = sr.ReadLine();
                    if (s3 == null)
                        break;

                    Tle tle = new Tle(s1, s2, s3);

                    //if (tle.getName().Contains("BIIA-22"))
                    //{
                        Satellite2 st = new Satellite2(tle);
                        ret.Add(st.NameNumber, st);
                    //}

                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                //return new Dictionary<string, Satellite2>();
            }

            return ret;
        }
Example #10
0
 public Satellite2(Tle tle)
     : this()
 {
     this._orbit = new Orbit(tle);
 }
Example #11
0
        // //////////////////////////////////////////////////////////////////////////
        public Tle(Tle tle)
        {
            m_strName = tle.m_strName;
            m_strLine1 = tle.m_strLine1;
            m_strLine2 = tle.m_strLine2;

            Initialize();
        }