Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Time time = new Time(this.dateTimePicker1.Value);

            MoonPosition moon    = new MoonPosition();
            XYZ          moonPos = moon.GetPosition(time);

            moonGeo = CoordTransformer.XyzToGeoCoord(moonPos);

            StringBuilder moonSb = new StringBuilder();

            moonSb.AppendLine("XYZ:" + moonPos.ToString());
            moonSb.AppendLine("GeoCoord:" + moonGeo.ToString());
            this.textBox_moon.Text = moonSb.ToString();


            SunPosition sun    = new SunPosition();
            XYZ         sunPos = sun.GetPosition(time);

            sunGeo = CoordTransformer.XyzToGeoCoord(sunPos);

            StringBuilder sunSb = new StringBuilder();

            sunSb.AppendLine("XYZ:" + sunPos.ToString());
            sunSb.AppendLine("GeoCoord:" + sunGeo.ToString());
            this.textBox_sun.Text = sunSb.ToString();
        }
Exemplo n.º 2
0
 /// <summary>
 /// 获取指定时刻太阳的位置。
 /// </summary>
 /// <param name="Time">时间</param>
 /// <returns></returns>
 public XYZ GetSunPosition(Time Time)
 {
     return(sunPosition.GetPosition(Time));
 }
Exemplo n.º 3
0
        /// <summary>
        /// EclipsedSatFilter核心
        /// </summary>
        /// <param name="gData"></param>
        /// <returns></returns>
        public override bool Revise(ref EpochInformation gData)
        {
            //   Time epoch = gData.CorrectedTime;
            Time epoch = gData.ReceiverTime;



            List <SatelliteNumber> satRejectedSet = new List <SatelliteNumber>();
            // Set the threshold to declare that satellites are in eclipse
            // threshold = cos(180 - coneAngle/2)
            double threshold = Math.Cos((CoordConsts.PI - ConeAngle / 2.0 * CoordConsts.DegToRadMultiplier));

            // Compute Sun position at this epoch, and store it in a Triple
            SunPosition sunPosition = new SunPosition();
            // Variables to hold Sun and Moon positions
            XYZ sunPos = (sunPosition.GetPosition(epoch));

            // Loop through all the satellites
            foreach (var sat in gData.EnabledSats)
            {
                SatelliteNumber prn = sat.Prn;
                //Define a XYZ that will hold satellite position, in ECEF
                XYZ svPos = gData[prn].Ephemeris.XYZ; //.GetSatPostion(satelliteType);
                XYZ rk    = svPos.UnitVector();       // Unitary vector from Earth mass center to satellite

                // Unitary vector from Earth mass center to Sun
                XYZ ri = sunPos.UnitVector();

                //Get dot product between unitary vectors = cosine(angle)
                double cosAngle = ri.Dot(rk);

                // Check if satellite is within shadow
                if (cosAngle <= threshold)
                {
                    // If satellite is eclipsed, then schedule it for removal
                    satRejectedSet.Add(prn);

                    if (!ShadowEpoch.ContainsKey(prn))
                    {
                        ShadowEpoch.Add(prn, epoch);
                    }
                    // Keep track of last known epoch the satellite was in eclipse
                    ShadowEpoch[prn] = epoch;

                    continue;
                }
                else
                {
                    // Maybe the satellite is out fo shadow, but it was recently
                    // in eclipse. Check also that.
                    if (ShadowEpoch.ContainsKey(prn))
                    {
                        // // If satellite was recently in eclipse, check if elapsed
                        // time is less or equal than postShadowPeriod
                        double temp = (double)Math.Abs(epoch - ShadowEpoch[prn]);

                        if (temp <= PostShadowPeriod)
                        {
                            // Satellite left shadow, but too recently. Delete it
                            satRejectedSet.Add(prn);
                        }
                        else
                        {
                            // If satellite left shadow a long time ago, set it free
                            ShadowEpoch.Remove(prn);
                        }
                    }
                }
            }
            //debug
            if (satRejectedSet.Count > 0 && satRejectedSet.FindAll(m => !RemovedPrn.Contains(m)).Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(gData.Name + "," + gData.ReceiverTime + ",删除太阳阴影影响的卫星:");
                sb.Append(String.Format(new EnumerableFormatProvider(), "{0}", satRejectedSet));
                log.Debug(sb.ToString());
                RemovedPrn.AddRange(satRejectedSet.FindAll(m => !RemovedPrn.Contains(m)));
            }

            //Remove satellites with missing satData
            gData.Remove(satRejectedSet, true, "删除太阳阴影影响的卫星");


            return(true);
        }