public void StartCalculation(Action <double> progressChangedCallback) { CreateGridFile(); TemporalGrid = new TemporalGrid(); TemporalGrid.Interval = 1; double progress = 0; for (int t = 0; t <= _trajectory.Duration; t++) { if (IntegrateToCurrentPosition) { CreateTrajectoryToCurrentPosition(t); } else { CreatePositionFile(t); } ExecuteINMTM(); double[][] noiseData = ReadNoiseData(); Grid grid = NoiseDataToGrid(noiseData, !_mapToLargerGrid); if (_mapToLargerGrid) { grid = Grid.MapOnLargerGrid(grid, _lowerLeftPoint, _upperRightPoint); } TemporalGrid.AddGrid(grid); progress = (t / (double)_trajectory.Duration) * 100; progressChangedCallback(progress); } progress = 100; progressChangedCallback(progress); }
public void t1_TemporalGrid() { var reader = new TrajectoryFileReader(CoordinateUnit.metric); var trajectory = reader.createTrajectoryFromFile(Globals.testdataDirectory + "test_track.dat"); Aircraft aircraft = new Aircraft("GP7270", "wing"); noiseModel = new IntegratedNoiseModel(trajectory, aircraft); noiseModel.StartCalculation(INMCompleted); while (!completed) { } TemporalGrid temporalGrid = noiseModel.TemporalGrid; int numberOfGrids = temporalGrid.GetNumberOfGrids(); Assert.AreNotEqual(0, numberOfGrids); Grid temp = new Grid(new double[1][] { new double[] { 0 } }, null); temporalGrid.AddGrid(temp); Assert.IsNotNull(temporalGrid.GetGrid(0)); Assert.AreEqual(numberOfGrids + 1, temporalGrid.GetNumberOfGrids()); Assert.AreEqual(temp, temporalGrid.GetGrid(numberOfGrids)); completed = false; }
public void RunINMFullTrajectory() { TemporalGrid = new TemporalGrid(); TemporalGrid.Interval = 1; CreateTrajectoryFile(); CreateGridFile(); ExecuteINMTM(); if (PopulatedAreaNoise != null) { ReadPopulatedAreaNoise(); } else { double[][] noiseData = ReadNoiseData(); Grid grid = NoiseDataToGrid(noiseData, !_mapToLargerGrid); if (_mapToLargerGrid) { Console.WriteLine(_lowerLeftPoint.X + "," + _lowerLeftPoint.Y); Console.WriteLine(_upperRightPoint.X + "," + _upperRightPoint.Y); grid = Grid.MapOnLargerGrid(grid, _lowerLeftPoint, _upperRightPoint); } grid.ReferencePoint = ReferencePoint; TemporalGrid.AddGrid(grid); } }
public void KMLAnimatorFullTest() { if (File.Exists(Globals.currentDirectory + "test.kml")) { File.Delete(Globals.currentDirectory + "test.kml"); } var reader = new TrajectoryFileReader(CoordinateUnit.metric); var trajectory = reader.createTrajectoryFromFile(Globals.testdataDirectory + "test_track.dat"); var aircraft = new Aircraft("GP7270", "wing"); var noiseModel = new IntegratedNoiseModel(trajectory, aircraft); noiseModel.StartCalculation(calculationCompleted); while (!INMCompleted) { } TemporalGrid temporalGrid = noiseModel.TemporalGrid; var population = new List <double[]> { new double[3] { 104064, 475499, 2.5 }, new double[3] { 104262, 476470, 3 } }; var camera = new FollowKMLAnimatorCamera(aircraft, trajectory); var sections = new List <KMLAnimatorSectionInterface>() { new AircraftKMLAnimator(aircraft, trajectory), new AirplotKMLAnimator(trajectory), new GroundplotKMLAnimator(trajectory), new ContourKMLAnimator(temporalGrid, trajectory, new List <int>() { 65, 70, 75 }), new AnnoyanceKMLAnimator(temporalGrid, population) }; var animator = new KMLAnimator(sections, camera); animator.AnimationToFile(trajectory.Duration, Globals.currentDirectory + "test.kml"); String output = File.ReadAllText(Globals.currentDirectory + "test.kml"); try { var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(output); } catch (XmlException ex) { Assert.Fail(ex.Message); } INMCompleted = false; }
/// <summary> /// Return a string in KML format containing all pre animation definitions /// that are required for the population annoyance /// </summary> /// <returns></returns> public AnnoyanceKMLAnimator(TemporalGrid temporalGrid, List <double[]> populationData) { _temporalGrid = temporalGrid; _populationData = populationData; ImageDefault = "happy2.png"; ImageAnnoyed = "angry2.png"; }
public ContourKMLAnimator(TemporalGrid temporalGrid, Trajectory trajectory = null, List<int> highlightedContours = null) { LowestContourValue = int.MaxValue; HighestContourValue = int.MinValue; _temporalGrid = temporalGrid; _trajectory = trajectory; _gradientContours = new List<int>(); _highlightedContours = (highlightedContours == null) ? new List<int>() : highlightedContours; if (_highlightedContours.Count > 0) { LowestContourValue = _highlightedContours.Min(); HighestContourValue = _highlightedContours.Max(); } }
protected void OneTrajectoryINM() { var aircraft = new Aircraft("GP7270", "wing"); var trajectoryGenerator = new TrajectoryGenerator(aircraft, referencePoint); if (_view.TrajectoryFile.Contains(".")) { var reader = new TrajectoryFileReader(CoordinateUnit.metric, trajectoryGenerator); trajectory = reader.CreateTrajectoryFromFile(_view.TrajectoryFile); } trajectory.Aircraft = aircraft; noiseModel = new IntegratedNoiseModel(trajectory, aircraft); bool integrateToCurrentPosition = true; int metric = 0; switch (_view.NoiseMetric) { case 0: metric = 1; integrateToCurrentPosition = false; break; case 1: metric = 1; break; case 2: metric = 0; break; case 3: metric = 2; break; case 4: metric = 3; break; } noiseModel.IntegrateToCurrentPosition = integrateToCurrentPosition; noiseModel.NoiseMetric = metric; noiseModel.StartCalculation(ProgressChanged); temporalGrid = noiseModel.TemporalGrid; _view.Invoke(delegate { _view.NoiseCalculationCompleted(); }); }
public void t5_INMFullTest() { var reader = new TrajectoryFileReader(CoordinateUnit.metric); var trajectory = reader.createTrajectoryFromFile(Globals.testdataDirectory + "test_track.dat"); var aircraft = new Aircraft("GP7270", "wing"); var noiseModel = new IntegratedNoiseModel(trajectory, aircraft); noiseModel.StartCalculation(INMCompleted); while (!completed) { } TemporalGrid temporalGrid = noiseModel.TemporalGrid; Assert.AreEqual(2, temporalGrid.GetNumberOfGrids()); completed = false; }
public void GridConverteMAXInterval() { var reader = new TrajectoryFileReader(CoordinateUnit.metric); var trajectory = reader.createTrajectoryFromFile(Globals.testdataDirectory + "test_track.dat"); Aircraft aircraft = new Aircraft("GP7270", "wing"); var noiseModel_MAX = new IntegratedNoiseModel(trajectory, aircraft); noiseModel_MAX.StartCalculation(testMAX); while (!testRunned_MAX) { } var converter_MAX = new GridConverter(noiseModel_MAX.TemporalGrid, GridTransformation.MAX); TemporalGrid res = converter_MAX.transform(); Assert.AreEqual(1, res.Interval); testRunned_MAX = false; }
public void GridConverterSELData() { var reader = new TrajectoryFileReader(CoordinateUnit.metric); var trajectory = reader.createTrajectoryFromFile(Globals.testdataDirectory + "test_track.dat"); Aircraft aircraft = new Aircraft("GP7270", "wing"); var noiseModel_SEL = new IntegratedNoiseModel(trajectory, aircraft); noiseModel_SEL.StartCalculation(testSEL); while (!testRunned_SEL) { } var converter_SEL = new GridConverter(noiseModel_SEL.TemporalGrid, GridTransformation.SEL); TemporalGrid res = converter_SEL.transform(); Assert.AreEqual(30.67, Math.Round(res.GetGrid(1).Data[65][60], 2), 0.001); testRunned_SEL = false; }
public void GridConverterSELNumberOfGrids() { var reader = new TrajectoryFileReader(CoordinateUnit.metric); var trajectory = reader.createTrajectoryFromFile(Globals.testdataDirectory + "test_track.dat"); Aircraft aircraft = new Aircraft("GP7270", "wing"); var noiseModel_SEL = new IntegratedNoiseModel(trajectory, aircraft); noiseModel_SEL.StartCalculation(testSEL); while (!testRunned_SEL) { } var converter_SEL = new GridConverter(noiseModel_SEL.TemporalGrid, GridTransformation.SEL); TemporalGrid res = converter_SEL.transform(); Assert.IsNotNull(converter_SEL); Assert.AreEqual(2, res.GetNumberOfGrids()); testRunned_SEL = false; }
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 MultipleTrajectoriesINM() { var reader = new TrajectoriesFileReader(); /* * if (TrajectoryFitness.trajectories != null) * { * trajectories = TrajectoryFitness.trajectories; * VisualiseOptimisation = true; * return; * } else * { */ trajectories = reader.CreateFromFile(_view.TrajectoryFile, referencePoint); //} /* * _view.Invoke(delegate { _view.NoiseCalculationCompleted(); }); * return; */ // Calculate the noise for each trajectory temporalGrid = new TemporalGrid(); int counter = 0; foreach (Trajectory trajectory in trajectories) { double percentage = (double)counter / trajectories.Count * 100.0; ProgressChanged(percentage); Console.WriteLine("INM " + counter + " started"); //if (counter > 3) { break; } var INM = new IntegratedNoiseModel(trajectory, trajectory.Aircraft); INM.CellSize = 125; INM.MapToLargerGrid(reader.LowerLeftPoint, reader.UpperRightPoint); INM.MaxDistanceFromAirport(referencePoint.Point, 100000); INM.IntegrateToCurrentPosition = true; INM.NoiseMetric = 0; if (_view.NoiseMetric == 1) { INM.NoiseMetric = 1; } INM.RunINMFullTrajectory(); Grid grid = INM.TemporalGrid.GetGrid(0); Console.WriteLine(grid.Data.Length + "x" + grid.Data[0].Length); grid.ReferencePoint = referencePoint; temporalGrid.AddGrid(grid); Console.WriteLine("INM " + counter + " completed"); counter++; } GridConverter converter; switch (_view.NoiseMetric) { case 0: converter = new GridConverter(temporalGrid, GridTransformation.LDEN); temporalGrid = converter.Transform(); break; case 1: converter = new GridConverter(temporalGrid, GridTransformation.SEL); temporalGrid = converter.Transform(); break; } _view.Invoke(delegate { _view.NoiseCalculationCompleted(); }); }