Intellisense

This commit is contained in:
C9Glax 2022-05-11 20:25:13 +02:00
parent f38f7f4c87
commit 52254de1aa
4 changed files with 34 additions and 34 deletions

View File

@ -1,3 +1,3 @@
Logging.Logger logger = new Logging.Logger(Logging.LogType.CONSOLE, Logging.LogLevel.DEBUG); Logging.Logger logger = new (Logging.LogType.CONSOLE, Logging.LogLevel.DEBUG);
Dictionary<UInt64, Graph.Node> nodes = OpenStreetMap_Importer.Importer.Import(logger); Dictionary<UInt64, Graph.Node> nodes = OpenStreetMap_Importer.Importer.Import(logger);
new astar.Astar(nodes, logger); astar.Astar astar = new(nodes, logger);

View File

@ -20,6 +20,6 @@
this.goalDistance = double.MaxValue; this.goalDistance = double.MaxValue;
this.pathLength = double.MaxValue; this.pathLength = double.MaxValue;
} }
public static Node nullnode = new Node(float.NaN, float.NaN); public static Node nullnode = new(float.NaN, float.NaN);
} }
} }

View File

@ -9,17 +9,17 @@ namespace OpenStreetMap_Importer
public static Dictionary<ulong, Node> Import(Logger ?logger = null) public static Dictionary<ulong, Node> Import(Logger ?logger = null)
{ {
List<Way> ways = new List<Way>(); List<Way> ways = new();
Dictionary<ulong, Node> nodes = new Dictionary<ulong, Node>(); Dictionary<ulong, Node> nodes = new();
bool wayTag = false; bool wayTag = false;
Way currentWay = new Way(); Way currentWay = new();
/* /*
* First iteration * First iteration
* Import "ways" with a tag "highway" and add the node-ids to the list of nodes * Import "ways" with a tag "highway" and add the node-ids to the list of nodes
*/ */
XmlReaderSettings readerSettings = new XmlReaderSettings() XmlReaderSettings readerSettings = new()
{ {
IgnoreWhitespace = true, IgnoreWhitespace = true,
IgnoreComments = true IgnoreComments = true
@ -172,33 +172,33 @@ namespace OpenStreetMap_Importer
{ {
NONE = 1, NONE = 1,
motorway = 130, motorway = 130,
trunk = 130, trunk = 125,
primary = 100, primary = 110,
secondary = 100, secondary = 100,
tertiary = 80, tertiary = 80,
unclassified = 50, unclassified = 40,
residential = 30, residential = 23,
motorway_link = 50, motorway_link = 55,
trunk_link = 50, trunk_link = 50,
primary_link = 30, primary_link = 30,
secondary_link = 30, secondary_link = 25,
tertiary_link = 20, tertiary_link = 24,
living_street = 5, living_street = 20,
service = 1, service = 14,
pedestrian = 1, pedestrian = 12,
track = 5, track = 6,
bus_guideway = 1, bus_guideway = 15,
escape = 1, escape = 3,
raceway = 1, raceway = 4,
road = 30, road = 28,
busway = 1, busway = 13,
footway = 1, footway = 8,
bridleway = 1, bridleway = 7,
steps = 1, steps = 5,
corridor = 1, corridor = 9,
path = 1, path = 10,
cycleway = 1, cycleway = 11,
construction = 1 construction = 2
} }

View File

@ -11,8 +11,8 @@ namespace astar
*/ */
public Astar(Dictionary<UInt64, Node> nodes, Logger ?logger = null) public Astar(Dictionary<UInt64, Node> nodes, Logger ?logger = null)
{ {
Random r = new Random(); Random r = new();
List<Node> path = new List<Node>(); List<Node> path = new();
while(path.Count < 1) while(path.Count < 1)
{ {
Node n1 = nodes[nodes.Keys.ElementAt(r.Next(0, nodes.Count - 1))]; Node n1 = nodes[nodes.Keys.ElementAt(r.Next(0, nodes.Count - 1))];
@ -44,7 +44,7 @@ namespace astar
private static List<Node> FindPath(ref Dictionary<ulong, Node> nodes, Node start, Node goal, ref Logger ?logger) private static List<Node> FindPath(ref Dictionary<ulong, Node> nodes, Node start, Node goal, ref Logger ?logger)
{ {
Reset(ref nodes); Reset(ref nodes);
List<Node> toVisit = new List<Node>(); List<Node> toVisit = new();
toVisit.Add(start); toVisit.Add(start);
Node currentNode = start; Node currentNode = start;
start.pathLength = 0; start.pathLength = 0;
@ -69,7 +69,7 @@ namespace astar
toVisit.Sort(CompareDistanceToGoal); toVisit.Sort(CompareDistanceToGoal);
} }
List<Node> path = new List<Node>(); List<Node> path = new();
if (currentNode != goal) if (currentNode != goal)
{ {