{"id":15761620,"url":"https://github.com/alrico88/wkt-parser-helper","last_synced_at":"2025-04-30T15:50:01.115Z","repository":{"id":57398594,"uuid":"238900025","full_name":"alrico88/wkt-parser-helper","owner":"alrico88","description":"Module to help parse GeoJSONs to WKT and back","archived":false,"fork":false,"pushed_at":"2025-04-25T10:53:00.000Z","size":377,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T15:49:43.248Z","etag":null,"topics":["buffer","geojson","javascript","parser","parses","wkb","wkt"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/wkt-parser-helper","language":"TypeScript","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/alrico88.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-07T10:47:34.000Z","updated_at":"2025-04-25T10:53:01.000Z","dependencies_parsed_at":"2024-10-04T11:04:35.768Z","dependency_job_id":"d795db06-586f-44d9-a5df-b8ea2f0c4768","html_url":"https://github.com/alrico88/wkt-parser-helper","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"f4854dce81552dca38e357d081f3713b3f6329f3"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fwkt-parser-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fwkt-parser-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fwkt-parser-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fwkt-parser-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alrico88","download_url":"https://codeload.github.com/alrico88/wkt-parser-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251734533,"owners_count":21635151,"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":["buffer","geojson","javascript","parser","parses","wkb","wkt"],"created_at":"2024-10-04T11:03:13.736Z","updated_at":"2025-04-30T15:50:01.067Z","avatar_url":"https://github.com/alrico88.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wkt-parser-helper\n\nConvert and parse between Well-Known-Text (WKT) and GeoJSON\n\n## Installation\n\nUsing npm `npm i wkt-parser-helper`\n\nUsing yarn `yarn add wkt-parser-helper`\n\n## Usage\n\nIn CommonJS env\n\n```javascript\nconst { parseFromWK } = require('wkt-parser-helper');\n\nconst geojson = parseFromWK(\n  'POLYGON ((-3.706512451171875 40.420074462890625, -3.70513916015625 40.420074462890625, -3.70513916015625 40.42144775390625, -3.706512451171875 40.42144775390625, -3.706512451171875 40.420074462890625))'\n);\n\n// geojson is a Polygon Geometry\n```\n\nUsing imports\n\n```javascript\nimport { convertToWK } from 'wkt-parser-helper';\n\nconst myFeature: Feature = {\n  type: 'Feature',\n  properties: {},\n  geometry: {\n    type: 'Polygon',\n    coordinates: [\n      [\n        [-3.706512451171875, 40.420074462890625],\n        [-3.70513916015625, 40.420074462890625],\n        [-3.70513916015625, 40.42144775390625],\n        [-3.706512451171875, 40.42144775390625],\n        [-3.706512451171875, 40.420074462890625],\n      ],\n    ],\n  },\n};\n\nconst myFeatureAsWKT = convertToWK(myFeature);\n\n// myFeatureAsWKT is 'POLYGON ((-3.706512451171875 40.420074462890625, -3.70513916015625 40.420074462890625, -3.70513916015625 40.42144775390625, -3.706512451171875 40.42144775390625, -3.706512451171875 40.420074462890625))'\n```\n\n## Breaking changes\n\nFrom v4.0.0 onwards, support for converting GeoJSON to WKB is dropped.\n\n## Table of contents\n\n### Functions\n\n- [convertFeatureCollection](#convertfeaturecollection)\n- [convertFeatureToWK](#convertfeaturetowk)\n- [convertGeometryToWK](#convertgeometrytowk)\n- [convertFeatureCollectionToWktCollection](#convertFeatureCollectionToWktCollection)\n- [convertToWK](#converttowk)\n- [parseFromWK](#parsefromwk)\n\n## Functions\n\n### convertFeatureCollection\n\n▸ **convertFeatureCollection**(`featureCollection`: FeatureCollection): _string_\n\nConverts a GeoJSON FeatureCollection to WKT GeometryCollection\n\n**`export`**\n\n#### Parameters:\n\n| Name                | Type              | Description                             |\n| :------------------ | :---------------- | :-------------------------------------- |\n| `featureCollection` | FeatureCollection | The FeatureCollection to convert to WKT |\n\n**Returns:** _string_\n\nThe GeoJSON converted to well known representation\n\n---\n\n### convertFeatureToWK\n\n▸ **convertFeatureToWK**(`geojson`: Feature): _string_\n\nConverts GeoJSON Feature to WKT\n\n**`export`**\n\n#### Parameters:\n\n| Name      | Type    | Description               |\n| :-------- | :------ | :------------------------ |\n| `geojson` | Feature | Feature object to convert |\n\n**Returns:** _string_\n\nThe GeoJSON converted to well known text representation\n\n---\n\n### convertGeometryToWK\n\n▸ **convertGeometryToWK**(`geojson`: Geometry): _string_\n\nConverts GeoJSON Geometry to WKT\n\n**`export`**\n\n#### Parameters:\n\n| Name      | Type     | Description                |\n| :-------- | :------- | :------------------------- |\n| `geojson` | Geometry | Geometry object to convert |\n\n**Returns:** _string_\n\nThe GeoJSON converted to well known text representation\n\n---\n\n### convertFeatureCollectionToWktCollection\n\n▸ **convertFeatureCollectionToWktCollection**\u003cP\\\u003e(`geojson`: _FeatureCollection_\u003cGeometry, P\\\u003e): P \u0026 { `wkt`: _string_ }[]\n\nConverts a GeoJSON FeatureCollection into an array of objects where each object\ncontains a WKT (Well-Known Text) string representing the geometry and the properties\nfrom the original GeoJSON feature\n\n#### Type parameters:\n\n| Name | Description                                    |\n| :--- | :--------------------------------------------- |\n| `P`  | The type of properties in the GeoJSON features |\n\n#### Parameters:\n\n| Name      | Type                              | Description                                   |\n| :-------- | :-------------------------------- | :-------------------------------------------- |\n| `geojson` | _FeatureCollection_\u003cGeometry, P\\\u003e | The GeoJSON FeatureCollection to be converted |\n\n**Returns:** P \u0026 { `wkt`: _string_ }[]\n\n)[]} An array of objects where each object contains a `wkt` string\nrepresenting the geometry and all the properties from the original GeoJSON feature\n\n---\n\n### convertToWK\n\n▸ **convertToWK**(`geojson`: GeoJSON): _string_\n\nShorthand to convert GeoJSON Features, Geometries or FeatureCollections to WKT or WKB\n\n**`export`**\n\n#### Parameters:\n\n| Name      | Type    | Description            |\n| :-------- | :------ | :--------------------- |\n| `geojson` | GeoJSON | The GeoJSON to convert |\n\n**Returns:** _string_\n\nThe GeoJSON as WKT\n\n---\n\n### parseFromWK\n\n▸ **parseFromWK**(`item`: _string_, `asFeature?`: _boolean_, `properties?`: GeoJsonProperties): Feature \\| Geometry\n\nParse a WKT or WKB into a GeoJSON Feature or Geometry\n\n**`export`**\n\n#### Parameters:\n\n| Name         | Type              | Default value | Description                   |\n| :----------- | :---------------- | :------------ | :---------------------------- |\n| `item`       | _string_          | -             | The WKT to convert to GeoJSON |\n| `asFeature`  | _boolean_         | false         | -                             |\n| `properties` | GeoJsonProperties | -             | -                             |\n\n**Returns:** Feature \\| Geometry\n\nThe WKT as GeoJSON\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falrico88%2Fwkt-parser-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falrico88%2Fwkt-parser-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falrico88%2Fwkt-parser-helper/lists"}