From 65462697df8b4cba968dcce1735d35cd1eb54b20 Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Wed, 26 Nov 2025 23:34:22 +0100 Subject: [PATCH] Primary constructor parameters --- MapControl/Shared/CenteredBoundingBox.cs | 2 +- MapControl/Shared/MapGraticule.cs | 10 +++++----- MapControl/Shared/Tile.cs | 8 ++++---- MapControl/Shared/TileMatrix.cs | 10 +++++----- MapControl/Shared/ViewportChangedEventArgs.cs | 4 ++-- MapControl/Shared/WmtsTileMatrix.cs | 20 ++++++++++++------- MapControl/Shared/WmtsTileMatrixLayer.cs | 10 ++++------ MapControl/WPF/BitmapTileMatrixLayer.cs | 2 +- 8 files changed, 35 insertions(+), 31 deletions(-) diff --git a/MapControl/Shared/CenteredBoundingBox.cs b/MapControl/Shared/CenteredBoundingBox.cs index df0bdb24..54ab920c 100644 --- a/MapControl/Shared/CenteredBoundingBox.cs +++ b/MapControl/Shared/CenteredBoundingBox.cs @@ -4,7 +4,7 @@ namespace MapControl { public class CenteredBoundingBox(Location center, double width, double height) : BoundingBox { - public override Location Center { get; } = center; + public override Location Center => center; public override double Width { get; } = Math.Max(width, 0d); public override double Height { get; } = Math.Max(height, 0d); } diff --git a/MapControl/Shared/MapGraticule.cs b/MapControl/Shared/MapGraticule.cs index 7a3f10bb..c73183f4 100644 --- a/MapControl/Shared/MapGraticule.cs +++ b/MapControl/Shared/MapGraticule.cs @@ -27,11 +27,11 @@ namespace MapControl { private class Label(string latText, string lonText, double x, double y, double rotation) { - public string LatitudeText { get; } = latText; - public string LongitudeText { get; } = lonText; - public double X { get; } = x; - public double Y { get; } = y; - public double Rotation { get; } = rotation; + public string LatitudeText => latText; + public string LongitudeText => lonText; + public double X => x; + public double Y => y; + public double Rotation => rotation; } private const double LineInterpolationResolution = 2d; diff --git a/MapControl/Shared/Tile.cs b/MapControl/Shared/Tile.cs index cbb5fcc8..779068c9 100644 --- a/MapControl/Shared/Tile.cs +++ b/MapControl/Shared/Tile.cs @@ -14,11 +14,11 @@ namespace MapControl { public abstract class Tile(int zoomLevel, int x, int y, int columnCount) { - public int ZoomLevel { get; } = zoomLevel; - public int X { get; } = x; - public int Y { get; } = y; + public int ZoomLevel => zoomLevel; + public int X => x; + public int Y => y; + public int Row => y; public int Column { get; } = ((x % columnCount) + columnCount) % columnCount; - public int Row => Y; public bool IsPending { get; set; } = true; diff --git a/MapControl/Shared/TileMatrix.cs b/MapControl/Shared/TileMatrix.cs index 2ecf4dd5..07c0a5df 100644 --- a/MapControl/Shared/TileMatrix.cs +++ b/MapControl/Shared/TileMatrix.cs @@ -2,10 +2,10 @@ { public class TileMatrix(int zoomLevel, int xMin, int yMin, int xMax, int yMax) { - public int ZoomLevel { get; } = zoomLevel; - public int XMin { get; } = xMin; - public int YMin { get; } = yMin; - public int XMax { get; } = xMax; - public int YMax { get; } = yMax; + public int ZoomLevel => zoomLevel; + public int XMin => xMin; + public int YMin => yMin; + public int XMax => xMax; + public int YMax => yMax; } } diff --git a/MapControl/Shared/ViewportChangedEventArgs.cs b/MapControl/Shared/ViewportChangedEventArgs.cs index d7e220f9..395db62c 100644 --- a/MapControl/Shared/ViewportChangedEventArgs.cs +++ b/MapControl/Shared/ViewportChangedEventArgs.cs @@ -9,12 +9,12 @@ namespace MapControl /// a MapTileLayer or a MapImageLayer should be updated immediately, /// or MapPath Data in projected map coordinates should be recalculated. /// - public bool ProjectionChanged { get; } = projectionChanged; + public bool ProjectionChanged => projectionChanged; /// /// Indicates that the view transform center has moved across 180° longitude. /// Used to control when a MapTileLayer should be updated immediately. /// - public bool TransformCenterChanged { get; } = transformCenterChanged; + public bool TransformCenterChanged => transformCenterChanged; } } diff --git a/MapControl/Shared/WmtsTileMatrix.cs b/MapControl/Shared/WmtsTileMatrix.cs index 6baed45f..7022f1c0 100644 --- a/MapControl/Shared/WmtsTileMatrix.cs +++ b/MapControl/Shared/WmtsTileMatrix.cs @@ -10,12 +10,18 @@ namespace MapControl string identifier, double scale, Point topLeft, int tileWidth, int tileHeight, int matrixWidth, int matrixHeight) { - public string Identifier { get; } = identifier; - public double Scale { get; } = scale; - public Point TopLeft { get; } = topLeft; - public int TileWidth { get; } = tileWidth; - public int TileHeight { get; } = tileHeight; - public int MatrixWidth { get; } = matrixWidth; - public int MatrixHeight { get; } = matrixHeight; + public string Identifier => identifier; + public double Scale => scale; + public Point TopLeft => topLeft; + public int TileWidth => tileWidth; + public int TileHeight => tileHeight; + public int MatrixWidth => matrixWidth; + public int MatrixHeight => matrixHeight; + + // Indicates if the total width in meters covers the whole earth + // circumference (minus one millimeter for floating point precision). + // + public bool HasFullHorizontalCoverage { get; } = + matrixWidth * tileWidth / scale >= 360d * MapProjection.Wgs84MeterPerDegree - 1e-3; } } diff --git a/MapControl/Shared/WmtsTileMatrixLayer.cs b/MapControl/Shared/WmtsTileMatrixLayer.cs index 550abd11..77a623f8 100644 --- a/MapControl/Shared/WmtsTileMatrixLayer.cs +++ b/MapControl/Shared/WmtsTileMatrixLayer.cs @@ -60,18 +60,16 @@ namespace MapControl var xMax = (int)Math.Floor((bounds.X + bounds.Width) / WmtsTileMatrix.TileWidth); var yMax = (int)Math.Floor((bounds.Y + bounds.Height) / WmtsTileMatrix.TileHeight); - // Total tile matrix width in meters. - // - var totalWidth = WmtsTileMatrix.MatrixWidth * WmtsTileMatrix.TileWidth / WmtsTileMatrix.Scale; - - if (Math.Abs(totalWidth - 360d * MapProjection.Wgs84MeterPerDegree) > 1d) + if (!WmtsTileMatrix.HasFullHorizontalCoverage) { - // No full longitudinal coverage, restrict x index. + // Set X range limits. // xMin = Math.Max(xMin, 0); xMax = Math.Min(Math.Max(xMax, 0), WmtsTileMatrix.MatrixWidth - 1); } + // Set Y range limits. + // yMin = Math.Max(yMin, 0); yMax = Math.Min(Math.Max(yMax, 0), WmtsTileMatrix.MatrixHeight - 1); diff --git a/MapControl/WPF/BitmapTileMatrixLayer.cs b/MapControl/WPF/BitmapTileMatrixLayer.cs index a08e14bb..7a40228f 100644 --- a/MapControl/WPF/BitmapTileMatrixLayer.cs +++ b/MapControl/WPF/BitmapTileMatrixLayer.cs @@ -42,7 +42,7 @@ namespace MapControl Transform = new MatrixTransform() }; - public WmtsTileMatrix WmtsTileMatrix { get; } = wmtsTileMatrix; + public WmtsTileMatrix WmtsTileMatrix => wmtsTileMatrix; public TileMatrix TileMatrix { get; private set; } = new TileMatrix(zoomLevel, 1, 1, 0, 0);