Installations
npm install point-in-polygon-hao
Developer Guide
Typescript
Yes
Module System
ESM
Node Version
20.10.0
NPM Version
10.2.3
Score
99.6
Supply Chain
91.9
Quality
89.8
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
JavaScript (100%)
Developer
rowanwins
Download Statistics
Total Downloads
4,269,198
Last Day
7,666
Last Week
240,981
Last Month
934,786
Last Year
4,005,645
GitHub Statistics
140 Stars
34 Commits
10 Forks
5 Watching
1 Branches
5 Contributors
Bundle Size
3.53 kB
Minified
1.38 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.2.4
Package Id
point-in-polygon-hao@1.2.4
Unpacked Size
28.19 kB
Size
6.49 kB
File Count
9
NPM Version
10.2.3
Node Version
20.10.0
Publised On
22 Dec 2024
Total Downloads
Cumulative downloads
Total Downloads
4,269,198
Last day
-13.7%
7,666
Compared to previous day
Last week
-1.5%
240,981
Compared to previous week
Last month
10.9%
934,786
Compared to previous month
Last year
2,298%
4,005,645
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
A small library for detecting in a point lies inside a polygon
Features
- Works on polygons with holes
- Works with degenerate/self-intersecting polyons
- Returns
0
if on the edge - Not effected by floating point errors
Usage
Install via npm install point-in-polygon-hao
import inside from 'point-in-polygon-hao'
const polygon = [
[
[1, 1],
[1, 2],
[2, 2],
[2, 1],
[1, 1]
]
];
inside([ 1.5, 1.5 ], polygon)
// => true
inside([ 4.9, 1.2 ], polygon)
// => false
inside([1, 2], polygon)
// => 0 to indicate on edge
Note: The input polygon format aligns with the GeoJson specification for polygons. This means that the first and last coordinate in a polygon must be repeated, if not this library will throw an error.
const polygonWithHole = [
[
[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]
],
[
[0.1, 0.1], [0.1, 0.9], [0.9, 0.9], [0.9, 0.1], [0.1, 0.1]
]
]
The library does not support multi-polygons.
Comparisons
Some rough comparisons to similar libraries.
While point-in-polygon
is slightly faster in most cases it does not support polygons with holes or degenerate polygons.
// For a point in a much larger geometry (700+ vertices)
point-in-poly-hao x 381,184 ops/sec ±0.80% (87 runs sampled)
point-in-polygon x 285,734 ops/sec ±1.33% (91 runs sampled)
robust-point-in-polygon x 267,738 ops/sec ±0.78% (93 runs sampled)
// For a point in bounding box check
point-in-poly-hao x 25,822,227 ops/sec ±2.87% (86 runs sampled)
point-in-polygon x 30,321,920 ops/sec ±2.14% (91 runs sampled)
robust-point-in-polygon x 26,708,560 ops/sec ±1.13% (91 runs sampled)
Algorithm
This library is based on the paper Optimal Reliable Point-in-Polygon Test and Differential Coding Boolean Operations on Polygons
Other notes
- Works irrespective of winding order of polygon
Does not appear to be effected by floating point errors compared topoint-in-polygon
orrobust-point-in-polygon
- Added robust-predicates to deal with some floating point errors

No vulnerabilities found.
Reason
11 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
Found 4/21 approved changesets -- score normalized to 1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 13 are checked with a SAST tool
Score
4.5
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More