ClosestNode no longer requires Region parameter, because regionmanager is passed.
This commit is contained in:
parent
8813023cd6
commit
f266c6c7e6
@ -8,14 +8,9 @@ public static class Pathfinder
|
||||
{
|
||||
public static List<PathNode> CustomAStar(string workingDir, Coordinates start, Coordinates goal, Tag.SpeedType vehicle)
|
||||
{
|
||||
RegionManager regionManager = new RegionManager(workingDir);
|
||||
Region? startRegion = regionManager.GetRegion(start);
|
||||
Region? goalRegion = regionManager.GetRegion(goal);
|
||||
if (startRegion is null || goalRegion is null)
|
||||
return new List<PathNode>();
|
||||
|
||||
OsmNode? startNode = ClosestNodeToCoordinates(start, startRegion, vehicle, ref regionManager);
|
||||
OsmNode? goalNode = ClosestNodeToCoordinates(goal, goalRegion, vehicle, ref regionManager);
|
||||
RegionManager regionManager = new (workingDir);
|
||||
OsmNode? startNode = ClosestNodeToCoordinates(start, vehicle, ref regionManager);
|
||||
OsmNode? goalNode = ClosestNodeToCoordinates(goal, vehicle, ref regionManager);
|
||||
if (startNode == null || goalNode == null)
|
||||
return new List<PathNode>();
|
||||
|
||||
@ -71,10 +66,13 @@ public static class Pathfinder
|
||||
return path;
|
||||
}
|
||||
|
||||
private static OsmNode? ClosestNodeToCoordinates(Coordinates coordinates, Region region, Tag.SpeedType vehicle, ref RegionManager regionManager)
|
||||
public static OsmNode? ClosestNodeToCoordinates(Coordinates coordinates, Tag.SpeedType vehicle, ref RegionManager regionManager)
|
||||
{
|
||||
OsmNode? closest = null;
|
||||
double distance = double.MaxValue;
|
||||
Region? region = regionManager.GetRegion(coordinates);
|
||||
if (region is null)
|
||||
return null;
|
||||
foreach (OsmNode node in region.nodes)
|
||||
{
|
||||
bool hasConnectionUsingVehicle = false;
|
||||
|
Loading…
Reference in New Issue
Block a user