@turf/helpers 4.7.0 → 5.0.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.
Files changed (5) hide show
  1. package/README.md +76 -55
  2. package/index.d.ts +52 -45
  3. package/index.js +45 -46
  4. package/main.js +567 -0
  5. package/package.json +20 -7
package/README.md CHANGED
@@ -1,15 +1,17 @@
1
1
  # @turf/helpers
2
2
 
3
- # feature
3
+ <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
4
+
5
+ ## feature
4
6
 
5
7
  Wraps a GeoJSON [Geometry](http://geojson.org/geojson-spec.html#geometry) in a GeoJSON [Feature](http://geojson.org/geojson-spec.html#feature-objects).
6
8
 
7
9
  **Parameters**
8
10
 
9
11
  - `geometry` **[Geometry](http://geojson.org/geojson-spec.html#geometry)** input geometry
10
- - `properties` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** an Object of key-value pairs to add as properties (optional, default `{}`)
11
- - `bbox` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>]** BBox [west, south, east, north]
12
- - `id` **\[([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** Identifier
12
+ - `properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an Object of key-value pairs to add as properties (optional, default `{}`)
13
+ - `bbox` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** BBox [west, south, east, north]
14
+ - `id` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))?** Identifier
13
15
 
14
16
  **Examples**
15
17
 
@@ -26,7 +28,7 @@ var feature = turf.feature(geometry);
26
28
 
27
29
  Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)** a GeoJSON Feature
28
30
 
29
- # geometry
31
+ ## geometry
30
32
 
31
33
  Creates a GeoJSON [Geometry](http://geojson.org/geojson-spec.html#geometry) from a Geometry string type & coordinates.
32
34
  For GeometryCollection type use `helpers.geometryCollection`
@@ -35,7 +37,7 @@ For GeometryCollection type use `helpers.geometryCollection`
35
37
 
36
38
  - `type` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Geometry Type
37
39
  - `coordinates` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** Coordinates
38
- - `bbox` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>]** BBox [west, south, east, north]
40
+ - `bbox` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** BBox [west, south, east, north]
39
41
 
40
42
  **Examples**
41
43
 
@@ -50,16 +52,16 @@ var geometry = turf.geometry(type, coordinates);
50
52
 
51
53
  Returns **[Geometry](http://geojson.org/geojson-spec.html#geometry)** a GeoJSON Geometry
52
54
 
53
- # point
55
+ ## point
54
56
 
55
57
  Takes coordinates and properties (optional) and returns a new [Point](http://geojson.org/geojson-spec.html#point) feature.
56
58
 
57
59
  **Parameters**
58
60
 
59
61
  - `coordinates` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** longitude, latitude position (each in decimal degrees)
60
- - `properties` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** an Object of key-value pairs to add as properties (optional, default `{}`)
61
- - `bbox` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>]** BBox [west, south, east, north]
62
- - `id` **\[([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** Identifier
62
+ - `properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an Object of key-value pairs to add as properties (optional, default `{}`)
63
+ - `bbox` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** BBox [west, south, east, north]
64
+ - `id` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))?** Identifier
63
65
 
64
66
  **Examples**
65
67
 
@@ -71,16 +73,16 @@ var point = turf.point([-75.343, 39.984]);
71
73
 
72
74
  Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)>** a Point feature
73
75
 
74
- # polygon
76
+ ## polygon
75
77
 
76
78
  Takes an array of LinearRings and optionally an [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) with properties and returns a [Polygon](http://geojson.org/geojson-spec.html#polygon) feature.
77
79
 
78
80
  **Parameters**
79
81
 
80
82
  - `coordinates` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>>>** an array of LinearRings
81
- - `properties` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** an Object of key-value pairs to add as properties (optional, default `{}`)
82
- - `bbox` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>]** BBox [west, south, east, north]
83
- - `id` **\[([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** Identifier
83
+ - `properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an Object of key-value pairs to add as properties (optional, default `{}`)
84
+ - `bbox` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** BBox [west, south, east, north]
85
+ - `id` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))?** Identifier
84
86
 
85
87
  **Examples**
86
88
 
@@ -101,7 +103,7 @@ var polygon = turf.polygon([[
101
103
 
102
104
  Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Polygon](http://geojson.org/geojson-spec.html#polygon)>** a Polygon feature
103
105
 
104
- # lineString
106
+ ## lineString
105
107
 
106
108
  Creates a [LineString](http://geojson.org/geojson-spec.html#linestring) based on a
107
109
  coordinate array. Properties can be added optionally.
@@ -109,9 +111,9 @@ coordinate array. Properties can be added optionally.
109
111
  **Parameters**
110
112
 
111
113
  - `coordinates` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>>** an array of Positions
112
- - `properties` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** an Object of key-value pairs to add as properties (optional, default `{}`)
113
- - `bbox` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>]** BBox [west, south, east, north]
114
- - `id` **\[([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** Identifier
114
+ - `properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an Object of key-value pairs to add as properties (optional, default `{}`)
115
+ - `bbox` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** BBox [west, south, east, north]
116
+ - `id` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))?** Identifier
115
117
 
116
118
  **Examples**
117
119
 
@@ -138,15 +140,15 @@ var linestring2 = turf.lineString([
138
140
 
139
141
  Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[LineString](http://geojson.org/geojson-spec.html#linestring)>** a LineString feature
140
142
 
141
- # featureCollection
143
+ ## featureCollection
142
144
 
143
145
  Takes one or more [Features](http://geojson.org/geojson-spec.html#feature-objects) and creates a [FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects).
144
146
 
145
147
  **Parameters**
146
148
 
147
149
  - `features` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Feature](http://geojson.org/geojson-spec.html#feature-objects)>** input features
148
- - `bbox` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>]** BBox [west, south, east, north]
149
- - `id` **\[([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** Identifier
150
+ - `bbox` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** BBox [west, south, east, north]
151
+ - `id` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))?** Identifier
150
152
 
151
153
  **Examples**
152
154
 
@@ -164,7 +166,7 @@ var collection = turf.featureCollection(features);
164
166
 
165
167
  Returns **[FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects)** a FeatureCollection of input features
166
168
 
167
- # multiLineString
169
+ ## multiLineString
168
170
 
169
171
  Creates a [Feature&lt;MultiLineString>](Feature<MultiLineString>) based on a
170
172
  coordinate array. Properties can be added optionally.
@@ -172,9 +174,9 @@ coordinate array. Properties can be added optionally.
172
174
  **Parameters**
173
175
 
174
176
  - `coordinates` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>>>** an array of LineStrings
175
- - `properties` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** an Object of key-value pairs to add as properties (optional, default `{}`)
176
- - `bbox` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>]** BBox [west, south, east, north]
177
- - `id` **\[([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** Identifier
177
+ - `properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an Object of key-value pairs to add as properties (optional, default `{}`)
178
+ - `bbox` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** BBox [west, south, east, north]
179
+ - `id` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))?** Identifier
178
180
 
179
181
  **Examples**
180
182
 
@@ -188,7 +190,7 @@ var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
188
190
 
189
191
  Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[MultiLineString](http://geojson.org/geojson-spec.html#multilinestring)>** a MultiLineString feature
190
192
 
191
- # multiPoint
193
+ ## multiPoint
192
194
 
193
195
  Creates a [Feature&lt;MultiPoint>](Feature<MultiPoint>) based on a
194
196
  coordinate array. Properties can be added optionally.
@@ -196,9 +198,9 @@ coordinate array. Properties can be added optionally.
196
198
  **Parameters**
197
199
 
198
200
  - `coordinates` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>>** an array of Positions
199
- - `properties` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** an Object of key-value pairs to add as properties (optional, default `{}`)
200
- - `bbox` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>]** BBox [west, south, east, north]
201
- - `id` **\[([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** Identifier
201
+ - `properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an Object of key-value pairs to add as properties (optional, default `{}`)
202
+ - `bbox` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** BBox [west, south, east, north]
203
+ - `id` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))?** Identifier
202
204
 
203
205
  **Examples**
204
206
 
@@ -212,7 +214,7 @@ var multiPt = turf.multiPoint([[0,0],[10,10]]);
212
214
 
213
215
  Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[MultiPoint](http://geojson.org/geojson-spec.html#multipoint)>** a MultiPoint feature
214
216
 
215
- # multiPolygon
217
+ ## multiPolygon
216
218
 
217
219
  Creates a [Feature&lt;MultiPolygon>](Feature<MultiPolygon>) based on a
218
220
  coordinate array. Properties can be added optionally.
@@ -220,9 +222,9 @@ coordinate array. Properties can be added optionally.
220
222
  **Parameters**
221
223
 
222
224
  - `coordinates` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>>>>** an array of Polygons
223
- - `properties` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** an Object of key-value pairs to add as properties (optional, default `{}`)
224
- - `bbox` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>]** BBox [west, south, east, north]
225
- - `id` **\[([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** Identifier
225
+ - `properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an Object of key-value pairs to add as properties (optional, default `{}`)
226
+ - `bbox` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** BBox [west, south, east, north]
227
+ - `id` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))?** Identifier
226
228
 
227
229
  **Examples**
228
230
 
@@ -236,7 +238,7 @@ var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
236
238
 
237
239
  Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon)>** a multipolygon feature
238
240
 
239
- # geometryCollection
241
+ ## geometryCollection
240
242
 
241
243
  Creates a [Feature&lt;GeometryCollection>](Feature<GeometryCollection>) based on a
242
244
  coordinate array. Properties can be added optionally.
@@ -244,9 +246,9 @@ coordinate array. Properties can be added optionally.
244
246
  **Parameters**
245
247
 
246
248
  - `geometries` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Geometry](http://geojson.org/geojson-spec.html#geometry)>** an array of GeoJSON Geometries
247
- - `properties` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** an Object of key-value pairs to add as properties (optional, default `{}`)
248
- - `bbox` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>]** BBox [west, south, east, north]
249
- - `id` **\[([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))]** Identifier
249
+ - `properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an Object of key-value pairs to add as properties (optional, default `{}`)
250
+ - `bbox` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** BBox [west, south, east, north]
251
+ - `id` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))?** Identifier
250
252
 
251
253
  **Examples**
252
254
 
@@ -266,14 +268,14 @@ var collection = turf.geometryCollection([pt, line]);
266
268
 
267
269
  Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[GeometryCollection](http://geojson.org/geojson-spec.html#geometrycollection)>** a GeoJSON GeometryCollection Feature
268
270
 
269
- # round
271
+ ## round
270
272
 
271
273
  Round number to precision
272
274
 
273
275
  **Parameters**
274
276
 
275
277
  - `num` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number
276
- - `precision` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** Precision (optional, default `0`)
278
+ - `precision` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Precision (optional, default `0`)
277
279
 
278
280
  **Examples**
279
281
 
@@ -287,7 +289,7 @@ turf.round(120.4321, 2)
287
289
 
288
290
  Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** rounded number
289
291
 
290
- # radiansToDistance
292
+ ## radiansToDistance
291
293
 
292
294
  Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
293
295
  Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
@@ -295,11 +297,11 @@ Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, ce
295
297
  **Parameters**
296
298
 
297
299
  - `radians` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** in radians across the sphere
298
- - `units` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. (optional, default `kilometers`)
300
+ - `units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. (optional, default `"kilometers"`)
299
301
 
300
302
  Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** distance
301
303
 
302
- # distanceToRadians
304
+ ## distanceToRadians
303
305
 
304
306
  Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
305
307
  Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
@@ -307,11 +309,11 @@ Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, ce
307
309
  **Parameters**
308
310
 
309
311
  - `distance` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** in real units
310
- - `units` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. (optional, default `kilometers`)
312
+ - `units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. (optional, default `kilometers`)
311
313
 
312
314
  Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** radians
313
315
 
314
- # distanceToDegrees
316
+ ## distanceToDegrees
315
317
 
316
318
  Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
317
319
  Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
@@ -319,11 +321,11 @@ Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, k
319
321
  **Parameters**
320
322
 
321
323
  - `distance` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** in real units
322
- - `units` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. (optional, default `kilometers`)
324
+ - `units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers. (optional, default `kilometers`)
323
325
 
324
326
  Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** degrees
325
327
 
326
- # bearingToAngle
328
+ ## bearingToAngle
327
329
 
328
330
  Converts any bearing angle from the north line direction (positive clockwise)
329
331
  and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
@@ -334,7 +336,7 @@ and returns an angle between 0-360 degrees (positive clockwise), 0 being the nor
334
336
 
335
337
  Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** angle between 0 and 360 degrees
336
338
 
337
- # radians2degrees
339
+ ## radians2degrees
338
340
 
339
341
  Converts an angle in radians to degrees
340
342
 
@@ -344,7 +346,7 @@ Converts an angle in radians to degrees
344
346
 
345
347
  Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** degrees between 0 and 360 degrees
346
348
 
347
- # degrees2radians
349
+ ## degrees2radians
348
350
 
349
351
  Converts an angle in degrees to radians
350
352
 
@@ -354,7 +356,7 @@ Converts an angle in degrees to radians
354
356
 
355
357
  Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** angle in radians
356
358
 
357
- # convertDistance
359
+ ## convertDistance
358
360
 
359
361
  Converts a distance to the requested unit.
360
362
  Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
@@ -363,11 +365,11 @@ Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, ce
363
365
 
364
366
  - `distance` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** to be converted
365
367
  - `originalUnit` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** of the distance
366
- - `finalUnit` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** returned unit (optional, default `kilometers`)
368
+ - `finalUnit` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** returned unit (optional, default `kilometers`)
367
369
 
368
370
  Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the converted distance
369
371
 
370
- # convertArea
372
+ ## convertArea
371
373
 
372
374
  Converts a area to the requested unit.
373
375
  Valid units: kilometers, kilometres, meters, metres, centimetres, millimeter, acre, mile, yard, foot, inch
@@ -375,18 +377,18 @@ Valid units: kilometers, kilometres, meters, metres, centimetres, millimeter, ac
375
377
  **Parameters**
376
378
 
377
379
  - `area` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** to be converted
378
- - `originalUnit` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** of the distance (optional, default `meters`)
379
- - `finalUnit` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** returned unit (optional, default `kilometers`)
380
+ - `originalUnit` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** of the distance (optional, default `meters`)
381
+ - `finalUnit` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** returned unit (optional, default `kilometers`)
380
382
 
381
383
  Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the converted distance
382
384
 
383
- # isNumber
385
+ ## isNumber
384
386
 
385
387
  isNumber
386
388
 
387
389
  **Parameters**
388
390
 
389
- - `num` **Any** Number to validate
391
+ - `num` **any** Number to validate
390
392
 
391
393
  **Examples**
392
394
 
@@ -399,6 +401,25 @@ turf.isNumber('foo')
399
401
 
400
402
  Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false
401
403
 
404
+ ## isObject
405
+
406
+ isObject
407
+
408
+ **Parameters**
409
+
410
+ - `input` **any** variable to validate
411
+
412
+ **Examples**
413
+
414
+ ```javascript
415
+ turf.isObject({elevation: 10})
416
+ //=true
417
+ turf.isObject('foo')
418
+ //=false
419
+ ```
420
+
421
+ Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true/false
422
+
402
423
  <!-- This file is automatically generated. Please don't edit it directly:
403
424
  if you find an error, edit the source file (likely index.js), and re-run
404
425
  ./scripts/generate-readmes in the turf project. -->
package/index.d.ts CHANGED
@@ -1,87 +1,84 @@
1
1
  /// <reference types='geojson' />
2
2
 
3
- export type Id = string|number
4
- export type Points = GeoJSON.FeatureCollection<GeoJSON.Point>;
5
- export type Point = GeoJSON.Feature<GeoJSON.Point>;
6
- export type MultiPoints = GeoJSON.FeatureCollection<GeoJSON.MultiPoint>;
7
- export type MultiPoint = GeoJSON.Feature<GeoJSON.MultiPoint>;
8
- export type LineStrings = GeoJSON.FeatureCollection<GeoJSON.LineString>;
9
- export type LineString = GeoJSON.Feature<GeoJSON.LineString>;
10
- export type MultiLineStrings = GeoJSON.FeatureCollection<GeoJSON.MultiLineString>;
11
- export type MultiLineString = GeoJSON.Feature<GeoJSON.MultiLineString>;
12
- export type Polygons = GeoJSON.FeatureCollection<GeoJSON.Polygon>;
13
- export type Polygon = GeoJSON.Feature<GeoJSON.Polygon>;
14
- export type MultiPolygons = GeoJSON.FeatureCollection<GeoJSON.MultiPolygon>;
15
- export type MultiPolygon = GeoJSON.Feature<GeoJSON.MultiPolygon>;
16
- export type Position = GeoJSON.Position;
17
- export type LineStringFeatures = LineString | LineStrings | MultiLineString | MultiLineStrings | GeoJSON.LineString | GeoJSON.MultiLineString
18
- export type PolygonFeatures = Polygon | Polygons | MultiPolygon | MultiPolygons | GeoJSON.Polygon | GeoJSON.MultiPolygon
19
- export type Features<Geom extends GeometryObject> = GeoJSON.FeatureCollection<Geom>;
20
- export type Feature<Geom extends GeometryObject> = GeoJSON.Feature<Geom>;
21
- export type Units = 'miles' | 'nauticalmiles' | 'degrees' | 'radians' | 'inches' | 'yards' | 'meters' | 'metres' | 'kilometers' | 'kilometres';
3
+ // GeoJSON Foreign Members
4
+ export type Id = string | number;
5
+ export type Properties = {[key: string]: any};
22
6
  export type BBox = [number, number, number, number];
23
- export type GeometryObject = GeoJSON.GeometryObject;
24
- export type GeometryCollection = GeoJSON.GeometryCollection;
25
- export type Geoms = GeoJSON.Point | GeoJSON.LineString | GeoJSON.Polygon | GeoJSON.MultiPoint | GeoJSON.MultiLineString | GeoJSON.MultiPolygon;
26
- export type GeometryTypes = 'Point' | 'LineString' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon';
27
7
 
28
- export interface FeatureGeometryCollection extends GeoJSON.Feature<any> {
29
- geometry: GeometryCollection
30
- }
8
+ // TurfJS String Types
9
+ export type Units = 'miles' | 'nauticalmiles' | 'degrees' | 'radians' | 'inches' | 'yards' | 'meters' | 'metres' | 'kilometers' | 'kilometres';
10
+ export type Geometry = 'Point' | 'LineString' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon';
11
+ export type Grid = 'point' | 'square' | 'hex' | 'triangle';
31
12
 
32
- export interface FeatureCollection {
33
- <Geom extends Geoms>(features: Feature<Geom>[], bbox?: BBox, id?: Id): Features<Geom>;
34
- (features: Feature<any>[], bbox?: BBox, id?: Id): Features<any>;
35
- }
13
+ // GeoJSON Geometry Types
14
+ export type Position = GeoJSON.Position;
15
+ export type Point = GeoJSON.Point;
16
+ export type MultiPoint = GeoJSON.MultiPoint;
17
+ export type MultiLineString = GeoJSON.MultiLineString;
18
+ export type LineString = GeoJSON.LineString;
19
+ export type Polygon = GeoJSON.Polygon;
20
+ export type MultiPolygon = GeoJSON.MultiPolygon;
21
+ export type GeometryObject = GeoJSON.GeometryObject;
22
+ export type GeometryCollection = GeoJSON.GeometryCollection;
36
23
 
37
- export interface Properties {
38
- [key: string]: any
24
+ // GeoJSON Feature Objects
25
+ export type FeatureCollection<T extends GeometryObject> = GeoJSON.FeatureCollection<T>;
26
+ export type Feature<T extends GeometryObject> = GeoJSON.Feature<T>;
27
+ export interface FeatureGeometryCollection extends Feature<any> {
28
+ geometry: GeometryCollection;
39
29
  }
40
30
 
41
31
  /**
42
32
  * http://turfjs.org/docs/#feature
43
33
  */
44
- export function feature<Geom extends GeometryObject>(geometry: Geom, properties?: Properties, bbox?: BBox, id?: Id): Feature<Geom>;
34
+ export function feature<T extends GeometryObject>(geometry: T, properties?: Properties, bbox?: BBox, id?: Id): Feature<T>;
35
+
36
+ /**
37
+ * http://turfjs.org/docs/#featurecollection
38
+ */
39
+ export function featureCollection<T extends GeometryObject>(features: Feature<T>[], bbox?: BBox, id?: Id): FeatureCollection<T>;
40
+ export function featureCollection(features: Feature<any>[], bbox?: BBox, id?: Id): FeatureCollection<any>;
45
41
 
46
42
  /**
47
43
  * http://turfjs.org/docs/#geometry
48
44
  */
49
- export function geometry(type: GeometryTypes, coordinates: any[], bbox?: BBox): GeometryObject;
45
+ export function geometry(type: 'Point', coordinates: Position, bbox?: BBox): Point;
46
+ export function geometry(type: 'LineString', coordinates: Position[], bbox?: BBox): LineString;
47
+ export function geometry(type: 'Polygon', coordinates: Position[][], bbox?: BBox): Polygon;
48
+ export function geometry(type: 'MultiPoint', coordinates: Position[], bbox?: BBox): MultiPoint;
49
+ export function geometry(type: 'MultiLineString', coordinates: Position[][], bbox?: BBox): MultiLineString;
50
+ export function geometry(type: 'MultiPolygon', coordinates: Position[][][], bbox?: BBox): MultiPolygon;
51
+ export function geometry(type: Geometry | string, coordinates: any[], bbox?: BBox): GeometryObject;
50
52
 
51
53
  /**
52
54
  * http://turfjs.org/docs/#point
53
55
  */
54
- export function point(coordinates: Position, properties?: Properties, bbox?: BBox, id?: Id): Point;
56
+ export function point(coordinates: Position, properties?: Properties, bbox?: BBox, id?: Id): Feature<Point>;
55
57
 
56
58
  /**
57
59
  * http://turfjs.org/docs/#polygon
58
60
  */
59
- export function polygon(coordinates: Position[][], properties?: Properties, bbox?: BBox, id?: Id): Polygon;
61
+ export function polygon(coordinates: Position[][], properties?: Properties, bbox?: BBox, id?: Id): Feature<Polygon>;
60
62
 
61
63
  /**
62
64
  * http://turfjs.org/docs/#linestring
63
65
  */
64
- export function lineString(coordinates: Position[], properties?: Properties, bbox?: BBox, id?: Id): LineString;
65
-
66
- /**
67
- * http://turfjs.org/docs/#featurecollection
68
- */
69
- export const featureCollection: FeatureCollection;
66
+ export function lineString(coordinates: Position[], properties?: Properties, bbox?: BBox, id?: Id): Feature<LineString>;
70
67
 
71
68
  /**
72
69
  * http://turfjs.org/docs/#multilinestring
73
70
  */
74
- export function multiLineString(coordinates: Position[][], properties?: Properties, bbox?: BBox, id?: Id): MultiLineString;
71
+ export function multiLineString(coordinates: Position[][], properties?: Properties, bbox?: BBox, id?: Id): Feature<MultiLineString>;
75
72
 
76
73
  /**
77
74
  * http://turfjs.org/docs/#multipoint
78
75
  */
79
- export function multiPoint(coordinates: Position[], properties?: Properties, bbox?: BBox, id?: Id): MultiPoint;
76
+ export function multiPoint(coordinates: Position[], properties?: Properties, bbox?: BBox, id?: Id): Feature<MultiPoint>;
80
77
 
81
78
  /**
82
79
  * http://turfjs.org/docs/#multipolygon
83
80
  */
84
- export function multiPolygon(coordinates: Position[][][], properties?: Properties, bbox?: BBox, id?: Id): MultiPolygon;
81
+ export function multiPolygon(coordinates: Position[][][], properties?: Properties, bbox?: BBox, id?: Id): Feature<MultiPolygon>;
85
82
 
86
83
  /**
87
84
  * http://turfjs.org/docs/#geometrycollection
@@ -137,3 +134,13 @@ export function convertArea(area: number, originalUnit?: Units, finalUnit?: Unit
137
134
  * http://turfjs.org/docs/#isnumber
138
135
  */
139
136
  export function isNumber(num: any): boolean
137
+
138
+ /**
139
+ * http://turfjs.org/docs/#isobject
140
+ */
141
+ export function isObject(input: any): boolean
142
+
143
+ /**
144
+ * Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
145
+ */
146
+ export const earthRadius: number;