Пример #1
0
 /// <summary>
 /// 添加一个子项,如果已经存在,则不添加。
 /// </summary>
 /// <param name="key"></param>
 public void Add(StaInfoItem item)
 {
     if (!Items.Contains(item))
     {
         Items.Add(item);
     }
 }
Пример #2
0
        /// <summary>
        /// 解析字符串。
        /// </summary>
        /// <param name="txt"></param>
        /// <returns></returns>
        public static StaFile ParseText(string txt)
        {
            //String[] lines = txt.Split(new char[] { '\r', '\north' },
            //     StringSplitOptions.RemoveEmptyEntries);
            StaFile file = new StaFile();

            file.Items = new List <StaInfoItem>();

            using (StreamReader r = new StreamReader(new MemoryStream(ASCIIEncoding.ASCII.GetBytes(txt))))
            {
                string line = null;
                while ((line = r.ReadLine()) != null)
                {
                    //
                    //TYPE 002: STATION INFORMATION
                    //-----------------------------
                    //
                    //STATION NAME          FLG          FROM                   TO         RECEIVER TYPE         ANTENNA TYPE          REC #   ANT #    NORTH      EAST      UP      DESCRIPTION             REMARK
                    //****************      ***  YYYY MM DD HH MM SS  YYYY MM DD HH MM SS  ********************  ********************  ******  ******  ***.****  ***.****  ***.****  **********************  ************************
                    //AIRA 21742S001        001
                    //.............
                    //ZWEN 12330M001        001  1980 01 06 00 00 00  2099 12 31 00 00 00  AOA SNR-8000 ACT      AOAD/M_T                 279     342    0.0000    0.0000    0.0460                            From ZWEN1430.02O
                    //
                    //
                    //TYPE 003: HANDLING OF STATION PROBLEMS
                    if (line.Contains("TYPE 002: STATION INFORMATION"))
                    {
                        line = r.ReadLine();
                        line = r.ReadLine();
                        line = r.ReadLine();
                        line = r.ReadLine();
                        while ((line = r.ReadLine()) != null)
                        {
                            if (line.Trim() == "" || line.Contains("TYPE 003"))
                            {
                                break;
                            }
                            StaInfoItem item = StaInfoItem.ParseLine(line);
                            file.Items.Add(item);
                        }
                        break;
                    }
                }
            }

            return(file);
        }
Пример #3
0
        /// <summary>
        /// 从 包含 O 文件的文件夹中读取、解析,并创建 StaFile 对象。
        /// </summary>
        /// <param name="oDir"></param>
        /// <returns></returns>
        public static StaFile CreateFromODir(string oDir)
        {
            StaFile file = new StaFile();

            file.Items = new List <StaInfoItem>();
            string[] files = Directory.GetFiles(oDir, Setting.RinexOFileFilter);

            foreach (var path in files)
            {
                Data.Rinex.RinexObsFileHeader h = new Data.Rinex.RinexObsFileReader(path).GetHeader();
                string name = h.MarkerName.Length > 4 ? h.MarkerName.Substring(0, 4).ToUpper() : h.MarkerName.ToUpper();
                //是否已经添加同名测站
                if (file.Items.Find(m => m.MakerName == name) != null)
                {
                    continue;
                }
                StaInfoItem sta = new StaInfoItem(name, h.SiteInfo, path);
                file.Items.Add(sta);
            }
            return(file);
        }
Пример #4
0
        /// <summary>
        /// STATION NAME          FLG          FROM                   TO         RECEIVER TYPE         ANTENNA TYPE          REC #   ANT #    NORTH      EAST      UP      DESCRIPTION             REMARK
        /// ****************      ***  YYYY MM DD HH MM SS  YYYY MM DD HH MM SS  ********************  ********************  ******  ******  ***.****  ***.****  ***.****  **********************  ************************
        /// AIRA 21742S001        001  1980 01 06 00 00 00  2099 12 31 00 00 00  TRIMBLE 4000SSI       TRM23903.00            17424       0    0.0000    0.0000    0.0000                            From AIRA1430.02O
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public static StaInfoItem ParseLine(string line)
        {
            StaInfoItem item = new StaInfoItem();

            item.MakerName    = line.Substring(0, 4);
            item.MakerNumber  = line.Substring(5, 11).Trim();
            item.Flag         = int.Parse(line.Substring(22, 3).Trim());
            item.From         = Time.Parse(line.Substring(27, 19));
            item.To           = Time.Parse(line.Substring(48, 19));
            item.OldStaName   = item.MakerName + "*";
            item.ReceiverType = line.Substring(69, 20).Trim();
            item.AntennaType  = line.Substring(91, 20).Trim();
            item.RecNum       = int.Parse(line.Substring(114, 7).Trim());
            item.AntNum       = int.Parse(line.Substring(121, 7).Trim());
            item.NEU          = new NEU(double.Parse(line.Substring(129, 9).Trim()),
                                        double.Parse(line.Substring(139, 9).Trim()),
                                        double.Parse(line.Substring(149, 9).Trim()));
            item.Discription = line.Substring(159, 22).Trim();
            item.Remark      = line.Substring(183, 24).Trim();
            return(item);
        }