Added Method for path-return (returns the path from current graph).

Added "tags" to return value for path.
This commit is contained in:
2023-04-09 17:38:57 +02:00
parent 2904be84f0
commit e0bb3ce3de
4 changed files with 35 additions and 24 deletions

View File

@ -30,4 +30,27 @@ public static partial class Pathfinder
return double.MaxValue;
return distance / speed;
}
private static List<PathNode> GetRouteFromCalc(OsmNode goalNode, RegionManager regionManager)
{
List<PathNode> path = new();
OsmNode? currentNode = goalNode;
while (currentNode is not null)
{
HashSet<Tag>? tags = null;
if (currentNode.previousPathNode is not null)
{
OsmEdge edge = currentNode.previousPathNode!.edges.First(e => e.neighborId.Equals(currentNode.nodeId));
tags = regionManager.GetRegion(currentNode.coordinates)!.tagManager.GetTagsForWayId(edge.wayId);
}
currentNode = currentNode.previousPathNode;
PathNode? pn = PathNode.FromOsmNode(currentNode, tags);
if(pn is not null)
path.Add(pn!);
}
path.Reverse();
return path;
}
}