Exemple #1
0
        /// <summary>
        /// Convert a position on the device's display to the corresponding geo-coordinate.
        /// </summary>
        /// <param name="screenPosition">Screen position to convert.</param>
        /// <returns>Geo-coordinate which represents the screen position.</returns>
        public GeoCoordinate ConvertScreenPositionToGeoCoordinate(Vector2 screenPosition)
        {
            // Get vector from the screen center to the screen position, but on the entire map image
            Vector2 fromScreenCenterToPositionNonScaled = (screenPosition - screenCenterVector) / zoomScale;

            Vector2 screenPositionPixelXY = ScreenCenterPixelXY + fromScreenCenterToPositionNonScaled;

            return(TileSystem.PixelXYToLatLong(screenPositionPixelXY, ZoomLevel));
        }
Exemple #2
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;
                    }
                }
            }
        }