Пример #1
0
        private bool CoordinateIsInBounds(ITwoDimensionalCoordinate coordinate)
        {
            var x = coordinate.GetX();
            var y = coordinate.GetY();

            return((x >= 0 && x < Width()) &&
                   (y >= 0 && y < Height()));
        }
Пример #2
0
        private void AddAdjacentPixelsOnY(ICollection <MapPixel> adjacentPixels, ITwoDimensionalCoordinate coordinate)
        {
            var currentCoordinate = new MapCoordinate(coordinate.GetX(), coordinate.GetY());

            for (var yOff = -1; yOff <= 1; yOff += 2)
            {
                currentCoordinate.SetY(coordinate.GetY() + yOff);

                if (CoordinateIsInBounds(coordinate))
                {
                    adjacentPixels.Add(_map[currentCoordinate.GetX(), currentCoordinate.GetY()]);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Constructs an airspace. The location of the airspace is defined by its south west corner.
        /// The airspace will always measure a square of 80000x80000 meters within altitudes of 500-20000 meters.
        /// </summary>
        /// <param name="southWestCorner">The southwest corner of the airspace</param>
        public Airspace(ITwoDimensionalCoordinate southWestCorner)
        {
            // These constants are defined in the assignment
            const int lowerAltitude = 500;
            const int upperAltitude = 20000;
            const int airspaceSize  = 80000;

            SouthWestCorner = southWestCorner;

            // Define the northeast corner based on the southwest corner and the above constants
            NorthEastCorner = new TwoDimensionalCoordinate(southWestCorner.X + airspaceSize, southWestCorner.Y + airspaceSize);

            //The lower and upper altitudes are defined in the assignment
            LowerAltitudeBoundary = lowerAltitude;
            UpperAltitudeBoundary = upperAltitude;
        }