diff --git a/3party/osrm/server.ini b/3party/osrm/server.ini deleted file mode 100644 index b1b1b04819..0000000000 --- a/3party/osrm/server.ini +++ /dev/null @@ -1,3 +0,0 @@ -Threads = 4 -IP = 0.0.0.0 -Port = 5000 diff --git a/generator/borders_generator.cpp b/generator/borders_generator.cpp index 0cd64efc0c..706c9cbd44 100644 --- a/generator/borders_generator.cpp +++ b/generator/borders_generator.cpp @@ -10,35 +10,4 @@ namespace osm { - bool ReadPolygon(istream & stream, m2::RegionD & region, string const & filename) - { - string line, name; - double lon, lat; - - // read ring id, fail if it's empty - getline(stream, name); - if (name.empty() || name == "END") - return false; - - while (stream.good()) - { - getline(stream, line); - strings::Trim(line); - - if (line.empty()) - continue; - - if (line == "END") - break; - - istringstream iss(line); - iss >> lon >> lat; - CHECK(!iss.fail(), ("Incorrect data in", filename)); - - region.AddPoint(MercatorBounds::FromLatLon(lat, lon)); - } - - // drop inner rings - return name[0] != '!'; } -} diff --git a/generator/country_loader.cpp b/generator/country_loader.cpp index cc11b66761..9ec1810380 100644 --- a/generator/country_loader.cpp +++ b/generator/country_loader.cpp @@ -4,11 +4,41 @@ #include "../base/logging.hpp" #include "../coding/file_reader.hpp" -#include "../coding/file_writer.hpp" #include "../coding/streams_sink.hpp" namespace borders { +bool ReadPolygon(istream & stream, m2::RegionD & region, string const & filename) +{ + string line, name; + double lon, lat; + + // read ring id, fail if it's empty + getline(stream, name); + if (name.empty() || name == "END") + return false; + + while (stream.good()) + { + getline(stream, line); + strings::Trim(line); + + if (line.empty()) + continue; + + if (line == "END") + break; + + istringstream iss(line); + iss >> lon >> lat; + CHECK(!iss.fail(), ("Incorrect data in", filename)); + + region.AddPoint(MercatorBounds::FromLatLon(lat, lon)); + } + + // drop inner rings + return name[0] != '!'; +} bool LoadBorders(string const & borderFile, vector & outBorders) { @@ -16,8 +46,12 @@ bool LoadBorders(string const & borderFile, vector & outBorders) string line; if (!getline(stream, line).good()) // skip title { - LOG(LERROR, ("Polygon file is empty:", borderFile)); - return false; + FileReader file(borderFile); + ReaderSource source(file); + stream::SinkReaderStream > stream(source); + + stream >> outBorders; + CHECK(!outBorders.empty(), ("Borders weren't loaded from", borderFile)); } m2::RegionD currentRegion; @@ -34,12 +68,6 @@ bool LoadBorders(string const & borderFile, vector & outBorders) class PolygonLoader { - CountryPolygons m_polygons; - m2::RectD m_rect; - - string const & m_baseDir; - CountriesContainerT & m_countries; - public: PolygonLoader(string const & baseDir, CountriesContainerT & countries) : m_baseDir(baseDir), m_countries(countries) {} @@ -52,11 +80,11 @@ public: vector borders; if (LoadBorders(m_baseDir + BORDERS_DIR + name + BORDERS_EXTENSION, borders)) { - for (size_t i = 0; i < borders.size(); ++i) + for (auto const & border : borders) { - m2::RectD const rect(borders[i].GetRect()); + m2::RectD const rect(border.GetRect()); m_rect.Add(rect); - m_polygons.m_regions.Add(borders[i], rect); + m_polygons.m_regions.Add(border, rect); } } } @@ -72,13 +100,20 @@ public: m_polygons.Clear(); m_rect.MakeEmpty(); } + +private: + CountryPolygons m_polygons; + m2::RectD m_rect; + + string const & m_baseDir; + CountriesContainerT & m_countries; }; bool LoadCountriesList(string const & baseDir, CountriesContainerT & countries) { countries.Clear(); - LOG(LINFO, ("Loading countries.")); + LOG(LINFO, ("Loading countries...")); PolygonLoader loader(baseDir, countries); ForEachCountry(baseDir, loader); diff --git a/generator/country_loader.hpp b/generator/country_loader.hpp index f192980d73..1e56528021 100644 --- a/generator/country_loader.hpp +++ b/generator/country_loader.hpp @@ -3,8 +3,8 @@ #include "../geometry/region2d.hpp" #include "../geometry/tree4d.hpp" -#include "../std/string.hpp" #include "../std/fstream.hpp" +#include "../std/string.hpp" #define BORDERS_DIR "borders/" #define BORDERS_EXTENSION ".poly"