Пример #1
0
        public string GenerateAirspaceGrid(List <IFlightTrack> flights)
        {
            string airspacegrid = "";

            var dps = new List <FTDataPoint>();

            flights.ForEach(f => dps.Add(f.GetNewestDataPoint()));

            //empty grid
            char[,] grid = new char[grid_heigth, grid_width];
            for (int i = 0; i < grid_heigth; i++)
            {
                for (int j = 0; j < grid_width; j++)
                {
                    grid[i, j] = ' ';
                }
            }

            //x at flightpositions
            IAirspaceArea aa = _airspace.GetAirspaceArea();
            //float width = aa.NorthEastCornerX - aa.SouthWestCornerX;
            //float heigth = aa.NorthEastCornerY - aa.SouthWestCornerY;
            float width  = aa.Width();
            float heigth = aa.Heigth();

            if (dps.Count > 0)
            {
                foreach (var dp in dps)
                {
                    int x = (int)lerp(0, grid_width, ((dp.X - aa.GetSouthWestCorner().X) / width));
                    int y = (int)lerp(0, grid_heigth, ((dp.Y - aa.GetSouthWestCorner().Y) / heigth));
                    grid[grid_heigth - 1 - y, x] = 'X';
                }
            }

            //grid to string + add border
            string line = "";

            for (int i = 0; i < grid_width; i++)
            {
                line += "-";
            }
            line          = "+" + line + "+\n";
            airspacegrid += line;

            for (int i = 0; i < grid_heigth; i++)
            {
                airspacegrid += "|";
                for (int j = 0; j < grid_width; j++)
                {
                    airspacegrid += grid[i, j];
                }
                airspacegrid += "|\n";
            }

            airspacegrid += line;

            return(airspacegrid);
        }
Пример #2
0
        public void AirspaceArea_Height_PositiveCalculationOutput()
        {
            //Arrange
            float testHeigth = 95000 - 15000;

            //Assert
            Assert.That(_uut.Heigth(), Is.EqualTo(testHeigth));
        }