https://github.com/stackblogger/distance-finder-by-geo
This plugin is used to fetch customers by Latitude and Longitude within a range provided by user at the time of plugin call.
https://github.com/stackblogger/distance-finder-by-geo
Last synced: 10 months ago
JSON representation
This plugin is used to fetch customers by Latitude and Longitude within a range provided by user at the time of plugin call.
- Host: GitHub
- URL: https://github.com/stackblogger/distance-finder-by-geo
- Owner: stackblogger
- Created: 2019-11-24T12:44:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-24T13:21:35.000Z (over 6 years ago)
- Last Synced: 2025-08-22T09:28:09.666Z (10 months ago)
- Language: TypeScript
- Size: 11.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DistanceFinderByGeo
Library to find data which falls under a given radius (km). The library uses Geopoint calculations using Radians to get distance between two coordinates and then find out which data falls under the given radius.
## Install
```sh
npm install distance-finder-by-geo
```
## Usage
```js
require('distance-finder-by-geo')
```
#### Download Sample Customers.txt file for testing
## Functions
Get All the Customers within Radius Range provided at the time of function call.
### `getAllCustomersWithinRange(point, jsonFilePath, radius, orderBy = '')`
#### Paramaters:
- point: The base Geopoint from where we need to find distance of other Coordinates
- jsonFilePath: Customers.txt file path which has the Coordinates data
- radius: The distance radius
- orderBy: (Optional) Pass the field name exist in Customers.txt file by which you want the Ascending Ordering
```js
// Working code sample
require('distance-finder-by-geo')
.getAllCustomersWithinRange({ lat: 53.339428, lng: -6.257664 }, __dirname + '/Customers.txt', 100, 'user_id')
.then(result => {
console.log(result);
}).catch(ex => {
console.log(ex);
})
```
Get all the data in Success Callback and Exception in Error Callback.