mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-07 04:53:54 +00:00
committed by
Konstantin Pastbin
parent
c9cbb64f12
commit
76ffc99abd
39
libs/indexer/index_builder.cpp
Normal file
39
libs/indexer/index_builder.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "indexer/index_builder.hpp"
|
||||
|
||||
#include "indexer/features_vector.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include "defines.hpp"
|
||||
|
||||
namespace indexer
|
||||
{
|
||||
bool BuildIndexFromDataFile(std::string const & dataFile, std::string const & tmpFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string const idxFileName(tmpFile + GEOM_INDEX_TMP_EXT);
|
||||
{
|
||||
FeaturesVectorTest features(dataFile);
|
||||
FileWriter writer(idxFileName);
|
||||
|
||||
BuildIndex(features.GetHeader(), features.GetVector(), writer, tmpFile);
|
||||
}
|
||||
|
||||
FilesContainerW(dataFile, FileWriter::OP_WRITE_EXISTING).Write(idxFileName, INDEX_FILE_TAG);
|
||||
FileWriter::DeleteFileX(idxFileName);
|
||||
}
|
||||
catch (Reader::Exception const & e)
|
||||
{
|
||||
LOG(LERROR, ("Error while reading file: ", e.Msg()));
|
||||
return false;
|
||||
}
|
||||
catch (Writer::Exception const & e)
|
||||
{
|
||||
LOG(LERROR, ("Error writing index file: ", e.Msg()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace indexer
|
||||
Reference in New Issue
Block a user