1
0
Fork 0
forked from 0x2620/oxjs

improvements to map

This commit is contained in:
rlx 2011-02-25 10:23:33 +00:00
commit 2e645418dd
9 changed files with 980 additions and 285 deletions

View file

@ -215,7 +215,7 @@ Ox.COUNTRIES = [
{code: 'MD-TR', continent: 'Europe', name: 'Transnistria', region: 'Eastern Europe', type: 'unrecognized'},
{code: 'AQ', continent: 'Antarctica', country: ['Argentina', 'Australia', 'Chile', 'France', 'New Zealand', 'Norway', 'United Kingdom'], name: 'Antarctica'},
{code: 'CX', continent: 'Asia', country: 'Australia', name: 'Christmas Island', region: 'South-Eastern Asia', type: 'dependent'},
{code: 'CC', continent: 'Asia', country: 'Australia', name: 'Cocos Island', region: 'South-Eastern Asia', type: 'dependent'},
{code: 'CC', continent: 'Asia', country: 'Australia', name: 'Cocos Islands', region: 'South-Eastern Asia', type: 'dependent'},
{code: 'HM', continent: 'Antarctica', country: 'Australia', name: 'Heard Island and McDonald Islands', type: 'dependent'},
{code: 'NF', continent: 'Oceania', country: 'Australia', name: 'Norfolk Island', region: 'Australia and New Zealand', type: 'dependent'},
{code: 'HK', continent: 'Asia', country: 'China', name: 'Hong Kong', region: 'Eastern Asia', type: 'dependent'},
@ -311,4 +311,76 @@ Ox.COUNTRIES = [
{code: 'WKUM', continent: 'Oceania', country: 'United States', name: 'Wake Island', region: 'Micronesia', type: 'former'},
{code: 'EU', continent: 'Europe', name: 'European Union', type: 'other'},
{code: 'UK', continent: 'Europe', name: 'United Kingdom', region: 'Northern Europe', type: 'other'}
];
];
Ox.COUNTRY_CODES = Ox.map(Ox.COUNTRIES, function(country) {
return country.code.length == 2 && ['EU', 'UK'].indexOf(country.code) == -1 ? country.code : null;
}).sort();
Ox.getCountryCode = (function() {
var aliases = {
'The Bahamas': 'Bahamas',
'The Netherlands': 'Netherlands',
'UK': 'United Kingdom',
'US Virgin Islands': 'United States Virgin Islands',
'USA': 'United States'
};
return function(geoname) {
var countryCode = '',
countryName = geoname.split(', ').pop();
Ox.forEach(aliases, function(val, key) {
if (countryName == key) {
countryName = val;
return false;
}
});
Ox.forEach(Ox.COUNTRIES, function(country) {
if (country.name == countryName) {
countryCode = country.code;
return false;
}
});
return countryCode;
};
}());
Ox.Place = function(options) {
/*
in: geoname, name, south, west, north, east
out: country, countryCode, geonameReverse, lat, lng
*/
var self = {},
that = Ox.extend(this, options);
['south', 'west', 'north', 'east'].forEach(function(v) {
self[v + 'Rad'] = Ox.rad(that[v]);
});
self.geonames = that.geoname.split(', ').reverse();
that.geonameReverse = self.geonames.join(', ');
Ox.forEach(Ox.COUNTRIES, function(country) {
if (country.name == self.geonames[0]) {
that.country = country.name;
that.countryCode = country.code;
return false;
}
});
function getArea() {
}
function getCenter() {
}
function getRad(points) {
}
return that;
};