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

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

#include "generator/collector_collection.hpp"
#include "generator/filter_collection.hpp"
#include "generator/osm_element.hpp"

#include "base/assert.hpp"

using namespace feature;

namespace generator
{
Translator::Translator(std::shared_ptr<FeatureProcessorInterface> const & processor,
                       std::shared_ptr<cache::IntermediateData> const & cache,
                       std::shared_ptr<FeatureMakerBase> const & maker,
                       std::shared_ptr<FilterInterface> const & filter,
                       std::shared_ptr<CollectorInterface> const & collector)
  : m_filter(filter)
  , m_collector(collector)
  , m_tagsEnricher(cache->GetCache())
  , m_featureMaker(maker)
  , m_processor(processor)
  , m_cache(cache)
{
  m_featureMaker->SetCache(cache->GetCache());
}

Translator::Translator(std::shared_ptr<FeatureProcessorInterface> const & processor,
                       std::shared_ptr<cache::IntermediateData> const & cache,
                       std::shared_ptr<FeatureMakerBase> const & maker)
  : Translator(processor, cache, maker, std::make_shared<FilterCollection>(),
               std::make_shared<CollectorCollection>())
{
}

void Translator::SetCollector(std::shared_ptr<CollectorInterface> const & collector)
{
  m_collector = collector;
}

void Translator::SetFilter(std::shared_ptr<FilterInterface> const & filter) { m_filter = filter; }

void Translator::Emit(OsmElement & element)
{
  Preprocess(element);
  if (!m_filter->IsAccepted(element))
    return;

  m_tagsEnricher(element);
  m_collector->Collect(element);
  m_featureMaker->Add(element);
  FeatureBuilder feature;
  while (m_featureMaker->GetNextFeature(feature))
  {
    if (!m_filter->IsAccepted(feature))
      continue;

    m_collector->CollectFeature(feature, element);
    m_processor->Process(feature);
  }
}

void Translator::Finish()
{
  m_collector->Finish();
  m_processor->Finish();
}

bool Translator::Save()
{
  m_collector->Finalize(true /* isStable */);
  return true;
}
}  // namespace generator