From 15628d3544a974c2b4eaa55181290ceebab6dafb Mon Sep 17 00:00:00 2001 From: glax Date: Sat, 1 Apr 2023 01:32:25 +0200 Subject: [PATCH] Loading Tags --- Server/RegionLoader.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Server/RegionLoader.cs b/Server/RegionLoader.cs index 8d06c73..3a2aaa7 100644 --- a/Server/RegionLoader.cs +++ b/Server/RegionLoader.cs @@ -25,6 +25,18 @@ public class RegionLoader Region r = GetRegion(regionHash); return r.ways; } + + public TagManager GetTags(ulong regionHash) + { + Region r = GetRegion(regionHash); + return r.tagManager; + } + + public HashSet? GetTagsForWay(ulong regionHash, ulong wayId) + { + Region r = GetRegion(regionHash); + return r.tagManager.GetTagsForWayId(wayId); + } public Region GetRegion(ulong regionHash) { @@ -60,6 +72,17 @@ public class RegionLoader newRegion.nodes.Add(deserializedNode); } } + + using (FileStream tagsFileStream = new FileStream(Path.Join(path, regionHash.ToString(), RegionConverter.tagsFileName), FileMode.Open)) + { + while (tagsFileStream.Position < tagsFileStream.Length) + { + TagManager tm = (TagManager)bFormatter.Deserialize(tagsFileStream); + ulong id = (ulong)tm.wayTagSets.First()!.Value.First(tag => tag.key == Tag.TagType.id)!.value; + foreach(Tag tag in tm.wayTagSets.First()!.Value) + newRegion.tagManager.AddTag(id, tag); + } + } #pragma warning restore SYSLIB0011 regionIdsDict.Add(regionHash, newRegion);