wkt-parser-helper
Advanced tools
Comparing version 2.0.0 to 3.0.0
{ | ||
"name": "wkt-parser-helper", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"keywords": [ | ||
"wkt", | ||
"wkb", | ||
"geojson", | ||
"parser", | ||
"FeatureCollection" | ||
"GeoJSON", | ||
"GeometryCollection", | ||
"FeatureCollection", | ||
"well-known-text" | ||
], | ||
"description": "Module to help parse GeoJSONs to WKT and back", | ||
"main": "index.js", | ||
"repository": "https://github.com/alrico88/wkt-parser-helper", | ||
"main": "dist/index.js", | ||
"module": "dist/wkt-parser-helper.esm.js", | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"repository": { | ||
"url": "https://github.com/alrico88/wkt-parser-helper" | ||
}, | ||
"author": "Alberto Rico", | ||
"license": "MIT", | ||
"dependencies": { | ||
"wkx": "^0.4.8" | ||
"wkx": "^0.5.0" | ||
}, | ||
"sideEffects": false, | ||
"devDependencies": { | ||
"eslint": "^5.4", | ||
"jest": "^25.1.0" | ||
"@types/geojson": "^7946.0.7", | ||
"@typescript-eslint/eslint-plugin": "^4.17.0", | ||
"@typescript-eslint/parser": "^4.17.0", | ||
"babel-jest": "^26.6.3", | ||
"eslint": "^7.22.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"husky": "^5.1.3", | ||
"jest": "^25.1.0", | ||
"tsdx": "^0.14.1", | ||
"tslib": "^2.1.0", | ||
"typedoc": "^0.20.30", | ||
"typedoc-plugin-markdown": "^3.6.0", | ||
"typescript": "^4.2.3" | ||
}, | ||
"scripts": { | ||
"test": "jest", | ||
"prepublish": "jest" | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"test": "tsdx test", | ||
"lint": "tsdx lint", | ||
"prepare": "tsdx build", | ||
"docs": "typedoc src/index.ts --readme", | ||
"coveralls": "tsdx test --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "tsdx lint" | ||
} | ||
}, | ||
"prettier": { | ||
"printWidth": 80, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
} | ||
} |
204
README.md
@@ -1,69 +0,185 @@ | ||
<a name="WktParserHelper"></a> | ||
# wkt-parser-helper | ||
## WktParserHelper | ||
## Installation | ||
**Kind**: global class | ||
Using npm `npm i wkt-parser-helper` | ||
- [WktParserHelper](#WktParserHelper) | ||
- [new WktParserHelper()](#new_WktParserHelper_new) | ||
- ~~[.convertPolygonToWK()](#WktParserHelper.convertPolygonToWK)~~ | ||
- [.convertToWK(GeoJSON, [type])](#WktParserHelper.convertToWK) ⇒ <code>string</code> \| <code>Buffer</code> | ||
- [.parseFromWK(item, [asFeature], [properties])](#WktParserHelper.parseFromWK) ⇒ <code>object</code> | ||
- [.convertFeatureCollection(GeoJSON)](#WktParserHelper.convertFeatureCollection) ⇒ <code>string</code> | ||
Using yarn `yarn add wkt-parser-helper` | ||
<a name="new_WktParserHelper_new"></a> | ||
## Usage | ||
### new WktParserHelper() | ||
In CommonJS env | ||
WktParserHelper class | ||
```javascript | ||
const { parseFromWK } = require('wkt-parser-helper'); | ||
<a name="WktParserHelper.convertPolygonToWK"></a> | ||
const geojson = parseFromWK( | ||
'POLYGON((-3.706512451171875 40.420074462890625,-3.70513916015625 40.420074462890625,-3.70513916015625 40.42144775390625,-3.706512451171875 40.42144775390625,-3.706512451171875 40.420074462890625))' | ||
); | ||
### ~~WktParserHelper.convertPolygonToWK()~~ | ||
// geojson is a Polygon Geometry | ||
``` | ||
**_Deprecated_** | ||
Using imports | ||
Converts GeoJSON to Wkt or Wkb | ||
```javascript | ||
import { convertToWK } from 'wkt-parser-helper'; | ||
**Kind**: static method of [<code>WktParserHelper</code>](#WktParserHelper) | ||
<a name="WktParserHelper.convertToWK"></a> | ||
const myFeature: Feature = { | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: { | ||
type: 'Polygon', | ||
coordinates: [ | ||
[ | ||
[-3.706512451171875, 40.420074462890625], | ||
[-3.70513916015625, 40.420074462890625], | ||
[-3.70513916015625, 40.42144775390625], | ||
[-3.706512451171875, 40.42144775390625], | ||
[-3.706512451171875, 40.420074462890625], | ||
], | ||
], | ||
}, | ||
}; | ||
### WktParserHelper.convertToWK(GeoJSON, [type]) ⇒ <code>string</code> \| <code>Buffer</code> | ||
const myFeatureAsWKT = convertToWK(myFeature, 'wkt'); | ||
Converts GeoJSON to WKT or WKB | ||
// myFeatureAsWKT is 'POLYGON((-3.706512451171875 40.420074462890625,-3.70513916015625 40.420074462890625,-3.70513916015625 40.42144775390625,-3.706512451171875 40.42144775390625,-3.706512451171875 40.420074462890625))' | ||
``` | ||
**Kind**: static method of [<code>WktParserHelper</code>](#WktParserHelper) | ||
**Returns**: <code>string</code> \| <code>Buffer</code> - WKT or WKB | ||
## Table of contents | ||
| Param | Type | Default | Description | | ||
| ------- | ------------------------------------------------------------ | ---------------------------- | -------------------------------- | | ||
| GeoJSON | <code>Object</code> | | GeoJSON to convert to WKT or WKB | | ||
| [type] | <code>'wkt'</code> \| <code>'wkb'</code> | <code>'wkt'</code> | | | ||
### Type aliases | ||
<a name="WktParserHelper.parseFromWK"></a> | ||
- [WKType](#wktype) | ||
### WktParserHelper.parseFromWK(item, [asFeature], [properties]) ⇒ <code>object</code> | ||
### Functions | ||
Parses from WKT or WKB | ||
- [convertFeatureCollection](#convertfeaturecollection) | ||
- [convertFeatureToWK](#convertfeaturetowk) | ||
- [convertGeometryToWK](#convertgeometrytowk) | ||
- [convertToWK](#converttowk) | ||
- [parseFromWK](#parsefromwk) | ||
**Kind**: static method of [<code>WktParserHelper</code>](#WktParserHelper) | ||
**Returns**: <code>object</code> - GeoJSON | ||
## Type aliases | ||
| Param | Type | Default | Description | | ||
| ------------ | ------------------------------------------ | ------------------ | --------------------------------------------- | | ||
| item | <code>string</code> \| <code>Buffer</code> | | WKT or WKB to convert to GeoJSON | | ||
| [asFeature] | <code>boolean</code> | <code>false</code> | | | ||
| [properties] | <code>object</code> | <code>{}</code> | Properties to embed resulting GeoJSON feature | | ||
### WKType | ||
<a name="WktParserHelper.convertFeatureCollection"></a> | ||
Ƭ **WKType**: _wkt_ \| _wkb_ | ||
### WktParserHelper.convertFeatureCollection(GeoJSON) ⇒ <code>string</code> | ||
Defined in: index.ts:4 | ||
Converts GeoJSON FeatureCollection to WKT GEOMETRYCOLLECTION | ||
## Functions | ||
**Kind**: static method of [<code>WktParserHelper</code>](#WktParserHelper) | ||
**Returns**: <code>string</code> - WKT or WKT | ||
### convertFeatureCollection | ||
| Param | Type | Description | | ||
| ------- | ------------------- | ------------------------------------------- | | ||
| GeoJSON | <code>Object</code> | GeoJSON FeatureCollection to convert to WKT | | ||
▸ **convertFeatureCollection**(`featureCollection`: FeatureCollection): _string_ | ||
Converts a GeoJSON FeatureCollection to WKT GeometryCollection | ||
**`export`** | ||
#### Parameters: | ||
| Name | Type | Description | | ||
| :------------------ | :---------------- | :-------------------------------------- | | ||
| `featureCollection` | FeatureCollection | The FeatureCollection to convert to WKT | | ||
**Returns:** _string_ | ||
The GeoJSON converted to well known representation | ||
Defined in: index.ts:38 | ||
--- | ||
### convertFeatureToWK | ||
▸ **convertFeatureToWK**(`geojson`: Feature, `type?`: [_WKType_](#wktype)): _string_ \| Buffer | ||
Converts GeoJSON Feature to WKT or WKB | ||
**`export`** | ||
#### Parameters: | ||
| Name | Type | Default value | Description | | ||
| :-------- | :------------------ | :------------ | :------------------------ | | ||
| `geojson` | Feature | - | Feature object to convert | | ||
| `type` | [_WKType_](#wktype) | 'wkt' | - | | ||
**Returns:** _string_ \| Buffer | ||
The GeoJSON converted to well known representation | ||
Defined in: index.ts:28 | ||
--- | ||
### convertGeometryToWK | ||
▸ **convertGeometryToWK**(`geojson`: Geometry, `type?`: [_WKType_](#wktype)): _string_ \| Buffer | ||
Converts GeoJSON Geometry to WKT or WKB | ||
**`export`** | ||
#### Parameters: | ||
| Name | Type | Default value | Description | | ||
| :-------- | :------------------ | :------------ | :------------------------- | | ||
| `geojson` | Geometry | - | Geometry object to convert | | ||
| `type` | [_WKType_](#wktype) | 'wkt' | - | | ||
**Returns:** _string_ \| Buffer | ||
The GeoJSON converted to well known representation | ||
Defined in: index.ts:14 | ||
--- | ||
### convertToWK | ||
▸ **convertToWK**(`geojson`: GeoJSON, `type?`: [_WKType_](#wktype)): _string_ \| Buffer | ||
Shorthand to convert GeoJSON Features, Geometries or FeatureCollections to WKT or WKB | ||
**`export`** | ||
#### Parameters: | ||
| Name | Type | Default value | Description | | ||
| :-------- | :------------------ | :------------ | :--------------------- | | ||
| `geojson` | GeoJSON | - | The GeoJSON to convert | | ||
| `type` | [_WKType_](#wktype) | 'wkt' | - | | ||
**Returns:** _string_ \| Buffer | ||
The GeoJSON as WKT or WKB | ||
Defined in: index.ts:56 | ||
--- | ||
### parseFromWK | ||
▸ **parseFromWK**(`item`: _string_ \| Buffer, `asFeature?`: _boolean_, `properties?`: GeoJsonProperties): Feature \| Geometry | ||
Parse a WKT or WKB into a GeoJSON Feature or Geometry | ||
**`export`** | ||
#### Parameters: | ||
| Name | Type | Default value | Description | | ||
| :----------- | :----------------- | :------------ | :--------------------------- | | ||
| `item` | _string_ \| Buffer | - | The WK to convert to GeoJSON | | ||
| `asFeature` | _boolean_ | false | - | | ||
| `properties` | GeoJsonProperties | - | - | | ||
**Returns:** Feature \| Geometry | ||
The WK as GeoJSON | ||
Defined in: index.ts:76 |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
32317
11
186
13
332
1
1
1
+ Addedwkx@0.5.0(transitive)
- Removedwkx@0.4.8(transitive)
Updatedwkx@^0.5.0