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

feature_visibility.hpp « indexer - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bc1ad86bd247a29c5494a71998805c485dee31c9 (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
89
90
91
#pragma once

#include "drawing_rule_def.hpp"

#include "../base/base.hpp"

#include "../std/vector.hpp"
#include "../std/string.hpp"
#include "../std/utility.hpp"


class FeatureBase;

namespace feature
{
  class TypesHolder;

  /// @note do not change this values. Should be equal with EGeomType.
  /// Used for checking visibility (by drawing style) for feature's geometry type
  /// (for Area - check only area type, but can draw symbol or caption).
  enum FeatureGeoType
  {
    FEATURE_TYPE_POINT = 0,
    FEATURE_TYPE_LINE = 1,
    FEATURE_TYPE_AREA = 2
  };

  bool IsDrawableAny(uint32_t type);
  bool IsDrawableForIndex(FeatureBase const & f, int level);

  /// @name Be carefull with FEATURE_TYPE_AREA.
  /// It's check only unique area styles, be it also can draw symbol or caption.
  //@{
  bool IsDrawableLike(vector<uint32_t> const & types, FeatureGeoType ft);
  bool RemoveNoDrawableTypes(vector<uint32_t> & types, FeatureGeoType ft);
  //@}

  int GetMinDrawableScale(FeatureBase const & f);

  /// @return [-1, -1] if no any text exists
  //@{
  /// @name Get scale range when feature is visible.
  pair<int, int> GetDrawableScaleRange(uint32_t type);
  pair<int, int> GetDrawableScaleRange(TypesHolder const & types);

  /// @name Get scale range when feature's text is visible.
  enum
  {
    RULE_TEXT = 1, RULE_SYMBOL = 2
  };

  pair<int, int> GetDrawableScaleRangeForRules(TypesHolder const & types, int rules);
  pair<int, int> GetDrawableScaleRangeForRules(FeatureBase const & f, int rules);
  //@}

  /// @return (geometry type, is coastline)
  pair<int, bool> GetDrawRule(FeatureBase const & f, int level,
                              vector<drule::Key> & keys, string & names);

  /// Used to check whether user types belong to particular classificator set.
  class TypeSetChecker
  {
    uint32_t m_type;
    uint8_t m_level;

    typedef char const * StringT;
    void SetType(StringT * beg, StringT * end);

  public:
    /// Construct by classificator set name.
    //@{
    TypeSetChecker(StringT name) { SetType(&name, &name + 1); }
    TypeSetChecker(StringT arr[], size_t n) { SetType(arr, arr + n); }
    //@}

    bool IsEqual(uint32_t type) const;
    template <class IterT> bool IsEqualR(IterT beg, IterT end) const
    {
      while (beg != end)
      {
        if (IsEqual(*beg++))
          return true;
      }
      return false;
    }
    bool IsEqualV(vector<uint32_t> const & v) const
    {
      return IsEqualR(v.begin(), v.end());
    }
  };
}