Moved id to tag storage
This commit is contained in:
parent
9ef1d4a978
commit
102499891c
@ -67,12 +67,8 @@ public class RegionConverter
|
||||
}
|
||||
else if (xmlReader.Name == "nd")
|
||||
{
|
||||
try
|
||||
{
|
||||
ulong id = Convert.ToUInt64(xmlReader.GetAttribute("ref")!);
|
||||
currentIds.Add(id);
|
||||
}
|
||||
catch (FormatException) { };
|
||||
ulong id = Convert.ToUInt64(xmlReader.GetAttribute("ref")!);
|
||||
currentIds.Add(id);
|
||||
}
|
||||
}
|
||||
wayReader.Close();
|
||||
@ -110,42 +106,31 @@ public class RegionConverter
|
||||
|
||||
private static void ImportWays(XmlReader xmlReader, Dictionary<ulong, ulong> nodeRegions, string outputPath)
|
||||
{
|
||||
BinaryFormatter bFormatter = new BinaryFormatter();
|
||||
bool currentWayIsHighway;
|
||||
ulong currentWayId = 0;
|
||||
List<ulong> currentNodeIds = new();
|
||||
Dictionary<Tag.TagType, dynamic> currentTags = new();
|
||||
Dictionary<ulong, FileStream> regionWaysFileStreams = new();
|
||||
Dictionary<ulong, FileStream> regionTagsFileStreams = new();
|
||||
while (xmlReader.ReadToFollowing("way"))
|
||||
{
|
||||
ulong wayId = Convert.ToUInt64(xmlReader.GetAttribute("id")!);
|
||||
currentWayIsHighway = false;
|
||||
currentNodeIds.Clear();
|
||||
currentTags.Clear();
|
||||
XmlReader wayReader = xmlReader.ReadSubtree();
|
||||
while (wayReader.Read())
|
||||
{
|
||||
currentWayId = Convert.ToUInt64(wayReader.GetAttribute("id")!);
|
||||
currentTags.TryAdd(Tag.TagType.id, Convert.ToUInt64(wayReader.GetAttribute("id")!));
|
||||
if (wayReader.Name == "tag")
|
||||
{
|
||||
Tag wayTag = Tag.ConvertToTag(wayReader.GetAttribute("k")!, wayReader.GetAttribute("v")!);
|
||||
currentTags.TryAdd(wayTag.key, wayTag.value);
|
||||
if(wayTag.key == Tag.TagType.highway)
|
||||
currentWayIsHighway = true;
|
||||
}
|
||||
else if (wayReader.Name == "nd")
|
||||
{
|
||||
try
|
||||
{
|
||||
ulong nodeId = Convert.ToUInt64(wayReader.GetAttribute("ref"));
|
||||
currentNodeIds.Add(nodeId);
|
||||
}
|
||||
catch (FormatException) { };
|
||||
ulong nodeId = Convert.ToUInt64(wayReader.GetAttribute("ref"));
|
||||
currentNodeIds.Add(nodeId);
|
||||
}
|
||||
}
|
||||
wayReader.Close();
|
||||
if (currentWayIsHighway)
|
||||
if (currentTags.ContainsKey(Tag.TagType.highway))
|
||||
{
|
||||
for (int i = 0; i < currentNodeIds.Count - 1; i++)
|
||||
{
|
||||
@ -155,24 +140,24 @@ public class RegionConverter
|
||||
{
|
||||
if (currentTags.ContainsKey(Tag.TagType.forward) && !(bool)currentTags[Tag.TagType.forward])
|
||||
{
|
||||
OsmWay n21e = new OsmWay(currentWayId, node2Id, node1Id, nodeRegions[node2Id]);
|
||||
OsmWay n21e = new OsmWay(currentTags[Tag.TagType.id], node2Id, node1Id, nodeRegions[node2Id]);
|
||||
WriteWay(ref regionWaysFileStreams, nodeRegions[node2Id], n21e, outputPath);
|
||||
WriteTag(ref regionTagsFileStreams, nodeRegions[node2Id], currentTags, outputPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
OsmWay n12e = new OsmWay(currentWayId, node1Id, node2Id, nodeRegions[node2Id]);
|
||||
OsmWay n12e = new OsmWay(currentTags[Tag.TagType.id], node1Id, node2Id, nodeRegions[node2Id]);
|
||||
WriteWay(ref regionWaysFileStreams, nodeRegions[node1Id], n12e, outputPath);
|
||||
WriteTag(ref regionTagsFileStreams, nodeRegions[node1Id], currentTags, outputPath);
|
||||
}
|
||||
}
|
||||
else if(nodeRegions.ContainsKey(node1Id) && nodeRegions.ContainsKey(node2Id))
|
||||
{
|
||||
OsmWay n12e = new OsmWay(currentWayId, node1Id, node2Id, nodeRegions[node2Id]);
|
||||
OsmWay n12e = new OsmWay(currentTags[Tag.TagType.id], node1Id, node2Id, nodeRegions[node2Id]);
|
||||
WriteWay(ref regionWaysFileStreams, nodeRegions[node1Id], n12e, outputPath);
|
||||
WriteTag(ref regionTagsFileStreams, nodeRegions[node1Id], currentTags, outputPath);
|
||||
|
||||
OsmWay n21e = new OsmWay(currentWayId, node2Id, node1Id, nodeRegions[node2Id]);
|
||||
OsmWay n21e = new OsmWay(currentTags[Tag.TagType.id], node2Id, node1Id, nodeRegions[node2Id]);
|
||||
WriteWay(ref regionWaysFileStreams, nodeRegions[node2Id], n21e, outputPath);
|
||||
WriteTag(ref regionTagsFileStreams, nodeRegions[node2Id], currentTags, outputPath);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user