Ox.load.Geo = function(options, callback) { Ox.getJSON(Ox.PATH + 'Ox.Geo/json/Ox.Geo.json', function(data) { //@ Constants ---------------------------------------------------------- /*@ Ox.COUNTRIES <[o]> Array of countries A list of independent (or de-facto independent) countries and dependencies (see Wikipedia), other entities with ISO 3166-1 alpha-2 country codes, and former countries according to ISO 3166-3 and IMDb. area Area of the country in square meters code ISO 3166-1 alpha-2 country code 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 Longitude of eastern boundary in deg googleName Google Maps country name imageURLs Collection of dataURLs marker Map marker imdbCode IMDb country code imdbName IMDb country name lat Latitude of the center in deg lng Longitude of the center in deg name Name north Latitude of northern boundary in deg other True if the country is an "other entity" (EU, FX, UK) south Latitude of southern boundary in deg wikipediaURL URL of the wikipedia article for the country west Longitude of western boundary in deg > Ox.COUNTRIES.length 311 > Ox.sum(Ox.test.array) 311 > Ox.test.array [13, 8, 176, 73, 7, 1, 0, 16, 13, 1, 3] @*/ Ox.COUNTRIES = data; //@ Functions ---------------------------------------------------------- /*@ Ox.getCountryByCode Returns a country object for a given country code (code) -> Country object code ISO 3166 country code > Ox.getCountryByCode('US').name 'United States' @*/ Ox.getCountryByCode = function(code) { var country; Ox.forEach(Ox.COUNTRIES, function(c) { if (c.code == code) { country = c; return false; } }); return country; }; /*@ Ox.getCountryByGeoname Returns a country object for a given geoname (name) -> Country object name Geoname > Ox.getCountryByGeoname('Los Angeles, California, United States').code 'US' > Ox.getCountryByGeoname('The Bottom, Saba, Bonaire, Saint Eustatius and Saba').code 'BQ' @*/ Ox.getCountryByGeoname = function(geoname) { // fixme: UAE correction doesn't belong here, fix in map geoname = geoname.replace(' - United Arab Emirates', ', United Arab Emirates') return Ox.getCountryByName( geoname.split(', ').pop() .replace('Saint Eustatius', 'Bonaire, Saint Eustatius') ); } /*@ Ox.getCountryByName Returns a country object for a given country name (name) -> Country object name 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 (name == c.name || name == c.googleName) { country = c; return false; } }); return country; }; callback(true); }); }