Moved Projects
This commit is contained in:
parent
903958a22a
commit
d677214573
@ -9,14 +9,18 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\astar\astar.csproj" />
|
<ProjectReference Include="..\astar\astar.csproj" />
|
||||||
<ProjectReference Include="..\Graph\Graph.csproj" />
|
|
||||||
<ProjectReference Include="..\OpenStreetMap Importer\OpenStreetMap Importer.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Geo-Graph">
|
||||||
|
<HintPath>C:\Users\glax\source\repos\Geo-Graph\Geo-Graph\bin\Debug\net6.0\Geo-Graph.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Logging">
|
<Reference Include="Logging">
|
||||||
<HintPath>..\..\Logging\Logging\bin\Debug\net6.0\Logging.dll</HintPath>
|
<HintPath>..\..\Logging\Logging\bin\Debug\net6.0\Logging.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="OSM-XML-Importer">
|
||||||
|
<HintPath>C:\Users\glax\source\repos\OSM-XML-Importer\OSM-XML-Importer\bin\Debug\net6.0\OSM-XML-Importer.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
using Graph;
|
using Graph;
|
||||||
using Logging;
|
using Logging;
|
||||||
using astar;
|
using astar;
|
||||||
|
using OSM_XML_Importer;
|
||||||
|
|
||||||
Logger logger = new (LogType.CONSOLE, LogLevel.DEBUG);
|
Logger logger = new (LogType.CONSOLE, LogLevel.DEBUG);
|
||||||
Graph.Graph graph = OpenStreetMap_Importer.Importer.Import(@"C:\Users\glax\Downloads\oberbayern-latest.osm", true, logger);
|
Graph.Graph graph = Importer.Import(@"C:\Users\glax\Downloads\oberbayern-latest.osm", true, logger);
|
||||||
logger.level = LogLevel.DEBUG;
|
logger.level = LogLevel.DEBUG;
|
||||||
|
|
||||||
Random r = new();
|
Random r = new();
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
namespace Graph
|
|
||||||
{
|
|
||||||
public class Edge
|
|
||||||
{
|
|
||||||
public ulong id { get; }
|
|
||||||
public Node neighbor { get; }
|
|
||||||
public float time { get; }
|
|
||||||
public float distance { get; }
|
|
||||||
|
|
||||||
public Edge(Node neighbor, float time, float distance, ulong? id)
|
|
||||||
{
|
|
||||||
this.neighbor = neighbor;
|
|
||||||
this.time = time;
|
|
||||||
this.distance = distance;
|
|
||||||
this.id = (id != null) ? id.Value : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
|
|
||||||
namespace Graph
|
|
||||||
{
|
|
||||||
public class Graph
|
|
||||||
{
|
|
||||||
private Dictionary<ulong, Node> nodes { get; }
|
|
||||||
|
|
||||||
public Graph()
|
|
||||||
{
|
|
||||||
this.nodes = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddNode(ulong id, Node n)
|
|
||||||
{
|
|
||||||
return this.nodes.TryAdd(id, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Node NodeAtIndex(int i)
|
|
||||||
{
|
|
||||||
return this.nodes.Values.ToArray()[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetNodeCount()
|
|
||||||
{
|
|
||||||
return this.nodes.Count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Node? GetNode(ulong id)
|
|
||||||
{
|
|
||||||
if (this.nodes.TryGetValue(id, out Node? n))
|
|
||||||
return n;
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ContainsNode(ulong id)
|
|
||||||
{
|
|
||||||
return this.nodes.ContainsKey(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ContainsNode(Node n)
|
|
||||||
{
|
|
||||||
return this.nodes.Values.Contains(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool RemoveNode(ulong id)
|
|
||||||
{
|
|
||||||
return this.nodes.Remove(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool RemoveNode(Node n)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Node ClosestNodeToCoordinates(float lat, float lon)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup />
|
|
||||||
</Project>
|
|
@ -1,25 +0,0 @@
|
|||||||
namespace Graph
|
|
||||||
{
|
|
||||||
public class Node
|
|
||||||
{
|
|
||||||
public float lat { get; }
|
|
||||||
public float lon { get; }
|
|
||||||
|
|
||||||
public HashSet<Edge> edges { get; }
|
|
||||||
|
|
||||||
public Node(float lat, float lon)
|
|
||||||
{
|
|
||||||
this.lat = lat;
|
|
||||||
this.lon = lon;
|
|
||||||
this.edges = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Edge? GetEdgeToNode(Node n)
|
|
||||||
{
|
|
||||||
foreach (Edge e in this.edges)
|
|
||||||
if (e.neighbor == n)
|
|
||||||
return e;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
namespace Graph.Utils
|
|
||||||
{
|
|
||||||
public struct Utils
|
|
||||||
{
|
|
||||||
public static double DistanceBetweenNodes(Node n1, Node n2)
|
|
||||||
{
|
|
||||||
return DistanceBetweenCoordinates(n1.lat, n1.lon, n2.lat, n2.lon);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double DistanceBetweenCoordinates(float lat1, float lon1, float lat2, float lon2)
|
|
||||||
{
|
|
||||||
const int earthRadius = 6371000;
|
|
||||||
double differenceLat = DegreesToRadians(lat2 - lat1);
|
|
||||||
double differenceLon = DegreesToRadians(lon2 - lon1);
|
|
||||||
|
|
||||||
double lat1Rads = DegreesToRadians(lat1);
|
|
||||||
double lat2Rads = DegreesToRadians(lat2);
|
|
||||||
|
|
||||||
double a = Math.Sin(differenceLat / 2) * Math.Sin(differenceLat / 2) + Math.Sin(differenceLon / 2) * Math.Sin(differenceLon / 2) * Math.Cos(lat1Rads) * Math.Cos(lat2Rads);
|
|
||||||
double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
|
|
||||||
|
|
||||||
return earthRadius * c;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double DegreesToRadians(double deg)
|
|
||||||
{
|
|
||||||
return deg * Math.PI / 180.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double RadiansToDegrees(double rad)
|
|
||||||
{
|
|
||||||
return rad * 180.0 / Math.PI;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
namespace Logging
|
|
||||||
{
|
|
||||||
public class Logger
|
|
||||||
{
|
|
||||||
private LogType logType;
|
|
||||||
private string logfilepath;
|
|
||||||
private loglevel level;
|
|
||||||
public Logger(LogType type, loglevel level)
|
|
||||||
{
|
|
||||||
this.logType = type;
|
|
||||||
this.logfilepath = "";
|
|
||||||
this.level = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Logger(LogType type, loglevel level, string path)
|
|
||||||
{
|
|
||||||
this.logType = type;
|
|
||||||
this.logfilepath = path;
|
|
||||||
this.level = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Log(loglevel type, string message, params object[] ?replace)
|
|
||||||
{
|
|
||||||
if(type <= this.level)
|
|
||||||
{
|
|
||||||
string header = string.Format("{0} {1} {2}: ", DateTime.Now.ToLocalTime().ToShortDateString(), DateTime.Now.ToLocalTime().ToLongTimeString(), type.ToString()[0]);
|
|
||||||
switch (this.logType)
|
|
||||||
{
|
|
||||||
case LogType.Console:
|
|
||||||
#pragma warning disable CS8604
|
|
||||||
Console.WriteLine(string.Format(header + message, replace));
|
|
||||||
#pragma warning restore CS8604
|
|
||||||
break;
|
|
||||||
case LogType.Logfile:
|
|
||||||
#pragma warning disable CS8604
|
|
||||||
File.WriteAllText(this.logfilepath, string.Format(header + message, replace));
|
|
||||||
#pragma warning restore CS8604
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum LogType { Console, Logfile }
|
|
||||||
public enum loglevel : ushort { INFO = 0, DEBUG = 1, ERROR = 2, VERBOSE = 3 };
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,349 +0,0 @@
|
|||||||
#pragma warning disable CS8600
|
|
||||||
#pragma warning disable CS8602
|
|
||||||
#pragma warning disable CS8604
|
|
||||||
using Logging;
|
|
||||||
using System.Xml;
|
|
||||||
using Graph;
|
|
||||||
using Graph.Utils;
|
|
||||||
|
|
||||||
namespace OpenStreetMap_Importer
|
|
||||||
{
|
|
||||||
public class Importer
|
|
||||||
{
|
|
||||||
|
|
||||||
private static XmlReaderSettings readerSettings = new()
|
|
||||||
{
|
|
||||||
IgnoreWhitespace = true,
|
|
||||||
IgnoreComments = true
|
|
||||||
};
|
|
||||||
|
|
||||||
public static Graph.Graph Import(string filePath = "", bool onlyJunctions = true, Logger? logger = null)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Count Node occurances when tag is "highway"
|
|
||||||
*/
|
|
||||||
logger?.Log(LogLevel.DEBUG, "Opening File...");
|
|
||||||
Stream mapData = File.Exists(filePath) ? new FileStream(filePath, FileMode.Open, FileAccess.Read) : new MemoryStream(OSM_Data.map);
|
|
||||||
logger?.Log(LogLevel.INFO, "Counting Node-Occurances...");
|
|
||||||
Dictionary<ulong, ushort> occuranceCount = CountNodeOccurances(mapData, logger);
|
|
||||||
logger?.Log(LogLevel.DEBUG, "Way Nodes: {0}", occuranceCount.Count);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Import Nodes and Edges
|
|
||||||
*/
|
|
||||||
mapData.Position = 0;
|
|
||||||
logger?.Log(LogLevel.INFO, "Importing Graph...");
|
|
||||||
Graph.Graph _graph = CreateGraph(mapData, occuranceCount, onlyJunctions, logger);
|
|
||||||
logger?.Log(LogLevel.DEBUG, "Loaded Nodes: {0}", _graph.GetNodeCount());
|
|
||||||
|
|
||||||
mapData.Close();
|
|
||||||
occuranceCount.Clear();
|
|
||||||
GC.Collect();
|
|
||||||
|
|
||||||
return _graph;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Dictionary<ulong, ushort> CountNodeOccurances(Stream mapData, Logger? logger = null)
|
|
||||||
{
|
|
||||||
Dictionary<ulong, ushort> _occurances = new();
|
|
||||||
|
|
||||||
XmlReader _reader = XmlReader.Create(mapData, readerSettings);
|
|
||||||
XmlReader _wayReader;
|
|
||||||
_reader.MoveToContent();
|
|
||||||
|
|
||||||
bool _isHighway;
|
|
||||||
List<ulong> _currentIds = new();
|
|
||||||
|
|
||||||
while (_reader.ReadToFollowing("way"))
|
|
||||||
{
|
|
||||||
_isHighway = false;
|
|
||||||
_currentIds.Clear();
|
|
||||||
_wayReader = _reader.ReadSubtree();
|
|
||||||
logger?.Log(LogLevel.VERBOSE, "WAY: {0}", _reader.GetAttribute("id"));
|
|
||||||
while (_wayReader.Read())
|
|
||||||
{
|
|
||||||
if (_reader.Name == "tag" && _reader.GetAttribute("k").Equals("highway"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!Enum.Parse(typeof(Way.type), _reader.GetAttribute("v"), true).Equals(Way.type.NONE))
|
|
||||||
_isHighway = true;
|
|
||||||
logger?.Log(LogLevel.VERBOSE, "Highway: {0}", _reader.GetAttribute("v"));
|
|
||||||
}
|
|
||||||
catch (ArgumentException) { };
|
|
||||||
}
|
|
||||||
else if(_reader.Name == "nd")
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_currentIds.Add(Convert.ToUInt64(_reader.GetAttribute("ref")));
|
|
||||||
logger?.Log(LogLevel.VERBOSE, "node-ref: {0}", _reader.GetAttribute("ref"));
|
|
||||||
}
|
|
||||||
catch (FormatException) { };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_isHighway)
|
|
||||||
{
|
|
||||||
foreach(ulong _id in _currentIds)
|
|
||||||
{
|
|
||||||
if (!_occurances.TryAdd(_id, 1))
|
|
||||||
_occurances[_id]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_wayReader.Close();
|
|
||||||
}
|
|
||||||
_reader.Close();
|
|
||||||
GC.Collect();
|
|
||||||
|
|
||||||
return _occurances;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Graph.Graph CreateGraph(Stream mapData, Dictionary<ulong, ushort> occuranceCount, bool onlyJunctions, Logger? logger = null)
|
|
||||||
{
|
|
||||||
Graph.Graph _graph = new();
|
|
||||||
Way _currentWay;
|
|
||||||
Node _n1, _n2, _currentNode;
|
|
||||||
float _time, _distance = 0;
|
|
||||||
|
|
||||||
XmlReader _reader = XmlReader.Create(mapData, readerSettings);
|
|
||||||
XmlReader _wayReader;
|
|
||||||
_reader.MoveToContent();
|
|
||||||
|
|
||||||
while (_reader.Read())
|
|
||||||
{
|
|
||||||
if(_reader.Name == "node")
|
|
||||||
{
|
|
||||||
ulong id = Convert.ToUInt64(_reader.GetAttribute("id"));
|
|
||||||
if (occuranceCount.ContainsKey(id))
|
|
||||||
{
|
|
||||||
float lat = Convert.ToSingle(_reader.GetAttribute("lat").Replace('.', ','));
|
|
||||||
float lon = Convert.ToSingle(_reader.GetAttribute("lon").Replace('.', ','));
|
|
||||||
_graph.AddNode(id, new Node(lat, lon));
|
|
||||||
logger?.Log(LogLevel.VERBOSE, "NODE {0} {1} {2} {3}", id, lat, lon, occuranceCount[id]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(_reader.Name == "way")
|
|
||||||
{
|
|
||||||
_wayReader = _reader.ReadSubtree();
|
|
||||||
_currentWay = new();
|
|
||||||
logger?.Log(LogLevel.VERBOSE, "WAY: {0}", _reader.GetAttribute("id"));
|
|
||||||
while (_wayReader.Read())
|
|
||||||
{
|
|
||||||
_wayReader = _reader.ReadSubtree();
|
|
||||||
_currentWay.AddTag("id", _reader.GetAttribute("id"));
|
|
||||||
while (_wayReader.Read())
|
|
||||||
{
|
|
||||||
if (_reader.Name == "tag")
|
|
||||||
{
|
|
||||||
string _value = _reader.GetAttribute("v");
|
|
||||||
string _key = _reader.GetAttribute("k");
|
|
||||||
logger?.Log(LogLevel.VERBOSE, "TAG {0} {1}", _key, _value);
|
|
||||||
_currentWay.AddTag(_key, _value);
|
|
||||||
}
|
|
||||||
else if (_reader.Name == "nd")
|
|
||||||
{
|
|
||||||
ulong _id = Convert.ToUInt64(_reader.GetAttribute("ref"));
|
|
||||||
_currentWay.nodeIds.Add(_id);
|
|
||||||
logger?.Log(LogLevel.VERBOSE, "node-ref: {0}", _id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_wayReader.Close();
|
|
||||||
|
|
||||||
if (!_currentWay.GetHighwayType().Equals(Way.type.NONE))
|
|
||||||
{
|
|
||||||
logger?.Log(LogLevel.VERBOSE, "WAY Nodes-count: {0} Type: {1}", _currentWay.nodeIds.Count, _currentWay.GetHighwayType());
|
|
||||||
if (!onlyJunctions)
|
|
||||||
{
|
|
||||||
for (int _nodeIdIndex = 0; _nodeIdIndex < _currentWay.nodeIds.Count - 1; _nodeIdIndex++)
|
|
||||||
{
|
|
||||||
_n1 = _graph.GetNode(_currentWay.nodeIds[_nodeIdIndex]);
|
|
||||||
_n2 = _graph.GetNode(_currentWay.nodeIds[_nodeIdIndex + 1]);
|
|
||||||
|
|
||||||
_distance = Convert.ToSingle(Utils.DistanceBetweenNodes(_n1, _n2));
|
|
||||||
_time = _distance / _currentWay.GetMaxSpeed();
|
|
||||||
if (!_currentWay.IsOneWay())
|
|
||||||
{
|
|
||||||
_n1.edges.Add(new Edge(_n2, _time, _distance, _currentWay.GetId()));
|
|
||||||
_n2.edges.Add(new Edge(_n1, _time, _distance, _currentWay.GetId()));
|
|
||||||
}
|
|
||||||
else if (_currentWay.IsForward())
|
|
||||||
{
|
|
||||||
_n1.edges.Add(new Edge(_n2, _time, _distance, _currentWay.GetId()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_n2.edges.Add(new Edge(_n1, _time, _distance, _currentWay.GetId()));
|
|
||||||
}
|
|
||||||
logger?.Log(LogLevel.VERBOSE, "Add Edge: {0} & {1} Weight: {2}", _currentWay.nodeIds[_nodeIdIndex], _currentWay.nodeIds[_nodeIdIndex + 1], _time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_n1 = _graph.GetNode(_currentWay.nodeIds[0]);
|
|
||||||
_currentNode = _n1;
|
|
||||||
for(int _nodeIdIndex = 0; _nodeIdIndex < _currentWay.nodeIds.Count - 1; _nodeIdIndex++)
|
|
||||||
{
|
|
||||||
_n2 = _graph.GetNode(_currentWay.nodeIds[_nodeIdIndex + 1]);
|
|
||||||
_distance += Convert.ToSingle(Utils.DistanceBetweenNodes(_currentNode, _n2));
|
|
||||||
if (occuranceCount[_currentWay.nodeIds[_nodeIdIndex]] > 1 || _nodeIdIndex == _currentWay.nodeIds.Count - 2) //junction found
|
|
||||||
{
|
|
||||||
_time = _distance / _currentWay.GetMaxSpeed();
|
|
||||||
if (!_currentWay.IsOneWay())
|
|
||||||
{
|
|
||||||
_n1.edges.Add(new Edge(_n2, _time, _distance, _currentWay.GetId()));
|
|
||||||
_n2.edges.Add(new Edge(_n1, _time, _distance, _currentWay.GetId()));
|
|
||||||
}
|
|
||||||
else if (_currentWay.IsForward())
|
|
||||||
{
|
|
||||||
_n1.edges.Add(new Edge(_n2, _time, _distance, _currentWay.GetId()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_n2.edges.Add(new Edge(_n1, _time, _distance, _currentWay.GetId()));
|
|
||||||
}
|
|
||||||
_distance = 0;
|
|
||||||
logger?.Log(LogLevel.VERBOSE, "Add Edge: {0} & {1} Weight: {2}", _currentWay.nodeIds[_nodeIdIndex], _currentWay.nodeIds[_nodeIdIndex + 1], _time);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_graph.RemoveNode(_currentWay.nodeIds[_nodeIdIndex]); //Not a junction
|
|
||||||
}
|
|
||||||
_currentNode = _n2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_reader.Close();
|
|
||||||
GC.Collect();
|
|
||||||
return _graph;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal struct Way
|
|
||||||
{
|
|
||||||
public List<ulong> nodeIds;
|
|
||||||
private Dictionary<string, object> tags;
|
|
||||||
|
|
||||||
|
|
||||||
public Dictionary<type, int> speed = new() {
|
|
||||||
{ type.NONE, 1 },
|
|
||||||
{ type.motorway, 130 },
|
|
||||||
{ type.trunk, 125 },
|
|
||||||
{ type.primary, 110 },
|
|
||||||
{ type.secondary, 100 },
|
|
||||||
{ type.tertiary, 90 },
|
|
||||||
{ type.unclassified, 40 },
|
|
||||||
{ type.residential, 20 },
|
|
||||||
{ type.motorway_link, 50 },
|
|
||||||
{ type.trunk_link, 50 },
|
|
||||||
{ type.primary_link, 30 },
|
|
||||||
{ type.secondary_link, 25 },
|
|
||||||
{ type.tertiary_link, 25 },
|
|
||||||
{ type.living_street, 20 },
|
|
||||||
{ type.service, 10 },
|
|
||||||
{ type.pedestrian, 10 },
|
|
||||||
{ type.track, 1 },
|
|
||||||
{ type.bus_guideway, 5 },
|
|
||||||
{ type.escape, 1 },
|
|
||||||
{ type.raceway, 1 },
|
|
||||||
{ type.road, 25 },
|
|
||||||
{ type.busway, 5 },
|
|
||||||
{ type.footway, 1 },
|
|
||||||
{ type.bridleway, 1 },
|
|
||||||
{ type.steps, 1 },
|
|
||||||
{ type.corridor, 1 },
|
|
||||||
{ type.path, 10 },
|
|
||||||
{ type.cycleway, 5 },
|
|
||||||
{ type.construction, 1 }
|
|
||||||
};
|
|
||||||
public enum type { NONE, motorway, trunk, primary, secondary, tertiary, unclassified, residential, motorway_link, trunk_link, primary_link, secondary_link, tertiary_link, living_street, service, pedestrian, track, bus_guideway, escape, raceway, road, busway, footway, bridleway, steps, corridor, path, cycleway, construction }
|
|
||||||
|
|
||||||
|
|
||||||
public Way()
|
|
||||||
{
|
|
||||||
this.nodeIds = new List<ulong>();
|
|
||||||
this.tags = new();
|
|
||||||
}
|
|
||||||
public void AddTag(string key, string value, Logger? logger = null)
|
|
||||||
{
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case "highway":
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.tags.Add(key, (type)Enum.Parse(typeof(type), value, true));
|
|
||||||
if (this.GetMaxSpeed().Equals((int)type.NONE))
|
|
||||||
{
|
|
||||||
this.tags["maxspeed"] = (int)this.GetHighwayType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
this.tags.Add(key, type.NONE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "maxspeed":
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (this.tags.ContainsKey("maxspeed"))
|
|
||||||
this.tags["maxspeed"] = Convert.ToInt32(value);
|
|
||||||
else
|
|
||||||
this.tags.Add(key, Convert.ToInt32(value));
|
|
||||||
}
|
|
||||||
catch (FormatException)
|
|
||||||
{
|
|
||||||
this.tags.Add(key, (int)this.GetHighwayType());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "oneway":
|
|
||||||
switch (value)
|
|
||||||
{
|
|
||||||
case "yes":
|
|
||||||
this.tags.Add(key, true);
|
|
||||||
break;
|
|
||||||
case "-1":
|
|
||||||
this.tags.Add("forward", false);
|
|
||||||
break;
|
|
||||||
case "no":
|
|
||||||
this.tags.Add(key, false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "id":
|
|
||||||
this.tags.Add(key, Convert.ToUInt64(value));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
logger?.Log(LogLevel.VERBOSE, "Tag {0} - {1} was not added.", key, value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ulong GetId()
|
|
||||||
{
|
|
||||||
return this.tags.ContainsKey("id") ? (ulong)this.tags["id"] : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public type GetHighwayType()
|
|
||||||
{
|
|
||||||
return this.tags.ContainsKey("highway") ? (type)this.tags["highway"] : type.NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsOneWay()
|
|
||||||
{
|
|
||||||
return this.tags.ContainsKey("oneway") ? (bool)this.tags["oneway"] : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetMaxSpeed()
|
|
||||||
{
|
|
||||||
return this.tags.ContainsKey("maxspeed") ? (int)this.tags["maxspeed"] : (int)this.GetHighwayType();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsForward()
|
|
||||||
{
|
|
||||||
return this.tags.ContainsKey("forward") ? (bool)this.tags["forward"] : true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
73
OpenStreetMap Importer/OSM-Data.Designer.cs
generated
73
OpenStreetMap Importer/OSM-Data.Designer.cs
generated
@ -1,73 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Dieser Code wurde von einem Tool generiert.
|
|
||||||
// Laufzeitversion:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
|
||||||
// der Code erneut generiert wird.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace OpenStreetMap_Importer {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
|
||||||
/// </summary>
|
|
||||||
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
|
||||||
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
|
||||||
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
|
||||||
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
public class OSM_Data {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal OSM_Data() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
public static global::System.Resources.ResourceManager ResourceManager {
|
|
||||||
get {
|
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenStreetMap_Importer.OSM-Data", typeof(OSM_Data).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
|
||||||
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
public static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sucht eine lokalisierte Ressource vom Typ System.Byte[].
|
|
||||||
/// </summary>
|
|
||||||
public static byte[] map {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("map", resourceCulture);
|
|
||||||
return ((byte[])(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,124 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
|
||||||
<data name="map" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>Resources\map.osm;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
@ -1,35 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<RootNamespace>OpenStreetMap_Importer</RootNamespace>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\Graph\Graph.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Logging">
|
|
||||||
<HintPath>..\..\Logging\Logging\bin\Debug\net6.0\Logging.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="osm-data.Designer.cs">
|
|
||||||
<DependentUpon>osm-data.resx</DependentUpon>
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Update="osm-data.resx">
|
|
||||||
<LastGenOutput>osm-data.Designer.cs</LastGenOutput>
|
|
||||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
File diff suppressed because it is too large
Load Diff
@ -7,10 +7,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Graph\Graph.csproj" />
|
<Reference Include="Geo-Graph">
|
||||||
</ItemGroup>
|
<HintPath>C:\Users\glax\source\repos\Geo-Graph\Geo-Graph\bin\Debug\net6.0\Geo-Graph.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Logging">
|
<Reference Include="Logging">
|
||||||
<HintPath>..\..\Logging\Logging\bin\Debug\net6.0\Logging.dll</HintPath>
|
<HintPath>..\..\Logging\Logging\bin\Debug\net6.0\Logging.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@ -7,10 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "astar", "astar.csproj", "{4
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Executable", "..\Executable\Executable.csproj", "{9B311732-9631-480D-97A3-54823CC27CC8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Executable", "..\Executable\Executable.csproj", "{9B311732-9631-480D-97A3-54823CC27CC8}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenStreetMap Importer", "..\OpenStreetMap Importer\OpenStreetMap Importer.csproj", "{1E918E64-866F-4386-AA44-AF7120A9294F}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Graph", "..\Graph\Graph.csproj", "{F8B3B881-73FB-4266-9475-9845067AB5F3}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -25,14 +21,6 @@ Global
|
|||||||
{9B311732-9631-480D-97A3-54823CC27CC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{9B311732-9631-480D-97A3-54823CC27CC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{9B311732-9631-480D-97A3-54823CC27CC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{9B311732-9631-480D-97A3-54823CC27CC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{9B311732-9631-480D-97A3-54823CC27CC8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{9B311732-9631-480D-97A3-54823CC27CC8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{1E918E64-866F-4386-AA44-AF7120A9294F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{1E918E64-866F-4386-AA44-AF7120A9294F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{1E918E64-866F-4386-AA44-AF7120A9294F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{1E918E64-866F-4386-AA44-AF7120A9294F}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{F8B3B881-73FB-4266-9475-9845067AB5F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{F8B3B881-73FB-4266-9475-9845067AB5F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{F8B3B881-73FB-4266-9475-9845067AB5F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{F8B3B881-73FB-4266-9475-9845067AB5F3}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
Loading…
Reference in New Issue
Block a user