@turf/helpers 7.1.0 → 7.3.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 +199 -154
- package/dist/cjs/index.cjs +10 -7
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +150 -111
- package/dist/esm/index.d.ts +150 -111
- package/dist/esm/index.js +10 -7
- package/dist/esm/index.js.map +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -4,38 +4,82 @@
|
|
|
4
4
|
|
|
5
5
|
## helpers
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Units
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Linear measurement units.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
⚠️ Warning. Be aware of the implications of using radian or degree units to
|
|
12
|
+
measure distance. The distance represented by a degree of longitude *varies*
|
|
13
|
+
depending on latitude.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
See [https://www.thoughtco.com/degree-of-latitude-and-longitude-distance-4070616][1]
|
|
16
|
+
for an illustration of this behaviour.
|
|
17
|
+
|
|
18
|
+
Type: (`"meters"` | `"metres"` | `"millimeters"` | `"millimetres"` | `"centimeters"` | `"centimetres"` | `"kilometers"` | `"kilometres"` | `"miles"` | `"nauticalmiles"` | `"inches"` | `"yards"` | `"feet"` | `"radians"` | `"degrees"`)
|
|
19
|
+
|
|
20
|
+
## AreaUnits
|
|
21
|
+
|
|
22
|
+
Area measurement units.
|
|
23
|
+
|
|
24
|
+
Type: (Exclude<[Units][2], (`"radians"` | `"degrees"`)> | `"acres"` | `"hectares"`)
|
|
25
|
+
|
|
26
|
+
## Grid
|
|
27
|
+
|
|
28
|
+
Grid types.
|
|
29
|
+
|
|
30
|
+
Type: (`"point"` | `"square"` | `"hex"` | `"triangle"`)
|
|
31
|
+
|
|
32
|
+
## Corners
|
|
33
|
+
|
|
34
|
+
Shorthand corner identifiers.
|
|
35
|
+
|
|
36
|
+
Type: (`"sw"` | `"se"` | `"nw"` | `"ne"` | `"center"` | `"centroid"`)
|
|
37
|
+
|
|
38
|
+
## Lines
|
|
39
|
+
|
|
40
|
+
Geometries made up of lines i.e. lines and polygons.
|
|
41
|
+
|
|
42
|
+
Type: ([LineString][3] | [MultiLineString][4] | [Polygon][5] | [MultiPolygon][6])
|
|
43
|
+
|
|
44
|
+
## AllGeoJSON
|
|
45
|
+
|
|
46
|
+
Convenience type for all possible GeoJSON.
|
|
47
|
+
|
|
48
|
+
Type: ([Feature][7] | [FeatureCollection][8] | [Geometry][9] | [GeometryCollection][10])
|
|
49
|
+
|
|
50
|
+
## earthRadius
|
|
51
|
+
|
|
52
|
+
The Earth radius in meters. Used by Turf modules that model the Earth as a sphere. The [mean radius][11] was selected because it is [recommended ][12] by the Haversine formula (used by turf/distance) to reduce error.
|
|
53
|
+
|
|
54
|
+
Type: [number][13]
|
|
55
|
+
|
|
56
|
+
## factors
|
|
14
57
|
|
|
15
58
|
Unit of measurement factors based on earthRadius.
|
|
16
59
|
|
|
17
60
|
Keys are the name of the unit, values are the number of that unit in a single radian
|
|
18
61
|
|
|
19
|
-
Type: [
|
|
62
|
+
Type: Record<[Units][2], [number][13]>
|
|
20
63
|
|
|
21
|
-
|
|
64
|
+
## areaFactors
|
|
22
65
|
|
|
23
66
|
Area of measurement factors based on 1 square meter.
|
|
24
67
|
|
|
25
|
-
Type: [
|
|
68
|
+
Type: Record<[AreaUnits][14], [number][13]>
|
|
26
69
|
|
|
27
70
|
## feature
|
|
28
71
|
|
|
29
|
-
Wraps a GeoJSON [Geometry][
|
|
72
|
+
Wraps a GeoJSON [Geometry][9] in a GeoJSON [Feature][7].
|
|
30
73
|
|
|
31
74
|
### Parameters
|
|
32
75
|
|
|
33
|
-
* `
|
|
34
|
-
* `properties` **[
|
|
35
|
-
* `options` **[Object][
|
|
76
|
+
* `geom` **(G | null)** 
|
|
77
|
+
* `properties` **[GeoJsonProperties][7]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
78
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
36
79
|
|
|
37
|
-
* `options.bbox` **[
|
|
38
|
-
* `options.id` **
|
|
80
|
+
* `options.bbox` **[BBox][16]?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
81
|
+
* `options.id` **Id?** Identifier associated with the Feature
|
|
82
|
+
* `geometry` **[GeometryObject][9]** input geometry
|
|
39
83
|
|
|
40
84
|
### Examples
|
|
41
85
|
|
|
@@ -50,18 +94,19 @@ var feature = turf.feature(geometry);
|
|
|
50
94
|
//=feature
|
|
51
95
|
```
|
|
52
96
|
|
|
53
|
-
Returns **[Feature][
|
|
97
|
+
Returns **[Feature][7]<[GeometryObject][9], [GeoJsonProperties][7]>** a GeoJSON Feature
|
|
54
98
|
|
|
55
99
|
## geometry
|
|
56
100
|
|
|
57
|
-
Creates a GeoJSON [Geometry][
|
|
101
|
+
Creates a GeoJSON [Geometry][9] from a Geometry string type & coordinates.
|
|
58
102
|
For GeometryCollection type use `helpers.geometryCollection`
|
|
59
103
|
|
|
60
104
|
### Parameters
|
|
61
105
|
|
|
62
|
-
* `type` **
|
|
63
|
-
* `coordinates` **[Array][
|
|
64
|
-
* `
|
|
106
|
+
* `type` **(`"Point"` | `"LineString"` | `"Polygon"` | `"MultiPoint"` | `"MultiLineString"` | `"MultiPolygon"`)** Geometry Type
|
|
107
|
+
* `coordinates` **[Array][17]\<any>** Coordinates
|
|
108
|
+
* `_options` **Record<[string][18], never>** (optional, default `{}`)
|
|
109
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
65
110
|
|
|
66
111
|
### Examples
|
|
67
112
|
|
|
@@ -72,20 +117,20 @@ var geometry = turf.geometry(type, coordinates);
|
|
|
72
117
|
// => geometry
|
|
73
118
|
```
|
|
74
119
|
|
|
75
|
-
Returns **[Geometry][
|
|
120
|
+
Returns **[Geometry][9]** a GeoJSON Geometry
|
|
76
121
|
|
|
77
122
|
## point
|
|
78
123
|
|
|
79
|
-
Creates a [Point][
|
|
124
|
+
Creates a [Point][19] [Feature][7] from a Position.
|
|
80
125
|
|
|
81
126
|
### Parameters
|
|
82
127
|
|
|
83
|
-
* `coordinates` **[
|
|
84
|
-
* `properties` **[
|
|
85
|
-
* `options` **[Object][
|
|
128
|
+
* `coordinates` **[Position][20]** longitude, latitude position (each in decimal degrees)
|
|
129
|
+
* `properties` **[GeoJsonProperties][7]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
130
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
86
131
|
|
|
87
|
-
* `options.bbox` **[
|
|
88
|
-
* `options.id` **
|
|
132
|
+
* `options.bbox` **[BBox][16]?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
133
|
+
* `options.id` **Id?** Identifier associated with the Feature
|
|
89
134
|
|
|
90
135
|
### Examples
|
|
91
136
|
|
|
@@ -95,21 +140,21 @@ var point = turf.point([-75.343, 39.984]);
|
|
|
95
140
|
//=point
|
|
96
141
|
```
|
|
97
142
|
|
|
98
|
-
Returns **[Feature][
|
|
143
|
+
Returns **[Feature][7]<[Point][19], [GeoJsonProperties][7]>** a Point feature
|
|
99
144
|
|
|
100
145
|
## points
|
|
101
146
|
|
|
102
|
-
Creates a [Point][
|
|
147
|
+
Creates a [Point][19] [FeatureCollection][8] from an Array of Point coordinates.
|
|
103
148
|
|
|
104
149
|
### Parameters
|
|
105
150
|
|
|
106
|
-
* `coordinates` **[Array][
|
|
107
|
-
* `properties` **[
|
|
108
|
-
* `options` **[Object][
|
|
151
|
+
* `coordinates` **[Array][17]<[Position][20]>** an array of Points
|
|
152
|
+
* `properties` **[GeoJsonProperties][7]** Translate these properties to each Feature (optional, default `{}`)
|
|
153
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
109
154
|
|
|
110
|
-
* `options.bbox` **[
|
|
155
|
+
* `options.bbox` **[BBox][16]?** Bounding Box Array \[west, south, east, north]
|
|
111
156
|
associated with the FeatureCollection
|
|
112
|
-
* `options.id` **
|
|
157
|
+
* `options.id` **Id?** Identifier associated with the FeatureCollection
|
|
113
158
|
|
|
114
159
|
### Examples
|
|
115
160
|
|
|
@@ -123,20 +168,20 @@ var points = turf.points([
|
|
|
123
168
|
//=points
|
|
124
169
|
```
|
|
125
170
|
|
|
126
|
-
Returns **[FeatureCollection][
|
|
171
|
+
Returns **[FeatureCollection][8]<[Point][19]>** Point Feature
|
|
127
172
|
|
|
128
173
|
## polygon
|
|
129
174
|
|
|
130
|
-
Creates a [Polygon][
|
|
175
|
+
Creates a [Polygon][5] [Feature][7] from an Array of LinearRings.
|
|
131
176
|
|
|
132
177
|
### Parameters
|
|
133
178
|
|
|
134
|
-
* `coordinates` **[Array][
|
|
135
|
-
* `properties` **[
|
|
136
|
-
* `options` **[Object][
|
|
179
|
+
* `coordinates` **[Array][17]<[Array][17]<[Position][20]>>** 
|
|
180
|
+
* `properties` **[GeoJsonProperties][7]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
181
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
137
182
|
|
|
138
|
-
* `options.bbox` **[
|
|
139
|
-
* `options.id` **
|
|
183
|
+
* `options.bbox` **[BBox][16]?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
184
|
+
* `options.id` **Id?** Identifier associated with the Feature
|
|
140
185
|
|
|
141
186
|
### Examples
|
|
142
187
|
|
|
@@ -146,20 +191,20 @@ var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]],
|
|
|
146
191
|
//=polygon
|
|
147
192
|
```
|
|
148
193
|
|
|
149
|
-
Returns **[Feature][
|
|
194
|
+
Returns **[Feature][7]<[Polygon][5], [GeoJsonProperties][7]>** Polygon Feature
|
|
150
195
|
|
|
151
196
|
## polygons
|
|
152
197
|
|
|
153
|
-
Creates a [Polygon][
|
|
198
|
+
Creates a [Polygon][5] [FeatureCollection][8] from an Array of Polygon coordinates.
|
|
154
199
|
|
|
155
200
|
### Parameters
|
|
156
201
|
|
|
157
|
-
* `coordinates` **[Array][
|
|
158
|
-
* `properties` **[
|
|
159
|
-
* `options` **[Object][
|
|
202
|
+
* `coordinates` **[Array][17]<[Array][17]<[Array][17]<[Position][20]>>>** 
|
|
203
|
+
* `properties` **[GeoJsonProperties][7]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
204
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
160
205
|
|
|
161
|
-
* `options.bbox` **[
|
|
162
|
-
* `options.id` **
|
|
206
|
+
* `options.bbox` **[BBox][16]?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
207
|
+
* `options.id` **Id?** Identifier associated with the FeatureCollection
|
|
163
208
|
|
|
164
209
|
### Examples
|
|
165
210
|
|
|
@@ -172,20 +217,20 @@ var polygons = turf.polygons([
|
|
|
172
217
|
//=polygons
|
|
173
218
|
```
|
|
174
219
|
|
|
175
|
-
Returns **[FeatureCollection][
|
|
220
|
+
Returns **[FeatureCollection][8]<[Polygon][5], [GeoJsonProperties][7]>** Polygon FeatureCollection
|
|
176
221
|
|
|
177
222
|
## lineString
|
|
178
223
|
|
|
179
|
-
Creates a [LineString][
|
|
224
|
+
Creates a [LineString][3] [Feature][7] from an Array of Positions.
|
|
180
225
|
|
|
181
226
|
### Parameters
|
|
182
227
|
|
|
183
|
-
* `coordinates` **[Array][
|
|
184
|
-
* `properties` **[
|
|
185
|
-
* `options` **[Object][
|
|
228
|
+
* `coordinates` **[Array][17]<[Position][20]>** an array of Positions
|
|
229
|
+
* `properties` **[GeoJsonProperties][7]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
230
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
186
231
|
|
|
187
|
-
* `options.bbox` **[
|
|
188
|
-
* `options.id` **
|
|
232
|
+
* `options.bbox` **[BBox][16]?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
233
|
+
* `options.id` **Id?** Identifier associated with the Feature
|
|
189
234
|
|
|
190
235
|
### Examples
|
|
191
236
|
|
|
@@ -197,21 +242,21 @@ var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]],
|
|
|
197
242
|
//=linestring2
|
|
198
243
|
```
|
|
199
244
|
|
|
200
|
-
Returns **[Feature][
|
|
245
|
+
Returns **[Feature][7]<[LineString][3], [GeoJsonProperties][7]>** LineString Feature
|
|
201
246
|
|
|
202
247
|
## lineStrings
|
|
203
248
|
|
|
204
|
-
Creates a [LineString][
|
|
249
|
+
Creates a [LineString][3] [FeatureCollection][8] from an Array of LineString coordinates.
|
|
205
250
|
|
|
206
251
|
### Parameters
|
|
207
252
|
|
|
208
|
-
* `coordinates` **[Array][
|
|
209
|
-
* `properties` **[
|
|
210
|
-
* `options` **[Object][
|
|
253
|
+
* `coordinates` **[Array][17]<[Array][17]<[Position][20]>>** 
|
|
254
|
+
* `properties` **[GeoJsonProperties][7]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
255
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
211
256
|
|
|
212
|
-
* `options.bbox` **[
|
|
257
|
+
* `options.bbox` **[BBox][16]?** Bounding Box Array \[west, south, east, north]
|
|
213
258
|
associated with the FeatureCollection
|
|
214
|
-
* `options.id` **
|
|
259
|
+
* `options.id` **Id?** Identifier associated with the FeatureCollection
|
|
215
260
|
|
|
216
261
|
### Examples
|
|
217
262
|
|
|
@@ -224,19 +269,19 @@ var linestrings = turf.lineStrings([
|
|
|
224
269
|
//=linestrings
|
|
225
270
|
```
|
|
226
271
|
|
|
227
|
-
Returns **[FeatureCollection][
|
|
272
|
+
Returns **[FeatureCollection][8]<[LineString][3], [GeoJsonProperties][7]>** LineString FeatureCollection
|
|
228
273
|
|
|
229
274
|
## featureCollection
|
|
230
275
|
|
|
231
|
-
Takes one or more [Features][
|
|
276
|
+
Takes one or more [Features][7] and creates a [FeatureCollection][8].
|
|
232
277
|
|
|
233
278
|
### Parameters
|
|
234
279
|
|
|
235
|
-
* `features` **[Array][
|
|
236
|
-
* `options` **[Object][
|
|
280
|
+
* `features` **[Array][17]<[Feature][7]<[GeometryObject][9], [GeoJsonProperties][7]>>** input features
|
|
281
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
237
282
|
|
|
238
|
-
* `options.bbox` **[
|
|
239
|
-
* `options.id` **
|
|
283
|
+
* `options.bbox` **[BBox][16]?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
284
|
+
* `options.id` **Id?** Identifier associated with the Feature
|
|
240
285
|
|
|
241
286
|
### Examples
|
|
242
287
|
|
|
@@ -254,21 +299,21 @@ var collection = turf.featureCollection([
|
|
|
254
299
|
//=collection
|
|
255
300
|
```
|
|
256
301
|
|
|
257
|
-
Returns **[FeatureCollection][
|
|
302
|
+
Returns **[FeatureCollection][8]<[GeometryObject][9], [GeoJsonProperties][7]>** FeatureCollection of Features
|
|
258
303
|
|
|
259
304
|
## multiLineString
|
|
260
305
|
|
|
261
|
-
Creates a [Feature
|
|
306
|
+
Creates a [Feature][7]<[MultiLineString][4]> based on a
|
|
262
307
|
coordinate array. Properties can be added optionally.
|
|
263
308
|
|
|
264
309
|
### Parameters
|
|
265
310
|
|
|
266
|
-
* `coordinates` **[Array][
|
|
267
|
-
* `properties` **[
|
|
268
|
-
* `options` **[Object][
|
|
311
|
+
* `coordinates` **[Array][17]<[Array][17]<[Position][20]>>** 
|
|
312
|
+
* `properties` **[GeoJsonProperties][7]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
313
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
269
314
|
|
|
270
|
-
* `options.bbox` **[
|
|
271
|
-
* `options.id` **
|
|
315
|
+
* `options.bbox` **[BBox][16]?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
316
|
+
* `options.id` **Id?** Identifier associated with the Feature
|
|
272
317
|
|
|
273
318
|
### Examples
|
|
274
319
|
|
|
@@ -278,23 +323,23 @@ var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
|
|
|
278
323
|
//=multiLine
|
|
279
324
|
```
|
|
280
325
|
|
|
281
|
-
* Throws **[Error][
|
|
326
|
+
* Throws **[Error][21]** if no coordinates are passed
|
|
282
327
|
|
|
283
|
-
Returns **[Feature][
|
|
328
|
+
Returns **[Feature][7]<[MultiLineString][4], [GeoJsonProperties][7]>** a MultiLineString feature
|
|
284
329
|
|
|
285
330
|
## multiPoint
|
|
286
331
|
|
|
287
|
-
Creates a [Feature
|
|
332
|
+
Creates a [Feature][7]<[MultiPoint][22]> based on a
|
|
288
333
|
coordinate array. Properties can be added optionally.
|
|
289
334
|
|
|
290
335
|
### Parameters
|
|
291
336
|
|
|
292
|
-
* `coordinates` **[Array][
|
|
293
|
-
* `properties` **[
|
|
294
|
-
* `options` **[Object][
|
|
337
|
+
* `coordinates` **[Array][17]<[Position][20]>** an array of Positions
|
|
338
|
+
* `properties` **[GeoJsonProperties][7]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
339
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
295
340
|
|
|
296
|
-
* `options.bbox` **[
|
|
297
|
-
* `options.id` **
|
|
341
|
+
* `options.bbox` **[BBox][16]?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
342
|
+
* `options.id` **Id?** Identifier associated with the Feature
|
|
298
343
|
|
|
299
344
|
### Examples
|
|
300
345
|
|
|
@@ -304,23 +349,23 @@ var multiPt = turf.multiPoint([[0,0],[10,10]]);
|
|
|
304
349
|
//=multiPt
|
|
305
350
|
```
|
|
306
351
|
|
|
307
|
-
* Throws **[Error][
|
|
352
|
+
* Throws **[Error][21]** if no coordinates are passed
|
|
308
353
|
|
|
309
|
-
Returns **[Feature][
|
|
354
|
+
Returns **[Feature][7]<[MultiPoint][22], [GeoJsonProperties][7]>** a MultiPoint feature
|
|
310
355
|
|
|
311
356
|
## multiPolygon
|
|
312
357
|
|
|
313
|
-
Creates a [Feature
|
|
358
|
+
Creates a [Feature][7]<[MultiPolygon][6]> based on a
|
|
314
359
|
coordinate array. Properties can be added optionally.
|
|
315
360
|
|
|
316
361
|
### Parameters
|
|
317
362
|
|
|
318
|
-
* `coordinates` **[Array][
|
|
319
|
-
* `properties` **[
|
|
320
|
-
* `options` **[Object][
|
|
363
|
+
* `coordinates` **[Array][17]<[Array][17]<[Array][17]<[Position][20]>>>** 
|
|
364
|
+
* `properties` **[GeoJsonProperties][7]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
365
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
321
366
|
|
|
322
|
-
* `options.bbox` **[
|
|
323
|
-
* `options.id` **
|
|
367
|
+
* `options.bbox` **[BBox][16]?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
368
|
+
* `options.id` **Id?** Identifier associated with the Feature
|
|
324
369
|
|
|
325
370
|
### Examples
|
|
326
371
|
|
|
@@ -330,23 +375,23 @@ var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
|
|
|
330
375
|
//=multiPoly
|
|
331
376
|
```
|
|
332
377
|
|
|
333
|
-
* Throws **[Error][
|
|
378
|
+
* Throws **[Error][21]** if no coordinates are passed
|
|
334
379
|
|
|
335
|
-
Returns **[Feature][
|
|
380
|
+
Returns **[Feature][7]<[MultiPolygon][6], [GeoJsonProperties][7]>** a multipolygon feature
|
|
336
381
|
|
|
337
382
|
## geometryCollection
|
|
338
383
|
|
|
339
|
-
Creates a
|
|
384
|
+
Creates a Feature<GeometryCollection> based on a
|
|
340
385
|
coordinate array. Properties can be added optionally.
|
|
341
386
|
|
|
342
387
|
### Parameters
|
|
343
388
|
|
|
344
|
-
* `geometries` **[Array][
|
|
345
|
-
* `properties` **[
|
|
346
|
-
* `options` **[Object][
|
|
389
|
+
* `geometries` **[Array][17]<([Point][19] | [LineString][3] | [Polygon][5] | [MultiPoint][22] | [MultiLineString][4] | [MultiPolygon][6])>** an array of GeoJSON Geometries
|
|
390
|
+
* `properties` **[GeoJsonProperties][7]** an Object of key-value pairs to add as properties (optional, default `{}`)
|
|
391
|
+
* `options` **[Object][15]** Optional Parameters (optional, default `{}`)
|
|
347
392
|
|
|
348
|
-
* `options.bbox` **[
|
|
349
|
-
* `options.id` **
|
|
393
|
+
* `options.bbox` **[BBox][16]?** Bounding Box Array \[west, south, east, north] associated with the Feature
|
|
394
|
+
* `options.id` **Id?** Identifier associated with the Feature
|
|
350
395
|
|
|
351
396
|
### Examples
|
|
352
397
|
|
|
@@ -358,7 +403,7 @@ var collection = turf.geometryCollection([pt, line]);
|
|
|
358
403
|
// => collection
|
|
359
404
|
```
|
|
360
405
|
|
|
361
|
-
Returns **[Feature][
|
|
406
|
+
Returns **[Feature][7]<[GeometryCollection][10], [GeoJsonProperties][7]>** a GeoJSON GeometryCollection Feature
|
|
362
407
|
|
|
363
408
|
## round
|
|
364
409
|
|
|
@@ -366,8 +411,8 @@ Round number to precision
|
|
|
366
411
|
|
|
367
412
|
### Parameters
|
|
368
413
|
|
|
369
|
-
* `num` **[number][
|
|
370
|
-
* `precision` **[number][
|
|
414
|
+
* `num` **[number][13]** Number
|
|
415
|
+
* `precision` **[number][13]** Precision (optional, default `0`)
|
|
371
416
|
|
|
372
417
|
### Examples
|
|
373
418
|
|
|
@@ -379,7 +424,7 @@ turf.round(120.4321, 2)
|
|
|
379
424
|
//=120.43
|
|
380
425
|
```
|
|
381
426
|
|
|
382
|
-
Returns **[number][
|
|
427
|
+
Returns **[number][13]** rounded number
|
|
383
428
|
|
|
384
429
|
## radiansToLength
|
|
385
430
|
|
|
@@ -388,11 +433,11 @@ Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, ce
|
|
|
388
433
|
|
|
389
434
|
### Parameters
|
|
390
435
|
|
|
391
|
-
* `radians` **[number][
|
|
392
|
-
* `units` **[
|
|
436
|
+
* `radians` **[number][13]** in radians across the sphere
|
|
437
|
+
* `units` **[Units][2]** can be degrees, radians, miles, inches, yards, metres,
|
|
393
438
|
meters, kilometres, kilometers. (optional, default `"kilometers"`)
|
|
394
439
|
|
|
395
|
-
Returns **[number][
|
|
440
|
+
Returns **[number][13]** distance
|
|
396
441
|
|
|
397
442
|
## lengthToRadians
|
|
398
443
|
|
|
@@ -401,11 +446,11 @@ Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, ce
|
|
|
401
446
|
|
|
402
447
|
### Parameters
|
|
403
448
|
|
|
404
|
-
* `distance` **[number][
|
|
405
|
-
* `units` **[
|
|
449
|
+
* `distance` **[number][13]** in real units
|
|
450
|
+
* `units` **[Units][2]** can be degrees, radians, miles, inches, yards, metres,
|
|
406
451
|
meters, kilometres, kilometers. (optional, default `"kilometers"`)
|
|
407
452
|
|
|
408
|
-
Returns **[number][
|
|
453
|
+
Returns **[number][13]** radians
|
|
409
454
|
|
|
410
455
|
## lengthToDegrees
|
|
411
456
|
|
|
@@ -414,11 +459,11 @@ Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, k
|
|
|
414
459
|
|
|
415
460
|
### Parameters
|
|
416
461
|
|
|
417
|
-
* `distance` **[number][
|
|
418
|
-
* `units` **[
|
|
462
|
+
* `distance` **[number][13]** in real units
|
|
463
|
+
* `units` **[Units][2]** can be degrees, radians, miles, inches, yards, metres,
|
|
419
464
|
meters, kilometres, kilometers. (optional, default `"kilometers"`)
|
|
420
465
|
|
|
421
|
-
Returns **[number][
|
|
466
|
+
Returns **[number][13]** degrees
|
|
422
467
|
|
|
423
468
|
## bearingToAzimuth
|
|
424
469
|
|
|
@@ -427,9 +472,9 @@ and returns an angle between 0-360 degrees (positive clockwise), 0 being the nor
|
|
|
427
472
|
|
|
428
473
|
### Parameters
|
|
429
474
|
|
|
430
|
-
* `bearing` **[number][
|
|
475
|
+
* `bearing` **[number][13]** angle, between -180 and +180 degrees
|
|
431
476
|
|
|
432
|
-
Returns **[number][
|
|
477
|
+
Returns **[number][13]** angle between 0 and 360 degrees
|
|
433
478
|
|
|
434
479
|
## azimuthToBearing
|
|
435
480
|
|
|
@@ -438,9 +483,9 @@ and returns an angle between -180 and +180 degrees (positive clockwise), 0 being
|
|
|
438
483
|
|
|
439
484
|
### Parameters
|
|
440
485
|
|
|
441
|
-
* `angle` **[number][
|
|
486
|
+
* `angle` **[number][13]** between 0 and 360 degrees
|
|
442
487
|
|
|
443
|
-
Returns **[number][
|
|
488
|
+
Returns **[number][13]** bearing between -180 and +180 degrees
|
|
444
489
|
|
|
445
490
|
## radiansToDegrees
|
|
446
491
|
|
|
@@ -448,9 +493,9 @@ Converts an angle in radians to degrees
|
|
|
448
493
|
|
|
449
494
|
### Parameters
|
|
450
495
|
|
|
451
|
-
* `radians` **[number][
|
|
496
|
+
* `radians` **[number][13]** angle in radians
|
|
452
497
|
|
|
453
|
-
Returns **[number][
|
|
498
|
+
Returns **[number][13]** degrees between 0 and 360 degrees
|
|
454
499
|
|
|
455
500
|
## degreesToRadians
|
|
456
501
|
|
|
@@ -458,35 +503,33 @@ Converts an angle in degrees to radians
|
|
|
458
503
|
|
|
459
504
|
### Parameters
|
|
460
505
|
|
|
461
|
-
* `degrees` **[number][
|
|
506
|
+
* `degrees` **[number][13]** angle between 0 and 360 degrees
|
|
462
507
|
|
|
463
|
-
Returns **[number][
|
|
508
|
+
Returns **[number][13]** angle in radians
|
|
464
509
|
|
|
465
510
|
## convertLength
|
|
466
511
|
|
|
467
|
-
Converts a length
|
|
468
|
-
Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
|
|
512
|
+
Converts a length from one unit to another.
|
|
469
513
|
|
|
470
514
|
### Parameters
|
|
471
515
|
|
|
472
|
-
* `length` **[number][
|
|
473
|
-
* `originalUnit` **Units**
|
|
474
|
-
* `finalUnit` **Units**
|
|
516
|
+
* `length` **[number][13]** Length to be converted
|
|
517
|
+
* `originalUnit` **[Units][2]** Input length unit (optional, default `"kilometers"`)
|
|
518
|
+
* `finalUnit` **[Units][2]** Returned length unit (optional, default `"kilometers"`)
|
|
475
519
|
|
|
476
|
-
Returns **[number][
|
|
520
|
+
Returns **[number][13]** The converted length
|
|
477
521
|
|
|
478
522
|
## convertArea
|
|
479
523
|
|
|
480
|
-
Converts
|
|
481
|
-
Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares
|
|
524
|
+
Converts an area from one unit to another.
|
|
482
525
|
|
|
483
526
|
### Parameters
|
|
484
527
|
|
|
485
|
-
* `area` **[number][
|
|
486
|
-
* `originalUnit` **
|
|
487
|
-
* `finalUnit` **
|
|
528
|
+
* `area` **[number][13]** Area to be converted
|
|
529
|
+
* `originalUnit` **[AreaUnits][14]** Input area unit (optional, default `"meters"`)
|
|
530
|
+
* `finalUnit` **[AreaUnits][14]** Returned area unit (optional, default `"kilometers"`)
|
|
488
531
|
|
|
489
|
-
Returns **[number][
|
|
532
|
+
Returns **[number][13]** The converted length
|
|
490
533
|
|
|
491
534
|
## isNumber
|
|
492
535
|
|
|
@@ -505,7 +548,7 @@ turf.isNumber('foo')
|
|
|
505
548
|
//=false
|
|
506
549
|
```
|
|
507
550
|
|
|
508
|
-
Returns **[boolean][
|
|
551
|
+
Returns **[boolean][23]** true/false
|
|
509
552
|
|
|
510
553
|
## isObject
|
|
511
554
|
|
|
@@ -524,51 +567,53 @@ turf.isObject('foo')
|
|
|
524
567
|
//=false
|
|
525
568
|
```
|
|
526
569
|
|
|
527
|
-
Returns **[boolean][
|
|
570
|
+
Returns **[boolean][23]** true/false, including false for Arrays and Functions
|
|
571
|
+
|
|
572
|
+
[1]: https://www.thoughtco.com/degree-of-latitude-and-longitude-distance-4070616
|
|
528
573
|
|
|
529
|
-
[
|
|
574
|
+
[2]: #units
|
|
530
575
|
|
|
531
|
-
[
|
|
576
|
+
[3]: https://tools.ietf.org/html/rfc7946#section-3.1.4
|
|
532
577
|
|
|
533
|
-
[
|
|
578
|
+
[4]: https://tools.ietf.org/html/rfc7946#section-3.1.5
|
|
534
579
|
|
|
535
|
-
[
|
|
580
|
+
[5]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
536
581
|
|
|
537
|
-
[
|
|
582
|
+
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.7
|
|
538
583
|
|
|
539
|
-
[
|
|
584
|
+
[7]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
540
585
|
|
|
541
|
-
[
|
|
586
|
+
[8]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
542
587
|
|
|
543
|
-
[
|
|
588
|
+
[9]: https://tools.ietf.org/html/rfc7946#section-3.1
|
|
544
589
|
|
|
545
|
-
[
|
|
590
|
+
[10]: https://tools.ietf.org/html/rfc7946#section-3.1.8
|
|
546
591
|
|
|
547
|
-
[
|
|
592
|
+
[11]: https://en.wikipedia.org/wiki/Earth_radius#Arithmetic_mean_radius
|
|
548
593
|
|
|
549
|
-
[
|
|
594
|
+
[12]: https://rosettacode.org/wiki/Haversine_formula#:~:text=This%20value%20is%20recommended
|
|
550
595
|
|
|
551
|
-
[
|
|
596
|
+
[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
552
597
|
|
|
553
|
-
[
|
|
598
|
+
[14]: #areaunits
|
|
554
599
|
|
|
555
|
-
[
|
|
600
|
+
[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
556
601
|
|
|
557
|
-
[
|
|
602
|
+
[16]: https://tools.ietf.org/html/rfc7946#section-5
|
|
558
603
|
|
|
559
|
-
[
|
|
604
|
+
[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
560
605
|
|
|
561
|
-
[
|
|
606
|
+
[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
562
607
|
|
|
563
|
-
[
|
|
608
|
+
[19]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
564
609
|
|
|
565
|
-
[
|
|
610
|
+
[20]: https://developer.mozilla.org/docs/Web/API/Position
|
|
566
611
|
|
|
567
|
-
[
|
|
612
|
+
[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
|
568
613
|
|
|
569
|
-
[
|
|
614
|
+
[22]: https://tools.ietf.org/html/rfc7946#section-3.1.3
|
|
570
615
|
|
|
571
|
-
[
|
|
616
|
+
[23]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
572
617
|
|
|
573
618
|
<!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
|
|
574
619
|
|