Cleanup of unnecessary code
This commit is contained in:
parent
d456275fc1
commit
2b252e2b06
@ -1,4 +1,3 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using OSMDatastructure;
|
||||
using OSMDatastructure.Graph;
|
||||
using Pathfinding;
|
||||
|
@ -12,15 +12,15 @@ public class OsmNode
|
||||
public OsmNode(ulong nodeId, float lat, float lon)
|
||||
{
|
||||
this.nodeId = nodeId;
|
||||
this.edges = new();
|
||||
this.coordinates = new Coordinates(lat, lon);
|
||||
edges = new();
|
||||
coordinates = new Coordinates(lat, lon);
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
public OsmNode(ulong nodeId, Coordinates coordinates)
|
||||
{
|
||||
this.nodeId = nodeId;
|
||||
this.edges = new();
|
||||
edges = new();
|
||||
this.coordinates = coordinates;
|
||||
}
|
||||
|
||||
@ -29,7 +29,8 @@ public class OsmNode
|
||||
HashSet<OsmEdge> e = edges.Where(edge => edge.neighborId == n.nodeId).ToHashSet();
|
||||
if (e.Count > 0)
|
||||
return e.First();
|
||||
else return null;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
|
@ -47,16 +47,12 @@ public class Region
|
||||
|
||||
public OsmNode? GetNode(ulong id)
|
||||
{
|
||||
if (ContainsNode(id))
|
||||
return nodes.First(node => node.nodeId == id);
|
||||
else return null;
|
||||
return ContainsNode(id) ? nodes.First(node => node.nodeId == id) : null;
|
||||
}
|
||||
|
||||
public OsmNode? GetNode(Coordinates coordinates)
|
||||
{
|
||||
if (ContainsNode(coordinates))
|
||||
return nodes.First(node => node.coordinates.Equals(coordinates));
|
||||
else return null;
|
||||
return ContainsNode(coordinates) ? nodes.First(node => node.coordinates.Equals(coordinates)) : null;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using OSMDatastructure.Graph;
|
||||
|
||||
namespace OSMDatastructure;
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
using System.Diagnostics.Tracing;
|
||||
using System.Text.Json.Serialization;
|
||||
using OSMDatastructure;
|
||||
using OSMDatastructure.Graph;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Text.Json;
|
||||
using OSMDatastructure.Graph;
|
||||
using Pathfinding;
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Server;
|
||||
|
Loading…
Reference in New Issue
Block a user