Exemplo n.º 1
0
        private void button_read_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);

            string[] pathes     = this.textBox_Pathes.Lines;
            int      dayOfweekO = 0;

            //sp3Observation = new Sp3File();
            TableTextManager = new ObjectTableManager();


            TableTextManager.OutputDirectory = directory;

            var SatEpochCountTable = TableTextManager.GetOrCreate("GNSSerSatEpochCount" + Path.GetFileNameWithoutExtension(pathes[0]).Substring(0, 12));

            #region  照时间顺序合并
            Time start = Time.MinValue;
            foreach (var pathItem in pathes)
            {
                Sp3Reader r = new Sp3Reader(pathItem);
                sp3 = r.ReadAll();
                var intervalSec = sp3.Header.EpochInterval;

                foreach (Sp3Section sec in sp3)
                {
                    Sp3Section s = new Sp3Section();
                    foreach (var rec in sec)
                    {
                        if (rec.Prn.SatelliteType == SatelliteType.R)
                        {
                            rec.Time = rec.Time + 1;
                        }
                        s.Time = rec.Time; s.Add(rec.Prn, rec);
                    }
                    if (sp3Observation == null || sp3Observation.Count == 0)
                    {
                        sp3Observation                  = new Sp3File();
                        sp3Observation.Header           = sp3.Header;
                        sp3Observation.Header.StartTime = s.Time;
                        sp3Observation.Header.Comments.Add("Processd by Gnsser");
                        sp3Observation.Header.Comments.Add("Collected from real time SSR clock correction");
                        dayOfweekO = sp3Observation.Header.StartTime.GetGpsWeekAndDay();
                    }
                    if (((s.Time.Hour == 0 && s.Time.Minute == 0 && s.Time.Second == 0) || start.GetGpsWeekAndDay() != s.Time.GetGpsWeekAndDay()) && sp3Observation.Count != 0)
                    {
                        var pathObservation = Path.Combine(directory, "Gnsser" + sp3.Name.Substring(0, 12) + dayOfweekO.ToString() + ".sp3");
                        sp3Observation.Header.NumberOfEpochs = sp3Observation.Count;
                        Sp3Writer Sp3WriterObservation = new Sp3Writer(pathObservation, sp3Observation);
                        Sp3WriterObservation.SaveToFile();
                        SatEpochCountTable.NewRow();
                        SatEpochCountTable.AddItem("Day", dayOfweekO);
                        sp3Observation.CheckOrBuildIndexCollection();
                        foreach (var item in sp3Observation.SatEphemerisCollection.Keys)
                        {
                            int a = sp3Observation.SatEphemerisCollection[item].Count;

                            SatEpochCountTable.AddItem(item, a);
                        }
                        SatEpochCountTable.EndRow();

                        sp3Observation.Clear();
                        sp3Observation.SatEphemerisCollection.Clear();
                        sp3Observation.Header.StartTime = s.Time;
                        //sp3Observation.Header.Comments.Add("Processd by Gnsser");
                        //sp3Observation.Header.Comments.Add("Collected from real time SSR clock correction");
                        dayOfweekO = sp3Observation.Header.StartTime.GetGpsWeekAndDay();
                        start      = s.Time;
                    }
                    if (!sp3Observation.Contains(s.Time))
                    {
                        sp3Observation.Add(s);
                    }
                }
            }

            TableTextManager.WriteAllToFileAndCloseStream();

            if (sp3Observation.Count != 0)
            {
                var pathObservation = Path.Combine(directory, "Gnsser" + sp3.Name.Substring(0, 12) + dayOfweekO.ToString() + ".sp3");
                sp3Observation.Header.NumberOfEpochs = sp3Observation.Count;
                Sp3Writer Sp3WriterObservation = new Sp3Writer(pathObservation, sp3Observation);
                Sp3WriterObservation.SaveToFile();
                sp3Observation.Clear();
            }

            #endregion

            Geo.Utils.FileUtil.OpenDirectory(directory);
        }
Exemplo n.º 2
0
        private void calculate_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  intervalSec  = double.Parse(textBox_interval.Text) * 60;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);
            string[] SSRsp3Pathes = this.textBox_SSRsp3Pathes.Lines;
            string[] NavPathes    = this.textBox_NavPathes.Lines;
            string[] ClockPathes  = this.textBox1.Lines;
            if (SSRsp3Pathes.Length != NavPathes.Length)
            {
                return;
            }
            int fileCount = SSRsp3Pathes.Length;

            if (!System.IO.Directory.Exists(@"D:\Temp\SSR1\"))
            {
                System.IO.Directory.CreateDirectory(@"D:\Temp\SSR1\");
            }
            EpochCountTableTextManager = new ObjectTableManager();


            EpochCountTableTextManager.OutputDirectory = "D:\\Temp\\SSR1\\";

            var SatEpochCountTable = EpochCountTableTextManager.GetOrCreate("BNCSatEpochCount");// + OriginalSSR.Header.Name);

            SatEpochCountTable.NewRow();

            for (int i = 0; i < fileCount; i++)
            {
                #region 读取SSR产品
                Time start0 = Time.MaxValue;
                Time end0   = Time.MinValue;
                OriginalSSRSp3 = new Sp3File();
                OriginalSSRSp3MinusPreciseClockOutput = new Sp3File();
                OriginalSSRSp3PlusNavOutput           = new Sp3File();
                Sp3Reader r = new Sp3Reader(SSRsp3Pathes[i]);
                OriginalSSRSp3 = r.ReadAll();
                OriginalSSRSp3.CheckOrBuildIndexCollection();

                Dictionary <string, int> SatEpochCount = new Dictionary <string, int>();
                foreach (var item in OriginalSSRSp3.Prns)
                {
                    SatEpochCount.Add(item.ToString(), OriginalSSRSp3.SatEphemerisCollection[item].Count);
                }
                SatEpochCountTable.AddItem("Day", start0.GetGpsWeekAndDay());
                foreach (var item in SatEpochCount)
                {
                    SatEpochCountTable.AddItem(item.Key, item.Value);
                }
                SatEpochCountTable.EndRow();

                #endregion

                #region 读取广播星历
                ParamNavFileReader NavReader = new ParamNavFileReader(NavPathes[i]);
                ephemeris = new SingleParamNavFileEphService(NavReader.ReadGnssNavFlie());
                #endregion
                #region 读取钟差文件

                //ClockFileReader reader = new ClockFileReader(ClockPathes[i]);
                //ClockFile = reader.ReadAll();
                //if (ClockFile.ClockCount == 0) return;
                #endregion
                OriginalSSRSp3.CheckOrBuildIndexCollection();
                for (Time time = OriginalSSRSp3.TimePeriod.Start; time <= OriginalSSRSp3.TimePeriod.End; time += 1)
                {
                    Sp3Section Sp3Section = new Sp3Section();
                    Sp3Section.Time = time;
                    foreach (var prn in OriginalSSRSp3.Prns)
                    {
                        var ss1 = OriginalSSRSp3.SatEphemerisCollection[prn].Values.FindLast(b => b.Time <= time);

                        if (!ephemeris.Prns.Contains(prn))
                        {
                            continue;
                        }
                        var ss = ephemeris.Get(prn, time);
                        XYZ eA = ss.XyzDot / ss.XyzDot.Length;
                        XYZ eC = ss.XYZ.Cross(ss.XyzDot) / (ss.XYZ.Cross(ss.XyzDot)).Length;
                        XYZ eR = eA.Cross(eC) / (eA.Cross(eC)).Length;

                        XYZ    deltaO = ss1.XYZ + ss1.XyzDot * (time.Seconds - ss1.Time.Seconds);
                        double x      = eA.X * deltaO.X + eA.X * deltaO.Y + eC.X * deltaO.Z;
                        double y      = eA.Y * deltaO.X + eA.Y * deltaO.Y + eC.Y * deltaO.Z;
                        double z      = eA.Z * deltaO.X + eA.Z * deltaO.Y + eC.Z * deltaO.Z;


                        Ephemeris Sp3Record = new Ephemeris();
                        Sp3Record.Prn = prn;
                        Sp3Record.XYZ = ss.XYZ - new XYZ(x, y, z);
                        if (prn.SatelliteType == SatelliteType.R)
                        {
                            Sp3Record.ClockBias = ss.ClockBias + ss1.ClockBias;
                        }
                        else
                        {
                            Sp3Record.ClockBias = ss.ClockBias - ss.RelativeCorrection + ss1.ClockBias;
                        }
                        Sp3Section.Add(prn, Sp3Record);
                    }
                    OriginalSSRSp3PlusNavOutput.Add(Sp3Section);
                }
                var resultPath = Path.Combine("D:\\Temp\\SSR1\\", OriginalSSRSp3.Name);

                Sp3Writer ClockFileWriter = new Sp3Writer(resultPath, OriginalSSRSp3PlusNavOutput);
                ClockFileWriter.SaveToFile();
            }


            //    List<AtomicClock> OriginalSSRDataSource = new List<AtomicClock>();
            //    List<AtomicClock> ClockFileDataSource = new List<AtomicClock>();

            //    foreach (var key in OriginalSSRSp3.Prns)
            //    {
            //        //OriginalSSRDataSource = OriginalSSR.GetClockItems(key);
            //        ClockFileDataSource = ClockFile.GetClockItems(key);
            //        if (ClockFileDataSource == null) continue;
            //        List<AtomicClock> ErrorResult = new List<AtomicClock>();
            //        List<AtomicClock> SSRPlusNavResult = new List<AtomicClock>();

            //        foreach (var item1 in ClockFileDataSource)
            //        {
            //            AtomicClock item2 = new AtomicClock();
            //            var clk =  OriginalSSRSp3.GetClockItem(item1.Prn.ToString(),item1.Time);
            //            if (item1.ClockBias == 9999999999.0 || clk == null)
            //            {
            //                item1.ClockBias = 9999999999.0;
            //                item2.Time = item1.Time;
            //                item2.Prn = item1.Prn;
            //                item2.Name = item1.Name;
            //                item2.ClockType = item1.ClockType;
            //                item2.ClockBias = 9999999999.0;
            //            }
            //            else
            //            {
            //                var NavItem = ephemeris.Get(item1.Prn, item1.Time);
            //                item2.Time = item1.Time;
            //                item2.Prn = item1.Prn;
            //                item2.Name = item1.Name;
            //                item2.ClockType = item1.ClockType;
            //                item2.ClockBias = NavItem.ClockBias - NavItem.RelativeTime + clk.ClockBias;
            //                item1.ClockBias = item2.ClockBias - item1.ClockBias;
            //            }
            //            SSRPlusNavResult.Add(item2);
            //            ErrorResult.Add(item1);

            //        }
            //        OriginalSSRSp3MinusPreciseClockOutput.Add(key, ErrorResult);
            //        OriginalSSRSp3PlusNavOutput.Add(key, SSRPlusNavResult);

            //    }

            //    double interval = double.Parse(this.textBox_interval.Text);
            //    ClockEstimationFrom = this.dateTimePicker_from.Value;
            //    ClockEstimationTo = this.dateTimePicker_to.Value;


            //    OriginalSSRSp3.Header = new Sp3Header ();
            //    OriginalSSRSp3.Header.AgencyName="Gnsser";
            //    OriginalSSRSp3.Header.EndTime=
            //    .Name = "SSR" + OriginalSSRSp3.Header.Name;
            //    OriginalSSRSp3.Header.CreationDate = DateTime.Now.ToString();
            //    OriginalSSRSp3.Header.CreationAgence = "Gnsser";
            //    OriginalSSRSp3.Header.ANALYSIS_CENTER = "Gnsser";
            //    OriginalSSRSp3.Header.CreationProgram = "Gnsser";
            //    OriginalSSRSp3MinusPreciseClockOutput.Header = OriginalSSRSp3.Header;
            //    OriginalSSRSp3PlusNavOutput.Header = OriginalSSRSp3.Header;

            //    var resutlPath = Path.Combine("D:\\Temp\\SSR1\\", OriginalSSRSp3.Header.Name);
            //    var errorResutlPath = Path.Combine("D:\\Temp\\SSR1\\", "error" + OriginalSSRSp3.Header.Name);

            //    ClockFileWriter ClockFileWriter = new ClockFileWriter(resutlPath, OriginalSSRSp3PlusNavOutput);
            //    ClockFileWriter.SaveToFile();
            //    ClockFileWriter errorClockFileWriter = new ClockFileWriter(errorResutlPath, OriginalSSRSp3MinusPreciseClockOutput);
            //    errorClockFileWriter.SaveToFile();
            //    TableTextManager = new TableObjectManager();


            //    TableTextManager.OutputDirectory = "D:\\Temp\\SSR1\\";

            //    var paramTable = TableTextManager.GetOrCreate(OriginalSSRSp3MinusPreciseClockOutput.Name + "errorSSRSat");
            //    int count = 0;
            //    SatelliteNumber prnIndex = new SatelliteNumber();
            //    foreach (var key in OriginalSSRSp3MinusPreciseClockOutput)
            //    {
            //        if (key.Count > count) { count = key.Count; prnIndex = key[0].Prn; }
            //    }

            //    var standard = OriginalSSRSp3MinusPreciseClockOutput.GetClockItems(prnIndex);
            //    double DoubleDiffer = 0;
            //    foreach (var key in standard)
            //    {
            //        paramTable.NewRow();
            //        paramTable.AddItem("Epoch", key.Time);
            //        foreach (var item1 in OriginalSSRSp3MinusPreciseClockOutput.Names)
            //        {
            //            if (item1 == key.Name.ToString()) continue;

            //            var ss = OriginalSSRSp3MinusPreciseClockOutput.GetClockItem(item1, key.Time);
            //            if (ss == null)
            //                continue;
            //            if (key.ClockBias == 9999999999.0 || ss.ClockBias == 9999999999.0)
            //                DoubleDiffer = 0;
            //            else DoubleDiffer = key.ClockBias - ss.ClockBias;
            //            paramTable.AddItem(ss.Prn + "-" + key.Prn, DoubleDiffer * 1E9);
            //        }
            //        paramTable.EndRow();
            //    }
            //    TableTextManager.WriteAllToFileAndCloseStream();
            //}
            //EpochCountTableTextManager.WriteAllToFileAndCloseStream();
            Geo.Utils.FileUtil.OpenDirectory("D:\\Temp\\SSR1\\");
        }