[osm/boundaries] check polygons with an ISO3166-2 as well in the country polygon index in case the country polygon is funky

This commit is contained in:
Al
2017-04-09 02:15:42 -04:00
parent 4ecd6c23c6
commit fc91471434
4 changed files with 23 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
import pycountry
class Countries(object):
AFGHANISTAN = 'af'
@@ -252,3 +254,9 @@ class Countries(object):
FORMER_SOVIET_UNION_COUNTRIES = set([RUSSIA, UKRAINE, BELARUS, KAZAKHSTAN, AZERBAIJAN, KYRGYZSTAN, GEORGIA, UZBEKISTAN, ARMENIA, TAJIKISTAN, MOLDOVA, TURKMENISTAN, LATVIA, LITHUANIA, ESTONIA])
CJK_COUNTRIES = set([CHINA, JAPAN, SOUTH_KOREA, TAIWAN, HONG_KONG, MACAO])
all_country_iso_codes = set([c.alpha2.lower() for c in pycountry.countries])
@classmethod
def is_valid_country_code(cls, alpha2_code):
return alpha2_code and alpha2_code.lower() in cls.all_country_iso_codes