Update with 0ad913e54b
This commit is contained in:
parent
bced45f688
commit
a700d429d4
@ -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);
|
Dictionary<UInt64, Graph.Node> nodes = OpenStreetMap_Importer.Importer.Import(logger);
|
||||||
new astar.Astar(nodes, logger);
|
new astar.Astar(nodes, logger);
|
@ -30,7 +30,7 @@ namespace OpenStreetMap_Importer
|
|||||||
{
|
{
|
||||||
if (reader.Name == "way" && reader.IsStartElement())
|
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)
|
if (currentWay.highway != Way.highwayType.NONE)
|
||||||
{
|
{
|
||||||
ways.Add(currentWay);
|
ways.Add(currentWay);
|
||||||
@ -46,7 +46,7 @@ namespace OpenStreetMap_Importer
|
|||||||
#pragma warning disable CS8604
|
#pragma warning disable CS8604
|
||||||
string value = reader.GetAttribute("v");
|
string value = reader.GetAttribute("v");
|
||||||
string key = reader.GetAttribute("k");
|
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
|
#pragma warning restore CS8600
|
||||||
switch (key)
|
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.Close();
|
||||||
reader = XmlReader.Create(new MemoryStream(OSM_Data.map), readerSettings);
|
reader = XmlReader.Create(new MemoryStream(OSM_Data.map), readerSettings);
|
||||||
@ -107,12 +107,12 @@ namespace OpenStreetMap_Importer
|
|||||||
float lon = Convert.ToSingle(reader.GetAttribute("lon").Replace('.', ','));
|
float lon = Convert.ToSingle(reader.GetAttribute("lon").Replace('.', ','));
|
||||||
#pragma warning restore CS8602
|
#pragma warning restore CS8602
|
||||||
nodes[id] = new Node(lat, lon);
|
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
|
* Add connections between nodes based on ways and calculate distance
|
||||||
@ -128,7 +128,7 @@ namespace OpenStreetMap_Importer
|
|||||||
Node neighborNode = nodes[way.nodeIds[index + 1]];
|
Node neighborNode = nodes[way.nodeIds[index + 1]];
|
||||||
double weight = Utils.DistanceBetweenNodes(currentNode, neighborNode);
|
double weight = Utils.DistanceBetweenNodes(currentNode, neighborNode);
|
||||||
currentNode.edges.Add(new Edge(neighborNode, weight));
|
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++;
|
edges++;
|
||||||
if (!way.oneway)
|
if (!way.oneway)
|
||||||
{
|
{
|
||||||
@ -145,7 +145,7 @@ namespace OpenStreetMap_Importer
|
|||||||
Node neighborNode = nodes[way.nodeIds[index - 1]];
|
Node neighborNode = nodes[way.nodeIds[index - 1]];
|
||||||
double weight = Utils.DistanceBetweenNodes(currentNode, neighborNode);
|
double weight = Utils.DistanceBetweenNodes(currentNode, neighborNode);
|
||||||
currentNode.edges.Add(new Edge(neighborNode, weight));
|
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++;
|
edges++;
|
||||||
if (!way.oneway)
|
if (!way.oneway)
|
||||||
{
|
{
|
||||||
@ -157,7 +157,7 @@ namespace OpenStreetMap_Importer
|
|||||||
}
|
}
|
||||||
reader.Close();
|
reader.Close();
|
||||||
|
|
||||||
logger?.Log(loglevel.DEBUG, "Edges: {0}", edges);
|
logger?.Log(LogLevel.DEBUG, "Edges: {0}", edges);
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,13 +17,13 @@ namespace astar
|
|||||||
{
|
{
|
||||||
Node n1 = nodes[nodes.Keys.ElementAt(r.Next(0, nodes.Count - 1))];
|
Node n1 = nodes[nodes.Keys.ElementAt(r.Next(0, nodes.Count - 1))];
|
||||||
Node n2 = 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);
|
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)
|
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)
|
while(currentNode != goal && toVisit.Count > 0)
|
||||||
{
|
{
|
||||||
currentNode = toVisit.First();
|
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
|
//Check all neighbors of current node
|
||||||
foreach (Edge e in currentNode.edges)
|
foreach (Edge e in currentNode.edges)
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ namespace astar
|
|||||||
|
|
||||||
if (currentNode != goal)
|
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;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user