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