Cleanup of unnecessary code

This commit is contained in:
2023-04-20 23:02:38 +02:00
parent d456275fc1
commit 2b252e2b06
9 changed files with 20 additions and 31 deletions

View File

@ -1,4 +1,3 @@
using System.Diagnostics.Tracing;
using System.Text.Json.Serialization;
using OSMDatastructure;
using OSMDatastructure.Graph;

View File

@ -50,7 +50,7 @@ public class Pathfinder
if (currentNode.Equals(goalNode))
{
Console.WriteLine("Path found.");
this.pathResult = GetPath(goalNode, DateTime.Now - startCalc);
pathResult = GetPath(goalNode, DateTime.Now - startCalc);
return this;
}

View File

@ -23,29 +23,26 @@ namespace Pathfinding
{
if(_regions.TryGetValue(id, out Region? value))
return value;
else
{
Region? loadedRegion = RegionFromId(id);
if(loadedRegion is not null)
_regions.Add(loadedRegion!.regionHash, value: loadedRegion);
return loadedRegion;
}
Region? loadedRegion = RegionFromId(id);
if(loadedRegion is not null)
_regions.Add(loadedRegion!.regionHash, value: loadedRegion);
return loadedRegion;
}
public Region[] GetAllRegions()
{
return this._regions.Values.ToArray();
return _regions.Values.ToArray();
}
private Region? RegionFromFile(string filePath)
{
Region? retRegion = null;
if (File.Exists(filePath))
{
FileStream regionFile = new FileStream(filePath, FileMode.Open);
retRegion = JsonSerializer.Deserialize<Region>(regionFile, Region.serializerOptions)!;
regionFile.Dispose();
}
if (!File.Exists(filePath))
return null;
FileStream regionFile = new (filePath, FileMode.Open);
Region retRegion = JsonSerializer.Deserialize<Region>(regionFile, Region.serializerOptions)!;
regionFile.Dispose();
return retRegion;
}