diff options
Diffstat (limited to 'generator/kml_parser.cpp')
-rw-r--r-- | generator/kml_parser.cpp | 64 |
1 files changed, 1 insertions, 63 deletions
diff --git a/generator/kml_parser.cpp b/generator/kml_parser.cpp index 55f4402354..20ccfe6ca6 100644 --- a/generator/kml_parser.cpp +++ b/generator/kml_parser.cpp @@ -218,7 +218,7 @@ namespace kml } } - bool LoadPolygonsFromKml(string const & kmlFile, PolygonsContainerT & country, int level) + bool LoadPolygons(string const & kmlFile, PolygonsContainerT & country, int level) { KmlParser parser(country, level); try @@ -233,66 +233,4 @@ namespace kml } return false; } - - class PolygonLoader - { - string m_baseDir; - int m_level; - - CountryPolygons & m_polygons; - m2::RectD & m_rect; - - public: - PolygonLoader(string const & basePolygonsDir, int level, CountryPolygons & polygons, m2::RectD & rect) - : m_baseDir(basePolygonsDir), m_level(level), m_polygons(polygons), m_rect(rect) - { - } - - void operator()(string const & name) - { - if (m_polygons.m_name.empty()) - m_polygons.m_name = name; - - PolygonsContainerT current; - if (LoadPolygonsFromKml(m_baseDir + BORDERS_DIR + name + BORDERS_EXTENSION, current, m_level)) - { - for (size_t i = 0; i < current.size(); ++i) - { - m2::RectD const rect(current[i].GetRect()); - m_rect.Add(rect); - m_polygons.m_regions.Add(current[i], rect); - } - } - } - }; - - bool LoadCountriesList(string const & baseDir, CountriesContainerT & countries, - int simplifyCountriesLevel) - { - if (simplifyCountriesLevel > 0) - { - LOG_SHORT(LINFO, ("Simplificator level for country polygons:", simplifyCountriesLevel)); - } - - countries.Clear(); - ifstream stream((baseDir + POLYGONS_FILE).c_str()); - string line; - LOG(LINFO, ("Loading countries.")); - while (stream.good()) - { - std::getline(stream, line); - if (line.empty()) - continue; - - CountryPolygons country; - m2::RectD rect; - - PolygonLoader loader(baseDir, simplifyCountriesLevel, country, rect); - utils::TokenizeString(line, "|", loader); - if (!country.m_regions.IsEmpty()) - countries.Add(country, rect); - } - LOG(LINFO, ("Countries loaded:", countries.GetSize())); - return !countries.IsEmpty(); - } } |