{"name":"polyclip-ts","description":"Apply boolean polygon clipping operations (intersection, union, difference, xor) to your Polygons & MultiPolygons.","version":"0.16.8","author":{"name":"Luiz Felipe Machado Barboza"},"license":"MIT","type":"module","main":"dist/esm/index.js","module":"dist/esm/index.js","jsdelivr":"dist/polyclip-ts.umd.min.js","unpkg":"dist/polyclip-ts.umd.min.js","types":"dist/esm/index.d.ts","exports":{"umd":"./dist/polyclip-ts.umd.min.js","import":"./dist/esm/index.js","require":"./dist/cjs/index.cjs","default":"./dist/cjs/index.cjs"},"keywords":["polygon","clipping","boolean","intersection","union","difference","xor","geometry","martinez"],"repository":{"type":"git","url":"git+https://github.com/luizbarboza/polyclip-ts.git"},"scripts":{"preversion":"npm run test","version":"npm run build && git add -A","postversion":"git push && git push --tags && npm publish","build":"rollup -c && tsup","test":"npm run test:typecheck && npm run test:lint && npm run test:jest","test:lint":"eslint src","test:typecheck":"tsc --noEmit","test:jest":"jest","bench":"node bench/bench.js"},"devDependencies":{"@babel/preset-env":"^7.19.0","@babel/preset-typescript":"^7.18.6","@rollup/plugin-json":"4","@rollup/plugin-node-resolve":"13","@rollup/plugin-terser":"^0.4.1","@rollup/plugin-typescript":"^8.5.0","@types/node":"^18.8.5","@typescript-eslint/eslint-plugin":"^5.25.0","@typescript-eslint/parser":"^5.25.0","benchmark":"^2.1.4","eslint":"^8.16.0","eslint-config-prettier":"^8.5.0","jest":"^27.5.1","jsts":"^2.12.1","martinez-polygon-clipping":"^0.7.1","tsup":"^8.3.5"},"dependencies":{"bignumber.js":"^9.1.0","splaytree-ts":"^1.0.2"},"_id":"polyclip-ts@0.16.8","gitHead":"e34774a63042aaf11dc0293885b37d720e21cbc6","bugs":{"url":"https://github.com/luizbarboza/polyclip-ts/issues"},"homepage":"https://github.com/luizbarboza/polyclip-ts#readme","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-JPtKbDRuPEuAjuTdhR62Gph7Is2BS1Szx69CFOO3g71lpJDFo78k4tFyi+qFOMVPePEzdSKkpGU3NBXPHHjvKQ==","shasum":"503160d05e9d56380533aab0bc2dae835d6da5f9","tarball":"http://registry-npm.ywwl.com/polyclip-ts/download/polyclip-ts-0.16.8.tgz","fileCount":11,"unpackedSize":462878,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCjwOuV4FrIOn0oAEWtXw8kgAmIJiBdSvL/t6zMDu8+XgIhAODtphcjxvBiU3dXoUFWLCUzARSVwSyxNTZjsxo8Q7J2"}],"size":115162,"noattachment":false,"key":"/polyclip-ts/-/polyclip-ts-0.16.8.tgz"},"_npmUser":{"name":"luizbarboza","email":"contact@luizbarboza.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/polyclip-ts_0.16.8_1734402759786_0.03524631378557741"},"_hasShrinkwrap":false,"readme":"# polyclip-ts\n\nApply boolean polygon clipping operations (`intersection`, `union`, `difference`, `xor`) to your Polygons & MultiPolygons.\n\n## Installing\n\nIf you use npm, `npm install polyclip-ts`. You can also download the [latest release on GitHub](https://github.com/luizbarboza/polyclip-ts/tags). For vanilla HTML in modern browsers, import polyclip-ts from Skypack:\n\n```html\n<script type=\"module\">\nimport * as polyclip from \"https://cdn.skypack.dev/polyclip-ts\";\n\npolyclip.intersection(…)\n</script>\n```\n\nFor legacy environments, you can load polyclip-ts’s UMD bundle from an npm-based CDN such as jsDelivr; a polyclip global is exported:\n\n```html\n<script src=\"https://cdn.jsdelivr.net/npm/polyclip-ts/dist/polyclip-ts.umd.min.js\"></script>\n<script>\npolyclip.intersection(…)\n</script>\n```\n\n## Quickstart\n\n<!-- prettier-ignore-start -->\n```javascript\nimport * as polyclip from \"polyclip-ts\"\n\nconst poly1 = [[[0,0],[2,0],[0,2],[0,0]]]\nconst poly2 = [[[-1,0],[1,0],[0,1],[-1,0]]]\n\npolyclip.union       (poly1, poly2 /* , poly3, ... */)\npolyclip.intersection(poly1, poly2 /* , poly3, ... */)\npolyclip.xor         (poly1, poly2 /* , poly3, ... */)\npolyclip.difference  (poly1, poly2 /* , poly3, ... */)\n```\n<!-- prettier-ignore-end -->\n\n## API\n\n```javascript\n/* All functions take one or more [multi]polygon(s) as input */\n\npolyclip.union       (geom, ...moreGeoms)\npolyclip.intersection(geom, ...moreGeoms)\npolyclip.xor         (geom, ...moreGeoms)\n\n/* The moreGeoms will be subtracted from the geom */\npolyclip.difference  (geom, ...moreGeoms)\n```\n\n### Input\n\nEach positional argument (`geom`) may be either a Polygon or a MultiPolygon. The [GeoJSON spec](https://tools.ietf.org/html/rfc7946#section-3.1) is followed, with the following notes/modifications:\n\n- MultiPolygons may contain touching or overlapping Polygons.\n- rings are not required to be self-closing.\n- rings may contain repeated points, which are ignored.\n- rings may be self-touching and/or self-crossing. Self-crossing rings will be interpreted using the [non-zero rule](https://en.wikipedia.org/wiki/Nonzero-rule).\n- winding order of rings does not matter.\n- inner rings may extend outside their outer ring. The portion of inner rings outside their outer ring is dropped.\n- inner rings may touch or overlap each other.\n\n### Output\n\nFor non-empty results, output will always be a MultiPolygon containing one or more non-overlapping, non-edge-sharing Polygons. The [GeoJSON spec](https://tools.ietf.org/html/rfc7946#section-3.1) is followed, with the following notes/modifications:\n\n- outer rings will be wound counter-clockwise, and inner rings clockwise.\n- inner rings will not extend outside their outer ring.\n- rings will not overlap, nor share an edge with each other.\n- rings will be self-closing.\n- rings will not contain repeated points.\n- rings will not contain superfluous points (intermediate points along a straight line).\n- rings will not be self-touching nor self-crossing.\n- rings _may_ touch each other, but _may not_ cross each other.\n\nIn the event that the result of the operation is the empty set, output will be a MultiPolygon with no Polygons: `[]`.\n\n## Correctness\n\nRun: `npm test`\n\nThe tests are broken up into unit tests and end-to-end tests. The end-to-end tests are organized as GeoJSON files, to make them easy to visualize thanks to [GitHub's helpful rendering of GeoJSON files](https://help.github.com/articles/mapping-geojson-files-on-github/). Browse those tests [here](test/end-to-end).\n\n## Performance\n\nThe Martinez-Rueda-Feito polygon clipping algorithm is used to compute the result in `O((n+k)*log(n))` time, where `n` is the total number of edges in all polygons involved and `k` is the number of intersections between edges.\n\n## Authors\n\n- [Luiz F. M. Barboza](https://github.com/SBanksX)\n- [Mike Fogel](https://github.com/mfogel)\n- [Alexander Milevski](https://github.com/w8r)\n- [Vladimir Ovsyannikov](https://github.com/sh1ng)\n\n## Based on\n\n- [A simple algorithm for Boolean operations on polygons](https://www.sciencedirect.com/science/article/abs/pii/S0965997813000379) by Francisco Martinez, Antonio Jesus Rueda, Francisco Ramon Feito (2009)\n","publish_time":1734402760000,"maintainers":[{"name":"luizbarboza","email":"contact@luizbarboza.com"}],"_cnpm_publish_time":1734402760000,"dist-tags":{"latest":"0.16.8"}}