Skip to content

Simple Geolocation function: items with geolocation, near points

License

Notifications You must be signed in to change notification settings

ajlopez/SimpleGeoLoc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleGeoLoc

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

Usage

Installation

Via npm on Node:

npm install simplegeoloc

Usage

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);

Examples:

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).

Versions

  • 0.0.1 Published, naive near implementation, visiting all items, using haversine function for distances

To Do

  • 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)

License

MIT

References

Contribution

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.

About

Simple Geolocation function: items with geolocation, near points

Resources

License

Stars

Watchers

Forks

Packages