Exemple #1
0
        /// <summary>
        /// NUM  STATION NAME           X (M)          Y (M)          Z (M)     FLAG
        ///  1  BRUS 13101M004     4027893.8650    307045.6950   4919475.0250
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public static CrdItem ParseLine(string line)
        {
            string[] strs = line.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            int     i     = 0;
            CrdItem coord = new CrdItem();

            coord.Num         = int.Parse(strs[i++]);
            coord.StationName = strs[i++];
            if (line.Substring(10, 10).Trim().Length > 0)
            {
                coord.Code = strs[i++];
            }
            coord.Xyz = new XYZ(
                double.Parse(strs[i++]),
                double.Parse(strs[i++]),
                double.Parse(strs[i++])
                );
            if (strs.Length > i)
            {
                coord.Flag = strs[i++];
            }
            coord.GeoCoord = Geo.Coordinates.CoordTransformer.XyzToGeoCoord(coord.Xyz);
            return(coord);
        }
Exemple #2
0
 public void Add(CrdItem item)
 {
     if (!Items.Contains(item))
     {
         item.Num += 1;
         this.Items.Add(item);
     }
 }
Exemple #3
0
        /// <summary>
        /// 等
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>

        public override bool Equals(object obj)
        {
            CrdItem o = obj as CrdItem;

            if (o == null)
            {
                return(false);
            }

            return(StationName.Equals(o.StationName));
        }
Exemple #4
0
        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);
            }
        }