コード例 #1
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="oDir"></param>
        /// <param name="berFileType"></param>
        /// <returns></returns>
        public static IBerFile Create(string oDir, BerFileType berFileType)
        {
            IBerFile o = null;

            switch (berFileType)
            {
            case BerFileType.ABB:
                o = AbbFile.CreateFromODir(oDir);
                break;

            case BerFileType.STA:
                o = StaFile.CreateFromODir(oDir);
                break;

            case BerFileType.CRD:
                o = CrdFile.CreateFromODir(oDir);
                break;

            case BerFileType.VEL:
                o = VelFile.CreateFromODir(oDir);
                break;

            default: break;
            }
            return(o);
        }
コード例 #2
0
        /// <summary>
        /// 合并
        /// </summary>
        /// <param name="textA"></param>
        /// <param name="textB"></param>
        /// <param name="berFileType"></param>
        /// <returns></returns>
        public static IBerFile Merge(string textA, string textB, BerFileType berFileType)
        {
            IBerFile a = null, b = null;

            switch (berFileType)
            {
            case BerFileType.ABB:
                a = AbbFile.ParseText(textA);
                b = AbbFile.ParseText(textB);
                break;

            case BerFileType.STA:
                a = StaFile.ParseText(textA);
                b = StaFile.ParseText(textB);
                break;

            case BerFileType.CRD:
                a = CrdFile.ParseText(textA);
                b = CrdFile.ParseText(textB);
                break;

            case BerFileType.VEL:
                a = VelFile.ParseText(textA);
                b = VelFile.ParseText(textB);
                break;

            default: break;
            }
            return(Merge(a, b, berFileType));
        }
コード例 #3
0
        /// <summary>
        /// 合并
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="berFileType"></param>
        /// <returns></returns>
        public static IBerFile Merge(IBerFile a, IBerFile b, BerFileType berFileType)
        {
            IBerFile o = null;

            switch (berFileType)
            {
            case BerFileType.ABB:
                o = AbbFile.Merger(a as AbbFile, b as AbbFile);
                break;

            case BerFileType.STA:
                o = StaFile.Merger(a as StaFile, b as StaFile);
                break;

            case BerFileType.CRD:
                o = CrdFile.Merger(a as CrdFile, b as CrdFile);
                break;

            case BerFileType.VEL:
                o = VelFile.Merger(a as VelFile, b as VelFile);
                break;

            default: break;
            }
            return(o);
        }
コード例 #4
0
ファイル: CrdFile.cs プロジェクト: yxw027/GNSSer
        /// <summary>
        /// 从O文件夹创建
        /// </summary>
        /// <param name="oDir"></param>
        /// <returns></returns>
        public static CrdFile CreateFromODir(string oDir)
        {
            CrdFile file = new CrdFile()
            {
                Comments   = new List <string>(),
                DateString = DateTime.Now.ToString(),
                Datum      = "IGS00",
                Epoch      = Time.Parse("2000-01-01 00:00:00"),
                Items      = new List <CrdItem>(),
                Label      = "IGS00 COORDINATES BASED ON SINEX O Files"
            };

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

            foreach (var item in files)
            {
                Data.Rinex.RinexObsFileHeader h = new Data.Rinex.RinexObsFileReader(item).GetHeader();
                //判断是否已经存在。
                string makerName = StringUtil.FillZero(h.MarkerName.ToUpper(), 4).Substring(0, 4);
                if (file.Items.Find(m => m.StationName == makerName) != null)
                {
                    continue;
                }

                string code = h.SiteInfo.MarkerNumber;

                file.Items.Add(new CrdItem(num++, makerName, code, h.ApproxXyz));
            }

            return(file);
        }
コード例 #5
0
ファイル: CrdFile.cs プロジェクト: yxw027/GNSSer
        /// <summary>
        /// 将另一个文件的内容添加进来,两个文件合并成一个文件。
        /// </summary>
        /// <param name="file"></param>
        /// <param name="strict"></param>
        /// <returns></returns>
        public void AddRange(CrdFile file, bool strict = false)
        {
            if (strict && (Datum != file.Datum || !this.Epoch.Equals(file.Epoch)))
            {
                throw new ArgumentException("两个文件历元或基准不一样。");
            }
            int num = this.Items.Count;

            foreach (var item in file.Items)
            {
                if (!Items.Contains(item))
                {
                    item.Num += num;
                    this.Items.Add(item);
                }
            }
        }
コード例 #6
0
ファイル: CrdFile.cs プロジェクト: yxw027/GNSSer
        /// <summary>
        /// 合并两个 ABB 文件。
        /// </summary>
        /// <param name="one"></param>
        /// <param name="another"></param>
        /// <returns></returns>
        public static CrdFile Merger(CrdFile one, CrdFile another)
        {
            CrdFile newOne = new CrdFile();

            newOne.DateString = DateTime.Now + "";
            newOne.Datum      = one.Datum;
            newOne.Epoch      = one.Epoch;
            newOne.Label      = "Merged";
            newOne.Items      = new List <CrdItem>();
            newOne.Items.AddRange(one.Items);

            foreach (var item in another.Items)
            {
                newOne.Add(item);
            }

            return(newOne);
        }
コード例 #7
0
ファイル: CrdFile.cs プロジェクト: yxw027/GNSSer
        public static CrdFile Read(Stream stream)
        {
            CrdFile file = new CrdFile();

            if (file.Comments == null)
            {
                file.Comments = new List <string>();
            }

            using (StreamReader reader = new StreamReader(stream))
            {
                string line;
                //第一行
                //PPP_021430_143MATE                                               24-JAN-13 09:21
                line            = reader.ReadLine();
                file.Label      = line.Substring(0, 65).Trim();
                file.DateString = line.Substring(65).Trim();

                //第二行
                //--------------------------------------------------------------------------------
                line = reader.ReadLine();

                //第3行
                //LOCAL GEODETIC DATUM: IGS00             EPOCH: 2002-05-23 11:57:30
                line = reader.ReadLine();
                if (line.Contains("DATUM"))
                {
                    file.Datum = line.Substring(line.IndexOf(":") + 1, 15).Trim();
                }
                if (line.Contains("EPOCH"))
                {
                    file.Epoch = new Time(DateTime.Parse(line.Substring(line.IndexOf("EPOCH") + 6)));
                }

                while ((line = reader.ReadLine()) != null)
                {
                    //正式记录
                    if (line.StartsWith("NUM"))
                    {
                        file.Items = new List <CrdItem>();
                        line       = reader.ReadLine();//空了一行。
                        while (line != null)
                        {
                            line = line.Trim();
                            if (line == "")
                            {
                                line = reader.ReadLine();
                                continue;
                            }

                            CrdItem coord = CrdItem.ParseLine(line);
                            file.Items.Add(coord);

                            line = reader.ReadLine();
                            if (line == "")
                            {
                                break;            //跳出
                            }
                        }

                        //末尾有些东西
                        while ((line = reader.ReadLine()) != null)
                        {
                            file.Comments.Add(line);
                        }
                    }
                }
                return(file);
            }
        }