{"id":22129020,"url":"https://github.com/chrispahm/geos-wasm","last_synced_at":"2025-04-06T11:10:04.888Z","repository":{"id":176832759,"uuid":"659282069","full_name":"chrispahm/geos-wasm","owner":"chrispahm","description":"WASM + JS port of GEOS","archived":false,"fork":false,"pushed_at":"2025-01-10T08:28:33.000Z","size":16296,"stargazers_count":96,"open_issues_count":2,"forks_count":11,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-30T10:07:52.196Z","etag":null,"topics":["geospatial","geospatial-analysis","webassembly"],"latest_commit_sha":null,"homepage":"https://chrispahm.github.io/geos-wasm/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrispahm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-27T13:56:30.000Z","updated_at":"2025-03-26T18:57:13.000Z","dependencies_parsed_at":"2023-12-19T16:00:00.602Z","dependency_job_id":"b0d3d5de-67dd-40b7-b42b-ce16bf135669","html_url":"https://github.com/chrispahm/geos-wasm","commit_stats":{"total_commits":94,"total_committers":3,"mean_commits":"31.333333333333332","dds":"0.22340425531914898","last_synced_commit":"2cd08be9f21757449cf6e27b89889d03703ff796"},"previous_names":["chrispahm/geos-wasm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispahm%2Fgeos-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispahm%2Fgeos-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispahm%2Fgeos-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispahm%2Fgeos-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrispahm","download_url":"https://codeload.github.com/chrispahm/geos-wasm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247471521,"owners_count":20944158,"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":["geospatial","geospatial-analysis","webassembly"],"created_at":"2024-12-01T17:57:58.921Z","updated_at":"2025-04-06T11:10:04.865Z","avatar_url":"https://github.com/chrispahm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# geos-wasm\n\nThis is a WebAssembly build of [GEOS](https://github.com/libgeos/geos) using [Emscripten](https://emscripten.org/). It can be used in the browser or in Node.js, bun, or deno.\n\nGEOS is a C/C++ port of the [Java Topology Suite](\n  https://github.com/locationtech/jts\n), a library for performing operations on planar geometry.\nGEOS provides many of the algorithms used by [PostGIS](http://www.postgis.net/), the [Shapely](http://www.postgis.net/) package for Python, the [sf](https://github.com/r-spatial/sf) package for R, and others.\n\n[Demo](https://chrispahm.github.io/geos-wasm/examples/buffer) • [API Documentation](https://chrispahm.github.io/geos-wasm/)\n\n## Installation\n\n### Browser\n\n```html\n\u003cscript type=\"module\"\u003e\n  import initGeosJs from './build/package/geos.esm.js';\n  const geos = await initGeosJs();\n\u003c/script\u003e\n```\n\n### Node.js\n\n```js\nimport initGeosJs from './src/index.mjs';\nconst geos = await initGeosJs();\n```\n\n## Example\n\n```js\nimport initGeosJs from '../../build/package/geos.esm.js'\n// initGeosJs returns a promise that resolves to a GEOS object\nconst geos = await initGeosJs()\n\n// use the GEOS object to call GEOS functions\n// Example: get the area of a polygon\n// create a WKT reader\nconst reader = geos.GEOSWKTReader_create()\nconst wkt = 'POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))'\n// read the WKT string into a GEOS geometry -\u003e returns a pointer\nconst size = wkt.length + 1\nconst wktPtr = geos.Module._malloc(size)\ngeos.Module.stringToUTF8(wkt, wktPtr, size)\nconst geomPtr = geos.GEOSWKTReader_read(reader, wktPtr)\n// create a pointer where the area will be written to\nconst areaPtr = geos.Module._malloc(8)\n// calculate the area of the geometry\ngeos.GEOSArea(geomPtr, areaPtr)\n// read the area from the pointer into a JS number\nconst area = geos.Module.getValue(areaPtr, 'double')\n\nconsole.log(area) // area = 1\n\n// free the WKT reader, the geometry, and the pointers\ngeos.GEOSWKTReader_destroy(reader)\ngeos.GEOSGeom_destroy(geomPtr)\ngeos.GEOSFree(areaPtr)\ngeos.Module._free(wktPtr)\n```\n\n## API\n\nPlease refer to the\n[API documentation](https://chrispahm.github.io/geos-wasm/).\n\n## Development\n\n### Prerequisites\n\n- [Emscripten](https://emscripten.org/docs/getting_started/downloads.html)\n- [Node.js](https://nodejs.org/en/download/)\n- [Doxygen](https://www.doxygen.nl/download.html)\n\n### Compiling\n\nThe compiling process and overall project structure is largely copied from [gdal3](https://github.com/bugra9/gdal3.js)! Thanks for the great work!\n\n- Clone the repository.\n- Run `npm install`.\n- Run `npm run make` or `make`. Run `make type=debug` for a debug version.\n\n### Testing\n\n```sh\nnpm test\n```\n\n### Contribution\n\nContributions are welcome!\nPlease open an issue in order to discuss contributions before submitting a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrispahm%2Fgeos-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrispahm%2Fgeos-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrispahm%2Fgeos-wasm/lists"}