@turf/helpers 6.2.0-alpha.1 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -453,7 +453,7 @@ Returns **[number][6]** the converted length
453
453
  ## convertArea
454
454
 
455
455
  Converts a area to the requested unit.
456
- Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches
456
+ Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares
457
457
 
458
458
  **Parameters**
459
459
 
package/dist/es/index.js CHANGED
@@ -19,7 +19,7 @@ export var factors = {
19
19
  centimetres: earthRadius * 100,
20
20
  degrees: earthRadius / 111325,
21
21
  feet: earthRadius * 3.28084,
22
- inches: earthRadius * 39.370,
22
+ inches: earthRadius * 39.37,
23
23
  kilometers: earthRadius / 1000,
24
24
  kilometres: earthRadius / 1000,
25
25
  meters: earthRadius,
@@ -42,7 +42,7 @@ export var unitsFactors = {
42
42
  centimetres: 100,
43
43
  degrees: 1 / 111325,
44
44
  feet: 3.28084,
45
- inches: 39.370,
45
+ inches: 39.37,
46
46
  kilometers: 1 / 1000,
47
47
  kilometres: 1 / 1000,
48
48
  meters: 1,
@@ -65,6 +65,7 @@ export var areaFactors = {
65
65
  centimeters: 10000,
66
66
  centimetres: 10000,
67
67
  feet: 10.763910417,
68
+ hectares: 0.0001,
68
69
  inches: 1550.003100006,
69
70
  kilometers: 0.000001,
70
71
  kilometres: 0.000001,
@@ -123,16 +124,23 @@ export function feature(geom, properties, options) {
123
124
  * var geometry = turf.geometry(type, coordinates);
124
125
  * // => geometry
125
126
  */
126
- export function geometry(type, coordinates, options) {
127
- if (options === void 0) { options = {}; }
127
+ export function geometry(type, coordinates, _options) {
128
+ if (_options === void 0) { _options = {}; }
128
129
  switch (type) {
129
- case "Point": return point(coordinates).geometry;
130
- case "LineString": return lineString(coordinates).geometry;
131
- case "Polygon": return polygon(coordinates).geometry;
132
- case "MultiPoint": return multiPoint(coordinates).geometry;
133
- case "MultiLineString": return multiLineString(coordinates).geometry;
134
- case "MultiPolygon": return multiPolygon(coordinates).geometry;
135
- default: throw new Error(type + " is invalid");
130
+ case "Point":
131
+ return point(coordinates).geometry;
132
+ case "LineString":
133
+ return lineString(coordinates).geometry;
134
+ case "Polygon":
135
+ return polygon(coordinates).geometry;
136
+ case "MultiPoint":
137
+ return multiPoint(coordinates).geometry;
138
+ case "MultiLineString":
139
+ return multiLineString(coordinates).geometry;
140
+ case "MultiPolygon":
141
+ return multiPolygon(coordinates).geometry;
142
+ default:
143
+ throw new Error(type + " is invalid");
136
144
  }
137
145
  }
138
146
  /**
@@ -152,6 +160,18 @@ export function geometry(type, coordinates, options) {
152
160
  */
153
161
  export function point(coordinates, properties, options) {
154
162
  if (options === void 0) { options = {}; }
163
+ if (!coordinates) {
164
+ throw new Error("coordinates is required");
165
+ }
166
+ if (!Array.isArray(coordinates)) {
167
+ throw new Error("coordinates must be an Array");
168
+ }
169
+ if (coordinates.length < 2) {
170
+ throw new Error("coordinates must be at least 2 numbers long");
171
+ }
172
+ if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
173
+ throw new Error("coordinates must contain numbers");
174
+ }
155
175
  var geom = {
156
176
  type: "Point",
157
177
  coordinates: coordinates,
@@ -459,7 +479,7 @@ export function round(num, precision) {
459
479
  *
460
480
  * @name radiansToLength
461
481
  * @param {number} radians in radians across the sphere
462
- * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
482
+ * @param {string} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
463
483
  * meters, kilometres, kilometers.
464
484
  * @returns {number} distance
465
485
  */
@@ -477,7 +497,7 @@ export function radiansToLength(radians, units) {
477
497
  *
478
498
  * @name lengthToRadians
479
499
  * @param {number} distance in real units
480
- * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
500
+ * @param {string} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
481
501
  * meters, kilometres, kilometers.
482
502
  * @returns {number} radians
483
503
  */
@@ -495,7 +515,7 @@ export function lengthToRadians(distance, units) {
495
515
  *
496
516
  * @name lengthToDegrees
497
517
  * @param {number} distance in real units
498
- * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
518
+ * @param {string} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
499
519
  * meters, kilometres, kilometers.
500
520
  * @returns {number} degrees
501
521
  */
@@ -526,7 +546,7 @@ export function bearingToAzimuth(bearing) {
526
546
  */
527
547
  export function radiansToDegrees(radians) {
528
548
  var degrees = radians % (2 * Math.PI);
529
- return degrees * 180 / Math.PI;
549
+ return (degrees * 180) / Math.PI;
530
550
  }
531
551
  /**
532
552
  * Converts an angle in degrees to radians
@@ -537,7 +557,7 @@ export function radiansToDegrees(radians) {
537
557
  */
538
558
  export function degreesToRadians(degrees) {
539
559
  var radians = degrees % 360;
540
- return radians * Math.PI / 180;
560
+ return (radians * Math.PI) / 180;
541
561
  }
542
562
  /**
543
563
  * Converts a length to the requested unit.
@@ -558,11 +578,11 @@ export function convertLength(length, originalUnit, finalUnit) {
558
578
  }
559
579
  /**
560
580
  * Converts a area to the requested unit.
561
- * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches
581
+ * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares
562
582
  * @param {number} area to be converted
563
583
  * @param {Units} [originalUnit="meters"] of the distance
564
584
  * @param {Units} [finalUnit="kilometers"] returned unit
565
- * @returns {number} the converted distance
585
+ * @returns {number} the converted area
566
586
  */
567
587
  export function convertArea(area, originalUnit, finalUnit) {
568
588
  if (originalUnit === void 0) { originalUnit = "meters"; }
@@ -606,7 +626,7 @@ export function isNumber(num) {
606
626
  * //=false
607
627
  */
608
628
  export function isObject(input) {
609
- return (!!input) && (input.constructor === Object);
629
+ return !!input && input.constructor === Object;
610
630
  }
611
631
  /**
612
632
  * Validate BBox
@@ -674,25 +694,3 @@ export function validateId(id) {
674
694
  throw new Error("id must be a number or a string");
675
695
  }
676
696
  }
677
- // Deprecated methods
678
- export function radians2degrees() {
679
- throw new Error("method has been renamed to `radiansToDegrees`");
680
- }
681
- export function degrees2radians() {
682
- throw new Error("method has been renamed to `degreesToRadians`");
683
- }
684
- export function distanceToDegrees() {
685
- throw new Error("method has been renamed to `lengthToDegrees`");
686
- }
687
- export function distanceToRadians() {
688
- throw new Error("method has been renamed to `lengthToRadians`");
689
- }
690
- export function radiansToDistance() {
691
- throw new Error("method has been renamed to `radiansToLength`");
692
- }
693
- export function bearingToAngle() {
694
- throw new Error("method has been renamed to `bearingToAzimuth`");
695
- }
696
- export function convertDistance() {
697
- throw new Error("method has been renamed to `convertLength`");
698
- }
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -1,7 +1,7 @@
1
1
  import { BBox, CollectionTypes, Feature, FeatureCollection, GeoJSONObject, Geometries, Geometry, GeometryCollection, GeometryObject, GeometryTypes, Id, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, Position, Properties, Types } from "./lib/geojson";
2
2
  export { Id, Properties, BBox, Position, Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryObject, GeoJSONObject, GeometryCollection, Geometry, GeometryTypes, Types, CollectionTypes, Geometries, Feature, FeatureCollection, };
3
3
  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";
4
+ export declare type Units = "meters" | "millimeters" | "centimeters" | "kilometers" | "acres" | "miles" | "nauticalmiles" | "inches" | "yards" | "feet" | "radians" | "degrees" | "hectares";
5
5
  export declare type Grid = "point" | "square" | "hex" | "triangle";
6
6
  export declare type Corners = "sw" | "se" | "nw" | "ne" | "center" | "centroid";
7
7
  export declare type Lines = LineString | MultiLineString | Polygon | MultiPolygon;
@@ -80,7 +80,7 @@ export declare function feature<G = Geometry, P = Properties>(geom: G, propertie
80
80
  * var geometry = turf.geometry(type, coordinates);
81
81
  * // => geometry
82
82
  */
83
- export declare function geometry(type: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon", coordinates: any[], options?: {}): Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
83
+ export declare function geometry(type: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon", coordinates: any[], _options?: {}): Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
84
84
  /**
85
85
  * Creates a {@link Point} {@link Feature} from a Position.
86
86
  *
@@ -341,7 +341,7 @@ export declare function round(num: number, precision?: number): number;
341
341
  *
342
342
  * @name radiansToLength
343
343
  * @param {number} radians in radians across the sphere
344
- * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
344
+ * @param {string} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
345
345
  * meters, kilometres, kilometers.
346
346
  * @returns {number} distance
347
347
  */
@@ -352,7 +352,7 @@ export declare function radiansToLength(radians: number, units?: Units): number;
352
352
  *
353
353
  * @name lengthToRadians
354
354
  * @param {number} distance in real units
355
- * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
355
+ * @param {string} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
356
356
  * meters, kilometres, kilometers.
357
357
  * @returns {number} radians
358
358
  */
@@ -363,7 +363,7 @@ export declare function lengthToRadians(distance: number, units?: Units): number
363
363
  *
364
364
  * @name lengthToDegrees
365
365
  * @param {number} distance in real units
366
- * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
366
+ * @param {string} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
367
367
  * meters, kilometres, kilometers.
368
368
  * @returns {number} degrees
369
369
  */
@@ -405,11 +405,11 @@ export declare function degreesToRadians(degrees: number): number;
405
405
  export declare function convertLength(length: number, originalUnit?: Units, finalUnit?: Units): number;
406
406
  /**
407
407
  * Converts a area to the requested unit.
408
- * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches
408
+ * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares
409
409
  * @param {number} area to be converted
410
410
  * @param {Units} [originalUnit="meters"] of the distance
411
411
  * @param {Units} [finalUnit="kilometers"] returned unit
412
- * @returns {number} the converted distance
412
+ * @returns {number} the converted area
413
413
  */
414
414
  export declare function convertArea(area: number, originalUnit?: Units, finalUnit?: Units): number;
415
415
  /**
@@ -480,10 +480,3 @@ export declare function validateBBox(bbox: any): void;
480
480
  * //=Error
481
481
  */
482
482
  export declare function validateId(id: any): void;
483
- export declare function radians2degrees(): void;
484
- export declare function degrees2radians(): void;
485
- export declare function distanceToDegrees(): void;
486
- export declare function distanceToRadians(): void;
487
- export declare function radiansToDistance(): void;
488
- export declare function bearingToAngle(): void;
489
- export declare function convertDistance(): void;
package/dist/js/index.js CHANGED
@@ -21,7 +21,7 @@ exports.factors = {
21
21
  centimetres: exports.earthRadius * 100,
22
22
  degrees: exports.earthRadius / 111325,
23
23
  feet: exports.earthRadius * 3.28084,
24
- inches: exports.earthRadius * 39.370,
24
+ inches: exports.earthRadius * 39.37,
25
25
  kilometers: exports.earthRadius / 1000,
26
26
  kilometres: exports.earthRadius / 1000,
27
27
  meters: exports.earthRadius,
@@ -44,7 +44,7 @@ exports.unitsFactors = {
44
44
  centimetres: 100,
45
45
  degrees: 1 / 111325,
46
46
  feet: 3.28084,
47
- inches: 39.370,
47
+ inches: 39.37,
48
48
  kilometers: 1 / 1000,
49
49
  kilometres: 1 / 1000,
50
50
  meters: 1,
@@ -67,6 +67,7 @@ exports.areaFactors = {
67
67
  centimeters: 10000,
68
68
  centimetres: 10000,
69
69
  feet: 10.763910417,
70
+ hectares: 0.0001,
70
71
  inches: 1550.003100006,
71
72
  kilometers: 0.000001,
72
73
  kilometres: 0.000001,
@@ -126,16 +127,23 @@ exports.feature = feature;
126
127
  * var geometry = turf.geometry(type, coordinates);
127
128
  * // => geometry
128
129
  */
129
- function geometry(type, coordinates, options) {
130
- if (options === void 0) { options = {}; }
130
+ function geometry(type, coordinates, _options) {
131
+ if (_options === void 0) { _options = {}; }
131
132
  switch (type) {
132
- case "Point": return point(coordinates).geometry;
133
- case "LineString": return lineString(coordinates).geometry;
134
- case "Polygon": return polygon(coordinates).geometry;
135
- case "MultiPoint": return multiPoint(coordinates).geometry;
136
- case "MultiLineString": return multiLineString(coordinates).geometry;
137
- case "MultiPolygon": return multiPolygon(coordinates).geometry;
138
- default: throw new Error(type + " is invalid");
133
+ case "Point":
134
+ return point(coordinates).geometry;
135
+ case "LineString":
136
+ return lineString(coordinates).geometry;
137
+ case "Polygon":
138
+ return polygon(coordinates).geometry;
139
+ case "MultiPoint":
140
+ return multiPoint(coordinates).geometry;
141
+ case "MultiLineString":
142
+ return multiLineString(coordinates).geometry;
143
+ case "MultiPolygon":
144
+ return multiPolygon(coordinates).geometry;
145
+ default:
146
+ throw new Error(type + " is invalid");
139
147
  }
140
148
  }
141
149
  exports.geometry = geometry;
@@ -156,6 +164,18 @@ exports.geometry = geometry;
156
164
  */
157
165
  function point(coordinates, properties, options) {
158
166
  if (options === void 0) { options = {}; }
167
+ if (!coordinates) {
168
+ throw new Error("coordinates is required");
169
+ }
170
+ if (!Array.isArray(coordinates)) {
171
+ throw new Error("coordinates must be an Array");
172
+ }
173
+ if (coordinates.length < 2) {
174
+ throw new Error("coordinates must be at least 2 numbers long");
175
+ }
176
+ if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
177
+ throw new Error("coordinates must contain numbers");
178
+ }
159
179
  var geom = {
160
180
  type: "Point",
161
181
  coordinates: coordinates,
@@ -475,7 +495,7 @@ exports.round = round;
475
495
  *
476
496
  * @name radiansToLength
477
497
  * @param {number} radians in radians across the sphere
478
- * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
498
+ * @param {string} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
479
499
  * meters, kilometres, kilometers.
480
500
  * @returns {number} distance
481
501
  */
@@ -494,7 +514,7 @@ exports.radiansToLength = radiansToLength;
494
514
  *
495
515
  * @name lengthToRadians
496
516
  * @param {number} distance in real units
497
- * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
517
+ * @param {string} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
498
518
  * meters, kilometres, kilometers.
499
519
  * @returns {number} radians
500
520
  */
@@ -513,7 +533,7 @@ exports.lengthToRadians = lengthToRadians;
513
533
  *
514
534
  * @name lengthToDegrees
515
535
  * @param {number} distance in real units
516
- * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
536
+ * @param {string} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
517
537
  * meters, kilometres, kilometers.
518
538
  * @returns {number} degrees
519
539
  */
@@ -546,7 +566,7 @@ exports.bearingToAzimuth = bearingToAzimuth;
546
566
  */
547
567
  function radiansToDegrees(radians) {
548
568
  var degrees = radians % (2 * Math.PI);
549
- return degrees * 180 / Math.PI;
569
+ return (degrees * 180) / Math.PI;
550
570
  }
551
571
  exports.radiansToDegrees = radiansToDegrees;
552
572
  /**
@@ -558,7 +578,7 @@ exports.radiansToDegrees = radiansToDegrees;
558
578
  */
559
579
  function degreesToRadians(degrees) {
560
580
  var radians = degrees % 360;
561
- return radians * Math.PI / 180;
581
+ return (radians * Math.PI) / 180;
562
582
  }
563
583
  exports.degreesToRadians = degreesToRadians;
564
584
  /**
@@ -581,11 +601,11 @@ function convertLength(length, originalUnit, finalUnit) {
581
601
  exports.convertLength = convertLength;
582
602
  /**
583
603
  * Converts a area to the requested unit.
584
- * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches
604
+ * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares
585
605
  * @param {number} area to be converted
586
606
  * @param {Units} [originalUnit="meters"] of the distance
587
607
  * @param {Units} [finalUnit="kilometers"] returned unit
588
- * @returns {number} the converted distance
608
+ * @returns {number} the converted area
589
609
  */
590
610
  function convertArea(area, originalUnit, finalUnit) {
591
611
  if (originalUnit === void 0) { originalUnit = "meters"; }
@@ -631,7 +651,7 @@ exports.isNumber = isNumber;
631
651
  * //=false
632
652
  */
633
653
  function isObject(input) {
634
- return (!!input) && (input.constructor === Object);
654
+ return !!input && input.constructor === Object;
635
655
  }
636
656
  exports.isObject = isObject;
637
657
  /**
@@ -702,32 +722,3 @@ function validateId(id) {
702
722
  }
703
723
  }
704
724
  exports.validateId = validateId;
705
- // Deprecated methods
706
- function radians2degrees() {
707
- throw new Error("method has been renamed to `radiansToDegrees`");
708
- }
709
- exports.radians2degrees = radians2degrees;
710
- function degrees2radians() {
711
- throw new Error("method has been renamed to `degreesToRadians`");
712
- }
713
- exports.degrees2radians = degrees2radians;
714
- function distanceToDegrees() {
715
- throw new Error("method has been renamed to `lengthToDegrees`");
716
- }
717
- exports.distanceToDegrees = distanceToDegrees;
718
- function distanceToRadians() {
719
- throw new Error("method has been renamed to `lengthToRadians`");
720
- }
721
- exports.distanceToRadians = distanceToRadians;
722
- function radiansToDistance() {
723
- throw new Error("method has been renamed to `radiansToLength`");
724
- }
725
- exports.radiansToDistance = radiansToDistance;
726
- function bearingToAngle() {
727
- throw new Error("method has been renamed to `bearingToAzimuth`");
728
- }
729
- exports.bearingToAngle = bearingToAngle;
730
- function convertDistance() {
731
- throw new Error("method has been renamed to `convertLength`");
732
- }
733
- exports.convertDistance = convertDistance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/helpers",
3
- "version": "6.2.0-alpha.1",
3
+ "version": "6.3.0",
4
4
  "description": "turf helpers module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -29,28 +29,36 @@
29
29
  ],
30
30
  "main": "dist/js/index.js",
31
31
  "module": "dist/es/index.js",
32
+ "exports": {
33
+ "./package.json": "./package.json",
34
+ ".": {
35
+ "import": "./dist/es/index.js",
36
+ "require": "./dist/js/index.js"
37
+ }
38
+ },
32
39
  "types": "dist/js/index.d.ts",
33
40
  "sideEffects": false,
34
41
  "files": [
35
42
  "dist"
36
43
  ],
37
44
  "scripts": {
38
- "bench": "npm-run-all prepare bench:run",
39
- "bench:run": "node bench.js",
45
+ "bench": "ts-node bench.js",
46
+ "build": "npm-run-all build:*",
47
+ "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
48
+ "build:js": "tsc",
40
49
  "docs": "node ../../scripts/generate-readmes",
41
- "prepare": "npm-run-all prepare:*",
42
- "prepare:es": "tsc --outDir dist/es --module esnext --declaration false",
43
- "prepare:js": "tsc",
44
- "test": "npm-run-all prepare test:*",
45
- "test:tape": "node -r esm test.js",
46
- "test:types": "tsc --noEmit types.ts"
50
+ "test": "npm-run-all test:*",
51
+ "test:tape": "ts-node -r esm test.js",
52
+ "test:types": "tsc --esModuleInterop --noEmit types.ts"
47
53
  },
48
54
  "devDependencies": {
49
55
  "@types/tape": "*",
50
56
  "benchmark": "*",
57
+ "npm-run-all": "*",
51
58
  "tape": "*",
59
+ "ts-node": "*",
52
60
  "tslint": "*",
53
61
  "typescript": "*"
54
62
  },
55
- "gitHead": "fc519c045a8931c1e14eab9160a7e28391f8da02"
63
+ "gitHead": "57c8877e1e2d67effc2cdd23385c02b2a6615a49"
56
64
  }
@@ -1,489 +0,0 @@
1
- import { BBox, CollectionTypes, Feature, FeatureCollection, GeoJSONObject, Geometries, Geometry, GeometryCollection, GeometryObject, GeometryTypes, Id, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, Position, Properties, Types } from "./lib/geojson";
2
- export { Id, Properties, BBox, Position, Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryObject, GeoJSONObject, GeometryCollection, Geometry, GeometryTypes, Types, CollectionTypes, Geometries, Feature, FeatureCollection, };
3
- 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";
5
- export declare type Grid = "point" | "square" | "hex" | "triangle";
6
- export declare type Corners = "sw" | "se" | "nw" | "ne" | "center" | "centroid";
7
- export declare type Lines = LineString | MultiLineString | Polygon | MultiPolygon;
8
- export declare type AllGeoJSON = Feature | FeatureCollection | Geometry | GeometryCollection;
9
- /**
10
- * @module helpers
11
- */
12
- /**
13
- * Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
14
- *
15
- * @memberof helpers
16
- * @type {number}
17
- */
18
- export declare let earthRadius: number;
19
- /**
20
- * Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
21
- *
22
- * @memberof helpers
23
- * @type {Object}
24
- */
25
- export declare let factors: {
26
- [key: string]: number;
27
- };
28
- /**
29
- * Units of measurement factors based on 1 meter.
30
- *
31
- * @memberof helpers
32
- * @type {Object}
33
- */
34
- export declare let unitsFactors: {
35
- [key: string]: number;
36
- };
37
- /**
38
- * Area of measurement factors based on 1 square meter.
39
- *
40
- * @memberof helpers
41
- * @type {Object}
42
- */
43
- export declare let areaFactors: any;
44
- /**
45
- * Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
46
- *
47
- * @name feature
48
- * @param {Geometry} geometry input geometry
49
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
50
- * @param {Object} [options={}] Optional Parameters
51
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
52
- * @param {string|number} [options.id] Identifier associated with the Feature
53
- * @returns {Feature} a GeoJSON Feature
54
- * @example
55
- * var geometry = {
56
- * "type": "Point",
57
- * "coordinates": [110, 50]
58
- * };
59
- *
60
- * var feature = turf.feature(geometry);
61
- *
62
- * //=feature
63
- */
64
- export declare function feature<G = Geometry, P = Properties>(geom: G, properties?: P, options?: {
65
- bbox?: BBox;
66
- id?: Id;
67
- }): Feature<G, P>;
68
- /**
69
- * Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.
70
- * For GeometryCollection type use `helpers.geometryCollection`
71
- *
72
- * @name geometry
73
- * @param {string} type Geometry Type
74
- * @param {Array<any>} coordinates Coordinates
75
- * @param {Object} [options={}] Optional Parameters
76
- * @returns {Geometry} a GeoJSON Geometry
77
- * @example
78
- * var type = "Point";
79
- * var coordinates = [110, 50];
80
- * var geometry = turf.geometry(type, coordinates);
81
- * // => geometry
82
- */
83
- export declare function geometry(type: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon", coordinates: any[], options?: {}): Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
84
- /**
85
- * Creates a {@link Point} {@link Feature} from a Position.
86
- *
87
- * @name point
88
- * @param {Array<number>} coordinates longitude, latitude position (each in decimal degrees)
89
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
90
- * @param {Object} [options={}] Optional Parameters
91
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
92
- * @param {string|number} [options.id] Identifier associated with the Feature
93
- * @returns {Feature<Point>} a Point feature
94
- * @example
95
- * var point = turf.point([-75.343, 39.984]);
96
- *
97
- * //=point
98
- */
99
- export declare function point<P = Properties>(coordinates: Position, properties?: P, options?: {
100
- bbox?: BBox;
101
- id?: Id;
102
- }): Feature<Point, P>;
103
- /**
104
- * Creates a {@link Point} {@link FeatureCollection} from an Array of Point coordinates.
105
- *
106
- * @name points
107
- * @param {Array<Array<number>>} coordinates an array of Points
108
- * @param {Object} [properties={}] Translate these properties to each Feature
109
- * @param {Object} [options={}] Optional Parameters
110
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north]
111
- * associated with the FeatureCollection
112
- * @param {string|number} [options.id] Identifier associated with the FeatureCollection
113
- * @returns {FeatureCollection<Point>} Point Feature
114
- * @example
115
- * var points = turf.points([
116
- * [-75, 39],
117
- * [-80, 45],
118
- * [-78, 50]
119
- * ]);
120
- *
121
- * //=points
122
- */
123
- export declare function points<P = Properties>(coordinates: Position[], properties?: P, options?: {
124
- bbox?: BBox;
125
- id?: Id;
126
- }): FeatureCollection<Point, P>;
127
- /**
128
- * Creates a {@link Polygon} {@link Feature} from an Array of LinearRings.
129
- *
130
- * @name polygon
131
- * @param {Array<Array<Array<number>>>} coordinates an array of LinearRings
132
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
133
- * @param {Object} [options={}] Optional Parameters
134
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
135
- * @param {string|number} [options.id] Identifier associated with the Feature
136
- * @returns {Feature<Polygon>} Polygon Feature
137
- * @example
138
- * var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], { name: 'poly1' });
139
- *
140
- * //=polygon
141
- */
142
- export declare function polygon<P = Properties>(coordinates: Position[][], properties?: P, options?: {
143
- bbox?: BBox;
144
- id?: Id;
145
- }): Feature<Polygon, P>;
146
- /**
147
- * Creates a {@link Polygon} {@link FeatureCollection} from an Array of Polygon coordinates.
148
- *
149
- * @name polygons
150
- * @param {Array<Array<Array<Array<number>>>>} coordinates an array of Polygon coordinates
151
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
152
- * @param {Object} [options={}] Optional Parameters
153
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
154
- * @param {string|number} [options.id] Identifier associated with the FeatureCollection
155
- * @returns {FeatureCollection<Polygon>} Polygon FeatureCollection
156
- * @example
157
- * var polygons = turf.polygons([
158
- * [[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]],
159
- * [[[-15, 42], [-14, 46], [-12, 41], [-17, 44], [-15, 42]]],
160
- * ]);
161
- *
162
- * //=polygons
163
- */
164
- export declare function polygons<P = Properties>(coordinates: Position[][][], properties?: P, options?: {
165
- bbox?: BBox;
166
- id?: Id;
167
- }): FeatureCollection<Polygon, P>;
168
- /**
169
- * Creates a {@link LineString} {@link Feature} from an Array of Positions.
170
- *
171
- * @name lineString
172
- * @param {Array<Array<number>>} coordinates an array of Positions
173
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
174
- * @param {Object} [options={}] Optional Parameters
175
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
176
- * @param {string|number} [options.id] Identifier associated with the Feature
177
- * @returns {Feature<LineString>} LineString Feature
178
- * @example
179
- * var linestring1 = turf.lineString([[-24, 63], [-23, 60], [-25, 65], [-20, 69]], {name: 'line 1'});
180
- * var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]], {name: 'line 2'});
181
- *
182
- * //=linestring1
183
- * //=linestring2
184
- */
185
- export declare function lineString<P = Properties>(coordinates: Position[], properties?: P, options?: {
186
- bbox?: BBox;
187
- id?: Id;
188
- }): Feature<LineString, P>;
189
- /**
190
- * Creates a {@link LineString} {@link FeatureCollection} from an Array of LineString coordinates.
191
- *
192
- * @name lineStrings
193
- * @param {Array<Array<Array<number>>>} coordinates an array of LinearRings
194
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
195
- * @param {Object} [options={}] Optional Parameters
196
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north]
197
- * associated with the FeatureCollection
198
- * @param {string|number} [options.id] Identifier associated with the FeatureCollection
199
- * @returns {FeatureCollection<LineString>} LineString FeatureCollection
200
- * @example
201
- * var linestrings = turf.lineStrings([
202
- * [[-24, 63], [-23, 60], [-25, 65], [-20, 69]],
203
- * [[-14, 43], [-13, 40], [-15, 45], [-10, 49]]
204
- * ]);
205
- *
206
- * //=linestrings
207
- */
208
- export declare function lineStrings<P = Properties>(coordinates: Position[][], properties?: P, options?: {
209
- bbox?: BBox;
210
- id?: Id;
211
- }): FeatureCollection<LineString, P>;
212
- /**
213
- * Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.
214
- *
215
- * @name featureCollection
216
- * @param {Feature[]} features input features
217
- * @param {Object} [options={}] Optional Parameters
218
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
219
- * @param {string|number} [options.id] Identifier associated with the Feature
220
- * @returns {FeatureCollection} FeatureCollection of Features
221
- * @example
222
- * var locationA = turf.point([-75.343, 39.984], {name: 'Location A'});
223
- * var locationB = turf.point([-75.833, 39.284], {name: 'Location B'});
224
- * var locationC = turf.point([-75.534, 39.123], {name: 'Location C'});
225
- *
226
- * var collection = turf.featureCollection([
227
- * locationA,
228
- * locationB,
229
- * locationC
230
- * ]);
231
- *
232
- * //=collection
233
- */
234
- export declare function featureCollection<G = Geometry, P = Properties>(features: Array<Feature<G, P>>, options?: {
235
- bbox?: BBox;
236
- id?: Id;
237
- }): FeatureCollection<G, P>;
238
- /**
239
- * Creates a {@link Feature<MultiLineString>} based on a
240
- * coordinate array. Properties can be added optionally.
241
- *
242
- * @name multiLineString
243
- * @param {Array<Array<Array<number>>>} coordinates an array of LineStrings
244
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
245
- * @param {Object} [options={}] Optional Parameters
246
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
247
- * @param {string|number} [options.id] Identifier associated with the Feature
248
- * @returns {Feature<MultiLineString>} a MultiLineString feature
249
- * @throws {Error} if no coordinates are passed
250
- * @example
251
- * var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
252
- *
253
- * //=multiLine
254
- */
255
- export declare function multiLineString<P = Properties>(coordinates: Position[][], properties?: P, options?: {
256
- bbox?: BBox;
257
- id?: Id;
258
- }): Feature<MultiLineString, P>;
259
- /**
260
- * Creates a {@link Feature<MultiPoint>} based on a
261
- * coordinate array. Properties can be added optionally.
262
- *
263
- * @name multiPoint
264
- * @param {Array<Array<number>>} coordinates an array of Positions
265
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
266
- * @param {Object} [options={}] Optional Parameters
267
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
268
- * @param {string|number} [options.id] Identifier associated with the Feature
269
- * @returns {Feature<MultiPoint>} a MultiPoint feature
270
- * @throws {Error} if no coordinates are passed
271
- * @example
272
- * var multiPt = turf.multiPoint([[0,0],[10,10]]);
273
- *
274
- * //=multiPt
275
- */
276
- export declare function multiPoint<P = Properties>(coordinates: Position[], properties?: P, options?: {
277
- bbox?: BBox;
278
- id?: Id;
279
- }): Feature<MultiPoint, P>;
280
- /**
281
- * Creates a {@link Feature<MultiPolygon>} based on a
282
- * coordinate array. Properties can be added optionally.
283
- *
284
- * @name multiPolygon
285
- * @param {Array<Array<Array<Array<number>>>>} coordinates an array of Polygons
286
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
287
- * @param {Object} [options={}] Optional Parameters
288
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
289
- * @param {string|number} [options.id] Identifier associated with the Feature
290
- * @returns {Feature<MultiPolygon>} a multipolygon feature
291
- * @throws {Error} if no coordinates are passed
292
- * @example
293
- * var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
294
- *
295
- * //=multiPoly
296
- *
297
- */
298
- export declare function multiPolygon<P = Properties>(coordinates: Position[][][], properties?: P, options?: {
299
- bbox?: BBox;
300
- id?: Id;
301
- }): Feature<MultiPolygon, P>;
302
- /**
303
- * Creates a {@link Feature<GeometryCollection>} based on a
304
- * coordinate array. Properties can be added optionally.
305
- *
306
- * @name geometryCollection
307
- * @param {Array<Geometry>} geometries an array of GeoJSON Geometries
308
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
309
- * @param {Object} [options={}] Optional Parameters
310
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
311
- * @param {string|number} [options.id] Identifier associated with the Feature
312
- * @returns {Feature<GeometryCollection>} a GeoJSON GeometryCollection Feature
313
- * @example
314
- * var pt = turf.geometry("Point", [100, 0]);
315
- * var line = turf.geometry("LineString", [[101, 0], [102, 1]]);
316
- * var collection = turf.geometryCollection([pt, line]);
317
- *
318
- * // => collection
319
- */
320
- export declare function geometryCollection<P = Properties>(geometries: Array<Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon>, properties?: P, options?: {
321
- bbox?: BBox;
322
- id?: Id;
323
- }): Feature<GeometryCollection, P>;
324
- /**
325
- * Round number to precision
326
- *
327
- * @param {number} num Number
328
- * @param {number} [precision=0] Precision
329
- * @returns {number} rounded number
330
- * @example
331
- * turf.round(120.4321)
332
- * //=120
333
- *
334
- * turf.round(120.4321, 2)
335
- * //=120.43
336
- */
337
- export declare function round(num: number, precision?: number): number;
338
- /**
339
- * Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
340
- * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
341
- *
342
- * @name radiansToLength
343
- * @param {number} radians in radians across the sphere
344
- * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
345
- * meters, kilometres, kilometers.
346
- * @returns {number} distance
347
- */
348
- export declare function radiansToLength(radians: number, units?: Units): number;
349
- /**
350
- * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
351
- * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
352
- *
353
- * @name lengthToRadians
354
- * @param {number} distance in real units
355
- * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
356
- * meters, kilometres, kilometers.
357
- * @returns {number} radians
358
- */
359
- export declare function lengthToRadians(distance: number, units?: Units): number;
360
- /**
361
- * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
362
- * Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
363
- *
364
- * @name lengthToDegrees
365
- * @param {number} distance in real units
366
- * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
367
- * meters, kilometres, kilometers.
368
- * @returns {number} degrees
369
- */
370
- export declare function lengthToDegrees(distance: number, units?: Units): number;
371
- /**
372
- * Converts any bearing angle from the north line direction (positive clockwise)
373
- * and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
374
- *
375
- * @name bearingToAzimuth
376
- * @param {number} bearing angle, between -180 and +180 degrees
377
- * @returns {number} angle between 0 and 360 degrees
378
- */
379
- export declare function bearingToAzimuth(bearing: number): number;
380
- /**
381
- * Converts an angle in radians to degrees
382
- *
383
- * @name radiansToDegrees
384
- * @param {number} radians angle in radians
385
- * @returns {number} degrees between 0 and 360 degrees
386
- */
387
- export declare function radiansToDegrees(radians: number): number;
388
- /**
389
- * Converts an angle in degrees to radians
390
- *
391
- * @name degreesToRadians
392
- * @param {number} degrees angle between 0 and 360 degrees
393
- * @returns {number} angle in radians
394
- */
395
- export declare function degreesToRadians(degrees: number): number;
396
- /**
397
- * Converts a length to the requested unit.
398
- * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
399
- *
400
- * @param {number} length to be converted
401
- * @param {Units} [originalUnit="kilometers"] of the length
402
- * @param {Units} [finalUnit="kilometers"] returned unit
403
- * @returns {number} the converted length
404
- */
405
- export declare function convertLength(length: number, originalUnit?: Units, finalUnit?: Units): number;
406
- /**
407
- * Converts a area to the requested unit.
408
- * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches
409
- * @param {number} area to be converted
410
- * @param {Units} [originalUnit="meters"] of the distance
411
- * @param {Units} [finalUnit="kilometers"] returned unit
412
- * @returns {number} the converted distance
413
- */
414
- export declare function convertArea(area: number, originalUnit?: Units, finalUnit?: Units): number;
415
- /**
416
- * isNumber
417
- *
418
- * @param {*} num Number to validate
419
- * @returns {boolean} true/false
420
- * @example
421
- * turf.isNumber(123)
422
- * //=true
423
- * turf.isNumber('foo')
424
- * //=false
425
- */
426
- export declare function isNumber(num: any): boolean;
427
- /**
428
- * isObject
429
- *
430
- * @param {*} input variable to validate
431
- * @returns {boolean} true/false
432
- * @example
433
- * turf.isObject({elevation: 10})
434
- * //=true
435
- * turf.isObject('foo')
436
- * //=false
437
- */
438
- export declare function isObject(input: any): boolean;
439
- /**
440
- * Validate BBox
441
- *
442
- * @private
443
- * @param {Array<number>} bbox BBox to validate
444
- * @returns {void}
445
- * @throws Error if BBox is not valid
446
- * @example
447
- * validateBBox([-180, -40, 110, 50])
448
- * //=OK
449
- * validateBBox([-180, -40])
450
- * //=Error
451
- * validateBBox('Foo')
452
- * //=Error
453
- * validateBBox(5)
454
- * //=Error
455
- * validateBBox(null)
456
- * //=Error
457
- * validateBBox(undefined)
458
- * //=Error
459
- */
460
- export declare function validateBBox(bbox: any): void;
461
- /**
462
- * Validate Id
463
- *
464
- * @private
465
- * @param {string|number} id Id to validate
466
- * @returns {void}
467
- * @throws Error if Id is not valid
468
- * @example
469
- * validateId([-180, -40, 110, 50])
470
- * //=Error
471
- * validateId([-180, -40])
472
- * //=Error
473
- * validateId('Foo')
474
- * //=OK
475
- * validateId(5)
476
- * //=OK
477
- * validateId(null)
478
- * //=Error
479
- * validateId(undefined)
480
- * //=Error
481
- */
482
- export declare function validateId(id: any): void;
483
- export declare function radians2degrees(): void;
484
- export declare function degrees2radians(): void;
485
- export declare function distanceToDegrees(): void;
486
- export declare function distanceToRadians(): void;
487
- export declare function radiansToDistance(): void;
488
- export declare function bearingToAngle(): void;
489
- export declare function convertDistance(): void;
@@ -1,193 +0,0 @@
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
- /**
29
- * Id
30
- *
31
- * https://tools.ietf.org/html/rfc7946#section-3.2
32
- * If a Feature has a commonly used identifier, that identifier SHOULD be included as a member of
33
- * 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
- *
39
- * https://tools.ietf.org/html/rfc7946#section-3.1.1
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.
43
- */
44
- export declare type Position = number[];
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
- }