public Satellite2 GetSatellite(string satName)
 {
     Satellite2 ret = new Satellite2();
     lock (this._satellites)
     {
         if(this._satellites.ContainsKey(satName))
             ret = this._satellites[satName];
     }
     return ret;
 }
Example #2
0
        private static void WriteFootPrint(Satellite2 s, XmlTextWriter tw)
        {
            //FileStream fs = new FileStream(s.Name + "_footprint.kml", FileMode.Create, FileAccess.Write, FileShare.ReadWrite, 256);
            //XmlTextWriter tw = new XmlTextWriter(fs, Encoding.UTF8);
            //tw.Formatting = Formatting.Indented;
            //tw.WriteStartDocument();
            //tw.WriteStartElement("kml", "http://earth.google.com/kml/2.0");
            //tw.WriteStartElement("Document");

            //WriteLineStyle("GPS", "0000ff", tw);

            #region FootPrint
            tw.WriteStartElement("Folder");//FootPrint
            tw.WriteElementString("name", "Footprint" );
            tw.WriteStartElement("Placemark");
            tw.WriteElementString("name", "Circle");
            tw.WriteElementString("visibility", "0");
            tw.WriteElementString("styleUrl", "#Footprint");
            tw.WriteStartElement("Style");
            tw.WriteStartElement("PolyStyle");
            tw.WriteElementString("fill", "0");
            tw.WriteEndElement(); // PolyStyle
            tw.WriteEndElement(); // Style
            //<Polygon>
            //	<tessellate>1</tessellate>
            //      <outerBoundaryIs>
            //        <LinearRing>
            //          <coordinates>
            //-93.27468332017597,43.31409521513579,999.9999999999999 -102.226768103357,40.4670784747462,999.9999999999999 -105.8163585721755,30.80281111876798,999.9999999999999 -104.358672003192,11.28951605279321,999.9999999999999 -89.29206720375167,1.493575267472583,999.9999999999999 -75.06237971503623,4.668087714474587,999.9999999999999 -73.26460063907996,20.71931469426008,999.9999999999999 -78.38887676947647,35.92964913359087,999.9999999999999 -93.27468332017597,43.31409521513579,999.9999999999999
            //          </coordinates>
            //        </LinearRing>
            //      </outerBoundaryIs>
            //</Polygon>
            tw.WriteStartElement("Polygon");
            //tw.WriteElementString("tesselate", "1");
            tw.WriteStartElement("outerBoundaryIs");
            tw.WriteStartElement("LinearRing");
            tw.WriteStartElement("coordinates");
            foreach (CoordGeo o in s.FootPrint)
            {
                tw.WriteString(o.LonDeg.ToString() + "," + o.LatDeg.ToString() + ",0" + " ");
            }
            tw.WriteEndElement();//coordinates
            tw.WriteEndElement();//LinearRing
            tw.WriteEndElement();//outerBoundaryIs
            tw.WriteEndElement();//Polygon
            tw.WriteEndElement();//Placemark

            #endregion

            #region SubSatellite Point
            //			tw.WriteStartElement("Placemark");
            //			tw.WriteElementString("name", "SubSatellite Point");
            //			//tw.WriteElementString("visibility", "0");
            //			tw.WriteElementString("styleUrl", "#GPS");
            //			tw.WriteStartElement("Point");
            //			tw.WriteElementString("altitudeMode", "absolute");
            //			tw.WriteElementString("coordinates", s.LongitudeDeg.ToString() + "," + s.LatitudeDeg.ToString() + ",0 ");
            //			tw.WriteEndElement();//Point
            //			tw.WriteEndElement();//Placemark
            #endregion

            #region Cone
            tw.WriteStartElement("Placemark");
            tw.WriteElementString("name", "Cone");
            //tw.WriteElementString("visibility", "0");
            tw.WriteElementString("styleUrl", "#Pyramid");
            tw.WriteStartElement("MultiGeometry");
            foreach(CoordGeo p in s.FootPrint)
            {
                tw.WriteStartElement("LineString");
                tw.WriteElementString("altitudeMode", "absolute");
                //tw.WriteElementString("tesselate", "0");
                tw.WriteStartElement("coordinates");
                double meters = s.Position.Altitude.Meters;
                tw.WriteString(p.LonDeg.ToString() + "," + p.LatDeg.ToString() + "," + p.Altitude.Meters.ToString() + " ");
                tw.WriteString(s.Position.LonDeg.ToString() + "," + s.Position.LatDeg.ToString() + "," + meters.ToString() + " ");
                tw.WriteEndElement();//coordinates
                tw.WriteEndElement();//LineString
            }
            tw.WriteEndElement();//MultiGeometry
            tw.WriteEndElement();//PlaceMark
            #endregion

            #region Shadow
            tw.WriteStartElement("Placemark");
            tw.WriteElementString("name", "Shadow");
            //tw.WriteElementString("visibility", "0");
            tw.WriteElementString("styleUrl", "#Pyramid");
            tw.WriteStartElement("MultiGeometry");
            List<CoordGeo> pts = s.FootPrint;
            int last = 0;
            int count = 1;
            for(int i = 4;i<=34;i+=2)//17 is center of hatch
            {

                CoordGeo start = (CoordGeo)pts[i];
                #region Find End Point
                // Will only work for 2PI/72 pts.
                last = 73 - (count*2);
                count++;
                if(last < 0)
                {
                    last = 73 + last;
                }
                CoordGeo end = (CoordGeo)pts[last];
                #endregion
                tw.WriteStartElement("LineString");
                //tw.WriteElementString("altitudeMode", "clampedToGround");//This is default behaviour
                tw.WriteElementString("tessellate", "1");
                tw.WriteStartElement("coordinates");
                tw.WriteString(start.LonDeg.ToString() + "," + start.LatDeg.ToString() + ",0 ");
                tw.WriteString(end.LonDeg.ToString() + "," + end.LatDeg.ToString() + ",0");
                tw.WriteEndElement();//coordinates
                tw.WriteEndElement();//LineString
            }
            tw.WriteEndElement();//MultiGeometry
            tw.WriteEndElement();//PlaceMark
            #endregion

            tw.WriteEndElement();//Folder
        }
        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 #4
0
        private static void WriteSatellite(Satellite2 s, XmlTextWriter tw)
        {
            #region Write Kml File
            //			FileStream fs = new FileStream(s.Name+".kml", FileMode.Create, FileAccess.Write, FileShare.ReadWrite, 256);
            //			XmlTextWriter tw = new XmlTextWriter(fs, Encoding.UTF8);
            //			tw.Formatting = Formatting.Indented;
            //			tw.WriteStartDocument();
            //			tw.WriteStartElement("kml", "http://earth.google.com/kml/2.0");
            //			tw.WriteStartElement("Document");

            //WriteLineStyle("GPS", "0000ff", tw);
            tw.WriteStartElement("Folder");//satellite
            tw.WriteElementString("name", s.Name );
            tw.WriteStartElement("Placemark");
            tw.WriteElementString("name", s.Name);
            tw.WriteElementString("visibility", "1");
            tw.WriteElementString("styleUrl", "#SubSatellite");
            tw.WriteStartElement("Point");
            tw.WriteElementString("extrude", "1");
            tw.WriteElementString("altitudeMode", "absolute");

            CoordGeo p = s.Position;
            tw.WriteElementString("coordinates", p.LonDeg.ToString() + "," + p.LatDeg.ToString() + "," + (p.Altitude.Meters).ToString());
            tw.WriteEndElement();//Point
            tw.WriteEndElement();//Placemark

            WriteFootPrint(s, tw);
            tw.WriteEndElement();//Folder
            #endregion

            //			tw.WriteEndElement();//Document
            //			tw.WriteEndElement();//kml
            //			tw.Flush();
            //			tw.Close();
            //			fs.Close();
        }