#include "generator/emitter_country.hpp" #include "generator/city_boundary_processor.hpp" #include "generator/feature_builder.hpp" #include "generator/feature_processing_layers.hpp" #include "generator/generate_info.hpp" #include "base/logging.hpp" #include #include "defines.hpp" namespace generator { EmitterCountry::EmitterCountry(feature::GenerateInfo const & info) : m_cityBoundaryProcessor(std::make_shared(info.m_boundariesTable)) , m_countryMapper(std::make_shared(info)) , m_skippedListFilename(info.GetIntermediateFileName("skipped_elements", ".lst")) { m_processingChain = std::make_shared(m_cityBoundaryProcessor); m_processingChain->Add(std::make_shared()); m_processingChain->Add(std::make_shared(m_cityBoundaryProcessor)); m_processingChain->Add(std::make_shared(info.m_bookingDatafileName, m_countryMapper)); m_processingChain->Add(std::make_shared(info.m_opentableDatafileName, m_countryMapper)); m_processingChain->Add(std::make_shared(m_countryMapper)); if (info.m_emitCoasts) { auto const geomFilename = info.GetIntermediateFileName(WORLD_COASTS_FILE_NAME, ".geom"); auto const worldCoastsFilename = info.GetTmpFileName(WORLD_COASTS_FILE_NAME); m_processingChain->Add(std::make_shared(worldCoastsFilename, geomFilename, m_countryMapper)); } } void EmitterCountry::Process(FeatureBuilder1 & feature) { m_processingChain->Handle(feature); } bool EmitterCountry::Finish() { for (auto & feature : m_cityBoundaryProcessor->GetFeatures()) m_countryMapper->RemoveInvalidTypesAndMap(feature); WriteDump(); return true; } void EmitterCountry::GetNames(std::vector & names) const { names = m_countryMapper->GetNames(); } void EmitterCountry::WriteDump() { std::ofstream file; file.exceptions(std::ios::failbit | std::ios::badbit); file.open(m_skippedListFilename); file << m_processingChain->GetAsStringRecursive(); LOG(LINFO, ("Skipped elements were saved to", m_skippedListFilename)); } } // namespace generator