{"id":20854364,"url":"https://github.com/w8r/greinerhormann","last_synced_at":"2025-04-05T00:05:42.050Z","repository":{"id":19273454,"uuid":"22509953","full_name":"w8r/GreinerHormann","owner":"w8r","description":"Greiner-Hormann polygon clipping algorithm. Does AND, OR, XOR. Plays nicely with Leaflet. Handles non-convex polygons and multiple clipping areas. ~3kb footprint, no dependencies","archived":false,"fork":false,"pushed_at":"2023-04-15T21:28:20.000Z","size":1827,"stargazers_count":240,"open_issues_count":15,"forks_count":34,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-28T23:04:29.230Z","etag":null,"topics":["algorithm","computational-geometry","leaflet","polygon-clipping","polygon-intersection","polygon-union"],"latest_commit_sha":null,"homepage":"http://w8r.github.io/GreinerHormann/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/w8r.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"w8r","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2014-08-01T12:59:28.000Z","updated_at":"2024-12-17T13:06:24.000Z","dependencies_parsed_at":"2022-08-31T01:51:14.721Z","dependency_job_id":"e569de17-0161-4b31-81fa-ca1063d721f5","html_url":"https://github.com/w8r/GreinerHormann","commit_stats":{"total_commits":50,"total_committers":4,"mean_commits":12.5,"dds":0.09999999999999998,"last_synced_commit":"bcce8e4f4619497e6458409ca78fbc5a878eaa3d"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2FGreinerHormann","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2FGreinerHormann/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2FGreinerHormann/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2FGreinerHormann/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/w8r","download_url":"https://codeload.github.com/w8r/GreinerHormann/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266562,"owners_count":20910836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","computational-geometry","leaflet","polygon-clipping","polygon-intersection","polygon-union"],"created_at":"2024-11-18T03:25:29.710Z","updated_at":"2025-04-05T00:05:42.028Z","avatar_url":"https://github.com/w8r.png","language":"JavaScript","funding_links":["https://github.com/sponsors/w8r"],"categories":[],"sub_categories":[],"readme":"[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)\nGreiner-Hormann polygon clipping\n================================\n\n * Does AND, OR, difference (intersection, union, difference, if you're human)\n * Plays nicely with [Leaflet](http://github.com/leaflet/leaflet/), comes with an adaptor for it\n * Handles non-convex polygons and multiple clipping areas\n * ~3kb compressed, no dependencies\n\n[Demo and documentation](http://w8r.github.io/GreinerHormann/)\n\n**Note:** If you are looking for something more powerful, take a look at the [Martinez polygon clipping](https://github.com/w8r/martinez) implementation.\n\n## Install\n```bash\n$ npm install greiner-hormann\n```\n\nBrowserify\n```js\nvar greinerHormann = require('greiner-hormann');\n```\n\nBrowser\n```html\n\u003cscript src=\"path/to/greiner-hormann(.leaflet).min.js\"\u003e\u003c/script\u003e\n```\n\n## Use\n```js\n...\nvar intersection = greinerHormann.intersection(source, clip);\nvar union        = greinerHormann.union(source, clip);\nvar diff         = greinerHormann.diff(source, clip);\n\n...\n\nif(intersection){\n    if(typeof intersection[0][0] === 'number'){ // single linear ring\n        intersection = [intersection];\n    }\n    for(var i = 0, len = intersection.length; i \u003c len; i++){\n        L.polygon(intersection[i], {...}).addTo(map);\n    }\n}\n```\n\n## Format\nInput and output can be `{x:x, y:y}` objects or `[x,y]` pairs. It will output the points in the same format you put in.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fw8r%2Fgreinerhormann","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fw8r%2Fgreinerhormann","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fw8r%2Fgreinerhormann/lists"}