{"name":"point-in-polygon-hao","version":"1.2.0","keywords":["point-in-polygon","pip","point","polygon","inside"],"author":{"name":"Rowan Winsemius"},"license":"MIT","_id":"point-in-polygon-hao@1.2.0","homepage":"https://github.com/rowanwins/point-in-polygon-hao","bugs":{"url":"https://github.com/rowanwins/point-in-polygon-hao/issues"},"dist":{"shasum":"d3aee090051c9766bea1ad853a60062a244616c7","tarball":"http://registry-npm.ywwl.com/point-in-polygon-hao/download/point-in-polygon-hao-1.2.0.tgz","fileCount":12,"integrity":"sha512-CZ7lsIwBeaWmsCUNY/zFiUFKdSg/X8ngMOhiTGW78iUB8frZm44TiDlLFN1xqJ0GI22hSJg2/SpzS+t/qrGvug==","signatures":[{"sig":"MEYCIQDkLSbr13vmwSHLVYDfGXV7p5iuVPmgV9XMM9joawX6LgIhAK2ENmNvnXjMK2+TUZJ6Mi7FqQalJvGBDp6q6ry+udfq","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11476,"size":4424,"noattachment":false,"key":"/point-in-polygon-hao/-/point-in-polygon-hao-1.2.0.tgz"},"main":"dist/pointInPolygon.mjs","type":"module","types":"index.d.ts","unpkg":"dist/pointInPolygon.min.js","module":"dist/pointInPolygon.mjs","gitHead":"beee5d63d3646ef39529c88fef69adcf3b5d5a4d","scripts":{"test":"vitest","bench":"npm run build && node test/bench.js","build":"rollup -c"},"_npmUser":{"name":"rowanwins","email":"rowanwins@yahoo.com.au"},"jsdelivr":"dist/pointInPolygon.min.js","repository":{"url":"git+https://github.com/rowanwins/point-in-polygon-hao.git","type":"git"},"_npmVersion":"10.2.3","description":"A point in polygon based on the paper Optimal Reliable Point-in-Polygon Test and Differential Coding Boolean Operations on Polygons","directories":{},"_nodeVersion":"20.10.0","dependencies":{"robust-predicates":"^3.0.2"},"_hasShrinkwrap":false,"devDependencies":{"esm":"^3.2.20","eslint":"^5.15.3","rollup":"^1.7.0","vitest":"^2.1.6","benchmark":"^2.1.4","load-json-file":"^5.2.0","point-in-polygon":"^1.0.1","@rollup/plugin-buble":"^0.21.3","rollup-plugin-terser":"^4.0.4","eslint-config-mourner":"^3.0.0","robust-point-in-polygon":"^1.0.3"},"_npmOperationalInternal":{"tmp":"tmp/point-in-polygon-hao_1.2.0_1732789983096_0.27013512992689526","host":"s3://npm-registry-packages"},"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":1732789983277,"maintainers":[{"name":"rowanwins","email":"rowanwins@yahoo.com.au"}],"_cnpm_publish_time":1732789983277,"dist-tags":{"latest":"1.2.4"}}