/// <summary> Builds persistent index from given parameters. </summary> /// <param name="filePath">Path to map data file.</param> /// <param name="outputDirectory">Output directory for index files.</param> public void BuildIndex(string filePath, string outputDirectory) { if (!outputDirectory.StartsWith(_indexRootFolder)) { Trace.Warn("index.mngr", Strings.MapIndexBuildOutputDirectoryMismatch); } // create directory for output files _fileSystemService.CreateDirectory(outputDirectory); // read settings var jsonContent = _fileSystemService.ReadText(_indexSettingsPath); var node = JSON.Parse(jsonContent); var settings = new IndexSettings(); settings.ReadFromJson(node); // create builder from given parameters var builder = new PersistentIndexBuilder(filePath, outputDirectory, _fileSystemService, settings, _objectPool, Trace); // build builder.Build(); }
private void ReadMapIndexHeader(string headerPath) { var boundingBox = PersistentIndexBuilder.ReadBoundingBox(_fileSystemService.ReadStream(headerPath)); var node = new TreeNode() { Path = Path.GetDirectoryName(headerPath) }; _tree.Insert(node, boundingBox); }
/// <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; }