44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using System.Text.Json.Serialization;
|
|
using OSMDatastructure;
|
|
using OSMDatastructure.Graph;
|
|
|
|
namespace Pathfinding;
|
|
|
|
public class PathNode : OsmNode
|
|
{
|
|
[JsonInclude]public new double directDistanceToGoal = double.MaxValue;
|
|
[JsonInclude]public new double currentPathLength = double.MaxValue;
|
|
[JsonInclude]public double distanceBetweenNodes = double.MaxValue;
|
|
[JsonInclude]public new double currentPathWeight = double.MaxValue;
|
|
[JsonInclude]public double weightBetweenNodes = double.MaxValue;
|
|
[JsonInclude]public Dictionary<string, string> tags = new();
|
|
|
|
public PathNode(ulong nodeId, float lat, float lon) : base(nodeId, lat, lon)
|
|
{
|
|
}
|
|
|
|
public PathNode(ulong nodeId, Coordinates coordinates) : base(nodeId, coordinates)
|
|
{
|
|
}
|
|
|
|
public static PathNode? FromOsmNode(OsmNode? node, HashSet<Tag>? tags, double distance, double weight)
|
|
{
|
|
if (node is null)
|
|
return null;
|
|
PathNode retNode = new(node.nodeId, node.coordinates)
|
|
{
|
|
currentPathLength = node.currentPathLength,
|
|
currentPathWeight = double.IsPositiveInfinity(node.currentPathWeight) ? double.MaxValue : node.currentPathWeight,
|
|
directDistanceToGoal = node.directDistanceToGoal,
|
|
distanceBetweenNodes = distance,
|
|
weightBetweenNodes = weight
|
|
};
|
|
if (tags != null)
|
|
foreach (Tag tag in tags)
|
|
{
|
|
retNode.tags.Add(tag.key.ToString(), tag.value.ToString());
|
|
}
|
|
|
|
return retNode;
|
|
}
|
|
} |