Ejemplo n.º 1
0
        /// <summary>
        /// 从 Sinex 文件中提取 XYZ 坐标。
        /// </summary>
        /// <param name="Site"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public static List <XYZ> GetEstXYZ(string[] Site, string path = "D:\\Test\\igs13p17212.SNX")
        {
            SinexFile     pubSinexFile = SinexReader.Read(path);
            List <string> pubSiteCode  = pubSinexFile.GetSiteCods();

            double[]   pubAllEst = pubSinexFile.GetEstimateVector();
            int        m         = Site.Length;
            List <XYZ> pubXYZ    = new List <XYZ>();

            for (int i = 0; i < m; i++)
            {
                string item = Site[i];
                for (int j = 0; j < pubSiteCode.Count; j++)
                {
                    if (pubSiteCode[j].ToUpper() == item.ToUpper())
                    {
                        XYZ xyz = new XYZ();
                        xyz.Site = item;
                        xyz.X    = pubAllEst[3 * j + 0];
                        xyz.Y    = pubAllEst[3 * j + 1];
                        xyz.Z    = pubAllEst[3 * j + 2];
                        pubXYZ.Add(xyz);
                    }
                }
            }
            return(pubXYZ);
        }
Ejemplo n.º 2
0
        private void button_extract_Click(object sender, EventArgs e)
        {
            SinexFile sinexfile;

            sinexfile = SinexReader.Read(textBox_SinexFile.Text);
            List <string> sites = sinexfile.GetSiteCods();

            progressBar1.Maximum = stations.Count;
            progressBar1.Minimum = 1;
            progressBar1.Step    = 1;
            progressBar1.Value   = progressBar1.Minimum;


            for (int i = 0; i < stations.Count; i++)
            {
                progressBar1.PerformStep();
                progressBar1.Refresh();
                if (sites.Contains(stations[i]))
                {
                    continue;
                }
                else
                {
                    File.Delete(stationfiles[i]);
                }
            }
            FormUtil.ShowIfOpenDirMessageBox(this.textBox_ObsFilePath.Text);
        }
Ejemplo n.º 3
0
        private void button_merge_Click(object sender, EventArgs e)
        {
            SinexFile fileMerged = null;

            foreach (var item in this.textBox_pathes.Lines)
            {
                SinexFile file = SinexReader.Read(item);
                if (fileMerged == null)
                {
                    fileMerged = file;
                }
                else
                {
                    fileMerged = SinexMerger.Merge(fileMerged, file, this.checkBox_eraseNonCoord.Checked);
                }
            }
            if (checkBox_showresult.Checked)
            {
                this.textBox_result.Text = fileMerged.ToString();
            }

            File.WriteAllText(this.textBox_savepath.Text, fileMerged.ToString());

            Geo.Utils.FormUtil.ShowIfOpenDirMessageBox(this.textBox_savepath.Text);
        }
Ejemplo n.º 4
0
        private void Read()
        {
            string pathA = this.textBox_PathA.Text;

            if (!File.Exists(pathA))
            {
                FormUtil.ShowFileNotExistBox(pathA);
                return;
            }
            string pathB = this.textBox_PathB.Text;

            if (!File.Exists(pathB))
            {
                FormUtil.ShowFileNotExistBox(pathB);
                return;
            }

            fileA = SinexReader.Read(pathA);
            this.textBox_sinexA.Text = fileA.ToString();
            List <SinexSiteDetail> listA = fileA.GetSinexSites();

            this.bindingSourceA.DataSource = listA;

            fileB = SinexReader.Read(pathB);
            this.textBox_sinexB.Text = fileB.ToString();
            List <SinexSiteDetail> listB = fileB.GetSinexSites();

            this.bindingSourceB.DataSource = listB;


            this.bindingSourceC.DataSource = SinexSiteDetail.Compare(listA, listB);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 坐标解析
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static List <NamedXyz> GetCoords(string path)
        {
            try
            {
                string extension = Path.GetExtension(path).ToLower();
                switch (extension)
                {
                case ".snx":
                    SinexFile fileA = SinexReader.Read(path, true);
                    return(fileA.GetSiteEstimatedCoords());

                case ".xls":
                    return(NamedXyz.ReadNamedXyz(path));

                case ".txt":
                    return(NamedXyz.ReadNamedXyztxt(path));

                case ".org":
                    GamitOrgFileService service = new GamitOrgFileService(path);
                    return(service.GetNamedXyzs());

                case ".rep":
                    var p = new PinnacleRepFileService(path);
                    return(p.GetNamedXyzs());

                case ".pos":    //"Rtklib 结果|*.pos
                {
                    var pp = Gnsser.Interoperation.RtkpostResult.Load(path);
                    return(pp.GetNamedXyzs());
                }

                case ".clk":
                case ".clk_30s":
                case ".clk_05s":
                    ClockFileHeader a       = ClockFileReader.ReadHeader(path);
                    List <NamedXyz> results = new List <NamedXyz>();
                    foreach (var item in a.ClockSolnStations)
                    {
                        NamedXyz bb = new NamedXyz();
                        bb.Name  = item.Name;
                        bb.Value = item.XYZ;
                        results.Add(bb);
                    }
                    return(results);

                default:
                    break;
                }
                return(new List <NamedXyz>());
            }catch (Exception ex)
            {
                new Log(ex.Message).Error(ex.Message + ", 解析出错!");
                return(new List <NamedXyz>());
            }
        }
Ejemplo n.º 6
0
        private void button_solve_Click(object sender, EventArgs e)
        {
            //读取
            string[]         filePathes = this.textBox_rinexPathes.Lines;
            List <SinexFile> sinexFiles = SinexReader.Read(filePathes);

            adjust = new SinexBlockAdjust(sinexFiles.ToArray());

            this.textBox_resultSinex.Text = adjust.ResultSinexFile.ToString();
            this.textBox_info.Text        = adjust.ToString();
        }
Ejemplo n.º 7
0
        private void button_read_Click(object sender, EventArgs e)
        {
            if (this.textBox_Path.Lines.Length == 0)
            {
                FormUtil.ShowFileNotExistBox("");
                return;
            }

            files = SinexReader.Read(this.textBox_Path.Lines);

            ShowFile();
        }
Ejemplo n.º 8
0
        private void button_read_Click(object sender, EventArgs e)
        {
            string path = this.textBox_Path.Text;

            if (!File.Exists(path))
            {
                FormUtil.ShowFileNotExistBox(path);
                return;
            }

            file = SinexReader.Read(path, this.checkBox_notReadMatix.Checked);

            ShowFile();
        }
Ejemplo n.º 9
0
        private void button_merge_Click(object sender, EventArgs e)
        {
            SinexFile a = SinexReader.ParseText(this.textBox_A.Text);
            SinexFile b = SinexReader.ParseText(this.textBox_B.Text);
            SinexFile c = SinexMerger.Merge(a, b);

            if (checkBox_show.Checked)
            {
                this.textBox_C.Text = c.ToString();
            }

            File.WriteAllText(this.textBox_mergePath.Text, c.ToString());

            Geo.Utils.FormUtil.ShowIfOpenDirMessageBox(this.textBox_mergePath.Text);
        }
Ejemplo n.º 10
0
        private void button_extractcoords_Click(object sender, EventArgs e)
        {
            sinexfile = SinexReader.Read(textBox_sinexFile.Text);
            List <string> sites = sinexfile.GetSiteCods();

            double[] CoordArray = sinexfile.GetEstimateVector();
            sitecood = new Dictionary <string, xyzblh>();
            for (int i = 0; i < sites.Count; i++)
            {
                string   tmpsite   = sites[i];
                XYZ      tmpxyz    = new XYZ(CoordArray[3 * i + 0], CoordArray[3 * i + 1], CoordArray[3 * i + 2]);
                GeoCoord tmplonlat = CoordTransformer.XyzToGeoCoord(tmpxyz, Ellipsoid.WGS84);
                if (!sitecood.Keys.Contains(tmpsite))
                {
                    sitecood.Add(tmpsite, new xyzblh());
                    sitecood[tmpsite].truexyz = tmpxyz;
                    sitecood[tmpsite].lon     = tmplonlat.Lon;
                    sitecood[tmpsite].lat     = tmplonlat.Lat;
                }
            }

            SavePath = this.textBox_uotputpath.Text + "\\sinexcoord" + ".txt";
            //"C:\\Users\\lilinyang\\Desktop\\sinexcoord" + ".txt";
            FileInfo     aFile = new FileInfo(SavePath);
            StreamWriter SW    = aFile.CreateText();

            System.Globalization.NumberFormatInfo GN = new System.Globalization.CultureInfo("zh-CN", false).NumberFormat;
            GN.NumberDecimalDigits = 6;
            foreach (var item in sitecood)
            {
                SW.Write(item.Key.ToString());
                SW.Write(" ");
                SW.Write(item.Value.truexyz.X.ToString());
                SW.Write(" ");
                SW.Write(item.Value.truexyz.Y.ToString());
                SW.Write(" ");
                SW.Write(item.Value.truexyz.Z.ToString());
                SW.Write(" ");
                SW.Write(item.Value.lon.ToString());
                SW.Write(" ");
                SW.Write(item.Value.lat.ToString());
                SW.Write("\n");
            }
            SW.Close();
        }
Ejemplo n.º 11
0
        private void Read()
        {
            string[]         filePathes = this.textBox_Path.Lines;
            List <SinexFile> sinexFiles = SinexReader.Read(filePathes);

            current = null;

            foreach (var item in sinexFiles)
            {
                if (current == null)
                {
                    current = item;
                }
                else
                {
                    SinexSubNetsUnion just = new SinexSubNetsUnion(current, item);
                    current = just.ResultSinexFile;
                }
            }
            this.textBox_info.Text = current.ToString();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 根据坐标文件读取坐标
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static BaseDictionary <string, NamedRmsXyz> GetCoords(string path)
        {
            string extension = Path.GetExtension(path).ToLower();

            switch (extension)
            {
            case ".snx":
                var SinexFile = SinexReader.Read(path);    // SinexFileReader
                return(SinexFile.GetSiteEstimateRmsdCoords());

                break;

            case ".xls":
                BaseDictionary <string, NamedRmsXyz> dic = new BaseDictionary <string, NamedRmsXyz>();
                var list = NamedXyz.ReadNamedXyz(path);
                foreach (var item in list)
                {
                    dic[item.Name.Trim().ToUpper()] = new NamedRmsXyz(item.Name, new RmsedXYZ(item.Value));
                }
                return(dic);

                break;

            case ".txt":
                BaseDictionary <string, NamedRmsXyz> dic2 = new BaseDictionary <string, NamedRmsXyz>();
                var list2 = NamedXyz.ReadNamedXyztxt(path);
                foreach (var item in list2)
                {
                    dic2[item.Name.Trim().ToUpper()] = new NamedRmsXyz(item.Name, new RmsedXYZ(item.Value));
                }
                return(dic2);

                break;

            default:
                break;
            }
            return(new BaseDictionary <string, NamedRmsXyz>());
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 读取基线向量观测文件和SNX文件,获取基线相关信息
        /// </summary>
        private void Int()
        {
            List <string> allKnownPointName = new System.Collections.Generic.List <string>(); //所指定的已知点,但这些已知点可能SNX文件中没有,不是全部采用

            KnownPointName              = new System.Collections.Generic.List <string>();     //实际采用的已知点,根据SNX文件读取坐标值
            KonwnPointsXyz              = new System.Collections.Generic.Dictionary <string, XYZ>();
            CommonPointName             = new System.Collections.Generic.List <string>();
            CommonPointsXyz             = new System.Collections.Generic.Dictionary <string, XYZ>();
            AllPointsApproXyz           = new System.Collections.Generic.Dictionary <string, XYZ>();             //所有点的坐标,已知点为真值,未知的为近似值
            AllPointName                = new System.Collections.Generic.List <string>();
            BaselineInfo                = new System.Collections.Generic.Dictionary <string, XYZ>();             //存放观测值基线残差信息
            BaselineInverseOfWegihtInfo = new System.Collections.Generic.Dictionary <string, SymmetricMatrix>(); //存放观测值的协方差阵

            var          coordNamePath = this.fileOpenControl2_KnownPointName.FilePath;
            StreamReader sr            = new StreamReader(coordNamePath);
            string       strLine       = sr.ReadLine();

            while ((strLine) != null && strLine != "")
            {
                string[] names = strLine.Split(new char[] { ' ', ',', ';', '\t' });
                foreach (var item in names)
                {
                    if (!allKnownPointName.Contains(item))
                    {
                        allKnownPointName.Add(item.ToUpper());
                    }
                }
                strLine = sr.ReadLine();
            }
            sr.Close();
            var coordPath = this.fileOpenControl1.FilePath;

            if (coordPath == null || !Path.GetExtension(coordPath).Contains(".snx"))
            {
                throw new Exception("请指定坐标基准文件SNX");
            }

            SinexFile                SinexFile = new Data.Sinex.SinexFile(coordPath);
            SinexFile                fileA     = SinexReader.Read(coordPath, true);
            List <NamedXyz>          listSnx   = fileA.GetSiteEstimatedCoords();
            Dictionary <string, XYZ> SnxXyz    = new System.Collections.Generic.Dictionary <string, XYZ>();//snx文件的坐标值

            //  var colName = SinexFile.GetSinexSites();
            foreach (var item in listSnx)
            {
                SnxXyz.Add(item.Name.ToUpper().Trim(), item.Value);
            }

            foreach (var item in allKnownPointName)
            {
                if (SnxXyz.ContainsKey(item))
                {
                    KonwnPointsXyz.Add(item, SnxXyz[item]);
                    KnownPointName.Add(item);
                }
            }

            var baselinefiles = this.fileOpenControl2baselinefiles.FilePathes;

            foreach (var path in baselinefiles)
            {
                using (StreamReader reader = new StreamReader(new FileStream(path, FileMode.Open)))
                {
                    int    nameIndex = -1;
                    int    detXIndex = -1; int detYIndex = -1; int detZIndex = -1;
                    int    QxxIndex = -1; int QxyIndex = -1; int QyyIndex = -1; int QxzIndex = -1; int QyzIndex = -1; int QzzIndex = -1;
                    int    RefApproXIndex = -1; int RefApproYIndex = -1; int RefApproZIndex = -1;
                    int    RovApproXIndex = -1; int RovApproYIndex = -1; int RovApproZIndex = -1;
                    string line = reader.ReadLine();
                    //第一行为头部
                    string[] titles = StringUtil.SplitByTab(line);
                    int      i      = 0;
                    foreach (var item in titles)
                    {
                        var title = item.ToLower();
                        if (title.Contains("name") && nameIndex == -1)
                        {
                            nameIndex = i;
                        }
                        else if (title.Contains("estvectorx") && detXIndex == -1)
                        {
                            detXIndex = i;
                        }
                        else if (title.Contains("estvectory") && detYIndex == -1)
                        {
                            detYIndex = i;
                        }
                        else if (title.Contains("estvectorz") && detZIndex == -1)
                        {
                            detZIndex = i;
                        }
                        else if (title.Contains("qxx") && QxxIndex == -1)
                        {
                            QxxIndex = i;
                        }
                        else if (title.Contains("qxy") && QxyIndex == -1)
                        {
                            QxyIndex = i;
                        }
                        else if (title.Contains("qyy") && QyyIndex == -1)
                        {
                            QyyIndex = i;
                        }
                        else if (title.Contains("qxz") && QxzIndex == -1)
                        {
                            QxzIndex = i;
                        }
                        else if (title.Contains("qyz") && QyzIndex == -1)
                        {
                            QyzIndex = i;
                        }
                        else if (title.Contains("qzz") && QzzIndex == -1)
                        {
                            QzzIndex = i;
                        }
                        else if (title.Contains("refapprox") && RefApproXIndex == -1)
                        {
                            RefApproXIndex = i;
                        }
                        else if (title.Contains("refapproy") && RefApproYIndex == -1)
                        {
                            RefApproYIndex = i;
                        }
                        else if (title.Contains("refapproz") && RefApproZIndex == -1)
                        {
                            RefApproZIndex = i;
                        }
                        else if (title.Contains("rovapprox") && RovApproXIndex == -1)
                        {
                            RovApproXIndex = i;
                        }
                        else if (title.Contains("rovapproy") && RovApproYIndex == -1)
                        {
                            RovApproYIndex = i;
                        }
                        else if (title.Contains("rovapproz") && RovApproZIndex == -1)
                        {
                            RovApproZIndex = i;
                        }
                        i++;
                    }

                    while ((line = reader.ReadLine()) != null)
                    {
                        if (String.IsNullOrWhiteSpace(line))
                        {
                            continue;
                        }
                        string[] values = StringUtil.SplitByTab(line);

                        string   baselineName = values[nameIndex];
                        string[] Names        = baselineName.Split('-');

                        string RefName = Names[0].Substring(0, 4).ToUpper();
                        string RovName = Names[1].Substring(0, 4).ToUpper();


                        XYZ      baselineValue = new XYZ(double.Parse(values[detXIndex]), double.Parse(values[detYIndex]), double.Parse(values[detZIndex]));
                        double[] qx            = new double[6] {
                            double.Parse(values[QxxIndex]) + 10e-10, double.Parse(values[QxyIndex]), double.Parse(values[QyyIndex]) + 10e-10, double.Parse(values[QxzIndex]), double.Parse(values[QyzIndex]), double.Parse(values[QzzIndex]) + 10e-10
                        };
                        SymmetricMatrix Q = new SymmetricMatrix(qx);

                        XYZ RefApproXYZ = new XYZ(double.Parse(values[RefApproXIndex]), double.Parse(values[RefApproYIndex]), double.Parse(values[RefApproZIndex]));
                        XYZ RovApproXYZ = new XYZ(double.Parse(values[RovApproXIndex]), double.Parse(values[RovApproYIndex]), double.Parse(values[RovApproZIndex]));

                        //观测值常数项l=L(基线向量)-(流动站近似坐标-基准站近似坐标)
                        //参考站
                        if (RefName == "SHAO" && RovName == "ZJZS")
                        {
                            //
                        }
                        if (SnxXyz.ContainsKey(RefName))
                        {
                            if (!CommonPointsXyz.ContainsKey(RefName))
                            {
                                CommonPointsXyz.Add(RefName, SnxXyz[RefName]);
                            }
                            //if (!AllPointsApproXyz.ContainsKey(RefName)) { AllPointsApproXyz.Add(RefName, RefApproXYZ); }
                            if (!AllPointsApproXyz.ContainsKey(RefName))
                            {
                                AllPointsApproXyz.Add(RefName, RefApproXYZ);// SnxXyz[RefName]);
                                AllPointName.Add(RefName);
                            }

                            if ((CommonPointsXyz[RefName] - AllPointsApproXyz[RefName]).Length > 1.0) //暂时防止同名点情况
                            {
                                CommonPointsXyz.Remove(RefName);
                                AllPointsApproXyz[RefName] = RefApproXYZ;
                                baselineValue += AllPointsApproXyz[RefName];
                            }
                            else
                            {
                                baselineValue += CommonPointsXyz[RefName];//基线观测值减去基线近似值
                                // baselineValue += AllPointsApproXyz[RefName];
                            }
                        }
                        else
                        {
                            if (!AllPointsApproXyz.ContainsKey(RefName))
                            {
                                AllPointsApproXyz.Add(RefName, RefApproXYZ);
                                AllPointName.Add(RefName);
                            }
                            baselineValue += AllPointsApproXyz[RefName];//基线观测值减去基线近似值
                        }
                        //流动站
                        if (SnxXyz.ContainsKey(RovName))
                        {
                            if (!CommonPointsXyz.ContainsKey(RovName))
                            {
                                CommonPointsXyz.Add(RovName, SnxXyz[RovName]);
                            }
                            //if (!AllPointsApproXyz.ContainsKey(RovName)) { AllPointsApproXyz.Add(RovName, RovApproXYZ); }
                            if (!AllPointsApproXyz.ContainsKey(RovName))
                            {
                                AllPointsApproXyz.Add(RovName, RovApproXYZ);// SnxXyz[RovName]);
                                AllPointName.Add(RovName);
                            }

                            if ((CommonPointsXyz[RovName] - AllPointsApproXyz[RovName]).Length > 1.0) //暂时防止同名点情况
                            {
                                CommonPointsXyz.Remove(RovName);
                                AllPointsApproXyz[RovName] = RovApproXYZ;
                                baselineValue -= AllPointsApproXyz[RovName];
                            }
                            else
                            {
                                baselineValue -= CommonPointsXyz[RovName];
                                // baselineValue -= AllPointsApproXyz[RovName];
                            }
                        }
                        else
                        {
                            if (!AllPointsApproXyz.ContainsKey(RovName))
                            {
                                AllPointsApproXyz.Add(RovName, RovApproXYZ);
                                AllPointName.Add(RovName);
                            }
                            baselineValue -= AllPointsApproXyz[RovName]; //基线观测值减去基线近似值
                        }
                        //// //基线观测值减去基线近似值
                        ////// baselineValue -= (AllPointsApproXyz[RovName] - AllPointsApproXyz[RefName]);

                        //不同基线文件中可能存在同名基线,需根据基线文件再唯一标示
                        BaselineInfo.Add(RefName + "-" + RovName + "-" + Path.GetFileName(path), baselineValue);
                        BaselineInverseOfWegihtInfo.Add(RefName + "-" + RovName + "-" + Path.GetFileName(path), Q);
                    }
                } //当前基线文件遍历完
            }     //所有基线文件遍历完

            //已知点的向量
            foreach (var item in KonwnPointsXyz)
            {
                if (!AllPointsApproXyz.ContainsKey(item.Key))
                {
                    AllPointsApproXyz.Add(item.Key, item.Value);
                    AllPointName.Add(item.Key);
                }
                string knownName = null;
                double length    = 10e14;
                foreach (var com in CommonPointsXyz)
                {
                    if (com.Key != item.Key)
                    {
                        double tmp = (com.Value - item.Value).Length;
                        if (tmp < length)
                        {
                            length    = tmp;
                            knownName = com.Key;
                        }
                    }
                }
                XYZ baseline = (CommonPointsXyz[knownName] - KonwnPointsXyz[item.Key]) - (AllPointsApproXyz[knownName] - AllPointsApproXyz[item.Key]);
                //不同基线文件中可能存在同名基线,需根据基线文件再唯一标示
                BaselineInfo.Add(item.Key + "-" + knownName + "-" + "基准基线", baseline);
                SymmetricMatrix Q = new SymmetricMatrix(3, 0); Q[0, 0] = Q[1, 1] = Q[2, 2] = 10e-10;
                BaselineInverseOfWegihtInfo.Add(item.Key + "-" + knownName + "-" + "基准基线", Q);
            }

            ////关系后续矩阵方程建立的编号,得小心改
            //foreach (var key in AllPointsApproXyz)
            //{
            //    AllPointName.Add(key.Key);
            //}
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Ambizap算法的实现。
        /// 选择两个点的PPP计算结果,及其基线计算结果。
        /// </summary>
        private void Read()
        {
            string pointNameA = null, pointNameB = null;

            //---------------------------------------------------数据读取//---------------------------------------------------
            //只提取两个点的位置信息及其基线。
            //读取PPP结果
            string[]               pppfilePathes = this.textBox_PathesOfPPP.Lines;
            List <SinexFile>       pppsinexFiles = SinexReader.Read(pppfilePathes);
            List <SinexSiteDetail> pppSitesA = new List <SinexSiteDetail>();
            List <SinexSiteDetail> pppSitesB = new List <SinexSiteDetail>();

            foreach (var file in pppsinexFiles)
            {
                List <SinexSiteDetail> sites = file.GetSinexSites();
                foreach (var item2 in sites)
                {
                    if (pointNameA == null)
                    {
                        pointNameA = item2.Name;
                    }
                    if (pointNameB == null && pointNameA != item2.Name)
                    {
                        pointNameB = item2.Name;
                    }

                    if (item2.Name == pointNameA)
                    {
                        pppSitesA.Add(item2);
                    }
                    if (item2.Name == pointNameB)
                    {
                        pppSitesB.Add(item2);
                    }
                }
            }
            if (pointNameA == null || pointNameB == null)
            {
                throw new ArgumentException("起算数据不足。");
            }

            //读取基线结果
            //只需要一条基线就行了。
            string[]               baseLineFilePathes = this.textBox_pathesOfBaseLine.Lines;
            List <SinexFile>       baseLineSinexFiles = SinexReader.Read(baseLineFilePathes);
            List <SinexSiteDetail> baseLineSites = new List <SinexSiteDetail>();

            foreach (var file in baseLineSinexFiles)
            {
                List <SinexSiteDetail> sites = file.GetSinexSites();
                foreach (var item2 in sites)
                {
                    if ((item2.Name == pointNameA || item2.Name == pointNameB) && (baseLineSites.Find(m => m.Name == item2.Name) == null))
                    {
                        baseLineSites.Add(item2);
                    }
                    if (baseLineSites.Count == 2)
                    {
                        break;
                    }
                }
                if (baseLineSites.Count == 2)
                {
                    break;
                }
            }
            //组建基线
            string   name = baseLineSites[0].Name + "-" + baseLineSites[1].Name;
            BaseLine line = new BaseLine(name, baseLineSites[1].EstimateXYZ - baseLineSites[0].EstimateXYZ);

            //---------------------------------------------------------平差计算--------------------------------------------
            //以第一个坐标为近似值
            XYZ aprioriA = pppSitesA[0].EstimateXYZ;
            XYZ aprioriB = pppSitesB[0].EstimateXYZ;

            //构建矩阵,具有约束条件的参数平差中,误差方程和约束方程的未知数相同。
            //参数有6个x0,y0,z0,x1,y1,z1,条件有三个 x1-x0 = a, y1-y0 = b, z1-z0 = c
            double[][] coeff_error  = MatrixUtil.Create((pppSitesA.Count + pppSitesB.Count) * 3, 6);
            double[][] indentity3x3 = MatrixUtil.CreateIdentity(3);
            for (int i = 0; i < pppSitesA.Count; i++)
            {
                MatrixUtil.SetSubMatrix(coeff_error, indentity3x3, i * 3, 0);
            }
            for (int i = 0; i < pppSitesB.Count; i++)
            {
                MatrixUtil.SetSubMatrix(coeff_error, indentity3x3, (pppSitesA.Count + i) * 3, 3);
            }

            //obsMinusApriori
            double[] obsMinusApriori_error = new double[(pppSitesA.Count + pppSitesB.Count) * 3];
            for (int i = 0; i < pppSitesA.Count; i++)
            {
                int rowIndex = i * 3;
                obsMinusApriori_error[rowIndex + 0] = pppSitesA[i].EstimateXYZ.X - aprioriA.X;
                obsMinusApriori_error[rowIndex + 1] = pppSitesA[i].EstimateXYZ.Y - aprioriA.Y;
                obsMinusApriori_error[rowIndex + 2] = pppSitesA[i].EstimateXYZ.Z - aprioriA.Z;
            }
            for (int i = 0; i < pppSitesB.Count; i++)
            {
                int rowIndex = (pppSitesA.Count + i) * 3;
                obsMinusApriori_error[rowIndex + 0] = pppSitesB[i].EstimateXYZ.X - aprioriB.X;
                obsMinusApriori_error[rowIndex + 1] = pppSitesB[i].EstimateXYZ.Y - aprioriB.Y;
                obsMinusApriori_error[rowIndex + 2] = pppSitesB[i].EstimateXYZ.Z - aprioriB.Z;
            }

            //Coeff_Condition,条件有三个 x0-x1 - a = 0,
            //条件方程:c x + w  = 0. => c deltaX + c X0 + w = 0
            double[][] coeff_condition = MatrixUtil.Create(3, 6);
            for (int index = 0; index < 3; index++)
            {
                coeff_condition[index][index + 0] = -1;
                coeff_condition[index][index + 3] = 1;
            }
            //ConstVector_Condition  c deltaX  - W = 0,  W = w - c X0
            double[] obsMinusApriori_condition = new double[3];
            XYZ      aprioriVector             = aprioriB - aprioriA;

            obsMinusApriori_condition[0] = line.Vector.X - aprioriVector.X;
            obsMinusApriori_condition[1] = line.Vector.Y - aprioriVector.Y;
            obsMinusApriori_condition[2] = line.Vector.Z - aprioriVector.Z;

            ParamAdjustmentWithCondition adjust = new ParamAdjustmentWithCondition(coeff_error, obsMinusApriori_error, coeff_condition, obsMinusApriori_condition);

            double[][] param = adjust.Solve();

            //---------------------------------------------------------结果输出--------------------------------------------
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("计算完毕");

            XYZ estA = aprioriA + new XYZ(adjust.ParamVector);
            XYZ estB = aprioriB + new XYZ(adjust.ParamVector[3], adjust.ParamVector[4], adjust.ParamVector[5]);

            sb.AppendLine("近似值A:" + aprioriA);
            sb.AppendLine("平差值A:" + estA);
            sb.AppendLine("近似值B:" + aprioriB);
            sb.AppendLine("平差值B:" + estB);
            sb.AppendLine("条件向量 A->B:" + line.Vector);
            sb.AppendLine("平差向量 A->B:" + (estB - estA));

            sb.AppendLine("------------------------------------参数------------------------------------");
            sb.AppendLine(MatrixUtil.GetFormatedText(param));
            double[][] param2 = adjust.Solve_ToBeCheck();
            sb.AppendLine("param2");
            sb.AppendLine(MatrixUtil.GetFormatedText(param2));


            sb.AppendLine("误差方程系数阵");
            sb.AppendLine(MatrixUtil.GetFormatedText(coeff_error));
            sb.AppendLine("------------------------------------obsMinusApriori------------------------------------");
            sb.AppendLine(MatrixUtil.GetFormatedText(MatrixUtil.Create(obsMinusApriori_error)));
            sb.AppendLine("------------------------------------Coeff_Condition------------------------------------");
            sb.AppendLine(MatrixUtil.GetFormatedText(coeff_condition));
            sb.AppendLine("------------------------------------ConstVector_Condition------------------------------------");
            sb.AppendLine(MatrixUtil.GetFormatedText(MatrixUtil.Create(obsMinusApriori_condition)));
            sb.AppendLine("------------------------------------误差方程法方程------------------------------------");
            sb.AppendLine(MatrixUtil.GetFormatedText(adjust.Normal_error));
            sb.AppendLine("------------------------------------条件方程法方程------------------------------------");
            sb.AppendLine(MatrixUtil.GetFormatedText(adjust.Normal_condition));
            sb.AppendLine("------------------------------------误差方程右手边------------------------------------");
            sb.AppendLine(MatrixUtil.GetFormatedText(adjust.RightHandSide_error));

            this.textBox_info.Text = sb.ToString();

            //----------------------------------------------------地图准备//----------------------------------------------------
            points.Clear();
            GeoCoord c1 = CoordTransformer.XyzToGeoCoord(aprioriA);
            GeoCoord c2 = CoordTransformer.XyzToGeoCoord(aprioriB);
            GeoCoord c3 = CoordTransformer.XyzToGeoCoord(estA);
            GeoCoord c4 = CoordTransformer.XyzToGeoCoord(estB);

            points.Add(new AnyInfo.Geometries.Point(c1.Lon, c1.Lat, "aprA"));
            points.Add(new AnyInfo.Geometries.Point(c2.Lon, c2.Lat, "aprB"));
            points.Add(new AnyInfo.Geometries.Point(c3.Lon, c3.Lat, "estA"));
            points.Add(new AnyInfo.Geometries.Point(c4.Lon, c4.Lat, "estB"));
        }