2022-11-17 20:39:50 +01:00
|
|
|
|
using GeoGraph;
|
2022-11-01 05:08:52 +01:00
|
|
|
|
using Logging;
|
|
|
|
|
using astar;
|
2022-11-13 15:29:31 +01:00
|
|
|
|
using OSM_XML_Importer;
|
2022-11-01 05:08:52 +01:00
|
|
|
|
|
2022-11-13 16:53:03 +01:00
|
|
|
|
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))
|
|
|
|
|
{
|
2022-11-13 16:55:22 +01:00
|
|
|
|
logger.Log(LogLevel.INFO, "File {0} does not exist.", xmlPath);
|
|
|
|
|
throw new FileNotFoundException(xmlPath);
|
2022-11-13 16:53:03 +01:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
xmlPath = args[0];
|
|
|
|
|
if (!File.Exists(xmlPath))
|
|
|
|
|
{
|
2022-11-13 16:55:22 +01:00
|
|
|
|
logger.Log(LogLevel.INFO, "File {0} does not exist.", xmlPath);
|
|
|
|
|
throw new FileNotFoundException(xmlPath);
|
2022-11-13 16:53:03 +01:00
|
|
|
|
}
|
|
|
|
|
if (confirmation.Contains(args[1].ToLower()))
|
|
|
|
|
onlyJunctions = true;
|
|
|
|
|
else
|
|
|
|
|
onlyJunctions = false;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2022-11-13 16:55:22 +01:00
|
|
|
|
logger.Log(LogLevel.INFO, "Invalid Arguments.");
|
2022-11-13 16:53:03 +01:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 20:39:50 +01:00
|
|
|
|
Graph graph = Importer.Import(xmlPath, onlyJunctions, logger);
|
2022-11-01 05:08:52 +01:00
|
|
|
|
|
|
|
|
|
Random r = new();
|
2022-11-03 19:14:14 +01:00
|
|
|
|
Route _route;
|
2022-11-01 05:08:52 +01:00
|
|
|
|
Node n1, n2;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
2022-11-13 14:59:06 +01:00
|
|
|
|
n1 = graph.NodeAtIndex(r.Next(0, graph.GetNodeCount() - 1));
|
|
|
|
|
n2 = graph.NodeAtIndex(r.Next(0, graph.GetNodeCount() - 1));
|
2022-11-13 14:02:27 +01:00
|
|
|
|
_route = new Astar().FindPath(graph, n1, n2, logger);
|
2022-11-03 19:14:14 +01:00
|
|
|
|
} while (!_route.routeFound);
|
2022-11-13 15:03:35 +01:00
|
|
|
|
logger.Log(LogLevel.INFO, "Press Enter to find new path.");
|
2022-11-13 16:53:03 +01:00
|
|
|
|
} while (Console.ReadKey().Key.Equals(ConsoleKey.Enter));
|