@turf/helpers 7.1.0-alpha.70 → 7.2.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 +149 -110
- package/dist/esm/index.d.ts +149 -110
- package/dist/esm/index.js +10 -7
- package/dist/esm/index.js.map +1 -1
- package/package.json +8 -8
package/dist/cjs/index.d.cts
CHANGED
|
@@ -11,20 +11,57 @@ import { Feature, Point, Position, LineString, MultiLineString, Polygon, MultiPo
|
|
|
11
11
|
*/
|
|
12
12
|
type Id = string | number;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @module helpers
|
|
16
|
+
*/
|
|
14
17
|
type Coord = Feature<Point> | Point | Position;
|
|
18
|
+
/**
|
|
19
|
+
* Linear measurement units.
|
|
20
|
+
*
|
|
21
|
+
* ⚠️ Warning. Be aware of the implications of using radian or degree units to
|
|
22
|
+
* measure distance. The distance represented by a degree of longitude *varies*
|
|
23
|
+
* depending on latitude.
|
|
24
|
+
*
|
|
25
|
+
* See https://www.thoughtco.com/degree-of-latitude-and-longitude-distance-4070616
|
|
26
|
+
* for an illustration of this behaviour.
|
|
27
|
+
*
|
|
28
|
+
* @typedef
|
|
29
|
+
*/
|
|
15
30
|
type Units = "meters" | "metres" | "millimeters" | "millimetres" | "centimeters" | "centimetres" | "kilometers" | "kilometres" | "miles" | "nauticalmiles" | "inches" | "yards" | "feet" | "radians" | "degrees";
|
|
31
|
+
/**
|
|
32
|
+
* Area measurement units.
|
|
33
|
+
*
|
|
34
|
+
* @typedef
|
|
35
|
+
*/
|
|
16
36
|
type AreaUnits = Exclude<Units, "radians" | "degrees"> | "acres" | "hectares";
|
|
37
|
+
/**
|
|
38
|
+
* Grid types.
|
|
39
|
+
*
|
|
40
|
+
* @typedef
|
|
41
|
+
*/
|
|
17
42
|
type Grid = "point" | "square" | "hex" | "triangle";
|
|
43
|
+
/**
|
|
44
|
+
* Shorthand corner identifiers.
|
|
45
|
+
*
|
|
46
|
+
* @typedef
|
|
47
|
+
*/
|
|
18
48
|
type Corners = "sw" | "se" | "nw" | "ne" | "center" | "centroid";
|
|
49
|
+
/**
|
|
50
|
+
* Geometries made up of lines i.e. lines and polygons.
|
|
51
|
+
*
|
|
52
|
+
* @typedef
|
|
53
|
+
*/
|
|
19
54
|
type Lines = LineString | MultiLineString | Polygon | MultiPolygon;
|
|
20
|
-
type AllGeoJSON = Feature | FeatureCollection | Geometry | GeometryCollection;
|
|
21
55
|
/**
|
|
22
|
-
*
|
|
56
|
+
* Convenience type for all possible GeoJSON.
|
|
57
|
+
*
|
|
58
|
+
* @typedef
|
|
23
59
|
*/
|
|
60
|
+
type AllGeoJSON = Feature | FeatureCollection | Geometry | GeometryCollection;
|
|
24
61
|
/**
|
|
25
62
|
* The Earth radius in kilometers. Used by Turf modules that model the Earth as a sphere. The {@link https://en.wikipedia.org/wiki/Earth_radius#Arithmetic_mean_radius mean radius} was selected because it is {@link https://rosettacode.org/wiki/Haversine_formula#:~:text=This%20value%20is%20recommended recommended } by the Haversine formula (used by turf/distance) to reduce error.
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
63
|
+
*
|
|
64
|
+
* @constant
|
|
28
65
|
*/
|
|
29
66
|
declare const earthRadius = 6371008.8;
|
|
30
67
|
/**
|
|
@@ -32,28 +69,26 @@ declare const earthRadius = 6371008.8;
|
|
|
32
69
|
*
|
|
33
70
|
* Keys are the name of the unit, values are the number of that unit in a single radian
|
|
34
71
|
*
|
|
35
|
-
* @
|
|
36
|
-
* @type {Object}
|
|
72
|
+
* @constant
|
|
37
73
|
*/
|
|
38
74
|
declare const factors: Record<Units, number>;
|
|
39
75
|
/**
|
|
40
76
|
|
|
41
77
|
* Area of measurement factors based on 1 square meter.
|
|
42
78
|
*
|
|
43
|
-
* @
|
|
44
|
-
* @type {Object}
|
|
79
|
+
* @constant
|
|
45
80
|
*/
|
|
46
81
|
declare const areaFactors: Record<AreaUnits, number>;
|
|
47
82
|
/**
|
|
48
83
|
* Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
|
|
49
84
|
*
|
|
50
|
-
* @
|
|
51
|
-
* @param {
|
|
52
|
-
* @param {
|
|
85
|
+
* @function
|
|
86
|
+
* @param {GeometryObject} geometry input geometry
|
|
87
|
+
* @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties
|
|
53
88
|
* @param {Object} [options={}] Optional Parameters
|
|
54
|
-
* @param {
|
|
55
|
-
* @param {
|
|
56
|
-
* @returns {Feature} a GeoJSON Feature
|
|
89
|
+
* @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
|
|
90
|
+
* @param {Id} [options.id] Identifier associated with the Feature
|
|
91
|
+
* @returns {Feature<GeometryObject, GeoJsonProperties>} a GeoJSON Feature
|
|
57
92
|
* @example
|
|
58
93
|
* var geometry = {
|
|
59
94
|
* "type": "Point",
|
|
@@ -72,8 +107,8 @@ declare function feature<G extends GeometryObject = Geometry, P extends GeoJsonP
|
|
|
72
107
|
* Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.
|
|
73
108
|
* For GeometryCollection type use `helpers.geometryCollection`
|
|
74
109
|
*
|
|
75
|
-
* @
|
|
76
|
-
* @param {
|
|
110
|
+
* @function
|
|
111
|
+
* @param {("Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon")} type Geometry Type
|
|
77
112
|
* @param {Array<any>} coordinates Coordinates
|
|
78
113
|
* @param {Object} [options={}] Optional Parameters
|
|
79
114
|
* @returns {Geometry} a GeoJSON Geometry
|
|
@@ -87,13 +122,13 @@ declare function geometry(type: "Point" | "LineString" | "Polygon" | "MultiPoint
|
|
|
87
122
|
/**
|
|
88
123
|
* Creates a {@link Point} {@link Feature} from a Position.
|
|
89
124
|
*
|
|
90
|
-
* @
|
|
91
|
-
* @param {
|
|
92
|
-
* @param {
|
|
125
|
+
* @function
|
|
126
|
+
* @param {Position} coordinates longitude, latitude position (each in decimal degrees)
|
|
127
|
+
* @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties
|
|
93
128
|
* @param {Object} [options={}] Optional Parameters
|
|
94
|
-
* @param {
|
|
95
|
-
* @param {
|
|
96
|
-
* @returns {Feature<Point>} a Point feature
|
|
129
|
+
* @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
|
|
130
|
+
* @param {Id} [options.id] Identifier associated with the Feature
|
|
131
|
+
* @returns {Feature<Point, GeoJsonProperties>} a Point feature
|
|
97
132
|
* @example
|
|
98
133
|
* var point = turf.point([-75.343, 39.984]);
|
|
99
134
|
*
|
|
@@ -106,13 +141,13 @@ declare function point<P extends GeoJsonProperties = GeoJsonProperties>(coordina
|
|
|
106
141
|
/**
|
|
107
142
|
* Creates a {@link Point} {@link FeatureCollection} from an Array of Point coordinates.
|
|
108
143
|
*
|
|
109
|
-
* @
|
|
110
|
-
* @param {
|
|
111
|
-
* @param {
|
|
144
|
+
* @function
|
|
145
|
+
* @param {Position[]} coordinates an array of Points
|
|
146
|
+
* @param {GeoJsonProperties} [properties={}] Translate these properties to each Feature
|
|
112
147
|
* @param {Object} [options={}] Optional Parameters
|
|
113
|
-
* @param {
|
|
148
|
+
* @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north]
|
|
114
149
|
* associated with the FeatureCollection
|
|
115
|
-
* @param {
|
|
150
|
+
* @param {Id} [options.id] Identifier associated with the FeatureCollection
|
|
116
151
|
* @returns {FeatureCollection<Point>} Point Feature
|
|
117
152
|
* @example
|
|
118
153
|
* var points = turf.points([
|
|
@@ -130,13 +165,13 @@ declare function points<P extends GeoJsonProperties = GeoJsonProperties>(coordin
|
|
|
130
165
|
/**
|
|
131
166
|
* Creates a {@link Polygon} {@link Feature} from an Array of LinearRings.
|
|
132
167
|
*
|
|
133
|
-
* @
|
|
134
|
-
* @param {
|
|
135
|
-
* @param {
|
|
168
|
+
* @function
|
|
169
|
+
* @param {Position[][]} coordinates an array of LinearRings
|
|
170
|
+
* @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties
|
|
136
171
|
* @param {Object} [options={}] Optional Parameters
|
|
137
|
-
* @param {
|
|
138
|
-
* @param {
|
|
139
|
-
* @returns {Feature<Polygon>} Polygon Feature
|
|
172
|
+
* @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
|
|
173
|
+
* @param {Id} [options.id] Identifier associated with the Feature
|
|
174
|
+
* @returns {Feature<Polygon, GeoJsonProperties>} Polygon Feature
|
|
140
175
|
* @example
|
|
141
176
|
* var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], { name: 'poly1' });
|
|
142
177
|
*
|
|
@@ -149,13 +184,13 @@ declare function polygon<P extends GeoJsonProperties = GeoJsonProperties>(coordi
|
|
|
149
184
|
/**
|
|
150
185
|
* Creates a {@link Polygon} {@link FeatureCollection} from an Array of Polygon coordinates.
|
|
151
186
|
*
|
|
152
|
-
* @
|
|
153
|
-
* @param {
|
|
154
|
-
* @param {
|
|
187
|
+
* @function
|
|
188
|
+
* @param {Position[][][]} coordinates an array of Polygon coordinates
|
|
189
|
+
* @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties
|
|
155
190
|
* @param {Object} [options={}] Optional Parameters
|
|
156
|
-
* @param {
|
|
157
|
-
* @param {
|
|
158
|
-
* @returns {FeatureCollection<Polygon>} Polygon FeatureCollection
|
|
191
|
+
* @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
|
|
192
|
+
* @param {Id} [options.id] Identifier associated with the FeatureCollection
|
|
193
|
+
* @returns {FeatureCollection<Polygon, GeoJsonProperties>} Polygon FeatureCollection
|
|
159
194
|
* @example
|
|
160
195
|
* var polygons = turf.polygons([
|
|
161
196
|
* [[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]],
|
|
@@ -171,13 +206,13 @@ declare function polygons<P extends GeoJsonProperties = GeoJsonProperties>(coord
|
|
|
171
206
|
/**
|
|
172
207
|
* Creates a {@link LineString} {@link Feature} from an Array of Positions.
|
|
173
208
|
*
|
|
174
|
-
* @
|
|
175
|
-
* @param {
|
|
176
|
-
* @param {
|
|
209
|
+
* @function
|
|
210
|
+
* @param {Position[]} coordinates an array of Positions
|
|
211
|
+
* @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties
|
|
177
212
|
* @param {Object} [options={}] Optional Parameters
|
|
178
|
-
* @param {
|
|
179
|
-
* @param {
|
|
180
|
-
* @returns {Feature<LineString>} LineString Feature
|
|
213
|
+
* @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
|
|
214
|
+
* @param {Id} [options.id] Identifier associated with the Feature
|
|
215
|
+
* @returns {Feature<LineString, GeoJsonProperties>} LineString Feature
|
|
181
216
|
* @example
|
|
182
217
|
* var linestring1 = turf.lineString([[-24, 63], [-23, 60], [-25, 65], [-20, 69]], {name: 'line 1'});
|
|
183
218
|
* var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]], {name: 'line 2'});
|
|
@@ -192,14 +227,14 @@ declare function lineString<P extends GeoJsonProperties = GeoJsonProperties>(coo
|
|
|
192
227
|
/**
|
|
193
228
|
* Creates a {@link LineString} {@link FeatureCollection} from an Array of LineString coordinates.
|
|
194
229
|
*
|
|
195
|
-
* @
|
|
196
|
-
* @param {
|
|
197
|
-
* @param {
|
|
230
|
+
* @function
|
|
231
|
+
* @param {Position[][]} coordinates an array of LinearRings
|
|
232
|
+
* @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties
|
|
198
233
|
* @param {Object} [options={}] Optional Parameters
|
|
199
|
-
* @param {
|
|
234
|
+
* @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north]
|
|
200
235
|
* associated with the FeatureCollection
|
|
201
|
-
* @param {
|
|
202
|
-
* @returns {FeatureCollection<LineString>} LineString FeatureCollection
|
|
236
|
+
* @param {Id} [options.id] Identifier associated with the FeatureCollection
|
|
237
|
+
* @returns {FeatureCollection<LineString, GeoJsonProperties>} LineString FeatureCollection
|
|
203
238
|
* @example
|
|
204
239
|
* var linestrings = turf.lineStrings([
|
|
205
240
|
* [[-24, 63], [-23, 60], [-25, 65], [-20, 69]],
|
|
@@ -215,12 +250,12 @@ declare function lineStrings<P extends GeoJsonProperties = GeoJsonProperties>(co
|
|
|
215
250
|
/**
|
|
216
251
|
* Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.
|
|
217
252
|
*
|
|
218
|
-
* @
|
|
219
|
-
* @param {Feature
|
|
253
|
+
* @function
|
|
254
|
+
* @param {Array<Feature<GeometryObject, GeoJsonProperties>>} features input features
|
|
220
255
|
* @param {Object} [options={}] Optional Parameters
|
|
221
|
-
* @param {
|
|
222
|
-
* @param {
|
|
223
|
-
* @returns {FeatureCollection} FeatureCollection of Features
|
|
256
|
+
* @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
|
|
257
|
+
* @param {Id} [options.id] Identifier associated with the Feature
|
|
258
|
+
* @returns {FeatureCollection<GeometryObject, GeoJsonProperties>} FeatureCollection of Features
|
|
224
259
|
* @example
|
|
225
260
|
* var locationA = turf.point([-75.343, 39.984], {name: 'Location A'});
|
|
226
261
|
* var locationB = turf.point([-75.833, 39.284], {name: 'Location B'});
|
|
@@ -239,16 +274,16 @@ declare function featureCollection<G extends GeometryObject = Geometry, P extend
|
|
|
239
274
|
id?: Id;
|
|
240
275
|
}): FeatureCollection<G, P>;
|
|
241
276
|
/**
|
|
242
|
-
* Creates a {@link Feature<MultiLineString>
|
|
277
|
+
* Creates a {@link Feature}<{@link MultiLineString}> based on a
|
|
243
278
|
* coordinate array. Properties can be added optionally.
|
|
244
279
|
*
|
|
245
|
-
* @
|
|
246
|
-
* @param {
|
|
247
|
-
* @param {
|
|
280
|
+
* @function
|
|
281
|
+
* @param {Position[][]} coordinates an array of LineStrings
|
|
282
|
+
* @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties
|
|
248
283
|
* @param {Object} [options={}] Optional Parameters
|
|
249
|
-
* @param {
|
|
250
|
-
* @param {
|
|
251
|
-
* @returns {Feature<MultiLineString>} a MultiLineString feature
|
|
284
|
+
* @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
|
|
285
|
+
* @param {Id} [options.id] Identifier associated with the Feature
|
|
286
|
+
* @returns {Feature<MultiLineString, GeoJsonProperties>} a MultiLineString feature
|
|
252
287
|
* @throws {Error} if no coordinates are passed
|
|
253
288
|
* @example
|
|
254
289
|
* var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
|
|
@@ -260,16 +295,16 @@ declare function multiLineString<P extends GeoJsonProperties = GeoJsonProperties
|
|
|
260
295
|
id?: Id;
|
|
261
296
|
}): Feature<MultiLineString, P>;
|
|
262
297
|
/**
|
|
263
|
-
* Creates a {@link Feature<MultiPoint>
|
|
298
|
+
* Creates a {@link Feature}<{@link MultiPoint}> based on a
|
|
264
299
|
* coordinate array. Properties can be added optionally.
|
|
265
300
|
*
|
|
266
|
-
* @
|
|
267
|
-
* @param {
|
|
268
|
-
* @param {
|
|
301
|
+
* @function
|
|
302
|
+
* @param {Position[]} coordinates an array of Positions
|
|
303
|
+
* @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties
|
|
269
304
|
* @param {Object} [options={}] Optional Parameters
|
|
270
|
-
* @param {
|
|
271
|
-
* @param {
|
|
272
|
-
* @returns {Feature<MultiPoint>} a MultiPoint feature
|
|
305
|
+
* @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
|
|
306
|
+
* @param {Id} [options.id] Identifier associated with the Feature
|
|
307
|
+
* @returns {Feature<MultiPoint, GeoJsonProperties>} a MultiPoint feature
|
|
273
308
|
* @throws {Error} if no coordinates are passed
|
|
274
309
|
* @example
|
|
275
310
|
* var multiPt = turf.multiPoint([[0,0],[10,10]]);
|
|
@@ -281,16 +316,16 @@ declare function multiPoint<P extends GeoJsonProperties = GeoJsonProperties>(coo
|
|
|
281
316
|
id?: Id;
|
|
282
317
|
}): Feature<MultiPoint, P>;
|
|
283
318
|
/**
|
|
284
|
-
* Creates a {@link Feature<MultiPolygon>
|
|
319
|
+
* Creates a {@link Feature}<{@link MultiPolygon}> based on a
|
|
285
320
|
* coordinate array. Properties can be added optionally.
|
|
286
321
|
*
|
|
287
|
-
* @
|
|
288
|
-
* @param {
|
|
289
|
-
* @param {
|
|
322
|
+
* @function
|
|
323
|
+
* @param {Position[][][]} coordinates an array of Polygons
|
|
324
|
+
* @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties
|
|
290
325
|
* @param {Object} [options={}] Optional Parameters
|
|
291
|
-
* @param {
|
|
292
|
-
* @param {
|
|
293
|
-
* @returns {Feature<MultiPolygon>} a multipolygon feature
|
|
326
|
+
* @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
|
|
327
|
+
* @param {Id} [options.id] Identifier associated with the Feature
|
|
328
|
+
* @returns {Feature<MultiPolygon, GeoJsonProperties>} a multipolygon feature
|
|
294
329
|
* @throws {Error} if no coordinates are passed
|
|
295
330
|
* @example
|
|
296
331
|
* var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
|
|
@@ -303,16 +338,16 @@ declare function multiPolygon<P extends GeoJsonProperties = GeoJsonProperties>(c
|
|
|
303
338
|
id?: Id;
|
|
304
339
|
}): Feature<MultiPolygon, P>;
|
|
305
340
|
/**
|
|
306
|
-
* Creates a
|
|
341
|
+
* Creates a Feature<GeometryCollection> based on a
|
|
307
342
|
* coordinate array. Properties can be added optionally.
|
|
308
343
|
*
|
|
309
|
-
* @
|
|
310
|
-
* @param {Array<
|
|
311
|
-
* @param {
|
|
344
|
+
* @function
|
|
345
|
+
* @param {Array<Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon>} geometries an array of GeoJSON Geometries
|
|
346
|
+
* @param {GeoJsonProperties} [properties={}] an Object of key-value pairs to add as properties
|
|
312
347
|
* @param {Object} [options={}] Optional Parameters
|
|
313
|
-
* @param {
|
|
314
|
-
* @param {
|
|
315
|
-
* @returns {Feature<GeometryCollection>} a GeoJSON GeometryCollection Feature
|
|
348
|
+
* @param {BBox} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
|
|
349
|
+
* @param {Id} [options.id] Identifier associated with the Feature
|
|
350
|
+
* @returns {Feature<GeometryCollection, GeoJsonProperties>} a GeoJSON GeometryCollection Feature
|
|
316
351
|
* @example
|
|
317
352
|
* var pt = turf.geometry("Point", [100, 0]);
|
|
318
353
|
* var line = turf.geometry("LineString", [[101, 0], [102, 1]]);
|
|
@@ -327,6 +362,7 @@ declare function geometryCollection<P extends GeoJsonProperties = GeoJsonPropert
|
|
|
327
362
|
/**
|
|
328
363
|
* Round number to precision
|
|
329
364
|
*
|
|
365
|
+
* @function
|
|
330
366
|
* @param {number} num Number
|
|
331
367
|
* @param {number} [precision=0] Precision
|
|
332
368
|
* @returns {number} rounded number
|
|
@@ -342,9 +378,9 @@ declare function round(num: number, precision?: number): number;
|
|
|
342
378
|
* Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
|
|
343
379
|
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
|
|
344
380
|
*
|
|
345
|
-
* @
|
|
381
|
+
* @function
|
|
346
382
|
* @param {number} radians in radians across the sphere
|
|
347
|
-
* @param {
|
|
383
|
+
* @param {Units} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
|
|
348
384
|
* meters, kilometres, kilometers.
|
|
349
385
|
* @returns {number} distance
|
|
350
386
|
*/
|
|
@@ -353,9 +389,9 @@ declare function radiansToLength(radians: number, units?: Units): number;
|
|
|
353
389
|
* Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
|
|
354
390
|
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
|
|
355
391
|
*
|
|
356
|
-
* @
|
|
392
|
+
* @function
|
|
357
393
|
* @param {number} distance in real units
|
|
358
|
-
* @param {
|
|
394
|
+
* @param {Units} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
|
|
359
395
|
* meters, kilometres, kilometers.
|
|
360
396
|
* @returns {number} radians
|
|
361
397
|
*/
|
|
@@ -364,9 +400,9 @@ declare function lengthToRadians(distance: number, units?: Units): number;
|
|
|
364
400
|
* Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
|
|
365
401
|
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
|
|
366
402
|
*
|
|
367
|
-
* @
|
|
403
|
+
* @function
|
|
368
404
|
* @param {number} distance in real units
|
|
369
|
-
* @param {
|
|
405
|
+
* @param {Units} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
|
|
370
406
|
* meters, kilometres, kilometers.
|
|
371
407
|
* @returns {number} degrees
|
|
372
408
|
*/
|
|
@@ -375,7 +411,7 @@ declare function lengthToDegrees(distance: number, units?: Units): number;
|
|
|
375
411
|
* Converts any bearing angle from the north line direction (positive clockwise)
|
|
376
412
|
* and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
|
|
377
413
|
*
|
|
378
|
-
* @
|
|
414
|
+
* @function
|
|
379
415
|
* @param {number} bearing angle, between -180 and +180 degrees
|
|
380
416
|
* @returns {number} angle between 0 and 360 degrees
|
|
381
417
|
*/
|
|
@@ -384,7 +420,7 @@ declare function bearingToAzimuth(bearing: number): number;
|
|
|
384
420
|
* Converts any azimuth angle from the north line direction (positive clockwise)
|
|
385
421
|
* and returns an angle between -180 and +180 degrees (positive clockwise), 0 being the north line
|
|
386
422
|
*
|
|
387
|
-
* @
|
|
423
|
+
* @function
|
|
388
424
|
* @param {number} angle between 0 and 360 degrees
|
|
389
425
|
* @returns {number} bearing between -180 and +180 degrees
|
|
390
426
|
*/
|
|
@@ -392,7 +428,7 @@ declare function azimuthToBearing(angle: number): number;
|
|
|
392
428
|
/**
|
|
393
429
|
* Converts an angle in radians to degrees
|
|
394
430
|
*
|
|
395
|
-
* @
|
|
431
|
+
* @function
|
|
396
432
|
* @param {number} radians angle in radians
|
|
397
433
|
* @returns {number} degrees between 0 and 360 degrees
|
|
398
434
|
*/
|
|
@@ -400,34 +436,36 @@ declare function radiansToDegrees(radians: number): number;
|
|
|
400
436
|
/**
|
|
401
437
|
* Converts an angle in degrees to radians
|
|
402
438
|
*
|
|
403
|
-
* @
|
|
439
|
+
* @function
|
|
404
440
|
* @param {number} degrees angle between 0 and 360 degrees
|
|
405
441
|
* @returns {number} angle in radians
|
|
406
442
|
*/
|
|
407
443
|
declare function degreesToRadians(degrees: number): number;
|
|
408
444
|
/**
|
|
409
|
-
* Converts a length
|
|
410
|
-
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
|
|
445
|
+
* Converts a length from one unit to another.
|
|
411
446
|
*
|
|
412
|
-
* @
|
|
413
|
-
* @param {
|
|
414
|
-
* @param {Units} [
|
|
415
|
-
* @
|
|
447
|
+
* @function
|
|
448
|
+
* @param {number} length Length to be converted
|
|
449
|
+
* @param {Units} [originalUnit="kilometers"] Input length unit
|
|
450
|
+
* @param {Units} [finalUnit="kilometers"] Returned length unit
|
|
451
|
+
* @returns {number} The converted length
|
|
416
452
|
*/
|
|
417
453
|
declare function convertLength(length: number, originalUnit?: Units, finalUnit?: Units): number;
|
|
418
454
|
/**
|
|
419
|
-
* Converts
|
|
420
|
-
*
|
|
421
|
-
* @
|
|
422
|
-
* @param {
|
|
423
|
-
* @param {
|
|
424
|
-
* @
|
|
455
|
+
* Converts an area from one unit to another.
|
|
456
|
+
*
|
|
457
|
+
* @function
|
|
458
|
+
* @param {number} area Area to be converted
|
|
459
|
+
* @param {AreaUnits} [originalUnit="meters"] Input area unit
|
|
460
|
+
* @param {AreaUnits} [finalUnit="kilometers"] Returned area unit
|
|
461
|
+
* @returns {number} The converted length
|
|
425
462
|
*/
|
|
426
463
|
declare function convertArea(area: number, originalUnit?: AreaUnits, finalUnit?: AreaUnits): number;
|
|
427
464
|
/**
|
|
428
465
|
* isNumber
|
|
429
466
|
*
|
|
430
|
-
* @
|
|
467
|
+
* @function
|
|
468
|
+
* @param {any} num Number to validate
|
|
431
469
|
* @returns {boolean} true/false
|
|
432
470
|
* @example
|
|
433
471
|
* turf.isNumber(123)
|
|
@@ -439,7 +477,8 @@ declare function isNumber(num: any): boolean;
|
|
|
439
477
|
/**
|
|
440
478
|
* isObject
|
|
441
479
|
*
|
|
442
|
-
* @
|
|
480
|
+
* @function
|
|
481
|
+
* @param {any} input variable to validate
|
|
443
482
|
* @returns {boolean} true/false, including false for Arrays and Functions
|
|
444
483
|
* @example
|
|
445
484
|
* turf.isObject({elevation: 10})
|
|
@@ -452,7 +491,7 @@ declare function isObject(input: any): boolean;
|
|
|
452
491
|
* Validate BBox
|
|
453
492
|
*
|
|
454
493
|
* @private
|
|
455
|
-
* @param {
|
|
494
|
+
* @param {any} bbox BBox to validate
|
|
456
495
|
* @returns {void}
|
|
457
496
|
* @throws {Error} if BBox is not valid
|
|
458
497
|
* @example
|
|
@@ -474,7 +513,7 @@ declare function validateBBox(bbox: any): void;
|
|
|
474
513
|
* Validate Id
|
|
475
514
|
*
|
|
476
515
|
* @private
|
|
477
|
-
* @param {
|
|
516
|
+
* @param {any} id Id to validate
|
|
478
517
|
* @returns {void}
|
|
479
518
|
* @throws {Error} if Id is not valid
|
|
480
519
|
* @example
|