point-in-cirlce
v1.0.0
Published
A npm package to check if a geo-coordinate point is within a cirlce, given its geographical center (latitude and longitude) and the radius. The function can take in Geo-Coordinates and can be used to test if a point is in a particular GeoFence or a Geobo
Downloads
108
Maintainers
Readme
##Points In Circle (GeoFence/GeoBountry) This Package helps in finding if a geo coordinate provided is located inside a circle. This can be used to check if a particular point is within or outside a circular GeoFence/GeoBountry.
Installation
npm install --save geo-point-in-circle
Usage
Parameters
The package takes in three inputs parameters.
- Latitude of the point to be checked.
- Longitude of the point to be checked.
- An object which holds the latitude, longitude of the center of the circle, and radius of the circle in km
Return Object
The package returns an object that has a "result" boolean - true or false and distanceFromCenter the distance of the point from the center of the circle . If the point is within the cirlce, it returns true, else will return false.
Example
const checkPoint = require("geo-point-in-circle");
circle = {
circleLat : 20.5937,
circleLng : 78.9629,
circleRadius : 120
}
console.log(checkPoint(20.902 , 79.9629 , circle));
The above will return the result as
{
result: true,
distanceFromCenter: 109.48865971794584
}