private field naming _cameFromDict

This commit is contained in:
glax 2023-04-20 22:58:50 +02:00
parent 2bd6c5d9c4
commit d456275fc1

View File

@ -13,7 +13,7 @@ public class Pathfinder
public readonly string workingDir;
public PathResult? pathResult;
public Dictionary<OsmNode, double>? gScore;
private Dictionary<OsmNode, OsmNode>? cameFromDict;
private Dictionary<OsmNode, OsmNode>? _cameFromDict;
private SpeedType _speedType;
public Pathfinder(string workingDirectory)
@ -42,7 +42,7 @@ public class Pathfinder
PriorityQueue<OsmNode, double> openSetfScore = new();
openSetfScore.Enqueue(startNode, 0);
gScore = new() { { startNode, 0 } };
cameFromDict = new();
_cameFromDict = new();
while (openSetfScore.Count > 0)
{
@ -64,8 +64,8 @@ public class Pathfinder
gScore.TryAdd(neighbor, double.MaxValue);
if (tentativeGScore < gScore[neighbor])
{
if(!cameFromDict.TryAdd(neighbor, currentNode))
cameFromDict[neighbor] = currentNode;
if(!_cameFromDict.TryAdd(neighbor, currentNode))
_cameFromDict[neighbor] = currentNode;
gScore[neighbor] = tentativeGScore;
double h = Heuristic(currentNode, neighbor, goalNode, edge,
heuristicRoadLevelPriority, heuristicFewJunctionsPriority, heuristicSameRoadPriority);
@ -92,15 +92,15 @@ public class Pathfinder
{
List<PathNode> path = new();
OsmNode currentNode = goalNode;
while (cameFromDict!.ContainsKey(cameFromDict[currentNode]))
while (_cameFromDict!.ContainsKey(_cameFromDict[currentNode]))
{
OsmEdge? currentEdge = cameFromDict[currentNode].edges.First(edge => edge.neighborId == currentNode.nodeId);
OsmEdge? currentEdge = _cameFromDict[currentNode].edges.First(edge => edge.neighborId == currentNode.nodeId);
HashSet<Tag>? tags =
regionManager.GetRegion(currentNode.coordinates)!.tagManager.GetTagsForWayId(currentEdge.wayId);
PathNode? newNode = PathNode.FromOsmNode(currentNode, tags);
if(newNode is not null)
path.Add(newNode);
currentNode = cameFromDict[currentNode];
currentNode = _cameFromDict[currentNode];
}
path.Reverse();