Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

turf-simplify

Package Overview
Dependencies
Maintainers
8
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-simplify - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

54

index.js
var simplify = require('simplify-js');
/**
* Simplifies a `GeoJSONFeature` containing a `GeoJSONLineString` or
* `GeoJSONPolygon` geometry. Internally uses [simplify-js](http://mourner.github.io/simplify-js/)
* to perform simplification.
* Takes a {@link LineString} or {@link Polygon} feature and returns a simplified version. Internally uses [simplify-js](http://mourner.github.io/simplify-js/) to perform simplification.
*
* @module turf/simplify
* @param {GeoJSONFeature} feature - a feature to be simplified
* @param {number} tolerance - simplification tolerance
* @param {boolean} highQuality - whether or not to spend more time to create
* @category transformation
* @param {Feature} feature a {@link LineString} or {@link Polygon} feature to be simplified
* @param {number} tolerance simplification tolerance
* @param {boolean} highQuality whether or not to spend more time to create
* a higher-quality simplification with a different algorithm
* @return {GeoJSONFeature} output
* @return {Feature} a simplified feature
* @example
* var quantization = 50;
* var minimumArea = 0;
* var simplified = turf.simplify(polys, quantization, minimumArea);
* var feature = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Polygon",
* "coordinates": [[
* [-70.603637, -33.399918],
* [-70.614624, -33.395332],
* [-70.639343, -33.392466],
* [-70.659942, -33.394759],
* [-70.683975, -33.404504],
* [-70.697021, -33.419406],
* [-70.701141, -33.434306],
* [-70.700454, -33.446339],
* [-70.694274, -33.458369],
* [-70.682601, -33.465816],
* [-70.668869, -33.472117],
* [-70.646209, -33.473835],
* [-70.624923, -33.472117],
* [-70.609817, -33.468107],
* [-70.595397, -33.458369],
* [-70.587158, -33.442901],
* [-70.587158, -33.426283],
* [-70.590591, -33.414248],
* [-70.594711, -33.406224],
* [-70.603637, -33.399918]
* ]]
* }
* };
* var tolerance = 0.01;
*
* var simplified = turf.simplify(
* feature, tolerance, false);
*
* //=feature
*
* //=simplified
*/

@@ -19,0 +53,0 @@ module.exports = function(feature, tolerance, highQuality){

9

package.json
{
"name": "turf-simplify",
"version": "1.0.2",
"version": "1.0.3",
"description": "simplify geographic shapes",

@@ -10,3 +10,4 @@ "main": "index.js",

"scripts": {
"test": "tape test/*.js"
"test": "tape test/*.js",
"doc": "dox -r < index.js | doxme --readme > README.md"
},

@@ -30,3 +31,5 @@ "repository": {

"benchmark": "^1.0.0",
"tape": "~3.0.3"
"tape": "~3.5.0",
"dox": "^0.6.1",
"doxme": "^1.4.3"
},

@@ -33,0 +36,0 @@ "dependencies": {

@@ -0,11 +1,71 @@

# turf-simplify
[![build status](https://secure.travis-ci.org/Turfjs/turf-simplify.png)](http://travis-ci.org/Turfjs/turf-simplify)
# turf-simplify
simplify geographic shapes
Simplifies geographic features.
### `turf.simplify(feature, tolerance, highQuality)`
Simplifies a Feature containing a LineString or
Polygon geometry. Internally uses [simplify-js](http://mourner.github.io/simplify-js/)
to perform simplification.
### Parameters
| parameter | type | description |
| ------------- | ------- | -------------------------------------------------------------------------------------------------------- |
| `feature` | Feature | - a LineString or Polygon feature to be simplified |
| `tolerance` | number | - simplification tolerance |
| `highQuality` | boolean | - whether or not to spend more time to create a higher-quality simplification with a different algorithm |
### Example
```js
var quantization = 50;
var minimumArea = 0;
var simplified = simplify(polys, quantization, minimumArea);
var feature = turf.polygon([[
[-70.603637, -33.399918],
[-70.614624, -33.395332],
[-70.639343, -33.392466],
[-70.659942, -33.394759],
[-70.683975, -33.404504],
[-70.697021, -33.419406],
[-70.701141, -33.434306],
[-70.700454, -33.446339],
[-70.694274, -33.458369],
[-70.682601, -33.465816],
[-70.668869, -33.472117],
[-70.646209, -33.473835],
[-70.624923, -33.472117],
[-70.609817, -33.468107],
[-70.595397, -33.458369],
[-70.587158, -33.442901],
[-70.587158, -33.426283],
[-70.590591, -33.414248],
[-70.594711, -33.406224],
[-70.603637, -33.399918]
]]);
var tolerance = 0.01;
var simplified = turf.simplify(
feature, tolerance, false);
//=feature
//=simplified
```
## Installation
Requires [nodejs](http://nodejs.org/).
```sh
$ npm install turf-simplify
```
## Tests
```sh
$ npm test
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc