{"id":13426479,"url":"https://github.com/NickCis/polygonize","last_synced_at":"2025-03-15T21:31:16.498Z","repository":{"id":50269534,"uuid":"92683740","full_name":"NickCis/polygonize","owner":"NickCis","description":"Javascript Implementation of GEOS's Polygonize function","archived":false,"fork":false,"pushed_at":"2017-11-24T01:57:46.000Z","size":90,"stargazers_count":18,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-02T11:23:25.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/NickCis.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":"2017-05-28T19:56:34.000Z","updated_at":"2022-09-18T00:24:15.000Z","dependencies_parsed_at":"2022-09-13T19:00:54.147Z","dependency_job_id":null,"html_url":"https://github.com/NickCis/polygonize","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NickCis%2Fpolygonize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NickCis%2Fpolygonize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NickCis%2Fpolygonize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NickCis%2Fpolygonize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NickCis","download_url":"https://codeload.github.com/NickCis/polygonize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243792372,"owners_count":20348633,"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":[],"created_at":"2024-07-31T00:01:35.756Z","updated_at":"2025-03-15T21:31:16.194Z","avatar_url":"https://github.com/NickCis.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Polygonize\n\n[![Build Status](https://travis-ci.org/NickCis/polygonize.svg?branch=master)](https://travis-ci.org/NickCis/polygonize)\n\nPolygonizes a set of Geometrys which contain linework that represents the edges of a planar graph. It's basically an implementation of [GEOS's Polygonizer](https://github.com/echoz/xlibspatialite/blob/master/geos/include/geos/operation/polygonize/Polygonizer.h).\n\nAlthough, the algorithm is the same as GEOS, it isn't a literal transcription of the C++ source code. It was rewriten in order to get a more javascript like code.\n\n## JSDoc\n\n```javascript\n/**\n * Polygonizes {@link LineString|(Multi)LineString(s)} into {@link Polygons}.\n *\n * Implementation of GEOSPolygonize function (`geos::operation::polygonize::Polygonizer`).\n *\n * Polygonizes a set of lines that represents edges in a planar graph. Edges must be correctly\n * noded, i.e., they must only meet at their endpoints.\n *\n * The implementation correctly handles:\n *\n * - Dangles: edges which have one or both ends which are not incident on another edge endpoint.\n * - Cut Edges (bridges): edges that are connected at both ends but which do not form part of a polygon.\n *\n * @name polygonize\n * @param {FeatureCollection|Geometry|Feature\u003cLineString|MultiLineString\u003e} geoJson Lines in order to polygonize\n * @returns {FeatureCollection\u003cPolygon\u003e} Polygons created\n * @throws {Error} if geoJson is invalid.\n */\n```\n\n## Example\n\nThis example is the test found in [`test/in/complex.geojson`](https://github.com/NickCis/polygonize/blob/master/test/in/complex.geojson).\n\n\n```javascript\nconst polygonize = require('polygonize'),\n    fs = require('fs'),\n    input = JSON.parse(fs.readFileSync('./test/in/complex.geojson'));\n\nconsole.log(JSON.stringify(polygonize(input)));\n```\n\nThe [input](https://github.com/NickCis/polygonize/blob/master/test/in/complex.geojson) as GeoJson LineString:\n\n![](https://cloud.githubusercontent.com/assets/174561/26525683/c30957de-4335-11e7-8eb9-bf72f268efb8.png)\n\nTurned into [polygons](https://github.com/NickCis/polygonize/blob/master/test/out/complex.geojson):\n\n![](https://cloud.githubusercontent.com/assets/174561/26525695/24f5270c-4336-11e7-9b62-60db8c0c9a28.png)\n\n\n## Documentation\n\nPolygonizes [(Multi)LineString(s)](http://geojson.org/geojson-spec.html#linestring) into [Polygons](Polygons).\n\nImplementation of GEOSPolygonize function (`geos::operation::polygonize::Polygonizer`).\n\nPolygonizes a set of lines that represents edges in a planar graph. Edges must be correctly noded, i.e., they must only meet at their endpoints.\n\nThe implementation correctly handles:\n\n-   Dangles: edges which have one or both ends which are not incident on another edge endpoint.\n-   Cut Edges (bridges): edges that are connected at both ends but which do not form part of a polygon.\n\n**Parameters**\n\n-   `geojson` **([FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) \\| [Geometry](http://geojson.org/geojson-spec.html#geometry) \\| [Feature](http://geojson.org/geojson-spec.html#feature-objects)\u0026lt;([LineString](http://geojson.org/geojson-spec.html#linestring) \\| [MultiLineString](http://geojson.org/geojson-spec.html#multilinestring))\u003e)** Lines in order to polygonize\n\n\n-   Throws **[Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)** if geoJson is invalid.\n\nReturns **[FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects)\u0026lt;[Polygon](http://geojson.org/geojson-spec.html#polygon)\u003e** Polygons created\n\n### Installation\n\nInstall this module individually:\n\n```sh\n$ npm install polygonize\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNickCis%2Fpolygonize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNickCis%2Fpolygonize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNickCis%2Fpolygonize/lists"}