forked from 0x2620/oxjs
add geo module documentation and tests
This commit is contained in:
parent
7c3a40368f
commit
43fa75c8db
8 changed files with 203 additions and 98 deletions
|
|
@ -2,8 +2,79 @@ 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
|
||||
area <n> Area of the country in square meters
|
||||
code <s> ISO 3166 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)
|
||||
east <n> Longitude of eastern boundary in deg
|
||||
former <b> True if the country is a former country
|
||||
imageURLs <o> Collection of dataURLs
|
||||
marker <s> Map marker
|
||||
imdbCode <s> IMDb country code
|
||||
imdbName <s> IMDb country name
|
||||
lat <n> Latitude of the center in deg
|
||||
lng <n> Longitude of the center in deg
|
||||
name <s> Name
|
||||
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
|
||||
west <n> Longitude of western boundary in deg
|
||||
<script>
|
||||
Ox.test.array = [
|
||||
// Current independent countries with dependencies
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return c.dependencies.length && !c.former && !c.other;
|
||||
}).length,
|
||||
// Current independent countries without dependencies
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return !c.dependencies.length && !c.dependency.length &&
|
||||
!c.former && !c.other;
|
||||
}).length,
|
||||
// Current dependecies
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return c.dependency.length && !c.former && !c.other;
|
||||
}).length,
|
||||
// Former independent countries with dependencies
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return c.dependencies.length && c.former && !c.other;
|
||||
}).length,
|
||||
// Former independent countries without dependencies
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return !c.dependencies.length && !c.dependency.length &&
|
||||
c.former && !c.other;
|
||||
}).length,
|
||||
// Former dependecies
|
||||
Ox.COUNTRIES.filter(function(c) {
|
||||
return c.dependency.length && c.former && !c.other;
|
||||
}).length,
|
||||
// Other entities
|
||||
Ox.COUNTRIES.filter(function(c) { return c.other; }).length
|
||||
];
|
||||
</script>
|
||||
> Ox.COUNTRIES.length
|
||||
311
|
||||
> Ox.sum(Ox.test.array)
|
||||
311
|
||||
> Ox.test.array
|
||||
[15, 189, 74, 1, 16, 13, 3]
|
||||
@*/
|
||||
Ox.COUNTRIES = data;
|
||||
|
||||
//@ Functions ----------------------------------------------------------
|
||||
|
||||
/*@
|
||||
Ox.getCountryByCode <f> Returns a country object for a given country code
|
||||
(code) -> <o> Country object
|
||||
code <s> ISO 3166 country code
|
||||
> Ox.getCountryByCode('US').name
|
||||
'United States'
|
||||
@*/
|
||||
|
||||
Ox.getCountryByCode = function(code) {
|
||||
var country;
|
||||
Ox.forEach(Ox.COUNTRIES, function(c) {
|
||||
|
|
@ -15,6 +86,14 @@ Ox.load.Geo = function(options, callback) {
|
|||
return country;
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.getCountryByName <f> Returns a country object for a given country name
|
||||
(name) -> <o> Country object
|
||||
name <s> Country name
|
||||
> Ox.getCountryByName('United States').code
|
||||
'US'
|
||||
@*/
|
||||
|
||||
Ox.getCountryByName = function(name) {
|
||||
var country;
|
||||
Ox.forEach(Ox.COUNTRIES, function(c) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue