Added Method for path-return (returns the path from current graph).
Added "tags" to return value for path.
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user