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

common-geohash-parent

v0.1.0

Published

Functions to get common geohash parent(s) of coordinates or bbox

Downloads

137

Readme

Common geohash parent finder v0.1.0

Class with multiple methods to help you find the common parent geohash from points, geohashes, bounding boxes, polygons or other GeoJSON shapes.

Installation

Using npm:

npm i common-geohash-parent

Using yarn:

yarn add common-geohash-parent

Example usage

In node:

const ParentFinder = require('common-geohash-parent');

const bbox = [-3.944092, 40.241799, -3.261566, 40.779502];
const precision = 5;
const finder = new ParentFinder(precision);
finder.fromBBox(bbox)
  .then((parents) => {
    // parents is ['ezjp','ezjr','ezjx','ezjn','ezjq','ezjw','ezjj','ezjm','ezjt','ezjh','ezjk','ezjs']
    ...
  });

Classes

Typedefs

ParentFinder

Kind: global class

new ParentFinder()

ParentFinder class

parentFinder.fromPoints(points) ⇒ ParentGeohashList

Finds common parents from array of points

Kind: instance method of ParentFinder
Returns: ParentGeohashList - Array of geohashes

| Param | Type | Description | | ------ | ----------------------------------------------- | ----------- | | points | Array.<Array.<number>> | [lon, lat] |

parentFinder.fromGeohashes(hashes) ⇒ ParentGeohashList

Finds common parents from array of geohashes

Kind: instance method of ParentFinder
Returns: ParentGeohashList - List of parent geohashes

| Param | Type | Description | | ------ | --------------------------------- | ----------------- | | hashes | Array.<string> | List of geohashes |

parentFinder.fromBBox(bbox) ⇒ Promise.<ParentGeohashList>

Finds common parents from bounding box

Kind: instance method of ParentFinder
Returns: Promise.<ParentGeohashList> - Promise of list of parent geohashes

| Param | Type | Description | | ----- | --------------------------------- | -------------------------------- | | bbox | Array.<number> | [number, number, number, number] |

parentFinder.fromPolygon(inputPolygon) ⇒ Promise.<ParentGeohashList>

Finds common parents from polygon feature

Kind: instance method of ParentFinder
Returns: Promise.<ParentGeohashList> - Promise of list of parent geohashes

| Param | Type | Description | | ------------ | ------------------- | ------------- | | inputPolygon | object | GeoJSON shape |

ParentFinder.ParentFinder

Kind: static class of ParentFinder

new ParentFinder(parentPrecision, [optimization])

Creates an instance of ParentFinder.

| Param | Type | Description | | --------------- | -------------------------------------------------------- | ---------------------------------------- | | parentPrecision | number | Initial parent precision | | [optimization] | OptimizationOptions | If desired, specify optimization options |

ParentGeohashList : Array.<string>

Kind: global typedef

OptimizationOptions

Kind: global typedef
Properties

| Name | Type | | ---------- | -------------------- | | enabled | boolean | | maxParents | number |