diff options
author | Alex Zolotarev <deathbaba@gmail.com> | 2011-04-01 06:09:07 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:14:36 +0300 |
commit | 4ee5ce10131f47924a33d0af59878b9deb098a10 (patch) | |
tree | 8ddda54f3558aea228ab17869fe2979b223b959a /generator/kml_parser.cpp | |
parent | 06c612827e830562514452e9b79b4bc3a7c8863b (diff) |
Added osm country borders generation and used them when building planet
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(); - } } |