| 1 | #include "GeoDictionariesLoader.h" | 
|---|---|
| 2 | |
| 3 | #include <Poco/Util/AbstractConfiguration.h> | 
| 4 | #include "GeodataProviders/HierarchiesProvider.h" | 
| 5 | #include "GeodataProviders/NamesProvider.h" | 
| 6 | |
| 7 | std::unique_ptr<RegionsHierarchies> GeoDictionariesLoader::reloadRegionsHierarchies(const Poco::Util::AbstractConfiguration & config) | 
| 8 | { | 
| 9 | static constexpr auto config_key = "path_to_regions_hierarchy_file"; | 
| 10 | |
| 11 | if (!config.has(config_key)) | 
| 12 | return {}; | 
| 13 | |
| 14 | const auto default_hierarchy_file = config.getString(config_key); | 
| 15 | auto data_provider = std::make_unique<RegionsHierarchiesDataProvider>(default_hierarchy_file); | 
| 16 | return std::make_unique<RegionsHierarchies>(std::move(data_provider)); | 
| 17 | } | 
| 18 | |
| 19 | std::unique_ptr<RegionsNames> GeoDictionariesLoader::reloadRegionsNames(const Poco::Util::AbstractConfiguration & config) | 
| 20 | { | 
| 21 | static constexpr auto config_key = "path_to_regions_names_files"; | 
| 22 | |
| 23 | if (!config.has(config_key)) | 
| 24 | return {}; | 
| 25 | |
| 26 | const auto directory = config.getString(config_key); | 
| 27 | auto data_provider = std::make_unique<RegionsNamesDataProvider>(directory); | 
| 28 | return std::make_unique<RegionsNames>(std::move(data_provider)); | 
| 29 | } | 
| 30 | 
