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

geotrie

v1.0.0

Published

Store and search geo data. Geohashes and stores latitude/longitude coordinates and provides a search interface.

Downloads

5

Readme

#Geotrie Store and search geo data. Geohashes and stores latitude/longitude coordinates and provides a search interface.

Right now depends on leveldb, as it uses the lexographical sorting of leveldb to provide a trie like data structure and efficient search algorithm. However this approach can and should be generalized to work in memory and with other databases.

Heavily borrowed from / inspired by level-trie and level-places. Thanks to Julian Gruber.

##Usage

var level = require('level')
var GeoTrie = require('geotrie')
var geotrie = geotrie(level(__dirname + '/db'))

geotrie.add({lat: 1, lon: 1}, 'SomeReferenceString')
geotrie.add({lat: 1.01, lon: 1}, 'OtherReferenceString')

geotrie.search({lat: 1, lon: 1}).toArray(function(err, results){
  //...
})

Results will come in the form of

{
  distance: 10, //in meters
  pos: {lat: 1, lon 1}, //stored position (will not be exact because of geohashing fidelity loss)
  ref: 'your string' //the reference string supplied during .add
}

Search Options ###hardLimit (Int) If supplied the search will immediately return after reaching this number of results (setting hard limit may result in omitted results that are closer to the centroid than other returned results) ###softLimit (Int) Usually a better option to setting hardLimit - If hit, the search will finish streaming after it completes it's current resolution level ###maxResolution (int) Defaults to 12. The search will start from the max resolution. If your relevant results will always be far apart then you can set this number lower for small efficiency gains ###minResolution (int) Defaults to 0. The search will end at this resolution even if the hard/soft limits have not been met.

##Notes Unfortunately geohash's are roughly rectangular in shape (and generally not square). If using a 2^(odd) base odd precision hash boxes will be square - all other hash boxes are about twice as big in the longitudinal direction at the equator (it reverses as you travel to extreme latitudes where longitudinal distances pinch).

##Geohash Precision Assuming base16 geohashing (4 bits per character) the hash precision will be as follows:

Precision | Lat Error | Lon Error ---|---|--- 2 | 1248.75 km | 2497.5 km 4 | 78.046875 km | 156.09375 km 6 | 4.8779296875 km | 9.755859375 km 8 | 304.870605469 m | 609.741210938 m 10 | 19.0544128418 m | 38.1088256836 m 12 | 1.19090080261 m | 2.38180160522 m