Cleanup
This commit is contained in:
parent
dd37430761
commit
cd3905915b
@ -1,9 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using OSMDatastructure;
|
||||
using OSMDatastructure.Graph;
|
||||
using static OSMDatastructure.Tag;
|
||||
using WayType = OSMDatastructure.Tag.WayType;
|
||||
|
||||
namespace Pathfinding;
|
||||
|
||||
@ -96,13 +94,13 @@ public class Pathfinder
|
||||
double nodeAngle = v1.Angle(v2);
|
||||
angle = ((180 - nodeAngle) / 180) * angleWeightFactor;
|
||||
}
|
||||
double prio = regionManager.GetPriorityForVehicle(_speedType,edge, regionManager.GetRegion(currentNode.coordinates)!);
|
||||
double prio = regionManager.GetPriorityForVehicle(_speedType,edge, currentNode);
|
||||
return distance / (1 + speed + angle + prio);
|
||||
}
|
||||
|
||||
private double Heuristic(OsmNode currentNode, OsmNode neighborNode, OsmNode goalNode, OsmEdge edge, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double nodeAngleFactor)
|
||||
{
|
||||
double roadPriority = regionManager.GetPriorityForVehicle(_speedType, edge, regionManager.GetRegion(currentNode.coordinates)!) * roadPriorityFactor;
|
||||
double roadPriority = regionManager.GetPriorityForVehicle(_speedType, edge, currentNode) * roadPriorityFactor;
|
||||
if (roadPriority == 0)
|
||||
return double.MaxValue;
|
||||
|
||||
@ -155,9 +153,9 @@ public class Pathfinder
|
||||
double weight = 0;
|
||||
while (_cameFromDict!.ContainsKey(_cameFromDict[currentNode]))
|
||||
{
|
||||
OsmEdge? currentEdge = _cameFromDict[currentNode].edges.First(edge => edge.neighborId == currentNode.nodeId);
|
||||
OsmEdge? currentEdge = _cameFromDict[currentNode].edges.FirstOrDefault(edge => edge.neighborId == currentNode.nodeId);
|
||||
HashSet<Tag>? tags =
|
||||
regionManager.GetRegion(currentNode.coordinates)!.tagManager.GetTagsForWayId(currentEdge.wayId);
|
||||
regionManager.GetRegion(currentNode.coordinates)!.tagManager.GetTagsForWayId(currentEdge!.wayId);
|
||||
PathNode? newNode = PathNode.FromOsmNode(currentNode, tags);
|
||||
if(newNode is not null)
|
||||
path.Add(newNode);
|
||||
@ -176,7 +174,7 @@ public class Pathfinder
|
||||
|
||||
private class Vector
|
||||
{
|
||||
public float x, y;
|
||||
public readonly float x, y;
|
||||
|
||||
public Vector(float x, float y)
|
||||
{
|
||||
|
@ -131,10 +131,11 @@ namespace Pathfinding
|
||||
}
|
||||
}
|
||||
|
||||
public double GetPriorityForVehicle(SpeedType speedType, OsmEdge edge, Region region)
|
||||
public double GetPriorityForVehicle(SpeedType speedType, OsmEdge edge, OsmNode node)
|
||||
{
|
||||
if (speedType == SpeedType.any)
|
||||
return 1;
|
||||
Region region = GetRegion(node.coordinates)!;
|
||||
WayType? wayType = (WayType?)region.tagManager.GetTag(edge.wayId, Tag.TagType.highway);
|
||||
if(wayType is null)
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user