diff options
author | Maksim Andrianov <maksimandrianov1@gmail.com> | 2019-05-08 13:27:24 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2019-05-08 17:15:30 +0300 |
commit | f8e8db3a46a9c18f68d3dcad15be32039d6e49f3 (patch) | |
tree | 17639a5dcd2fe6efed3a72eebe30b5a9c3282665 /generator | |
parent | 37c5e74995665a98705049443f028eab51265f1e (diff) |
[generator] Removed OsmTagMixer from TranslatorWorld.
Diffstat (limited to 'generator')
-rw-r--r-- | generator/generator_tool/generator_tool.cpp | 3 | ||||
-rw-r--r-- | generator/translator_factory.hpp | 5 | ||||
-rw-r--r-- | generator/translator_world.cpp | 23 | ||||
-rw-r--r-- | generator/translator_world.hpp | 15 |
4 files changed, 42 insertions, 4 deletions
diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index 2eacd32225..64457f0109 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -340,7 +340,8 @@ int GeneratorToolMain(int argc, char ** argv) if (FLAGS_generate_world) { auto emitter = CreateEmitter(EmitterType::World, genInfo); - translators.Append(CreateTranslator(TranslatorType::World, emitter, cacheLoader.GetCache(), genInfo)); + auto const translatorType = FLAGS_no_ads ? TranslatorType::World : TranslatorType::WorldWithAds; + translators.Append(CreateTranslator(translatorType, emitter, cacheLoader.GetCache(), genInfo)); } if (FLAGS_make_coasts) diff --git a/generator/translator_factory.hpp b/generator/translator_factory.hpp index 06eb27fc2b..d9a4e5b287 100644 --- a/generator/translator_factory.hpp +++ b/generator/translator_factory.hpp @@ -24,7 +24,8 @@ enum class TranslatorType Country, CountryWithAds, Coastline, - World + World, + WorldWithAds }; template <class... Args> @@ -46,6 +47,8 @@ std::shared_ptr<TranslatorInterface> CreateTranslator(TranslatorType type, Args& return create<TranslatorGeoObjects>(std::forward<Args>(args)...); case TranslatorType::World: return create<TranslatorWorld>(std::forward<Args>(args)...); + case TranslatorType::WorldWithAds: + return create<TranslatorWorldWithAds>(std::forward<Args>(args)...); } UNREACHABLE(); } diff --git a/generator/translator_world.cpp b/generator/translator_world.cpp index a737db9d9a..2faab093e1 100644 --- a/generator/translator_world.cpp +++ b/generator/translator_world.cpp @@ -5,6 +5,7 @@ #include "generator/filter_elements.hpp" #include "generator/generate_info.hpp" #include "generator/intermediate_data.hpp" +#include "generator/node_mixer.hpp" #include "platform/platform.hpp" @@ -19,7 +20,6 @@ TranslatorWorld::TranslatorWorld(std::shared_ptr<EmitterInterface> emitter, cach : Translator(emitter, cache, std::make_shared<FeatureMaker>(cache)) , m_tagAdmixer(info.GetIntermediateFileName("ways", ".csv"), info.GetIntermediateFileName("towns", ".csv")) , m_tagReplacer(GetPlatform().ResourcesDir() + REPLACED_TAGS_FILE) - , m_osmTagMixer(GetPlatform().ResourcesDir() + MIXED_TAGS_FILE) { AddFilter(std::make_shared<FilterPlanet>()); AddFilter(std::make_shared<FilterElements>(base::JoinPath(GetPlatform().ResourcesDir(), SKIPPED_ELEMENTS_FILE))); @@ -29,7 +29,26 @@ void TranslatorWorld::Preprocess(OsmElement & element) { // Here we can add new tags to the elements! m_tagReplacer(element); - m_tagAdmixer(element); + m_tagAdmixer(element);; +} + +TranslatorWorldWithAds::TranslatorWorldWithAds(std::shared_ptr<EmitterInterface> emitter, + cache::IntermediateDataReader & cache, + feature::GenerateInfo const & info) + : TranslatorWorld(emitter, cache, info) + , m_osmTagMixer(base::JoinPath(GetPlatform().ResourcesDir(), MIXED_TAGS_FILE)) {} + +void TranslatorWorldWithAds::Preprocess(OsmElement & element) +{ + // Here we can add new tags to the elements! m_osmTagMixer(element); + TranslatorWorld::Preprocess(element); +} + +bool TranslatorWorldWithAds::Finish() +{ + MixFakeNodes(GetPlatform().ResourcesDir() + MIXED_NODES_FILE, + std::bind(&TranslatorWorldWithAds::Emit, this, std::placeholders::_1)); + return TranslatorWorld::Finish(); } } // namespace generator diff --git a/generator/translator_world.hpp b/generator/translator_world.hpp index d0d0512df1..565fc113b7 100644 --- a/generator/translator_world.hpp +++ b/generator/translator_world.hpp @@ -31,6 +31,21 @@ public: private: TagAdmixer m_tagAdmixer; TagReplacer m_tagReplacer; +}; + +// The TranslatorWorldWithAds class implements translator for building the world with advertising. +class TranslatorWorldWithAds : public TranslatorWorld +{ +public: + explicit TranslatorWorldWithAds(std::shared_ptr<EmitterInterface> emitter, + cache::IntermediateDataReader & cache, + feature::GenerateInfo const & info); + + // TranslatorInterface overrides: + void Preprocess(OsmElement & element) override; + bool Finish() override; + +private: OsmTagMixer m_osmTagMixer; }; } // namespace generator |