@turf/helpers 6.5.0 → 7.0.0-alpha.1
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 +63 -100
- package/dist/es/lib/geojson.js +0 -7
- package/dist/js/index.d.ts +27 -33
- package/dist/js/index.js +60 -97
- package/dist/js/lib/geojson.d.ts +2 -185
- package/dist/js/lib/geojson.js +0 -7
- package/package.json +11 -7
package/dist/js/index.js
CHANGED
|
@@ -13,13 +13,15 @@ exports.earthRadius = 6371008.8;
|
|
|
13
13
|
/**
|
|
14
14
|
* Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
|
|
15
15
|
*
|
|
16
|
+
* Keys are the name of the unit, values are the number of that unit in a single radian
|
|
17
|
+
*
|
|
16
18
|
* @memberof helpers
|
|
17
19
|
* @type {Object}
|
|
18
20
|
*/
|
|
19
21
|
exports.factors = {
|
|
20
22
|
centimeters: exports.earthRadius * 100,
|
|
21
23
|
centimetres: exports.earthRadius * 100,
|
|
22
|
-
degrees:
|
|
24
|
+
degrees: 360 / (2 * Math.PI),
|
|
23
25
|
feet: exports.earthRadius * 3.28084,
|
|
24
26
|
inches: exports.earthRadius * 39.37,
|
|
25
27
|
kilometers: exports.earthRadius / 1000,
|
|
@@ -34,29 +36,7 @@ exports.factors = {
|
|
|
34
36
|
yards: exports.earthRadius * 1.0936,
|
|
35
37
|
};
|
|
36
38
|
/**
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
* @memberof helpers
|
|
40
|
-
* @type {Object}
|
|
41
|
-
*/
|
|
42
|
-
exports.unitsFactors = {
|
|
43
|
-
centimeters: 100,
|
|
44
|
-
centimetres: 100,
|
|
45
|
-
degrees: 1 / 111325,
|
|
46
|
-
feet: 3.28084,
|
|
47
|
-
inches: 39.37,
|
|
48
|
-
kilometers: 1 / 1000,
|
|
49
|
-
kilometres: 1 / 1000,
|
|
50
|
-
meters: 1,
|
|
51
|
-
metres: 1,
|
|
52
|
-
miles: 1 / 1609.344,
|
|
53
|
-
millimeters: 1000,
|
|
54
|
-
millimetres: 1000,
|
|
55
|
-
nauticalmiles: 1 / 1852,
|
|
56
|
-
radians: 1 / exports.earthRadius,
|
|
57
|
-
yards: 1.0936133,
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
39
|
+
|
|
60
40
|
* Area of measurement factors based on 1 square meter.
|
|
61
41
|
*
|
|
62
42
|
* @memberof helpers
|
|
@@ -74,6 +54,7 @@ exports.areaFactors = {
|
|
|
74
54
|
meters: 1,
|
|
75
55
|
metres: 1,
|
|
76
56
|
miles: 3.86e-7,
|
|
57
|
+
nauticalmiles: 2.9155334959812285e-7,
|
|
77
58
|
millimeters: 1000000,
|
|
78
59
|
millimetres: 1000000,
|
|
79
60
|
yards: 1.195990046,
|
|
@@ -98,9 +79,8 @@ exports.areaFactors = {
|
|
|
98
79
|
*
|
|
99
80
|
* //=feature
|
|
100
81
|
*/
|
|
101
|
-
function feature(geom, properties, options) {
|
|
102
|
-
|
|
103
|
-
var feat = { type: "Feature" };
|
|
82
|
+
function feature(geom, properties, options = {}) {
|
|
83
|
+
const feat = { type: "Feature" };
|
|
104
84
|
if (options.id === 0 || options.id) {
|
|
105
85
|
feat.id = options.id;
|
|
106
86
|
}
|
|
@@ -127,8 +107,7 @@ exports.feature = feature;
|
|
|
127
107
|
* var geometry = turf.geometry(type, coordinates);
|
|
128
108
|
* // => geometry
|
|
129
109
|
*/
|
|
130
|
-
function geometry(type, coordinates, _options) {
|
|
131
|
-
if (_options === void 0) { _options = {}; }
|
|
110
|
+
function geometry(type, coordinates, _options = {}) {
|
|
132
111
|
switch (type) {
|
|
133
112
|
case "Point":
|
|
134
113
|
return point(coordinates).geometry;
|
|
@@ -162,8 +141,7 @@ exports.geometry = geometry;
|
|
|
162
141
|
*
|
|
163
142
|
* //=point
|
|
164
143
|
*/
|
|
165
|
-
function point(coordinates, properties, options) {
|
|
166
|
-
if (options === void 0) { options = {}; }
|
|
144
|
+
function point(coordinates, properties, options = {}) {
|
|
167
145
|
if (!coordinates) {
|
|
168
146
|
throw new Error("coordinates is required");
|
|
169
147
|
}
|
|
@@ -176,9 +154,9 @@ function point(coordinates, properties, options) {
|
|
|
176
154
|
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
|
|
177
155
|
throw new Error("coordinates must contain numbers");
|
|
178
156
|
}
|
|
179
|
-
|
|
157
|
+
const geom = {
|
|
180
158
|
type: "Point",
|
|
181
|
-
coordinates
|
|
159
|
+
coordinates,
|
|
182
160
|
};
|
|
183
161
|
return feature(geom, properties, options);
|
|
184
162
|
}
|
|
@@ -203,9 +181,8 @@ exports.point = point;
|
|
|
203
181
|
*
|
|
204
182
|
* //=points
|
|
205
183
|
*/
|
|
206
|
-
function points(coordinates, properties, options) {
|
|
207
|
-
|
|
208
|
-
return featureCollection(coordinates.map(function (coords) {
|
|
184
|
+
function points(coordinates, properties, options = {}) {
|
|
185
|
+
return featureCollection(coordinates.map((coords) => {
|
|
209
186
|
return point(coords, properties);
|
|
210
187
|
}), options);
|
|
211
188
|
}
|
|
@@ -225,23 +202,24 @@ exports.points = points;
|
|
|
225
202
|
*
|
|
226
203
|
* //=polygon
|
|
227
204
|
*/
|
|
228
|
-
function polygon(coordinates, properties, options) {
|
|
229
|
-
|
|
230
|
-
for (var _i = 0, coordinates_1 = coordinates; _i < coordinates_1.length; _i++) {
|
|
231
|
-
var ring = coordinates_1[_i];
|
|
205
|
+
function polygon(coordinates, properties, options = {}) {
|
|
206
|
+
for (const ring of coordinates) {
|
|
232
207
|
if (ring.length < 4) {
|
|
233
208
|
throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
|
|
234
209
|
}
|
|
235
|
-
|
|
210
|
+
if (ring[ring.length - 1].length !== ring[0].length) {
|
|
211
|
+
throw new Error("First and last Position are not equivalent.");
|
|
212
|
+
}
|
|
213
|
+
for (let j = 0; j < ring[ring.length - 1].length; j++) {
|
|
236
214
|
// Check if first point of Polygon contains two numbers
|
|
237
215
|
if (ring[ring.length - 1][j] !== ring[0][j]) {
|
|
238
216
|
throw new Error("First and last Position are not equivalent.");
|
|
239
217
|
}
|
|
240
218
|
}
|
|
241
219
|
}
|
|
242
|
-
|
|
220
|
+
const geom = {
|
|
243
221
|
type: "Polygon",
|
|
244
|
-
coordinates
|
|
222
|
+
coordinates,
|
|
245
223
|
};
|
|
246
224
|
return feature(geom, properties, options);
|
|
247
225
|
}
|
|
@@ -264,9 +242,8 @@ exports.polygon = polygon;
|
|
|
264
242
|
*
|
|
265
243
|
* //=polygons
|
|
266
244
|
*/
|
|
267
|
-
function polygons(coordinates, properties, options) {
|
|
268
|
-
|
|
269
|
-
return featureCollection(coordinates.map(function (coords) {
|
|
245
|
+
function polygons(coordinates, properties, options = {}) {
|
|
246
|
+
return featureCollection(coordinates.map((coords) => {
|
|
270
247
|
return polygon(coords, properties);
|
|
271
248
|
}), options);
|
|
272
249
|
}
|
|
@@ -288,14 +265,13 @@ exports.polygons = polygons;
|
|
|
288
265
|
* //=linestring1
|
|
289
266
|
* //=linestring2
|
|
290
267
|
*/
|
|
291
|
-
function lineString(coordinates, properties, options) {
|
|
292
|
-
if (options === void 0) { options = {}; }
|
|
268
|
+
function lineString(coordinates, properties, options = {}) {
|
|
293
269
|
if (coordinates.length < 2) {
|
|
294
270
|
throw new Error("coordinates must be an array of two or more positions");
|
|
295
271
|
}
|
|
296
|
-
|
|
272
|
+
const geom = {
|
|
297
273
|
type: "LineString",
|
|
298
|
-
coordinates
|
|
274
|
+
coordinates,
|
|
299
275
|
};
|
|
300
276
|
return feature(geom, properties, options);
|
|
301
277
|
}
|
|
@@ -319,9 +295,8 @@ exports.lineString = lineString;
|
|
|
319
295
|
*
|
|
320
296
|
* //=linestrings
|
|
321
297
|
*/
|
|
322
|
-
function lineStrings(coordinates, properties, options) {
|
|
323
|
-
|
|
324
|
-
return featureCollection(coordinates.map(function (coords) {
|
|
298
|
+
function lineStrings(coordinates, properties, options = {}) {
|
|
299
|
+
return featureCollection(coordinates.map((coords) => {
|
|
325
300
|
return lineString(coords, properties);
|
|
326
301
|
}), options);
|
|
327
302
|
}
|
|
@@ -348,9 +323,8 @@ exports.lineStrings = lineStrings;
|
|
|
348
323
|
*
|
|
349
324
|
* //=collection
|
|
350
325
|
*/
|
|
351
|
-
function featureCollection(features, options) {
|
|
352
|
-
|
|
353
|
-
var fc = { type: "FeatureCollection" };
|
|
326
|
+
function featureCollection(features, options = {}) {
|
|
327
|
+
const fc = { type: "FeatureCollection" };
|
|
354
328
|
if (options.id) {
|
|
355
329
|
fc.id = options.id;
|
|
356
330
|
}
|
|
@@ -378,11 +352,10 @@ exports.featureCollection = featureCollection;
|
|
|
378
352
|
*
|
|
379
353
|
* //=multiLine
|
|
380
354
|
*/
|
|
381
|
-
function multiLineString(coordinates, properties, options) {
|
|
382
|
-
|
|
383
|
-
var geom = {
|
|
355
|
+
function multiLineString(coordinates, properties, options = {}) {
|
|
356
|
+
const geom = {
|
|
384
357
|
type: "MultiLineString",
|
|
385
|
-
coordinates
|
|
358
|
+
coordinates,
|
|
386
359
|
};
|
|
387
360
|
return feature(geom, properties, options);
|
|
388
361
|
}
|
|
@@ -404,11 +377,10 @@ exports.multiLineString = multiLineString;
|
|
|
404
377
|
*
|
|
405
378
|
* //=multiPt
|
|
406
379
|
*/
|
|
407
|
-
function multiPoint(coordinates, properties, options) {
|
|
408
|
-
|
|
409
|
-
var geom = {
|
|
380
|
+
function multiPoint(coordinates, properties, options = {}) {
|
|
381
|
+
const geom = {
|
|
410
382
|
type: "MultiPoint",
|
|
411
|
-
coordinates
|
|
383
|
+
coordinates,
|
|
412
384
|
};
|
|
413
385
|
return feature(geom, properties, options);
|
|
414
386
|
}
|
|
@@ -431,11 +403,10 @@ exports.multiPoint = multiPoint;
|
|
|
431
403
|
* //=multiPoly
|
|
432
404
|
*
|
|
433
405
|
*/
|
|
434
|
-
function multiPolygon(coordinates, properties, options) {
|
|
435
|
-
|
|
436
|
-
var geom = {
|
|
406
|
+
function multiPolygon(coordinates, properties, options = {}) {
|
|
407
|
+
const geom = {
|
|
437
408
|
type: "MultiPolygon",
|
|
438
|
-
coordinates
|
|
409
|
+
coordinates,
|
|
439
410
|
};
|
|
440
411
|
return feature(geom, properties, options);
|
|
441
412
|
}
|
|
@@ -458,11 +429,10 @@ exports.multiPolygon = multiPolygon;
|
|
|
458
429
|
*
|
|
459
430
|
* // => collection
|
|
460
431
|
*/
|
|
461
|
-
function geometryCollection(geometries, properties, options) {
|
|
462
|
-
|
|
463
|
-
var geom = {
|
|
432
|
+
function geometryCollection(geometries, properties, options = {}) {
|
|
433
|
+
const geom = {
|
|
464
434
|
type: "GeometryCollection",
|
|
465
|
-
geometries
|
|
435
|
+
geometries,
|
|
466
436
|
};
|
|
467
437
|
return feature(geom, properties, options);
|
|
468
438
|
}
|
|
@@ -480,12 +450,11 @@ exports.geometryCollection = geometryCollection;
|
|
|
480
450
|
* turf.round(120.4321, 2)
|
|
481
451
|
* //=120.43
|
|
482
452
|
*/
|
|
483
|
-
function round(num, precision) {
|
|
484
|
-
if (precision === void 0) { precision = 0; }
|
|
453
|
+
function round(num, precision = 0) {
|
|
485
454
|
if (precision && !(precision >= 0)) {
|
|
486
455
|
throw new Error("precision must be a positive number");
|
|
487
456
|
}
|
|
488
|
-
|
|
457
|
+
const multiplier = Math.pow(10, precision || 0);
|
|
489
458
|
return Math.round(num * multiplier) / multiplier;
|
|
490
459
|
}
|
|
491
460
|
exports.round = round;
|
|
@@ -499,9 +468,8 @@ exports.round = round;
|
|
|
499
468
|
* meters, kilometres, kilometers.
|
|
500
469
|
* @returns {number} distance
|
|
501
470
|
*/
|
|
502
|
-
function radiansToLength(radians, units) {
|
|
503
|
-
|
|
504
|
-
var factor = exports.factors[units];
|
|
471
|
+
function radiansToLength(radians, units = "kilometers") {
|
|
472
|
+
const factor = exports.factors[units];
|
|
505
473
|
if (!factor) {
|
|
506
474
|
throw new Error(units + " units is invalid");
|
|
507
475
|
}
|
|
@@ -518,9 +486,8 @@ exports.radiansToLength = radiansToLength;
|
|
|
518
486
|
* meters, kilometres, kilometers.
|
|
519
487
|
* @returns {number} radians
|
|
520
488
|
*/
|
|
521
|
-
function lengthToRadians(distance, units) {
|
|
522
|
-
|
|
523
|
-
var factor = exports.factors[units];
|
|
489
|
+
function lengthToRadians(distance, units = "kilometers") {
|
|
490
|
+
const factor = exports.factors[units];
|
|
524
491
|
if (!factor) {
|
|
525
492
|
throw new Error(units + " units is invalid");
|
|
526
493
|
}
|
|
@@ -550,7 +517,7 @@ exports.lengthToDegrees = lengthToDegrees;
|
|
|
550
517
|
* @returns {number} angle between 0 and 360 degrees
|
|
551
518
|
*/
|
|
552
519
|
function bearingToAzimuth(bearing) {
|
|
553
|
-
|
|
520
|
+
let angle = bearing % 360;
|
|
554
521
|
if (angle < 0) {
|
|
555
522
|
angle += 360;
|
|
556
523
|
}
|
|
@@ -565,7 +532,7 @@ exports.bearingToAzimuth = bearingToAzimuth;
|
|
|
565
532
|
* @returns {number} degrees between 0 and 360 degrees
|
|
566
533
|
*/
|
|
567
534
|
function radiansToDegrees(radians) {
|
|
568
|
-
|
|
535
|
+
const degrees = radians % (2 * Math.PI);
|
|
569
536
|
return (degrees * 180) / Math.PI;
|
|
570
537
|
}
|
|
571
538
|
exports.radiansToDegrees = radiansToDegrees;
|
|
@@ -577,7 +544,7 @@ exports.radiansToDegrees = radiansToDegrees;
|
|
|
577
544
|
* @returns {number} angle in radians
|
|
578
545
|
*/
|
|
579
546
|
function degreesToRadians(degrees) {
|
|
580
|
-
|
|
547
|
+
const radians = degrees % 360;
|
|
581
548
|
return (radians * Math.PI) / 180;
|
|
582
549
|
}
|
|
583
550
|
exports.degreesToRadians = degreesToRadians;
|
|
@@ -590,9 +557,7 @@ exports.degreesToRadians = degreesToRadians;
|
|
|
590
557
|
* @param {Units} [finalUnit="kilometers"] returned unit
|
|
591
558
|
* @returns {number} the converted length
|
|
592
559
|
*/
|
|
593
|
-
function convertLength(length, originalUnit, finalUnit) {
|
|
594
|
-
if (originalUnit === void 0) { originalUnit = "kilometers"; }
|
|
595
|
-
if (finalUnit === void 0) { finalUnit = "kilometers"; }
|
|
560
|
+
function convertLength(length, originalUnit = "kilometers", finalUnit = "kilometers") {
|
|
596
561
|
if (!(length >= 0)) {
|
|
597
562
|
throw new Error("length must be a positive number");
|
|
598
563
|
}
|
|
@@ -607,17 +572,15 @@ exports.convertLength = convertLength;
|
|
|
607
572
|
* @param {Units} [finalUnit="kilometers"] returned unit
|
|
608
573
|
* @returns {number} the converted area
|
|
609
574
|
*/
|
|
610
|
-
function convertArea(area, originalUnit, finalUnit) {
|
|
611
|
-
if (originalUnit === void 0) { originalUnit = "meters"; }
|
|
612
|
-
if (finalUnit === void 0) { finalUnit = "kilometers"; }
|
|
575
|
+
function convertArea(area, originalUnit = "meters", finalUnit = "kilometers") {
|
|
613
576
|
if (!(area >= 0)) {
|
|
614
577
|
throw new Error("area must be a positive number");
|
|
615
578
|
}
|
|
616
|
-
|
|
579
|
+
const startFactor = exports.areaFactors[originalUnit];
|
|
617
580
|
if (!startFactor) {
|
|
618
581
|
throw new Error("invalid original units");
|
|
619
582
|
}
|
|
620
|
-
|
|
583
|
+
const finalFactor = exports.areaFactors[finalUnit];
|
|
621
584
|
if (!finalFactor) {
|
|
622
585
|
throw new Error("invalid final units");
|
|
623
586
|
}
|
|
@@ -643,7 +606,7 @@ exports.isNumber = isNumber;
|
|
|
643
606
|
* isObject
|
|
644
607
|
*
|
|
645
608
|
* @param {*} input variable to validate
|
|
646
|
-
* @returns {boolean} true/false
|
|
609
|
+
* @returns {boolean} true/false, including false for Arrays and Functions
|
|
647
610
|
* @example
|
|
648
611
|
* turf.isObject({elevation: 10})
|
|
649
612
|
* //=true
|
|
@@ -651,7 +614,7 @@ exports.isNumber = isNumber;
|
|
|
651
614
|
* //=false
|
|
652
615
|
*/
|
|
653
616
|
function isObject(input) {
|
|
654
|
-
return
|
|
617
|
+
return input !== null && typeof input === "object" && !Array.isArray(input);
|
|
655
618
|
}
|
|
656
619
|
exports.isObject = isObject;
|
|
657
620
|
/**
|
|
@@ -660,7 +623,7 @@ exports.isObject = isObject;
|
|
|
660
623
|
* @private
|
|
661
624
|
* @param {Array<number>} bbox BBox to validate
|
|
662
625
|
* @returns {void}
|
|
663
|
-
* @throws Error if BBox is not valid
|
|
626
|
+
* @throws {Error} if BBox is not valid
|
|
664
627
|
* @example
|
|
665
628
|
* validateBBox([-180, -40, 110, 50])
|
|
666
629
|
* //=OK
|
|
@@ -685,7 +648,7 @@ function validateBBox(bbox) {
|
|
|
685
648
|
if (bbox.length !== 4 && bbox.length !== 6) {
|
|
686
649
|
throw new Error("bbox must be an Array of 4 or 6 numbers");
|
|
687
650
|
}
|
|
688
|
-
bbox.forEach(
|
|
651
|
+
bbox.forEach((num) => {
|
|
689
652
|
if (!isNumber(num)) {
|
|
690
653
|
throw new Error("bbox must only contain numbers");
|
|
691
654
|
}
|
|
@@ -698,7 +661,7 @@ exports.validateBBox = validateBBox;
|
|
|
698
661
|
* @private
|
|
699
662
|
* @param {string|number} id Id to validate
|
|
700
663
|
* @returns {void}
|
|
701
|
-
* @throws Error if Id is not valid
|
|
664
|
+
* @throws {Error} if Id is not valid
|
|
702
665
|
* @example
|
|
703
666
|
* validateId([-180, -40, 110, 50])
|
|
704
667
|
* //=Error
|
package/dist/js/lib/geojson.d.ts
CHANGED
|
@@ -1,193 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GeometryTypes
|
|
3
|
-
*
|
|
4
|
-
* https://tools.ietf.org/html/rfc7946#section-1.4
|
|
5
|
-
* The valid values for the "type" property of GeoJSON geometry objects.
|
|
6
|
-
*/
|
|
7
|
-
export declare type GeometryTypes = "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon" | "GeometryCollection";
|
|
8
|
-
export declare type CollectionTypes = "FeatureCollection" | "GeometryCollection";
|
|
9
|
-
/**
|
|
10
|
-
* Types
|
|
11
|
-
*
|
|
12
|
-
* https://tools.ietf.org/html/rfc7946#section-1.4
|
|
13
|
-
* The value values for the "type" property of GeoJSON Objects.
|
|
14
|
-
*/
|
|
15
|
-
export declare type Types = "Feature" | GeometryTypes | CollectionTypes;
|
|
16
|
-
/**
|
|
17
|
-
* Bounding box
|
|
18
|
-
*
|
|
19
|
-
* https://tools.ietf.org/html/rfc7946#section-5
|
|
20
|
-
* A GeoJSON object MAY have a member named "bbox" to include information on the coordinate range for its Geometries, Features, or FeatureCollections.
|
|
21
|
-
* The value of the bbox member MUST be an array of length 2*n where n is the number of dimensions represented in the contained geometries,
|
|
22
|
-
* with all axes of the most southwesterly point followed by all axes of the more northeasterly point.
|
|
23
|
-
* The axes order of a bbox follows the axes order of geometries.
|
|
24
|
-
*/
|
|
25
|
-
export declare type BBox2d = [number, number, number, number];
|
|
26
|
-
export declare type BBox3d = [number, number, number, number, number, number];
|
|
27
|
-
export declare type BBox = BBox2d | BBox3d;
|
|
28
1
|
/**
|
|
29
2
|
* Id
|
|
30
3
|
*
|
|
31
4
|
* https://tools.ietf.org/html/rfc7946#section-3.2
|
|
32
5
|
* If a Feature has a commonly used identifier, that identifier SHOULD be included as a member of
|
|
33
6
|
* the Feature object with the name "id", and the value of this member is either a JSON string or number.
|
|
34
|
-
*/
|
|
35
|
-
export declare type Id = string | number;
|
|
36
|
-
/**
|
|
37
|
-
* Position
|
|
38
7
|
*
|
|
39
|
-
*
|
|
40
|
-
* Array should contain between two and three elements.
|
|
41
|
-
* The previous GeoJSON specification allowed more elements (e.g., which could be used to represent M values),
|
|
42
|
-
* but the current specification only allows X, Y, and (optionally) Z to be defined.
|
|
8
|
+
* Should be contributed to @types/geojson
|
|
43
9
|
*/
|
|
44
|
-
export declare type
|
|
45
|
-
/**
|
|
46
|
-
* Properties
|
|
47
|
-
*
|
|
48
|
-
* https://tools.ietf.org/html/rfc7946#section-3.2
|
|
49
|
-
* A Feature object has a member with the name "properties".
|
|
50
|
-
* The value of the properties member is an object (any JSON object or a JSON null value).
|
|
51
|
-
*/
|
|
52
|
-
export declare type Properties = {
|
|
53
|
-
[name: string]: any;
|
|
54
|
-
} | null;
|
|
55
|
-
/**
|
|
56
|
-
* Geometries
|
|
57
|
-
*/
|
|
58
|
-
export declare type Geometries = Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
|
|
59
|
-
/**
|
|
60
|
-
* GeoJSON Object
|
|
61
|
-
*
|
|
62
|
-
* https://tools.ietf.org/html/rfc7946#section-3
|
|
63
|
-
* The GeoJSON specification also allows [foreign members](https://tools.ietf.org/html/rfc7946#section-6.1)
|
|
64
|
-
* Developers should use "&" type in TypeScript or extend the interface to add these foreign members.
|
|
65
|
-
*/
|
|
66
|
-
export interface GeoJSONObject {
|
|
67
|
-
/**
|
|
68
|
-
* Specifies the type of GeoJSON object.
|
|
69
|
-
*/
|
|
70
|
-
type: string;
|
|
71
|
-
/**
|
|
72
|
-
* Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections.
|
|
73
|
-
* https://tools.ietf.org/html/rfc7946#section-5
|
|
74
|
-
*/
|
|
75
|
-
bbox?: BBox;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Geometry Object
|
|
79
|
-
*
|
|
80
|
-
* https://tools.ietf.org/html/rfc7946#section-3
|
|
81
|
-
*/
|
|
82
|
-
export interface GeometryObject extends GeoJSONObject {
|
|
83
|
-
type: GeometryTypes;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Geometry
|
|
87
|
-
*
|
|
88
|
-
* https://tools.ietf.org/html/rfc7946#section-3
|
|
89
|
-
*/
|
|
90
|
-
export interface Geometry extends GeoJSONObject {
|
|
91
|
-
coordinates: Position | Position[] | Position[][] | Position[][][];
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Point Geometry Object
|
|
95
|
-
*
|
|
96
|
-
* https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
97
|
-
*/
|
|
98
|
-
export interface Point extends GeometryObject {
|
|
99
|
-
type: "Point";
|
|
100
|
-
coordinates: Position;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* MultiPoint Geometry Object
|
|
104
|
-
*
|
|
105
|
-
* https://tools.ietf.org/html/rfc7946#section-3.1.3
|
|
106
|
-
*/
|
|
107
|
-
export interface MultiPoint extends GeometryObject {
|
|
108
|
-
type: "MultiPoint";
|
|
109
|
-
coordinates: Position[];
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* LineString Geometry Object
|
|
113
|
-
*
|
|
114
|
-
* https://tools.ietf.org/html/rfc7946#section-3.1.4
|
|
115
|
-
*/
|
|
116
|
-
export interface LineString extends GeometryObject {
|
|
117
|
-
type: "LineString";
|
|
118
|
-
coordinates: Position[];
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* MultiLineString Geometry Object
|
|
122
|
-
*
|
|
123
|
-
* https://tools.ietf.org/html/rfc7946#section-3.1.5
|
|
124
|
-
*/
|
|
125
|
-
export interface MultiLineString extends GeometryObject {
|
|
126
|
-
type: "MultiLineString";
|
|
127
|
-
coordinates: Position[][];
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Polygon Geometry Object
|
|
131
|
-
*
|
|
132
|
-
* https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
133
|
-
*/
|
|
134
|
-
export interface Polygon extends GeometryObject {
|
|
135
|
-
type: "Polygon";
|
|
136
|
-
coordinates: Position[][];
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* MultiPolygon Geometry Object
|
|
140
|
-
*
|
|
141
|
-
* https://tools.ietf.org/html/rfc7946#section-3.1.7
|
|
142
|
-
*/
|
|
143
|
-
export interface MultiPolygon extends GeometryObject {
|
|
144
|
-
type: "MultiPolygon";
|
|
145
|
-
coordinates: Position[][][];
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* GeometryCollection
|
|
149
|
-
*
|
|
150
|
-
* https://tools.ietf.org/html/rfc7946#section-3.1.8
|
|
151
|
-
*
|
|
152
|
-
* A GeoJSON object with type "GeometryCollection" is a Geometry object.
|
|
153
|
-
* A GeometryCollection has a member with the name "geometries".
|
|
154
|
-
* The value of "geometries" is an array. Each element of this array is a GeoJSON Geometry object.
|
|
155
|
-
* It is possible for this array to be empty.
|
|
156
|
-
*/
|
|
157
|
-
export interface GeometryCollection extends GeometryObject {
|
|
158
|
-
type: "GeometryCollection";
|
|
159
|
-
geometries: Array<Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon>;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Feature
|
|
163
|
-
*
|
|
164
|
-
* https://tools.ietf.org/html/rfc7946#section-3.2
|
|
165
|
-
* A Feature object represents a spatially bounded thing.
|
|
166
|
-
* Every Feature object is a GeoJSON object no matter where it occurs in a GeoJSON text.
|
|
167
|
-
*/
|
|
168
|
-
export interface Feature<G = Geometry | GeometryCollection, P = Properties> extends GeoJSONObject {
|
|
169
|
-
type: "Feature";
|
|
170
|
-
geometry: G;
|
|
171
|
-
/**
|
|
172
|
-
* A value that uniquely identifies this feature in a
|
|
173
|
-
* https://tools.ietf.org/html/rfc7946#section-3.2.
|
|
174
|
-
*/
|
|
175
|
-
id?: Id;
|
|
176
|
-
/**
|
|
177
|
-
* Properties associated with this feature.
|
|
178
|
-
*/
|
|
179
|
-
properties: P;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Feature Collection
|
|
183
|
-
*
|
|
184
|
-
* https://tools.ietf.org/html/rfc7946#section-3.3
|
|
185
|
-
* A GeoJSON object with the type "FeatureCollection" is a FeatureCollection object.
|
|
186
|
-
* A FeatureCollection object has a member with the name "features".
|
|
187
|
-
* The value of "features" is a JSON array. Each element of the array is a Feature object as defined above.
|
|
188
|
-
* It is possible for this array to be empty.
|
|
189
|
-
*/
|
|
190
|
-
export interface FeatureCollection<G = Geometry | GeometryCollection, P = Properties> extends GeoJSONObject {
|
|
191
|
-
type: "FeatureCollection";
|
|
192
|
-
features: Array<Feature<G, P>>;
|
|
193
|
-
}
|
|
10
|
+
export declare type Id = string | number;
|
package/dist/js/lib/geojson.js
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Type definitions for geojson 7946.0
|
|
3
|
-
// Project: https://geojson.org/
|
|
4
|
-
// Definitions by: Jacob Bruun <https://github.com/cobster>
|
|
5
|
-
// Arne Schubert <https://github.com/atd-schubert>
|
|
6
|
-
// Jeff Jacobson <https://github.com/JeffJacobson>
|
|
7
|
-
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
8
|
-
// TypeScript Version: 2.3
|
|
9
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.1",
|
|
4
4
|
"description": "turf helpers module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"exports": {
|
|
34
34
|
"./package.json": "./package.json",
|
|
35
35
|
".": {
|
|
36
|
+
"types": "./dist/js/index.d.ts",
|
|
36
37
|
"import": "./dist/es/index.js",
|
|
37
38
|
"require": "./dist/js/index.js"
|
|
38
39
|
}
|
|
@@ -43,23 +44,26 @@
|
|
|
43
44
|
"dist"
|
|
44
45
|
],
|
|
45
46
|
"scripts": {
|
|
46
|
-
"bench": "
|
|
47
|
+
"bench": "tsx bench.js",
|
|
47
48
|
"build": "npm-run-all build:*",
|
|
48
49
|
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
|
|
49
50
|
"build:js": "tsc",
|
|
50
|
-
"docs": "
|
|
51
|
+
"docs": "tsx ../../scripts/generate-readmes",
|
|
51
52
|
"test": "npm-run-all test:*",
|
|
52
|
-
"test:tape": "
|
|
53
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
53
|
+
"test:tape": "tsx test.js",
|
|
54
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@types/tape": "*",
|
|
57
58
|
"benchmark": "*",
|
|
58
59
|
"npm-run-all": "*",
|
|
59
60
|
"tape": "*",
|
|
60
|
-
"ts-node": "*",
|
|
61
61
|
"tslint": "*",
|
|
62
|
+
"tsx": "*",
|
|
62
63
|
"typescript": "*"
|
|
63
64
|
},
|
|
64
|
-
"
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"tslib": "^2.3.0"
|
|
67
|
+
},
|
|
68
|
+
"gitHead": "cf7a0c507b017ca066acffd0ce23bda5b393fb5a"
|
|
65
69
|
}
|