{"name":"point-in-polygon-hao","version":"1.2.4","type":"module","description":"A point in polygon based on the paper Optimal Reliable Point-in-Polygon Test and Differential Coding Boolean Operations on Polygons","main":"dist/cjs/index.cjs","module":"dist/esm/index.js","types":"dist/esm/index.d.ts","unpkg":"dist/pointInPolygon.min.js","jsdelivr":"dist/pointInPolygon.min.js","scripts":{"bench":"npm run build && node test/bench.js","build":"rollup -c","test":"vitest"},"exports":{".":{"import":"./dist/esm/index.js","require":"./dist/cjs/index.cjs"}},"dependencies":{"robust-predicates":"^3.0.2"},"devDependencies":{"@rollup/plugin-buble":"^1.0.3","@rollup/plugin-node-resolve":"^15.3.0","@rollup/plugin-terser":"^0.4.4","benchmark":"^2.1.4","eslint":"^5.15.3","eslint-config-mourner":"^3.0.0","esm":"^3.2.20","load-json-file":"^5.2.0","point-in-polygon":"^1.0.1","robust-point-in-polygon":"^1.0.3","rollup":"^4.28.0","rollup-plugin-copy":"^3.5.0","vitest":"^2.1.6"},"keywords":["point-in-polygon","pip","point","polygon","inside"],"author":{"name":"Rowan Winsemius"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/rowanwins/point-in-polygon-hao.git"},"homepage":"https://github.com/rowanwins/point-in-polygon-hao","_id":"point-in-polygon-hao@1.2.4","gitHead":"c31c1e76f42b571cd732ec817134b42a70df8d8b","bugs":{"url":"https://github.com/rowanwins/point-in-polygon-hao/issues"},"_nodeVersion":"20.10.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-x2pcvXeqhRHlNRdhLs/tgFapAbSSe86wa/eqmj1G6pWftbEs5aVRJhRGM6FYSUERKu0PjekJzMq0gsI2XyiclQ==","shasum":"8662abdcc84bcca230cc3ecbb0b0ab1a306f1bd6","tarball":"http://registry-npm.ywwl.com/point-in-polygon-hao/download/point-in-polygon-hao-1.2.4.tgz","fileCount":9,"unpackedSize":28862,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGWVv7PVmuezSVV/DzeMNWjq9mFuf2+sa8RJqhpDP+pVAiBoOmLXxGXKMWBuXQXPYZETBiBTNr81TbDh/LqM/+XAFw=="}],"size":6646,"noattachment":false,"key":"/point-in-polygon-hao/-/point-in-polygon-hao-1.2.4.tgz"},"_npmUser":{"name":"rowanwins","email":"rowanwins@yahoo.com.au"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/point-in-polygon-hao_1.2.4_1734846882479_0.43931783113022194"},"_hasShrinkwrap":false,"readme":"A small library for detecting in a point lies inside a polygon\n\n**Features**\n- Works on polygons with holes\n- Works with degenerate/self-intersecting polyons \n- Returns `0` if on the edge\n- Not effected by floating point errors\n\n\n### Usage\nInstall via `npm install point-in-polygon-hao`\n\n````\nimport inside from 'point-in-polygon-hao'\n\nconst polygon = [\n  [\n    [1, 1],\n    [1, 2],\n    [2, 2],\n    [2, 1],\n    [1, 1]\n  ]\n];\n\ninside([ 1.5, 1.5 ], polygon)\n// => true\n\ninside([ 4.9, 1.2 ], polygon)\n// => false\n\ninside([1, 2], polygon)\n// => 0 to indicate on edge\n````\n\n**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.\n````\nconst polygonWithHole = [\n  [\n    [0, 0], [1, 0], [1, 1], [0, 1], [0, 0]\n  ],\n  [\n    [0.1, 0.1], [0.1, 0.9], [0.9, 0.9], [0.9, 0.1], [0.1, 0.1]\n  ]\n]\n````\nThe library does not support multi-polygons.\n\n### Comparisons\nSome rough comparisons to similar libraries. \nWhile `point-in-polygon` is slightly faster in most cases it does not support polygons with holes or degenerate polygons.\n\n````\n// For a point in a much larger geometry (700+ vertices)\npoint-in-poly-hao x 381,184 ops/sec ±0.80% (87 runs sampled)\npoint-in-polygon x 285,734 ops/sec ±1.33% (91 runs sampled)\nrobust-point-in-polygon x 267,738 ops/sec ±0.78% (93 runs sampled)\n````\n\n````\n// For a point in bounding box check\npoint-in-poly-hao x 25,822,227 ops/sec ±2.87% (86 runs sampled)\npoint-in-polygon x 30,321,920 ops/sec ±2.14% (91 runs sampled)\nrobust-point-in-polygon x 26,708,560 ops/sec ±1.13% (91 runs sampled)\n````\n\n### Algorithm\nThis library is based on the paper [Optimal Reliable Point-in-Polygon Test and\nDifferential Coding Boolean Operations on Polygons](https://www.researchgate.net/publication/328261365_Optimal_Reliable_Point-in-Polygon_Test_and_Differential_Coding_Boolean_Operations_on_Polygons)\n\n### Other notes\n* Works irrespective of winding order of polygon\n* ~~Does not appear to be effected by floating point errors compared to `point-in-polygon` or `robust-point-in-polygon`~~\n  * Added robust-predicates to deal with some floating point errors\n","publish_time":1734846882653,"maintainers":[{"name":"rowanwins","email":"rowanwins@yahoo.com.au"}],"_cnpm_publish_time":1734846882653,"dist-tags":{"latest":"1.2.4"}}