Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spatial-mapping

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spatial-mapping

maps 2d coordinates to a unique string key

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

spatial-mapping

This module divides an area to buckets and maps 2d coordinates to a unique key. This key can then be used to store users in a hash or a rational database that doesn't have a spatial-query support.

Indexing this column will enable us to query for users in a specific bucket. Also- this module exposes an api to get all the buckets around a specific coordinates, so that we could query for all users in a bucket-size area that doesn't necessarily falls in one whole bucket. Filtering the users that actually falls in the required area will be done by the callback of the requesting function.

An example of using this module can be found in the nodemmo project.

usage


var options = {
  gridUnit: {
    width: 2000,
    height: 500
  }
};

var spatialMapper = require('spatial-mapping')(options);
var x = 10000, y = 4000;
var gridKey = spatialMapper.getKey(x, y);
console.log('gridKey', gridKey); // gridKey [5,8]

var gridIds = spatialMapper.getViewGrids(x, y);
console.log('gridIds', gridIds); // gridIds [ '[4,7]', '[4,8]', '[5,7]', '[5,8]' ]

License

MIT

Keywords

FAQs

Package last updated on 19 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc