コード例 #1
0
        /// <summary>
        /// Creates and initializes an instance of MapRectangleByTile.
        /// </summary>
        /// <param name="x">X-coordinate of the tile</param>
        /// <param name="y">Y-coordinate of the tile</param>
        /// <param name="z">Z-coordinate of the tile</param>
        public TileMapRectangle(int x, int y, int z)
        {
            var rect = ReprojectionProvider.TileToSphereMercator(X = x, Y = y, Z = z, 6371000);

            West  = Math.Min(rect.Left, rect.Right);
            East  = Math.Max(rect.Left, rect.Right);
            North = Math.Max(rect.Top, rect.Bottom);
            South = Math.Min(rect.Top, rect.Bottom);
        }
コード例 #2
0
        /// <inheritdoc/>
        public Stream GetImageStream(int x, int y, int zoom)
        {
            // get tile bounds in mercator units
            var rect    = ReprojectionProvider.TileToSphereMercator(x, y, zoom, 6371000);
            var mapRect = new Tools.Reprojection.MapRectangle(rect.Left, rect.Bottom, rect.Right, rect.Top);

            // Request the map tile from the ReprojectionService. The returned image stream may be
            // null, e.g. when the requested tile is out of bounds regarding the inner MapServer configuration.
            // In that case return a default  tile preventing the map from displaying enlarged images from other
            // zoom levels (> avoids "zoom artifacts").
            return((ReprojectionService.GetImageStream(mapRect, new Size(256, 256)) ?? new MemoryStream(defaultTile)).Reset());
        }