GEO infromation parser from geonames service. For more information please check Info and documentation topics.
Installation
$ npm install geoinfo
Examples
- Get countries with population more 1 millionvar request =split =geoinfo = ;request;
- Get countries information from countryInfo.txt file
var fs = split = geoinfo = ; fs //start parse file from 52 line ;
-
Get Countries translations (see)
var request =split =geoinfo = ;request; -
Get cities informations
var fs = split = geoinfo = ; fs ;
- Get admin code information (admin1CodesASCII.txt and admin2Codes.txt)
var split = geoinfo = request = ; request ; request ; //code for the second administrative division, a county in the US request ;
API
geoinfo.filter(callback)
Parameters
callback
Function to test each element of the data collection. Invoked with arguments (record). Return true to keep the element, false otherwise.
Example
geoinfo;
geoinfo.range(start, length)
Parameters
start
An integer greater than or equal to zero representing the offset for the start of the Range
length
An integer greater than or equal to zero representing the count of row that should be taken. If length not specified the data will taken from start to end of collection.
Example
geoinfo; //gets 10 records from line 2 to line 12
geoinfo.city()
Parse city information from files: cities1000.txt, cities5000.txt, cities15000.text. Returns the city object.
Example of city object
geonameid: '4046704' name: 'Fort Hunt' asciiname: 'Fort Hunt' alternatenames: '' lat: '38.73289' lng: '-77.05803' featureClass: 'P' featureCode: 'PPL' countryCode: 'US' cc2: '' adminCode1: 'VA' adminCode2: '059' adminCode3: '' adminCode4: '' population: '16045' elevation: '10' dem: '16' timezone: 'America/New_York' updated: '2011-05-14'
geoinfo.country()
Parse country information from file countryInfo.txt. Returns the country object.
Example of country object
iso2: 'AD' iso3: 'AND' isoNumeric: '020' fips: 'AN' country: 'Andorra' capital: 'Andorra la Vella' area: '468' population: '84000' continent: 'EU' tld: '.ad' currencyCode: 'EUR' currencyName: 'Euro' phone: '376' postalCodeFormat: 'AD###' postalCodeRegex: '^(?:AD)*(\\d{3})$' languages: 'ca' geonameid: '3041565' neighbours: 'ES,FR'
geoinfo.admin1CodesASCII()
Parse admin code information from files: admin1CodesASCII.txt, admin2Codes.txt. Returns the admin code object.
Example of admin code object
codes: 'AD.06' name: 'Sant Julià de Loria' asciiname: 'Sant Julia de Loria' geonameid: '3039162'
geoinfo.countryI18n()
Parse country alternates names from http://ws.geonames.org/countryInfoCSV endpoint (for more details please check geonames documentation. Returns i18n object
Example of i18n object
iso: 'AI' iso3: 'AIA' isoNumeric: '660' fips: 'AV' name: '安圭拉' capital: '山谷市' area: '102.0' population: '13254' continent: 'NA' languages: 'en-AI' currency: 'XCD' geonameid: '3573511'
geoinfo.i18n()
Parse alternates names from alternateNames.zip file.
Example returns object
alternateNameId: '1556376' geonameid: '49518' isolanguage: 'es' alternateName: 'Ruanda' isPreferredName: '1' isShortName: '1' isColloquial: ''