2023-04-06 14:27:25 +02:00
|
|
|
using System.Text.Json.Serialization;
|
2023-04-09 17:38:57 +02:00
|
|
|
using OSMDatastructure;
|
2023-04-06 14:27:25 +02:00
|
|
|
using OSMDatastructure.Graph;
|
|
|
|
|
|
|
|
namespace Pathfinding;
|
|
|
|
|
|
|
|
public class PathNode : OsmNode
|
|
|
|
{
|
|
|
|
[JsonInclude]public new double directDistanceToGoal = double.MaxValue;
|
2023-04-09 17:52:37 +02:00
|
|
|
[JsonInclude]public double directDistanceDelta = double.MaxValue;
|
2023-04-09 17:46:35 +02:00
|
|
|
[JsonInclude]public new double currentPathLength = double.MaxValue;
|
2023-04-09 17:52:37 +02:00
|
|
|
[JsonInclude]public double pathDistanceDelta = double.MaxValue;
|
2023-04-09 17:46:35 +02:00
|
|
|
[JsonInclude]public new double currentPathWeight = double.MaxValue;
|
2023-04-09 17:52:37 +02:00
|
|
|
[JsonInclude]public double pathWeightDelta = double.MaxValue;
|
2023-04-09 17:38:57 +02:00
|
|
|
[JsonInclude]public Dictionary<string, string> tags = new();
|
|
|
|
|
2023-04-06 14:27:25 +02:00
|
|
|
public PathNode(ulong nodeId, float lat, float lon) : base(nodeId, lat, lon)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public PathNode(ulong nodeId, Coordinates coordinates) : base(nodeId, coordinates)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-04-09 17:52:37 +02:00
|
|
|
public static PathNode? FromOsmNode(OsmNode? node, HashSet<Tag>? tags, double pathDistanceDelta, double pathWeightDelta, double directDistanceDelta)
|
2023-04-06 14:27:25 +02:00
|
|
|
{
|
|
|
|
if (node is null)
|
|
|
|
return null;
|
2023-04-09 17:46:35 +02:00
|
|
|
PathNode retNode = new(node.nodeId, node.coordinates)
|
2023-04-06 14:27:25 +02:00
|
|
|
{
|
|
|
|
currentPathLength = node.currentPathLength,
|
2023-04-09 17:02:56 +02:00
|
|
|
currentPathWeight = double.IsPositiveInfinity(node.currentPathWeight) ? double.MaxValue : node.currentPathWeight,
|
2023-04-09 17:46:35 +02:00
|
|
|
directDistanceToGoal = node.directDistanceToGoal,
|
2023-04-09 17:52:37 +02:00
|
|
|
directDistanceDelta = directDistanceDelta,
|
|
|
|
pathDistanceDelta = pathDistanceDelta,
|
|
|
|
pathWeightDelta = pathWeightDelta
|
2023-04-06 14:27:25 +02:00
|
|
|
};
|
2023-04-09 17:38:57 +02:00
|
|
|
if (tags != null)
|
|
|
|
foreach (Tag tag in tags)
|
|
|
|
{
|
|
|
|
retNode.tags.Add(tag.key.ToString(), tag.value.ToString());
|
|
|
|
}
|
|
|
|
|
2023-04-06 14:27:25 +02:00
|
|
|
return retNode;
|
|
|
|
}
|
|
|
|
}
|