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

geomash

v1.2.0

Published

a module that build geohash aggregations in levelDB

Downloads

18

Readme

Geomash

npm version build status

A node.js module for building geohash aggregations from GeoJSON files.

Why geohashes

This works is the result of development around aggregating lots of data into geohashes. The idea is that we can aggregate data on the server and serve these relatively small json files that tell us the count of data with a fine grid of geohashes. The geohash can be re-aggregated based on zoom and provide a nice method for view clusters of data at different scales.

Usage

There are 2 ways that you can use geomash: on the command line and as a node.js module.

Command Line

To use geomash as a command line utility you have to install it globally first

npm install geomash -g

This installs an executable called geomash that you can use to create some aggregations.

Usage: geomash -i [id string] -f [input file] -o [output file] -p [precision number]

Options:
  -i  [required]
  -f  [default: "none"]
  -o  [default: "none"]
  -p  [default: "9"]

You can also pipe geojson files into geomash like so:

cat data.geojson | geomash -i myid -p 6

Node Module

To use geomash as a node module you also need to install it via npm install geomash. Then in side your node app you would do something like

// the geomash module return a function so that it can accept a redis port and host at require time.
// passing nothing to geomash tells it to use a purely in-memory cache
var geomash = require('geomash')({
  redis: {
    port: 6329,
    host: '127.0.0.1'
  }
})

geomash.add(id, feature, precision, function (err) {
  geomash.dump(id, function (err, agg) {
    console.log(agg)
  })
})

Geomash can also be used with a redis backend so it aggregations work can be done in a more distributed way. To use redis you pass in a json object containing a host and a port of your redis instance like so:

``javascript var geomash = require('require')({ host: '127.0.0.1', port: 6379
})

// then everything it same


## Docs

Geomash exposes these methods:

### Add

Adds a feature to a geohash aggregation.

`geomash.add(id, feature, precision, callback)`

### Clear

Clears the geohash aggregation for a given id.

`geomash.clear(id, callback)`

### Dump

Dumps out the geohash aggregation for a given id.

`geomash.dump(id, callback)`

### Insert

Inserts geohash aggregation object for a given id.

`geomash.insert(id, agg, callback)`

### createGeoHash

Creates geohash key from a feature.

`geomash.createGeoHash(feature, precision, callback)`

### count

Counts the length of geohash keys

`geomash.count(id, callback)`


## License

[ISC](license.txt)