@turf/buffer 6.5.0 → 7.0.0-alpha.1
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 +9 -8
- package/dist/es/index.js +1 -1
- package/dist/js/index.js +4 -4
- package/index.d.ts +12 -32
- package/package.json +16 -14
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
|
-
|
|
15
|
+
### Parameters
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
**
|
|
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]
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import center from '@turf/center';
|
|
2
|
-
import { GeoJSONReader, BufferOp, GeoJSONWriter } from 'turf
|
|
2
|
+
import { GeoJSONReader, BufferOp, GeoJSONWriter } from '@turf/jsts';
|
|
3
3
|
import { featureEach, geomEach } from '@turf/meta';
|
|
4
4
|
import { geoAzimuthalEquidistant } from 'd3-geo';
|
|
5
5
|
import { featureCollection, earthRadius, radiansToLength, lengthToRadians, feature } from '@turf/helpers';
|
package/dist/js/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var center = require('@turf/center');
|
|
4
|
-
var
|
|
4
|
+
var jsts = require('@turf/jsts');
|
|
5
5
|
var meta = require('@turf/meta');
|
|
6
6
|
var d3Geo = require('d3-geo');
|
|
7
7
|
var helpers = require('@turf/helpers');
|
|
@@ -104,11 +104,11 @@ function bufferFeature(geojson, radius, units, steps) {
|
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
// JSTS buffer operation
|
|
107
|
-
var reader = new
|
|
107
|
+
var reader = new jsts.GeoJSONReader();
|
|
108
108
|
var geom = reader.read(projected);
|
|
109
109
|
var distance = helpers.radiansToLength(helpers.lengthToRadians(radius, units), "meters");
|
|
110
|
-
var buffered =
|
|
111
|
-
var writer = new
|
|
110
|
+
var buffered = jsts.BufferOp.bufferOp(geom, distance, steps);
|
|
111
|
+
var writer = new jsts.GeoJSONWriter();
|
|
112
112
|
buffered = writer.write(buffered);
|
|
113
113
|
|
|
114
114
|
// Detect if empty geometries
|
package/index.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
GeometryCollection,
|
|
10
10
|
Feature,
|
|
11
11
|
FeatureCollection,
|
|
12
|
-
|
|
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
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
25
|
+
| Feature<GeometryObject>
|
|
26
|
+
| Point
|
|
27
|
+
| LineString
|
|
28
|
+
| Polygon
|
|
29
|
+
| MultiPoint
|
|
30
|
+
| MultiLineString
|
|
31
|
+
| MultiPolygon,
|
|
52
32
|
radius?: number,
|
|
53
33
|
options?: Options
|
|
54
|
-
):
|
|
34
|
+
): Feature<Polygon | MultiPolygon>;
|
|
55
35
|
declare function buffer(
|
|
56
|
-
feature:
|
|
36
|
+
feature: FeatureCollection<GeometryObject> | GeometryCollection,
|
|
57
37
|
radius?: number,
|
|
58
38
|
options?: Options
|
|
59
|
-
):
|
|
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": "
|
|
3
|
+
"version": "7.0.0-alpha.1",
|
|
4
4
|
"description": "turf buffer module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"exports": {
|
|
36
36
|
"./package.json": "./package.json",
|
|
37
37
|
".": {
|
|
38
|
+
"types": "./index.d.ts",
|
|
38
39
|
"import": "./dist/es/index.js",
|
|
39
40
|
"require": "./dist/js/index.js"
|
|
40
41
|
}
|
|
@@ -46,30 +47,31 @@
|
|
|
46
47
|
"index.d.ts"
|
|
47
48
|
],
|
|
48
49
|
"scripts": {
|
|
49
|
-
"bench": "
|
|
50
|
+
"bench": "tsx bench.js",
|
|
50
51
|
"build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
|
|
51
|
-
"docs": "
|
|
52
|
+
"docs": "tsx ../../scripts/generate-readmes",
|
|
52
53
|
"test": "npm-run-all test:*",
|
|
53
|
-
"test:tape": "
|
|
54
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
54
|
+
"test:tape": "tsx test.js",
|
|
55
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
|
-
"@turf/truncate": "^
|
|
58
|
+
"@turf/truncate": "^7.0.0-alpha.1",
|
|
58
59
|
"benchmark": "*",
|
|
59
60
|
"load-json-file": "*",
|
|
60
61
|
"npm-run-all": "*",
|
|
61
62
|
"rollup": "*",
|
|
62
63
|
"tape": "*",
|
|
64
|
+
"tsx": "*",
|
|
63
65
|
"write-json-file": "*"
|
|
64
66
|
},
|
|
65
67
|
"dependencies": {
|
|
66
|
-
"@turf/bbox": "^
|
|
67
|
-
"@turf/center": "^
|
|
68
|
-
"@turf/helpers": "^
|
|
69
|
-
"@turf/
|
|
70
|
-
"@turf/
|
|
71
|
-
"
|
|
72
|
-
"
|
|
68
|
+
"@turf/bbox": "^7.0.0-alpha.1",
|
|
69
|
+
"@turf/center": "^7.0.0-alpha.1",
|
|
70
|
+
"@turf/helpers": "^7.0.0-alpha.1",
|
|
71
|
+
"@turf/jsts": "^2.7.1",
|
|
72
|
+
"@turf/meta": "^7.0.0-alpha.1",
|
|
73
|
+
"@turf/projection": "^7.0.0-alpha.1",
|
|
74
|
+
"d3-geo": "1.7.1"
|
|
73
75
|
},
|
|
74
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "cf7a0c507b017ca066acffd0ce23bda5b393fb5a"
|
|
75
77
|
}
|