Esempio n. 1
0
        /// <summary>
        /// 写入
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="maxOrder">只读取到相应的阶次,节约时间</param>
        /// <returns></returns>
        public void Write(SphericalHarmonicsFile file, int maxOrder = int.MaxValue)
        {
            using (StreamWriter wr = new StreamWriter(path))
            {
                var format      = "0.000000000000000E+00";
                var sigmaFormat = "0.0000000000E+00";

                foreach (var kv in file.Data)
                {
                    var order = kv.Key;
                    if (order > maxOrder)
                    {
                        break;
                    }

                    var n = Geo.Utils.StringUtil.FillSpaceLeft(kv.Key.ToString(), 5);
                    int i = 0;
                    foreach (var item in kv.Value.C)
                    {
                        var m = Geo.Utils.StringUtil.FillSpaceLeft(i.ToString(), 5);
                        var c = Geo.Utils.StringUtil.FillSpaceLeft(item.Value.ToString(format), 25);
                        var s = Geo.Utils.StringUtil.FillSpaceLeft(kv.Value.S[i].Value.ToString(format), 25);

                        var sigmaC = Geo.Utils.StringUtil.FillSpaceLeft(item.Rms.ToString(sigmaFormat), 20);
                        var sigmaS = Geo.Utils.StringUtil.FillSpaceLeft(kv.Value.S[i].Rms.ToString(sigmaFormat), 20);
                        var line   = n + m + c + s + sigmaC + sigmaS;
                        wr.WriteLine(line);
                        i++;
                    }
                }
            }
        }
 /// <summary>
 /// 球谐函数计算器
 /// </summary>
 /// <param name="File"></param>
 public SphericalHarmonicsCalculater(SphericalHarmonicsFile File)
 {
     this.File = File;
     if (this.File.Contains(0))//包含0,非重力,为高程
     {
         IsCommon2DSphericalHarmonics = true;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 读取
        /// </summary>
        /// <param name="maxOrder">只读取到相应的阶次,节约时间</param>
        /// <returns></returns>
        public SphericalHarmonicsFile Read(int maxOrder = int.MaxValue)
        {
            SphericalHarmonicsFile file = new SphericalHarmonicsFile();

            using (StreamReader sr = new StreamReader(path))
            {
                string line = null;
                SphericalHarmonicsItem current = null;
                while ((line = sr.ReadLine()) != null)
                {
                    line = line.Replace("D", "E");
                    string[] strs = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    if (strs.Length < 4)
                    {
                        continue;
                    }
                    int n = int.Parse(strs[0]);
                    int m = int.Parse(strs[1]);

                    if (n > maxOrder)
                    {
                        break;
                    }

                    if (m == 0)
                    {
                        current = file.GetOrCreate(n);
                    }                                             // current = new SphericalHarmonicsItem(n + 1); file[n] = current; }
                    var cVal   = double.Parse(strs[2]);
                    var sVal   = double.Parse(strs[3]);
                    var cSigma = 0.0;
                    if (strs.Length > 4)
                    {
                        cSigma = double.Parse(strs[4]);
                    }
                    var sSigma = 0.0;
                    if (strs.Length > 5)
                    {
                        sSigma = double.Parse(strs[5]);
                    }

                    current.Set(m, new RmsedNumeral(cVal, cSigma), new RmsedNumeral(sVal, sSigma));
                }
            }
            return(file);
        }