This commit is contained in:
C9Glax 2022-05-11 19:45:35 +02:00
parent bced45f688
commit a700d429d4
3 changed files with 14 additions and 14 deletions

View File

@ -1,3 +1,3 @@
Logging.Logger logger = new Logging.Logger(Logging.LogType.Console, Logging.loglevel.DEBUG);
Logging.Logger logger = new Logging.Logger(Logging.LogType.CONSOLE, Logging.LogLevel.DEBUG);
Dictionary<UInt64, Graph.Node> nodes = OpenStreetMap_Importer.Importer.Import(logger);
new astar.Astar(nodes, logger);

View File

@ -30,7 +30,7 @@ namespace OpenStreetMap_Importer
{
if (reader.Name == "way" && reader.IsStartElement())
{
logger?.Log(loglevel.VERBOSE, "WAY {0} nodes {1}", currentWay.highway.ToString(), currentWay.nodeIds.Count);
logger?.Log(LogLevel.VERBOSE, "WAY {0} nodes {1}", currentWay.highway.ToString(), currentWay.nodeIds.Count);
if (currentWay.highway != Way.highwayType.NONE)
{
ways.Add(currentWay);
@ -46,7 +46,7 @@ namespace OpenStreetMap_Importer
#pragma warning disable CS8604
string value = reader.GetAttribute("v");
string key = reader.GetAttribute("k");
logger?.Log(loglevel.VERBOSE, "TAG {0} {1}", key, value);
logger?.Log(LogLevel.VERBOSE, "TAG {0} {1}", key, value);
#pragma warning restore CS8600
switch (key)
{
@ -85,7 +85,7 @@ namespace OpenStreetMap_Importer
}
}
logger?.Log(loglevel.DEBUG, "Ways: {0} Nodes: {1}", ways.Count, nodes.Count);
logger?.Log(LogLevel.DEBUG, "Ways: {0} Nodes: {1}", ways.Count, nodes.Count);
reader.Close();
reader = XmlReader.Create(new MemoryStream(OSM_Data.map), readerSettings);
@ -107,12 +107,12 @@ namespace OpenStreetMap_Importer
float lon = Convert.ToSingle(reader.GetAttribute("lon").Replace('.', ','));
#pragma warning restore CS8602
nodes[id] = new Node(lat, lon);
logger?.Log(loglevel.VERBOSE, "NODE {0} {1} {2}", id, lat, lon);
logger?.Log(LogLevel.VERBOSE, "NODE {0} {1} {2}", id, lat, lon);
}
}
}
logger?.Log(loglevel.INFO, "Import finished. Calculating distances.");
logger?.Log(LogLevel.INFO, "Import finished. Calculating distances.");
/*
* Add connections between nodes based on ways and calculate distance
@ -128,7 +128,7 @@ namespace OpenStreetMap_Importer
Node neighborNode = nodes[way.nodeIds[index + 1]];
double weight = Utils.DistanceBetweenNodes(currentNode, neighborNode);
currentNode.edges.Add(new Edge(neighborNode, weight));
logger?.Log(loglevel.VERBOSE, "EDGE {0} -- {1} --> {2}", way.nodeIds[index], weight, way.nodeIds[index + 1]);
logger?.Log(LogLevel.VERBOSE, "EDGE {0} -- {1} --> {2}", way.nodeIds[index], weight, way.nodeIds[index + 1]);
edges++;
if (!way.oneway)
{
@ -145,7 +145,7 @@ namespace OpenStreetMap_Importer
Node neighborNode = nodes[way.nodeIds[index - 1]];
double weight = Utils.DistanceBetweenNodes(currentNode, neighborNode);
currentNode.edges.Add(new Edge(neighborNode, weight));
logger?.Log(loglevel.VERBOSE, "EDGE {0} -- {1} --> {2}", way.nodeIds[index], weight, way.nodeIds[index - 1]);
logger?.Log(LogLevel.VERBOSE, "EDGE {0} -- {1} --> {2}", way.nodeIds[index], weight, way.nodeIds[index - 1]);
edges++;
if (!way.oneway)
{
@ -157,7 +157,7 @@ namespace OpenStreetMap_Importer
}
reader.Close();
logger?.Log(loglevel.DEBUG, "Edges: {0}", edges);
logger?.Log(LogLevel.DEBUG, "Edges: {0}", edges);
return nodes;
}

View File

@ -17,13 +17,13 @@ namespace astar
{
Node n1 = nodes[nodes.Keys.ElementAt(r.Next(0, nodes.Count - 1))];
Node n2 = nodes[nodes.Keys.ElementAt(r.Next(0, nodes.Count - 1))];
logger?.Log(loglevel.INFO, "From {0} - {1} to {2} - {3}", n1.lat, n1.lon, n2.lat, n2.lon);
logger?.Log(LogLevel.INFO, "From {0} - {1} to {2} - {3}", n1.lat, n1.lon, n2.lat, n2.lon);
path = FindPath(ref nodes, n1, n2, ref logger);
}
logger?.Log(loglevel.INFO, "Path found");
logger?.Log(LogLevel.INFO, "Path found");
foreach (Node n in path)
logger?.Log(loglevel.INFO, "lat {0:000.00000} lon {1:000.00000} traveled {2:0000.00} / {3:0000.00} beeline {4:0000.00}", n.lat, n.lon, n.pathLength, path.ElementAt(path.Count-1).pathLength, n.goalDistance);
logger?.Log(LogLevel.INFO, "lat {0:000.00000} lon {1:000.00000} traveled {2:0000.00} / {3:0000.00} beeline {4:0000.00}", n.lat, n.lon, n.pathLength, path.ElementAt(path.Count-1).pathLength, n.goalDistance);
}
/*
@ -52,7 +52,7 @@ namespace astar
while(currentNode != goal && toVisit.Count > 0)
{
currentNode = toVisit.First();
logger?.Log(loglevel.VERBOSE, "toVisit-length: {0} path: {1} goal: {2}", toVisit.Count, currentNode.pathLength, currentNode.goalDistance);
logger?.Log(LogLevel.VERBOSE, "toVisit-length: {0} path: {1} goal: {2}", toVisit.Count, currentNode.pathLength, currentNode.goalDistance);
//Check all neighbors of current node
foreach (Edge e in currentNode.edges)
{
@ -73,7 +73,7 @@ namespace astar
if (currentNode != goal)
{
logger?.Log(loglevel.INFO, "No path between {0} - {1} and {2} - {3}", start.lat, start.lon, goal.lat, goal.lon);
logger?.Log(LogLevel.INFO, "No path between {0} - {1} and {2} - {3}", start.lat, start.lon, goal.lat, goal.lon);
return path;
}