rwanda-geo-structure
v1.3.2
Published
Rwanda Geo Structure is a JavaScript app that simplifies obtaining local Rwandan administrative divisions. It allows developers to enable users to select divisions like province, district, sector, cell, and village, streamlining the collection of location
Downloads
174
Readme
Rwanda Geo Structure
Rwanda Geo Structure is a comprehensive JavaScript package that provides easy access to Rwanda's administrative divisions. It allows developers to retrieve and work with data about provinces, districts, sectors, cells, and villages in Rwanda, streamlining the process of collecting and managing location-based data for applications focused on Rwanda.
Table of Contents
Installation
To install the Rwanda Geo Structure package, run the following command in your project directory:
npm install rwanda-geo-structure
or if you're using Yarn:
yarn add rwanda-geo-structure
API Reference
getCountry()
Returns the country name.
- Returns:
string
- Always returns "Rwanda"
getProvinces()
Retrieves all provinces in Rwanda.
- Returns:
string[]
- An array of province names
getDistricts()
Retrieves all districts in Rwanda.
- Returns:
string[]
- An array of district names
getDistrictsByProvince(province: string)
Retrieves all districts within a specified province.
Parameters:
province: string
- The name of the provinceReturns:
string[]
- An array of district names within the specified province
getSectors()
Retrieves all sectors in Rwanda.
- Returns:
string[]
- An array of sector names
getSectorsByDistrict(province: string, district: string)
Retrieves all sectors within a specified district.
Parameters:
province: string
- The name of the provincedistrict: string
- The name of the districtReturns:
string[]
- An array of sector names within the specified district
getCells()
Retrieves all cells in Rwanda.
- Returns:
string[]
- An array of cell names
getCellsBySector(province: string, district: string, sector: string)
Retrieves all cells within a specified sector.
Parameters:
province: string
- The name of the provincedistrict: string
- The name of the districtsector: string
- The name of the sectorReturns:
string[]
- An array of cell names within the specified sector
getVillages()
Retrieves all villages in Rwanda.
- Returns:
string[]
- An array of village names
getVillagesByCell(province: string, district: string, sector: string, cell: string)
Retrieves all villages within a specified cell.
Parameters:
province: string
- The name of the provincedistrict: string
- The name of the districtsector: string
- The name of the sectorcell: string
- The name of the cellReturns:
string[]
- An array of village names within the specified cell
getRandomLocation()
Generates a random location in Rwanda, including province, district, sector, cell, and village.
- Returns:
Object
- An object containing randomly selected location data
{
province: string;
district: string;
sector: string;
cell: string;
village: string;
}
countLocations()
Counts the number of administrative divisions at each level in Rwanda.
- Returns:
Object
- An object containing the count of each administrative division
{
provinces: number;
districts: number;
sectors: number;
cells: number;
villages: number;
}
Usage Examples
Here are some examples of how to use the Rwanda Geo Structure package in your projects:
Getting all provinces
import { getProvinces } from "rwanda-geo-structure";
const provinces = getProvinces();
console.log(provinces);
// Output: ['Eastern Province', 'Kigali City', 'Northern Province', 'Southern Province', 'Western Province']
Getting districts in a specific province
import { getDistrictsByProvince } from "rwanda-geo-structure";
const districts = getDistrictsByProvince("Kigali City");
console.log(districts);
// Output: ['Gasabo', 'Kicukiro', 'Nyarugenge']
Getting sectors in a specific district
import { getSectorsByDistrict } from "rwanda-geo-structure";
const sectors = getSectorsByDistrict("Kigali City", "Gasabo");
console.log(sectors);
// Output: ['Bumbogo', 'Gatsata', 'Gikomero', 'Gisozi', 'Jabana', 'Jali', 'Kacyiru', 'Kimihurura', 'Kimironko', 'Kinyinya', 'Ndera', 'Nduba', 'Remera', 'Rusororo', 'Rutunga']
Getting a random location
import { getRandomLocation } from "rwanda-geo-structure";
const randomLocation = getRandomLocation();
console.log(randomLocation);
// Output:
// {
// province: 'Southern Province',
// district: 'Huye',
// sector: 'Ngoma',
// cell: 'Butare',
// village: 'Akabuye'
// }
Counting all administrative divisions
import { countLocations } from "rwanda-geo-structure";
const counts = countLocations();
console.log(counts);
// Output:
// {
// provinces: 5,
// districts: 30,
// sectors: 416,
// cells: 2148,
// villages: 14837
// }
Authors
Contributing
Contributions to the Rwanda Geo Structure package are welcome! Here are some ways you can contribute:
- Report bugs or request features by opening an issue.
- Submit pull requests to fix bugs or add new features.
- Improve documentation or add usage examples.
Please ensure that your code adheres to the existing style and that all tests pass before submitting a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
For more information or support, please open an issue on the GitHub repository.