1
0
Fork 0
forked from 0x2620/oxjs

improved geodata and tools

This commit is contained in:
rolux 2011-05-23 21:38:52 +02:00
commit 912f2121a4
47 changed files with 682294 additions and 3535 deletions

View file

@ -15,14 +15,17 @@ Ox.load.Geo = function(options, callback) {
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
dependencies <[s]> Array of dependencies of the country (country codes)
dependency <[s]> Array of countries the country is a dependency of (country codes)
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
east <n> Longitude of eastern boundary in deg
former <b> True if the country is a former country
googleName <s|u> Google Maps country name
imageURLs <o> Collection of dataURLs
marker <s> Map marker
imdbCode <s> IMDb country code
imdbName <s> IMDb country name
imdbCode <s|u> IMDb country code
imdbName <s|u> IMDb country name
lat <n> Latitude of the center in deg
lng <n> Longitude of the center in deg
name <s> Name
@ -35,29 +38,47 @@ Ox.load.Geo = function(options, callback) {
Ox.test.array = [
// Current independent countries with dependencies
Ox.COUNTRIES.filter(function(c) {
return c.dependencies.length && !c.former && !c.other;
return c.dependencies.length && !c.dissolved.length && !c.other;
}).length,
// Current independent countries without dependencies
// 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.former && !c.other;
!c.disputes.length && !c.disputed.length &&
!c.dissolved.length && !c.other;
}).length,
// Current dependecies
// Current dependent countries
Ox.COUNTRIES.filter(function(c) {
return c.dependency.length && !c.former && !c.other;
return c.dependency.length && !c.dissolved.length && !c.other;
}).length,
// Current disputed countries
Ox.COUNTRIES.filter(function(c) {
return c.disputed.length && !c.dissolved.length && !c.other;
}).length,
// Former independent countries with dependencies
Ox.COUNTRIES.filter(function(c) {
return c.dependencies.length && c.former && !c.other;
return c.dependencies.length && c.dissolved.length && !c.other;
}).length,
// Former independent countries without dependencies
// Former independent countries with disputes
Ox.COUNTRIES.filter(function(c) {
return c.disputes.length && c.dissolved.length && !c.other;
}).length,
// Former independent countries without dependencies or disputes
Ox.COUNTRIES.filter(function(c) {
return !c.dependencies.length && !c.dependency.length &&
c.former && !c.other;
!c.disputes.length && !c.disputed.length &&
c.dissolved.length && !c.other;
}).length,
// Former dependecies
// Former dependect countries
Ox.COUNTRIES.filter(function(c) {
return c.dependency.length && c.former && !c.other;
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
@ -68,8 +89,9 @@ Ox.load.Geo = function(options, callback) {
> Ox.sum(Ox.test.array)
311
> Ox.test.array
[15, 189, 74, 1, 16, 13, 3]
[13, 8, 176, 73, 7, 1, 0, 16, 13, 1, 3]
@*/
Ox.COUNTRIES = data;
//@ Functions ----------------------------------------------------------
@ -104,6 +126,7 @@ Ox.load.Geo = function(options, callback) {
@*/
Ox.getCountryByGeoname = function(geoname) {
geoname = geoname.replace(' - United Arab Emirates', ', United Arab Emirates')
return Ox.getCountryByName(
geoname.split(', ').pop()
.replace('Saint Eustatius', 'Bonaire, Saint Eustatius')
@ -116,12 +139,14 @@ Ox.load.Geo = function(options, callback) {
name <s> Country name
> Ox.getCountryByName('United States').code
'US'
> Ox.getCountryByName('USA').code
'US'
@*/
Ox.getCountryByName = function(name) {
var country;
Ox.forEach(Ox.COUNTRIES, function(c) {
if (c.name == name) {
if (name == c.name || name == c.googleName) {
country = c;
return false;
}