1.0.1 • Published 8 months ago
@ruhisfi/geodata v1.0.1
GeoData
GeoData is a TypeScript library that provides utilities for working with geographical data, including retrieving country information, determining if two countries share a border, and calculating the distance between two countries.
Features
- Retrieve country information by ISO 3166-1 alpha-2 code.
- Check if two countries share a border.
- Calculate the distance between two countries using their coordinates.
Usage
Importing the library:
import { GeoData } from "@ruhisfi/geodata";Retrieve country information:
const country = GeoData.getCountry("US");
console.log(country); // Output: { code: "US", name: "United States of America", region: "North America", lat: 37.0902, lon: -95.7129, borders: ["CA", "MX"] }Check if two countries share a border:
const sharesBorder = GeoData.doesBorder("US", "CA");
console.log(sharesBorder); // Output: trueCaculate the distance between two countries:
const distance = GeoData.getDistance("FI", "US");
console.log(distance); // Output: Distance in kilometersLicense
This project is licensed under the MIT License. See the LICENSE file for details.