forked from organicmaps/organicmaps
Remove polygons.lst, use directory listing
This commit is contained in:
parent
e30b0a0cce
commit
41a9cd6af6
3 changed files with 52 additions and 431 deletions
|
@ -1,368 +0,0 @@
|
|||
Afghanistan
|
||||
Albania
|
||||
Algeria
|
||||
American Samoa
|
||||
Andorra
|
||||
Angola
|
||||
Anguilla
|
||||
Antigua and Barbuda
|
||||
Argentina
|
||||
Armenia
|
||||
Aruba
|
||||
Australia
|
||||
Austria
|
||||
Azerbaijan
|
||||
Bahamas
|
||||
Bahrain
|
||||
Bangladesh
|
||||
Barbados
|
||||
Belarus
|
||||
Belgium
|
||||
Belize
|
||||
Benin
|
||||
Bermuda
|
||||
Bhutan
|
||||
Bolivia
|
||||
Bosnia and Herzegovina
|
||||
Botswana
|
||||
Bouvet Island
|
||||
Brazil_Northeast
|
||||
Brazil_Central-West
|
||||
Brazil_North
|
||||
Brazil_South
|
||||
Brazil_Southeast
|
||||
British Indian Ocean Territory
|
||||
British Virgin Islands
|
||||
Brunei
|
||||
Bulgaria
|
||||
Burkina Faso
|
||||
Burma
|
||||
Burundi
|
||||
Cambodia
|
||||
Cameroon
|
||||
Cape Verde
|
||||
Cayman Islands
|
||||
Central African Republic
|
||||
Chad
|
||||
Chile
|
||||
China
|
||||
Christmas Island
|
||||
Cocos Islands
|
||||
Colombia
|
||||
Comoros
|
||||
Congo-Brazzaville
|
||||
Congo-Kinshasa
|
||||
Cook Islands
|
||||
Costa Rica
|
||||
Croatia
|
||||
Cuba
|
||||
Curacao
|
||||
Cyprus
|
||||
Czech Republic
|
||||
Denmark
|
||||
Djibouti
|
||||
Dominica
|
||||
Dominican Republic
|
||||
East Timor
|
||||
Ecuador
|
||||
Egypt
|
||||
El Salvador
|
||||
Equatorial Guinea
|
||||
Eritrea
|
||||
Estonia
|
||||
Ethiopia
|
||||
Falkland Islands
|
||||
Faroe Islands
|
||||
Fiji
|
||||
Finland
|
||||
French Guiana
|
||||
French Polynesia
|
||||
French Southern Territories
|
||||
Gabon
|
||||
Gambia
|
||||
Georgia
|
||||
Ghana
|
||||
Gibraltar
|
||||
Greece
|
||||
Greenland
|
||||
Grenada
|
||||
Guadeloupe
|
||||
Guam
|
||||
Guatemala
|
||||
Guernsey
|
||||
Guinea-Bissau
|
||||
Guinea
|
||||
Guyana
|
||||
Haiti
|
||||
Heard Island and McDonald Islands
|
||||
Honduras
|
||||
Hungary
|
||||
Iceland
|
||||
India
|
||||
Indonesia
|
||||
Iran
|
||||
Iraq
|
||||
Ireland
|
||||
Isle of Man
|
||||
Israel
|
||||
Italy
|
||||
Ivory Coast
|
||||
Jamaica
|
||||
Japan_Chubu
|
||||
Japan_Chugoku
|
||||
Japan_Hokkaido
|
||||
Japan_Kanto
|
||||
Japan_Kinki
|
||||
Japan_Kyushu
|
||||
Japan_Shikoku
|
||||
Japan_Tohoku
|
||||
Jersey
|
||||
Jordan
|
||||
Kazakhstan
|
||||
Kenya
|
||||
Kiribati
|
||||
Kosovo
|
||||
Kuwait
|
||||
Kyrgyzstan
|
||||
Laos
|
||||
Latvia
|
||||
Lebanon
|
||||
Liberia
|
||||
Libya
|
||||
Liechtenstein
|
||||
Lithuania
|
||||
Luxembourg
|
||||
Macedonia
|
||||
Madagascar
|
||||
Malawi
|
||||
Malaysia
|
||||
Maldives
|
||||
Mali
|
||||
Malta
|
||||
Marshall Islands
|
||||
Martinique
|
||||
Mauritania
|
||||
Mauritius
|
||||
Mayotte
|
||||
Mexico
|
||||
Micronesia
|
||||
Moldova
|
||||
Monaco
|
||||
Mongolia
|
||||
Montenegro
|
||||
Montserrat
|
||||
Morocco
|
||||
Mozambique
|
||||
Namibia
|
||||
Nauru
|
||||
Nepal
|
||||
Netherlands Antilles
|
||||
Netherlands
|
||||
New Caledonia
|
||||
New Zealand
|
||||
Nicaragua
|
||||
Niger
|
||||
Nigeria
|
||||
Niue
|
||||
Norfolk Island
|
||||
North Korea
|
||||
Northern Mariana Islands
|
||||
Norway
|
||||
Oman
|
||||
Pakistan
|
||||
Palau
|
||||
Palestine
|
||||
Panama
|
||||
Papua New Guinea
|
||||
Paraguay
|
||||
Peru
|
||||
Philippines
|
||||
Pitcairn Islands
|
||||
Poland
|
||||
Portugal
|
||||
Puerto Rico
|
||||
Qatar
|
||||
Reunion
|
||||
Romania
|
||||
Rwanda
|
||||
Sahrawi
|
||||
Saint Barthelemy
|
||||
Saint Helena, Ascension and Tristan da Cunha
|
||||
Saint Kitts and Nevis
|
||||
Saint Lucia
|
||||
Saint Martin
|
||||
Saint Pierre and Miquelon
|
||||
Saint Vincent and the Grenadines
|
||||
Samoa
|
||||
San Marino
|
||||
Sao Tome and Principe
|
||||
Saudi Arabia
|
||||
Senegal
|
||||
Serbia
|
||||
Seychelles
|
||||
Sierra Leone
|
||||
Singapore
|
||||
Slovakia
|
||||
Slovenia
|
||||
Solomon Islands
|
||||
Somalia
|
||||
South Africa
|
||||
South Georgia and the South Sandwich Islands
|
||||
South Korea
|
||||
South Sudan
|
||||
Spain
|
||||
Sri Lanka
|
||||
Sudan
|
||||
Suriname
|
||||
Svalbard and Jan Mayen
|
||||
Swaziland
|
||||
Sweden
|
||||
Switzerland
|
||||
Syria
|
||||
Taiwan
|
||||
Tajikistan
|
||||
Tanzania
|
||||
Thailand
|
||||
Togo
|
||||
Tokelau
|
||||
Tonga
|
||||
Trinidad and Tobago
|
||||
Tunisia
|
||||
Turkey
|
||||
Turkmenistan
|
||||
Turks and Caicos Islands
|
||||
Tuvalu
|
||||
Uganda
|
||||
Ukraine
|
||||
United Arab Emirates
|
||||
United States Virgin Islands
|
||||
Uruguay
|
||||
Uzbekistan
|
||||
Vanuatu
|
||||
Vatican
|
||||
Venezuela
|
||||
Vietnam
|
||||
Wallis and Futuna
|
||||
Yemen
|
||||
Zambia
|
||||
Zimbabwe
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
Russia_Central
|
||||
Russia_Far Eastern
|
||||
Russia_North Caucasian
|
||||
Russia_Northwestern
|
||||
Russia_Siberian
|
||||
Russia_Southern
|
||||
Russia_Urals
|
||||
Russia_Volga
|
||||
UK_England
|
||||
UK_Northern Ireland
|
||||
UK_Scotland
|
||||
UK_Wales
|
||||
Crimea
|
||||
Clarion Island
|
||||
Clipperton Island
|
||||
Cocos Island
|
||||
Galapagos Islands
|
||||
Guadalupe Island
|
||||
Malpelo Island
|
||||
Socorro Island
|
|
@ -22,8 +22,8 @@
|
|||
#include "../std/vector.hpp"
|
||||
#include "../std/bind.hpp"
|
||||
|
||||
|
||||
#define POLYGONS_FILE "polygons.lst"
|
||||
#include "../../boost/boost/filesystem.hpp"
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
|
||||
namespace borders
|
||||
|
@ -34,27 +34,22 @@ 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) {}
|
||||
PolygonLoader(CountriesContainerT & countries)
|
||||
: m_countries(countries) {}
|
||||
|
||||
void operator() (string const & name)
|
||||
void operator() (string const & name, vector<m2::RegionD> & borders)
|
||||
{
|
||||
if (m_polygons.m_name.empty())
|
||||
m_polygons.m_name = name;
|
||||
|
||||
vector<m2::RegionD> borders;
|
||||
if (osm::LoadBorders(m_baseDir + BORDERS_DIR + name + BORDERS_EXTENSION, borders))
|
||||
for (size_t i = 0; i < borders.size(); ++i)
|
||||
{
|
||||
for (size_t i = 0; i < borders.size(); ++i)
|
||||
{
|
||||
m2::RectD const rect(borders[i].GetRect());
|
||||
m_rect.Add(rect);
|
||||
m_polygons.m_regions.Add(borders[i], rect);
|
||||
}
|
||||
m2::RectD const rect(borders[i].GetRect());
|
||||
m_rect.Add(rect);
|
||||
m_polygons.m_regions.Add(borders[i], rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,18 +69,21 @@ public:
|
|||
template <class ToDo>
|
||||
void ForEachCountry(string const & baseDir, ToDo & toDo)
|
||||
{
|
||||
ifstream stream((baseDir + POLYGONS_FILE).c_str());
|
||||
string line;
|
||||
string bordersDir = baseDir + BORDERS_DIR;
|
||||
ASSERT(fs::exists(bordersDir) && fs::is_directory(bordersDir), ("Cannot read borders directory", bordersDir));
|
||||
|
||||
while (stream.good())
|
||||
fs::directory_iterator end_iter;
|
||||
for (fs::directory_iterator dir_iter(bordersDir); dir_iter != end_iter; ++dir_iter)
|
||||
{
|
||||
std::getline(stream, line);
|
||||
if (line.empty())
|
||||
continue;
|
||||
|
||||
// in polygons file every country is a separate string
|
||||
toDo(line);
|
||||
toDo.Finish();
|
||||
if (fs::is_regular_file(dir_iter->status()) && dir_iter->path().filename().string().find(BORDERS_EXTENSION) != string::npos)
|
||||
{
|
||||
vector<m2::RegionD> borders;
|
||||
if (osm::LoadBorders(dir_iter->path().string(), borders))
|
||||
{
|
||||
toDo(dir_iter->path().stem().string(), borders);
|
||||
toDo.Finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +93,7 @@ bool LoadCountriesList(string const & baseDir, CountriesContainerT & countries)
|
|||
|
||||
LOG(LINFO, ("Loading countries."));
|
||||
|
||||
PolygonLoader loader(baseDir, countries);
|
||||
PolygonLoader loader(countries);
|
||||
ForEachCountry(baseDir, loader);
|
||||
|
||||
LOG(LINFO, ("Countries loaded:", countries.GetSize()));
|
||||
|
@ -106,53 +104,48 @@ bool LoadCountriesList(string const & baseDir, CountriesContainerT & countries)
|
|||
class PackedBordersGenerator
|
||||
{
|
||||
FilesContainerW m_writer;
|
||||
string const & m_baseDir;
|
||||
|
||||
vector<storage::CountryDef> m_polys;
|
||||
|
||||
public:
|
||||
PackedBordersGenerator(string const & baseDir)
|
||||
: m_writer(baseDir + PACKED_POLYGONS_FILE), m_baseDir(baseDir)
|
||||
: m_writer(baseDir + PACKED_POLYGONS_FILE)
|
||||
{
|
||||
}
|
||||
|
||||
void operator() (string const & name)
|
||||
void operator() (string const & name, vector<m2::RegionD> & borders)
|
||||
{
|
||||
vector<m2::RegionD> borders;
|
||||
if (osm::LoadBorders(m_baseDir + BORDERS_DIR + name + BORDERS_EXTENSION, borders))
|
||||
// use index in vector as tag
|
||||
FileWriter w = m_writer.GetWriter(strings::to_string(m_polys.size()));
|
||||
serial::CodingParams cp;
|
||||
|
||||
uint32_t const count = static_cast<uint32_t>(borders.size());
|
||||
|
||||
// calc rect
|
||||
m2::RectD rect;
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
rect.Add(borders[i].GetRect());
|
||||
|
||||
// store polygon info
|
||||
m_polys.push_back(storage::CountryDef(name, rect));
|
||||
|
||||
// write polygons as paths
|
||||
WriteVarUint(w, count);
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
{
|
||||
// use index in vector as tag
|
||||
FileWriter w = m_writer.GetWriter(strings::to_string(m_polys.size()));
|
||||
serial::CodingParams cp;
|
||||
typedef vector<m2::PointD> VectorT;
|
||||
typedef m2::DistanceToLineSquare<m2::PointD> DistanceT;
|
||||
|
||||
uint32_t const count = static_cast<uint32_t>(borders.size());
|
||||
VectorT const & in = borders[i].Data();
|
||||
VectorT out;
|
||||
|
||||
// calc rect
|
||||
m2::RectD rect;
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
rect.Add(borders[i].GetRect());
|
||||
/// @todo Choose scale level for simplification.
|
||||
double const eps = my::sq(scales::GetEpsilonForSimplify(10));
|
||||
DistanceT dist;
|
||||
SimplifyNearOptimal(20, in.begin(), in.end(), eps, dist,
|
||||
AccumulateSkipSmallTrg<DistanceT, m2::PointD>(dist, out, eps));
|
||||
|
||||
// store polygon info
|
||||
m_polys.push_back(storage::CountryDef(name, rect));
|
||||
|
||||
// write polygons as paths
|
||||
WriteVarUint(w, count);
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
{
|
||||
typedef vector<m2::PointD> VectorT;
|
||||
typedef m2::DistanceToLineSquare<m2::PointD> DistanceT;
|
||||
|
||||
VectorT const & in = borders[i].Data();
|
||||
VectorT out;
|
||||
|
||||
/// @todo Choose scale level for simplification.
|
||||
double const eps = my::sq(scales::GetEpsilonForSimplify(10));
|
||||
DistanceT dist;
|
||||
SimplifyNearOptimal(20, in.begin(), in.end(), eps, dist,
|
||||
AccumulateSkipSmallTrg<DistanceT, m2::PointD>(dist, out, eps));
|
||||
|
||||
serial::SaveOuterPath(out, cp, w);
|
||||
}
|
||||
serial::SaveOuterPath(out, cp, w);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
|
||||
#include "../std/fstream.hpp"
|
||||
|
||||
#define POLYGONS_FILE "polygons.lst"
|
||||
#define BORDERS_DIR "borders/"
|
||||
#define BORDERS_EXTENSION ".kml"
|
||||
|
||||
#define MIN_SIMPLIFIED_POINTS_COUNT 4
|
||||
|
||||
namespace feature
|
||||
|
|
Loading…
Add table
Reference in a new issue