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
|
#include "generator/translator.hpp"
#include "generator/collector_interface.hpp"
#include "generator/emitter_interface.hpp"
#include "generator/intermediate_data.hpp"
#include "generator/osm_element.hpp"
#include "base/assert.hpp"
using namespace feature;
namespace generator
{
Translator::Translator(std::shared_ptr<EmitterInterface> emitter, cache::IntermediateDataReader & cache,
std::shared_ptr<FeatureMakerBase> maker, FilterCollection const & filters,
CollectorCollection const & collectors)
: m_filters(filters)
, m_collectors(collectors)
, m_tagsEnricher(cache)
, m_featureMaker(maker)
, m_emitter(emitter)
, m_cache(cache)
{
CHECK(m_emitter, ());
}
Translator::Translator(std::shared_ptr<EmitterInterface> emitter, cache::IntermediateDataReader & cache,
std::shared_ptr<FeatureMakerBase> maker)
: Translator(emitter, cache, maker, {} /* filters */, {} /* collectors */) {}
void Translator::Emit(OsmElement & element)
{
if (!m_filters.IsAccepted(element))
return;
Preprocess(element);
m_tagsEnricher(element);
m_collectors.Collect(element);
m_featureMaker->Add(element);
FeatureBuilder feature;
while (m_featureMaker->GetNextFeature(feature))
{
if (!m_filters.IsAccepted(feature))
continue;
m_collectors.CollectFeature(feature, element);
m_emitter->Process(feature);
}
}
bool Translator::Finish()
{
m_collectors.Save();
return m_emitter->Finish();
}
void Translator::GetNames(std::vector<std::string> & names) const
{
m_emitter->GetNames(names);
}
void Translator::AddCollector(std::shared_ptr<CollectorInterface> collector)
{
m_collectors.Append(collector);
}
void Translator::AddCollectorCollection(CollectorCollection const & collectors)
{
m_collectors.AddCollection(collectors);
}
void Translator::AddFilter(std::shared_ptr<FilterInterface> filter)
{
m_filters.Append(filter);
}
void Translator::AddFilterCollection(FilterCollection const & filters)
{
m_filters.AddCollection(filters);
}
} // namespace generator
|