@turf/helpers 6.2.0-alpha.3 → 6.5.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/dist/es/index.js CHANGED
@@ -29,7 +29,7 @@ export var factors = {
29
29
  millimetres: earthRadius * 1000,
30
30
  nauticalmiles: earthRadius / 1852,
31
31
  radians: 1,
32
- yards: earthRadius / 1.0936,
32
+ yards: earthRadius * 1.0936,
33
33
  };
34
34
  /**
35
35
  * Units of measurement factors based on 1 meter.
@@ -52,7 +52,7 @@ export var unitsFactors = {
52
52
  millimetres: 1000,
53
53
  nauticalmiles: 1 / 1852,
54
54
  radians: 1 / earthRadius,
55
- yards: 1 / 1.0936,
55
+ yards: 1.0936133,
56
56
  };
57
57
  /**
58
58
  * Area of measurement factors based on 1 square meter.
@@ -694,25 +694,3 @@ export function validateId(id) {
694
694
  throw new Error("id must be a number or a string");
695
695
  }
696
696
  }
697
- // Deprecated methods
698
- export function radians2degrees() {
699
- throw new Error("method has been renamed to `radiansToDegrees`");
700
- }
701
- export function degrees2radians() {
702
- throw new Error("method has been renamed to `degreesToRadians`");
703
- }
704
- export function distanceToDegrees() {
705
- throw new Error("method has been renamed to `lengthToDegrees`");
706
- }
707
- export function distanceToRadians() {
708
- throw new Error("method has been renamed to `lengthToRadians`");
709
- }
710
- export function radiansToDistance() {
711
- throw new Error("method has been renamed to `radiansToLength`");
712
- }
713
- export function bearingToAngle() {
714
- throw new Error("method has been renamed to `bearingToAzimuth`");
715
- }
716
- export function convertDistance() {
717
- throw new Error("method has been renamed to `convertLength`");
718
- }
File without changes
@@ -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?: Record<string, never>): Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
84
84
  /**
85
85
  * Creates a {@link Point} {@link Feature} from a Position.
86
86
  *
@@ -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
@@ -31,7 +31,7 @@ exports.factors = {
31
31
  millimetres: exports.earthRadius * 1000,
32
32
  nauticalmiles: exports.earthRadius / 1852,
33
33
  radians: 1,
34
- yards: exports.earthRadius / 1.0936,
34
+ yards: exports.earthRadius * 1.0936,
35
35
  };
36
36
  /**
37
37
  * Units of measurement factors based on 1 meter.
@@ -54,7 +54,7 @@ exports.unitsFactors = {
54
54
  millimetres: 1000,
55
55
  nauticalmiles: 1 / 1852,
56
56
  radians: 1 / exports.earthRadius,
57
- yards: 1 / 1.0936,
57
+ yards: 1.0936133,
58
58
  };
59
59
  /**
60
60
  * Area of measurement factors based on 1 square meter.
@@ -722,32 +722,3 @@ function validateId(id) {
722
722
  }
723
723
  }
724
724
  exports.validateId = validateId;
725
- // Deprecated methods
726
- function radians2degrees() {
727
- throw new Error("method has been renamed to `radiansToDegrees`");
728
- }
729
- exports.radians2degrees = radians2degrees;
730
- function degrees2radians() {
731
- throw new Error("method has been renamed to `degreesToRadians`");
732
- }
733
- exports.degrees2radians = degrees2radians;
734
- function distanceToDegrees() {
735
- throw new Error("method has been renamed to `lengthToDegrees`");
736
- }
737
- exports.distanceToDegrees = distanceToDegrees;
738
- function distanceToRadians() {
739
- throw new Error("method has been renamed to `lengthToRadians`");
740
- }
741
- exports.distanceToRadians = distanceToRadians;
742
- function radiansToDistance() {
743
- throw new Error("method has been renamed to `radiansToLength`");
744
- }
745
- exports.radiansToDistance = radiansToDistance;
746
- function bearingToAngle() {
747
- throw new Error("method has been renamed to `bearingToAzimuth`");
748
- }
749
- exports.bearingToAngle = bearingToAngle;
750
- function convertDistance() {
751
- throw new Error("method has been renamed to `convertLength`");
752
- }
753
- exports.convertDistance = convertDistance;
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/helpers",
3
- "version": "6.2.0-alpha.3",
3
+ "version": "6.5.0",
4
4
  "description": "turf helpers module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -18,6 +18,7 @@
18
18
  "type": "git",
19
19
  "url": "git://github.com/Turfjs/turf.git"
20
20
  },
21
+ "funding": "https://opencollective.com/turf",
21
22
  "publishConfig": {
22
23
  "access": "public"
23
24
  },
@@ -30,8 +31,11 @@
30
31
  "main": "dist/js/index.js",
31
32
  "module": "dist/es/index.js",
32
33
  "exports": {
33
- "import": "./dist/es/index.js",
34
- "require": "./dist/js/index.js"
34
+ "./package.json": "./package.json",
35
+ ".": {
36
+ "import": "./dist/es/index.js",
37
+ "require": "./dist/js/index.js"
38
+ }
35
39
  },
36
40
  "types": "dist/js/index.d.ts",
37
41
  "sideEffects": false,
@@ -57,5 +61,5 @@
57
61
  "tslint": "*",
58
62
  "typescript": "*"
59
63
  },
60
- "gitHead": "dce9edfc705352e8cb9e0083c9330ba0e8d77409"
64
+ "gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
61
65
  }
@@ -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
- }