/// <summary> Creates instance of <see cref="ElementSource" /> from persistent storage. </summary> /// <param name="directory">Already resolved directory which contains all indecies.</param> /// <param name="fileService">File system service.</param> /// <param name="objectPool">ObjectPool.</param> internal ElementSource(string directory, IFileSystemService fileService, IObjectPool objectPool) { // load map data from streams BoundingBox = PersistentIndexBuilder.ReadBoundingBox(fileService.ReadStream(string.Format(MapConsts.HeaderPathFormat, directory))); KvUsage = new KeyValueUsage(fileService.ReadStream(string.Format(MapConsts.KeyValueUsagePathFormat, directory))); KvIndex = KeyValueIndex.Load(fileService.ReadStream(string.Format(MapConsts.KeyValueIndexPathFormat, directory))); KvStore = new KeyValueStore(KvIndex, KvUsage, fileService.ReadStream(string.Format(MapConsts.KeyValueStorePathFormat, directory))); ElementStore = new ElementStore(KvStore, fileService.ReadStream(string.Format(MapConsts.ElementStorePathFormat, directory)), objectPool); SpatialIndexTree = SpatialIndex.Load(fileService.ReadStream(string.Format(MapConsts.SpatialIndexPathFormat, directory))); IsReadOnly = true; }