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

@webkitty/geo-rev

v1.1.1

Published

Reverse geocoder for Node.js working with offline data and fast lookup times.

Downloads

202

Readme

Every release of the package contains a modified version of the latest free GeoNames.org cities500 dataset (licensed under a Creative Commons Attribution 4.0 License). There is also a possibility to use an external dataset in the same format. Geocoding of given coordinates is performed using a K-D Tree index, which is built during initialization of the component.

✅ Features

  • [x] Parses local (offline) geographical database of places.
  • [x] Looks up a nearest place (town/city) to a given geographical location.

⚙️ Usage

Show me the code!

import { createRevGeocoder } from '@webkitty/geo-rev';

const revGeocoder = await createRevGeocoder();
const result = revGeocoder.lookup({latitude: 50.652576, longitude: 13.723918});
console.log(result);
{
  record: {
    name: 'Hrob',
    latitude: 50.65919,
    longitude: 13.72676,
    countryCode: 'CZ'
  },
  distance: 0.7622437751065233  // [km]
}

By default the geocoder uses a bundled dataset.

OK, what if I need to update the dataset in the future?

The latest dataset is bundled with each release, but you can always supply yours:

const revGeocoder = await createRevGeocoder({dataset: '/path/to/your/dataset.csv'});

We use a simple script to convert the GeoNames.org dataset to the supported format:

wget https://download.geonames.org/export/dump/cities500.zip -O /tmp/geonames.zip
unzip /tmp/geonames.zip | cut -f2,5,6,9 -s --output-delimiter=';' > cities500.csv

But I have a custom dataset!

No problem, I can hear you. Just convert yours to the following format:

  • Cell delimiter is a semi-colon (;).
  • Row delimiter is a Unix LF (\n).
  • There is no header row.
  • Cell values are not quoted.
  • Order of the columns is:
    1. Name of the place (UTF8 string)
    2. Latitude (float number)
    3. Longitude (float number)
    4. ISO Alpha-2 country code of the place (string)

For the sake of completeness the CSV should look as follows:

Soldeu;42.57688;1.66769;AD
Musashino;35.70611;139.55944;JP
Ängelholm;56.2428;12.86219;SE
...

🛠️ Build

make

🙇‍ Dependencies and attributions

  • https://github.com/mikolalysenko/static-kdtree - Static K-D tree data structure
  • https://geonames.org - The GeoNames geographical database

📜 License

Copyright © 2020 stuchl4n3k. This project is MIT licensed.