diff --git a/data/countries.txt b/data/countries.txt index 4431e8fc8e..44bb7007d9 100644 --- a/data/countries.txt +++ b/data/countries.txt @@ -127,7 +127,7 @@ Estonia Finland France - All regions + All regions|France_Alsace|France_Aquitaine|France_Auvergne|France_Basse-Normandie|France_Bourgogne|France_Bretagne|France_Centre|France_Champagne-Ardenne|France_Corsica|France_Franche-Comte|France_Haute-Normandie|France_Languedoc-Roussillon|France_Limousin|France_Lorraine|France_Midi-Pyrenees|France_Nord-Pas-de-Calais|France_Paris & Ile-de-France|France_Pays de la Loire|France_Picardie|France_Poitou-Charentes|France_Provence-Alpes-Cote d'Azur|France_Rhone-Alpes Alsace|France_Alsace Aquitaine|France_Aquitaine Auvergne|France_Auvergne @@ -152,7 +152,7 @@ Rhone-Alpes|France_Rhone-Alpes Georgia Germany - All states + All states|Germany_Baden-Wurttemberg|Germany_Bavaria|Germany_Berlin & Brandenburg|Germany_Bremen & Lower Saxony|Germany_Hamburg|Germany_Hesse|Germany_Mecklenburg-Vorpommern|Germany_North Rhine-Westphalia|Germany_Rhineland-Palatinate|Germany_Saarland|Germany_Saxony-Anhalt|Germany_Saxony|Germany_Schleswig-Holstein|Germany_Thuringia Baden-Wurttemberg|Germany_Baden-Wurttemberg Bavaria|Germany_Bavaria Berlin & Brandenburg|Germany_Berlin & Brandenburg @@ -244,7 +244,7 @@ Seychelles North America Canada - All provinces and territories + All provinces and territories|Canada_Alberta|Canada_British Columbia|Canada_Manitoba|Canada_New Brunswick|Canada_Newfoundland and Labrador|Canada_Northwest Territories|Canada_Nova Scotia|Canada_Nunavut|Canada_Ontario|Canada_Prince Edward Island|Canada_Quebec|Canada_Saskatchewan|Canada_Yukon Alberta|Canada_Alberta British Columbia|Canada_British Columbia Manitoba|Canada_Manitoba @@ -261,7 +261,7 @@ Greenland Mexico United States of America - All states + All states|USA_Alabama|USA_Alaska|USA_Arizona|USA_Arkansas|USA_California|USA_Colorado|USA_Connecticut|USA_Delaware|USA_District of Columbia|USA_Florida|USA_Georgia|USA_Hawaii|USA_Idaho|USA_Illinois|USA_Indiana|USA_Iowa|USA_Kansas|USA_Kentucky|USA_Louisiana|USA_Maine|USA_Maryland|USA_Massachusetts|USA_Michigan|USA_Minnesota|USA_Mississippi|USA_Missouri|USA_Montana|USA_Nebraska|USA_Nevada|USA_New Hampshire|USA_New Jersey|USA_New Mexico|USA_New York|USA_North Carolina|USA_North Dakota|USA_Ohio|USA_Oklahoma|USA_Oregon|USA_Pennsylvania|USA_Rhode Island|USA_South Carolina|USA_South Dakota|USA_Tennessee|USA_Texas|USA_Utah|USA_Vermont|USA_Virginia|USA_Washington|USA_West Virginia|USA_Wisconsin|USA_Wyoming Alabama|USA_Alabama Alaska|USA_Alaska Arizona|USA_Arizona diff --git a/storage/country.cpp b/storage/country.cpp index 7ab0572da4..0a590a153b 100644 --- a/storage/country.cpp +++ b/storage/country.cpp @@ -1,20 +1,20 @@ #include "country.hpp" -#include "../base/logging.hpp" - -#include "../base/std_serialization.hpp" - -#include "../coding/streams_sink.hpp" -#include "../coding/file_reader.hpp" -#include "../coding/file_writer.hpp" -#include "../coding/file_container.hpp" - #include "../version/version.hpp" #include "../platform/platform.hpp" #include "../indexer/data_header.hpp" +#include "../coding/streams_sink.hpp" +#include "../coding/file_reader.hpp" +#include "../coding/file_writer.hpp" +#include "../coding/file_container.hpp" + +#include "../base/logging.hpp" +#include "../base/std_serialization.hpp" +#include "../base/string_utils.hpp" + #include "../std/fstream.hpp" #include "../std/ctime.hpp" @@ -101,9 +101,6 @@ namespace storage bool LoadCountries(string const & countriesFile, TTilesContainer const & sortedTiles, TCountriesContainer & countries) { - // small prediction - are we using cells or simple countries? - bool const cellsAreUsed = sortedTiles.size() > 1000; - countries.Clear(); ifstream stream(countriesFile.c_str()); std::string line; @@ -138,17 +135,20 @@ namespace storage case 2: // country name case 3: // region { - string const name = line.substr(spaces); - currentCountry = &countries.AddAtDepth(spaces - 1, Country(name)); - if (!cellsAreUsed) - { // we trying to load countries by name instead of square cell tiles + line = line.substr(spaces); + strings::SimpleTokenizer tokIt(line, "|"); + // first string is country name, not always equal to country file name + currentCountry = &countries.AddAtDepth(spaces - 1, Country(*tokIt)); + while (tokIt) + { TTilesContainer::const_iterator const first = sortedTiles.begin(); TTilesContainer::const_iterator const last = sortedTiles.end(); - string const nameWithExt = name + DATA_FILE_EXTENSION; + string const nameWithExt = *tokIt + DATA_FILE_EXTENSION; TTilesContainer::const_iterator found = lower_bound( first, last, TTile(nameWithExt, 0)); if (found != last && !(nameWithExt < found->first)) currentCountry->AddTile(*found); + ++tokIt; } } break;