From 33232a7eb77b3f17ecfdb9c236cb5f288374ccd3 Mon Sep 17 00:00:00 2001 From: glax Date: Fri, 21 Apr 2023 14:37:38 +0200 Subject: [PATCH] Roads are now painted according to priority. --- RenderPath/Renderer.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/RenderPath/Renderer.cs b/RenderPath/Renderer.cs index 400d63b..4386176 100644 --- a/RenderPath/Renderer.cs +++ b/RenderPath/Renderer.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Drawing.Imaging; +using OSMDatastructure; using OSMDatastructure.Graph; using Pathfinding; @@ -14,6 +15,9 @@ public static class Renderer private static readonly Color WeightStartColor = Color.FromArgb(0, 0, 255); private static readonly Color WeightCenterColor = Color.FromArgb(255, 255, 0); private static readonly Color WeightEndColor = Color.FromArgb(0, 255, 0); + private static readonly Color RoadPrioStart = Color.FromArgb(155, 100, 100, 100); + private static readonly Color RoadPrioCenter = Color.FromArgb(255, 100, 200, 200); + private static readonly Color RoadPrioEnd = Color.FromArgb(255, 255, 180, 0); public class Bounds { @@ -65,20 +69,16 @@ public static class Renderer Graphics g = Graphics.FromImage(ret); g.Clear(Color.White); - //TODO Use road priority for roadcolor - Color start = Color.FromArgb(255, 25, 25, 25); - Color center = Color.FromArgb(255, 0, 0, 0); - Color end = Color.FromArgb(255, 0, 255, 0); - foreach (OsmNode node in nodes) { foreach (OsmEdge edge in node.edges) { + double priority = rm.GetPriorityForVehicle(Tag.SpeedType.car, edge, node) / 17; Coordinates c1 = node.coordinates; OsmNode nNode = rm.GetNode(edge.neighborId, edge.neighborRegion)!; Coordinates c2 = nNode.coordinates; - Pen p = new(GradientPick(0, start, center, end), PenThickness); + Pen p = new(GradientPick(priority, RoadPrioStart, RoadPrioCenter, RoadPrioEnd), PenThickness); float x1 = (c1.longitude - minLon) * scaleFactor; float y1 = (maxLat - c1.latitude) * scaleFactor; float x2 = (c2.longitude - minLon) * scaleFactor;