From 0a522baba5abc247b52b306d9c51123e4ba07cb6 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 23 Jul 2024 16:14:53 +0200 Subject: [PATCH] Updated to match dependencies --- Graph_Renderer/Coloring.cs | 11 +++-------- Graph_Renderer/Renderer.cs | 6 +++--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Graph_Renderer/Coloring.cs b/Graph_Renderer/Coloring.cs index 760778a..6e0d438 100644 --- a/Graph_Renderer/Coloring.cs +++ b/Graph_Renderer/Coloring.cs @@ -1,7 +1,6 @@ using System.Drawing; using System.Runtime.Versioning; -using astar.PathingHelper; -using Graph; +using OSM_Graph.Enums; using static System.Drawing.Color; namespace Graph_Renderer; @@ -10,13 +9,9 @@ namespace Graph_Renderer; public static class Coloring { public static Pen DefaultPen = new(Gray, 2); - public static Pen GetPenForWay(Way way) + public static Pen GetPenForWay(OSM_Graph.Way way) { - if (!way.Tags.TryGetValue("highway", out string? highwayTypeStr)) - return DefaultPen; - if (!Enum.TryParse(highwayTypeStr, out HighwayType highwayType)) - return DefaultPen; - return ColorDictionary[highwayType]; + return ColorDictionary[way.GetHighwayType()]; } private static readonly Dictionary ColorDictionary = new() { diff --git a/Graph_Renderer/Renderer.cs b/Graph_Renderer/Renderer.cs index 7b1f866..6343f7e 100644 --- a/Graph_Renderer/Renderer.cs +++ b/Graph_Renderer/Renderer.cs @@ -24,7 +24,7 @@ public static class Renderer using(GraphicsPath capPath = new ()) { // A triangle - capPath.AddLines(new Point[]{new (-2, -2), new (0, 2), new (2, -2)}); + capPath.AddLines(new Point[]{new (-2, -2), new (0, 0), new (2, -2)}); previous.CustomEndCap = new CustomLineCap(null, capPath); } @@ -34,10 +34,10 @@ public static class Renderer Point startCoordinates = PixelCoordinatesFromGeoCoordinates(node, minCoordinates, multiplier, bitmap.Height); //All neighbors - foreach ((ulong neighborNodeId, ulong wayId) in node.Neighbors.Where(kv => r.Graph.ContainsNode(kv.Key))) + foreach ((ulong neighborNodeId, KeyValuePair wayId) in node.Neighbors.Where(kv => r.Graph.ContainsNode(kv.Key))) { Point endCoordinates = PixelCoordinatesFromGeoCoordinates(r.Graph.Nodes[neighborNodeId], minCoordinates, multiplier, bitmap.Height); - graphics.DrawLine(Coloring.GetPenForWay(r.Graph.Ways[wayId]), startCoordinates, endCoordinates); + graphics.DrawLine(Coloring.GetPenForWay(r.Graph.Ways[wayId.Key]), startCoordinates, endCoordinates); } //Previous