ember-production-deprecations
v5.81.0
Published
weather and gis aggregation library with a simple API
Downloads
988
Readme
Weather and Earthquake SDK -- Premium Package
Overview
The Earthquake Data Library is a Node.js SDK that provides an easy-to-use interface for fetching and analyzing earthquake data from the USGS (United States Geological Survey) Earthquake API. This library allows users to retrieve recent earthquake information, query earthquakes by geographic radius, and perform basic analysis on seismic events.
Features
- Fetch recent earthquakes with customizable parameters
- Query earthquakes within a specified radius of a geographic point
- Retrieve the most significant recent earthquakes
- Calculate distances between geographic coordinates
- Interpret earthquake magnitudes with descriptive categories
Installation
Please make sure you have a valid license prior to installing this library. To install the Earthquake Data Library, run the following command in your project directory:
npm install earthquake-data-library
Note: Make sure you have Node.js and npm installed on your system.
Usage
Here's a basic example of how to use the Earthquake Data Library:
const EarthquakeLibrary = require("earthquake-data-library");
const earthquakeLib = new EarthquakeLibrary();
async function main() {
try {
// Get recent earthquakes
const recentQuakes = await earthquakeLib.getEarthquakes({
startTime: "2023-06-01",
minMagnitude: 4.5,
limit: 10,
});
console.log("Recent significant earthquakes:", recentQuakes);
// Get earthquakes within 1000km of Tokyo
const tokyoQuakes = await earthquakeLib.getEarthquakesByRadius(
35.6762,
139.6503,
1000,
5
);
console.log("Recent earthquakes near Tokyo:", tokyoQuakes);
// Get magnitude description
console.log(
"A magnitude 6.5 earthquake is considered:",
earthquakeLib.getMagnitudeDescription(6.5)
);
} catch (error) {
console.error("Error:", error.message);
}
}
main();
API Reference
getEarthquakes(options)
Fetches earthquake data based on specified parameters.
options
(Object):startTime
(String): Start date for the query (default: '2023-01-01')endTime
(String): End date for the query (default: current date)minMagnitude
(Number): Minimum magnitude (default: 0)maxMagnitude
(Number): Maximum magnitude (default: 10)limit
(Number): Maximum number of results to return (default: 100)
Returns a Promise that resolves to an array of earthquake objects.
getEarthquakesByRadius(latitude, longitude, maxRadiusKm, minMagnitude)
Fetches earthquakes within a specified radius of a geographic point.
latitude
(Number): Latitude of the center pointlongitude
(Number): Longitude of the center pointmaxRadiusKm
(Number): Maximum radius in kilometersminMagnitude
(Number): Minimum magnitude (default: 0)
Returns a Promise that resolves to an array of earthquake objects.
getMostSignificantEarthquakes(limit)
Retrieves the most significant recent earthquakes.
limit
(Number): Maximum number of results to return (default: 10)
Returns a Promise that resolves to an array of earthquake objects.
calculateDistance(lat1, lon1, lat2, lon2)
Calculates the distance between two geographic points.
lat1
,lon1
: Latitude and longitude of the first pointlat2
,lon2
: Latitude and longitude of the second point
Returns the distance in kilometers.
getMagnitudeDescription(magnitude)
Provides a descriptive category for an earthquake magnitude.
magnitude
(Number): The earthquake magnitude
Returns a string describing the magnitude category (e.g., "Minor", "Moderate", "Major").
Error Handling
The library uses a centralized error handling mechanism. All methods that interact with the USGS API will throw an error if the request fails or if there's an issue with the data. It's recommended to use try-catch blocks when calling these methods.
Contributing
Contributions to the Earthquake Data Library are welcome! Please feel free to submit a Pull Request. Author: Incisiv3
License
This project is licensed under the MIT License! - see the LICENSE file for details.