@turf/helpers 5.0.0-alpha → 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.
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
@@ -134,3 +134,13 @@ export function convertArea(area: number, originalUnit?: Units, finalUnit?: Unit
134
134
  * http://turfjs.org/docs/#isnumber
135
135
  */
136
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;
package/index.js CHANGED
@@ -352,6 +352,7 @@ var areaFactors = {
352
352
  feet: 10.763910417,
353
353
  inches: 1550.003100006
354
354
  };
355
+
355
356
  /**
356
357
  * Round number to precision
357
358
  *
@@ -378,14 +379,15 @@ export function round(num, precision) {
378
379
  *
379
380
  * @name radiansToDistance
380
381
  * @param {number} radians in radians across the sphere
381
- * @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
382
+ * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.
382
383
  * @returns {number} distance
383
384
  */
384
385
  export function radiansToDistance(radians, units) {
385
386
  if (radians === undefined || radians === null) throw new Error('radians is required');
386
387
 
388
+ if (units && typeof units !== 'string') throw new Error('units must be a string');
387
389
  var factor = factors[units || 'kilometers'];
388
- if (!factor) throw new Error('units is invalid');
390
+ if (!factor) throw new Error(units + ' units is invalid');
389
391
  return radians * factor;
390
392
  }
391
393
 
@@ -401,8 +403,9 @@ export function radiansToDistance(radians, units) {
401
403
  export function distanceToRadians(distance, units) {
402
404
  if (distance === undefined || distance === null) throw new Error('distance is required');
403
405
 
406
+ if (units && typeof units !== 'string') throw new Error('units must be a string');
404
407
  var factor = factors[units || 'kilometers'];
405
- if (!factor) throw new Error('units is invalid');
408
+ if (!factor) throw new Error(units + ' units is invalid');
406
409
  return distance / factor;
407
410
  }
408
411
 
@@ -463,7 +466,6 @@ export function degrees2radians(degrees) {
463
466
  return radians * Math.PI / 180;
464
467
  }
465
468
 
466
-
467
469
  /**
468
470
  * Converts a distance to the requested unit.
469
471
  * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
@@ -516,3 +518,23 @@ export function convertArea(area, originalUnit, finalUnit) {
516
518
  export function isNumber(num) {
517
519
  return !isNaN(num) && num !== null && !Array.isArray(num);
518
520
  }
521
+
522
+ /**
523
+ * isObject
524
+ *
525
+ * @param {*} input variable to validate
526
+ * @returns {boolean} true/false
527
+ * @example
528
+ * turf.isObject({elevation: 10})
529
+ * //=true
530
+ * turf.isObject('foo')
531
+ * //=false
532
+ */
533
+ export function isObject(input) {
534
+ return (!!input) && (input.constructor === Object);
535
+ }
536
+
537
+ /**
538
+ * Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
539
+ */
540
+ export var earthRadius = 6371008.8;
@@ -356,6 +356,7 @@ var areaFactors = {
356
356
  feet: 10.763910417,
357
357
  inches: 1550.003100006
358
358
  };
359
+
359
360
  /**
360
361
  * Round number to precision
361
362
  *
@@ -469,7 +470,6 @@ function degrees2radians(degrees) {
469
470
  return radians * Math.PI / 180;
470
471
  }
471
472
 
472
-
473
473
  /**
474
474
  * Converts a distance to the requested unit.
475
475
  * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
@@ -523,6 +523,26 @@ function isNumber(num) {
523
523
  return !isNaN(num) && num !== null && !Array.isArray(num);
524
524
  }
525
525
 
526
+ /**
527
+ * isObject
528
+ *
529
+ * @param {*} input variable to validate
530
+ * @returns {boolean} true/false
531
+ * @example
532
+ * turf.isObject({elevation: 10})
533
+ * //=true
534
+ * turf.isObject('foo')
535
+ * //=false
536
+ */
537
+ function isObject(input) {
538
+ return (!!input) && (input.constructor === Object);
539
+ }
540
+
541
+ /**
542
+ * Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
543
+ */
544
+ var earthRadius = 6371008.8;
545
+
526
546
  exports.feature = feature;
527
547
  exports.geometry = geometry;
528
548
  exports.point = point;
@@ -543,3 +563,5 @@ exports.degrees2radians = degrees2radians;
543
563
  exports.convertDistance = convertDistance;
544
564
  exports.convertArea = convertArea;
545
565
  exports.isNumber = isNumber;
566
+ exports.isObject = isObject;
567
+ exports.earthRadius = earthRadius;
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "@turf/helpers",
3
- "version": "5.0.0-alpha",
3
+ "version": "5.0.0",
4
4
  "description": "turf helpers module",
5
- "main": "index.es5.js",
6
- "module": "index.js",
7
- "jsnext:main": "index.js",
5
+ "main": "main",
6
+ "module": "index",
7
+ "jsnext:main": "index",
8
8
  "types": "index.d.ts",
9
9
  "files": [
10
10
  "index.js",
11
11
  "index.d.ts",
12
- "index.es5.js"
12
+ "main.js"
13
13
  ],
14
14
  "scripts": {
15
15
  "pretest": "rollup -c ../../rollup.config.js",
16
- "test": "node test.es5.js",
17
- "bench": "node bench.js"
16
+ "test": "node -r @std/esm test.js",
17
+ "posttest": "uglifyjs main.js -o main.min.js",
18
+ "bench": "node -r @std/esm bench.js"
18
19
  },
19
20
  "repository": {
20
21
  "type": "git",
@@ -41,7 +42,13 @@
41
42
  "devDependencies": {
42
43
  "benchmark": "*",
43
44
  "rollup": "*",
44
- "tape": "*"
45
+ "tape": "*",
46
+ "@std/esm": "*",
47
+ "uglify-js": "*"
45
48
  },
46
- "dependencies": {}
49
+ "dependencies": {},
50
+ "@std/esm": {
51
+ "esm": "js",
52
+ "cjs": true
53
+ }
47
54
  }