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: 47050454c83565eeaabbf39e280bc3c7c735fc42 (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
#include "classificator_loader.hpp"
#include "classificator.hpp"
#include "drawing_rules.hpp"
#include "drules_struct.pb.h"

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

#include "../coding/file_reader_stream.hpp"
#include "../coding/file_reader.hpp"

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


namespace classificator
{
  void ReadCommon(ReaderType const & classificator,
                  ReaderType const & visibility,
                  ReaderType const & types)
  {
    string buffer;

    Classificator & c = classif();
    c.Clear();

    //LOG(LINFO, ("Reading classificator"));
    classificator.ReadAsString(buffer);
    c.ReadClassificator(buffer);

    //LOG(LINFO, ("Reading visibility"));
    visibility.ReadAsString(buffer);
    c.ReadVisibility(buffer);

    //LOG(LINFO, ("Reading types mapping"));
    types.ReadAsString(buffer);
    c.ReadTypesMapping(buffer);
  }

  void ReadVisibility(string const & fPath)
  {
    string buffer;
    ReaderType(new FileReader(fPath)).ReadAsString(buffer);
    classif().ReadVisibility(buffer);
  }

  void Load()
  {
    LOG(LINFO, ("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"));
#ifdef USE_PROTO_STYLES
    // Load from protobuffer text file.
    string buffer;
    ReaderType(p.GetReader("drules_proto.txt")).ReadAsString(buffer);
    drule::rules().LoadFromProto(buffer);
#else
    ReaderPtrStream rulesS(p.GetReader("drawing_rules.bin"));
    drule::ReadRules(rulesS);
#endif

    LOG(LINFO, ("Reading of classificator done"));
  }
}