From 68cb0ee3fd744c88a070ec534adb88d28c821410 Mon Sep 17 00:00:00 2001 From: glax Date: Sun, 23 Apr 2023 13:06:29 +0200 Subject: [PATCH] Filter MaxValueWeights --- RenderPath/Renderer.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/RenderPath/Renderer.cs b/RenderPath/Renderer.cs index 95c6095..c67b15e 100644 --- a/RenderPath/Renderer.cs +++ b/RenderPath/Renderer.cs @@ -136,13 +136,16 @@ public static class Renderer public static ValueTuple DrawGScores(Dictionary gScoreDict, Image? renderOver = null, Bounds? bounds = null) { - float minLat = bounds?.minLat ?? gScoreDict.Min(kv => kv.Key.coordinates.latitude); - float minLon = bounds?.minLon ?? gScoreDict.Min(kv => kv.Key.coordinates.longitude); - float maxLat = bounds?.maxLat ?? gScoreDict.Max(kv => kv.Key.coordinates.latitude); - float maxLon = bounds?.maxLon ?? gScoreDict.Max(kv => kv.Key.coordinates.longitude); + Dictionary gScore = + gScoreDict.Where(kv => kv.Value < double.MaxValue).ToDictionary(pair => pair.Key, pair => pair.Value); + + float minLat = bounds?.minLat ?? gScore.Min(kv => kv.Key.coordinates.latitude); + float minLon = bounds?.minLon ?? gScore.Min(kv => kv.Key.coordinates.longitude); + float maxLat = bounds?.maxLat ?? gScore.Max(kv => kv.Key.coordinates.latitude); + float maxLon = bounds?.maxLon ?? gScore.Max(kv => kv.Key.coordinates.longitude); - double minWeight = gScoreDict.Min(kv => kv.Value); - double maxWeight = gScoreDict.Max(kv => kv.Value); + double minWeight = gScore.Min(kv => kv.Value); + double maxWeight = gScore.Max(kv => kv.Value); float latDiff = maxLat - minLat; float lonDiff = maxLon - minLon; @@ -159,7 +162,7 @@ public static class Renderer float pointSize = PenThickness * 1.5f; - foreach (KeyValuePair kv in gScoreDict) + foreach (KeyValuePair kv in gScore) { double percentage = (kv.Value - minWeight) / (maxWeight - minWeight); Brush b = new SolidBrush(GradientPick(percentage, WeightStartColor, WeightCenterColor, WeightEndColor));