Beispiel #1
0
        private void TopView_Load(object sender, EventArgs e)
        {
            // Parse the file containing multiple trajectories
            string rawTrackData = File.ReadAllText(Globals.currentDirectory + "inbound.txt");
            var    _trackData   = rawTrackData
                                  .Split('\n')
                                  .Select(q =>
                                          q.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                                          .Select(Convert.ToString)
                                          .ToArray()
                                          )
                                  .ToArray();


            // Define variables
            string              flight_id           = "";
            var                 trajectories        = new List <Trajectory>();
            ReferencePoint      referencePoint      = new ReferencePoint(new GeoPoint3D(4.7066753, 52.3297923));
            TrajectoryGenerator trajectoryGenerator = new TrajectoryGenerator(new Aircraft("GP7270", "wing"), referencePoint);


            // Loop through the positions of all trajectories
            for (int i = 0; i < _trackData.Length; i++)
            {
                // Switch to the next trajectory
                if (i == _trackData.Length - 1 || (_trackData[i][0] != flight_id && i > 0))
                {
                    trajectories.Add(trajectoryGenerator.GenerateTrajectory());

                    // Prepare next trajectory
                    var aircraft = new Aircraft("GP7270", "wing");
                    trajectoryGenerator = new TrajectoryGenerator(aircraft, referencePoint);
                }

                // Prevent failing on empty lines
                if (_trackData[i].Count() == 0)
                {
                    continue;
                }
                flight_id = _trackData[i][0];

                // Parse the next position of the current trajectory
                //DateTime t = DateTime.Parse(_trackData[i][14]);
                double x = 0;
                double.TryParse(_trackData[i][4], out x);
                double y = 0;
                double.TryParse(_trackData[i][5], out y);
                double z = 0;
                double.TryParse(_trackData[i][6], out z);
                z = z * 0.3040 * 100;
                trajectoryGenerator.AddDatapoint(x, y, z, 200, 200000);
            }


            // Calculate the noise for each trajectory
            TemporalGrid temporalGrid = new TemporalGrid();
            int          counter      = 0;

            foreach (Trajectory trajectory in trajectories)
            {
                counter++;
                Console.WriteLine(counter);
                if (counter > 15)
                {
                    break;
                }

                var INM = new IntegratedNoiseModel(trajectory, trajectory.Aircraft);
                INM.RunINMFullTrajectory();

                Grid grid = INM.TemporalGrid.GetGrid(0);
                Console.WriteLine(grid.LowerLeftCorner.X);
                Console.WriteLine(grid.LowerLeftCorner.Y);
                grid.ReferencePoint = referencePoint;
                temporalGrid.AddGrid(grid);
            }

            var camera   = new TopViewKMLAnimatorCamera(new GeoPoint3D(4.7066753, 52.3297923, 22000));
            var sections = new List <KMLAnimatorSectionInterface>()
            {
                new ContourKMLAnimator(temporalGrid),
                new MultipleGroundplotKMLAnimator(trajectories)
            };
            var animator = new KMLAnimator(sections, camera);

            animator.Duration = 0;
            animator.AnimationToFile(temporalGrid.GetNumberOfGrids(), Globals.currentDirectory + "topview_fullpath.kml");
        }
        protected void MultipleTrajectoryVisualisation()
        {
            // Legend
            var legend = new LegendCreator();

            // plot legend
            legend.OutputLegendImage();
            legend.OutputLegendTitle();

            // Create sections
            var sections = new List <KMLAnimatorSectionInterface>();

            //sections.Add(new MaintainMultipleGroundPlotKMLAnimator(trajectories));
            if (!VisualiseOptimisation)
            {
                // Contour animator
                List <int> contoursOfInterest = (_view.VisualiseContoursOfInterest) ? _view.ContoursOfInterest : null;
                var        contourAnimator    = new ContourKMLAnimator(temporalGrid, null, contoursOfInterest);
                if (_view.VisualiseGradient)
                {
                    legend.SetSettings(_view.LowestContourValue, _view.HighestContourValue);
                    contourAnimator.SetGradientSettings((int)_view.LowestContourValue, (int)_view.HighestContourValue, (int)_view.ContourValueStep);
                }
                contourAnimator.AltitudeOffset = (_view.MapFile != "");
                sections.Add(new MultipleGroundplotKMLAnimator(trajectories));
                sections.Add(new LegendKMLAnimator());
                sections.Add(contourAnimator);
            }
            else
            {
                trajectories = TrajectoryFitness.trajectories;
                sections.Add(new FitnessGroundPlotKMLAnimator(trajectories));
            }
            if (_view.MapFile != "")
            {
                sections.Add(new CustomMapKMLAnimator(_view.MapFile, _view.MapBottomLeft, _view.MapUpperRight));
            }
            if (_view.Heatmap)
            {
                var population = new PopulationData(Globals.currentDirectory + "population.dat");
                population.Chance = _view.PopulationFactor;
                var section = new HeatmapKMLAnimator(population);
                section.DotSize = _view.PopulationDotSize;
                section.DotFile = _view.PopulationDotFile;
                sections.Add(section);
            }

            var camera = new TopViewKMLAnimatorCamera(
                new GeoPoint3D(4.9773743, 52.2384423,
                               _view.CameraAltitude)
                );
            // Create animator

            /*
             * var camera = new TopViewKMLAnimatorCamera(
             *  new GeoPoint3D(referencePoint.GeoPoint.Longitude, referencePoint.GeoPoint.Latitude,
             *  _view.CameraAltitude)
             * );
             */
            var animator = new KMLAnimator(sections, camera);

            animator.Duration = 0;
            animator.AnimationToFile(trajectories.Count, Globals.webrootDirectory + "visualisation.kml");

            _view.Invoke(delegate { _view.PreparationCalculationCompleted(); });
        }