src/AircraftTrajectories/Models/TemporalGrid/TemporalGridFileReader.cs
/// <summary>
/// Converts the generic input file into a grid of values
/// </summary>
/// <param name="genericData"></param>
/// <returns></returns>
Converts the generic input file into a grid of values
Converts the generic input file into a grid of values
protected Grid GenericDataToGrid(double[][] genericData, int dataColumnIndex)
        {
            double[][] genericDataGrid = { };
            double currentX = genericData[0][0];
            List<double> column = new List<double>();
            int columnIndex = 0;
            for (int i = 0; i < genericData.Length - 1; i++)
            {
                if (currentX != genericData[i][0])
                {
                    if (columnIndex == 0)
                    {
                        int numberOfColumns = genericData.Length / column.Count;
                        genericDataGrid = new double[numberOfColumns][];
                    }
                    genericDataGrid[columnIndex] = column.ToArray();
                    column = new List<double>();
                    currentX = genericData[i][0];
                    columnIndex++;
                }
                column.Add(genericData[i][dataColumnIndex]);
            }
            genericDataGrid[columnIndex] = column.ToArray();
            Point3D lowerLeftCorner = new Point3D(genericData[0][0], genericData[0][1]);
            return new Grid(genericDataGrid, lowerLeftCorner, _cellSize);
        }
protected Grid GenericDataToGrid ( double [ ] [ ] genericData , int dataColumnIndex ) { double [ ] [ ] genericDataGrid = { } ; double currentX = genericData [ 0 ] [ 0 ] ; List < double > column = new List < double > ( ) ; int columnIndex = 0 ; for ( int i = 0 ; i < genericData . Length - 1 ; i ++ ) { if ( currentX != genericData [ i ] [ 0 ] ) { if ( columnIndex == 0 ) { int numberOfColumns = genericData . Length / column . Count ; genericDataGrid = new double [ numberOfColumns ] [ ] ; } genericDataGrid [ columnIndex ] = column . ToArray ( ) ; column = new List < double > ( ) ; currentX = genericData [ i ] [ 0 ] ; columnIndex ++ ; } column . Add ( genericData [ i ] [ dataColumnIndex ] ) ; } genericDataGrid [ columnIndex ] = column . ToArray ( ) ; Point3D lowerLeftCorner = new Point3D ( genericData [ 0 ] [ 0 ] , genericData [ 0 ] [ 1 ] ) ; return new Grid ( genericDataGrid , lowerLeftCorner , _cellSize ) ; }
Converts the generic input file into a grid of values
Converts the generic input file into a grid of values
// Store generic input in a 2D grid // Check whether we encountered a new column // Check whether this was the first column // Now the total number of columns of the grid is known // Add the column to the grid
None
genericData
double[][]
None
dataColumnIndex
int