Check if files for ways and tags exist upon import.
This commit is contained in:
parent
87e260562f
commit
349ed9da94
@ -251,14 +251,16 @@ public class RegionConverter
|
|||||||
throw new FileNotFoundException("Region does not exist");
|
throw new FileNotFoundException("Region does not exist");
|
||||||
|
|
||||||
#pragma warning disable SYSLIB0011
|
#pragma warning disable SYSLIB0011
|
||||||
using (FileStream wayFileStream = new FileStream(Path.Join(folderPath, regionHash.ToString(), RegionConverter.WaysFileName), FileMode.Open))
|
string waysPath = Path.Join(folderPath, regionHash.ToString(), RegionConverter.WaysFileName);
|
||||||
{
|
if(File.Exists(waysPath))
|
||||||
while (wayFileStream.Position < wayFileStream.Length)
|
using (FileStream wayFileStream = new FileStream(waysPath, FileMode.Open))
|
||||||
{
|
{
|
||||||
OsmEdge deserializedEdge = (OsmEdge)bFormatter.Deserialize(wayFileStream);
|
while (wayFileStream.Position < wayFileStream.Length)
|
||||||
ways.Add(deserializedEdge);
|
{
|
||||||
|
OsmEdge deserializedEdge = (OsmEdge)bFormatter.Deserialize(wayFileStream);
|
||||||
|
ways.Add(deserializedEdge);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
using (FileStream nodeFileStream = new FileStream(Path.Join(folderPath, regionHash.ToString(), RegionConverter.NodesFileName), FileMode.Open))
|
using (FileStream nodeFileStream = new FileStream(Path.Join(folderPath, regionHash.ToString(), RegionConverter.NodesFileName), FileMode.Open))
|
||||||
{
|
{
|
||||||
@ -269,16 +271,18 @@ public class RegionConverter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (FileStream tagsFileStream = new FileStream(Path.Join(folderPath, regionHash.ToString(), RegionConverter.TagsFileName), FileMode.Open))
|
string tagsPath = Path.Join(folderPath, regionHash.ToString(), RegionConverter.TagsFileName);
|
||||||
{
|
if(File.Exists(tagsPath))
|
||||||
while (tagsFileStream.Position < tagsFileStream.Length)
|
using (FileStream tagsFileStream = new FileStream(tagsPath, FileMode.Open))
|
||||||
{
|
{
|
||||||
TagManager tm = (TagManager)bFormatter.Deserialize(tagsFileStream);
|
while (tagsFileStream.Position < tagsFileStream.Length)
|
||||||
ulong id = (ulong)tm.wayTagSets.First()!.Value.First(tag => tag.key == Tag.TagType.id)!.value;
|
{
|
||||||
foreach(Tag tag in tm.wayTagSets.First()!.Value)
|
TagManager tm = (TagManager)bFormatter.Deserialize(tagsFileStream);
|
||||||
newRegion.tagManager.AddTag(id, tag);
|
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
|
#pragma warning restore SYSLIB0011
|
||||||
|
|
||||||
return new ValueTuple<Region, HashSet<OsmEdge>>(newRegion, ways);
|
return new ValueTuple<Region, HashSet<OsmEdge>>(newRegion, ways);
|
||||||
|
Reference in New Issue
Block a user