// Create Milling Elements from string Arr from Excel file public static DataStruct.RoadSection RoadSectionElementsBuilder(string[,] excelDataVariable) { DataStruct.RoadSection roadSection = new DataStruct.RoadSection(); // find dimensions of input arr int row = excelDataVariable.GetLength(0); int col = excelDataVariable.GetLength(1) - 1; for (int rows = 0; rows < row; rows++) { string[] singleRow = new string[col + 1]; //temp variable to hold single row of input data; + 1 because of min milling depth acordint to Geomechanic rec int columns = 0; for (; columns < col; columns++) { singleRow[columns] = excelDataVariable[rows, columns]; // extract single row from input data to temp variable } singleRow[columns] = excelDataVariable[rows, columns]; DataStruct.Cross_section elementsFromSingleRow = ExtractMillingElementsFromSingleRow(singleRow); roadSection.AddCross(elementsFromSingleRow); } return(roadSection); }
private static DataStruct.Cross_section ExtractMillingElementsFromSingleRow(string[] singleRow) { List <DataStruct.MillingElement> singleRowMillingElements = new List <DataStruct.MillingElement>(); int rowLength = singleRow.GetLength(0) - 1; // - 1 to use old code and take min milling depth from geomechanic double station = Convert.ToDouble(singleRow[0]); string profilName = singleRow[1]; if (profilName == "10") { Console.WriteLine(); } int iterationEnd = (rowLength - 4) / 2 + 2 - 1; double crossSectionWidth = Convert.ToDouble(singleRow[rowLength - 2]); double elementWidth = crossSectionWidth / (iterationEnd - 2); // distance between two points wiht elevation double projLayerThick = Convert.ToDouble(singleRow[rowLength - 1]); // Thickness of project asphalt layers double allowableMinMillingDepth = 0; // Min alloable milling depth according to geomechanic double.TryParse(singleRow[rowLength], out allowableMinMillingDepth); //if thre is value take the value or just pass 0 double leftEdgeProjectLevel = 0; double midProjectLevel = 0; double rightProjectLevel = 0; for (int i = 2; i < iterationEnd; i++) { double existStartLevel; double projStartLevel; double existEndLevel; double projEndLevel; existStartLevel = Convert.ToDouble(singleRow[i]); projStartLevel = Convert.ToDouble(singleRow[i + 5]); existEndLevel = Convert.ToDouble(singleRow[i + 1]); projEndLevel = Convert.ToDouble(singleRow[i + 6]); double elementStart = elementWidth * (i - 2) * (-1); List <DataStruct.MillingElement> tempListMillingElems = ConvertToMillingElemets(existStartLevel, projStartLevel, existEndLevel, projEndLevel, elementWidth, projLayerThick, station, profilName, elementStart, allowableMinMillingDepth); foreach (var item in tempListMillingElems) { singleRowMillingElements.Add(item); } if (i == 2) { leftEdgeProjectLevel = projStartLevel; } if (i == 4) { midProjectLevel = projStartLevel; } if (i == 5) { rightProjectLevel = projEndLevel; } } // Element to return DataStruct.Cross_section tempCrossSection = new DataStruct.Cross_section(profilName, station, leftEdgeProjectLevel, rightProjectLevel, midProjectLevel, crossSectionWidth, singleRowMillingElements); tempCrossSection.ProjLayerThick = projLayerThick; return(tempCrossSection); }