@turf/helpers 6.5.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 +6 -3
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
|
|
@@ -98,9 +78,8 @@ exports.areaFactors = {
|
|
|
98
78
|
*
|
|
99
79
|
* //=feature
|
|
100
80
|
*/
|
|
101
|
-
function feature(geom, properties, options) {
|
|
102
|
-
|
|
103
|
-
var feat = { type: "Feature" };
|
|
81
|
+
function feature(geom, properties, options = {}) {
|
|
82
|
+
const feat = { type: "Feature" };
|
|
104
83
|
if (options.id === 0 || options.id) {
|
|
105
84
|
feat.id = options.id;
|
|
106
85
|
}
|
|
@@ -127,8 +106,7 @@ exports.feature = feature;
|
|
|
127
106
|
* var geometry = turf.geometry(type, coordinates);
|
|
128
107
|
* // => geometry
|
|
129
108
|
*/
|
|
130
|
-
function geometry(type, coordinates, _options) {
|
|
131
|
-
if (_options === void 0) { _options = {}; }
|
|
109
|
+
function geometry(type, coordinates, _options = {}) {
|
|
132
110
|
switch (type) {
|
|
133
111
|
case "Point":
|
|
134
112
|
return point(coordinates).geometry;
|
|
@@ -162,8 +140,7 @@ exports.geometry = geometry;
|
|
|
162
140
|
*
|
|
163
141
|
* //=point
|
|
164
142
|
*/
|
|
165
|
-
function point(coordinates, properties, options) {
|
|
166
|
-
if (options === void 0) { options = {}; }
|
|
143
|
+
function point(coordinates, properties, options = {}) {
|
|
167
144
|
if (!coordinates) {
|
|
168
145
|
throw new Error("coordinates is required");
|
|
169
146
|
}
|
|
@@ -176,9 +153,9 @@ function point(coordinates, properties, options) {
|
|
|
176
153
|
if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
|
|
177
154
|
throw new Error("coordinates must contain numbers");
|
|
178
155
|
}
|
|
179
|
-
|
|
156
|
+
const geom = {
|
|
180
157
|
type: "Point",
|
|
181
|
-
coordinates
|
|
158
|
+
coordinates,
|
|
182
159
|
};
|
|
183
160
|
return feature(geom, properties, options);
|
|
184
161
|
}
|
|
@@ -203,9 +180,8 @@ exports.point = point;
|
|
|
203
180
|
*
|
|
204
181
|
* //=points
|
|
205
182
|
*/
|
|
206
|
-
function points(coordinates, properties, options) {
|
|
207
|
-
|
|
208
|
-
return featureCollection(coordinates.map(function (coords) {
|
|
183
|
+
function points(coordinates, properties, options = {}) {
|
|
184
|
+
return featureCollection(coordinates.map((coords) => {
|
|
209
185
|
return point(coords, properties);
|
|
210
186
|
}), options);
|
|
211
187
|
}
|
|
@@ -225,23 +201,24 @@ exports.points = points;
|
|
|
225
201
|
*
|
|
226
202
|
* //=polygon
|
|
227
203
|
*/
|
|
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];
|
|
204
|
+
function polygon(coordinates, properties, options = {}) {
|
|
205
|
+
for (const ring of coordinates) {
|
|
232
206
|
if (ring.length < 4) {
|
|
233
207
|
throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
|
|
234
208
|
}
|
|
235
|
-
|
|
209
|
+
if (ring[ring.length - 1].length !== ring[0].length) {
|
|
210
|
+
throw new Error("First and last Position are not equivalent.");
|
|
211
|
+
}
|
|
212
|
+
for (let j = 0; j < ring[ring.length - 1].length; j++) {
|
|
236
213
|
// Check if first point of Polygon contains two numbers
|
|
237
214
|
if (ring[ring.length - 1][j] !== ring[0][j]) {
|
|
238
215
|
throw new Error("First and last Position are not equivalent.");
|
|
239
216
|
}
|
|
240
217
|
}
|
|
241
218
|
}
|
|
242
|
-
|
|
219
|
+
const geom = {
|
|
243
220
|
type: "Polygon",
|
|
244
|
-
coordinates
|
|
221
|
+
coordinates,
|
|
245
222
|
};
|
|
246
223
|
return feature(geom, properties, options);
|
|
247
224
|
}
|
|
@@ -264,9 +241,8 @@ exports.polygon = polygon;
|
|
|
264
241
|
*
|
|
265
242
|
* //=polygons
|
|
266
243
|
*/
|
|
267
|
-
function polygons(coordinates, properties, options) {
|
|
268
|
-
|
|
269
|
-
return featureCollection(coordinates.map(function (coords) {
|
|
244
|
+
function polygons(coordinates, properties, options = {}) {
|
|
245
|
+
return featureCollection(coordinates.map((coords) => {
|
|
270
246
|
return polygon(coords, properties);
|
|
271
247
|
}), options);
|
|
272
248
|
}
|
|
@@ -288,14 +264,13 @@ exports.polygons = polygons;
|
|
|
288
264
|
* //=linestring1
|
|
289
265
|
* //=linestring2
|
|
290
266
|
*/
|
|
291
|
-
function lineString(coordinates, properties, options) {
|
|
292
|
-
if (options === void 0) { options = {}; }
|
|
267
|
+
function lineString(coordinates, properties, options = {}) {
|
|
293
268
|
if (coordinates.length < 2) {
|
|
294
269
|
throw new Error("coordinates must be an array of two or more positions");
|
|
295
270
|
}
|
|
296
|
-
|
|
271
|
+
const geom = {
|
|
297
272
|
type: "LineString",
|
|
298
|
-
coordinates
|
|
273
|
+
coordinates,
|
|
299
274
|
};
|
|
300
275
|
return feature(geom, properties, options);
|
|
301
276
|
}
|
|
@@ -319,9 +294,8 @@ exports.lineString = lineString;
|
|
|
319
294
|
*
|
|
320
295
|
* //=linestrings
|
|
321
296
|
*/
|
|
322
|
-
function lineStrings(coordinates, properties, options) {
|
|
323
|
-
|
|
324
|
-
return featureCollection(coordinates.map(function (coords) {
|
|
297
|
+
function lineStrings(coordinates, properties, options = {}) {
|
|
298
|
+
return featureCollection(coordinates.map((coords) => {
|
|
325
299
|
return lineString(coords, properties);
|
|
326
300
|
}), options);
|
|
327
301
|
}
|
|
@@ -348,9 +322,8 @@ exports.lineStrings = lineStrings;
|
|
|
348
322
|
*
|
|
349
323
|
* //=collection
|
|
350
324
|
*/
|
|
351
|
-
function featureCollection(features, options) {
|
|
352
|
-
|
|
353
|
-
var fc = { type: "FeatureCollection" };
|
|
325
|
+
function featureCollection(features, options = {}) {
|
|
326
|
+
const fc = { type: "FeatureCollection" };
|
|
354
327
|
if (options.id) {
|
|
355
328
|
fc.id = options.id;
|
|
356
329
|
}
|
|
@@ -378,11 +351,10 @@ exports.featureCollection = featureCollection;
|
|
|
378
351
|
*
|
|
379
352
|
* //=multiLine
|
|
380
353
|
*/
|
|
381
|
-
function multiLineString(coordinates, properties, options) {
|
|
382
|
-
|
|
383
|
-
var geom = {
|
|
354
|
+
function multiLineString(coordinates, properties, options = {}) {
|
|
355
|
+
const geom = {
|
|
384
356
|
type: "MultiLineString",
|
|
385
|
-
coordinates
|
|
357
|
+
coordinates,
|
|
386
358
|
};
|
|
387
359
|
return feature(geom, properties, options);
|
|
388
360
|
}
|
|
@@ -404,11 +376,10 @@ exports.multiLineString = multiLineString;
|
|
|
404
376
|
*
|
|
405
377
|
* //=multiPt
|
|
406
378
|
*/
|
|
407
|
-
function multiPoint(coordinates, properties, options) {
|
|
408
|
-
|
|
409
|
-
var geom = {
|
|
379
|
+
function multiPoint(coordinates, properties, options = {}) {
|
|
380
|
+
const geom = {
|
|
410
381
|
type: "MultiPoint",
|
|
411
|
-
coordinates
|
|
382
|
+
coordinates,
|
|
412
383
|
};
|
|
413
384
|
return feature(geom, properties, options);
|
|
414
385
|
}
|
|
@@ -431,11 +402,10 @@ exports.multiPoint = multiPoint;
|
|
|
431
402
|
* //=multiPoly
|
|
432
403
|
*
|
|
433
404
|
*/
|
|
434
|
-
function multiPolygon(coordinates, properties, options) {
|
|
435
|
-
|
|
436
|
-
var geom = {
|
|
405
|
+
function multiPolygon(coordinates, properties, options = {}) {
|
|
406
|
+
const geom = {
|
|
437
407
|
type: "MultiPolygon",
|
|
438
|
-
coordinates
|
|
408
|
+
coordinates,
|
|
439
409
|
};
|
|
440
410
|
return feature(geom, properties, options);
|
|
441
411
|
}
|
|
@@ -458,11 +428,10 @@ exports.multiPolygon = multiPolygon;
|
|
|
458
428
|
*
|
|
459
429
|
* // => collection
|
|
460
430
|
*/
|
|
461
|
-
function geometryCollection(geometries, properties, options) {
|
|
462
|
-
|
|
463
|
-
var geom = {
|
|
431
|
+
function geometryCollection(geometries, properties, options = {}) {
|
|
432
|
+
const geom = {
|
|
464
433
|
type: "GeometryCollection",
|
|
465
|
-
geometries
|
|
434
|
+
geometries,
|
|
466
435
|
};
|
|
467
436
|
return feature(geom, properties, options);
|
|
468
437
|
}
|
|
@@ -480,12 +449,11 @@ exports.geometryCollection = geometryCollection;
|
|
|
480
449
|
* turf.round(120.4321, 2)
|
|
481
450
|
* //=120.43
|
|
482
451
|
*/
|
|
483
|
-
function round(num, precision) {
|
|
484
|
-
if (precision === void 0) { precision = 0; }
|
|
452
|
+
function round(num, precision = 0) {
|
|
485
453
|
if (precision && !(precision >= 0)) {
|
|
486
454
|
throw new Error("precision must be a positive number");
|
|
487
455
|
}
|
|
488
|
-
|
|
456
|
+
const multiplier = Math.pow(10, precision || 0);
|
|
489
457
|
return Math.round(num * multiplier) / multiplier;
|
|
490
458
|
}
|
|
491
459
|
exports.round = round;
|
|
@@ -499,9 +467,8 @@ exports.round = round;
|
|
|
499
467
|
* meters, kilometres, kilometers.
|
|
500
468
|
* @returns {number} distance
|
|
501
469
|
*/
|
|
502
|
-
function radiansToLength(radians, units) {
|
|
503
|
-
|
|
504
|
-
var factor = exports.factors[units];
|
|
470
|
+
function radiansToLength(radians, units = "kilometers") {
|
|
471
|
+
const factor = exports.factors[units];
|
|
505
472
|
if (!factor) {
|
|
506
473
|
throw new Error(units + " units is invalid");
|
|
507
474
|
}
|
|
@@ -518,9 +485,8 @@ exports.radiansToLength = radiansToLength;
|
|
|
518
485
|
* meters, kilometres, kilometers.
|
|
519
486
|
* @returns {number} radians
|
|
520
487
|
*/
|
|
521
|
-
function lengthToRadians(distance, units) {
|
|
522
|
-
|
|
523
|
-
var factor = exports.factors[units];
|
|
488
|
+
function lengthToRadians(distance, units = "kilometers") {
|
|
489
|
+
const factor = exports.factors[units];
|
|
524
490
|
if (!factor) {
|
|
525
491
|
throw new Error(units + " units is invalid");
|
|
526
492
|
}
|
|
@@ -550,7 +516,7 @@ exports.lengthToDegrees = lengthToDegrees;
|
|
|
550
516
|
* @returns {number} angle between 0 and 360 degrees
|
|
551
517
|
*/
|
|
552
518
|
function bearingToAzimuth(bearing) {
|
|
553
|
-
|
|
519
|
+
let angle = bearing % 360;
|
|
554
520
|
if (angle < 0) {
|
|
555
521
|
angle += 360;
|
|
556
522
|
}
|
|
@@ -565,7 +531,7 @@ exports.bearingToAzimuth = bearingToAzimuth;
|
|
|
565
531
|
* @returns {number} degrees between 0 and 360 degrees
|
|
566
532
|
*/
|
|
567
533
|
function radiansToDegrees(radians) {
|
|
568
|
-
|
|
534
|
+
const degrees = radians % (2 * Math.PI);
|
|
569
535
|
return (degrees * 180) / Math.PI;
|
|
570
536
|
}
|
|
571
537
|
exports.radiansToDegrees = radiansToDegrees;
|
|
@@ -577,7 +543,7 @@ exports.radiansToDegrees = radiansToDegrees;
|
|
|
577
543
|
* @returns {number} angle in radians
|
|
578
544
|
*/
|
|
579
545
|
function degreesToRadians(degrees) {
|
|
580
|
-
|
|
546
|
+
const radians = degrees % 360;
|
|
581
547
|
return (radians * Math.PI) / 180;
|
|
582
548
|
}
|
|
583
549
|
exports.degreesToRadians = degreesToRadians;
|
|
@@ -590,9 +556,7 @@ exports.degreesToRadians = degreesToRadians;
|
|
|
590
556
|
* @param {Units} [finalUnit="kilometers"] returned unit
|
|
591
557
|
* @returns {number} the converted length
|
|
592
558
|
*/
|
|
593
|
-
function convertLength(length, originalUnit, finalUnit) {
|
|
594
|
-
if (originalUnit === void 0) { originalUnit = "kilometers"; }
|
|
595
|
-
if (finalUnit === void 0) { finalUnit = "kilometers"; }
|
|
559
|
+
function convertLength(length, originalUnit = "kilometers", finalUnit = "kilometers") {
|
|
596
560
|
if (!(length >= 0)) {
|
|
597
561
|
throw new Error("length must be a positive number");
|
|
598
562
|
}
|
|
@@ -607,17 +571,15 @@ exports.convertLength = convertLength;
|
|
|
607
571
|
* @param {Units} [finalUnit="kilometers"] returned unit
|
|
608
572
|
* @returns {number} the converted area
|
|
609
573
|
*/
|
|
610
|
-
function convertArea(area, originalUnit, finalUnit) {
|
|
611
|
-
if (originalUnit === void 0) { originalUnit = "meters"; }
|
|
612
|
-
if (finalUnit === void 0) { finalUnit = "kilometers"; }
|
|
574
|
+
function convertArea(area, originalUnit = "meters", finalUnit = "kilometers") {
|
|
613
575
|
if (!(area >= 0)) {
|
|
614
576
|
throw new Error("area must be a positive number");
|
|
615
577
|
}
|
|
616
|
-
|
|
578
|
+
const startFactor = exports.areaFactors[originalUnit];
|
|
617
579
|
if (!startFactor) {
|
|
618
580
|
throw new Error("invalid original units");
|
|
619
581
|
}
|
|
620
|
-
|
|
582
|
+
const finalFactor = exports.areaFactors[finalUnit];
|
|
621
583
|
if (!finalFactor) {
|
|
622
584
|
throw new Error("invalid final units");
|
|
623
585
|
}
|
|
@@ -643,7 +605,7 @@ exports.isNumber = isNumber;
|
|
|
643
605
|
* isObject
|
|
644
606
|
*
|
|
645
607
|
* @param {*} input variable to validate
|
|
646
|
-
* @returns {boolean} true/false
|
|
608
|
+
* @returns {boolean} true/false, including false for Arrays and Functions
|
|
647
609
|
* @example
|
|
648
610
|
* turf.isObject({elevation: 10})
|
|
649
611
|
* //=true
|
|
@@ -651,7 +613,7 @@ exports.isNumber = isNumber;
|
|
|
651
613
|
* //=false
|
|
652
614
|
*/
|
|
653
615
|
function isObject(input) {
|
|
654
|
-
return
|
|
616
|
+
return input !== null && typeof input === "object" && !Array.isArray(input);
|
|
655
617
|
}
|
|
656
618
|
exports.isObject = isObject;
|
|
657
619
|
/**
|
|
@@ -660,7 +622,7 @@ exports.isObject = isObject;
|
|
|
660
622
|
* @private
|
|
661
623
|
* @param {Array<number>} bbox BBox to validate
|
|
662
624
|
* @returns {void}
|
|
663
|
-
* @throws Error if BBox is not valid
|
|
625
|
+
* @throws {Error} if BBox is not valid
|
|
664
626
|
* @example
|
|
665
627
|
* validateBBox([-180, -40, 110, 50])
|
|
666
628
|
* //=OK
|
|
@@ -685,7 +647,7 @@ function validateBBox(bbox) {
|
|
|
685
647
|
if (bbox.length !== 4 && bbox.length !== 6) {
|
|
686
648
|
throw new Error("bbox must be an Array of 4 or 6 numbers");
|
|
687
649
|
}
|
|
688
|
-
bbox.forEach(
|
|
650
|
+
bbox.forEach((num) => {
|
|
689
651
|
if (!isNumber(num)) {
|
|
690
652
|
throw new Error("bbox must only contain numbers");
|
|
691
653
|
}
|
|
@@ -698,7 +660,7 @@ exports.validateBBox = validateBBox;
|
|
|
698
660
|
* @private
|
|
699
661
|
* @param {string|number} id Id to validate
|
|
700
662
|
* @returns {void}
|
|
701
|
-
* @throws Error if Id is not valid
|
|
663
|
+
* @throws {Error} if Id is not valid
|
|
702
664
|
* @example
|
|
703
665
|
* validateId([-180, -40, 110, 50])
|
|
704
666
|
* //=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.0",
|
|
4
4
|
"description": "turf helpers module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"docs": "node ../../scripts/generate-readmes",
|
|
51
51
|
"test": "npm-run-all test:*",
|
|
52
52
|
"test:tape": "ts-node -r esm test.js",
|
|
53
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
53
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/tape": "*",
|
|
@@ -61,5 +61,8 @@
|
|
|
61
61
|
"tslint": "*",
|
|
62
62
|
"typescript": "*"
|
|
63
63
|
},
|
|
64
|
-
"
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"tslib": "^2.3.0"
|
|
66
|
+
},
|
|
67
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
65
68
|
}
|