src/AircraftTrajectories/Models/Trajectory/TrajectoryFileReader.cs
/// <summary>
/// Create a Trajectory object with the data found in the given file
/// </summary>
/// <param name="filepath">the file of which the data should be read</param>
/// <returns>a Trajectory object</returns>
Create a Trajectory object with the data found in the given file
Create a Trajectory object with the data found in the given file
public Trajectory CreateTrajectoryFromFile(string filepath)
        {
            readFromFile(filepath);
            double t = 0;
            double previousV = 0;
            Point3D previousPoint = null;
            foreach (double[] row in _trackData)
            {
                if (row.Length == 0) { continue; }
                var currentPoint = new Point3D(row[0], row[1], row[2], CoordinateUnits);
                var metricPoint = currentPoint.ConvertTo(CoordinateUnit.metric);
                var currentV = row[3];
                if (previousPoint != null)
                {
                    t += previousPoint.DistanceTo(metricPoint) / ((currentV + previousV) / 2);
                }
                _trajectoryGenerator.AddDatapoint(metricPoint.X, metricPoint.Y, metricPoint.Z, row[3], row[4], t);
                previousPoint = currentPoint;
                previousV = currentV;
            }
            Trajectory trajectory = _trajectoryGenerator.GenerateTrajectory();
            return trajectory;
        }
public Trajectory CreateTrajectoryFromFile ( string filepath ) { readFromFile ( filepath ) ; double t = 0 ; double previousV = 0 ; Point3D previousPoint = null ; foreach ( double [ ] row in _trackData ) { if ( row . Length == 0 ) { continue ; } var currentPoint = new Point3D ( row [ 0 ] , row [ 1 ] , row [ 2 ] , CoordinateUnits ) ; var metricPoint = currentPoint . ConvertTo ( CoordinateUnit . metric ) ; var currentV = row [ 3 ] ; if ( previousPoint != null ) { t += previousPoint . DistanceTo ( metricPoint ) / ( ( currentV + previousV ) / 2 ) ; } _trajectoryGenerator . AddDatapoint ( metricPoint . X , metricPoint . Y , metricPoint . Z , row [ 3 ] , row [ 4 ] , t ) ; previousPoint = currentPoint ; previousV = currentV ; } Trajectory trajectory = _trajectoryGenerator . GenerateTrajectory ( ) ; return trajectory ; }
Create a Trajectory object with the data found in the given file
Create a Trajectory object with the data found in the given file
a Trajectory object
a Trajectory object
filepath
string
the file of which the data should be read
the file of which the data should be read