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

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

#include "base/logging.hpp"

namespace style
{

char const * kSupportedColors[] = {"placemark-red",    "placemark-blue",  "placemark-purple",
                                   "placemark-yellow", "placemark-pink",  "placemark-brown",
                                   "placemark-green",  "placemark-orange"};

string GetSupportedStyle(string const & s, string const & context, string const & fallback)
{
  if (s.empty())
    return fallback;

  for (size_t i = 0; i < ARRAY_SIZE(kSupportedColors); ++i)
  {
    if (s == kSupportedColors[i])
      return s;
  }

  // Not recognized symbols are replaced with default one
  LOG(LWARNING, ("Icon", s, "for point", context, "is not supported"));
  return fallback;
}

string GetDefaultStyle() { return kSupportedColors[0]; }

} // style

ApiMarkPoint::ApiMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container)
  : UserMark(ptOrg, container)
{}

ApiMarkPoint::ApiMarkPoint(string const & name, string const & id, string const & style,
                           m2::PointD const & ptOrg, UserMarkContainer * container)
  : UserMark(ptOrg, container),
    m_name(name),
    m_id(id),
    m_style(style)
{}

string ApiMarkPoint::GetSymbolName() const
{
  return m_style.empty() ? "api-result" : m_style;
}

UserMark::Type ApiMarkPoint::GetMarkType() const
{
  return UserMark::Type::API;
}

m2::PointD ApiMarkPoint::GetPixelOffset() const
{
  return m_style.empty() ? m2::PointD(0.0, 0.0) : m2::PointD(0.0, 3.0);
}