geo/map bugfixes
This commit is contained in:
parent
b6c74551fa
commit
dfd2787438
14 changed files with 892 additions and 809 deletions
|
@ -1,10 +1,9 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>ox.js listmap demo</title
|
<title>OxJS ListMap Demo</title
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
<script type="text/javascript" src="../../build/Ox.js"></script>
|
<script type="text/javascript" src="../../dev/Ox.js"></script>
|
||||||
<script type="text/javascript" src="../../source/_/ox.map.js"></script>
|
|
||||||
<script type="text/javascript" src="js/listmap.js"></script>
|
<script type="text/javascript" src="js/listmap.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -1,21 +1,43 @@
|
||||||
Ox.load('UI', {
|
Ox.load({UI: {}, Geo: {}}, function() {
|
||||||
debug: true,
|
|
||||||
theme: 'modern'
|
|
||||||
}, function() {
|
|
||||||
|
|
||||||
Ox.load('Geo', function() {
|
var markerColor = {
|
||||||
|
'Northern America': [64, 64, 255],
|
||||||
|
'Central America': [0, 0, 255],
|
||||||
|
'Caribbean': [0, 0, 128],
|
||||||
|
'Southern America': [0, 255, 0],
|
||||||
|
'Northern Europe': [255, 255, 192],
|
||||||
|
'Western Europe': [255, 255, 0],
|
||||||
|
'Eastern Europe': [255, 128, 0],
|
||||||
|
'Southern Europe': [128, 128, 0],
|
||||||
|
'Northern Africa': [128, 128, 128],
|
||||||
|
'Western Africa': [64, 64, 128],
|
||||||
|
'Middle Africa': [64, 64, 64],
|
||||||
|
'Eastern Africa': [128, 64, 64],
|
||||||
|
'Southern Africa': [64, 128, 64],
|
||||||
|
'Western Asia': [255, 128, 128],
|
||||||
|
'Central Asia': [255, 0, 0],
|
||||||
|
'Eastern Asia': [128, 0, 0],
|
||||||
|
'Southern Asia': [255, 0, 255],
|
||||||
|
'South-Eastern Asia': [128, 0, 128],
|
||||||
|
'Australia and New Zealand': [0, 128, 128],
|
||||||
|
'Micronesia': [192, 255, 255],
|
||||||
|
'Melanesia': [0, 255, 255],
|
||||||
|
'Polynesia': [128, 128, 255],
|
||||||
|
'Antarctica': [192, 192, 192]
|
||||||
|
},
|
||||||
|
|
||||||
var listmap = new Ox.ListMap({
|
$listmap = new Ox.ListMap({
|
||||||
height: window.innerHeight,
|
height: window.innerHeight,
|
||||||
places: Ox.map(Ox.COUNTRIES, function(place) {
|
places: Ox.COUNTRIES.map(function(place) {
|
||||||
return {
|
return {
|
||||||
alternativeNames: place.googleName ? [place.googleName] : [],
|
alternativeNames: Ox.compact([place.google, place.imdb, place.wikipedia]),
|
||||||
area: place.area,
|
area: place.area,
|
||||||
countryCode: place.code,
|
countryCode: place.code,
|
||||||
editable: true,
|
editable: true,
|
||||||
flag: place.code,
|
flag: place.code,
|
||||||
geoname: place.name,
|
geoname: place.name,
|
||||||
id: place.code,
|
id: place.code,
|
||||||
|
markerColor: markerColor[place.region] || [128,128,128],
|
||||||
name: place.name,
|
name: place.name,
|
||||||
type: 'country',
|
type: 'country',
|
||||||
lat: place.lat,
|
lat: place.lat,
|
||||||
|
@ -26,7 +48,6 @@ Ox.load('UI', {
|
||||||
east: place.east
|
east: place.east
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
showTypes: true,
|
|
||||||
width: window.innerWidth
|
width: window.innerWidth
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
|
@ -39,14 +60,12 @@ Ox.load('UI', {
|
||||||
|
|
||||||
$(window).resize(function() {
|
$(window).resize(function() {
|
||||||
Ox.print('RESIZE', window.innerHeight)
|
Ox.print('RESIZE', window.innerHeight)
|
||||||
listmap.options({
|
$listmap.options({
|
||||||
height: window.innerHeight,
|
height: window.innerHeight,
|
||||||
width: window.innerWidth
|
width: window.innerWidth
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
window.listmap = listmap;
|
window.$listmap = $listmap;
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
|
@ -1,36 +1,33 @@
|
||||||
Ox.load('UI', {
|
Ox.load({UI: {
|
||||||
debug: true,
|
debug: true,
|
||||||
hideScreen: true,
|
hideScreen: true,
|
||||||
showScreen: true,
|
showScreen: true,
|
||||||
theme: 'modern'
|
theme: 'modern'
|
||||||
}, function() {
|
}, Geo: {}}, function() {
|
||||||
|
|
||||||
Ox.load('Geo', function() {
|
|
||||||
|
|
||||||
Ox.getJSON('json/cities50000.json', function(cities) {
|
Ox.getJSON('json/cities50000.json', function(cities) {
|
||||||
|
|
||||||
var places = cities.map(function(city, i) {
|
var places = cities.map(function(city, i) {
|
||||||
var countryCode = city.country_code == 'XK' ? 'RS-KO' : city.country_code,
|
var area = Math.max(city.population, 1) * 100,
|
||||||
marker = city.population > 10000000 ? {size: 24, color: [255, 0, 0]} :
|
geoname = city.name + ', ' + Ox.getCountryByCode(city.country_code).name,
|
||||||
city.population > 5000000 ? {size: 22, color: [255, 32, 0]} :
|
|
||||||
city.population > 2000000 ? {size: 20, color: [255, 64, 0]} :
|
|
||||||
city.population > 1000000 ? {size: 18, color: [255, 96, 0]} :
|
|
||||||
city.population > 500000 ? {size: 16, color: [255, 128, 0]} :
|
|
||||||
city.population > 200000 ? {size: 14, color: [255, 160, 0]} :
|
|
||||||
city.population > 100000 ? {size: 12, color: [255, 192, 0]} :
|
|
||||||
city.population > 50000 ? {size: 10, color: [255, 224, 0]} :
|
|
||||||
{size: 8, color: [255, 255, 0]},
|
|
||||||
area = Math.max(city.population, 1) * 100,
|
|
||||||
latSize = Math.sqrt(area) / Ox.EARTH_CIRCUMFERENCE * 360,
|
latSize = Math.sqrt(area) / Ox.EARTH_CIRCUMFERENCE * 360,
|
||||||
lngSize = Math.sqrt(area) * Ox.getDegreesPerMeter(city.latitude);
|
lngSize = Math.sqrt(area) * Ox.getDegreesPerMeter(city.latitude),
|
||||||
|
marker = city.population > 10000000 ? {size: 24, color: [255, 0, 0]}
|
||||||
|
: city.population > 5000000 ? {size: 22, color: [255, 32, 0]}
|
||||||
|
: city.population > 2000000 ? {size: 20, color: [255, 64, 0]}
|
||||||
|
: city.population > 1000000 ? {size: 18, color: [255, 96, 0]}
|
||||||
|
: city.population > 500000 ? {size: 16, color: [255, 128, 0]}
|
||||||
|
: city.population > 200000 ? {size: 14, color: [255, 160, 0]}
|
||||||
|
: city.population > 100000 ? {size: 12, color: [255, 192, 0]}
|
||||||
|
: city.population > 50000 ? {size: 10, color: [255, 224, 0]}
|
||||||
|
: {size: 8, color: [255, 255, 0]};
|
||||||
return {
|
return {
|
||||||
alternativeNames: [],
|
alternativeNames: [],
|
||||||
area: area,
|
area: area,
|
||||||
countryCode: countryCode,
|
countryCode: city.country_code,
|
||||||
editable: true,
|
editable: true,
|
||||||
flag: countryCode,
|
geoname: geoname,
|
||||||
geoname: city.name + ', ' + Ox.getCountryByCode(countryCode).name,
|
geonameSort: getGeonameSort(geoname),
|
||||||
geonameSort: getGeonameSort(city.name + ', ' + Ox.getCountryByCode(countryCode).name),
|
|
||||||
id: Ox.encodeBase32(Ox.uid()),
|
id: Ox.encodeBase32(Ox.uid()),
|
||||||
markerColor: marker.color,
|
markerColor: marker.color,
|
||||||
markerSize: marker.size,
|
markerSize: marker.size,
|
||||||
|
@ -208,4 +205,3 @@ Ox.load('Geo', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 1.9 KiB |
|
@ -58,7 +58,7 @@ Ox.ListMap = function(options, self) {
|
||||||
format: function(value, data) {
|
format: function(value, data) {
|
||||||
return $('<img>')
|
return $('<img>')
|
||||||
.attr({
|
.attr({
|
||||||
src: Ox.getFlagByGeoname(data.name, 16)
|
src: Ox.getFlagByGeoname(data.geoname, 16)
|
||||||
})
|
})
|
||||||
.css({
|
.css({
|
||||||
width: '14px',
|
width: '14px',
|
||||||
|
|
|
@ -840,10 +840,10 @@ Ox.Map = function(options, self) {
|
||||||
|
|
||||||
self.places = [];
|
self.places = [];
|
||||||
if (!self.isAsync) {
|
if (!self.isAsync) {
|
||||||
self.options.places.forEach(function(place, i) {
|
self.options.places.forEach(function(place) {
|
||||||
self.places[i] = new Ox.MapPlace(Ox.extend({
|
self.places.push(new Ox.MapPlace(Ox.extend({
|
||||||
map: that
|
map: that
|
||||||
}, place));
|
}, place)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
google.maps.event.trigger(self.map, 'resize');
|
google.maps.event.trigger(self.map, 'resize');
|
||||||
|
|
|
@ -206,6 +206,7 @@ Ox.MapMarker = function(options) {
|
||||||
//Ox.Log('Map', 'setOptions, that.map: ', that.map)
|
//Ox.Log('Map', 'setOptions, that.map: ', that.map)
|
||||||
if (that.map.options('showTypes')) {
|
if (that.map.options('showTypes')) {
|
||||||
that.color = typeColor[that.place.type];
|
that.color = typeColor[that.place.type];
|
||||||
|
}
|
||||||
that.size = 8;
|
that.size = 8;
|
||||||
Ox.forEach(areaSize, function(size, area) {
|
Ox.forEach(areaSize, function(size, area) {
|
||||||
if (that.place.area > area) {
|
if (that.place.area > area) {
|
||||||
|
@ -214,7 +215,6 @@ Ox.MapMarker = function(options) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
that.marker.setOptions({
|
that.marker.setOptions({
|
||||||
// fixme: cursor remains pointer
|
// fixme: cursor remains pointer
|
||||||
cursor: that.place.editing ? 'move' : 'pointer',
|
cursor: that.place.editing ? 'move' : 'pointer',
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
Ox.load('UI', function() {
|
Ox.load('UI', function() {
|
||||||
|
|
||||||
Ox.getJSONC('../jsonc/countries.jsonc', function(geo) {
|
Ox.getJSONC('../jsonc/countries.jsonc', function(data) {
|
||||||
|
|
||||||
|
Ox.getJSON('../json/countries.json', function(countries) {
|
||||||
|
|
||||||
var $map = $('<img>')
|
var $map = $('<img>')
|
||||||
.attr({
|
.attr({
|
||||||
|
@ -10,7 +12,7 @@ Ox.load('UI', function() {
|
||||||
$bar = Ox.Bar({size: 24}),
|
$bar = Ox.Bar({size: 24}),
|
||||||
$status = $('<div>')
|
$status = $('<div>')
|
||||||
.css({margin: '5px 0 0 8px'})
|
.css({margin: '5px 0 0 8px'})
|
||||||
.appendTo($bar)
|
.appendTo($bar),
|
||||||
$panel = Ox.SplitPanel({
|
$panel = Ox.SplitPanel({
|
||||||
elements: [
|
elements: [
|
||||||
{
|
{
|
||||||
|
@ -27,18 +29,18 @@ Ox.load('UI', function() {
|
||||||
errors = [],
|
errors = [],
|
||||||
geocoder = new google.maps.Geocoder(),
|
geocoder = new google.maps.Geocoder(),
|
||||||
json = [],
|
json = [],
|
||||||
|
length = countries.length,
|
||||||
timeout = 2000;
|
timeout = 2000;
|
||||||
|
|
||||||
Ox.getJSON('../json/countries.json', function(countries) {
|
getNextCountry();
|
||||||
var length = countries.length;
|
|
||||||
callGetData();
|
function getNextCountry() {
|
||||||
function callGetData() {
|
getCountryData(countries.shift(), function(country) {
|
||||||
getData(countries.shift(), function(country) {
|
|
||||||
addFlag(country);
|
addFlag(country);
|
||||||
json.push(country);
|
json.push(country);
|
||||||
$status.html(json.length + '/' + length + ' ' + country.name);
|
$status.html(json.length + '/' + length + ' ' + country.name);
|
||||||
if (countries.length) {
|
if (countries.length) {
|
||||||
setTimeout(callGetData, timeout);
|
setTimeout(getNextCountry, timeout);
|
||||||
} else {
|
} else {
|
||||||
var $dialog = Ox.Dialog({
|
var $dialog = Ox.Dialog({
|
||||||
buttons: [
|
buttons: [
|
||||||
|
@ -58,22 +60,18 @@ Ox.load('UI', function() {
|
||||||
WebkitUserSelect: 'text'
|
WebkitUserSelect: 'text'
|
||||||
})
|
})
|
||||||
.html(
|
.html(
|
||||||
'<code><pre>' + JSON.stringify(json, null, 4) + '</pre></code>'
|
'<code><pre>' + JSON.stringify(
|
||||||
|
errors.length ? {errors: errors, data: json} : json,
|
||||||
|
null, 4) + '</pre></code>'
|
||||||
),
|
),
|
||||||
height: window.innerHeight * 0.9 - 48,
|
height: window.innerHeight * 0.9 - 48,
|
||||||
title: 'Ox.Geo',
|
title: 'Ox.Geo',
|
||||||
width: window.innerWidth * 0.9
|
width: window.innerWidth * 0.9
|
||||||
}).open();
|
}).open();
|
||||||
Ox.print('Errors:', errors);
|
$status.html('');
|
||||||
$status.html(
|
|
||||||
errors.length
|
|
||||||
? 'Done, see console for errors.'
|
|
||||||
: 'Done, no errors.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
function addFlag(country) {
|
function addFlag(country) {
|
||||||
var $div,
|
var $div,
|
||||||
|
@ -104,8 +102,7 @@ Ox.load('UI', function() {
|
||||||
bottom: (height - height * southWest.y) + 'px',
|
bottom: (height - height * southWest.y) + 'px',
|
||||||
})
|
})
|
||||||
.hide()
|
.hide()
|
||||||
.appendTo(Ox.UI.$body),
|
.appendTo(Ox.UI.$body)
|
||||||
|
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$div = [
|
$div = [
|
||||||
|
@ -124,7 +121,7 @@ Ox.load('UI', function() {
|
||||||
$('<img>')
|
$('<img>')
|
||||||
.attr({
|
.attr({
|
||||||
src: '../png/icons/16/' + country.code + '.png',
|
src: '../png/icons/16/' + country.code + '.png',
|
||||||
title: country.name + ' ((' + country.south + ", " + country.west + "), (" + country.north + ", " + country.east + "))"
|
title: country.name
|
||||||
})
|
})
|
||||||
.addClass('flag')
|
.addClass('flag')
|
||||||
.css({
|
.css({
|
||||||
|
@ -147,12 +144,12 @@ Ox.load('UI', function() {
|
||||||
.appendTo(Ox.UI.$body);
|
.appendTo(Ox.UI.$body);
|
||||||
}
|
}
|
||||||
|
|
||||||
function geocode(address, country, callback) {
|
function geocode(geoname, callback) {
|
||||||
var bounds;
|
var bounds, location = data.location[geoname];
|
||||||
if (!Ox.isUndefined(country.north)) {
|
if (location) {
|
||||||
bounds = new google.maps.LatLngBounds(
|
bounds = new google.maps.LatLngBounds(
|
||||||
new google.maps.LatLng(country.south, country.west),
|
new google.maps.LatLng(location.south, location.west),
|
||||||
new google.maps.LatLng(country.north, country.east)
|
new google.maps.LatLng(location.north, location.east)
|
||||||
);
|
);
|
||||||
callback({
|
callback({
|
||||||
bounds: bounds,
|
bounds: bounds,
|
||||||
|
@ -161,7 +158,7 @@ Ox.load('UI', function() {
|
||||||
} else {
|
} else {
|
||||||
geocoder.geocode({
|
geocoder.geocode({
|
||||||
language: 'en',
|
language: 'en',
|
||||||
address: address
|
address: geoname
|
||||||
}, function(results, status) {
|
}, function(results, status) {
|
||||||
if (results && results.length) {
|
if (results && results.length) {
|
||||||
var result = results[0];
|
var result = results[0];
|
||||||
|
@ -170,41 +167,36 @@ Ox.load('UI', function() {
|
||||||
location: result.geometry.location
|
location: result.geometry.location
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
errors.push([address, status])
|
errors.push({geoname: geoname, status: status});
|
||||||
|
Ox.print('remove this print statement', errors)
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getData(country, callback) {
|
function getCountryData(country, callback) {
|
||||||
if (country.lat) {
|
|
||||||
callback(country);
|
var geonames = Ox.clone(data.geocode[country.name]) || [country.name],
|
||||||
return;
|
length = geonames.length,
|
||||||
}
|
|
||||||
var addresses = geo.geocode[country.name] || [country.name],
|
|
||||||
length = addresses.length,
|
|
||||||
union;
|
union;
|
||||||
getImageURLs(country, function(imageURLs) {
|
getNextGeoname();
|
||||||
// this might be too much data
|
|
||||||
/*
|
function getNextGeoname() {
|
||||||
Ox.extend(country, {
|
geocode(geonames.shift(), function(geodata) {
|
||||||
imageURLs: imageURLs
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
callGeocode();
|
|
||||||
});
|
|
||||||
function callGeocode() {
|
|
||||||
geocode(addresses.shift(), country, function(data) {
|
|
||||||
var center, lat, lng,
|
var center, lat, lng,
|
||||||
northEast, southWest,
|
northEast, southWest,
|
||||||
east, north, south, west;
|
east, north, south, west;
|
||||||
if (data) {
|
if (geodata) {
|
||||||
union = !union ? data.bounds : union.union(data.bounds);
|
union = !union ? geodata.bounds : union.union(geodata.bounds);
|
||||||
if (addresses.length == 0) {
|
}
|
||||||
|
if (geonames.length) {
|
||||||
|
setTimeout(getNextGeoname, timeout);
|
||||||
|
} else {
|
||||||
|
if (union) {
|
||||||
if (length == 1) {
|
if (length == 1) {
|
||||||
lat = data.location.lat();
|
lat = geodata.location.lat();
|
||||||
lng = data.location.lng();
|
lng = geodata.location.lng();
|
||||||
} else {
|
} else {
|
||||||
center = union.getCenter();
|
center = union.getCenter();
|
||||||
lat = center.lat();
|
lat = center.lat();
|
||||||
|
@ -216,7 +208,7 @@ Ox.load('UI', function() {
|
||||||
north = northEast.lat();
|
north = northEast.lat();
|
||||||
south = southWest.lat();
|
south = southWest.lat();
|
||||||
west = southWest.lng();
|
west = southWest.lng();
|
||||||
callback($.extend(country, {
|
country = Ox.extend(country, {
|
||||||
area: Ox.getArea(
|
area: Ox.getArea(
|
||||||
{lat: south, lng: west},
|
{lat: south, lng: west},
|
||||||
{lat: north, lng: east}
|
{lat: north, lng: east}
|
||||||
|
@ -227,32 +219,21 @@ Ox.load('UI', function() {
|
||||||
north: toFixed(north),
|
north: toFixed(north),
|
||||||
south: toFixed(south),
|
south: toFixed(south),
|
||||||
west: toFixed(west)
|
west: toFixed(west)
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
callback(country);
|
callback(country);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (addresses.length) {
|
|
||||||
setTimeout(callGeocode, timeout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageURLs(country, callback) {
|
|
||||||
var image = new Image();
|
|
||||||
image.onload = function() {
|
|
||||||
callback({
|
|
||||||
icon16: Ox.canvas(image).canvas.toDataURL()
|
|
||||||
});
|
|
||||||
};
|
|
||||||
image.src = '../png/icons/16/' + country.code + '.png';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toFixed(num) {
|
function toFixed(num) {
|
||||||
return parseFloat(num.toFixed(8));
|
return parseFloat(num.toFixed(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
|
@ -380,27 +380,26 @@
|
||||||
],
|
],
|
||||||
"geocode": {
|
"geocode": {
|
||||||
// construction of countries unknown to the google maps geocoder
|
// construction of countries unknown to the google maps geocoder
|
||||||
|
"Abkhazia": ["Abkhazia, Georgia"],
|
||||||
"Akrotiri and Dhekelia": ["Akrotiri, Cyprus", "Dhekelia, Cyprus"],
|
"Akrotiri and Dhekelia": ["Akrotiri, Cyprus", "Dhekelia, Cyprus"],
|
||||||
"Bonaire, Saint Eustatius and Saba": ["Bonaire", "Saba, Netherlands Antilles", "Saint Eustatius"],
|
"Bonaire, Sint Eustatius and Saba": ["Bonaire", "Saba", "Sint Eustatius"],
|
||||||
"Byelorussian Soviet Socialist Republic": ["Belarus"],
|
"Byelorussian Soviet Socialist Republic": ["Belarus"],
|
||||||
|
"Canary Islands": ["Ferro, Canary Islands", "Isla Alegranza, Canary Islands"],
|
||||||
"Canton and Enderbury Islands": ["Canton Island", "Enderbury Island"],
|
"Canton and Enderbury Islands": ["Canton Island", "Enderbury Island"],
|
||||||
"Ceuta and Melilla": ["Ceuta", "Melilla"],
|
"Ceuta and Melilla": ["Ceuta", "Melilla"],
|
||||||
"Curaçao": ["Banda Abou, Curaçao"],
|
|
||||||
"Czechoslovakia": ["Czech Republic", "Slovakia"],
|
"Czechoslovakia": ["Czech Republic", "Slovakia"],
|
||||||
"East Germany": [
|
"East Germany": ["Mecklenburg Vorpommern", "Saxony", "Thuringia"],
|
||||||
"Mecklenburg Vorpommern", "Saxony", "Thuringia"
|
|
||||||
],
|
|
||||||
"Dahomey": ["Benin"],
|
"Dahomey": ["Benin"],
|
||||||
"European Union": ["Europe"],
|
"European Union": ["Cyprus", "Finland", "Greece", "Portugal"],
|
||||||
"French Afar and Issas": ["Djibouti"],
|
"French Afar and Issas": ["Djibouti"],
|
||||||
// see http://en.wikipedia.org/wiki/French_Southern_and_Antarctic_Lands
|
// see http://en.wikipedia.org/wiki/French_Southern_and_Antarctic_Lands
|
||||||
// and http://en.wikipedia.org/wiki/Scattered_Islands_in_the_Indian_Ocean
|
// and http://en.wikipedia.org/wiki/Scattered_Islands_in_the_Indian_Ocean
|
||||||
"French Southern and Antarctic Territories": ["Adélie Land", "Bassas da India", "Glorioso Islands", "Île Kerguelen"],
|
"French Southern and Antarctic Territories": ["Adélie Land", "Bassas da India", "Glorioso Islands"],
|
||||||
"French Southern Territories": ["Bassas da India", "Glorioso Islands", "Île Kerguelen"],
|
"French Southern Territories": ["Amsterdam Island", "Bassas da India", "Glorioso Islands", "Kerguelen Island"],
|
||||||
"Georgia": ["Georgia, Asia"],
|
"Georgia": ["Georgia, Asia"],
|
||||||
// see http://en.wikipedia.org/wiki/Gilbert_Islands
|
// see http://en.wikipedia.org/wiki/Gilbert_Islands
|
||||||
"Gilbert and Ellice Islands": ["Arorae, Kiribati", "Butaritari, Kiribati", "Makin, Kiribati", "Tuvalu"],
|
"Gilbert and Ellice Islands": ["Arorae, Kiribati", "Butaritari, Kiribati", "Makin, Kiribati", "Tuvalu"],
|
||||||
"Jamaica": ["Clarendon Parish, Jamaica", "St. James Parish, Jamaica", "St. Thomas Parish, Jamaica", "Westmoreland Parish, Jamaica"], // in case results are us-biased
|
// "Jamaica": ["Clarendon Parish, Jamaica", "St. James Parish, Jamaica", "St. Thomas Parish, Jamaica", "Westmoreland Parish, Jamaica"], // in case results are us-biased
|
||||||
"Jammu and Kashmir": ["Jammu and Kashmir, India"],
|
"Jammu and Kashmir": ["Jammu and Kashmir, India"],
|
||||||
"Johnston Island": ["Johnston Atoll"],
|
"Johnston Island": ["Johnston Atoll"],
|
||||||
"Korea": ["North Korea", "South Korea"],
|
"Korea": ["North Korea", "South Korea"],
|
||||||
|
@ -409,7 +408,7 @@
|
||||||
"Neutral Zone": ["39944, Saudi Arabia", "76611, Saudi Arabia"],
|
"Neutral Zone": ["39944, Saudi Arabia", "76611, Saudi Arabia"],
|
||||||
"New Hebrides": ["Vanuatu"],
|
"New Hebrides": ["Vanuatu"],
|
||||||
"North Vietnam": ["Ha Giang Province, Vietnam", "Lai Chau Province, Vietnam", "Thua Thien-Hue Province, Vietnam"],
|
"North Vietnam": ["Ha Giang Province, Vietnam", "Lai Chau Province, Vietnam", "Thua Thien-Hue Province, Vietnam"],
|
||||||
"North Yemen": ["Al Jawf, Yemen", "Hajjah, Yemen", "Ta'izz, Yemen"],
|
"North Yemen": ["Al Jawf, Yemen", "Hajjah, Yemen", "Ta'izz Province, Yemen"],
|
||||||
"Northern Cyprus": ["Karpass, Cyprus", "Kokkina, Cyprus", "Lympia, Cyprus"],
|
"Northern Cyprus": ["Karpass, Cyprus", "Kokkina, Cyprus", "Lympia, Cyprus"],
|
||||||
"Pacific Islands": ["Marshall Islands", "Micronesia", "Northern Mariana Islands", "Palau"],
|
"Pacific Islands": ["Marshall Islands", "Micronesia", "Northern Mariana Islands", "Palau"],
|
||||||
// "Palestine": ["71, Israel", "El-arish Rafah, Egypt"],
|
// "Palestine": ["71, Israel", "El-arish Rafah, Egypt"],
|
||||||
|
@ -419,21 +418,21 @@
|
||||||
"San Marino": ["San Marino, Europe"], // in case results are us-biased
|
"San Marino": ["San Marino, Europe"], // in case results are us-biased
|
||||||
"Serbia and Montenegro": ["Montenegro", "Serbia"],
|
"Serbia and Montenegro": ["Montenegro", "Serbia"],
|
||||||
"Siam": ["Thailand"],
|
"Siam": ["Thailand"],
|
||||||
"Sint Maarten": ["Sint Maarten, Netherlands Antilles"],
|
"Sint Maarten": ["Great Bay, Sint Maarten", "Oyster Pond, Sint Maarten", "Simpson Bay Lagoon, Sint Maarten"],
|
||||||
"South Ossetia": ["Shida Kartli"],
|
"South Ossetia": ["Shida Kartli"],
|
||||||
// see http://en.wikipedia.org/wiki/Sudan#States_and_regions
|
// see http://en.wikipedia.org/wiki/Sudan#States_and_regions
|
||||||
// "South Sudan": [
|
// "South Sudan": [
|
||||||
// "Central Equatoria, Sudan", "Eastern Equatoria, Sudan", "Jonglei, Sudan", "Lakes, Sudan", "Northern Bahr el Ghazal, Sudan",
|
// "Central Equatoria, Sudan", "Eastern Equatoria, Sudan", "Jonglei, Sudan", "Lakes, Sudan", "Northern Bahr el Ghazal, Sudan",
|
||||||
// "Upper Nile, Sudan", "Unity, Sudan", "Warrap, Sudan", "Western Bahr el Ghazal, Sudan", "Western Equatoria, Sudan"
|
// "Upper Nile, Sudan", "Unity, Sudan", "Warrap, Sudan", "Western Bahr el Ghazal, Sudan", "Western Equatoria, Sudan"
|
||||||
// ],
|
// ],
|
||||||
"South Vietnam": ["Ca Mau Province, Vietnam", "Da Nang Province, Vietnam", "Kiên Giang Province, Vietnam"],
|
"South Vietnam": ["Ca Mau Province, Vietnam", "Da Nang Province, Vietnam", "Khanh Hoa Province, Vietnam", "Kien Giang Province, Vietnam"],
|
||||||
"South Yemen": ["Al-Mahrah, Yemen", "Lahij, Yemen"],
|
"South Yemen": ["Al-Mahrah, Yemen", "Lahij, Yemen"],
|
||||||
"Soviet Union": [
|
"Soviet Union": [
|
||||||
"Armenia", "Azerbaijan", "Belarus", "Estonia", "Georgia, Europe",
|
"Armenia", "Azerbaijan", "Belarus", "Estonia", "Georgia, Europe",
|
||||||
"Latvia", "Lithuania", "Kazakhstan", "Kyrgyzstan", "Moldova",
|
"Latvia", "Lithuania", "Kazakhstan", "Kyrgyzstan", "Moldova",
|
||||||
"Russia", "Tajikistan", "Turkmenistan", "Ukraine", "Uzbekistan"
|
"Russia", "Tajikistan", "Turkmenistan", "Ukraine", "Uzbekistan"
|
||||||
],
|
],
|
||||||
"United Kingdom": ["England", "Northern Ireland", "Scotland", "Wales, United Kingdom"],
|
"United Kingdom": ["England", "Northern Ireland", "Scotland"],
|
||||||
"United States Minor Outlying Islands": [
|
"United States Minor Outlying Islands": [
|
||||||
"Baker Island, UM", "Howland Island", "Jarvis Island", "Johnston Atoll", "Kingman Reef",
|
"Baker Island, UM", "Howland Island", "Jarvis Island", "Johnston Atoll", "Kingman Reef",
|
||||||
"Midway Islands", "Palmyra Atoll", "Wake Island"
|
"Midway Islands", "Palmyra Atoll", "Wake Island"
|
||||||
|
@ -442,9 +441,7 @@
|
||||||
"United States Miscellaneous Pacific Islands": [
|
"United States Miscellaneous Pacific Islands": [
|
||||||
"Baker Island, UM", "Howland Island", "Jarvis Island", "Kingman Reef", "Palmyra Atoll"
|
"Baker Island, UM", "Howland Island", "Jarvis Island", "Kingman Reef", "Palmyra Atoll"
|
||||||
],
|
],
|
||||||
"UK": ["England", "Northern Ireland", "Scotland", "Wales, United Kingdom"],
|
|
||||||
"Upper Volta": ["Burkina Faso"],
|
"Upper Volta": ["Burkina Faso"],
|
||||||
"Wake Island": ["Wake Atoll"],
|
|
||||||
"Wales": ["Wales, United Kingdom"],
|
"Wales": ["Wales, United Kingdom"],
|
||||||
"West Germany": ["Schleswig Holstein", "Northrhine Westphalia", "Bavaria, Germany"],
|
"West Germany": ["Schleswig Holstein", "Northrhine Westphalia", "Bavaria, Germany"],
|
||||||
"Yugoslavia": [
|
"Yugoslavia": [
|
||||||
|
|
|
@ -53,17 +53,14 @@ def get_countries():
|
||||||
html = read_wikipedia_url('ISO 3166-3')
|
html = read_wikipedia_url('ISO 3166-3')
|
||||||
matches = re.compile('<td id="([A-Z]{4})">.*?<a href="/wiki/(.*?)".*?>', re.DOTALL).findall(html)
|
matches = re.compile('<td id="([A-Z]{4})">.*?<a href="/wiki/(.*?)".*?>', re.DOTALL).findall(html)
|
||||||
countries += map(lambda x: parse(x), matches)
|
countries += map(lambda x: parse(x), matches)
|
||||||
print sorted(map(lambda x: x['name'], countries))
|
|
||||||
# ISO 3166-1 alpha-2
|
# ISO 3166-1 alpha-2
|
||||||
html = fix(read_wikipedia_url('ISO 3166-1 alpha-2'))
|
html = fix(read_wikipedia_url('ISO 3166-1 alpha-2'))
|
||||||
matches = re.compile('<tt>([A-Z]{2})</tt></td>\n<td><a href="/wiki/(.*?)"', re.DOTALL).findall(html)
|
matches = re.compile('<tt>([A-Z]{2})</tt></td>\n<td><a href="/wiki/(.*?)"', re.DOTALL).findall(html)
|
||||||
countries += filter(lambda x: not exists(x), map(lambda x: parse(x), matches))
|
countries += filter(lambda x: not exists(x), map(lambda x: parse(x), matches))
|
||||||
print sorted(map(lambda x: x['name'], countries))
|
|
||||||
# List of sovereign states
|
# List of sovereign states
|
||||||
html = read_wikipedia_url('List of sovereign states')
|
html = read_wikipedia_url('List of sovereign states')
|
||||||
matches = re.compile('> </span><a href="/wiki/(.*?)"', re.DOTALL).findall(html)
|
matches = re.compile('> </span><a href="/wiki/(.*?)"', re.DOTALL).findall(html)
|
||||||
countries += filter(lambda x: not exists(x), map(lambda x: parse(x), matches))
|
countries += filter(lambda x: not exists(x), map(lambda x: parse(x), matches))
|
||||||
print sorted(map(lambda x: x['name'], countries))
|
|
||||||
'''
|
'''
|
||||||
for year in range(1970, 2020, 10):
|
for year in range(1970, 2020, 10):
|
||||||
html = read_wikipedia_url('List of sovereign states in the %ds' % year)
|
html = read_wikipedia_url('List of sovereign states in the %ds' % year)
|
||||||
|
@ -119,7 +116,7 @@ def get_country_data(country):
|
||||||
for c, d in DATA['dependencies'].iteritems():
|
for c, d in DATA['dependencies'].iteritems():
|
||||||
c = c.split(', ')
|
c = c.split(', ')
|
||||||
if name in c:
|
if name in c:
|
||||||
country['dependecies'] = d if not 'dependencies' in country else country['dependencies'] + d
|
country['dependencies'] = d if not 'dependencies' in country else country['dependencies'] + d
|
||||||
elif name in d:
|
elif name in d:
|
||||||
country['dependency'] = c if not 'dependency' in country else country['dependency'] + c
|
country['dependency'] = c if not 'dependency' in country else country['dependency'] + c
|
||||||
# disputes
|
# disputes
|
||||||
|
@ -152,10 +149,6 @@ def get_country_data(country):
|
||||||
country['languages'] = [language]
|
country['languages'] = [language]
|
||||||
else:
|
else:
|
||||||
country['languages'].append(language)
|
country['languages'].append(language)
|
||||||
# location
|
|
||||||
if name in DATA['location']:
|
|
||||||
for key, value in DATA['location'][name].iteritems():
|
|
||||||
country[key] = value
|
|
||||||
return country
|
return country
|
||||||
|
|
||||||
def get_flag(id):
|
def get_flag(id):
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import Image
|
import Image
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
svg_path = '../svg/icons/'
|
svg_path = '../svg/icons/'
|
||||||
png_path = '../png/icons/4096/'
|
png_path = '../png/icons/4096/'
|
||||||
|
@ -21,7 +22,8 @@ for file in os.listdir(svg_path):
|
||||||
image = image.resize((size, size), Image.ANTIALIAS)
|
image = image.resize((size, size), Image.ANTIALIAS)
|
||||||
image.save(png_file.replace('/4096/', '/%d/' % size))
|
image.save(png_file.replace('/4096/', '/%d/' % size))
|
||||||
|
|
||||||
for file in os.listdir('../png/flags/'):
|
if sys.argv[-1] == '-png':
|
||||||
|
for file in os.listdir('../png/flags/'):
|
||||||
if file[-4:] == '.png':
|
if file[-4:] == '.png':
|
||||||
country = file[:-4]
|
country = file[:-4]
|
||||||
png_file = png_path + country + '.png'
|
png_file = png_path + country + '.png'
|
||||||
|
|
Loading…
Reference in a new issue