Logo Lanfrica

kozera920/rwanda-location-lookup

Domain:

geospatial

Record type:

software
Creator:
koz
Host:
# rwanda-location-lookup Convert map coordinates to Rwanda's full administrative hierarchy in one call. Give the package a latitude and longitude, and it returns: - Province - District - Sector - Cell - Village Bundled boundary data is included, so developers can install and use it directly without downloading shapefiles. `lookup()` auto-loads bundled GeoJSON and now handles Vite optimized-deps paths without manual `public/geo` copy steps. ## Install ```bash npm install rwanda-location-lookup ``` ## Demo Live demo: rwanda-location-lookup.vercel.app Use it to test: - Coordinates to Province, District, Sector, Cell, Village - Current device location lookup - Reverse lookup from hierarchy to center coordinates ## Quick Start ```js import { lookup } from "rwanda-location-lookup"; const result = await lookup({ latitude: -1.944, longitude: 30.062, }); console.log(result); ``` Example output: ```js { province: "Kigali City", district: "Nyarugenge", sector: "Nyarugenge", cell: "Kiyovu", village: "Ishema", ids: { province: 1, district: 11, sector: 1109, cell: 110903, village: "11090308" } } ``` ## API (Short and Clean) - `lookup(...)` : Async one-call lookup using bundled Rwanda data. - `loadData()` : Async load + cache bundled data once. - `lookupByCoords(...)` : Sync lookup using coordinates and already-loaded data. - `lookupByPoint(...)` : Sync lookup using a GeoJSON Point and already-loaded data. - `toPoint(...)` : Convert `{ latitude, longitude }` (or `{ lat, lng }`) to a GeoJSON Point. - `validateData(...)` : Validate the `districts/sectors/cells/villages` FeatureCollections. - `center(...)` : Async reverse lookup using bundled data. Provide hierarchy names/ids and get center coordinates. - `centerBy(...)` : Sync reverse lookup using already-loaded data. ## High-Performance Usage (Many Requests) ```js import { loadData, lookupByCoords } from "rwanda-location-lookup"; const data = await loadData(); const a = lookupByCoords({ latitude: -1.94 …