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;
|
||||||
using OSMDatastructure.Graph;
|
using OSMDatastructure.Graph;
|
||||||
using Pathfinding;
|
using Pathfinding;
|
||||||
|
@ -12,15 +12,15 @@ public class OsmNode
|
|||||||
public OsmNode(ulong nodeId, float lat, float lon)
|
public OsmNode(ulong nodeId, float lat, float lon)
|
||||||
{
|
{
|
||||||
this.nodeId = nodeId;
|
this.nodeId = nodeId;
|
||||||
this.edges = new();
|
edges = new();
|
||||||
this.coordinates = new Coordinates(lat, lon);
|
coordinates = new Coordinates(lat, lon);
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
public OsmNode(ulong nodeId, Coordinates coordinates)
|
public OsmNode(ulong nodeId, Coordinates coordinates)
|
||||||
{
|
{
|
||||||
this.nodeId = nodeId;
|
this.nodeId = nodeId;
|
||||||
this.edges = new();
|
edges = new();
|
||||||
this.coordinates = coordinates;
|
this.coordinates = coordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,8 @@ public class OsmNode
|
|||||||
HashSet<OsmEdge> e = edges.Where(edge => edge.neighborId == n.nodeId).ToHashSet();
|
HashSet<OsmEdge> e = edges.Where(edge => edge.neighborId == n.nodeId).ToHashSet();
|
||||||
if (e.Count > 0)
|
if (e.Count > 0)
|
||||||
return e.First();
|
return e.First();
|
||||||
else return null;
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object? obj)
|
public override bool Equals(object? obj)
|
||||||
|
@ -47,16 +47,12 @@ public class Region
|
|||||||
|
|
||||||
public OsmNode? GetNode(ulong id)
|
public OsmNode? GetNode(ulong id)
|
||||||
{
|
{
|
||||||
if (ContainsNode(id))
|
return ContainsNode(id) ? nodes.First(node => node.nodeId == id) : null;
|
||||||
return nodes.First(node => node.nodeId == id);
|
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmNode? GetNode(Coordinates coordinates)
|
public OsmNode? GetNode(Coordinates coordinates)
|
||||||
{
|
{
|
||||||
if (ContainsNode(coordinates))
|
return ContainsNode(coordinates) ? nodes.First(node => node.coordinates.Equals(coordinates)) : null;
|
||||||
return nodes.First(node => node.coordinates.Equals(coordinates));
|
|
||||||
else return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using OSMDatastructure.Graph;
|
|
||||||
|
|
||||||
namespace OSMDatastructure;
|
namespace OSMDatastructure;
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using System.Diagnostics.Tracing;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using OSMDatastructure;
|
using OSMDatastructure;
|
||||||
using OSMDatastructure.Graph;
|
using OSMDatastructure.Graph;
|
||||||
|
@ -50,7 +50,7 @@ public class Pathfinder
|
|||||||
if (currentNode.Equals(goalNode))
|
if (currentNode.Equals(goalNode))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Path found.");
|
Console.WriteLine("Path found.");
|
||||||
this.pathResult = GetPath(goalNode, DateTime.Now - startCalc);
|
pathResult = GetPath(goalNode, DateTime.Now - startCalc);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,29 +23,26 @@ namespace Pathfinding
|
|||||||
{
|
{
|
||||||
if(_regions.TryGetValue(id, out Region? value))
|
if(_regions.TryGetValue(id, out Region? value))
|
||||||
return value;
|
return value;
|
||||||
else
|
|
||||||
{
|
Region? loadedRegion = RegionFromId(id);
|
||||||
Region? loadedRegion = RegionFromId(id);
|
if(loadedRegion is not null)
|
||||||
if(loadedRegion is not null)
|
_regions.Add(loadedRegion!.regionHash, value: loadedRegion);
|
||||||
_regions.Add(loadedRegion!.regionHash, value: loadedRegion);
|
return loadedRegion;
|
||||||
return loadedRegion;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Region[] GetAllRegions()
|
public Region[] GetAllRegions()
|
||||||
{
|
{
|
||||||
return this._regions.Values.ToArray();
|
return _regions.Values.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Region? RegionFromFile(string filePath)
|
private Region? RegionFromFile(string filePath)
|
||||||
{
|
{
|
||||||
Region? retRegion = null;
|
if (!File.Exists(filePath))
|
||||||
if (File.Exists(filePath))
|
return null;
|
||||||
{
|
|
||||||
FileStream regionFile = new FileStream(filePath, FileMode.Open);
|
FileStream regionFile = new (filePath, FileMode.Open);
|
||||||
retRegion = JsonSerializer.Deserialize<Region>(regionFile, Region.serializerOptions)!;
|
Region retRegion = JsonSerializer.Deserialize<Region>(regionFile, Region.serializerOptions)!;
|
||||||
regionFile.Dispose();
|
regionFile.Dispose();
|
||||||
}
|
|
||||||
return retRegion;
|
return retRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Text.Json;
|
|
||||||
using OSMDatastructure.Graph;
|
using OSMDatastructure.Graph;
|
||||||
using Pathfinding;
|
using Pathfinding;
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using System.Globalization;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Server;
|
namespace Server;
|
||||||
|
Reference in New Issue
Block a user