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

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

#include "indexer/feature_data.hpp"
#include "indexer/feature_visibility.hpp"
#include "indexer/classificator.hpp"
#include "indexer/classificator_loader.hpp"
#include "indexer/scales.hpp"

#include "base/logging.hpp"

#include "std/set.hpp"

namespace
{

class DoGetMaxLowMinHighZoom
{
  Classificator const & m_classif;
  pair<int, int> m_res;
  string m_low;

  set<uint32_t> m_skip;
  bool IsSkip(uint32_t t) const
  {
    ftype::TruncValue(t, 2);
    return m_skip.count(t) > 0;
  }

public:
  DoGetMaxLowMinHighZoom(Classificator const & c)
    : m_classif(classif()), m_res(-1, 1000)
  {
    char const * arr[][2] = {
      {"highway", "bus_stop"},
      {"highway", "speed_camera"},
      {"highway", "platform"},
      {"highway", "world_level"},
      {"highway", "world_towns_level"},
    };

    for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
      m_skip.insert(c.GetTypeByPath(vector<string>(arr[i], arr[i] + 2)));
  }

  void operator() (ClassifObject const * p, uint32_t type)
  {
    if (IsSkip(type))
      return;

    pair<int, int> const r = feature::GetDrawableScaleRange(type);
    if (r.first == -1 || r.second == -1)
    {
      LOG(LINFO, (r, m_classif.GetFullObjectName(type)));
      return;
    }

    if (m_res.first < r.first)
    {
      m_res.first = r.first;
      m_low = p->GetName();
    }
    if (m_res.second > r.second)
      m_res.second = r.second;
  }

  void Print()
  {
    TEST_EQUAL(m_res.second, scales::GetUpperStyleScale(), (m_res));
    LOG(LINFO, ("Max low highway zoom:", m_res, "for type:", m_low));
  }
};

}

UNIT_TEST(VisibleScales_Highway)
{
  Classificator const & c = classif();

  char const * arr[] = { "highway" };
  uint32_t const type = c.GetTypeByPath(vector<string>(arr, arr + 1));

  ClassifObject const * pObj = c.GetObject(type);

  DoGetMaxLowMinHighZoom doGet(c);
  pObj->ForEachObjectInTree(doGet, type);

  doGet.Print();
}