Compare commits
12 Commits
f6d55c7f3e
...
db6d6ccaef
Author | SHA1 | Date | |
---|---|---|---|
db6d6ccaef | |||
7e1d03abf7 | |||
cb7500a4fa | |||
94234b3498 | |||
f1c7ff4b47 | |||
cc48016874 | |||
6db8278581 | |||
3770ff9b57 | |||
4c0a3edd4a | |||
32a9f8afa6 | |||
413052e031 | |||
8f42c34b97 |
@ -2,9 +2,10 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,11 +1,49 @@
|
||||
using Graph;
|
||||
using GeoGraph;
|
||||
using Logging;
|
||||
using astar;
|
||||
using OSM_XML_Importer;
|
||||
|
||||
Logger logger = new (LogType.CONSOLE, LogLevel.DEBUG);
|
||||
Graph.Graph graph = Importer.Import(@"C:\Users\glax\Downloads\oberbayern-latest.osm", true, logger);
|
||||
logger.level = LogLevel.DEBUG;
|
||||
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);
|
||||
|
||||
Random r = new();
|
||||
Route _route;
|
||||
|
11
README.md
11
README.md
@ -1,8 +1,11 @@
|
||||
### astar
|
||||
Test of A* Algorithm
|
||||
# astar
|
||||
Test of A* Algorithm on real-world road data
|
||||
|
||||
# Linked Repos
|
||||
## Usage
|
||||
`Executable.exe <path to osm.xml> <junctions-only-mode 'yes','1','true'>`
|
||||
|
||||
### 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)
|
||||
|
13
astar/.idea/.idea.astar/.idea/.gitignore
vendored
Normal file
13
astar/.idea/.idea.astar/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# 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
|
4
astar/.idea/.idea.astar/.idea/encodings.xml
Normal file
4
astar/.idea/.idea.astar/.idea/encodings.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
10
astar/.idea/.idea.astar/.idea/indexLayout.xml
Normal file
10
astar/.idea/.idea.astar/.idea/indexLayout.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders>
|
||||
<Path>../../astar</Path>
|
||||
</attachedFolders>
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
7
astar/.idea/.idea.astar/.idea/vcs.xml
Normal file
7
astar/.idea/.idea.astar/.idea/vcs.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?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>
|
@ -1,6 +1,6 @@
|
||||
using Logging;
|
||||
using Graph;
|
||||
using Graph.Utils;
|
||||
using GeoGraph;
|
||||
using GeoGraph.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 graph, Node start, Node goal, Logger? logger)
|
||||
public Route FindPath(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,10 +20,6 @@ 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
|
||||
@ -34,6 +30,7 @@ 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);
|
||||
}
|
||||
}
|
||||
@ -53,14 +50,13 @@ 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();
|
||||
|
||||
@ -69,10 +65,8 @@ 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;
|
||||
}
|
||||
|
||||
@ -97,6 +91,7 @@ namespace astar
|
||||
}
|
||||
|
||||
return _route;
|
||||
#pragma warning restore CS8604, CS8600
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Graph;
|
||||
using GeoGraph;
|
||||
namespace astar
|
||||
{
|
||||
public class Route
|
||||
|
@ -1,9 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>12</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
2
astar/astar.sln.DotSettings.user
Normal file
2
astar/astar.sln.DotSettings.user
Normal file
@ -0,0 +1,2 @@
|
||||
<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>
|
Loading…
Reference in New Issue
Block a user