forked from 0x2620/oxjs
update geo module
This commit is contained in:
parent
2b394ca28b
commit
e0d4dd3bec
1619 changed files with 6021 additions and 686370 deletions
|
|
@ -13,18 +13,22 @@ Ox.load.Geo = function(options, callback) {
|
|||
<a href="http://en.wikipedia.org/wiki/List_of_sovereign_states">Wikipedia</a>),
|
||||
other entities with
|
||||
<a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2</a>
|
||||
country codes, and former countries according to <a href="http://en.wikipedia.org/wiki/ISO_3166-3">ISO 3166-3</a>
|
||||
country codes, and former countries according to
|
||||
<a href="http://en.wikipedia.org/wiki/ISO_3166-3">ISO 3166-3</a>
|
||||
and <a href="http://www.imdb.com/country/">IMDb</a>.
|
||||
area <n> Area of the country in square meters
|
||||
code <s> ISO 3166-1 alpha-2 country code
|
||||
created <o> FIXME: incomplete data
|
||||
dependencies <[s]> Array of dependencies of the country
|
||||
dependency <[s]> Array of countries the country is a dependency of
|
||||
disputed <[s]> Array of countries the country is disputed by
|
||||
disputes <[s]> Array of countries the country disputes
|
||||
dissolved <[s]> Array of countries the country has been dissolved (merged, renamed or split) into
|
||||
dissolved <o> Present if the country was dissolves
|
||||
country <s|[s]> Succeeding country or countries
|
||||
date <s> Date of dissolution
|
||||
type <s> "joined", "merged", "renamed" or "split"
|
||||
east <n> Longitude of eastern boundary in deg
|
||||
googleName <s|u> Google Maps country name
|
||||
imdbCode <s|u> IMDb country code
|
||||
imdbName <s|u> IMDb country name
|
||||
languages <[s]> Array of languages that are spoken in this country more than in any other
|
||||
lat <n> Latitude of the center in deg
|
||||
|
|
@ -33,64 +37,42 @@ Ox.load.Geo = function(options, callback) {
|
|||
north <n> Latitude of northern boundary in deg
|
||||
other <b> True if the country is an "other entity" (EU, FX, UK)
|
||||
south <n> Latitude of southern boundary in deg
|
||||
wikipediaURL <s> URL of the wikipedia article for the country
|
||||
wikipediaName <s> Wikipedia country name (http://en.wikipedia.org/wiki/$wikipediaName)
|
||||
west <n> Longitude of western boundary in deg
|
||||
<script>
|
||||
Ox.test.array = [
|
||||
// Current independent countries with dependencies
|
||||
// Current independent countries
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return c.dependencies.length && !c.dissolved.length && !c.other;
|
||||
}).length,
|
||||
// Current independent countries with (fixme: not necessarily current) disputes
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return c.disputes.length && !c.dissolved.length && !c.other;
|
||||
}).length,
|
||||
// Current independent countries without dependencies or disputes
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return !c.dependencies.length && !c.dependency.length
|
||||
&& !c.disputes.length && !c.disputed.length
|
||||
&& !c.dissolved.length && !c.other;
|
||||
return !c.dissolved && !c.dependency && !c.disputed
|
||||
}).length,
|
||||
// Current dependent countries
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return c.dependency.length && !c.dissolved.length && !c.other;
|
||||
return !c.dissolved && c.dependency
|
||||
}).length,
|
||||
// Current disputed countries
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return c.disputed.length && !c.dissolved.length && !c.other;
|
||||
return !c.dissolved && c.disputed
|
||||
}).length,
|
||||
// Former independent countries with dependencies
|
||||
// Dissolved independent countries
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return c.dependencies.length && c.dissolved.length && !c.other;
|
||||
return c.dissolved && !c.dependency && !c.disputed
|
||||
}).length,
|
||||
// Former independent countries with disputes
|
||||
// Dissolved dependent countries
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return c.disputes.length && c.dissolved.length && !c.other;
|
||||
return c.dissolved && c.dependency
|
||||
}).length,
|
||||
// Former independent countries without dependencies or disputes
|
||||
// Dissolved disputed countries
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return !c.dependencies.length && !c.dependency.length
|
||||
&& !c.disputes.length && !c.disputed.length
|
||||
&& c.dissolved.length && !c.other;
|
||||
}).length,
|
||||
// Former dependect countries
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return c.dependency.length && c.dissolved.length && !c.other;
|
||||
}).length,
|
||||
// Former disputed countries
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return c.disputed.length && c.dissolved.length && !c.other;
|
||||
}).length,
|
||||
// Other entities
|
||||
Ox.COUNTRIES.filter(function(c) { return c.other; }).length
|
||||
return c.dissolved && c.disputed
|
||||
}).length
|
||||
];
|
||||
</script>
|
||||
> Ox.COUNTRIES.length
|
||||
311
|
||||
319
|
||||
> Ox.sum(Ox.test.array)
|
||||
311
|
||||
319
|
||||
> Ox.test.array
|
||||
[13, 8, 176, 73, 7, 1, 0, 16, 13, 1, 3]
|
||||
[202, 77, 6, 22, 11, 1]
|
||||
@*/
|
||||
|
||||
Ox.COUNTRIES = data;
|
||||
|
|
@ -122,7 +104,7 @@ Ox.load.Geo = function(options, callback) {
|
|||
name <s> Geoname
|
||||
> Ox.getCountryByGeoname('Los Angeles, California, United States').code
|
||||
'US'
|
||||
> Ox.getCountryByGeoname('The Bottom, Saba, Bonaire, Saint Eustatius and Saba').code
|
||||
> Ox.getCountryByGeoname('The Bottom, Saba, Bonaire, Sint Eustatius and Saba').code
|
||||
'BQ'
|
||||
@*/
|
||||
|
||||
|
|
@ -131,7 +113,7 @@ Ox.load.Geo = function(options, callback) {
|
|||
geoname = geoname.replace(' - United Arab Emirates', ', United Arab Emirates')
|
||||
return Ox.getCountryByName(
|
||||
geoname.split(', ').pop()
|
||||
.replace('Saint Eustatius', 'Bonaire, Saint Eustatius')
|
||||
.replace('Sint Eustatius', 'Bonaire, Sint Eustatius')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -164,10 +146,10 @@ Ox.load.Geo = function(options, callback) {
|
|||
geoname <s> Geoname
|
||||
@*/
|
||||
|
||||
Ox.getImageByGeoname = function(type, size, geoname) {
|
||||
Ox.getFlagByGeoname = function(geoname, size) {
|
||||
var country = Ox.getCountryByGeoname(geoname),
|
||||
code = country ? country.code : 'NTHH';
|
||||
return Ox.PATH + 'Ox.Geo/png/' + type + 's/' + size + '/' + code + '.png';
|
||||
code = country ? country.flag || country.code : 'NTHH';
|
||||
return Ox.PATH + 'Ox.Geo/png/flags/' + size + '/' + code + '.png';
|
||||
};
|
||||
|
||||
/*@
|
||||
|
|
@ -178,7 +160,7 @@ Ox.load.Geo = function(options, callback) {
|
|||
language <s> Language
|
||||
@*/
|
||||
|
||||
Ox.getImageByLanguage = function(type, size, language) {
|
||||
Ox.getFlagByLanguage = function(language, size) {
|
||||
language = language
|
||||
.replace(' languages', '')
|
||||
.replace(' Sign Language', '');
|
||||
|
|
@ -189,8 +171,8 @@ Ox.load.Geo = function(options, callback) {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
code = country ? country.code : 'NTHH';
|
||||
return Ox.PATH + 'Ox.Geo/png/' + type + 's/' + size + '/' + code + '.png';
|
||||
code = country ? country.flag || country.code : 'NTHH';
|
||||
return Ox.PATH + 'Ox.Geo/png/flags/' + size + '/' + code + '.png';
|
||||
};
|
||||
|
||||
callback(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue