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

index_builder.cpp « indexer - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 360cc504e043a5fe6d63cc244ce0f72102a99c7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "index_builder.hpp"
#include "features_vector.hpp"

#include "../defines.hpp"

#include "../base/logging.hpp"


namespace indexer
{
  bool BuildIndexFromDatFile(string const & datFile, string const & tmpFile)
  {
    try
    {
      // First - open container for writing (it can be reallocated).
      FilesContainerW writeCont(datFile, FileWriter::OP_WRITE_EXISTING);
      FileWriter writer = writeCont.GetWriter(INDEX_FILE_TAG);

      // Second - open container for reading.
      FilesContainerR readCont(datFile);

      feature::DataHeader header;
      header.Load(readCont.GetReader(HEADER_FILE_TAG));

      FeaturesVector featuresVector(readCont, header);

      BuildIndex(header.GetLastScale() + 1, header.GetLastScale(), featuresVector, writer, tmpFile);
    }
    catch (Reader::Exception const & e)
    {
      LOG(LERROR, ("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