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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
#include "feature_styler.hpp"
namespace
{
struct less_depth
{
bool operator() (di::DrawRule const & r1, di::DrawRule const & r2) const
{
return (r1.m_depth < r2.m_depth);
}
};
}
namespace feature
{
StylesContainer::StylesContainer() {}
StylesContainer::~StylesContainer()
{
//for_each(m_rules.begin(), m_rules.end(), DeleteFunctor());
}
void StylesContainer::GetStyles(FeatureType const & f, int const zoom)
{
// do special stuff
vector<drule::Key> keys;
string names; // for debug use only, in release it's empty
pair<int, bool> type = feature::GetDrawRule(f, zoom, keys, names);
m_hasLineStyles = false;
m_geometryType = type.first;
m_isCoastline = type.second;
f.GetPreferredDrawableNames(m_primaryText, m_secondaryText);
m_refText = f.GetRoadNumber();
double const population = static_cast<double>(f.GetPopulation());
if (population == 1)
m_popRank = 0.0;
else
{
double const upperBound = 3.0E6;
m_popRank = min(upperBound, population) / upperBound;
}
// low zoom heuristics
if (zoom <= 5)
{
// draw country names and capitals on native language only
if (!m_secondaryText.empty())
{
m_primaryText.swap(m_secondaryText);
m_secondaryText.clear();
}
// don't use population rank on low zoom
m_popRank = 0.0;
// hide superlong names on low zoom
if (m_primaryText.size() > 70)
m_primaryText.clear();
}
m_priorityModifier = 0;
if (population != 0){
// dividing by planet population to get m_priorityModifier < 1
m_priorityModifier = static_cast<double>(population) / 7E9;
}
drule::MakeUnique(keys);
size_t const count = keys.size();
int layer = f.GetLayer();
bool isTransparent = false;
if (layer == feature::LAYER_TRANSPARENT_TUNNEL)
{
layer = 0;
isTransparent = true;
}
m_rules.resize(count);
for (size_t i = 0; i < count; ++i)
{
double depth = keys[i].m_priority;
if (layer != 0)
depth = (layer * drule::layer_base_priority) + fmod(depth, drule::layer_base_priority);
depth += m_priorityModifier;
m_rules[i] = ( di::DrawRule( drule::rules().Find(keys[i]), depth, isTransparent) );
if (!m_hasLineStyles && (keys[i].m_type == drule::line))
m_hasLineStyles = true;
if (m_hasLineStyles && !m_hasPathText && !m_primaryText.empty())
if (m_rules[i].m_rule->GetCaption(0) != 0)
m_hasPathText = true;
}
sort(m_rules.begin(), m_rules.end(), less_depth());
m_count = m_rules.size();
}
}
|