algeria is a simple Node.js package that provides administrative, location,.. information about algeria.
var dz = require('algeria');
(wilaya is the algerian name for county)
dz.wilaya(id, field)
where id
is the wilaya number, between 1 and 48.
field
can be id
, name
, longName
, position
, latitude
, longitude
.
If field
is not given, an abject with all available information is returned.
Exemple:
var dz=require('algeria');
dz.wilaya(16,'name') // "Alger"
dz.wilaya(15,'longName') // "Wilaya de Tizi Ouzou"
dz.wilaya(6, 'id') // "06"
dz.wilaya(11, 'position') // { latitude: 24.0982893, longitude: 3.743509 }
A loop through wilayas.
Exemple:
var dz=require('algeria');
dz.wilaya.each( function( wilaya ){
console.info(wilaya.id," ",wilaya.name);
});
Get a 'commune' element by its 'ONS code' (primary key). (commune is the algerian name for township)
var dz=require('algeria');
dz.commune( "1604" ); // { name: 'Belouizdad', wilaya: 16, ONSCode: '1604'}
The previous command returns information about the wilaya (county) :
var dz=require('algeria');
dz.commune( "1604" ).wilaya;
A loop through all communes of algeria :
var dz=require('algeria');
dz.commune.each( function(commune){console.info(commune);} );
Loop through all communes of a wilaya :
var dz=require('algeria');
dz.commune.each( 16, function(commune){console.info(commune);} );