bkk-district-geocoding
v0.0.1
Published
 
Downloads
11
Readme
Bangkok District Geocoding
A lightweight library to find the Bangkok district based on latitude and longitude coordinates.
Features
- Fast and Efficient: Quickly find a district from geographic coordinates.
- Offline: No network requests needed; all data is included in the package.
- TypeScript Support: Fully typed for a better development experience.
Data Source
The geographic data for Bangkok's 50 districts is sourced from the official Open Government Data of Bangkok website:
The original data was provided in Shapefile format and was converted to GeoJSON using mygeodata.cloud.
Installation
pnpm install bkk-district-geocoding
# or
npm install bkk-district-geocoding
# or
yarn add bkk-district-geocodingUsage
import { getDistrictFromLatLng } from 'bkk-district-geocoding'
const latitude = 13.7563
const longitude = 100.5018
const district = getDistrictFromLatLng(latitude, longitude)
if (district) {
console.log(`The district is: ${district.properties.dname}`)
console.log(`District Code: ${district.properties.dcode}`)
} else {
console.log('No district found for the given coordinates.')
}Development
This project uses pnpm as the package manager.
pnpm install- Install dependenciespnpm dev- Start the development serverpnpm build- Build for productionpnpm test- Run all tests
