示例#1
0
        /// <summary>
        /// Calculates a zoom factor of a tile matrix.
        /// </summary>
        /// <param name="tileMatrix">Tile matrix to calculate the zoom for.</param>
        /// <returns>Zoom factor</returns>
        private static double CalculateZoom(ITileMatrix tileMatrix)
        {
            // calculate the logical bounds of a single tile
            var logicalSize = new SizeF(
                (float)(Math.Abs(tileMatrix.BottomRightCorner.X - tileMatrix.TopLeftCorner.X) / tileMatrix.MatrixWidth),
                (float)(Math.Abs(tileMatrix.TopLeftCorner.Y - tileMatrix.BottomRightCorner.Y) / tileMatrix.MatrixHeight)
                );

            // get the pixel size of a tile directly provided by the tile matrix
            var pixelSize = new Size(tileMatrix.TileWidth, tileMatrix.TileHeight);

            // use CalculateZoom with the logical bounds and the pixel size to
            // calculate a representative zoom factor for the tile matrix
            return(CalculateZoom(logicalSize, pixelSize));
        }
示例#2
0
 /// <summary>
 /// Determines the minimum value for the y-coordinate of a tile.
 /// </summary>
 /// <param name="tileMatrix">The tile matrix to determine the value for.</param>
 /// <returns>Minimum value.</returns>
 public static int MinY(this ITileMatrix tileMatrix) => Math.Min(0, tileMatrix.MatrixMinY.GetValueOrDefault(0));
示例#3
0
 /// <summary>
 /// Determines the maximum value for the y-coordinate of a tile.
 /// </summary>
 /// <param name="tileMatrix">The tile matrix to determine the value for.</param>
 /// <returns>Maximum value.</returns>
 public static int MaxY(this ITileMatrix tileMatrix) => Math.Min(tileMatrix.MatrixHeight - 1, tileMatrix.MatrixMaxY.GetValueOrDefault(tileMatrix.MatrixHeight - 1));
示例#4
0
 /// <summary>
 /// Determines the maximum value for the x-coordinate of a tile.
 /// </summary>
 /// <param name="tileMatrix">The tile matrix to determine the value for.</param>
 /// <returns>Maximum value.</returns>
 public static int MaxX(this ITileMatrix tileMatrix) => Math.Min(tileMatrix.MatrixWidth - 1, tileMatrix.MatrixMaxX.GetValueOrDefault(tileMatrix.MatrixWidth - 1));