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 =var classifyPoint =consoleconsoleconsole
npm install point-in-big-polygon
var classifyPoint = require("point-in-big-polygon")(loops[,clockwise])
Preprocess a polygon given by a collection of oriented loops to handle point membership queries.
loopsare a collection of oriented loops representing the boundary of the polygon. These loops must be manifold (ie no self intersections or dangling edges).
clockwiseis an optional parameter, which if set changes the sign of the classification function.
Returns A point membership function that can be used to classify points relative to the function
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.
pis a point encoded as a length 2 array
Returns A signed floating point value which classifies
p relative to the boundary
pis on the boundary
(c) 2014 Mikola Lysenko. MIT License