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-compress

v1.1.5

Published

A data compression library for large sized Geopolygons.

Downloads

50

Readme

geohash - compress

A data compression and Geo-hasing library for large sized Geo-polygons. It solves the problem when standard point-in-polygon query takes too much time and conversion of Geo-polygon into Geohashes for constant time point-in-polygon query, takes large space in memory. This library provides a memory effiecent soltution for constant time point-in-polygon query by converting the hashes to lowest possible order.

Installation

In Node.js

npm install geohash-compress 

Run test locally

  1. Clone this repo
https://github.com/raghav1408/geohash-compress.git
  1. Install NPM packages
npm install
  1. Run tests
npm run test

Usage in Node.js example

const geoHashCompress = require('geohash-compress');
// Geofence is array of {long,lat} of the geofence.
(async()=>{
    let geofence = [[
        [75.4375024, 22.8725924],
        [75.4401784, 22.9105034],
        [75.4562348, 22.9185316],
        [75.4620329, 22.9287898],
        [75.4375024, 22.8725924],
    ]]
    //construct a new polygon from the geofence 
    // maximum hash length in the output = 7(default = 7)
    // minimum hash length(if possible) in the output = 1(default = 1)
    const polygon = await new geoHashCompress(geofence,7,1); 
    
    // compress the polygon and returns a map with geohash as key eg: {tsj8p6n:true}
    let hashes = polygon.compress(); 

    // prints object {...,tsj8:true,tsj8p6n:true,tsj8p6o:true,tsj8p6p:true,...}
    console.log(hashes)
    
    //polygon.insideOrOutside(long,lat) 
    //return true/false if point{long,lat} is inside/outside polygon.
    console.log(polygon.insideOrOutside(75.8814993,22.7418224)) 
    
    // returns compressed geometry as Geojson.
    const geojson = polygon.toGeoJson();
})()
 

Benchmarks

Intial data size of polygon : 34.8 MB
Final data size of polygon : 1.2 MB

100 point-in-polygon query without compression: 3ms
100 point-in-polygon query with compression: 4ms

Without Compression 34.8 MBWith Compression 1.2MB

Without Compression 34.8 MB -> With Compression 1.2 MB

License

Distributed under the Apache 2.0 License. See LICENSE for more information.