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

geohash-neighbours

v0.2.1

Published

finds the cells near a given geohash

Downloads

10

Readme

geohash-neighbours

finds the cells near a given geohash

NPM version Build Status

js-standard-style

Table Of Contents

Installation

With npm do

npm install geohash-neighbours

Status

Algorithm was written and implemented in few days: as a mathematician, I am confident it is right. It needs more test cases as well as users that try it and compare it to the method they are currently using. Your feedback will be welcome.

GeoHash format

The geoHash is given in binary format as a string of 0 1, so iterations look like the following

n=1

0 - 1

n=2

00 - 01
  ___/
 /
10 - 11

n=3

000 - 001 - 010 - 011
  _________________/
 /
100 - 101 - 110 - 111

n=4

0000 - 0001   0100 - 0101
   ____/    __/   ____/
  /        /     /
0010 - 0011   0110 - 0111
   ___________________/
  /
1000 - 1001   1100 - 1101
   ____/    __/   ____/
  /        /     /
1010 - 1011   1110 - 1111

API

neighboursOf(geoHash)

computes the cells near a given geohash

const neighboursOf = require('geohash-neighbours').neighboursOf
const geoHash = '0011'

console.log(neighboursOf(geoHash)) // [
                                   //   '0000', '0001', '0100'
                                   //   '0010',         '0110'
                                   //   '1000', '1001', '1100'
                                   // ]
  • @param {String}: geoHash given in geoHash format.
  • @returns {Array}: neighbours of given geohash, that are 8 geohashes in most cases, belonging to the same iteration step. Cells are in anticlockwise order.

eastOf(geoHash)

neighbour at east a given geohash, if any

  • @param {String}: geoHash given in geoHash format.
  • @returns {String}: neighbour at east of given geohash.
const eastOf = require('geohash-neighbours').eastOf

console.log(eastOf('0000'))

northeastOf(geoHash)

neighbour at northeast a given geohash, if any

  • @param {String}: geoHash given in geoHash format.
  • @returns {String}: neighbour at northeast of given geohash.
const northeastOf = require('geohash-neighbours').northeastOf

console.log(northeastOf('0000'))

northOf(geoHash)

neighbour at north a given geohash, if any

  • @param {String}: geoHash given in geoHash format.
  • @returns {String}: neighbour at north of given geohash.
const northOf = require('geohash-neighbours').northOf

console.log(northOf('0000'))

northwestOf(geoHash)

neighbour at northwest a given geohash, if any

  • @param {String}: geoHash given in geoHash format.
  • @returns {String}: neighbour at northwest of given geohash.
const northwestOf = require('geohash-neighbours').northwestOf

console.log(northwestOf('0000'))

westOf(geoHash)

neighbour at west a given geohash, if any

  • @param {String}: geoHash given in geoHash format.
  • @returns {String}: neighbour at west of given geohash.
const westOf = require('geohash-neighbours').westOf

console.log(westOf('0000'))

southwestOf(geoHash)

neighbour at southwest a given geohash, if any

  • @param {String}: geoHash given in geoHash format.
  • @returns {String}: neighbour at southwest of given geohash.
const southwestOf = require('geohash-neighbours').southwestOf

console.log(southwestOf('0000'))

southOf(geoHash)

neighbour at south a given geohash, if any

  • @param {String}: geoHash given in geoHash format.
  • @returns {String}: neighbour at south of given geohash.
const southOf = require('geohash-neighbours').southOf

console.log(southOf('0000'))

southeastOf(geoHash)

neighbour at southeast a given geohash, if any

  • @param {String}: geoHash given in geoHash format.
  • @returns {String}: neighbour at southeast of given geohash.
const southeastOf = require('geohash-neighbours').southeastOf

console.log(southeastOf('0000'))

License

MIT