Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
point-in-polygon
Advanced tools
determine if a point is inside a polygon with a ray intersection counting algorithm
The point-in-polygon npm package is a utility for determining whether a given point lies inside a polygon. This can be useful in various applications such as geographical mapping, collision detection in games, and more.
Check if a point is inside a polygon
This feature allows you to check if a given point is inside a specified polygon. The function returns true if the point is inside the polygon and false otherwise.
const inside = require('point-in-polygon');
const point = [1, 1];
const polygon = [[0, 0], [2, 0], [2, 2], [0, 2]];
console.log(inside(point, polygon)); // true
The point-in-polygon-hao package provides similar functionality to point-in-polygon, allowing you to check if a point is inside a polygon. It is a lightweight and efficient alternative.
The robust-point-in-polygon package offers a more robust solution for checking if a point is inside a polygon. It handles edge cases and numerical precision issues better than point-in-polygon.
The turf-inside module is part of the Turf.js library, which provides advanced geospatial analysis tools. It offers more comprehensive geospatial functionalities compared to point-in-polygon, including point-in-polygon checks.
Determine if a point is inside of a polygon.
This module casts a semi-infinite ray from the inquiry point and counts intersections, based on this algorithm.
If you need a numerically robust solution and are willing to trade some performance for it, use robust-point-in-polygon.
var pointInPolygon = require('point-in-polygon');
var polygon = [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ] ];
console.log(pointInPolygon([ 1.5, 1.5 ], polygon)); // true
console.log(pointInPolygon([ 4.9, 1.2 ], polygon)); // false
console.log(pointInPolygon([ 1.8, 1.1 ], polygon)); // true
var pointInPolygon = require('point-in-polygon')
var pointInPolygonFlat = require('point-in-polygon/flat')
var pointInPolygonNested = require('point-in-polygon/nested')
Return whether point
is contained in polygon
.
point
should be a 2-item array of coordinatespolygon
should be an array of 2-item arrays of coordinates or a flat array of coordinatesstart
is an offset into polygon
. default 0
end
is an offset into polygon
. default polygon.length
The flat or nested is detected automatically. Or you can use the specific methods if you want to skip the check.
npm install point-in-polygon
MIT
FAQs
determine if a point is inside a polygon with a ray intersection counting algorithm
We found that point-in-polygon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.