From 2028e3cf90b851283e1b0ec84b4e15534ad9dcee Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Fri, 21 Nov 2025 15:52:38 +0100 Subject: [PATCH] Correct comments --- MapControl/Shared/MapTileLayer.cs | 2 +- MapControl/Shared/ViewTransform.cs | 2 +- MapControl/Shared/WmtsTileMatrixLayer.cs | 2 +- MapControl/WPF/BitmapTileMatrixLayer.cs | 12 ++++-------- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/MapControl/Shared/MapTileLayer.cs b/MapControl/Shared/MapTileLayer.cs index 00be27ec..4930dd38 100644 --- a/MapControl/Shared/MapTileLayer.cs +++ b/MapControl/Shared/MapTileLayer.cs @@ -153,7 +153,7 @@ namespace MapControl var tileMatrixZoomLevel = (int)Math.Floor(ParentMap.ZoomLevel - ZoomLevelOffset + 0.001); var tileMatrixScale = MapBase.ZoomLevelToScale(tileMatrixZoomLevel); - // Bounds in tile pixels from view size. + // Tile matrix bounds in pixels. // var bounds = ParentMap.ViewTransform.GetTileMatrixBounds(tileMatrixScale, MapTopLeft, ParentMap.ActualWidth, ParentMap.ActualHeight); diff --git a/MapControl/Shared/ViewTransform.cs b/MapControl/Shared/ViewTransform.cs index f6be3224..9cb673d9 100644 --- a/MapControl/Shared/ViewTransform.cs +++ b/MapControl/Shared/ViewTransform.cs @@ -123,7 +123,7 @@ namespace MapControl } /// - /// Gets the index bounds of a tile matrix. + /// Gets the pixel bounds of a tile matrix. /// public Rect GetTileMatrixBounds(double tileMatrixScale, Point tileMatrixTopLeft, double viewWidth, double viewHeight) { diff --git a/MapControl/Shared/WmtsTileMatrixLayer.cs b/MapControl/Shared/WmtsTileMatrixLayer.cs index abeda5ba..b927d383 100644 --- a/MapControl/Shared/WmtsTileMatrixLayer.cs +++ b/MapControl/Shared/WmtsTileMatrixLayer.cs @@ -48,7 +48,7 @@ namespace MapControl public bool UpdateTiles(ViewTransform viewTransform, double viewWidth, double viewHeight) { - // Bounds in tile pixels from view size. + // Tile matrix bounds in pixels. // var bounds = viewTransform.GetTileMatrixBounds(WmtsTileMatrix.Scale, WmtsTileMatrix.TopLeft, viewWidth, viewHeight); diff --git a/MapControl/WPF/BitmapTileMatrixLayer.cs b/MapControl/WPF/BitmapTileMatrixLayer.cs index b6d4708d..5eff8cdf 100644 --- a/MapControl/WPF/BitmapTileMatrixLayer.cs +++ b/MapControl/WPF/BitmapTileMatrixLayer.cs @@ -34,7 +34,7 @@ namespace MapControl } } - public class BitmapTileMatrixLayer(WmtsTileMatrix wmtsTileMatrix, int zoomLevel) : FrameworkElement + public class BitmapTileMatrixLayer(WmtsTileMatrix wmtsTileMatrix, int zoomLevel) : UIElement { private readonly ImageBrush imageBrush = new ImageBrush { @@ -42,8 +42,6 @@ namespace MapControl Transform = new MatrixTransform() }; - private WriteableBitmap bitmap; - public WmtsTileMatrix WmtsTileMatrix { get; } = wmtsTileMatrix; public TileMatrix TileMatrix { get; private set; } = new TileMatrix(zoomLevel, 1, 1, 0, 0); @@ -67,7 +65,7 @@ namespace MapControl public bool UpdateTiles(ViewTransform viewTransform, double viewWidth, double viewHeight) { - // Bounds in tile pixels from view size. + // Tile matrix bounds in pixels. // var bounds = viewTransform.GetTileMatrixBounds(WmtsTileMatrix.Scale, WmtsTileMatrix.TopLeft, viewWidth, viewHeight); @@ -114,9 +112,7 @@ namespace MapControl var width = WmtsTileMatrix.TileWidth * (TileMatrix.XMax - TileMatrix.XMin + 1); var height = WmtsTileMatrix.TileHeight * (TileMatrix.YMax - TileMatrix.YMin + 1); - bitmap = new WriteableBitmap(width, height, 96, 96, PixelFormats.Pbgra32, null); - - imageBrush.ImageSource = bitmap; + imageBrush.ImageSource = new WriteableBitmap(width, height, 96, 96, PixelFormats.Pbgra32, null); imageBrush.Viewport = new Rect(0, 0, width, height); } @@ -167,7 +163,7 @@ namespace MapControl WmtsTileMatrix.TileWidth, WmtsTileMatrix.TileHeight); - bitmap.WritePixels(rect, tile.PixelBuffer, 4 * WmtsTileMatrix.TileWidth, 0); + ((WriteableBitmap)imageBrush.ImageSource).WritePixels(rect, tile.PixelBuffer, 4 * WmtsTileMatrix.TileWidth, 0); } private void OnTileCompleted(object sender, EventArgs e)