npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

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

npm version License: MIT npm downloads GitHub issues GitHub stars Build Status Coverage Status Maintainability code style: prettier PRs Welcome

portfolio linkedin

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 province

  • Returns: 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 province

  • district: string - The name of the district

  • Returns: 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 province

  • district: string - The name of the district

  • sector: string - The name of the sector

  • Returns: 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 province

  • district: string - The name of the district

  • sector: string - The name of the sector

  • cell: string - The name of the cell

  • Returns: 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:

  1. Report bugs or request features by opening an issue.
  2. Submit pull requests to fix bugs or add new features.
  3. 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.