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);
var gridIds = spatialMapper.getViewGrids(x, y);
console.log('gridIds', gridIds);
License
MIT