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

map_style_reader.cpp « indexer - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: db88c4b6bec1c985069a7d241041384a1adade1d (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
#include "map_style_reader.hpp"

#include "base/logging.hpp"

#include "coding/file_name_utils.hpp"

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

#include "std/string.hpp"

namespace
{

char const * const kMapStyleKey = "MapStyleKeyV1";

const char * const kSuffixLegacyLight = "";
const char * const kSuffixLegacyDark = "_dark";
const char * const kSuffixModernClear = "_clear";

string GetStyleSuffix(MapStyle mapStyle)
{
  switch (mapStyle)
  {
  case MapStyleLight:
    return kSuffixLegacyLight;
   case MapStyleDark:
    return kSuffixLegacyDark;
  case MapStyleClear:
    return kSuffixModernClear;
  }
  LOG(LWARNING, ("Unknown map style", mapStyle));
  return kSuffixModernClear;
}

}  // namespace

void StyleReader::SetCurrentStyle(MapStyle mapStyle)
{
  Settings::Set(kMapStyleKey, static_cast<int>(mapStyle));
}

MapStyle StyleReader::GetCurrentStyle()
{
  int mapStyle = MapStyleLight;
// @TODO(shalnev) It's a hotfix to fix tests generator_tests and map_tests.
// Tests should work with any styles.
#if defined(OMIM_OS_ANDROID) || defined(OMIM_OS_IPHONE)
  if (!Settings::Get(kMapStyleKey, mapStyle))
    mapStyle = MapStyleClear;
#endif

  return static_cast<MapStyle>(mapStyle);
}

ReaderPtr<Reader> StyleReader::GetDrawingRulesReader()
{
  string const rulesFile = string("drules_proto") + GetStyleSuffix(GetCurrentStyle()) + ".bin";
  return GetPlatform().GetReader(rulesFile);
}

ReaderPtr<Reader> StyleReader::GetResourceReader(string const & file, string const & density)
{
  string const resourceDir = string("resources-") + density + GetStyleSuffix(GetCurrentStyle());
  return GetPlatform().GetReader(my::JoinFoldersToPath(resourceDir, file));
}

StyleReader & GetStyleReader()
{
  static StyleReader instance;
  return instance;
}