From 2b3a8606c02589addeee4e1ae18bf039626ffc38 Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Fri, 19 Dec 2025 07:38:06 +0100 Subject: [PATCH] Updated MapPolypoint --- MapControl/Avalonia/MapPolypoint.Avalonia.cs | 9 ++++++--- MapControl/Shared/MapPath.cs | 20 +------------------- MapControl/Shared/WmsImageLayer.cs | 2 +- MapControl/WPF/MapPolypoint.WPF.cs | 5 ++++- MapControl/WinUI/MapPolypoint.WinUI.cs | 5 ++++- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/MapControl/Avalonia/MapPolypoint.Avalonia.cs b/MapControl/Avalonia/MapPolypoint.Avalonia.cs index d2e40abb..05779d43 100644 --- a/MapControl/Avalonia/MapPolypoint.Avalonia.cs +++ b/MapControl/Avalonia/MapPolypoint.Avalonia.cs @@ -81,7 +81,10 @@ namespace MapControl private void AddPolylinePoints(PathFigures figures, IEnumerable locations, double longitudeOffset, bool closed) { - var points = LocationsToView(locations, longitudeOffset); + var points = locations + .Select(location => LocationToView(location, longitudeOffset)) + .Where(point => point.HasValue) + .Select(point => point.Value); if (points.Any()) { @@ -120,8 +123,8 @@ namespace MapControl { if (figures.Count == 0) { - // Avalonia Shape seems to ignore PathGeometry with empty Figures collection - + // Avalonia Shape seems to ignore PathGeometry with empty Figures collection. + // figures.Add(new PathFigure { StartPoint = new Point(-1000, -1000) }); } diff --git a/MapControl/Shared/MapPath.cs b/MapControl/Shared/MapPath.cs index ba7549e5..b4e0dbc5 100644 --- a/MapControl/Shared/MapPath.cs +++ b/MapControl/Shared/MapPath.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -#if WPF +#if WPF using System.Windows; #elif UWP using Windows.UI.Xaml; @@ -123,21 +121,5 @@ namespace MapControl return point; } - - protected IEnumerable LocationsToMap(IEnumerable locations, double longitudeOffset) - { - return locations - .Select(location => LocationToMap(location, longitudeOffset)) - .Where(point => point.HasValue) - .Select(point => point.Value); - } - - protected IEnumerable LocationsToView(IEnumerable locations, double longitudeOffset) - { - return locations - .Select(location => LocationToView(location, longitudeOffset)) - .Where(point => point.HasValue) - .Select(point => point.Value); - } } } diff --git a/MapControl/Shared/WmsImageLayer.cs b/MapControl/Shared/WmsImageLayer.cs index 7ae97c8b..f66022bd 100644 --- a/MapControl/Shared/WmsImageLayer.cs +++ b/MapControl/Shared/WmsImageLayer.cs @@ -330,7 +330,7 @@ namespace MapControl { "J", Math.Round(imagePos.Y).ToString("F0") } }; - // GetRequestUri may modify queryParameters["LAYERS"] + // GetRequestUri may modify queryParameters["LAYERS"]. // uri = GetRequestUri(queryParameters) + "&QUERY_LAYERS=" + queryParameters["LAYERS"]; } diff --git a/MapControl/WPF/MapPolypoint.WPF.cs b/MapControl/WPF/MapPolypoint.WPF.cs index 5767c544..0b67fff2 100644 --- a/MapControl/WPF/MapPolypoint.WPF.cs +++ b/MapControl/WPF/MapPolypoint.WPF.cs @@ -79,7 +79,10 @@ namespace MapControl private void AddPolylinePoints(StreamGeometryContext context, IEnumerable locations, double longitudeOffset, bool closed) { - var points = LocationsToView(locations, longitudeOffset); + var points = locations + .Select(location => LocationToView(location, longitudeOffset)) + .Where(point => point.HasValue) + .Select(point => point.Value); if (points.Any()) { diff --git a/MapControl/WinUI/MapPolypoint.WinUI.cs b/MapControl/WinUI/MapPolypoint.WinUI.cs index 519ff6e7..168dd6c2 100644 --- a/MapControl/WinUI/MapPolypoint.WinUI.cs +++ b/MapControl/WinUI/MapPolypoint.WinUI.cs @@ -84,7 +84,10 @@ namespace MapControl private void AddPolylinePoints(PathFigureCollection figures, IEnumerable locations, double longitudeOffset, bool closed) { - var points = LocationsToView(locations, longitudeOffset); + var points = locations + .Select(location => LocationToView(location, longitudeOffset)) + .Where(point => point.HasValue) + .Select(point => point.Value); if (points.Any()) {