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

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

#include "map/feature_vec_model.hpp"

#include "indexer/scales.hpp"
#include "indexer/classificator_loader.hpp"


namespace
{

class CheckNonEmptyGeometry
{
  int m_scale;
public:
  vector<FeatureID> m_ids;

  void operator() (FeatureID const & id)
  {
    m_ids.push_back(id);
  }

  void operator() (FeatureType const & ft)
  {
    bool res = false;
    ft.ForEachPoint([&res] (m2::PointD const &) { res = true; }, m_scale);
    ft.ForEachTriangle([&res] (m2::PointD const &, m2::PointD const &, m2::PointD const &) { res = true; }, m_scale);

    TEST(res, (ft, "Scale =", m_scale));
  }

  void SetScale(int scale)
  {
    m_ids.clear();
    m_scale = scale;
  }
};

bool RunTest(string const & countryFileName, int lowS, int highS)
{
  model::FeaturesFetcher src;
  auto p = src.RegisterMap(platform::LocalCountryFile::MakeForTesting(countryFileName));
  if (p.second != MwmSet::RegResult::Success)
    return false;

  MwmSet::MwmId const & id = p.first;
  ASSERT(id.IsAlive(), ());

  version::Format const version = id.GetInfo()->m_version.format;
  if (version == version::unknownFormat)
    return false;

  CheckNonEmptyGeometry doCheck;
  for (int scale = lowS; scale <= highS; ++scale)
  {
    doCheck.SetScale(scale);
    src.ForEachFeatureID(MercatorBounds::FullRect(), doCheck, scale);
    src.ReadFeatures(doCheck, doCheck.m_ids);
  }

  return true;
}
}

UNIT_TEST(ForEachFeatureID_Test)
{
  classificator::Load();

  /// @todo Uncomment World* checking after next map data update.
  // TEST(RunTest("World", 0, scales::GetUpperWorldScale()), ());
  // TEST(RunTest("WorldCoasts.mwm", 0, scales::GetUpperWorldScale()), ());
  // TEST(RunTest("Belarus", scales::GetUpperWorldScale() + 1, scales::GetUpperStyleScale()), ());
  TEST(RunTest("minsk-pass", scales::GetUpperWorldScale() + 1, scales::GetUpperStyleScale()), ());
}