Пример #1
0
        /// <summary>
        /// Initializes the active tile plane by requesting images centered at the specified geo-coordinate.
        /// </summary>
        /// <param name="centerCoordinate">The geo-coordinate which will serve as the center of the
        /// middle tile.</param>
        private void GetActivePlaneImages(GeoCoordinate centerCoordinate)
        {
            Vector2 centerPixelXY = TileSystem.LatLongToPixelXY(centerCoordinate, zoomLevel);

            int planeCenterIndex = PlaneCenterIndex;

            for (int xIndex = 0; xIndex < ActiveTilePlaneSize; xIndex++)
            {
                int xDelta = xIndex - planeCenterIndex;

                for (int yIndex = 0; yIndex < ActiveTilePlaneSize; yIndex++)
                {
                    int yDelta = yIndex - planeCenterIndex;

                    TileInformation cellInformation = activeTilePlane[xIndex, yIndex];

                    // Initialize or clean the active tile cube cell
                    if (cellInformation == null)
                    {
                        cellInformation = new TileInformation(TileServerRequestCompleted);
                        activeTilePlane[xIndex, yIndex] = cellInformation;
                    }
                    else
                    {
                        cellInformation.Dispose();
                    }

                    // Calculate the center geo-coordinate for the current tile
                    Vector2       tileCenterPixelXY = centerPixelXY + tileDimensions * new Vector2(xDelta, yDelta);
                    GeoCoordinate tileCenterGeoCoordinate;

                    try
                    {
                        tileCenterGeoCoordinate = TileSystem.PixelXYToLatLong(tileCenterPixelXY, zoomLevel);
                        GetImageFromServer(cellInformation, tileCenterGeoCoordinate, zoomLevel, ViewType);
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        cellInformation.Image = unavailableImage;
                    }
                }
            }
        }