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;
|
||||||
using OSMDatastructure.Graph;
|
using OSMDatastructure.Graph;
|
||||||
using static OSMDatastructure.Tag;
|
using static OSMDatastructure.Tag;
|
||||||
using WayType = OSMDatastructure.Tag.WayType;
|
|
||||||
|
|
||||||
namespace Pathfinding;
|
namespace Pathfinding;
|
||||||
|
|
||||||
@ -96,13 +94,13 @@ public class Pathfinder
|
|||||||
double nodeAngle = v1.Angle(v2);
|
double nodeAngle = v1.Angle(v2);
|
||||||
angle = ((180 - nodeAngle) / 180) * angleWeightFactor;
|
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);
|
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)
|
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)
|
if (roadPriority == 0)
|
||||||
return double.MaxValue;
|
return double.MaxValue;
|
||||||
|
|
||||||
@ -155,9 +153,9 @@ public class Pathfinder
|
|||||||
double weight = 0;
|
double weight = 0;
|
||||||
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.FirstOrDefault(edge => edge.neighborId == currentNode.nodeId);
|
||||||
HashSet<Tag>? tags =
|
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);
|
PathNode? newNode = PathNode.FromOsmNode(currentNode, tags);
|
||||||
if(newNode is not null)
|
if(newNode is not null)
|
||||||
path.Add(newNode);
|
path.Add(newNode);
|
||||||
@ -176,7 +174,7 @@ public class Pathfinder
|
|||||||
|
|
||||||
private class Vector
|
private class Vector
|
||||||
{
|
{
|
||||||
public float x, y;
|
public readonly float x, y;
|
||||||
|
|
||||||
public Vector(float x, float 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)
|
if (speedType == SpeedType.any)
|
||||||
return 1;
|
return 1;
|
||||||
|
Region region = GetRegion(node.coordinates)!;
|
||||||
WayType? wayType = (WayType?)region.tagManager.GetTag(edge.wayId, Tag.TagType.highway);
|
WayType? wayType = (WayType?)region.tagManager.GetTag(edge.wayId, Tag.TagType.highway);
|
||||||
if(wayType is null)
|
if(wayType is null)
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user