aboutsummaryrefslogtreecommitdiff
path: root/libs/map/map_tests/feature_getters_tests.cpp
blob: c20e43af47058595f6a60dfd3860f9e7ff634768 (plain) (blame)
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
#include "testing/testing.hpp"

#include "map/framework.hpp"

#include "indexer/classificator.hpp"

#include "platform/local_country_file.hpp"

#include "coding/string_utf8_multilang.hpp"

#include "geometry/mercator.hpp"

#include <algorithm>
#include <vector>

UNIT_TEST(Framework_ForEachFeatureAtPoint_And_Others)
{
  using namespace std;

  Framework frm({} /* params */, false /* loadMaps */);
  frm.RegisterMap(platform::LocalCountryFile::MakeForTesting("minsk-pass"));

  // May vary according to the new minsk-pass data.
  vector<char const *> types = {
      "highway|footway|",   "hwtag|yesbicycle|",    "psurface|paved_good|",

      "highway|service|",   "psurface|paved_good|",

      "amenity|parking|",

      "barrier|lift_gate|",
  };
  frm.ForEachFeatureAtPoint([&](FeatureType & ft)
  {
    ft.ForEachType([&types](uint32_t type)
    {
      string const strType = classif().GetFullObjectName(type);
      auto found = find(types.begin(), types.end(), strType);
      TEST(found != types.end(), (strType));
      types.erase(found);
    });
  }, mercator::FromLatLon(53.8826576, 27.5378385), scales::GetUpperScale());
  TEST_EQUAL(0, types.size(), (types));

  ftypes::IsBuildingChecker const & isBuilding = ftypes::IsBuildingChecker::Instance();
  {
    // Restaurant in the building.
    auto const id = frm.GetFeatureAtPoint(mercator::FromLatLon(53.89395, 27.567365));
    TEST(id.IsValid(), ());
    frm.GetDataSource().ReadFeature([&](FeatureType & ft)
    {
      TEST_EQUAL("Родны Кут", ft.GetDefaultName(), ());
      TEST(!isBuilding(ft), ());
    }, id);
  }

  {
    // Same building as above, very close to the restaurant.
    auto const id = frm.GetFeatureAtPoint(mercator::FromLatLon(53.893603, 27.567032));
    TEST(id.IsValid(), ());
    frm.GetDataSource().ReadFeature([&](FeatureType & ft) { TEST(isBuilding(ft), ()); }, id);
  }
}