From d6faf252eec2bc5b413782b718fc0d543aa023db Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Wed, 10 Sep 2025 22:19:20 +0200 Subject: [PATCH] TileSource.GetUri/LoadImageAsync argument order --- MapControl/Shared/BoundingBoxTileSource.cs | 8 ++++---- MapControl/Shared/TileImageLoader.cs | 6 +++--- MapControl/Shared/TileSource.cs | 16 ++++++++-------- MapControl/WinUI/Tile.WinUI.cs | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/MapControl/Shared/BoundingBoxTileSource.cs b/MapControl/Shared/BoundingBoxTileSource.cs index 69bd2dc6..974a24ae 100644 --- a/MapControl/Shared/BoundingBoxTileSource.cs +++ b/MapControl/Shared/BoundingBoxTileSource.cs @@ -5,9 +5,9 @@ namespace MapControl { public class BoundingBoxTileSource : TileSource { - public override Uri GetUri(int column, int row, int zoomLevel) + public override Uri GetUri(int zoomLevel, int column, int row) { - GetTileBounds(column, row, zoomLevel, out double west, out double south, out double east, out double north); + GetTileBounds(zoomLevel, column, row, out double west, out double south, out double east, out double north); return GetUri(west, south, east, north); } @@ -33,9 +33,9 @@ namespace MapControl /// /// Gets the bounding box in meters of a standard Web Mercator tile, - /// specified by grid column and row indices and zoom level. + /// specified by zoom level and grid column and row indices. /// - public static void GetTileBounds(int column, int row, int zoomLevel, + public static void GetTileBounds(int zoomLevel, int column, int row, out double west, out double south, out double east, out double north) { var tileSize = 360d / (1 << zoomLevel); // tile size in degrees diff --git a/MapControl/Shared/TileImageLoader.cs b/MapControl/Shared/TileImageLoader.cs index 32d087f5..99ae8f19 100644 --- a/MapControl/Shared/TileImageLoader.cs +++ b/MapControl/Shared/TileImageLoader.cs @@ -150,15 +150,15 @@ namespace MapControl private static async Task LoadTileImage(Tile tile, TileSource tileSource, string cacheName) { // Pass tileSource.LoadImageAsync calls to platform-specific method - // LoadTileImage(Tile, Func>) for execution on the UI thread in WinUI and UWP. + // tile.LoadImageAsync(Func>) for execution on the UI thread in WinUI and UWP. if (string.IsNullOrEmpty(cacheName)) { - await tile.LoadImageAsync(() => tileSource.LoadImageAsync(tile.Column, tile.Row, tile.ZoomLevel)).ConfigureAwait(false); + await tile.LoadImageAsync(() => tileSource.LoadImageAsync(tile.ZoomLevel, tile.Column, tile.Row)).ConfigureAwait(false); } else { - var uri = tileSource.GetUri(tile.Column, tile.Row, tile.ZoomLevel); + var uri = tileSource.GetUri(tile.ZoomLevel, tile.Column, tile.Row); if (uri != null) { diff --git a/MapControl/Shared/TileSource.cs b/MapControl/Shared/TileSource.cs index 15885b84..d6a27827 100644 --- a/MapControl/Shared/TileSource.cs +++ b/MapControl/Shared/TileSource.cs @@ -48,16 +48,16 @@ namespace MapControl /// /// Gets the image Uri for the specified tile indices and zoom level. /// - public virtual Uri GetUri(int column, int row, int zoomLevel) + public virtual Uri GetUri(int zoomLevel, int column, int row) { Uri uri = null; if (UriTemplate != null) { var uriString = UriTemplate + .Replace("{z}", zoomLevel.ToString()) .Replace("{x}", column.ToString()) - .Replace("{y}", row.ToString()) - .Replace("{z}", zoomLevel.ToString()); + .Replace("{y}", row.ToString()); if (Subdomains != null && Subdomains.Length > 0) { @@ -71,12 +71,12 @@ namespace MapControl } /// - /// Loads a tile ImageSource asynchronously from GetUri(column, row, zoomLevel). + /// Loads a tile ImageSource asynchronously from GetUri(zoomLevel, column, row). /// This method is called by TileImageLoader when caching is disabled. /// - public virtual Task LoadImageAsync(int column, int row, int zoomLevel) + public virtual Task LoadImageAsync(int zoomLevel, int column, int row) { - var uri = GetUri(column, row, zoomLevel); + var uri = GetUri(zoomLevel, column, row); return uri != null ? ImageLoader.LoadImageAsync(uri) : Task.FromResult((ImageSource)null); } @@ -106,9 +106,9 @@ namespace MapControl public class TmsTileSource : TileSource { - public override Uri GetUri(int column, int row, int zoomLevel) + public override Uri GetUri(int zoomLevel, int column, int row) { - return base.GetUri(column, (1 << zoomLevel) - 1 - row, zoomLevel); + return base.GetUri(zoomLevel, column, (1 << zoomLevel) - 1 - row); } } } diff --git a/MapControl/WinUI/Tile.WinUI.cs b/MapControl/WinUI/Tile.WinUI.cs index a31c9f3d..ffc56d66 100644 --- a/MapControl/WinUI/Tile.WinUI.cs +++ b/MapControl/WinUI/Tile.WinUI.cs @@ -22,7 +22,7 @@ namespace MapControl { var tcs = new TaskCompletionSource(); - async void LoadImage() + async void LoadAndSetImageSource() { try { @@ -51,9 +51,9 @@ namespace MapControl } } #if UWP - if (!await Image.Dispatcher.TryRunAsync(CoreDispatcherPriority.Low, LoadImage)) + if (!await Image.Dispatcher.TryRunAsync(CoreDispatcherPriority.Low, LoadAndSetImageSource)) #else - if (!Image.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, LoadImage)) + if (!Image.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, LoadAndSetImageSource)) #endif { tcs.TrySetCanceled();