Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <deathbaba@gmail.com>2010-12-05 19:24:16 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-22 22:33:57 +0300
commitd6e12b7ce4bcbf0ccd1c07eb25de143422913c34 (patch)
treea7e910c330ce4da9b4f2d8be76067adece2561c4 /indexer/index_builder.cpp
One Month In Minsk. Made in Belarus.
Diffstat (limited to 'indexer/index_builder.cpp')
-rw-r--r--indexer/index_builder.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/indexer/index_builder.cpp b/indexer/index_builder.cpp
new file mode 100644
index 0000000000..6b86cef541
--- /dev/null
+++ b/indexer/index_builder.cpp
@@ -0,0 +1,39 @@
+#include "index_builder.hpp"
+#include "feature_processor.hpp"
+#include "features_vector.hpp"
+#include "../coding/file_reader.hpp"
+
+namespace indexer
+{
+ bool BuildIndexFromDatFile(string const & fullIndexFilePath, string const & fullDatFilePath,
+ string const & tmpFilePath)
+ {
+ try
+ {
+ FileReader dataReader(fullDatFilePath);
+ // skip xml header with metadata
+ uint64_t startOffset = feature::ReadDatHeaderSize(dataReader);
+ FileReader subReader = dataReader.SubReader(startOffset, dataReader.Size() - startOffset);
+ FeaturesVector<FileReader> featuresVector(subReader);
+
+ FileWriter indexWriter(fullIndexFilePath.c_str());
+ BuildIndex(featuresVector, indexWriter, tmpFilePath);
+ }
+ catch (Reader::OpenException const & e)
+ {
+ LOG(LERROR, (e.what(), " file is not found"));
+ return false;
+ }
+ catch (Reader::Exception const & e)
+ {
+ LOG(LERROR, ("Unknown error while reading file ", e.what()));
+ return false;
+ }
+ catch (Writer::Exception const & e)
+ {
+ LOG(LERROR, ("Error writing index file", e.what()));
+ }
+
+ return true;
+ }
+} // namespace indexer