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-big-polygon
Advanced tools
Industrial scale point-in-polygon test. Given a polygon, this module preprocesses it in O(n log(n)) time such that any point can be classified against the polygon in O(log(n)) operations. All computations are performed in exact arithmetic.
If you want to use multiple polygons/regions, you should use point-in-region instead.
var preprocessPolygon = require('point-in-big-polygon')
//Define the polygon loops
var loops = [
[ [-10, -10], [-10, 10], [10, 10], [10, -10] ],
[ [-1, -1], [1, -1], [1, 1], [-1, 1] ]
]
//Preprocess it
var classifyPoint = preprocessPolygon(loops)
//Render polygon test in ASCII to console
var img = []
for(var y=-12; y<=12; y+=1) {
var row = []
for(var x=-12; x<=12; x+=0.5) {
var v = classifyPoint([x, y])
if(v < 0) {
row.push('-')
} else if(v === 0) {
row.push('o')
} else {
row.push('+')
}
}
img.push(row.join(''))
}
console.log(img.join('\n'))
Example output:
+++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++
++++ooooooooooooooooooooooooooooooooooooooooo++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o-----------------ooooo-----------------o++++
++++o-----------------o+++o-----------------o++++
++++o-----------------ooooo-----------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++o---------------------------------------o++++
++++ooooooooooooooooooooooooooooooooooooooooo++++
+++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++
This module works in any reasonable CommonJS environment including browserify, iojs and node.js.
npm install point-in-big-polygon
var classifyPoint = require("point-in-big-polygon")(loops)
Preprocess a polygon given by a collection of clockwise oriented loops to handle point membership queries.
loops
are a collection of oriented loops representing the boundary of the polygon. These loops must be manifold (ie no self intersections or dangling edges).Returns A point membership function that can be used to classify points relative to the function
classifyPoint(p)
This function is the result of running the preprocessing operation on a polygon. It takes a single point as input and tests it against the boundary.
p
is a point encoded as a length 2 arrayReturns A number which classifies p
relative to the boundary
-1
means that p
is inside0
means that p
is on the boundary+1
means that p
is outside(c) 2014 Mikola Lysenko. MIT License
FAQs
Industrial strength point in polygon test
The npm package point-in-big-polygon receives a total of 18,940 weekly downloads. As such, point-in-big-polygon popularity was classified as popular.
We found that point-in-big-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.