@turf/helpers 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 +193 -179
- package/dist/es/index.js +63 -100
- package/dist/es/lib/geojson.js +0 -7
- package/dist/js/index.d.ts +27 -33
- package/dist/js/index.js +60 -97
- package/dist/js/lib/geojson.d.ts +2 -185
- package/dist/js/lib/geojson.js +0 -7
- package/package.json +11 -7
package/README.md
CHANGED
|
@@ -2,35 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## helpers
|
|
6
|
+
|
|
7
|
+
### earthRadius
|
|
6
8
|
|
|
7
9
|
Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
Type: [number][1]
|
|
12
|
+
|
|
13
|
+
### factors
|
|
10
14
|
|
|
11
15
|
Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
Keys are the name of the unit, values are the number of that unit in a single radian
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
Type: [Object][2]
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
### areaFactors
|
|
18
22
|
|
|
19
23
|
Area of measurement factors based on 1 square meter.
|
|
20
24
|
|
|
25
|
+
Type: [Object][2]
|
|
26
|
+
|
|
21
27
|
## feature
|
|
22
28
|
|
|
23
|
-
Wraps a GeoJSON [Geometry][
|
|
29
|
+
Wraps a GeoJSON [Geometry][3] in a GeoJSON [Feature][4].
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
### Parameters
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the Feature
|
|
31
|
-
- `options.id` **([string][7] \| [number][6])?** Identifier associated with the Feature
|
|
33
|
+
* `geometry` **[Geometry][5]** input geometry
|
|
34
|
+
* `properties` **[Object][2]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
35
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
32
36
|
|
|
33
|
-
**
|
|
37
|
+
* `options.bbox` **[Array][6]<[number][1]>?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
38
|
+
* `options.id` **([string][7] | [number][1])?** Identifier associated with the Feature
|
|
39
|
+
|
|
40
|
+
### Examples
|
|
34
41
|
|
|
35
42
|
```javascript
|
|
36
43
|
var geometry = {
|
|
@@ -47,42 +54,40 @@ Returns **[Feature][8]** a GeoJSON Feature
|
|
|
47
54
|
|
|
48
55
|
## geometry
|
|
49
56
|
|
|
50
|
-
Creates a GeoJSON [Geometry][
|
|
57
|
+
Creates a GeoJSON [Geometry][3] from a Geometry string type & coordinates.
|
|
51
58
|
For GeometryCollection type use `helpers.geometryCollection`
|
|
52
59
|
|
|
53
|
-
|
|
60
|
+
### Parameters
|
|
54
61
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the Geometry
|
|
62
|
+
* `type` **[string][7]** Geometry Type
|
|
63
|
+
* `coordinates` **[Array][6]\<any>** Coordinates
|
|
64
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
59
65
|
|
|
60
|
-
|
|
66
|
+
### Examples
|
|
61
67
|
|
|
62
68
|
```javascript
|
|
63
|
-
var type =
|
|
69
|
+
var type = "Point";
|
|
64
70
|
var coordinates = [110, 50];
|
|
65
|
-
|
|
66
71
|
var geometry = turf.geometry(type, coordinates);
|
|
67
|
-
|
|
68
|
-
//=geometry
|
|
72
|
+
// => geometry
|
|
69
73
|
```
|
|
70
74
|
|
|
71
|
-
Returns **[Geometry][
|
|
75
|
+
Returns **[Geometry][5]** a GeoJSON Geometry
|
|
72
76
|
|
|
73
77
|
## point
|
|
74
78
|
|
|
75
|
-
Creates a [Point][9] [Feature][
|
|
79
|
+
Creates a [Point][9] [Feature][4] from a Position.
|
|
80
|
+
|
|
81
|
+
### Parameters
|
|
76
82
|
|
|
77
|
-
**
|
|
83
|
+
* `coordinates` **[Array][6]<[number][1]>** longitude, latitude position (each in decimal degrees)
|
|
84
|
+
* `properties` **[Object][2]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
85
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
78
86
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
- `options` **[Object][4]** Optional Parameters (optional, default `{}`)
|
|
82
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the Feature
|
|
83
|
-
- `options.id` **([string][7] \| [number][6])?** Identifier associated with the Feature
|
|
87
|
+
* `options.bbox` **[Array][6]<[number][1]>?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
88
|
+
* `options.id` **([string][7] | [number][1])?** Identifier associated with the Feature
|
|
84
89
|
|
|
85
|
-
|
|
90
|
+
### Examples
|
|
86
91
|
|
|
87
92
|
```javascript
|
|
88
93
|
var point = turf.point([-75.343, 39.984]);
|
|
@@ -90,21 +95,23 @@ var point = turf.point([-75.343, 39.984]);
|
|
|
90
95
|
//=point
|
|
91
96
|
```
|
|
92
97
|
|
|
93
|
-
Returns **[Feature][8]
|
|
98
|
+
Returns **[Feature][8]<[Point][10]>** a Point feature
|
|
94
99
|
|
|
95
100
|
## points
|
|
96
101
|
|
|
97
102
|
Creates a [Point][9] [FeatureCollection][11] from an Array of Point coordinates.
|
|
98
103
|
|
|
99
|
-
|
|
104
|
+
### Parameters
|
|
105
|
+
|
|
106
|
+
* `coordinates` **[Array][6]<[Array][6]<[number][1]>>** an array of Points
|
|
107
|
+
* `properties` **[Object][2]** Translate these properties to each Feature (optional, default `{}`)
|
|
108
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
100
109
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the FeatureCollection
|
|
105
|
-
- `options.id` **([string][7] \| [number][6])?** Identifier associated with the FeatureCollection
|
|
110
|
+
* `options.bbox` **[Array][6]<[number][1]>?** Bounding Box Array \[west, south, east, north]
|
|
111
|
+
associated with the FeatureCollection
|
|
112
|
+
* `options.id` **([string][7] | [number][1])?** Identifier associated with the FeatureCollection
|
|
106
113
|
|
|
107
|
-
|
|
114
|
+
### Examples
|
|
108
115
|
|
|
109
116
|
```javascript
|
|
110
117
|
var points = turf.points([
|
|
@@ -116,21 +123,22 @@ var points = turf.points([
|
|
|
116
123
|
//=points
|
|
117
124
|
```
|
|
118
125
|
|
|
119
|
-
Returns **[FeatureCollection][12]
|
|
126
|
+
Returns **[FeatureCollection][12]<[Point][10]>** Point Feature
|
|
120
127
|
|
|
121
128
|
## polygon
|
|
122
129
|
|
|
123
|
-
Creates a [Polygon][13] [Feature][
|
|
130
|
+
Creates a [Polygon][13] [Feature][4] from an Array of LinearRings.
|
|
124
131
|
|
|
125
|
-
|
|
132
|
+
### Parameters
|
|
126
133
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the Feature
|
|
131
|
-
- `options.id` **([string][7] \| [number][6])?** Identifier associated with the Feature
|
|
134
|
+
* `coordinates` **[Array][6]<[Array][6]<[Array][6]<[number][1]>>>** an array of LinearRings
|
|
135
|
+
* `properties` **[Object][2]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
136
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
132
137
|
|
|
133
|
-
**
|
|
138
|
+
* `options.bbox` **[Array][6]<[number][1]>?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
139
|
+
* `options.id` **([string][7] | [number][1])?** Identifier associated with the Feature
|
|
140
|
+
|
|
141
|
+
### Examples
|
|
134
142
|
|
|
135
143
|
```javascript
|
|
136
144
|
var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], { name: 'poly1' });
|
|
@@ -138,21 +146,22 @@ var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]],
|
|
|
138
146
|
//=polygon
|
|
139
147
|
```
|
|
140
148
|
|
|
141
|
-
Returns **[Feature][8]
|
|
149
|
+
Returns **[Feature][8]<[Polygon][14]>** Polygon Feature
|
|
142
150
|
|
|
143
151
|
## polygons
|
|
144
152
|
|
|
145
153
|
Creates a [Polygon][13] [FeatureCollection][11] from an Array of Polygon coordinates.
|
|
146
154
|
|
|
147
|
-
|
|
155
|
+
### Parameters
|
|
156
|
+
|
|
157
|
+
* `coordinates` **[Array][6]<[Array][6]<[Array][6]<[Array][6]<[number][1]>>>>** an array of Polygon coordinates
|
|
158
|
+
* `properties` **[Object][2]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
159
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
148
160
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
- `options` **[Object][4]** Optional Parameters (optional, default `{}`)
|
|
152
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the Feature
|
|
153
|
-
- `options.id` **([string][7] \| [number][6])?** Identifier associated with the FeatureCollection
|
|
161
|
+
* `options.bbox` **[Array][6]<[number][1]>?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
162
|
+
* `options.id` **([string][7] | [number][1])?** Identifier associated with the FeatureCollection
|
|
154
163
|
|
|
155
|
-
|
|
164
|
+
### Examples
|
|
156
165
|
|
|
157
166
|
```javascript
|
|
158
167
|
var polygons = turf.polygons([
|
|
@@ -163,21 +172,22 @@ var polygons = turf.polygons([
|
|
|
163
172
|
//=polygons
|
|
164
173
|
```
|
|
165
174
|
|
|
166
|
-
Returns **[FeatureCollection][12]
|
|
175
|
+
Returns **[FeatureCollection][12]<[Polygon][14]>** Polygon FeatureCollection
|
|
167
176
|
|
|
168
177
|
## lineString
|
|
169
178
|
|
|
170
|
-
Creates a [LineString][15] [Feature][
|
|
179
|
+
Creates a [LineString][15] [Feature][4] from an Array of Positions.
|
|
171
180
|
|
|
172
|
-
|
|
181
|
+
### Parameters
|
|
173
182
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the Feature
|
|
178
|
-
- `options.id` **([string][7] \| [number][6])?** Identifier associated with the Feature
|
|
183
|
+
* `coordinates` **[Array][6]<[Array][6]<[number][1]>>** an array of Positions
|
|
184
|
+
* `properties` **[Object][2]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
185
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
179
186
|
|
|
180
|
-
**
|
|
187
|
+
* `options.bbox` **[Array][6]<[number][1]>?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
188
|
+
* `options.id` **([string][7] | [number][1])?** Identifier associated with the Feature
|
|
189
|
+
|
|
190
|
+
### Examples
|
|
181
191
|
|
|
182
192
|
```javascript
|
|
183
193
|
var linestring1 = turf.lineString([[-24, 63], [-23, 60], [-25, 65], [-20, 69]], {name: 'line 1'});
|
|
@@ -187,21 +197,23 @@ var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]],
|
|
|
187
197
|
//=linestring2
|
|
188
198
|
```
|
|
189
199
|
|
|
190
|
-
Returns **[Feature][8]
|
|
200
|
+
Returns **[Feature][8]<[LineString][16]>** LineString Feature
|
|
191
201
|
|
|
192
202
|
## lineStrings
|
|
193
203
|
|
|
194
204
|
Creates a [LineString][15] [FeatureCollection][11] from an Array of LineString coordinates.
|
|
195
205
|
|
|
196
|
-
|
|
206
|
+
### Parameters
|
|
207
|
+
|
|
208
|
+
* `coordinates` **[Array][6]<[Array][6]<[Array][6]<[number][1]>>>** an array of LinearRings
|
|
209
|
+
* `properties` **[Object][2]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
210
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
197
211
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the FeatureCollection
|
|
202
|
-
- `options.id` **([string][7] \| [number][6])?** Identifier associated with the FeatureCollection
|
|
212
|
+
* `options.bbox` **[Array][6]<[number][1]>?** Bounding Box Array \[west, south, east, north]
|
|
213
|
+
associated with the FeatureCollection
|
|
214
|
+
* `options.id` **([string][7] | [number][1])?** Identifier associated with the FeatureCollection
|
|
203
215
|
|
|
204
|
-
|
|
216
|
+
### Examples
|
|
205
217
|
|
|
206
218
|
```javascript
|
|
207
219
|
var linestrings = turf.lineStrings([
|
|
@@ -212,20 +224,21 @@ var linestrings = turf.lineStrings([
|
|
|
212
224
|
//=linestrings
|
|
213
225
|
```
|
|
214
226
|
|
|
215
|
-
Returns **[FeatureCollection][12]
|
|
227
|
+
Returns **[FeatureCollection][12]<[LineString][16]>** LineString FeatureCollection
|
|
216
228
|
|
|
217
229
|
## featureCollection
|
|
218
230
|
|
|
219
|
-
Takes one or more [Features][
|
|
231
|
+
Takes one or more [Features][4] and creates a [FeatureCollection][11].
|
|
232
|
+
|
|
233
|
+
### Parameters
|
|
220
234
|
|
|
221
|
-
**
|
|
235
|
+
* `features` **[Array][6]<[Feature][8]>** input features
|
|
236
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
222
237
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the Feature
|
|
226
|
-
- `options.id` **([string][7] \| [number][6])?** Identifier associated with the Feature
|
|
238
|
+
* `options.bbox` **[Array][6]<[number][1]>?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
239
|
+
* `options.id` **([string][7] | [number][1])?** Identifier associated with the Feature
|
|
227
240
|
|
|
228
|
-
|
|
241
|
+
### Examples
|
|
229
242
|
|
|
230
243
|
```javascript
|
|
231
244
|
var locationA = turf.point([-75.343, 39.984], {name: 'Location A'});
|
|
@@ -245,18 +258,19 @@ Returns **[FeatureCollection][12]** FeatureCollection of Features
|
|
|
245
258
|
|
|
246
259
|
## multiLineString
|
|
247
260
|
|
|
248
|
-
Creates a [Feature
|
|
261
|
+
Creates a [Feature\<MultiLineString>][17] based on a
|
|
249
262
|
coordinate array. Properties can be added optionally.
|
|
250
263
|
|
|
251
|
-
|
|
264
|
+
### Parameters
|
|
252
265
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the Feature
|
|
257
|
-
- `options.id` **([string][7] \| [number][6])?** Identifier associated with the Feature
|
|
266
|
+
* `coordinates` **[Array][6]<[Array][6]<[Array][6]<[number][1]>>>** an array of LineStrings
|
|
267
|
+
* `properties` **[Object][2]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
268
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
258
269
|
|
|
259
|
-
**
|
|
270
|
+
* `options.bbox` **[Array][6]<[number][1]>?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
271
|
+
* `options.id` **([string][7] | [number][1])?** Identifier associated with the Feature
|
|
272
|
+
|
|
273
|
+
### Examples
|
|
260
274
|
|
|
261
275
|
```javascript
|
|
262
276
|
var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
|
|
@@ -264,24 +278,25 @@ var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
|
|
|
264
278
|
//=multiLine
|
|
265
279
|
```
|
|
266
280
|
|
|
267
|
-
|
|
281
|
+
* Throws **[Error][18]** if no coordinates are passed
|
|
268
282
|
|
|
269
|
-
Returns **[Feature][8]
|
|
283
|
+
Returns **[Feature][8]<[MultiLineString][19]>** a MultiLineString feature
|
|
270
284
|
|
|
271
285
|
## multiPoint
|
|
272
286
|
|
|
273
|
-
Creates a [Feature
|
|
287
|
+
Creates a [Feature\<MultiPoint>][20] based on a
|
|
274
288
|
coordinate array. Properties can be added optionally.
|
|
275
289
|
|
|
276
|
-
|
|
290
|
+
### Parameters
|
|
291
|
+
|
|
292
|
+
* `coordinates` **[Array][6]<[Array][6]<[number][1]>>** an array of Positions
|
|
293
|
+
* `properties` **[Object][2]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
294
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
277
295
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
- `options` **[Object][4]** Optional Parameters (optional, default `{}`)
|
|
281
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the Feature
|
|
282
|
-
- `options.id` **([string][7] \| [number][6])?** Identifier associated with the Feature
|
|
296
|
+
* `options.bbox` **[Array][6]<[number][1]>?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
297
|
+
* `options.id` **([string][7] | [number][1])?** Identifier associated with the Feature
|
|
283
298
|
|
|
284
|
-
|
|
299
|
+
### Examples
|
|
285
300
|
|
|
286
301
|
```javascript
|
|
287
302
|
var multiPt = turf.multiPoint([[0,0],[10,10]]);
|
|
@@ -289,24 +304,25 @@ var multiPt = turf.multiPoint([[0,0],[10,10]]);
|
|
|
289
304
|
//=multiPt
|
|
290
305
|
```
|
|
291
306
|
|
|
292
|
-
|
|
307
|
+
* Throws **[Error][18]** if no coordinates are passed
|
|
293
308
|
|
|
294
|
-
Returns **[Feature][8]
|
|
309
|
+
Returns **[Feature][8]<[MultiPoint][21]>** a MultiPoint feature
|
|
295
310
|
|
|
296
311
|
## multiPolygon
|
|
297
312
|
|
|
298
|
-
Creates a [Feature
|
|
313
|
+
Creates a [Feature\<MultiPolygon>][22] based on a
|
|
299
314
|
coordinate array. Properties can be added optionally.
|
|
300
315
|
|
|
301
|
-
|
|
316
|
+
### Parameters
|
|
302
317
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the Feature
|
|
307
|
-
- `options.id` **([string][7] \| [number][6])?** Identifier associated with the Feature
|
|
318
|
+
* `coordinates` **[Array][6]<[Array][6]<[Array][6]<[Array][6]<[number][1]>>>>** an array of Polygons
|
|
319
|
+
* `properties` **[Object][2]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
320
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
308
321
|
|
|
309
|
-
**
|
|
322
|
+
* `options.bbox` **[Array][6]<[number][1]>?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
323
|
+
* `options.id` **([string][7] | [number][1])?** Identifier associated with the Feature
|
|
324
|
+
|
|
325
|
+
### Examples
|
|
310
326
|
|
|
311
327
|
```javascript
|
|
312
328
|
var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
|
|
@@ -314,51 +330,46 @@ var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
|
|
|
314
330
|
//=multiPoly
|
|
315
331
|
```
|
|
316
332
|
|
|
317
|
-
|
|
333
|
+
* Throws **[Error][18]** if no coordinates are passed
|
|
318
334
|
|
|
319
|
-
Returns **[Feature][8]
|
|
335
|
+
Returns **[Feature][8]<[MultiPolygon][23]>** a multipolygon feature
|
|
320
336
|
|
|
321
337
|
## geometryCollection
|
|
322
338
|
|
|
323
|
-
Creates a [Feature
|
|
339
|
+
Creates a [Feature\<GeometryCollection>][24] based on a
|
|
324
340
|
coordinate array. Properties can be added optionally.
|
|
325
341
|
|
|
326
|
-
|
|
342
|
+
### Parameters
|
|
343
|
+
|
|
344
|
+
* `geometries` **[Array][6]<[Geometry][5]>** an array of GeoJSON Geometries
|
|
345
|
+
* `properties` **[Object][2]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
346
|
+
* `options` **[Object][2]** Optional Parameters (optional, default `{}`)
|
|
327
347
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
- `options` **[Object][4]** Optional Parameters (optional, default `{}`)
|
|
331
|
-
- `options.bbox` **[Array][5]<[number][6]>?** Bounding Box Array [west, south, east, north] associated with the Feature
|
|
332
|
-
- `options.id` **([string][7] \| [number][6])?** Identifier associated with the Feature
|
|
348
|
+
* `options.bbox` **[Array][6]<[number][1]>?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
349
|
+
* `options.id` **([string][7] | [number][1])?** Identifier associated with the Feature
|
|
333
350
|
|
|
334
|
-
|
|
351
|
+
### Examples
|
|
335
352
|
|
|
336
353
|
```javascript
|
|
337
|
-
var pt =
|
|
338
|
-
|
|
339
|
-
"coordinates": [100, 0]
|
|
340
|
-
};
|
|
341
|
-
var line = {
|
|
342
|
-
"type": "LineString",
|
|
343
|
-
"coordinates": [ [101, 0], [102, 1] ]
|
|
344
|
-
};
|
|
354
|
+
var pt = turf.geometry("Point", [100, 0]);
|
|
355
|
+
var line = turf.geometry("LineString", [[101, 0], [102, 1]]);
|
|
345
356
|
var collection = turf.geometryCollection([pt, line]);
|
|
346
357
|
|
|
347
|
-
|
|
358
|
+
// => collection
|
|
348
359
|
```
|
|
349
360
|
|
|
350
|
-
Returns **[Feature][8]
|
|
361
|
+
Returns **[Feature][8]<[GeometryCollection][25]>** a GeoJSON GeometryCollection Feature
|
|
351
362
|
|
|
352
363
|
## round
|
|
353
364
|
|
|
354
365
|
Round number to precision
|
|
355
366
|
|
|
356
|
-
|
|
367
|
+
### Parameters
|
|
357
368
|
|
|
358
|
-
|
|
359
|
-
|
|
369
|
+
* `num` **[number][1]** Number
|
|
370
|
+
* `precision` **[number][1]** Precision (optional, default `0`)
|
|
360
371
|
|
|
361
|
-
|
|
372
|
+
### Examples
|
|
362
373
|
|
|
363
374
|
```javascript
|
|
364
375
|
turf.round(120.4321)
|
|
@@ -368,110 +379,113 @@ turf.round(120.4321, 2)
|
|
|
368
379
|
//=120.43
|
|
369
380
|
```
|
|
370
381
|
|
|
371
|
-
Returns **[number][
|
|
382
|
+
Returns **[number][1]** rounded number
|
|
372
383
|
|
|
373
384
|
## radiansToLength
|
|
374
385
|
|
|
375
386
|
Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
|
|
376
387
|
Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
|
|
377
388
|
|
|
378
|
-
|
|
389
|
+
### Parameters
|
|
379
390
|
|
|
380
|
-
|
|
381
|
-
|
|
391
|
+
* `radians` **[number][1]** in radians across the sphere
|
|
392
|
+
* `units` **[string][7]** can be degrees, radians, miles, inches, yards, metres,
|
|
393
|
+
meters, kilometres, kilometers. (optional, default `"kilometers"`)
|
|
382
394
|
|
|
383
|
-
Returns **[number][
|
|
395
|
+
Returns **[number][1]** distance
|
|
384
396
|
|
|
385
397
|
## lengthToRadians
|
|
386
398
|
|
|
387
399
|
Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
|
|
388
400
|
Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
|
|
389
401
|
|
|
390
|
-
|
|
402
|
+
### Parameters
|
|
391
403
|
|
|
392
|
-
|
|
393
|
-
|
|
404
|
+
* `distance` **[number][1]** in real units
|
|
405
|
+
* `units` **[string][7]** can be degrees, radians, miles, inches, yards, metres,
|
|
406
|
+
meters, kilometres, kilometers. (optional, default `"kilometers"`)
|
|
394
407
|
|
|
395
|
-
Returns **[number][
|
|
408
|
+
Returns **[number][1]** radians
|
|
396
409
|
|
|
397
410
|
## lengthToDegrees
|
|
398
411
|
|
|
399
412
|
Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
|
|
400
413
|
Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
|
|
401
414
|
|
|
402
|
-
|
|
415
|
+
### Parameters
|
|
403
416
|
|
|
404
|
-
|
|
405
|
-
|
|
417
|
+
* `distance` **[number][1]** in real units
|
|
418
|
+
* `units` **[string][7]** can be degrees, radians, miles, inches, yards, metres,
|
|
419
|
+
meters, kilometres, kilometers. (optional, default `"kilometers"`)
|
|
406
420
|
|
|
407
|
-
Returns **[number][
|
|
421
|
+
Returns **[number][1]** degrees
|
|
408
422
|
|
|
409
423
|
## bearingToAzimuth
|
|
410
424
|
|
|
411
425
|
Converts any bearing angle from the north line direction (positive clockwise)
|
|
412
426
|
and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
|
|
413
427
|
|
|
414
|
-
|
|
428
|
+
### Parameters
|
|
415
429
|
|
|
416
|
-
|
|
430
|
+
* `bearing` **[number][1]** angle, between -180 and +180 degrees
|
|
417
431
|
|
|
418
|
-
Returns **[number][
|
|
432
|
+
Returns **[number][1]** angle between 0 and 360 degrees
|
|
419
433
|
|
|
420
434
|
## radiansToDegrees
|
|
421
435
|
|
|
422
436
|
Converts an angle in radians to degrees
|
|
423
437
|
|
|
424
|
-
|
|
438
|
+
### Parameters
|
|
425
439
|
|
|
426
|
-
|
|
440
|
+
* `radians` **[number][1]** angle in radians
|
|
427
441
|
|
|
428
|
-
Returns **[number][
|
|
442
|
+
Returns **[number][1]** degrees between 0 and 360 degrees
|
|
429
443
|
|
|
430
444
|
## degreesToRadians
|
|
431
445
|
|
|
432
446
|
Converts an angle in degrees to radians
|
|
433
447
|
|
|
434
|
-
|
|
448
|
+
### Parameters
|
|
435
449
|
|
|
436
|
-
|
|
450
|
+
* `degrees` **[number][1]** angle between 0 and 360 degrees
|
|
437
451
|
|
|
438
|
-
Returns **[number][
|
|
452
|
+
Returns **[number][1]** angle in radians
|
|
439
453
|
|
|
440
454
|
## convertLength
|
|
441
455
|
|
|
442
456
|
Converts a length to the requested unit.
|
|
443
457
|
Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
|
|
444
458
|
|
|
445
|
-
|
|
459
|
+
### Parameters
|
|
446
460
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
461
|
+
* `length` **[number][1]** to be converted
|
|
462
|
+
* `originalUnit` **Units** of the length (optional, default `"kilometers"`)
|
|
463
|
+
* `finalUnit` **Units** returned unit (optional, default `"kilometers"`)
|
|
450
464
|
|
|
451
|
-
Returns **[number][
|
|
465
|
+
Returns **[number][1]** the converted length
|
|
452
466
|
|
|
453
467
|
## convertArea
|
|
454
468
|
|
|
455
469
|
Converts a area to the requested unit.
|
|
456
470
|
Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares
|
|
457
471
|
|
|
458
|
-
|
|
472
|
+
### Parameters
|
|
459
473
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
474
|
+
* `area` **[number][1]** to be converted
|
|
475
|
+
* `originalUnit` **Units** of the distance (optional, default `"meters"`)
|
|
476
|
+
* `finalUnit` **Units** returned unit (optional, default `"kilometers"`)
|
|
463
477
|
|
|
464
|
-
Returns **[number][
|
|
478
|
+
Returns **[number][1]** the converted area
|
|
465
479
|
|
|
466
480
|
## isNumber
|
|
467
481
|
|
|
468
482
|
isNumber
|
|
469
483
|
|
|
470
|
-
|
|
484
|
+
### Parameters
|
|
471
485
|
|
|
472
|
-
|
|
486
|
+
* `num` **any** Number to validate
|
|
473
487
|
|
|
474
|
-
|
|
488
|
+
### Examples
|
|
475
489
|
|
|
476
490
|
```javascript
|
|
477
491
|
turf.isNumber(123)
|
|
@@ -486,11 +500,11 @@ Returns **[boolean][26]** true/false
|
|
|
486
500
|
|
|
487
501
|
isObject
|
|
488
502
|
|
|
489
|
-
|
|
503
|
+
### Parameters
|
|
490
504
|
|
|
491
|
-
|
|
505
|
+
* `input` **any** variable to validate
|
|
492
506
|
|
|
493
|
-
|
|
507
|
+
### Examples
|
|
494
508
|
|
|
495
509
|
```javascript
|
|
496
510
|
turf.isObject({elevation: 10})
|
|
@@ -499,19 +513,19 @@ turf.isObject('foo')
|
|
|
499
513
|
//=false
|
|
500
514
|
```
|
|
501
515
|
|
|
502
|
-
Returns **[boolean][26]** true/false
|
|
516
|
+
Returns **[boolean][26]** true/false, including false for Arrays and Functions
|
|
503
517
|
|
|
504
|
-
[1]: https://
|
|
518
|
+
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
505
519
|
|
|
506
|
-
[2]: https://
|
|
520
|
+
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
507
521
|
|
|
508
522
|
[3]: https://tools.ietf.org/html/rfc7946#section-3.1
|
|
509
523
|
|
|
510
|
-
[4]: https://
|
|
524
|
+
[4]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
511
525
|
|
|
512
|
-
[5]: https://
|
|
526
|
+
[5]: https://tools.ietf.org/html/rfc7946#section-3.1
|
|
513
527
|
|
|
514
|
-
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/
|
|
528
|
+
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
515
529
|
|
|
516
530
|
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
517
531
|
|