SimpleGeoLoc simple items with geolocation, near items function


Simple geolocation functions. Add items with geolocation information, then find items near a point/distance.

Via npm on Node:

npm install simplegeoloc

Reference in your program:

var sgl = require('simplegeoloc');

Create an item store:

var store = sgl.createStore();

Add items to store:

store.add(latitude, longitude, item);


store.add(-34.47706, -58.50177, { city: 'Acassuso', geoname_id: 3436508 });
store.add(-34.74471, -58.40410, { city: 'Banfield', geoname_id: 3436152 });

Items near to a point:

var items = store.near(-34.47706, -58.50177);

The returned value is a JavaScript array. Each element has properties latitude, longitude, item (with the original associated item data).

  • 0.0.1 Published, naive near implementation, visiting all items, using haversine function for distances
  • First sample
  • Improve near implementation, partitioning items using an internal grid, then, visiting all the items in near cells instead of all the item list
  • New input format for position (latitude, longitude as strings; degree, minutes, seconds format 12° 20.736′ N, 98° 45.924′ W, etc)


Feel free to file issues and submit pull requests — contributions are welcome<

If you submit a pull request, please be sure to add or update corresponding test cases, and ensure that npm test continues to pass.