Coder Social home page Coder Social logo

simplegeoloc's Introduction

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.

simplegeoloc's People

Contributors

ajlopez avatar sunbox avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.