Пример #1
0
        public void LegendCreator()
        {
            LegendCreator creator = new LegendCreator();

            Assert.IsNotNull(creator);
            Assert.AreEqual(80, creator.max);
            Assert.AreEqual(65, creator.min);
        }
Пример #2
0
        public void OutputLegendTitleTest()
        {
            LegendCreator creator = new LegendCreator();

            creator.OutputLegendTitle();

            if (File.Exists("titleImage.png"))
            {
                Assert.Pass();
            }
        }
Пример #3
0
        public void OutputLegendImageTest()
        {
            LegendCreator creator = new LegendCreator();

            creator.OutputLegendImage();

            if (File.Exists("gradientImage.png"))
            {
                Assert.Pass();
            }
        }
        protected void OneTrajectoryVisualisation()
        {
            // Create legend
            var legend = new LegendCreator();

            legend.OutputLegendImage();
            legend.OutputLegendTitle();

            var sections = new List <KMLAnimatorSectionInterface>();

            // Contour animator
            List <int> contoursOfInterest = (_view.VisualiseContoursOfInterest) ? _view.ContoursOfInterest : null;
            var        contourAnimator    = new ContourKMLAnimator(temporalGrid, trajectory, contoursOfInterest);

            if (_view.VisualiseGradient)
            {
                contourAnimator.SetGradientSettings((int)_view.LowestContourValue, (int)_view.HighestContourValue, (int)_view.ContourValueStep);
            }

            // Create sections
            sections.Add(new LegendKMLAnimator());
            sections.Add(new AircraftKMLAnimator(trajectory.Aircraft, trajectory));
            sections.Add(new AirplotKMLAnimator(trajectory));
            sections.Add(new GroundplotKMLAnimator(trajectory));
            sections.Add(contourAnimator);
            //new AnnoyanceKMLAnimator(temporalGrid, population.getPopulationData())
            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);
            }

            // Create animator
            var camera   = new FollowKMLAnimatorCamera(trajectory.Aircraft, trajectory);
            var animator = new KMLAnimator(sections, camera);

            animator.AnimationToFile(trajectory.Duration, Globals.webrootDirectory + "visualisation.kml");

            _view.Invoke(delegate { _view.PreparationCalculationCompleted(); });
        }
        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(); });
        }
        private void CreateContoursKML(Grid grid)
        {
            StringBuilder kml = new StringBuilder();

            kml.AppendLine("<?xml version='1.0' encoding='UTF-8'?>");
            kml.AppendLine("<kml xmlns='http://www.opengis.net/kml/2.2' xmlns:gx='http://www.google.com/kml/ext/2.2' xmlns:kml='http://www.opengis.net/kml/2.2' xmlns:atom='http://www.w3.org/2005/Atom'>");
            kml.AppendLine("<Document>");

            if (_useGradient)
            {
                kml.Append(@"
<ScreenOverlay>
<name>Legend</name>
<Icon><href>webroot/gradientImage.png</href></Icon>
<overlayXY x= ""0.03"" y= ""0.85"" xunits= ""fraction"" yunits= ""fraction"" />
<screenXY x = ""0.03"" y =""0.85"" xunits =""fraction"" yunits =""fraction""/>
<rotationXY x = ""0.5"" y = ""0.5"" xunits =""fraction"" yunits =""fraction""/>
<size x = ""0"" y = ""0"" xunits = ""pixels"" yunits = ""pixels"" />
</ScreenOverlay>

<ScreenOverlay>
<name>Legend Title</name>
<Icon><href>webroot/titleImage.png</href>
</Icon>
<overlayXY x = ""0.02"" y = ""0.94"" xunits = ""fraction"" yunits = ""fraction"" />
<screenXY x = ""0.02"" y = ""0.94"" xunits = ""fraction"" yunits = ""fraction"" />
<rotationXY x = ""0.5"" y = ""0.5"" xunits = ""fraction"" yunits = ""fraction"" />
<size x = ""0"" y = ""0"" xunits = ""pixels"" yunits = ""pixels"" />
</ScreenOverlay>
			"            );
            }

            // create legend
            if (_useGradient)
            {
                LegendCreator legendCreator = new LegendCreator();
                legendCreator.min = _dbMin;
                legendCreator.max = _dbMax;
                legendCreator.c1  = Color.FromArgb(200, 255, 0, 20);
                legendCreator.c2  = Color.FromArgb(200, 252, 236, 3);
                legendCreator.OutputLegendImage();
                legendCreator.OutputLegendTitle();
            }

            // define which noise value contours to visualise
            List <int> visualisedContours = new List <int>();

            for (int x = 0; x < lbVisibleContours.Items.Count; x++)
            {
                if (lbVisibleContours.GetSelected(x) == true)
                {
                    visualisedContours.Add(_dbMin + x);
                }
            }

            int i = 0;

            foreach (Contour contour in grid.Contours)
            {
                if (!visualisedContours.Contains(contour.Value))
                {
                    continue;
                }
                i++;

                String contourKml = getContourStyle(contour, i) + @"
<Placemark id='contour_placemark" + i + @"'>
	<name>"     + contour.Value + @" dB(A)</name>
	<description><![CDATA[description: <br>label: "     + contour.Value + @"]]></description>
    <styleUrl>#contour_style" + i + @"</styleUrl>
	<ExtendedData>
		<Data name=""description"">
		</Data>
		<Data name=""label"">
			<value>"             + contour.Value + @"</value>
		</Data>
	</ExtendedData>
    <Polygon>
        <outerBoundaryIs>
            <LinearRing id='contour" + i + @"'>
				<tessellate>1</tessellate>
                <coordinates>
				"                 + GetContourCoordinates(grid, contour) + @"
				</coordinates>
            </LinearRing>
        </outerBoundaryIs>
    </Polygon>
</Placemark>";
                kml.Append(contourKml);
            }

            kml.AppendLine("</Document>");
            kml.AppendLine("</kml>");

            // write contours to kml file
            String filepath = "contours.kml";

            System.IO.StreamWriter file = new System.IO.StreamWriter(filepath);
            file.Write(kml.ToString());
            file.Close();
        }