Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 将另一个文件的内容添加进来,两个文件合并成一个文件。
        /// </summary>
        /// <param name="file"></param>
        /// <param name="strict"></param>
        /// <returns></returns>
        public void Merge(VelFile 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);
                }
            }
        }
Exemplo n.º 5
0
        public static IBerFile Merger(VelFile one, VelFile another)
        {
            VelFile newOne = new VelFile();

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

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

            return(newOne);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 从观测文件夹中读取。
        /// </summary>
        /// <param name="oDir"></param>
        /// <returns></returns>
        public static VelFile CreateFromODir(string oDir)
        {
            VelFile file = new VelFile()
            {
                Comments   = new List <string>(),
                DateString = DateTime.Now + "",
                Datum      = "IGS00",
                Epoch      = Time.Parse("2000-01-01 00:00:00"),
                Items      = new List <VelItem>(),
                Label      = "NUVEL1A-NNR VELOCITIES  "
            };

            file.Items = new List <VelItem>();
            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 VelItem()
                {
                    Code        = code,
                    Flag        = "",
                    Num         = num++,
                    Plate       = "",
                    StationName = makerName,
                    Vxyz        = new XYZ()
                });
            }

            return(file);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 读取Bernese速度文件
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        public static VelFile Read(Stream stream)
        {
            VelFile file = new VelFile();

            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 <VelItem>();
                        line       = reader.ReadLine();//空了一行。
                        while (line != null)
                        {
                            line = line.Trim();
                            if (line == "")
                            {
                                line = reader.ReadLine();
                                continue;
                            }

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

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

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