From d18e4f5abfbb2e2b5aa51781b0cb2b7860778603 Mon Sep 17 00:00:00 2001 From: C9Glax <13404778+C9Glax@users.noreply.github.com> Date: Wed, 8 Feb 2023 18:49:47 +0100 Subject: [PATCH] OsmNode.cs: Fixed ToString() no previous node --- OSMDatastructure/OsmNode.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/OSMDatastructure/OsmNode.cs b/OSMDatastructure/OsmNode.cs index e808014..f77d7ee 100644 --- a/OSMDatastructure/OsmNode.cs +++ b/OSMDatastructure/OsmNode.cs @@ -41,9 +41,15 @@ public class OsmNode public override string ToString() { - return string.Format( - "NODE {0} Edges-Count: {1} previousPathNode: {2} currentPathWeight: {3} directDistanceToGoal: {4}", - this.coordinates.ToString(), this.edges.Count, this.previousPathNode.coordinates.ToString(), - this.currentPathWeight, this.directDistanceToGoal); + if(this.previousPathNode != null) + return string.Format( + "NODE {0} Edges-Count: {1} previousPathNode: {2} currentPathWeight: {3} directDistanceToGoal: {4}", + this.coordinates.ToString(), this.edges.Count, this.previousPathNode.coordinates.ToString(), + this.currentPathWeight, this.directDistanceToGoal); + else + return string.Format( + "NODE {0} Edges-Count: {1} previousPathNode: NO PREVIOUS NODE currentPathWeight: {2} directDistanceToGoal: {3}", + this.coordinates.ToString(), this.edges.Count, + this.currentPathWeight, this.directDistanceToGoal); } } \ No newline at end of file