Node map more log
This commit is contained in:
parent
edc0cd01f4
commit
fbf7e61a16
@ -12,7 +12,7 @@ public class RegionLoader(float regionSize, string? importFolderPath = null, ILo
|
|||||||
internal readonly string ImportFolderPath = Path.Join(importFolderPath ?? Environment.CurrentDirectory, regionSize.ToString(CultureInfo.InvariantCulture));
|
internal readonly string ImportFolderPath = Path.Join(importFolderPath ?? Environment.CurrentDirectory, regionSize.ToString(CultureInfo.InvariantCulture));
|
||||||
private const string NodesMapRegionFileName = "nodes.map";
|
private const string NodesMapRegionFileName = "nodes.map";
|
||||||
private const string WayMapRegionFileName = "ways.map";
|
private const string WayMapRegionFileName = "ways.map";
|
||||||
private Dictionary<ulong, long>? nodeRegionDict = null;
|
private Dictionary<ulong, long>? _nodeRegionDict;
|
||||||
|
|
||||||
public Graph.Graph? LoadRegionFromRegionId(long regionId)
|
public Graph.Graph? LoadRegionFromRegionId(long regionId)
|
||||||
{
|
{
|
||||||
@ -82,9 +82,11 @@ public class RegionLoader(float regionSize, string? importFolderPath = null, ILo
|
|||||||
public Graph.Graph? LoadRegionFromNodeId(ulong nodeId)
|
public Graph.Graph? LoadRegionFromNodeId(ulong nodeId)
|
||||||
{
|
{
|
||||||
logger?.LogDebug($"Loading Region for Node {nodeId}");
|
logger?.LogDebug($"Loading Region for Node {nodeId}");
|
||||||
if (nodeRegionDict is null)
|
if (_nodeRegionDict is null || _nodeRegionDict.Count < 1)
|
||||||
{
|
{
|
||||||
nodeRegionDict = new();
|
DateTime start = DateTime.Now;
|
||||||
|
logger?.LogInformation($"Loading Node map from {Path.Join(ImportFolderPath, NodesMapRegionFileName)}");
|
||||||
|
_nodeRegionDict = new();
|
||||||
using StreamReader nodesMapFileStream = new(Path.Join(ImportFolderPath, NodesMapRegionFileName), Encoding.ASCII);
|
using StreamReader nodesMapFileStream = new(Path.Join(ImportFolderPath, NodesMapRegionFileName), Encoding.ASCII);
|
||||||
while (!nodesMapFileStream.EndOfStream)
|
while (!nodesMapFileStream.EndOfStream)
|
||||||
{
|
{
|
||||||
@ -93,18 +95,21 @@ public class RegionLoader(float regionSize, string? importFolderPath = null, ILo
|
|||||||
continue;
|
continue;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ulong id = ulong.Parse(line.Split('-')[0]);
|
string[] split = line.Split('-');
|
||||||
long regionId = long.Parse(line.Split('-')[1]);
|
ulong id = ulong.Parse(split[0]);
|
||||||
nodeRegionDict.TryAdd(id, regionId);
|
long regionId = long.Parse(split[1]);
|
||||||
|
logger?.LogTrace($"Adding node {id} {regionId}");
|
||||||
|
_nodeRegionDict.TryAdd(id, regionId);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger?.LogError(e, "Error parsing Node-line.");
|
logger?.LogError(e, "Error parsing Node-line.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger?.LogInformation($"Loading Nodemap took {DateTime.Now - start:mm\\:ss\\.fff}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nodeRegionDict.TryGetValue(nodeId, out long rId))
|
if (_nodeRegionDict.TryGetValue(nodeId, out long rId))
|
||||||
return LoadRegionFromRegionId(rId);
|
return LoadRegionFromRegionId(rId);
|
||||||
logger?.LogWarning($"Could not find Node {nodeId}");
|
logger?.LogWarning($"Could not find Node {nodeId}");
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user