| 13 | namespace indexer |
| 14 | { |
| 15 | bool BuildIndexFromDataFile(std::string const & dataFile, std::string const & tmpFile) |
| 16 | { |
| 17 | try |
| 18 | { |
| 19 | std::string const idxFileName(tmpFile + GEOM_INDEX_TMP_EXT); |
| 20 | { |
| 21 | FeaturesVectorTest features(dataFile); |
| 22 | FileWriter writer(idxFileName); |
| 23 | |
| 24 | BuildIndex(features.GetHeader(), features.GetVector(), writer, tmpFile); |
| 25 | } |
| 26 | |
| 27 | FilesContainerW(dataFile, FileWriter::OP_WRITE_EXISTING).Write(idxFileName, INDEX_FILE_TAG); |
| 28 | FileWriter::DeleteFileX(idxFileName); |
| 29 | } |
| 30 | catch (Reader::Exception const & e) |
| 31 | { |
| 32 | LOG(LERROR, ("Error while reading file: ", e.Msg())); |
| 33 | return false; |
| 34 | } |
| 35 | catch (Writer::Exception const & e) |
| 36 | { |
| 37 | LOG(LERROR, ("Error writing index file: ", e.Msg())); |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | return true; |
| 42 | } |
| 43 | } // namespace indexer |