/// <summary> /// 查找所有的三角回路 /// </summary> /// <param name="lineNames"></param> /// <param name="siteNames"></param> /// <returns></returns> public static List <TriangularNetName> BuildTriangularNetNames(List <GnssBaseLineName> lineNames, List <string> siteNames) { var length = lineNames.Count; List <TriangularNetName> list = new List <TriangularNetName>(); foreach (var line in lineNames) { foreach (var site in siteNames) { if (line.Contains(site)) { continue; } var lineA = new GnssBaseLineName(line.RefName, site); var lineB = new GnssBaseLineName(line.RovName, site); if (GnssBaseLineName.ContainsOrReversedContains(lineNames, lineA) && GnssBaseLineName.ContainsOrReversedContains(lineNames, lineB) ) { var net = new TriangularNetName(line, site); list.Add(net); } } } var result = list.Distinct().ToList(); return(result); }
/// <summary> /// 移除基线 /// </summary> /// <param name="line"></param> public void Remove(GnssBaseLineName line) { foreach (var item in this.KeyValues) { item.Value.Remove(line); } }
/// <summary> /// 这条基线是否合限,原理:如果所有都超限了,则肯定超限如果有合限的,则合限。 /// </summary> /// <param name="line"></param> /// <returns></returns> public QualityOfTriAngleClosureError GetBest(GnssBaseLineName line) { var lines = this.Get(line); if (lines.Count == 0) { return(null); } lines.Sort(); return(lines[0]); }
/// <summary> /// 这条基线是否合限,原理:如果所有都超限了,则肯定超限如果有合限的,则合限。 /// </summary> /// <param name="line"></param> /// <returns></returns> public BaseLineNet GetBest(GnssBaseLineName line) { var lines = this.Get(line); if (lines.Count == 0) { return(null); } lines.Sort(); return(lines[0]); }
/// <summary> /// 获取第一个匹配的结果 /// </summary> /// <param name="lineName"></param> /// <returns></returns> public EstimatedBaseline GetFirst(GnssBaseLineName lineName) { foreach (var item in this) { var line = item.GetOrReversed(lineName); if (line != null) { return(line); } } return(null); }
/// <summary> /// 获取基线或者反基线 /// </summary> /// <param name="line"></param> /// <returns></returns> public EstimatedBaseline GetBaseLineOrReversed(GnssBaseLineName line) { foreach (var item in this.KeyValues) { var estLine = item.Value.GetOrReversed(line); if (estLine != null) { return(estLine); } } return(null); }
/// <summary> /// 获取包含的三角网 /// </summary> /// <param name="line"></param> /// <returns></returns> public List <BaseLineNet> Get(GnssBaseLineName line) { List <BaseLineNet> nets = new List <BaseLineNet>(); foreach (var item in this.KeyValues) { if (item.Key.Contains(line)) { nets.Add(item.Value); } } return(nets); }
/// <summary> /// 获取包含的三角网 /// </summary> /// <param name="line"></param> /// <returns></returns> public List <QualityOfTriAngleClosureError> Get(GnssBaseLineName line) { List <QualityOfTriAngleClosureError> nets = new List <QualityOfTriAngleClosureError>(); foreach (var item in this.KeyValues) { if (item.Key.Contains(line)) { nets.Add(item.Value); } } return(nets); }
/// <summary> /// 获取所有时段的同名基线对象 /// </summary> /// <param name="lineName"></param> /// <returns></returns> public List <SiteObsBaseline> GetLines(GnssBaseLineName lineName) { List <SiteObsBaseline> result = new List <SiteObsBaseline>(); foreach (var item in this) { if (item.Contains(lineName)) { result.Add(item.Get(lineName)); } } return(result); }
/// <summary> /// 初始化,读取赋值 /// </summary> public void Init() { if (ObsFilesPaths.Length <= 0) { throw new Exception("选择独立基线前,请配置好观测数据!"); } //初始化 DataOfAllSites = new SiteEpochSatData[ObsFilesPaths.Length]; RinexFileObsDataSource RinexFileObsDataSource = new Data.Rinex.RinexFileObsDataSource(ObsFilesPaths[0], false); //加载读取全部文件 List <ISingleSiteObsStream> obsDataSources = RinexFileObsDataSource.LoadObsData(ObsFilesPaths); int siteNumberCount = 0; foreach (var obsData in obsDataSources) { SiteEpochSatData siteEpochSatData = new SiteEpochSatData(); siteEpochSatData.Path = obsData.Path; siteEpochSatData.SiteName = GnssBaseLineName.GetSiteName(obsData.Path);// obsData.SiteInfo.MarkerName.ToUpper(); siteEpochSatData.SiteNumber = siteNumberCount; siteEpochSatData.PrnInfo = new string[2880]; siteEpochSatData.TimeInfo = new double[2880]; int jj = 0; foreach (var item in obsData) { double seconds = item.ReceiverTime.Hour * 60 * 60 + item.ReceiverTime.Minute * 60 + item.ReceiverTime.Seconds; double seconds1 = item.ReceiverTime.SecondsOfDay; if (seconds != seconds1) { throw new Exception("单基线选取中时间统计出错!"); } string prnStr = null; foreach (var prn in item.TotalPrns) { prnStr += prn.ToString(); } if (prnStr != null) { siteEpochSatData.TimeInfo[jj] = seconds; siteEpochSatData.PrnInfo[jj] = prnStr; jj++; } } DataOfAllSites[siteNumberCount] = siteEpochSatData; siteNumberCount++; } }
/// <summary> /// 计算权 /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <returns></returns> public override double GetWeight(INode start, INode end) { var lineName = new GnssBaseLineName(start.Id, end.Id); var est = BaseLineNet.GetOrReversed(lineName); if (est == null) { return(double.MaxValue); } //此路不通 switch (IndependentLineSelectType) { case IndependentLineSelectType.距离最短: return(est.EstimatedVector.Length); break; case IndependentLineSelectType.RMS最小: return(est.StdDev); //.EstimatedRmsXyzOfRov.Rms.Length; break; case IndependentLineSelectType.闭合差最小: //如果没有,则返回一个大值 var quality = CurrentQualityManager.GetBest(lineName); if (quality != null) { return(quality.ClosureError.Value.Length); } return(double.MaxValue); break; default: return(est.EstimatedVector.Length); break; } }
private void SingleRun(List <string> failedPathes, GnssBaseLineName baselines) { IntegralGnssFileSolver Solver = null; string baseline = baselines.ToString(); #if !DEBUG try { #endif Solver = BuildSolver(baselines.RefFilePath, baselines.RovFilePath); this.InitProcess(Solver.Context.ObservationDataSource.ObsInfo.Count); Solver.ResultProduced += Solver_ResultProduced; Solver.Completed += Solver_Completed; Run(Solver); #if !DEBUG } catch (Exception ex) { if (BuildSolverAndRun(baseline)) { failedPathes.Add(baseline); } var roverMsg = ""; if (Solver != null) { roverMsg = Solver.Current + ""; } var msg = Solver + baseline + ", " + roverMsg + ", 计算发生致命错误:" + ex.Message; log.Fatal(msg); if (Setting.GnsserConfig.IsDebug) { ex.Data["GNSSerMsg"] = msg; throw ex; } } #endif }
/// <summary> /// 构造函数 /// </summary> /// <param name="LineName"></param> /// <param name="RmsedXYZ"></param> public BaseLineRepeatError(GnssBaseLineName LineName, RmsedXYZ RmsedXYZ) { this.LineName = LineName; this.RmsedXYZ = RmsedXYZ; }
// public Dictionary<string, SiteEpochSatData> DataOfAllSites = new Dictionary<string, SiteEpochSatData>(); #endregion public void IndepentBaselineProcess() { //存储基线 Dictionary <string, Edge> graphRound = new Dictionary <string, Edge>(); int n = DataOfAllSites.Length; mgraph = new MGraph(); mgraph.n = n; mgraph.e = n * (n - 1) / 2; mgraph.vex = new VertexType[n]; mgraph.edges = new int[n][]; road = new Road[n * (n - 1) / 2]; v = new int[n * (n - 1) / 2]; int ii = 0; for (int i = 0; i < n; i++) { // SiteEpochSatData dataA = DataOfAllSites.ElementAt(i).Value; SiteEpochSatData dataA = DataOfAllSites[i]; mgraph.vex[i] = new VertexType(); mgraph.vex[i].no = i; mgraph.vex[i].name = dataA.SiteName; v[i] = i; //顶点ver[i]初始时表示各在不同的连通分支v[i]中,父结点依次为v[i] for (int j = i + 1; j < n; j++) { mgraph.edges[i] = new int[n]; SiteEpochSatData dataB = DataOfAllSites[j]; //.ElementAt (j).Value; double toleranceSeccond = 3.5; //限差 单位:秒 int count = 0; //for (int k = 0, s = 0; k < dataA.TimeInfo.Length.Data.Count && s < dataB.Data.Count; k++, s++) for (int k = 0, s = 0; k < dataA.TimeInfo.Length && s < dataB.TimeInfo.Length; k++, s++) { //double diff = Math.Abs(dataA.Data.ElementAt(k).Key - dataB.Data.ElementAt(s).Key); double diff = Math.Abs(dataA.TimeInfo[k] - dataB.TimeInfo[s]); if (diff <= toleranceSeccond) { //IEnumerable<int> strB = dataB.EpochSatData.ElementAt(s).Value; string strA = dataA.PrnInfo[k]; string strB = dataB.PrnInfo[s]; if (strA == null || strB == null) { break; } for (int ss = 0; ss < strA.Length / 3; ss++) { string prn = strA.Substring(ss * 3, 3); if (strB.Contains(prn)) // if (strB.IndexOf(prn)!=-1) //即含有 { count += 1; } } } else { // if (dataB.Data.ElementAt(s).Key < dataA.Data.ElementAt(k).Key) if (dataB.TimeInfo[s] < dataA.TimeInfo[k]) { while (diff > toleranceSeccond) { s++; if (s >= dataB.TimeInfo.Length) { break; } //diff = Math.Abs(dataA.Data.ElementAt(k).Key - dataB.Data.ElementAt(s).Key); diff = Math.Abs(dataA.TimeInfo[k] - dataB.TimeInfo[s]); if (diff <= toleranceSeccond) { string strA = dataA.PrnInfo[k]; string strB = dataB.PrnInfo[s]; if (strA == null || strB == null) { break; } for (int ss = 0; ss < strA.Length / 3; ss++) { string prn = strA.Substring(ss * 3, 3); if (strB.Contains(prn)) { count += 1; } } break; } } } else if (dataB.TimeInfo[s] > dataA.TimeInfo[k]) { while (diff > toleranceSeccond) { k++; if (k >= dataA.TimeInfo.Length) { break; } diff = Math.Abs(dataA.TimeInfo[k] - dataB.TimeInfo[s]); if (diff <= toleranceSeccond) { string strA = dataA.PrnInfo[k]; string strB = dataB.PrnInfo[s]; if (strA == null || strB == null) { break; } for (int ss = 0; ss < strA.Length / 3; ss++) { string prn = strA.Substring(ss * 3, 3); if (strB.Contains(prn)) { count += 1; } } break; } } } } } //End 完成一条基线的统计 mgraph.edges[i][j] = count; road[ii] = new Road(); road[ii].a = i; road[ii].b = j; road[ii].w = count; ii++; ////写入 //string sb = dataA.SiteName + "-" + dataB.SiteName + " " + count.ToString(); //writer.WriteLine(sb); Node NodeA = new Node(); NodeA.Name = dataA.SiteNumber; NodeA.strName = dataA.SiteName; NodeA.Visited = false; NodeA.Tag = dataA.Path; Node NodeB = new Node(); NodeB.Name = dataB.SiteNumber; NodeB.strName = dataB.SiteName; NodeB.Visited = false; NodeB.Tag = dataB.Path; Edge edge = new Edge(); edge.NodeA = NodeA; edge.NodeB = NodeB; edge.Weight = count; string baselineName = dataA.SiteName + dataB.SiteName; graphRound.Add(baselineName, edge); } } //sort 排序 由大到小 List <KeyValuePair <string, Edge> > graphPair = new List <KeyValuePair <string, Edge> >(graphRound); graphPair.Sort(delegate(KeyValuePair <string, Edge> s1, KeyValuePair <string, Edge> s2) { return(s1.Value.Weight.CompareTo(s2.Value.Weight)); }); //存储排序基线 Dictionary <string, Edge> graph = new Dictionary <string, Edge>(); for (int index = graphPair.Count - 1; index >= 0; index--) { var item = graphPair.ElementAt(index); Edge edge = new Edge(); edge.NodeA = item.Value.NodeA; edge.NodeB = item.Value.NodeB; edge.Weight = item.Value.Weight; graph.Add(item.Key, edge); //重新排序 road[mgraph.e - 1 - index].a = DataOfAllSites[item.Value.NodeA.Name].SiteNumber; road[mgraph.e - 1 - index].b = DataOfAllSites[item.Value.NodeB.Name].SiteNumber; road[mgraph.e - 1 - index].w = item.Value.Weight; } //根据Kruskal算法生成最小生成树 GetMinCostSpanTree List <Edge> findedMinCostSpanTree = new List <Edge>(); List <List <Node> > findedNodes = new List <List <Node> >(); findedNodes.Add(new List <Node>() { graph.ElementAt(0).Value.NodeA, graph.ElementAt(0).Value.NodeB }); findedMinCostSpanTree.Add(graph.ElementAt(0).Value); for (int index = 1; index < graph.Count; index++) { var item = graph.ElementAt(index); int i = 0, indexA = -1, indexB = -1; Node nodeA = item.Value.NodeA; Node nodeB = item.Value.NodeB; foreach (var nodes in findedNodes) { foreach (var node in nodes) { if (!item.Value.NodeB.Visited && node.Name == nodeB.Name && node.Visited == nodeB.Visited) { item.Value.NodeB.Visited = true; indexB = i; } if (!item.Value.NodeA.Visited && node.Name == nodeA.Name && node.Visited == nodeA.Visited) { item.Value.NodeA.Visited = true; indexA = i; } } i++; } // if (item.Value.NodeA.Visited && item.Value.NodeB.Visited && (indexA != indexB)) { //连接不同的联通分量,则这两个连通分量可以合并成一个了。 int minId = Math.Min(indexA, indexB); int maxId = Math.Max(indexA, indexB); findedNodes[minId].AddRange(findedNodes[maxId]); findedNodes.RemoveAt(maxId); findedMinCostSpanTree.Add(item.Value); } else if (!item.Value.NodeA.Visited && !item.Value.NodeB.Visited) { //都不包含,直接添加新列表 findedNodes.Add(new List <Node>() { nodeA, nodeB }); findedMinCostSpanTree.Add(item.Value); } else if (item.Value.NodeA.Visited && !item.Value.NodeB.Visited) { //包含A,则将B添加到A的集合中去 findedNodes[indexA].Add(nodeB); findedMinCostSpanTree.Add(item.Value); } else if (!item.Value.NodeA.Visited && item.Value.NodeB.Visited) { //包含B,则将A添加到B的集合中去 findedNodes[indexB].Add(nodeA); findedMinCostSpanTree.Add(item.Value); } item.Value.NodeA.Visited = false; item.Value.NodeB.Visited = false; } //writer.WriteLine("\n"); //writer.WriteLine("根据最大观测量选择的独立基线: "); int jj = 0; IndepentBaselinesInfo = new List <GnssBaseLineName>(); foreach (var item in findedMinCostSpanTree) { var tmp = new GnssBaseLineName(item.NodeA.strName, item.NodeB.strName) { RefFilePath = item.NodeA.Tag + "", RovFilePath = item.NodeB.Tag + "", } ; // + BaseLineSplitter + item.NodeB.strName;// + " " + key.Weight; IndepentBaselinesInfo.Add(tmp); //写入 //writer.WriteLine(tmp); jj++; } //writer.Close(); //关闭 }
/// <summary> /// 移除 /// </summary> /// <param name="name"></param> public void Remove(GnssBaseLineName name) { // this.ObsFileManager.Remove(name); //移除基线 BaseLineManager.Remove(name); }
/// <summary> /// 包含基线否 /// </summary> /// <param name="baseLineName"></param> /// <returns></returns> public bool Contains(GnssBaseLineName baseLineName) { return(Contains(baseLineName.RefName) && Contains(baseLineName.RovName)); }