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

turf-buffer

Package Overview
Dependencies
Maintainers
8
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-buffer - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

49

index.js

@@ -10,7 +10,37 @@ // http://stackoverflow.com/questions/839899/how-do-i-calculate-a-point-on-a-circles-circumference

module.exports = function(feature, radius, units, done){
/**
* Calculates a buffer for a {@link Point}, {@link LineString}, or {@link Polygon} {@link Feature}/{@link FeatureCollection} for a given radius. Units supported are miles, kilometers, and degrees.
*
* @module turf/buffer
* @category transformation
* @param {FeatureCollection} feature a Feature or FeatureCollection of any type
* @param {Number} distance distance to draw the buffer
* @param {String} unit 'miles' or 'kilometers'
* @return {FeatureCollection} a FeatureCollection containing {@link Polygon} features representing buffers
*
* @example
* var pt = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Point",
* "coordinates": [-90.548630, 14.616599]
* }
* };
* var unit = 'miles';
*
* var buffered = turf.buffer(pt, 500, unit);
*
* var resultFeatures = buffered.features.concat(pt);
* var result = {
* "type": "FeatureCollection",
* "features": resultFeatures
* };
*
* //=result
*/
module.exports = function(feature, radius, units){
var buffered;
done = done || function () {};
switch(units){

@@ -20,5 +50,11 @@ case 'miles':

break
case 'feet':
radius = radius / 364568.0;
break
case 'kilometers':
radius = radius / 111.12;
break
case 'meters':
radius = radius / 111120.0;
break
case 'degrees':

@@ -31,6 +67,3 @@ break

multi.properties = {};
buffered = bufferOp(multi, radius);
done(null, buffered);
return buffered;

@@ -40,4 +73,2 @@ }

buffered = bufferOp(feature, radius);
done(null, buffered);
return buffered;

@@ -67,2 +98,2 @@ }

return buffered;
}
}

19

package.json
{
"name": "turf-buffer",
"version": "1.0.0",
"version": "1.0.1",
"description": "turf buffer module",
"main": "index.js",
"scripts": {
"test": "tape test.js"
"test": "tape test.js",
"doc": "dox -r < index.js | doxme --readme > README.md"
},
"repository": {
"type": "git",
"url": "https://github.com/morganherlocker/turf-buffer.git"
"url": "https://github.com/Turfjs/turf-buffer.git"
},

@@ -25,15 +26,17 @@ "keywords": [

"bugs": {
"url": "https://github.com/morganherlocker/turf-buffer/issues"
"url": "https://github.com/Turfjs/turf-buffer/issues"
},
"homepage": "https://github.com/morganherlocker/turf-buffer",
"homepage": "https://github.com/Turfjs/turf-buffer",
"devDependencies": {
"benchmark": "^1.0.0",
"tape": "^3.0.3"
"tape": "^3.5.0",
"dox": "^0.6.1",
"doxme": "^1.4.3"
},
"dependencies": {
"jsts": "^0.15.0",
"turf-combine": "1.0.1",
"turf-combine": "^1.0.1",
"turf-featurecollection": "^1.0.0",
"turf-polygon": "^1.0.0"
"turf-polygon": "^1.0.2"
}
}

@@ -1,39 +0,49 @@

turf-buffer
===========
[![Build Status](https://travis-ci.org/Turfjs/turf-buffer.svg)](https://travis-ci.org/Turfjs/turf-buffer)
# turf-buffer
Buffers a point, linestring, or polygon Feature/FeatureCollection to a given radius. Units supported are miles, kilometers, and degrees.
[![build status](https://secure.travis-ci.org/Turfjs/turf-buffer.png)](http://travis-ci.org/Turfjs/turf-buffer)
###Install
turf buffer module
```sh
npm install turf-buffer
```
###Parameters
### `turf.buffer(feature, distance, unit)`
|name|description|
|---|---|
|feature|A Feature or FeatureCollection of any type|
|distance|Distance to draw the buffer|
|unit|'miles' or 'kilometers'|
Calculates a buffer for a Point, LineString, or Polygon Feature/FeatureCollection for a given radius. Units supported are miles, kilometers, and degrees.
###Usage
### Parameters
| parameter | type | description |
| ---------- | ----------------- | ------------------------------------------ |
| `feature` | FeatureCollection | a Feature or FeatureCollection of any type |
| `distance` | Number | distance to draw the buffer |
| `unit` | String | 'miles' or 'kilometers' |
### Example
```js
buffer(feature, distance, unit)
var pt = turf.point([-90.548630, 14.616599]);
var unit = 'miles';
var buffered = turf.buffer(pt, 500, unit);
var result = turf.featurecollection(
buffered.features.concat(pt));
//=result
```
###Example
## Installation
```js
var buffer = require('turf-buffer')
var point = require('turf-point')
Requires [nodejs](http://nodejs.org/).
var pt = point(14.616599, -90.548630)
var unit = 'miles'
```sh
$ npm install turf-buffer
```
var buffered = buffer(pt, 10, unit)
## Tests
console.log(buffered)
```
```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