Esempio n. 1
0
 /// <summary>
 /// 写入文件
 /// </summary>
 /// <param name="obsFile"></param>
 /// <param name="path"></param>
 /// <param name="verion"></param>
 /// <param name="minInterval"></param>
 public static void Write(RinexObsFile obsFile, string path, double verion = -1, int minInterval = 1)
 {
     if (verion < 2)
     {
         verion = obsFile.Header.Version;
     }
     using (RinexObsFileWriter writer = new RinexObsFileWriter(path, verion))
     {
         writer.Write(obsFile, minInterval);
     }
 }
Esempio n. 2
0
        private void button_run_Click(object sender, EventArgs e)
        {
            string dirPath = this.textBox_dir.Text;

            string[] files = Directory.GetFiles(dirPath, "*.*O");

            if (files.Length == 0)
            {
                files = Directory.GetFiles(dirPath, "*.SMT");

                foreach (var item in files)
                {
                    string     path = System.IO.Path.ChangeExtension(item, "**o");
                    byte[]     bt   = File.ReadAllBytes(item);
                    FileStream fs   = File.Create(path);
                    fs.Write(bt, 0, bt.Length);
                    fs.Close();
                }
            }


            files = Directory.GetFiles(dirPath, "*.*O");

            this.progressBarComponent1.InitProcess(files.Length);
            List <string> paths = new List <string>();

            foreach (var item in files)
            {
                if (Gnsser.Data.Rinex.ObsFileFormater.Format(item))
                {
                }

                Data.Rinex.RinexObsFile obsFile = new Gnsser.Data.Rinex.RinexObsFileReader(item).ReadObsFile();

                double per  = 0.01;
                string info = ObsFileCountManager.RemoveObserversInfo(ref obsFile, per * 0.01);

                Gnsser.Data.Rinex.ObsFileProcesserChain chain = new Gnsser.Data.Rinex.ObsFileProcesserChain();
                var process = new Gnsser.Data.Rinex.ObsFileCodeFilterProcesser()
                {
                    MaxPercentage = per
                };
                chain.AddProcessor(process);
                chain.Revise(ref obsFile);


                info = process.Message;

                string sbb = new Gnsser.Data.Rinex.RinexObsFileWriter().GetRinexString(obsFile, 3.02);

                File.WriteAllText(item, sbb);


                paths.Add(item);


                this.progressBarComponent1.PerformProcessStep();
            }

            StringBuilder sb = new StringBuilder();

            foreach (var item in paths)
            {
                sb.AppendLine(item);
            }
            MessageBox.Show("操作完毕!共修改 " + paths.Count + " 个.\r\n" + sb.ToString());
        }
Esempio n. 3
0
        /// <summary>
        /// 构建头部字符串。
        /// </summary>
        /// <param name="header"></param>
        /// <returns></returns>
        public static string BuildHeaderString(ClockFileHeader header, double version = 3.00)
        {
            StringBuilder sb = new StringBuilder();

            // HeaderLabel.RINEX_VERSION_TYPE:
            sb.Append(StringUtil.FillSpace(StringUtil.FillSpaceLeft(version.ToString("0.00"), 9), 20));
            sb.Append(StringUtil.FillSpaceRight("C", 40));
            sb.AppendLine(ClockHeaderLabel.RINEX_VERSION_TYPE);

            // HeaderLabel.PGM_RUN_BY_DATE:
            sb.Append(StringUtil.FillSpace("Gnsser", 20));
            sb.Append(StringUtil.FillSpace("GeoSolution", 20));
            sb.Append(StringUtil.FillSpace(DateTime.UtcNow.ToString("yyyyMMdd HHmmss") + " UTC", 20));
            sb.AppendLine(ClockHeaderLabel.PGM_RUN_BY_DATE);

            // HeaderLabel.COMMENT:
            header.RemoveGnsserComment();
            sb.AppendLine(RinexObsFileWriter.BuildGnsserCommentLines());
            if (header == null)
            {
                sb.AppendLine(StringUtil.FillSpace("", 60) + ClockHeaderLabel.END_OF_HEADER);

                return(sb.ToString());
            }

            if (header.Comments != null)
            {
                foreach (var item in header.Comments)
                {
                    if (item.Contains("Gnsser"))
                    {
                        continue;
                    }                                          //不重复写Gnsser信息。
                    if (String.IsNullOrWhiteSpace(item))
                    {
                        continue;
                    }
                    sb.AppendLine(StringUtil.FillSpace(item, 60) + ClockHeaderLabel.COMMENT);
                }
            }
            if (header.TIME_SYSTEM_ID != null)
            {
                sb.AppendLine(StringUtil.FillSpace(header.TIME_SYSTEM_ID, 60) + ClockHeaderLabel.TIME_SYSTEM_ID);
            }
            if (header.SYS_PCVS_APPLIED != null)
            {
                sb.AppendLine(StringUtil.FillSpace(header.TIME_SYSTEM_ID, 60) + ClockHeaderLabel.SYS_PCVS_APPLIED);
            }
            if (header.LEAP_SECONDS != 0)
            {
                sb.AppendLine(StringUtil.FillSpace(header.LEAP_SECONDS.ToString(), 6) + StringUtil.FillSpace("", 54) + ClockHeaderLabel.LEAP_SECONDS);
            }
            if (header.COUNT_OF_TYPES_OF_DATA != 0)
            {
                StringBuilder sb0 = GetTypesOfData(header);
                sb.AppendLine(StringUtil.FillSpace(sb0.ToString(), 60) + ClockHeaderLabel.TYPES_OF_DATA);
            }
            if (header.ANALYSIS_CENTER != null)
            {
                sb.AppendLine(StringUtil.FillSpace(header.ANALYSIS_CENTER, 60) + ClockHeaderLabel.ANALYSIS_CENTER);
            }
            if (header.OF_CLK_REF != null)
            {
                sb.AppendLine(StringUtil.FillSpace(header.OF_CLK_REF, 60) + ClockHeaderLabel.OF_CLK_REF);
            }
            if (header.ANALYSIS_CLK_REF != null)
            {
                sb.AppendLine(StringUtil.FillSpace(header.ANALYSIS_CLK_REF, 60) + ClockHeaderLabel.ANALYSIS_CLK_REF);
            }
            if (header.OF_SOLN_STA_TRF != null)
            {
                sb.AppendLine(StringUtil.FillSpace(header.OF_SOLN_STA_TRF, 60) + ClockHeaderLabel.OF_SOLN_STA_TRF);
            }
            if (header.ClockSolnStations != null)
            {
                if (header.ClockSolnStations.Count != 0)
                {
                    foreach (var item in header.ClockSolnStations)
                    {
                        sb.Append(StringUtil.FillSpace(item.Name, 4) + StringUtil.FillSpace(item.Number, 20));
                        sb.Append(StringUtil.FillSpace(item.XYZ.X.ToString(), 11) + StringUtil.FillSpace(item.XYZ.Y.ToString(), 11) + StringUtil.FillSpace(item.XYZ.Z.ToString(), 11));
                        sb.AppendLine(ClockHeaderLabel.SOLN_STA_NAME_NUM);
                    }
                }
            }
            if (header.OF_SOLN_SATS != 0)
            {
                sb.AppendLine(StringUtil.FillSpace(StringUtil.FillSpaceLeft("", 4) + header.OF_SOLN_SATS.ToString(), 60) + ClockHeaderLabel.OF_SOLN_SATS);
            }

            if (header.PrnList != null)
            {
                for (int i = 0; i < header.PrnList.Count; i++)
                {
                    sb.Append(header.PrnList[i].ToString() + " ");
                    if ((i + 1) % 15 == 0)
                    {
                        sb.AppendLine(ClockHeaderLabel.PRN_LIST);
                    }
                }
                int nn = header.PrnList.Count % 15;
                if (nn != 0)
                {
                    sb.AppendLine(StringUtil.FillSpace("", 60 - 4 * nn) + ClockHeaderLabel.PRN_LIST);
                }
            }


            sb.AppendLine(StringUtil.FillSpace("", 60) + ClockHeaderLabel.END_OF_HEADER);

            return(sb.ToString());
        }