public List <string> MainAction(List <string> dataFromFile, List <string[]> HeightCorrect, bool IsGSI_16) { List <string> result = new List <string>(); List <string> middle = new List <string>(); Station station = new Station(); foreach (var item in dataFromFile) { if (item.Contains("41") & item.Contains("?...")) { station.AllMoveDistance = 0; station.ComulativeSholders = 0; station.ComulativeStationDifference = 0; station.GroundHeight = 0; middle.Clear(); } if (item.Contains("571.08") && item.Contains("83..08")) { middle.Add(item); result.AddRange(RecaculateStation(middle, HeightCorrect, station, IsGSI_16)); middle.Clear(); continue; } middle.Add(item); } return(CONVERT.ChangeNumeric(result, IsGSI_16)); }
static public List <string> CreateFile(List <string> data, bool IsGSI_16) { List <string> result = new List <string>(); int currentCountLine = 0; int startCountLine = 0; string[] forCopy; foreach (var item in data) { if (currentCountLine == 0 & item.Contains("41") && item.Contains("?...")) { currentCountLine++; continue; } if (currentCountLine > 0 & item.Contains("41") && item.Contains("?...")) { if (startCountLine > 0) { currentCountLine -= 1; forCopy = new string[currentCountLine - startCountLine]; data.CopyTo(startCountLine, forCopy, 0, currentCountLine - startCountLine); result.AddRange(DivideIn2Move(forCopy, IsGSI_16).Item1); result.AddRange(DivideIn2Move(forCopy, IsGSI_16).Item2); startCountLine = currentCountLine; currentCountLine++; } else { forCopy = new string[currentCountLine - startCountLine]; data.CopyTo(startCountLine, forCopy, 0, currentCountLine - startCountLine); result.AddRange(DivideIn2Move(forCopy, IsGSI_16).Item1); result.AddRange(DivideIn2Move(forCopy, IsGSI_16).Item2); startCountLine = currentCountLine; currentCountLine++; } } if (currentCountLine == data.Count) { forCopy = new string[currentCountLine - startCountLine]; data.CopyTo(startCountLine, forCopy, 0, currentCountLine - startCountLine); result.AddRange(DivideIn2Move(forCopy, IsGSI_16).Item2); result.AddRange(DivideIn2Move(forCopy, IsGSI_16).Item1); startCountLine = currentCountLine; currentCountLine++; } currentCountLine++; } if (result.Count == 0) { forCopy = new string[currentCountLine - startCountLine]; data.CopyTo(startCountLine, forCopy, 0, currentCountLine - startCountLine); result.AddRange(DivideIn2Move(forCopy, IsGSI_16).Item1); result.AddRange(DivideIn2Move(forCopy, IsGSI_16).Item2); } return(CONVERT.ChangeNumeric(result, IsGSI_16)); }
static private List <string> Recalculate(List <string> data, bool IsGSI_16) { int count = 1; List <string> result = new List <string>(); Station station = new Station(); foreach (var item in data) { if (item.Contains("41") && item.Contains("?...")) { result.Add(item); continue; } if (item.Contains("83..") && !item.Contains("571.08")) { station.GroundHeight = GET.GroundHeight(item); result.Add(CONVERT.ChangeValueInLine(GET.PointName(item), station.GroundHeight, IsGSI_16)); } if (item.Contains("32...8")) { if (count == 1) { result.Add(item.Replace(" 336.08", " 331.08")); station.RearPointName = GET.PointName(item); station.RearPointDistance = GET.Distance(item); station.RearLevelHeight = GET.LevelHeight(item); count++; continue; } if (count == 2) { result.Add(item.Replace(" 335.08", " 332.08")); station.FrontPointName = GET.PointName(item); station.FrontPointDistance = GET.Distance(item); station.FrontLevelHeight = GET.LevelHeight(item); count = 1; continue; } } if (item.Contains("571.08") && item.Contains("83..")) { station.AllMoveDistance += station.RearPointDistance + station.FrontPointDistance; station.ComulativeSholders += station.RearPointDistance - station.FrontPointDistance; station.GroundHeight += station.RearLevelHeight - station.FrontLevelHeight; station.StationDifference = (int)GET.IntroductionError(7); station.ComulativeStationDifference += station.StationDifference; result.Add(CONVERT.ToStationStringBuilder(station, IsGSI_16, true)); } } return(result); }
//static public string ToStationStringBuilder(Station station, bool IsGSI_16) //{ // string result = $"110001+{CONVERT.ToFormateGSI(station.FrontPointName, IsGSI_16)} 571.08{CONVERT.ToFormateGSI(station.StationDifference, IsGSI_16)} 572.08{CONVERT.ToFormateGSI(station.ComulativeStationDifference, IsGSI_16)} 573.08{CONVERT.ToFormateGSI(station.ComulativeSholders, IsGSI_16)} 574.08{CONVERT.ToFormateGSI(station.AllMoveDistance, IsGSI_16)} 83..08{CONVERT.ToFormateGSI(station.GroundHeight, IsGSI_16)} "; // return result; //} static public string ToStationStringBuilder(Station station, bool IsGSI_16, bool IsBBFF = false) { string result = string.Empty; if (IsBBFF) { result = $"110001+{CONVERT.ToFormateGSI(station.FrontPointName, IsGSI_16)} 573.08{CONVERT.ToFormateGSI(station.ComulativeSholders, IsGSI_16)} 574.08{CONVERT.ToFormateGSI(station.AllMoveDistance, IsGSI_16)} 83..08{CONVERT.ToFormateGSI(station.GroundHeight, IsGSI_16)} "; } else { result = $"110001+{CONVERT.ToFormateGSI(station.FrontPointName, IsGSI_16)} 571.08{CONVERT.ToFormateGSI(station.StationDifference, IsGSI_16)} 572.08{CONVERT.ToFormateGSI(station.ComulativeStationDifference, IsGSI_16)} 573.08{CONVERT.ToFormateGSI(station.ComulativeSholders, IsGSI_16)} 574.08{CONVERT.ToFormateGSI(station.AllMoveDistance, IsGSI_16)} 83..08{CONVERT.ToFormateGSI(station.GroundHeight, IsGSI_16)} "; } return(result); }
public List <string> RecaculateStation(List <string> DataStationFromFile, List <string[]> HeightCorrect, Station station, bool IsGSI_16) { List <string> result = new List <string>(); List <string> middle = new List <string>(); int row = 1; int correctRearValue; int correctFrontValue; foreach (var item in DataStationFromFile) { if (item.Contains("41") && item.Contains("?...")) { result.Add(item); continue; } if (item.Contains("83..") && !item.Contains("571.08")) { station.GroundHeight = GET.GroundHeight(item); result.Add(item); } if (item.Contains("32...8")) { if (row == 1) { station.RearPointName = GET.PointName(item); station.RearPointDistance = GET.Distance(item); correctRearValue = GET.CorrectValue(HeightCorrect, station.RearPointName); station.StationHeight = GetStationHeight(GET.LevelHeight(item), GET.LevelHeight(DataStationFromFile[DataStationFromFile.IndexOf(item) + 1])); var SpecialRearH = GET.LevelHeight(DataStationFromFile[DataStationFromFile.IndexOf(item) + 3]); station.RearLevelHeight = (GET.LevelHeight(item) + SpecialRearH) / 2 - correctRearValue + station.StationHeight; station.MeasureSKO = GET.SKO(item); middle.Add(CONVERT.ToStationStringBuilder(station.RearPointName, station.RearPointDistance, "331.08", station.RearLevelHeight, 3, station.MeasureSKO, IsGSI_16)); row++; continue; } if (row == 2) { station.FrontPointName = GET.PointName(item); station.FrontPointDistance = GET.Distance(item); station.MeasureSKO = GET.SKO(item); correctFrontValue = GET.CorrectValue(HeightCorrect, station.FrontPointName); int SpecialFrontH = GET.LevelHeight(DataStationFromFile[DataStationFromFile.IndexOf(item) + 1]); station.FrontLevelHeight = (GET.LevelHeight(item) + SpecialFrontH) / 2 - correctFrontValue + station.StationHeight; middle.Add(CONVERT.ToStationStringBuilder(station.FrontPointName, station.FrontPointDistance, "332.08", station.FrontLevelHeight, 3, station.MeasureSKO, IsGSI_16)); row++; continue; } if (row == 3) { station.SpetialFrontPointDistance = GET.Distance(item); station.MeasureSKO = GET.SKO(item); station.SpetialFrontLevelHeight = station.FrontLevelHeight; middle.Add(CONVERT.ToStationStringBuilder(station.FrontPointName, station.SpetialFrontPointDistance, "336.08", station.SpetialFrontLevelHeight, 3, station.MeasureSKO, IsGSI_16)); row++; continue; } if (row == 4) { station.SpetialRearPointDistance = GET.Distance(item); station.MeasureSKO = GET.SKO(item); station.SpetialRearLevelHeight = station.RearLevelHeight; station.StationHeight = 0; middle.Add(CONVERT.ToStationStringBuilder(station.RearPointName, station.SpetialRearPointDistance, "335.08", station.SpetialRearLevelHeight, 3, station.MeasureSKO, IsGSI_16)); row = 1; continue; } } middle.Add(item); } station.GroundHeight += ((station.RearLevelHeight - station.FrontLevelHeight) + (station.SpetialRearLevelHeight - station.SpetialFrontLevelHeight)) / 2; foreach (var item in middle) { if (item.Contains("32...8")) { if (row == 1) { result.Add(CONVERT.ChangeValueInLine(item, station.RearPointDistance, station.RearLevelHeight, "331.08", IsGSI_16)); row++; continue; } if (row == 2) { result.Add(CONVERT.ChangeValueInLine(item, station.FrontPointDistance, station.FrontLevelHeight, "332.08", IsGSI_16)); row++; continue; } if (row == 3) { result.Add(CONVERT.ChangeValueInLine(item, station.SpetialFrontPointDistance, station.SpetialFrontLevelHeight, "336.08", IsGSI_16)); row++; continue; } if (row == 4) { result.Add(CONVERT.ChangeValueInLine(item, station.SpetialRearPointDistance, station.SpetialRearLevelHeight, "335.08", IsGSI_16)); row = 1; continue; } } if (item.Contains("571.08") && item.Contains("83..08")) { result.Add(CONVERT.ToStationStringBuilder(item, station.GroundHeight, IsGSI_16)); } } return(result); }
public List <string> RecaculateStation(List <string> DataStationFromFile, List <string[]> HeightCorrect, Station station, double sigma, bool IsGSI_16) { List <string> result = new List <string>(); List <string> middle = new List <string>(); int row = 1; int correctRearValue; int correctFrontValue; foreach (var item in DataStationFromFile) { if (item.Contains("41") && item.Contains("?...")) { result.Add(item); continue; } if (item.Contains("83..") && !item.Contains("571.08")) { station.GroundHeight = GET.GroundHeight(item); result.Add(CONVERT.ChangeValueInLine(GET.PointName(item), station.GroundHeight, IsGSI_16)); } if (item.Contains("32...8")) { if (row == 1) { station.RearPointName = GET.PointName(item); station.RearPointDistance = GET.Distance(item); correctRearValue = GET.CorrectValue(HeightCorrect, station.RearPointName); station.StationHeight = GetStationHeight(GET.LevelHeight(item), GET.LevelHeight(DataStationFromFile[DataStationFromFile.IndexOf(item) + 1])); station.MeasureError = (int)(GET.IntroductionError(sigma) * 100); var SpecialRearH = GET.LevelHeight(DataStationFromFile[DataStationFromFile.IndexOf(item) + 3]); station.RearLevelHeight = (GET.LevelHeight(item) + SpecialRearH) / 2 - correctRearValue + station.StationHeight + station.MeasureError; station.MeasureSKO = (int)(GET.IntroductionError(0.1) * 100); middle.Add(CONVERT.ToStationStringBuilder(station.RearPointName, station.RearPointDistance, "331.08", station.RearLevelHeight, 3, station.MeasureSKO, IsGSI_16)); row++; continue; } if (row == 2) { station.FrontPointName = GET.PointName(item); station.FrontPointDistance = GET.Distance(item); correctFrontValue = GET.CorrectValue(HeightCorrect, station.FrontPointName); int SpecialFrontH = GET.LevelHeight(DataStationFromFile[DataStationFromFile.IndexOf(item) + 1]); station.MeasureError = (int)(GET.IntroductionError(sigma) * 100); station.FrontLevelHeight = (GET.LevelHeight(item) + SpecialFrontH) / 2 - correctFrontValue + station.MeasureError + station.StationHeight; station.MeasureSKO = (int)(GET.IntroductionError(0.1) * 100); middle.Add(CONVERT.ToStationStringBuilder(station.FrontPointName, station.FrontPointDistance, "332.08", station.FrontLevelHeight, 3, station.MeasureSKO, IsGSI_16)); row++; continue; } if (row == 3) { station.SpetialFrontPointDistance = GET.Distance(item); var rnd = new Random(); int value = rnd.Next(-45, 45); station.SpetialFrontLevelHeight = station.FrontLevelHeight + value; station.MeasureSKO = (int)(GET.IntroductionError(0.1) * 100); middle.Add(CONVERT.ToStationStringBuilder(station.FrontPointName, station.SpetialFrontPointDistance, "336.08", station.SpetialFrontLevelHeight, 3, station.MeasureSKO, IsGSI_16)); row++; continue; } if (row == 4) { station.SpetialRearPointDistance = GET.Distance(item); var rnd = new Random(); int value = rnd.Next(-45, 45); station.SpetialRearLevelHeight = station.RearLevelHeight + value; station.StationHeight = 0; station.MeasureSKO = (int)(GET.IntroductionError(0.1) * 100); middle.Add(CONVERT.ToStationStringBuilder(station.RearPointName, station.SpetialRearPointDistance, "335.08", station.SpetialRearLevelHeight, 3, station.MeasureSKO, IsGSI_16)); row = 1; continue; } } middle.Add(item); } int NewDistance = ((station.RearPointDistance + station.FrontPointDistance + station.SpetialFrontPointDistance + station.SpetialRearPointDistance) / 2) + (int)(GET.IntroductionError(900) * 1000); int SholderError = (int)(GET.IntroductionError(900) * 1000); station.RearPointDistance = NewDistance / 2 + SholderError; station.FrontPointDistance = NewDistance / 2 - SholderError; station.SpetialFrontPointDistance = station.FrontPointDistance + (int)(GET.IntroductionError(3) * 50); station.SpetialRearPointDistance = station.RearPointDistance + (int)(GET.IntroductionError(3) * 50); station.AllMoveDistance += (station.RearPointDistance + station.FrontPointDistance + station.SpetialRearPointDistance + station.SpetialFrontPointDistance) / 2; station.ComulativeSholders += ((station.RearPointDistance - station.FrontPointDistance) + (station.SpetialRearPointDistance - station.SpetialFrontPointDistance)) / 2; station.GroundHeight += ((station.RearLevelHeight - station.FrontLevelHeight) + (station.SpetialRearLevelHeight - station.SpetialFrontLevelHeight)) / 2; station.StationDifference = (int)GET.IntroductionError(7); station.ComulativeStationDifference += station.StationDifference; foreach (var item in middle) { if (item.Contains("32...8")) { if (row == 1) { result.Add(CONVERT.ChangeValueInLine(item, station.RearPointDistance, station.RearLevelHeight, "331.08", IsGSI_16)); row++; continue; } if (row == 2) { result.Add(CONVERT.ChangeValueInLine(item, station.FrontPointDistance, station.FrontLevelHeight, "332.08", IsGSI_16)); row++; continue; } if (row == 3) { result.Add(CONVERT.ChangeValueInLine(item, station.SpetialFrontPointDistance, station.SpetialFrontLevelHeight, "336.08", IsGSI_16)); row++; continue; } if (row == 4) { result.Add(CONVERT.ChangeValueInLine(item, station.SpetialRearPointDistance, station.SpetialRearLevelHeight, "335.08", IsGSI_16)); row = 1; continue; } } if (item.Contains("571.08") && item.Contains("83..08")) { result.Add(CONVERT.ToStationStringBuilder(station, IsGSI_16)); } } return(result); }
static public string ChangeValueInLine(string pointName, int groundHeight, bool IsGSI_16) { string result = $"110001+{CONVERT.ToFormateGSI(pointName, IsGSI_16)} 83..08{CONVERT.ToFormateGSI(groundHeight, IsGSI_16)} "; return(result); }
static public string ChangeValueInLine(string rowData, int distance, int levelHeigth, string code, bool IsGSI_16) { string result = new Regex(@"32\.\.\.8(.*?)\s").Replace(rowData, $"32...8{CONVERT.ToFormateGSI(distance, IsGSI_16)} "); return(new Regex(@"33\d\.08(.*?)\s").Replace(result, $"{code}{CONVERT.ToFormateGSI(levelHeigth, IsGSI_16)} ")); }
static public string ToStationStringBuilder(string pointName, int distance, string code, int levelHeight, int measureCount, int measureSKO, bool IsGSI_16) { string result = $"110001+{CONVERT.ToFormateGSI(pointName, IsGSI_16)} 32...8{CONVERT.ToFormateGSI(distance, IsGSI_16)} {code}{CONVERT.ToFormateGSI(levelHeight, IsGSI_16)} 390...{CONVERT.ToFormateGSI(measureCount, IsGSI_16)} 391.08{CONVERT.ToFormateGSI(measureSKO, IsGSI_16)} "; return(result); }
private async void start_btn_Click(object sender, EventArgs e) { if (data.Count == 0) { if (MessageBox.Show("Необходимо импортировать файл", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK) { return; } } start_btn.Visible = false; label1.Visible = true; start_btn.Enabled = false; settingForm.dataGridView1.Enabled = false; List <string[]> dataGrid = new List <string[]>(); foreach (var item in settingForm.dataGridView1.Rows) { if ((item as DataGridViewRow).Cells[0].Value == null) { continue; } dataGrid.Add(new string[2] { (item as DataGridViewRow).Cells[0].Value.ToString(), (item as DataGridViewRow).Cells[1].Value.ToString() }); } Implementations implementations = new Implementations(); if (!CONVERT.IsBFFB(data)) { data = CONVERT.ToBFFB(data); } if (IsImplementSKO) { var ResultData = await Task.Run(() => implementations.MainAction(data, dataGrid, 0.2, IsGSI_16)); implementations.SaveFile(ResultData, OpenFile, Implementations.SaveFileType.CHANGED); if (IsCredoCreated) { var res = await Task.Factory.StartNew(() => ForCredo.CreateFile(ResultData, IsGSI_16)); implementations.SaveFile(res, OpenFile, Implementations.SaveFileType.CD31); } } else { data = implementations.MainAction(data, dataGrid, IsGSI_16); implementations.SaveFile(data, OpenFile, Implementations.SaveFileType.CHANGED); } if (IsCredoCreated) { var res = await Task.Factory.StartNew(() => ForCredo.CreateFile(data, IsGSI_16)); implementations.SaveFile(res, OpenFile, Implementations.SaveFileType.CD31); } if (!IsCredoCreated && !IsImplementSKO) { MessageBox.Show("Функция изменения формата работает только при создании файла для CREDO или Внесения СКО", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } settingForm.dataGridView1.Enabled = true; settingForm.dataGridView1.Rows.Clear(); data.Clear(); start_btn.Enabled = true; start_btn.Visible = true; label1.Visible = false; }