1
0
Fork 0
forked from 0x2620/oxjs

update geo module

This commit is contained in:
rolux 2011-11-17 02:15:03 +01:00
commit 1503901e81
39 changed files with 3945 additions and 1685 deletions

View file

@ -223,6 +223,7 @@ geo = {
'Coral Sea Islands': 'Flag_of_Australia.svg',
'Diego Garcia': 'Flag_of_the_British_Indian_Ocean_Territory.svg',
'French Guiana': 'Flag_of_French_Guiana.svg',
'Heard Island and McDonald Islands': 'Flag_of_Australia.svg',
'Korea': 'Flag_of_Korea_1882.svg',
# 'Libya': 'Flag_of_the_Libyan_Jamahiriya_1977.svg',
'Metropolitan France': 'Flag_of_France.svg',
@ -260,7 +261,6 @@ geo = {
'Byelorussian Soviet Socialist Republic': ['Belarus'],
'Canton and Enderbury Islands': ['Canton Island', 'Enderbury Island'],
'Ceuta and Melilla': ['Ceuta', 'Melilla'],
'Clipperton Island': ['Île de la Passion'],
'Curaçao': ['Banda Abou, Curaçao'],
'Czechoslovakia': ['Czech Republic', 'Slovakia'],
'East Germany': [
@ -281,8 +281,7 @@ geo = {
'Korea': ['North Korea', 'South Korea'],
'Lebanon': ['Lebanon, Asia'], # in case results are us-biased
'Metropolitan France': ['France'],
'Midway Islands': ['Midway Atoll'],
'Neutral Zone': ['Neutral Zone, Saudi Arabia'],
'Neutral Zone': ['39944, Saudi Arabia', '76611, Saudi Arabia'],
'New Hebrides': ['Vanuatu'],
'North Vietnam': ['Ha Giang, Vietnam', 'Lai Chau, Vietnam', 'Thua Thien-Hue, Vietnam'],
'Northern Cyprus': ['Karpass, Cyprus', 'Kokkina, Cyprus', 'Lympia, Cyprus'],
@ -308,10 +307,14 @@ geo = {
'Russia', 'Tajikistan', 'Turkmenistan', 'Ukraine', 'Uzbekistan'
],
'United Kingdom': ['England', 'Northern Ireland', 'Scotland', 'Wales, United Kingdom'],
'United States Minor Outlying Islands': ['Midway Islands'],
# Baker Island, Howland Island, Jarvis Island, Kingman Reef, Palmyra Atoll --
# but the first three each return the full United States Minor Outlying Islands
'United States Miscellaneous Pacific Islands': ['Kingman Reef', 'Palmyra Atoll'],
'United States Minor Outlying Islands': [
'Baker Island, UM', 'Howland Island', 'Jarvis Island', 'Johnston Atoll', 'Kingman Reef',
'Midway Islands', 'Palmyra Atoll', 'Wake Island'
],
# see http://en.wikipedia.org/wiki/United_States_Miscellaneous_Pacific_Islands
'United States Miscellaneous Pacific Islands': [
'Baker Island, UM', 'Howland Island', 'Jarvis Island', 'Kingman Reef', 'Palmyra Atoll'
],
'UK': ['England', 'Northern Ireland', 'Scotland', 'Wales, United Kingdom'],
'Upper Volta': ['Burkina Faso'],
'Wake Island': ['Wake Atoll'],
@ -579,7 +582,7 @@ geo = {
'SI': 'crop(left)',
'SITH': 'crop()',
'SJ': 'crop(left)',
'SK': 'crop(679)',
'SK': 'crop(left)',
'SKIN': 'border(165)',
'SL': 'crop()',
'SM': 'crop()',
@ -1110,7 +1113,9 @@ def get_country_flag(code, url):
if update_image:
write_file('../svg/flags/' + code + '.svg', img)
if not os.path.exists(png_file) or update_image:
png = read_url(url.replace('/commons/', '/commons/thumb/') + '/' + str(width) + 'px-.png')
url = url.replace('/wikipedia/commons/', '/wikipedia/commons/thumb/')
url = url.replace('/wikipedia/en/', '/wikipedia/en/thumb/')
png = read_url(url + '/' + str(width) + 'px-.png')
write_file(png_file, png)
png = Image.open(png_file)
else:
@ -1122,7 +1127,7 @@ def get_country_flag(code, url):
write_image(png_file, png)
else:
png = Image.open(png_file)
for width in [256, 32]:
for width in [512, 128, 32]:
file = '../png/flags/' + str(width) + '/' + code + '.png'
if not os.path.exists(file) or update_image:
png_ = png.resize((width, int(round(width / png.size[0] * png.size[1]))), Image.ANTIALIAS)
@ -1253,8 +1258,8 @@ def get_country_icon(code):
if len(args) == 0:
args = [int(flag.size[0] / 4)]
width = int(flag.size[1] / 2)
left = int(args[0] - width / 2)
right = int(args[0] + width / 2)
left = int(args[0] - flag.size[1] / 4)
right = int(args[0] + flag.size[1] / 4)
crop_left = flag.crop((left, 0, right, flag.size[1]))
crop_right = flag.crop((flag.size[0] - right, 0, flag.size[0] - left, flag.size[1]))
icon.paste(crop_left, (0, 0))
@ -1298,7 +1303,7 @@ def get_country_icon(code):
write_image(file, icon.resize((1024, 1024), Image.ANTIALIAS))
else:
icon = Image.open(file)
for width in [256, 16]:
for width in [256, 64, 16]:
file = '../png/icons/' + str(width) + '/' + code + '.png'
if not os.path.exists(file) or True:
write_image(file, icon.resize((width, width), Image.ANTIALIAS))