@turf/buffer 6.4.0 → 7.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,15 +12,16 @@ FeatureCollection, only valid members will be returned in the output
12
12
  FeatureCollection - i.e., the output collection may have fewer members than
13
13
  the input, or even be empty.
14
14
 
15
- **Parameters**
15
+ ### Parameters
16
16
 
17
- - `geojson` **([FeatureCollection][1] \| [Geometry][2] \| [Feature][3]<any>)** input to be buffered
18
- - `radius` **[number][4]** distance to draw the buffer (negative values are allowed)
19
- - `options` **[Object][5]** Optional parameters (optional, default `{}`)
20
- - `options.units` **[string][6]** any of the options supported by turf units (optional, default `"kilometers"`)
21
- - `options.steps` **[number][4]** number of steps (optional, default `8`)
17
+ * `geojson` **([FeatureCollection][1] | [Geometry][2] | [Feature][3]\<any>)** input to be buffered
18
+ * `radius` **[number][4]** distance to draw the buffer (negative values are allowed)
19
+ * `options` **[Object][5]** Optional parameters (optional, default `{}`)
22
20
 
23
- **Examples**
21
+ * `options.units` **[string][6]** any of the options supported by turf units (optional, default `"kilometers"`)
22
+ * `options.steps` **[number][4]** number of steps (optional, default `8`)
23
+
24
+ ### Examples
24
25
 
25
26
  ```javascript
26
27
  var point = turf.point([-90.548630, 14.616599]);
@@ -30,7 +31,7 @@ var buffered = turf.buffer(point, 500, {units: 'miles'});
30
31
  var addToMap = [point, buffered]
31
32
  ```
32
33
 
33
- Returns **([FeatureCollection][1] \| [Feature][3]&lt;([Polygon][7] \| [MultiPolygon][8])> | [undefined][9])** buffered features
34
+ Returns **([FeatureCollection][1] | [Feature][3]<([Polygon][7] | [MultiPolygon][8])> | [undefined][9])** buffered features
34
35
 
35
36
  [1]: https://tools.ietf.org/html/rfc7946#section-3.3
36
37
 
package/dist/es/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import center from '@turf/center';
2
- import { BufferOp, GeoJSONReader, GeoJSONWriter } from 'turf-jsts';
3
- import { geomEach, featureEach } from '@turf/meta';
2
+ import { GeoJSONReader, BufferOp, GeoJSONWriter } from '@turf/jsts';
3
+ import { featureEach, geomEach } from '@turf/meta';
4
4
  import { geoAzimuthalEquidistant } from 'd3-geo';
5
- import { feature, featureCollection, radiansToLength, lengthToRadians, earthRadius } from '@turf/helpers';
5
+ import { featureCollection, earthRadius, radiansToLength, lengthToRadians, feature } from '@turf/helpers';
6
6
 
7
7
  /**
8
8
  * Calculates a buffer for input features for a given radius. Units supported are miles, kilometers, and degrees.
@@ -53,8 +53,8 @@ function buffer(geojson, radius, options) {
53
53
  });
54
54
  return featureCollection(results);
55
55
  case "FeatureCollection":
56
- featureEach(geojson, function (feature$$1) {
57
- var multiBuffered = bufferFeature(feature$$1, radius, units, steps);
56
+ featureEach(geojson, function (feature) {
57
+ var multiBuffered = bufferFeature(feature, radius, units, steps);
58
58
  if (multiBuffered) {
59
59
  featureEach(multiBuffered, function (buffered) {
60
60
  if (buffered) results.push(buffered);
package/dist/js/index.js CHANGED
@@ -1,13 +1,15 @@
1
1
  'use strict';
2
2
 
3
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
-
5
- var center = _interopDefault(require('@turf/center'));
6
- var turfJsts = require('turf-jsts');
3
+ var center = require('@turf/center');
4
+ var jsts = require('@turf/jsts');
7
5
  var meta = require('@turf/meta');
8
6
  var d3Geo = require('d3-geo');
9
7
  var helpers = require('@turf/helpers');
10
8
 
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var center__default = /*#__PURE__*/_interopDefaultLegacy(center);
12
+
11
13
  /**
12
14
  * Calculates a buffer for input features for a given radius. Units supported are miles, kilometers, and degrees.
13
15
  *
@@ -102,11 +104,11 @@ function bufferFeature(geojson, radius, units, steps) {
102
104
  };
103
105
 
104
106
  // JSTS buffer operation
105
- var reader = new turfJsts.GeoJSONReader();
107
+ var reader = new jsts.GeoJSONReader();
106
108
  var geom = reader.read(projected);
107
109
  var distance = helpers.radiansToLength(helpers.lengthToRadians(radius, units), "meters");
108
- var buffered = turfJsts.BufferOp.bufferOp(geom, distance, steps);
109
- var writer = new turfJsts.GeoJSONWriter();
110
+ var buffered = jsts.BufferOp.bufferOp(geom, distance, steps);
111
+ var writer = new jsts.GeoJSONWriter();
110
112
  buffered = writer.write(buffered);
111
113
 
112
114
  // Detect if empty geometries
@@ -171,9 +173,10 @@ function unprojectCoords(coords, proj) {
171
173
  * @returns {GeoProjection} D3 Geo Azimuthal Equidistant Projection
172
174
  */
173
175
  function defineProjection(geojson) {
174
- var coords = center(geojson).geometry.coordinates;
176
+ var coords = center__default['default'](geojson).geometry.coordinates;
175
177
  var rotation = [-coords[0], -coords[1]];
176
178
  return d3Geo.geoAzimuthalEquidistant().rotate(rotation).scale(helpers.earthRadius);
177
179
  }
178
180
 
179
181
  module.exports = buffer;
182
+ module.exports.default = buffer;
package/index.d.ts CHANGED
@@ -9,8 +9,8 @@ import {
9
9
  GeometryCollection,
10
10
  Feature,
11
11
  FeatureCollection,
12
- Units,
13
- } from "@turf/helpers";
12
+ } from "geojson";
13
+ import { Units } from "@turf/helpers";
14
14
 
15
15
  interface Options {
16
16
  units?: Units;
@@ -20,42 +20,22 @@ interface Options {
20
20
  /**
21
21
  * http://turfjs.org/docs/#buffer
22
22
  */
23
- declare function buffer<Geom extends Point | LineString | Polygon>(
24
- feature: Feature<Geom> | Geom,
25
- radius?: number,
26
- options?: Options
27
- ): Feature<Polygon>;
28
- declare function buffer<
29
- Geom extends MultiPoint | MultiLineString | MultiPolygon
30
- >(
31
- feature: Feature<Geom> | Geom,
32
- radius?: number,
33
- options?: Options
34
- ): Feature<MultiPolygon>;
35
- declare function buffer<Geom extends Point | LineString | Polygon>(
36
- feature: FeatureCollection<Geom>,
37
- radius?: number,
38
- options?: Options
39
- ): FeatureCollection<Polygon>;
40
- declare function buffer<
41
- Geom extends MultiPoint | MultiLineString | MultiPolygon
42
- >(
43
- feature: FeatureCollection<Geom>,
44
- radius?: number,
45
- options?: Options
46
- ): FeatureCollection<MultiPolygon>;
47
23
  declare function buffer(
48
24
  feature:
49
- | FeatureCollection<any>
50
- | Feature<GeometryCollection>
51
- | GeometryCollection,
25
+ | Feature<GeometryObject>
26
+ | Point
27
+ | LineString
28
+ | Polygon
29
+ | MultiPoint
30
+ | MultiLineString
31
+ | MultiPolygon,
52
32
  radius?: number,
53
33
  options?: Options
54
- ): FeatureCollection<Polygon | MultiPolygon>;
34
+ ): Feature<Polygon | MultiPolygon>;
55
35
  declare function buffer(
56
- feature: Feature<any> | GeometryObject,
36
+ feature: FeatureCollection<GeometryObject> | GeometryCollection,
57
37
  radius?: number,
58
38
  options?: Options
59
- ): Feature<Polygon | MultiPolygon>;
39
+ ): FeatureCollection<Polygon | MultiPolygon>;
60
40
 
61
41
  export default buffer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/buffer",
3
- "version": "6.4.0",
3
+ "version": "7.0.0-alpha.0",
4
4
  "description": "turf buffer module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -17,6 +17,7 @@
17
17
  "type": "git",
18
18
  "url": "git://github.com/Turfjs/turf.git"
19
19
  },
20
+ "funding": "https://opencollective.com/turf",
20
21
  "publishConfig": {
21
22
  "access": "public"
22
23
  },
@@ -50,10 +51,10 @@
50
51
  "docs": "node ../../scripts/generate-readmes",
51
52
  "test": "npm-run-all test:*",
52
53
  "test:tape": "node -r esm test.js",
53
- "test:types": "tsc --esModuleInterop --noEmit types.ts"
54
+ "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
54
55
  },
55
56
  "devDependencies": {
56
- "@turf/truncate": "^6.4.0",
57
+ "@turf/truncate": "^7.0.0-alpha.0",
57
58
  "benchmark": "*",
58
59
  "load-json-file": "*",
59
60
  "npm-run-all": "*",
@@ -62,13 +63,13 @@
62
63
  "write-json-file": "*"
63
64
  },
64
65
  "dependencies": {
65
- "@turf/bbox": "^6.4.0",
66
- "@turf/center": "^6.4.0",
67
- "@turf/helpers": "^6.4.0",
68
- "@turf/meta": "^6.4.0",
69
- "@turf/projection": "^6.4.0",
70
- "d3-geo": "1.7.1",
71
- "turf-jsts": "*"
66
+ "@turf/bbox": "^7.0.0-alpha.0",
67
+ "@turf/center": "^7.0.0-alpha.0",
68
+ "@turf/helpers": "^7.0.0-alpha.0",
69
+ "@turf/jsts": "^2.7.1",
70
+ "@turf/meta": "^7.0.0-alpha.0",
71
+ "@turf/projection": "^7.0.0-alpha.0",
72
+ "d3-geo": "1.7.1"
72
73
  },
73
- "gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac"
74
+ "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
74
75
  }