Removed unnecessary factors
This commit is contained in:
@ -13,25 +13,21 @@ public class Pathfinder
|
||||
public Dictionary<OsmNode, double>? gScore;
|
||||
private Dictionary<OsmNode, OsmNode>? _cameFromDict;
|
||||
private SpeedType _speedType;
|
||||
private double roadPriorityFactor, junctionFactor, sameRoadFactor, turnAngle;
|
||||
private double roadPriorityFactor, turnAngle;
|
||||
|
||||
public Pathfinder(string workingDirectory, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double turnAngle)
|
||||
public Pathfinder(string workingDirectory, double roadPriorityFactor, double turnAngle)
|
||||
{
|
||||
if (!Path.Exists(workingDirectory))
|
||||
throw new DirectoryNotFoundException(workingDirectory);
|
||||
regionManager = new(workingDirectory);
|
||||
this.roadPriorityFactor = roadPriorityFactor;
|
||||
this.junctionFactor = junctionFactor;
|
||||
this.sameRoadFactor = sameRoadFactor;
|
||||
this.turnAngle = turnAngle;
|
||||
}
|
||||
|
||||
public Pathfinder(RegionManager regionManager, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double turnAngle)
|
||||
public Pathfinder(RegionManager regionManager, double roadPriorityFactor, double turnAngle)
|
||||
{
|
||||
this.regionManager = regionManager;
|
||||
this.roadPriorityFactor = roadPriorityFactor;
|
||||
this.junctionFactor = junctionFactor;
|
||||
this.sameRoadFactor = sameRoadFactor;
|
||||
this.turnAngle = turnAngle;
|
||||
}
|
||||
|
||||
@ -154,27 +150,9 @@ public class Pathfinder
|
||||
else
|
||||
angle = nodeAngle / 180;
|
||||
}
|
||||
|
||||
TagManager curTags = regionManager.GetRegion(currentNode.coordinates)!.tagManager;
|
||||
TagManager nextTags = regionManager.GetRegion(neighborNode.coordinates)!.tagManager;
|
||||
|
||||
bool sameName = false;
|
||||
string? curName = (string?)curTags.GetTag(edge.wayId, TagType.name);
|
||||
bool sameRef = false;
|
||||
string? curRef = (string?)curTags.GetTag(edge.wayId, TagType.tagref);
|
||||
if(curName is not null)
|
||||
foreach (OsmEdge pEdge in neighborNode.edges)
|
||||
{
|
||||
if ((string?)nextTags.GetTag(pEdge.wayId, TagType.name) == curName)
|
||||
sameName = true;
|
||||
if ((string?)nextTags.GetTag(pEdge.wayId, TagType.tagref) == curRef)
|
||||
sameRef = true;
|
||||
}
|
||||
|
||||
double junctionCount = (neighborNode.edges.Count > 2 ? 0 : 1) * junctionFactor;
|
||||
double roadPriority = priority * roadPriorityFactor;
|
||||
double sameRoadName = (sameRef || sameName ? 1 : 0) * sameRoadFactor;
|
||||
return Utils.DistanceBetween(neighborNode, goalNode) / (speed * angle + 1);
|
||||
return Utils.DistanceBetween(neighborNode, goalNode) / (speed * angle + roadPriority + 1);
|
||||
}
|
||||
|
||||
public void SaveResult(string path)
|
||||
|
Reference in New Issue
Block a user