algeria

0.0.3 • Public • Published

algeria

algeria is a simple Node.js package that provides administrative, location,.. information about algeria.

Using package

var dz = require('algeria');

Available functions

wilaya

(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 }

wilaya.each

A loop through wilayas.

Exemple:

    var dz=require('algeria');
    dz.wilaya.each( function( wilaya ){
        console.info(wilaya.id,"   ",wilaya.name);
    });

commune

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'}

commune(code).wilaya

The previous command returns information about the wilaya (county) :

    var dz=require('algeria');
    dz.commune( "1604" ).wilaya;

commune.each( callback )

A loop through all communes of algeria :

    var dz=require('algeria');
    dz.commune.each( function(commune){console.info(commune);} );

commune.each( wilaya, callback )

Loop through all communes of a wilaya :

    var dz=require('algeria');
    dz.commune.each( 16, function(commune){console.info(commune);} );

Readme

Keywords

Package Sidebar

Install

npm i algeria

Weekly Downloads

3

Version

0.0.3

License

GNU GPL v2

Last publish

Collaborators

  • rouabhi