Compare commits

..

No commits in common. "db6d6ccaefeb9c4f2920cb7e23e58beac56f7ae5" and "f6d55c7f3e33e0234f16a4ba1115f5fa83f41013" have entirely different histories.

11 changed files with 25 additions and 99 deletions

View File

@ -2,10 +2,9 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>12</LangVersion>
</PropertyGroup>
<ItemGroup>

View File

@ -1,49 +1,11 @@
using GeoGraph;
using Graph;
using Logging;
using astar;
using OSM_XML_Importer;
string[] confirmation = { "yes", "1", "true" };
Logger logger = new (LogType.CONSOLE, LogLevel.DEBUG);
string xmlPath;
bool onlyJunctions;
switch (args.Length)
{
case 0:
xmlPath = @"";
onlyJunctions = true;
break;
case 1:
xmlPath = args[0];
onlyJunctions = true;
if (!File.Exists(xmlPath))
{
logger.Log(LogLevel.INFO, "File {0} does not exist.", xmlPath);
throw new FileNotFoundException(xmlPath);
}
break;
case 2:
xmlPath = args[0];
if (!File.Exists(xmlPath))
{
logger.Log(LogLevel.INFO, "File {0} does not exist.", xmlPath);
throw new FileNotFoundException(xmlPath);
}
if (confirmation.Contains(args[1].ToLower()))
onlyJunctions = true;
else
onlyJunctions = false;
break;
default:
logger.Log(LogLevel.INFO, "Invalid Arguments.");
logger.Log(LogLevel.INFO, "Arguments can be:");
logger.Log(LogLevel.INFO, "arg0 Path to file: string");
logger.Log(LogLevel.INFO, "arg1 onlyJunctions: 'yes', '1', 'true'");
return;
}
Graph graph = Importer.Import(xmlPath, onlyJunctions, logger);
Graph.Graph graph = Importer.Import(@"C:\Users\glax\Downloads\oberbayern-latest.osm", true, logger);
logger.level = LogLevel.DEBUG;
Random r = new();
Route _route;

View File

@ -1,11 +1,8 @@
# astar
Test of A* Algorithm on real-world road data
### astar
Test of A* Algorithm
## Usage
`Executable.exe <path to osm.xml> <junctions-only-mode 'yes','1','true'>`
# Linked Repos
### Linked Repos
- [Logging](https://github.com/C9Glax/Logging)
- [OSM-XML-Importer](https://github.com/C9Glax/OSM-XML-Importer)
- [Geo-Graph](https://github.com/C9Glax/Geo-Graph)
- [OSM-Landmarks](https://github.com/C9Glax/OSM-Landmarks)

View File

@ -1,13 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/projectSettingsUpdater.xml
/.idea.astar.iml
/contentModel.xml
/modules.xml
# 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,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders>
<Path>../../astar</Path>
</attachedFolders>
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

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

View File

@ -1,6 +1,6 @@
using Logging;
using GeoGraph;
using GeoGraph.Utils;
using Graph;
using Graph.Utils;
namespace astar
{
@ -10,7 +10,7 @@ namespace astar
private Dictionary<Node, float> goalDistance = new();
private Dictionary<Node, Node> previousNode = new();
public Route FindPath(Graph graph, Node start, Node goal, Logger? logger)
public Route FindPath(Graph.Graph graph, Node start, Node goal, Logger? logger)
{
logger?.Log(LogLevel.INFO, "From {0:000.00000}#{1:000.00000} to {2:000.00000}#{3:000.00000} Great-Circle {4:00000.00}km", start.lat, start.lon, goal.lat, goal.lon, Utils.DistanceBetweenNodes(start, goal)/1000);
List<Node> toVisit = new();
@ -20,6 +20,10 @@ namespace astar
SetDistanceToGoal(start, Convert.ToSingle(Utils.DistanceBetweenNodes(start, goal)));
while (toVisit.Count > 0 && GetTimeRequiredToReach(toVisit[0]) < GetTimeRequiredToReach(goal))
{
if(currentNode == goal)
{
logger?.Log(LogLevel.INFO, "Way found, checking for shorter option.");
}
currentNode = toVisit.First();
logger?.Log(LogLevel.VERBOSE, "toVisit-length: {0} path-length: {1} goal-distance: {2}", toVisit.Count, timeRequired[currentNode], goalDistance[currentNode]);
//Check all neighbors of current node
@ -30,7 +34,6 @@ namespace astar
SetDistanceToGoal(e.neighbor, Convert.ToSingle(Utils.DistanceBetweenNodes(e.neighbor, goal)));
SetTimeRequiredToReach(e.neighbor, GetTimeRequiredToReach(currentNode) + e.time);
SetPreviousNodeOf(e.neighbor, currentNode);
if (!toVisit.Contains(e.neighbor))
toVisit.Add(e.neighbor);
}
}
@ -50,13 +53,14 @@ namespace astar
return new Route(new List<Step>(), false, float.MaxValue, float.MaxValue);
}
#pragma warning disable CS8604, CS8600 // Route was found, so has to have a previous node and edges
List<Node> tempNodes = new();
tempNodes.Add(goal);
while(currentNode != start)
{
#pragma warning disable CS8604, CS8600 // Route was found, so has to have a previous node
tempNodes.Add(GetPreviousNodeOf(currentNode));
currentNode = GetPreviousNodeOf(currentNode);
#pragma warning restore CS8604, CS8600
}
tempNodes.Reverse();
@ -65,8 +69,10 @@ namespace astar
for(int i = 0; i < tempNodes.Count - 1; i++)
{
#pragma warning disable CS8600, CS8604 // Route was found, so has to have an edge
Edge e = tempNodes[i].GetEdgeToNode(tempNodes[i + 1]);
steps.Add(new Step(tempNodes[i], e, GetTimeRequiredToReach(tempNodes[i]), GetDistanceToGoal(tempNodes[i])));
#pragma warning restore CS8600, CS8604
totalDistance += e.distance;
}
@ -91,7 +97,6 @@ namespace astar
}
return _route;
#pragma warning restore CS8604, CS8600
}
/*

View File

@ -1,4 +1,4 @@
using GeoGraph;
using Graph;
namespace astar
{
public class Route

View File

@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>12</LangVersion>
</PropertyGroup>
<ItemGroup>

View File

@ -1,2 +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_005CGeo_002DGraph_005CGeo_002DGraph_005Cbin_005CDebug_005Cnet6_002E0_005CGeo_002DGraph_002Edll/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>