{"id":13593450,"url":"https://github.com/sromku/polygon-contains-point","last_synced_at":"2025-04-09T04:34:15.790Z","repository":{"id":7205596,"uuid":"8510824","full_name":"sromku/polygon-contains-point","owner":"sromku","description":"Point in polygon - Check if the point inside the polygon","archived":true,"fork":false,"pushed_at":"2019-03-25T17:10:36.000Z","size":106,"stargazers_count":292,"open_issues_count":8,"forks_count":102,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-11-06T15:42:47.862Z","etag":null,"topics":["java","polygons"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sromku.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-01T21:39:56.000Z","updated_at":"2024-10-27T19:09:57.000Z","dependencies_parsed_at":"2022-08-24T20:10:23.046Z","dependency_job_id":null,"html_url":"https://github.com/sromku/polygon-contains-point","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sromku%2Fpolygon-contains-point","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sromku%2Fpolygon-contains-point/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sromku%2Fpolygon-contains-point/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sromku%2Fpolygon-contains-point/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sromku","download_url":"https://codeload.github.com/sromku/polygon-contains-point/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247980829,"owners_count":21027803,"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":["java","polygons"],"created_at":"2024-08-01T16:01:20.444Z","updated_at":"2025-04-09T04:34:14.952Z","avatar_url":"https://github.com/sromku.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"polygon-contains-point\n======================\n\nThe point-in-polygon (PIP) problem asks whether a given point in the plane lies inside, outside, or on the boundary of a polygon.\nWiki reference: [Point in polygon](http://en.wikipedia.org/wiki/Point_in_polygon)\n\n## Latest Release\n\n:inbox_tray: Download - [polygon-1.0.2.jar](https://github.com/sromku/polygon-contains-point/releases/download/1.0.2/polygon-1.0.2.jar)\n\n:bookmark_tabs: Changelog - https://github.com/sromku/polygon-contains-point/releases/latest\n\n## Algorith\nThe number of intersections for a ray passing from the exterior of the polygon to any point; if odd, it shows that the point lies inside the polygon. If it is even, the point lies outside the polygon.\n\n\u003cimg src=\"/assets/simple_polygon.png\"/\u003e\n\n## Usage\n\n### Build Polygon\n\nThis is the simple version of the polygon. You can build both types of polygons: [concave and non-convex](http://en.wikipedia.org/wiki/Convex_and_concave_polygons)\n``` java\nPolygon polygon = Polygon.Builder()\n        .addVertex(new Point(1, 3))\n        .addVertex(new Point(2, 8))\n        .addVertex(new Point(5, 4))\n        .addVertex(new Point(5, 9))\n        .addVertex(new Point(7, 5))\n        .addVertex(new Point(6, 1))\n        .addVertex(new Point(3, 1))\n        .build();\n```\n\n### Build Polygon with Holes\n\nFirst build all the border sides of the polygon. Close the borders and then you can start adding holes into the polygon.\nYou can add multiple number of holes, just remember to `close()` after each added hole. \n``` java\nPolygon polygon = Polygon.Builder()\n        .addVertex(new Point(1, 2)) // polygon\n        .addVertex(new Point(1, 6))\n        .addVertex(new Point(8, 7))\n        .addVertex(new Point(8, 1))\n        .close() \n        .addVertex(new Point(2, 3)) // hole one\n        .addVertex(new Point(5, 5))\n        .addVertex(new Point(6, 2))\n        .close() \n        .addVertex(new Point(6, 6)) // hole two\n        .addVertex(new Point(7, 6))\n        .addVertex(new Point(7, 5))\n        .build();\n```\n\n\u003cimg src=\"/assets/polygon_with_holes.png\"/\u003e\n\n### Check if the point inside\n\n``` java\nPoint point = new Point(4.5f, 7);\nboolean contains = polygon.contains(point);\n```\n\n## Tests\n\nTwo main tests are attached (not in junit format). Both tests cover polygons with holes and without.\n\n## License\n\nApache 2.0. See [LICENSE](LICENSE)\n\n## Follow us\n\n[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=https://github.com/snatik/polygon-contains-point)\n[![Twitter Follow](https://img.shields.io/twitter/follow/snatikteam.svg?style=social)](https://twitter.com/snatikteam)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsromku%2Fpolygon-contains-point","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsromku%2Fpolygon-contains-point","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsromku%2Fpolygon-contains-point/lists"}