Roads are now painted according to priority.

This commit is contained in:
glax 2023-04-21 14:37:38 +02:00
parent cf5b1e9945
commit 33232a7eb7

View File

@ -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;