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

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

#include "map/place_page_info.hpp"

#include "indexer/feature.hpp"
#include "indexer/feature_algo.hpp"
#include "indexer/feature_decl.hpp"

#include "metrics/eye.hpp"

namespace utils
{
eye::MapObject MakeEyeMapObject(place_page::Info const & info)
{
  if (!info.IsFeature())
    return {};

  auto types = info.GetTypes();
  if (types.Empty())
    return {};

  types.SortBySpec();

  eye::MapObject mapObject;
  mapObject.SetBestType(classif().GetReadableObjectName(types.GetBestType()));
  mapObject.SetPos(info.GetMercator());
  mapObject.SetDefaultName(info.GetDefaultName());
  mapObject.SetReadableName(info.GetPrimaryFeatureName());

  return mapObject;
}

eye::MapObject MakeEyeMapObject(FeatureType & ft)
{
  feature::TypesHolder types(ft);
  if (types.Empty())
    return {};

  types.SortBySpec();

  eye::MapObject mapObject;
  mapObject.SetBestType(classif().GetReadableObjectName(types.GetBestType()));
  mapObject.SetPos(feature::GetCenter(ft));

  string name;
  if (ft.GetName(StringUtf8Multilang::kDefaultCode, name))
    mapObject.SetDefaultName(name);

  name.clear();
  ft.GetReadableName(name);
  mapObject.SetReadableName(name);

  return mapObject;
}

void RegisterEyeEventIfPossible(eye::MapObject::Event::Type const type,
                                boost::optional<m2::PointD> const & userPos,
                                place_page::Info const & info)
{
  if (!userPos)
    return;

  auto const mapObject = utils::MakeEyeMapObject(info);
  if (!mapObject.IsEmpty())
    eye::Eye::Event::MapObjectEvent(mapObject, type, *userPos);
}
}  // namespace utils