Compare commits

..

No commits in common. "61626a207b4d13c1e2bea34de39fdf2ecb59ce57" and "8f869b316d01c14c0ec6f07c2d3423239106a970" have entirely different histories.

11 changed files with 0 additions and 255 deletions

5
.gitignore vendored
View File

@ -1,5 +0,0 @@
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/

View File

@ -1,13 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/projectSettingsUpdater.xml
/modules.xml
/contentModel.xml
/.idea.Graph_Renderer.iml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -1,16 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Graph_Renderer", "Graph_Renderer\Graph_Renderer.csproj", "{024707C9-9048-4C3F-A2AC-80D74356EE4E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{024707C9-9048-4C3F-A2AC-80D74356EE4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{024707C9-9048-4C3F-A2AC-80D74356EE4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{024707C9-9048-4C3F-A2AC-80D74356EE4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{024707C9-9048-4C3F-A2AC-80D74356EE4E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -1,4 +0,0 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CGlax_005CRiderProjects_005Castar_005CExecutable_005Cbin_005CDebug_005Cnet8_002E0_005Castar_002Edll/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CGlax_005CRiderProjects_005COSM_005FGraph_005COSM_005FGraph_005Cbin_005CDebug_005Cnet8_002E0_005CGraph_002Edll/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CGlax_005CRiderProjects_005COSM_005FGraph_005COSM_005FGraph_005Cbin_005CDebug_005Cnet8_002E0_005COSM_005FGraph_002Edll/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -1,49 +0,0 @@
using System.Drawing;
using astar.PathingHelper;
using Graph;
namespace Graph_Renderer;
public static class Coloring
{
public static Color GetColorForWay(Way way)
{
if (!way.Tags.TryGetValue("highway", out string? highwayTypeStr))
return Color.Gray;
if (!Enum.TryParse(highwayTypeStr, out HighwayType highwayType))
return Color.Gray;
return ColorDictionary[highwayType];
}
private static readonly Dictionary<HighwayType, Color> ColorDictionary = new() {
{ HighwayType.NONE, Color.Gray },
{ HighwayType.motorway, Color.OrangeRed },
{ HighwayType.trunk, Color.Orange },
{ HighwayType.primary, Color.Yellow },
{ HighwayType.secondary, Color.Aqua },
{ HighwayType.tertiary, Color.Black },
{ HighwayType.unclassified, Color.Gray },
{ HighwayType.residential, Color.Gray },
{ HighwayType.motorway_link, Color.OrangeRed },
{ HighwayType.trunk_link, Color.Orange },
{ HighwayType.primary_link, Color.Yellow },
{ HighwayType.secondary_link, Color.Aqua },
{ HighwayType.tertiary_link, Color.Black },
{ HighwayType.living_street, Color.Gray },
{ HighwayType.service, Color.Gray },
{ HighwayType.pedestrian, Color.ForestGreen },
{ HighwayType.track, Color.Gray },
{ HighwayType.bus_guideway, Color.Navy },
{ HighwayType.escape, Color.Gray },
{ HighwayType.raceway, Color.Gray },
{ HighwayType.road, Color.Gray },
{ HighwayType.busway, Color.Navy },
{ HighwayType.footway, Color.GreenYellow },
{ HighwayType.bridleway, Color.Gray },
{ HighwayType.steps, Color.PaleGreen },
{ HighwayType.corridor, Color.Green },
{ HighwayType.path, Color.Green },
{ HighwayType.cycleway, Color.Salmon },
{ HighwayType.construction, Color.Gray }
};
}

View File

@ -1,28 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Reference Include="astar">
<HintPath>..\..\astar\Executable\bin\Debug\net8.0\astar.dll</HintPath>
</Reference>
<Reference Include="Graph">
<HintPath>..\..\OSM_Graph\OSM_Graph\bin\Debug\net8.0\Graph.dll</HintPath>
</Reference>
<Reference Include="OSM_Graph">
<HintPath>..\..\OSM_Graph\OSM_Graph\bin\Debug\net8.0\OSM_Graph.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="GlaxArguments" Version="1.1.0" />
<PackageReference Include="GlaxLogger" Version="1.0.7.2" />
<PackageReference Include="System.Drawing.Common" Version="8.0.7" />
</ItemGroup>
</Project>

View File

@ -1,43 +0,0 @@
// See https://aka.ms/new-console-template for more information
using System.Globalization;
using System.Runtime.InteropServices;
using astar;
using GlaxArguments;
using GlaxLogger;
using Graph_Renderer;
using Microsoft.Extensions.Logging;
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Console.WriteLine("Only runs on Windows. Sorry.");
return -1;
}
Argument regionArg = new (["-r", "--regionSize"], 1, "Region-Size");
Argument importPathArg = new (["-i", "--importPath"], 1, "Region-Directory");
Argument routeCoordinateArg = new(["-c", "--route", "--coordinates"], 4, "Start and end coordinates");
ArgumentFetcher af = new ([regionArg, importPathArg, routeCoordinateArg]);
Dictionary<Argument, string[]> arguments = af.Fetch(args);
if (!arguments.TryGetValue(regionArg, out string[]? regionVal) ||
!float.TryParse(regionVal[0], NumberFormatInfo.InvariantInfo, out float regionSize) ||
!arguments.TryGetValue(importPathArg, out string[]? importPathVal) ||
!arguments.TryGetValue(routeCoordinateArg, out string[]? routeCoordinateVal) ||
!float.TryParse(routeCoordinateVal[0], NumberFormatInfo.InvariantInfo, out float startLat) ||
!float.TryParse(routeCoordinateVal[1], NumberFormatInfo.InvariantInfo, out float startLon) ||
!float.TryParse(routeCoordinateVal[2], NumberFormatInfo.InvariantInfo, out float endLat) ||
!float.TryParse(routeCoordinateVal[3], NumberFormatInfo.InvariantInfo, out float endLon))
{
return -1;
}
Logger logger = new(LogLevel.Information, consoleOut: Console.Out);
Route r = Astar.FindPath(startLat, startLon, endLat, endLon, regionSize, true, importPathVal[0], logger);
Renderer.Render(r, 30000, "render.png");
return 0;

View File

@ -1,79 +0,0 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.Versioning;
using astar;
namespace Graph_Renderer;
public static class Renderer
{
[SupportedOSPlatform("Windows")]
public static void Render(Route r, int longestEdge, string outputPath)
{
ValueTuple<float, float> minCoordinates = r.MinCoordinates();
ValueTuple<float, float> maxCoordinates = r.MaxCoordinates();
float deltaLat = maxCoordinates.Item1 - minCoordinates.Item1;
float deltaLon = maxCoordinates.Item2 - minCoordinates.Item2;
float multiplier = deltaLat > deltaLon ? longestEdge / deltaLat : longestEdge / deltaLon;
Bitmap bitmap = new((int)(deltaLon * multiplier), (int)(deltaLat * multiplier), System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
Graphics graphics = Graphics.FromImage(bitmap);
Pen previous = new (Color.White, 2);
using(GraphicsPath capPath = new ())
{
// A triangle
capPath.AddLines(new Point[]{new (-2, -2), new (0, 2), new (2, -2)});
previous.CustomEndCap = new CustomLineCap(null, capPath);
}
foreach ((ulong nodeId, Node? node) in r.Graph.Nodes)
{
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)))
{
Point endCoordinates = PixelCoordinatesFromGeoCoordinates(r.Graph.Nodes[neighborNodeId], minCoordinates, multiplier, bitmap.Height);
graphics.DrawLine(new Pen(Coloring.GetColorForWay(r.Graph.Ways[wayId]), 2), startCoordinates, endCoordinates);
}
//Previous
if (node.PreviousNodeId is not null)
{
Point previousCoordinates = PixelCoordinatesFromGeoCoordinates(r.Graph.Nodes[(ulong)node.PreviousNodeId], minCoordinates, multiplier, bitmap.Height);
graphics.DrawLine(previous, startCoordinates, previousCoordinates);
}
}
if (r.RouteFound)
{
Pen route = new(Color.BlueViolet, 2);
foreach (Step step in r.Steps)
{
Point startCoordinates = PixelCoordinatesFromGeoCoordinates(step.Node1, minCoordinates, multiplier, bitmap.Height);
Point endCoordinates = PixelCoordinatesFromGeoCoordinates(step.Node2, minCoordinates, multiplier, bitmap.Height);
graphics.DrawLine(route, startCoordinates, endCoordinates);
}
}
Directory.CreateDirectory(new FileInfo(outputPath).DirectoryName!);
bitmap.Save(outputPath);
Console.WriteLine(outputPath);
}
private static Point PixelCoordinatesFromGeoCoordinates
(Node node, ValueTuple<float, float> minCoordinates, float multiplier, int height) =>
PixelCoordinatesFromGeoCoordinates(node.Lat, node.Lon, minCoordinates, multiplier, height);
private static Point PixelCoordinatesFromGeoCoordinates(float lat, float lon,
ValueTuple<float, float> minCoordinates, float multiplier, int height)
{
float pLat = lat - minCoordinates.Item1;
float pLon = lon - minCoordinates.Item2;
return new Point((int)(pLon * multiplier), height - (int)(pLat * multiplier));
}
}