point-in-big-polygon is a JavaScript library providing an industrial-strength solution for the point-in-polygon problem. It specializes in classifying a single point against a potentially large and complex 2D polygon with high precision. The library preprocesses the polygon in O(n log(n)) time to create an optimized classification function, which then determines if any given point is inside, on the boundary, or outside the polygon in O(log(n)) operations. All internal computations utilize exact arithmetic, guaranteeing robust and precise results even with degenerate cases or floating-point inaccuracies. The current stable version is 2.0.1, and while its last major update was around 2014, it remains a reliable tool for specialized geospatial or geometric computations in CommonJS environments, including Node.js and browsers via bundlers like Browserify. Its primary differentiation lies in its optimized performance and exactness for single, complex polygons.
npm install point-in-big-polygonVerified import paths — ran on the pinned version, not inferred.
Classifies points against a polygon with a hole and renders the result as an ASCII image to the console, illustrating inside (-), boundary (o), and outside (+) regions using the `classifyPoint` function.
Ensure all polygon loops adhere to manifold geometry constraints. Use a geometry validation library or careful construction to prevent invalid polygons.
For scenarios involving many distinct polygons, evaluate 'point-in-region'. For a single polygon, ensure input loops are correctly structured and meet manifold requirements.
Explicitly check `if (v < 0)` for inside, `if (v === 0)` for on boundary, and `if (v > 0)` for outside when interpreting results.
Always pass coordinates as `[x, y]` arrays for both polygon vertices and points to be classified.
Ensure `loops` is an array where each element is itself an array of `[x, y]` points representing a polygon loop. Example: `[[[0,0],[1,0],[1,1]], [[0.1,0.1],[0.9,0.1],[0.9,0.9]]]`
Verify all points and vertices are correctly formatted as `[x, y]` arrays and that no loops are empty or contain fewer than 3 vertices.
Simplify the polygon if possible, remove duplicate vertices, or pre-validate its manifold properties. For extreme cases where exactness is not strictly required, consider alternative approximate point-in-polygon algorithms.
No dependency data recorded yet.