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 = ;
Create an item store:
var store = sgl;
Add items to store:
store;
Examples:
store;store;
Items near to a point:
var items = store;
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
- Geotagging with lat/long formats
- Geographic coordinate system
- How to convert address (as text) to gps coordinates?
- The Google Geocoding API
- Free Geocoding Utilities at GPSVisualizer.com
- Calculate distance between 2 GPS coordinates
- Calculate distance, bearing and more between Latitude/Longitude points See accuracy note, for error due to use medium earth radius
- What is the distance between a degree of latitude and longitude?
- Earth Radius
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.