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

classificator_loader.cpp « indexer - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 34cc1fdc755202176407f535fed6b3a32915f02e (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "classificator_loader.hpp"
#include "classificator.hpp"
#include "drawing_rules.hpp"

#include "../defines.hpp"

#include "../platform/platform.hpp"

#include "../coding/reader_streambuf.hpp"

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

#include "../std/iostream.hpp"
#include "../std/fstream.hpp"


namespace classificator
{
  void ReadCommon(Reader * classificator,
                  Reader * visibility,
                  Reader * types)
  {
    Classificator & c = classif();
    c.Clear();

    {
      //LOG(LINFO, ("Reading classificator"));
      ReaderStreamBuf buffer(classificator);

      istream s(&buffer);
      c.ReadClassificator(s);
    }

    {
      //LOG(LINFO, ("Reading visibility"));
      ReaderStreamBuf buffer(visibility);

      istream s(&buffer);
      c.ReadVisibility(s);
    }

    {
      //LOG(LINFO, ("Reading types mapping"));
      ReaderStreamBuf buffer(types);

      istream s(&buffer);
      c.ReadTypesMapping(s);
    }
  }

  void ReadVisibility(string const & fPath)
  {
    ifstream s(fPath.c_str());
    classif().ReadVisibility(s);
  }

  void Load()
  {
    LOG(LDEBUG, ("Reading of classificator started"));

    Platform & p = GetPlatform();

    ReadCommon(p.GetReader("classificator.txt"),
               p.GetReader("visibility.txt"),
               p.GetReader("types.txt"));

    //LOG(LINFO, ("Reading of drawing rules"));
    drule::RulesHolder & rules = drule::rules();

#if defined(OMIM_PRODUCTION)
    // Load from proto buffer binary file.
    string buffer;
    ModelReaderPtr(p.GetReader(DRAWING_RULES_BIN_FILE)).ReadAsString(buffer);

    rules.LoadFromBinaryProto(buffer);
#else
    // Load from proto buffer text file.
    string buffer;
    ModelReaderPtr(p.GetReader(DRAWING_RULES_TXT_FILE)).ReadAsString(buffer);

    rules.LoadFromTextProto(buffer);
#endif

    LOG(LDEBUG, ("Reading of classificator finished"));
  }
}