Fixed valid start and end nodes (for type)
This commit is contained in:
parent
c238a9eed3
commit
9e72d50448
@ -7,11 +7,11 @@ namespace Pathfinding;
|
|||||||
public static partial class Pathfinder
|
public static partial class Pathfinder
|
||||||
{
|
{
|
||||||
|
|
||||||
private static ValueTuple<OsmNode?, OsmNode?> SetupNodes(Coordinates startCoordinates, Coordinates goalCoordinates, RegionManager regionManager )
|
private static ValueTuple<OsmNode?, OsmNode?> SetupNodes(Coordinates startCoordinates, Coordinates goalCoordinates, RegionManager regionManager, Tag.SpeedType vehicle)
|
||||||
{
|
{
|
||||||
ValueTuple<OsmNode?, OsmNode?> retTuple = new();
|
ValueTuple<OsmNode?, OsmNode?> retTuple = new();
|
||||||
retTuple.Item1 = regionManager.ClosestNodeToCoordinates(startCoordinates, Tag.SpeedType.any);
|
retTuple.Item1 = regionManager.ClosestNodeToCoordinates(startCoordinates, vehicle);
|
||||||
retTuple.Item2 = regionManager.ClosestNodeToCoordinates(goalCoordinates, Tag.SpeedType.any);
|
retTuple.Item2 = regionManager.ClosestNodeToCoordinates(goalCoordinates, vehicle);
|
||||||
if (retTuple.Item1 is null || retTuple.Item2 is null)
|
if (retTuple.Item1 is null || retTuple.Item2 is null)
|
||||||
return retTuple;
|
return retTuple;
|
||||||
retTuple.Item1.currentPathWeight = 0;
|
retTuple.Item1.currentPathWeight = 0;
|
||||||
|
@ -9,7 +9,7 @@ public static partial class Pathfinder
|
|||||||
Coordinates goal)
|
Coordinates goal)
|
||||||
{
|
{
|
||||||
RegionManager regionManager = new (workingDir);
|
RegionManager regionManager = new (workingDir);
|
||||||
ValueTuple<OsmNode?, OsmNode?> startAndEndNode = SetupNodes(start, goal, regionManager);
|
ValueTuple<OsmNode?, OsmNode?> startAndEndNode = SetupNodes(start, goal, regionManager, Tag.SpeedType.any);
|
||||||
if (startAndEndNode.Item1 is null || startAndEndNode.Item2 is null)
|
if (startAndEndNode.Item1 is null || startAndEndNode.Item2 is null)
|
||||||
return new List<PathNode>();
|
return new List<PathNode>();
|
||||||
OsmNode goalNode = startAndEndNode.Item2!;
|
OsmNode goalNode = startAndEndNode.Item2!;
|
||||||
|
@ -10,14 +10,13 @@ public static partial class Pathfinder
|
|||||||
Coordinates goal, Tag.SpeedType vehicle)
|
Coordinates goal, Tag.SpeedType vehicle)
|
||||||
{
|
{
|
||||||
RegionManager regionManager = new (workingDir);
|
RegionManager regionManager = new (workingDir);
|
||||||
ValueTuple<OsmNode?, OsmNode?> startAndEndNode = SetupNodes(start, goal, regionManager);
|
ValueTuple<OsmNode?, OsmNode?> startAndEndNode = SetupNodes(start, goal, regionManager, vehicle);
|
||||||
if (startAndEndNode.Item1 is null || startAndEndNode.Item2 is null)
|
if (startAndEndNode.Item1 is null || startAndEndNode.Item2 is null)
|
||||||
return new List<PathNode>();
|
return new List<PathNode>();
|
||||||
OsmNode goalNode = startAndEndNode.Item2!;
|
OsmNode goalNode = startAndEndNode.Item2!;
|
||||||
|
|
||||||
PriorityQueue<OsmNode, double> toVisit = new();
|
PriorityQueue<OsmNode, double> toVisit = new();
|
||||||
toVisit.Enqueue(startAndEndNode.Item1, 0);
|
toVisit.Enqueue(startAndEndNode.Item1, 0);
|
||||||
bool stop = false;
|
|
||||||
|
|
||||||
while (toVisit.Count > 0)
|
while (toVisit.Count > 0)
|
||||||
{
|
{
|
||||||
@ -53,7 +52,6 @@ public static partial class Pathfinder
|
|||||||
|
|
||||||
return GetRouteFromCalc(goalNode, regionManager);
|
return GetRouteFromCalc(goalNode, regionManager);
|
||||||
}
|
}
|
||||||
//stop = true;
|
|
||||||
if (!toVisit.UnorderedItems.Any(item => item.Element.Equals(neighbor)))
|
if (!toVisit.UnorderedItems.Any(item => item.Element.Equals(neighbor)))
|
||||||
toVisit.Enqueue(neighbor, GetPriority(currentNode, currentNode.previousPathNode, edge, vehicle, regionManager));
|
toVisit.Enqueue(neighbor, GetPriority(currentNode, currentNode.previousPathNode, edge, vehicle, regionManager));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user