@turf/helpers 6.4.0 → 7.0.0-alpha.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 +193 -179
- package/dist/es/index.js +62 -100
- package/dist/es/lib/geojson.js +0 -7
- package/dist/js/index.d.ts +27 -30
- package/dist/js/index.js +59 -97
- package/dist/js/lib/geojson.d.ts +2 -185
- package/dist/js/lib/geojson.js +0 -7
- package/package.json +7 -3
package/dist/es/index.js
CHANGED
|
@@ -7,17 +7,19 @@
|
|
|
7
7
|
* @memberof helpers
|
|
8
8
|
* @type {number}
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export const earthRadius = 6371008.8;
|
|
11
11
|
/**
|
|
12
12
|
* Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
|
|
13
13
|
*
|
|
14
|
+
* Keys are the name of the unit, values are the number of that unit in a single radian
|
|
15
|
+
*
|
|
14
16
|
* @memberof helpers
|
|
15
17
|
* @type {Object}
|
|
16
18
|
*/
|
|
17
|
-
export
|
|
19
|
+
export const factors = {
|
|
18
20
|
centimeters: earthRadius * 100,
|
|
19
21
|
centimetres: earthRadius * 100,
|
|
20
|
-
degrees:
|
|
22
|
+
degrees: 360 / (2 * Math.PI),
|
|
21
23
|
feet: earthRadius * 3.28084,
|
|
22
24
|
inches: earthRadius * 39.37,
|
|
23
25
|
kilometers: earthRadius / 1000,
|
|
@@ -32,35 +34,13 @@ export var factors = {
|
|
|
32
34
|
yards: earthRadius * 1.0936,
|
|
33
35
|
};
|
|
34
36
|
/**
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
* @memberof helpers
|
|
38
|
-
* @type {Object}
|
|
39
|
-
*/
|
|
40
|
-
export var unitsFactors = {
|
|
41
|
-
centimeters: 100,
|
|
42
|
-
centimetres: 100,
|
|
43
|
-
degrees: 1 / 111325,
|
|
44
|
-
feet: 3.28084,
|
|
45
|
-
inches: 39.37,
|
|
46
|
-
kilometers: 1 / 1000,
|
|
47
|
-
kilometres: 1 / 1000,
|
|
48
|
-
meters: 1,
|
|
49
|
-
metres: 1,
|
|
50
|
-
miles: 1 / 1609.344,
|
|
51
|
-
millimeters: 1000,
|
|
52
|
-
millimetres: 1000,
|
|
53
|
-
nauticalmiles: 1 / 1852,
|
|
54
|
-
radians: 1 / earthRadius,
|
|
55
|
-
yards: 1.0936133,
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
37
|
+
|
|
58
38
|
* Area of measurement factors based on 1 square meter.
|
|
59
39
|
*
|
|
60
40
|
* @memberof helpers
|
|
61
41
|
* @type {Object}
|
|
62
42
|
*/
|
|
63
|
-
export
|
|
43
|
+
export const areaFactors = {
|
|
64
44
|
acres: 0.000247105,
|
|
65
45
|
centimeters: 10000,
|
|
66
46
|
centimetres: 10000,
|
|
@@ -96,9 +76,8 @@ export var areaFactors = {
|
|
|
96
76
|
*
|
|
97
77
|
* //=feature
|
|
98
78
|
*/
|
|
99
|
-
export function feature(geom, properties, options) {
|
|
100
|
-
|
|
101
|
-
var feat = { type: "Feature" };
|
|
79
|
+
export function feature(geom, properties, options = {}) {
|
|
80
|
+
const feat = { type: "Feature" };
|
|
102
81
|
if (options.id === 0 || options.id) {
|
|
103
82
|
feat.id = options.id;
|
|
104
83
|
}
|
|
@@ -124,8 +103,7 @@ export function feature(geom, properties, options) {
|
|
|
124
103
|
* var geometry = turf.geometry(type, coordinates);
|
|
125
104
|
* // => geometry
|
|
126
105
|
*/
|
|
127
|
-
export function geometry(type, coordinates, _options) {
|
|
128
|
-
if (_options === void 0) { _options = {}; }
|
|
106
|
+
export function geometry(type, coordinates, _options = {}) {
|
|
129
107
|
switch (type) {
|
|
130
108
|
case "Point":
|
|
131
109
|
return point(coordinates).geometry;
|
|
@@ -158,8 +136,7 @@ export function geometry(type, coordinates, _options) {
|
|
|
158
136
|
*
|
|
159
137
|
* //=point
|
|
160
138
|
*/
|
|
161
|
-
export function point(coordinates, properties, options) {
|
|
162
|
-
if (options === void 0) { options = {}; }
|
|
139
|
+
export function point(coordinates, properties, options = {}) {
|
|
163
140
|
if (!coordinates) {
|
|
164
141
|
throw new Error("coordinates is required");
|
|
165
142
|
}
|
|
@@ -172,9 +149,9 @@ export function point(coordinates, properties, options) {
|
|
|
172
149
|
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
|
|
173
150
|
throw new Error("coordinates must contain numbers");
|
|
174
151
|
}
|
|
175
|
-
|
|
152
|
+
const geom = {
|
|
176
153
|
type: "Point",
|
|
177
|
-
coordinates
|
|
154
|
+
coordinates,
|
|
178
155
|
};
|
|
179
156
|
return feature(geom, properties, options);
|
|
180
157
|
}
|
|
@@ -198,9 +175,8 @@ export function point(coordinates, properties, options) {
|
|
|
198
175
|
*
|
|
199
176
|
* //=points
|
|
200
177
|
*/
|
|
201
|
-
export function points(coordinates, properties, options) {
|
|
202
|
-
|
|
203
|
-
return featureCollection(coordinates.map(function (coords) {
|
|
178
|
+
export function points(coordinates, properties, options = {}) {
|
|
179
|
+
return featureCollection(coordinates.map((coords) => {
|
|
204
180
|
return point(coords, properties);
|
|
205
181
|
}), options);
|
|
206
182
|
}
|
|
@@ -219,23 +195,24 @@ export function points(coordinates, properties, options) {
|
|
|
219
195
|
*
|
|
220
196
|
* //=polygon
|
|
221
197
|
*/
|
|
222
|
-
export function polygon(coordinates, properties, options) {
|
|
223
|
-
|
|
224
|
-
for (var _i = 0, coordinates_1 = coordinates; _i < coordinates_1.length; _i++) {
|
|
225
|
-
var ring = coordinates_1[_i];
|
|
198
|
+
export function polygon(coordinates, properties, options = {}) {
|
|
199
|
+
for (const ring of coordinates) {
|
|
226
200
|
if (ring.length < 4) {
|
|
227
201
|
throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
|
|
228
202
|
}
|
|
229
|
-
|
|
203
|
+
if (ring[ring.length - 1].length !== ring[0].length) {
|
|
204
|
+
throw new Error("First and last Position are not equivalent.");
|
|
205
|
+
}
|
|
206
|
+
for (let j = 0; j < ring[ring.length - 1].length; j++) {
|
|
230
207
|
// Check if first point of Polygon contains two numbers
|
|
231
208
|
if (ring[ring.length - 1][j] !== ring[0][j]) {
|
|
232
209
|
throw new Error("First and last Position are not equivalent.");
|
|
233
210
|
}
|
|
234
211
|
}
|
|
235
212
|
}
|
|
236
|
-
|
|
213
|
+
const geom = {
|
|
237
214
|
type: "Polygon",
|
|
238
|
-
coordinates
|
|
215
|
+
coordinates,
|
|
239
216
|
};
|
|
240
217
|
return feature(geom, properties, options);
|
|
241
218
|
}
|
|
@@ -257,9 +234,8 @@ export function polygon(coordinates, properties, options) {
|
|
|
257
234
|
*
|
|
258
235
|
* //=polygons
|
|
259
236
|
*/
|
|
260
|
-
export function polygons(coordinates, properties, options) {
|
|
261
|
-
|
|
262
|
-
return featureCollection(coordinates.map(function (coords) {
|
|
237
|
+
export function polygons(coordinates, properties, options = {}) {
|
|
238
|
+
return featureCollection(coordinates.map((coords) => {
|
|
263
239
|
return polygon(coords, properties);
|
|
264
240
|
}), options);
|
|
265
241
|
}
|
|
@@ -280,14 +256,13 @@ export function polygons(coordinates, properties, options) {
|
|
|
280
256
|
* //=linestring1
|
|
281
257
|
* //=linestring2
|
|
282
258
|
*/
|
|
283
|
-
export function lineString(coordinates, properties, options) {
|
|
284
|
-
if (options === void 0) { options = {}; }
|
|
259
|
+
export function lineString(coordinates, properties, options = {}) {
|
|
285
260
|
if (coordinates.length < 2) {
|
|
286
261
|
throw new Error("coordinates must be an array of two or more positions");
|
|
287
262
|
}
|
|
288
|
-
|
|
263
|
+
const geom = {
|
|
289
264
|
type: "LineString",
|
|
290
|
-
coordinates
|
|
265
|
+
coordinates,
|
|
291
266
|
};
|
|
292
267
|
return feature(geom, properties, options);
|
|
293
268
|
}
|
|
@@ -310,9 +285,8 @@ export function lineString(coordinates, properties, options) {
|
|
|
310
285
|
*
|
|
311
286
|
* //=linestrings
|
|
312
287
|
*/
|
|
313
|
-
export function lineStrings(coordinates, properties, options) {
|
|
314
|
-
|
|
315
|
-
return featureCollection(coordinates.map(function (coords) {
|
|
288
|
+
export function lineStrings(coordinates, properties, options = {}) {
|
|
289
|
+
return featureCollection(coordinates.map((coords) => {
|
|
316
290
|
return lineString(coords, properties);
|
|
317
291
|
}), options);
|
|
318
292
|
}
|
|
@@ -338,9 +312,8 @@ export function lineStrings(coordinates, properties, options) {
|
|
|
338
312
|
*
|
|
339
313
|
* //=collection
|
|
340
314
|
*/
|
|
341
|
-
export function featureCollection(features, options) {
|
|
342
|
-
|
|
343
|
-
var fc = { type: "FeatureCollection" };
|
|
315
|
+
export function featureCollection(features, options = {}) {
|
|
316
|
+
const fc = { type: "FeatureCollection" };
|
|
344
317
|
if (options.id) {
|
|
345
318
|
fc.id = options.id;
|
|
346
319
|
}
|
|
@@ -367,11 +340,10 @@ export function featureCollection(features, options) {
|
|
|
367
340
|
*
|
|
368
341
|
* //=multiLine
|
|
369
342
|
*/
|
|
370
|
-
export function multiLineString(coordinates, properties, options) {
|
|
371
|
-
|
|
372
|
-
var geom = {
|
|
343
|
+
export function multiLineString(coordinates, properties, options = {}) {
|
|
344
|
+
const geom = {
|
|
373
345
|
type: "MultiLineString",
|
|
374
|
-
coordinates
|
|
346
|
+
coordinates,
|
|
375
347
|
};
|
|
376
348
|
return feature(geom, properties, options);
|
|
377
349
|
}
|
|
@@ -392,11 +364,10 @@ export function multiLineString(coordinates, properties, options) {
|
|
|
392
364
|
*
|
|
393
365
|
* //=multiPt
|
|
394
366
|
*/
|
|
395
|
-
export function multiPoint(coordinates, properties, options) {
|
|
396
|
-
|
|
397
|
-
var geom = {
|
|
367
|
+
export function multiPoint(coordinates, properties, options = {}) {
|
|
368
|
+
const geom = {
|
|
398
369
|
type: "MultiPoint",
|
|
399
|
-
coordinates
|
|
370
|
+
coordinates,
|
|
400
371
|
};
|
|
401
372
|
return feature(geom, properties, options);
|
|
402
373
|
}
|
|
@@ -418,11 +389,10 @@ export function multiPoint(coordinates, properties, options) {
|
|
|
418
389
|
* //=multiPoly
|
|
419
390
|
*
|
|
420
391
|
*/
|
|
421
|
-
export function multiPolygon(coordinates, properties, options) {
|
|
422
|
-
|
|
423
|
-
var geom = {
|
|
392
|
+
export function multiPolygon(coordinates, properties, options = {}) {
|
|
393
|
+
const geom = {
|
|
424
394
|
type: "MultiPolygon",
|
|
425
|
-
coordinates
|
|
395
|
+
coordinates,
|
|
426
396
|
};
|
|
427
397
|
return feature(geom, properties, options);
|
|
428
398
|
}
|
|
@@ -444,11 +414,10 @@ export function multiPolygon(coordinates, properties, options) {
|
|
|
444
414
|
*
|
|
445
415
|
* // => collection
|
|
446
416
|
*/
|
|
447
|
-
export function geometryCollection(geometries, properties, options) {
|
|
448
|
-
|
|
449
|
-
var geom = {
|
|
417
|
+
export function geometryCollection(geometries, properties, options = {}) {
|
|
418
|
+
const geom = {
|
|
450
419
|
type: "GeometryCollection",
|
|
451
|
-
geometries
|
|
420
|
+
geometries,
|
|
452
421
|
};
|
|
453
422
|
return feature(geom, properties, options);
|
|
454
423
|
}
|
|
@@ -465,12 +434,11 @@ export function geometryCollection(geometries, properties, options) {
|
|
|
465
434
|
* turf.round(120.4321, 2)
|
|
466
435
|
* //=120.43
|
|
467
436
|
*/
|
|
468
|
-
export function round(num, precision) {
|
|
469
|
-
if (precision === void 0) { precision = 0; }
|
|
437
|
+
export function round(num, precision = 0) {
|
|
470
438
|
if (precision && !(precision >= 0)) {
|
|
471
439
|
throw new Error("precision must be a positive number");
|
|
472
440
|
}
|
|
473
|
-
|
|
441
|
+
const multiplier = Math.pow(10, precision || 0);
|
|
474
442
|
return Math.round(num * multiplier) / multiplier;
|
|
475
443
|
}
|
|
476
444
|
/**
|
|
@@ -483,9 +451,8 @@ export function round(num, precision) {
|
|
|
483
451
|
* meters, kilometres, kilometers.
|
|
484
452
|
* @returns {number} distance
|
|
485
453
|
*/
|
|
486
|
-
export function radiansToLength(radians, units) {
|
|
487
|
-
|
|
488
|
-
var factor = factors[units];
|
|
454
|
+
export function radiansToLength(radians, units = "kilometers") {
|
|
455
|
+
const factor = factors[units];
|
|
489
456
|
if (!factor) {
|
|
490
457
|
throw new Error(units + " units is invalid");
|
|
491
458
|
}
|
|
@@ -501,9 +468,8 @@ export function radiansToLength(radians, units) {
|
|
|
501
468
|
* meters, kilometres, kilometers.
|
|
502
469
|
* @returns {number} radians
|
|
503
470
|
*/
|
|
504
|
-
export function lengthToRadians(distance, units) {
|
|
505
|
-
|
|
506
|
-
var factor = factors[units];
|
|
471
|
+
export function lengthToRadians(distance, units = "kilometers") {
|
|
472
|
+
const factor = factors[units];
|
|
507
473
|
if (!factor) {
|
|
508
474
|
throw new Error(units + " units is invalid");
|
|
509
475
|
}
|
|
@@ -531,7 +497,7 @@ export function lengthToDegrees(distance, units) {
|
|
|
531
497
|
* @returns {number} angle between 0 and 360 degrees
|
|
532
498
|
*/
|
|
533
499
|
export function bearingToAzimuth(bearing) {
|
|
534
|
-
|
|
500
|
+
let angle = bearing % 360;
|
|
535
501
|
if (angle < 0) {
|
|
536
502
|
angle += 360;
|
|
537
503
|
}
|
|
@@ -545,7 +511,7 @@ export function bearingToAzimuth(bearing) {
|
|
|
545
511
|
* @returns {number} degrees between 0 and 360 degrees
|
|
546
512
|
*/
|
|
547
513
|
export function radiansToDegrees(radians) {
|
|
548
|
-
|
|
514
|
+
const degrees = radians % (2 * Math.PI);
|
|
549
515
|
return (degrees * 180) / Math.PI;
|
|
550
516
|
}
|
|
551
517
|
/**
|
|
@@ -556,7 +522,7 @@ export function radiansToDegrees(radians) {
|
|
|
556
522
|
* @returns {number} angle in radians
|
|
557
523
|
*/
|
|
558
524
|
export function degreesToRadians(degrees) {
|
|
559
|
-
|
|
525
|
+
const radians = degrees % 360;
|
|
560
526
|
return (radians * Math.PI) / 180;
|
|
561
527
|
}
|
|
562
528
|
/**
|
|
@@ -568,9 +534,7 @@ export function degreesToRadians(degrees) {
|
|
|
568
534
|
* @param {Units} [finalUnit="kilometers"] returned unit
|
|
569
535
|
* @returns {number} the converted length
|
|
570
536
|
*/
|
|
571
|
-
export function convertLength(length, originalUnit, finalUnit) {
|
|
572
|
-
if (originalUnit === void 0) { originalUnit = "kilometers"; }
|
|
573
|
-
if (finalUnit === void 0) { finalUnit = "kilometers"; }
|
|
537
|
+
export function convertLength(length, originalUnit = "kilometers", finalUnit = "kilometers") {
|
|
574
538
|
if (!(length >= 0)) {
|
|
575
539
|
throw new Error("length must be a positive number");
|
|
576
540
|
}
|
|
@@ -584,17 +548,15 @@ export function convertLength(length, originalUnit, finalUnit) {
|
|
|
584
548
|
* @param {Units} [finalUnit="kilometers"] returned unit
|
|
585
549
|
* @returns {number} the converted area
|
|
586
550
|
*/
|
|
587
|
-
export function convertArea(area, originalUnit, finalUnit) {
|
|
588
|
-
if (originalUnit === void 0) { originalUnit = "meters"; }
|
|
589
|
-
if (finalUnit === void 0) { finalUnit = "kilometers"; }
|
|
551
|
+
export function convertArea(area, originalUnit = "meters", finalUnit = "kilometers") {
|
|
590
552
|
if (!(area >= 0)) {
|
|
591
553
|
throw new Error("area must be a positive number");
|
|
592
554
|
}
|
|
593
|
-
|
|
555
|
+
const startFactor = areaFactors[originalUnit];
|
|
594
556
|
if (!startFactor) {
|
|
595
557
|
throw new Error("invalid original units");
|
|
596
558
|
}
|
|
597
|
-
|
|
559
|
+
const finalFactor = areaFactors[finalUnit];
|
|
598
560
|
if (!finalFactor) {
|
|
599
561
|
throw new Error("invalid final units");
|
|
600
562
|
}
|
|
@@ -618,7 +580,7 @@ export function isNumber(num) {
|
|
|
618
580
|
* isObject
|
|
619
581
|
*
|
|
620
582
|
* @param {*} input variable to validate
|
|
621
|
-
* @returns {boolean} true/false
|
|
583
|
+
* @returns {boolean} true/false, including false for Arrays and Functions
|
|
622
584
|
* @example
|
|
623
585
|
* turf.isObject({elevation: 10})
|
|
624
586
|
* //=true
|
|
@@ -626,7 +588,7 @@ export function isNumber(num) {
|
|
|
626
588
|
* //=false
|
|
627
589
|
*/
|
|
628
590
|
export function isObject(input) {
|
|
629
|
-
return
|
|
591
|
+
return input !== null && typeof input === "object" && !Array.isArray(input);
|
|
630
592
|
}
|
|
631
593
|
/**
|
|
632
594
|
* Validate BBox
|
|
@@ -634,7 +596,7 @@ export function isObject(input) {
|
|
|
634
596
|
* @private
|
|
635
597
|
* @param {Array<number>} bbox BBox to validate
|
|
636
598
|
* @returns {void}
|
|
637
|
-
* @throws Error if BBox is not valid
|
|
599
|
+
* @throws {Error} if BBox is not valid
|
|
638
600
|
* @example
|
|
639
601
|
* validateBBox([-180, -40, 110, 50])
|
|
640
602
|
* //=OK
|
|
@@ -659,7 +621,7 @@ export function validateBBox(bbox) {
|
|
|
659
621
|
if (bbox.length !== 4 && bbox.length !== 6) {
|
|
660
622
|
throw new Error("bbox must be an Array of 4 or 6 numbers");
|
|
661
623
|
}
|
|
662
|
-
bbox.forEach(
|
|
624
|
+
bbox.forEach((num) => {
|
|
663
625
|
if (!isNumber(num)) {
|
|
664
626
|
throw new Error("bbox must only contain numbers");
|
|
665
627
|
}
|
|
@@ -671,7 +633,7 @@ export function validateBBox(bbox) {
|
|
|
671
633
|
* @private
|
|
672
634
|
* @param {string|number} id Id to validate
|
|
673
635
|
* @returns {void}
|
|
674
|
-
* @throws Error if Id is not valid
|
|
636
|
+
* @throws {Error} if Id is not valid
|
|
675
637
|
* @example
|
|
676
638
|
* validateId([-180, -40, 110, 50])
|
|
677
639
|
* //=Error
|
package/dist/es/lib/geojson.js
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Type definitions for geojson 7946.0
|
|
2
|
-
// Project: https://geojson.org/
|
|
3
|
-
// Definitions by: Jacob Bruun <https://github.com/cobster>
|
|
4
|
-
// Arne Schubert <https://github.com/atd-schubert>
|
|
5
|
-
// Jeff Jacobson <https://github.com/JeffJacobson>
|
|
6
|
-
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
7
|
-
// TypeScript Version: 2.3
|
package/dist/js/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BBox,
|
|
2
|
-
|
|
1
|
+
import { BBox, Feature, FeatureCollection, Geometry, GeometryCollection, GeometryObject, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, Position, GeoJsonProperties } from "geojson";
|
|
2
|
+
import { Id } from "./lib/geojson";
|
|
3
|
+
export * from "./lib/geojson";
|
|
3
4
|
export declare type Coord = Feature<Point> | Point | Position;
|
|
4
|
-
export declare type Units = "meters" | "millimeters" | "centimeters" | "kilometers" | "acres" | "miles" | "nauticalmiles" | "inches" | "yards" | "feet" | "radians" | "degrees" | "hectares";
|
|
5
|
+
export declare type Units = "meters" | "metres" | "millimeters" | "millimetres" | "centimeters" | "centimetres" | "kilometers" | "kilometres" | "acres" | "miles" | "nauticalmiles" | "inches" | "yards" | "feet" | "radians" | "degrees" | "hectares";
|
|
5
6
|
export declare type Grid = "point" | "square" | "hex" | "triangle";
|
|
6
7
|
export declare type Corners = "sw" | "se" | "nw" | "ne" | "center" | "centroid";
|
|
7
8
|
export declare type Lines = LineString | MultiLineString | Polygon | MultiPolygon;
|
|
@@ -15,32 +16,28 @@ export declare type AllGeoJSON = Feature | FeatureCollection | Geometry | Geomet
|
|
|
15
16
|
* @memberof helpers
|
|
16
17
|
* @type {number}
|
|
17
18
|
*/
|
|
18
|
-
export declare
|
|
19
|
+
export declare const earthRadius = 6371008.8;
|
|
19
20
|
/**
|
|
20
21
|
* Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
* @type {Object}
|
|
24
|
-
*/
|
|
25
|
-
export declare let factors: {
|
|
26
|
-
[key: string]: number;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Units of measurement factors based on 1 meter.
|
|
23
|
+
* Keys are the name of the unit, values are the number of that unit in a single radian
|
|
30
24
|
*
|
|
31
25
|
* @memberof helpers
|
|
32
26
|
* @type {Object}
|
|
33
27
|
*/
|
|
34
|
-
export declare
|
|
28
|
+
export declare const factors: {
|
|
35
29
|
[key: string]: number;
|
|
36
30
|
};
|
|
37
31
|
/**
|
|
32
|
+
|
|
38
33
|
* Area of measurement factors based on 1 square meter.
|
|
39
34
|
*
|
|
40
35
|
* @memberof helpers
|
|
41
36
|
* @type {Object}
|
|
42
37
|
*/
|
|
43
|
-
export declare
|
|
38
|
+
export declare const areaFactors: {
|
|
39
|
+
[key: string]: number;
|
|
40
|
+
};
|
|
44
41
|
/**
|
|
45
42
|
* Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
|
|
46
43
|
*
|
|
@@ -61,7 +58,7 @@ export declare let areaFactors: any;
|
|
|
61
58
|
*
|
|
62
59
|
* //=feature
|
|
63
60
|
*/
|
|
64
|
-
export declare function feature<G = Geometry, P =
|
|
61
|
+
export declare function feature<G extends GeometryObject = Geometry, P = GeoJsonProperties>(geom: G | null, properties?: P, options?: {
|
|
65
62
|
bbox?: BBox;
|
|
66
63
|
id?: Id;
|
|
67
64
|
}): Feature<G, P>;
|
|
@@ -80,7 +77,7 @@ export declare function feature<G = Geometry, P = Properties>(geom: G, propertie
|
|
|
80
77
|
* var geometry = turf.geometry(type, coordinates);
|
|
81
78
|
* // => geometry
|
|
82
79
|
*/
|
|
83
|
-
export declare function geometry(type: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon", coordinates: any[], _options?:
|
|
80
|
+
export declare function geometry(type: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon", coordinates: any[], _options?: Record<string, never>): Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon;
|
|
84
81
|
/**
|
|
85
82
|
* Creates a {@link Point} {@link Feature} from a Position.
|
|
86
83
|
*
|
|
@@ -96,7 +93,7 @@ export declare function geometry(type: "Point" | "LineString" | "Polygon" | "Mul
|
|
|
96
93
|
*
|
|
97
94
|
* //=point
|
|
98
95
|
*/
|
|
99
|
-
export declare function point<P =
|
|
96
|
+
export declare function point<P = GeoJsonProperties>(coordinates: Position, properties?: P, options?: {
|
|
100
97
|
bbox?: BBox;
|
|
101
98
|
id?: Id;
|
|
102
99
|
}): Feature<Point, P>;
|
|
@@ -120,7 +117,7 @@ export declare function point<P = Properties>(coordinates: Position, properties?
|
|
|
120
117
|
*
|
|
121
118
|
* //=points
|
|
122
119
|
*/
|
|
123
|
-
export declare function points<P =
|
|
120
|
+
export declare function points<P = GeoJsonProperties>(coordinates: Position[], properties?: P, options?: {
|
|
124
121
|
bbox?: BBox;
|
|
125
122
|
id?: Id;
|
|
126
123
|
}): FeatureCollection<Point, P>;
|
|
@@ -139,7 +136,7 @@ export declare function points<P = Properties>(coordinates: Position[], properti
|
|
|
139
136
|
*
|
|
140
137
|
* //=polygon
|
|
141
138
|
*/
|
|
142
|
-
export declare function polygon<P =
|
|
139
|
+
export declare function polygon<P = GeoJsonProperties>(coordinates: Position[][], properties?: P, options?: {
|
|
143
140
|
bbox?: BBox;
|
|
144
141
|
id?: Id;
|
|
145
142
|
}): Feature<Polygon, P>;
|
|
@@ -161,7 +158,7 @@ export declare function polygon<P = Properties>(coordinates: Position[][], prope
|
|
|
161
158
|
*
|
|
162
159
|
* //=polygons
|
|
163
160
|
*/
|
|
164
|
-
export declare function polygons<P =
|
|
161
|
+
export declare function polygons<P = GeoJsonProperties>(coordinates: Position[][][], properties?: P, options?: {
|
|
165
162
|
bbox?: BBox;
|
|
166
163
|
id?: Id;
|
|
167
164
|
}): FeatureCollection<Polygon, P>;
|
|
@@ -182,7 +179,7 @@ export declare function polygons<P = Properties>(coordinates: Position[][][], pr
|
|
|
182
179
|
* //=linestring1
|
|
183
180
|
* //=linestring2
|
|
184
181
|
*/
|
|
185
|
-
export declare function lineString<P =
|
|
182
|
+
export declare function lineString<P = GeoJsonProperties>(coordinates: Position[], properties?: P, options?: {
|
|
186
183
|
bbox?: BBox;
|
|
187
184
|
id?: Id;
|
|
188
185
|
}): Feature<LineString, P>;
|
|
@@ -205,7 +202,7 @@ export declare function lineString<P = Properties>(coordinates: Position[], prop
|
|
|
205
202
|
*
|
|
206
203
|
* //=linestrings
|
|
207
204
|
*/
|
|
208
|
-
export declare function lineStrings<P =
|
|
205
|
+
export declare function lineStrings<P = GeoJsonProperties>(coordinates: Position[][], properties?: P, options?: {
|
|
209
206
|
bbox?: BBox;
|
|
210
207
|
id?: Id;
|
|
211
208
|
}): FeatureCollection<LineString, P>;
|
|
@@ -231,7 +228,7 @@ export declare function lineStrings<P = Properties>(coordinates: Position[][], p
|
|
|
231
228
|
*
|
|
232
229
|
* //=collection
|
|
233
230
|
*/
|
|
234
|
-
export declare function featureCollection<G = Geometry, P =
|
|
231
|
+
export declare function featureCollection<G extends GeometryObject = Geometry, P = GeoJsonProperties>(features: Array<Feature<G, P>>, options?: {
|
|
235
232
|
bbox?: BBox;
|
|
236
233
|
id?: Id;
|
|
237
234
|
}): FeatureCollection<G, P>;
|
|
@@ -252,7 +249,7 @@ export declare function featureCollection<G = Geometry, P = Properties>(features
|
|
|
252
249
|
*
|
|
253
250
|
* //=multiLine
|
|
254
251
|
*/
|
|
255
|
-
export declare function multiLineString<P =
|
|
252
|
+
export declare function multiLineString<P = GeoJsonProperties>(coordinates: Position[][], properties?: P, options?: {
|
|
256
253
|
bbox?: BBox;
|
|
257
254
|
id?: Id;
|
|
258
255
|
}): Feature<MultiLineString, P>;
|
|
@@ -273,7 +270,7 @@ export declare function multiLineString<P = Properties>(coordinates: Position[][
|
|
|
273
270
|
*
|
|
274
271
|
* //=multiPt
|
|
275
272
|
*/
|
|
276
|
-
export declare function multiPoint<P =
|
|
273
|
+
export declare function multiPoint<P = GeoJsonProperties>(coordinates: Position[], properties?: P, options?: {
|
|
277
274
|
bbox?: BBox;
|
|
278
275
|
id?: Id;
|
|
279
276
|
}): Feature<MultiPoint, P>;
|
|
@@ -295,7 +292,7 @@ export declare function multiPoint<P = Properties>(coordinates: Position[], prop
|
|
|
295
292
|
* //=multiPoly
|
|
296
293
|
*
|
|
297
294
|
*/
|
|
298
|
-
export declare function multiPolygon<P =
|
|
295
|
+
export declare function multiPolygon<P = GeoJsonProperties>(coordinates: Position[][][], properties?: P, options?: {
|
|
299
296
|
bbox?: BBox;
|
|
300
297
|
id?: Id;
|
|
301
298
|
}): Feature<MultiPolygon, P>;
|
|
@@ -317,7 +314,7 @@ export declare function multiPolygon<P = Properties>(coordinates: Position[][][]
|
|
|
317
314
|
*
|
|
318
315
|
* // => collection
|
|
319
316
|
*/
|
|
320
|
-
export declare function geometryCollection<P =
|
|
317
|
+
export declare function geometryCollection<P = GeoJsonProperties>(geometries: Array<Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon>, properties?: P, options?: {
|
|
321
318
|
bbox?: BBox;
|
|
322
319
|
id?: Id;
|
|
323
320
|
}): Feature<GeometryCollection, P>;
|
|
@@ -428,7 +425,7 @@ export declare function isNumber(num: any): boolean;
|
|
|
428
425
|
* isObject
|
|
429
426
|
*
|
|
430
427
|
* @param {*} input variable to validate
|
|
431
|
-
* @returns {boolean} true/false
|
|
428
|
+
* @returns {boolean} true/false, including false for Arrays and Functions
|
|
432
429
|
* @example
|
|
433
430
|
* turf.isObject({elevation: 10})
|
|
434
431
|
* //=true
|
|
@@ -442,7 +439,7 @@ export declare function isObject(input: any): boolean;
|
|
|
442
439
|
* @private
|
|
443
440
|
* @param {Array<number>} bbox BBox to validate
|
|
444
441
|
* @returns {void}
|
|
445
|
-
* @throws Error if BBox is not valid
|
|
442
|
+
* @throws {Error} if BBox is not valid
|
|
446
443
|
* @example
|
|
447
444
|
* validateBBox([-180, -40, 110, 50])
|
|
448
445
|
* //=OK
|
|
@@ -464,7 +461,7 @@ export declare function validateBBox(bbox: any): void;
|
|
|
464
461
|
* @private
|
|
465
462
|
* @param {string|number} id Id to validate
|
|
466
463
|
* @returns {void}
|
|
467
|
-
* @throws Error if Id is not valid
|
|
464
|
+
* @throws {Error} if Id is not valid
|
|
468
465
|
* @example
|
|
469
466
|
* validateId([-180, -40, 110, 50])
|
|
470
467
|
* //=Error
|