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

geocircle

v1.0.0

Published

Great Circle Distance library for calculating geo-coordinates within kilometre radiuses

Downloads

5

Readme

Geo Circle

This is a lightweight geo utility package that can extract all of the latitude and longitude coordinates within an array of data within a user-defined km circle area

Installation

Installation is with npm : npm install geocircle --save

Usage

To get started, create a GeoCircle object and pass it the correct parameters. In your array of data you need to have a LatLng object of anatomy { lat: 34.0001, lng: -33.1111 } by default the key latlng is used but you can specify a user-defined key for example coords as the fourth argument to the GeoCircle constructor.

const GeoCircle = require('geocircle');

const data = [
    {
        name: "A",
        coords: { //we'll specify the key 'coords' to target this object that holds the lat/lng
            lat: 52.000,
            lng: -33.500
        }
    },
    {
        name: "B",
        coords: {
            lat: -34.9285,
            lng: 138.6007
        }
    }
];

var geoCircle = new GeoCircle(52.000, -33.000, data, 'coords'); //note the use of the key 'coords'
geoCircle.setGeoCircleWithin(100) //within 100km
console.log(geoCircle.toString()) // name: A | Latitude: 52.00000 | Longitude: -33.50000

Method Reference

Public Properties (GeoCircle)

| Property | Summary | |--------------------|--------------------------------------------------------------------------------------------------| | SORT_ASCENDING | The identifier for the ascending sorting order of the sort() method | | SORT_DESCENDING | The identifier for the descending sorting order of the sort() method |

Public Methods (GeoCircle)

| Method | Summary | |--------------------|--------------------------------------------------------------------------------------------------| | setGeoCircleWithin | Filters the internal data array to only the coordinates within the km radius provided as a param | | sort | (key, sort = SORT_DESCENDING) Sorts the internal data by key and by asc or desc | | toString | Returns a human readable string representation of the internal data |

Static Methods (LatLng)

| Method | Summary | |---------------------------|-------------------------------------------------------------------------------------------| | getLatLngFromCoordsString | Returns a LatLng object based on the coordinates string passed e.g "-34.000,80.0444" |