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

thunderbolt-feature-exports

v5.81.0

Published

weather and gis aggregation library with a simple API

Downloads

76

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 point
  • longitude (Number): Longitude of the center point
  • maxRadiusKm (Number): Maximum radius in kilometers
  • minMagnitude (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 point
  • lat2, 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.