node-red-contrib-web-worldmap 4.9.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +7 -3
  3. package/examples/{feedback.json → Feedback.json} +1 -9
  4. package/examples/MouseCoordinates.json +159 -0
  5. package/examples/sidcEdgeIcon.json +158 -0
  6. package/node_modules/@turf/bezier-spline/README.md +15 -21
  7. package/node_modules/@turf/bezier-spline/dist/cjs/index.cjs +165 -0
  8. package/node_modules/@turf/bezier-spline/dist/cjs/index.cjs.map +1 -0
  9. package/node_modules/@turf/bezier-spline/dist/{es/index.js → cjs/index.d.cts} +9 -30
  10. package/node_modules/@turf/bezier-spline/dist/{js → esm}/index.d.ts +5 -3
  11. package/node_modules/@turf/bezier-spline/dist/esm/index.js +165 -0
  12. package/node_modules/@turf/bezier-spline/dist/esm/index.js.map +1 -0
  13. package/node_modules/@turf/bezier-spline/package.json +33 -25
  14. package/node_modules/@turf/helpers/README.md +231 -219
  15. package/node_modules/@turf/helpers/dist/cjs/index.cjs +308 -0
  16. package/node_modules/@turf/helpers/dist/cjs/index.cjs.map +1 -0
  17. package/node_modules/@turf/helpers/dist/{es/index.js → cjs/index.d.cts} +103 -303
  18. package/node_modules/@turf/helpers/dist/{js → esm}/index.d.ts +67 -53
  19. package/node_modules/@turf/helpers/dist/esm/index.js +308 -0
  20. package/node_modules/@turf/helpers/dist/esm/index.js.map +1 -0
  21. package/node_modules/@turf/helpers/package.json +32 -22
  22. package/node_modules/@turf/invariant/README.md +47 -58
  23. package/node_modules/@turf/invariant/dist/cjs/index.cjs +127 -0
  24. package/node_modules/@turf/invariant/dist/cjs/index.cjs.map +1 -0
  25. package/node_modules/@turf/invariant/dist/cjs/index.d.cts +108 -0
  26. package/node_modules/@turf/invariant/dist/{js → esm}/index.d.ts +12 -9
  27. package/node_modules/@turf/invariant/dist/esm/index.js +127 -0
  28. package/node_modules/@turf/invariant/dist/esm/index.js.map +1 -0
  29. package/node_modules/@turf/invariant/package.json +31 -22
  30. package/node_modules/@types/geojson/LICENSE +21 -0
  31. package/node_modules/@types/geojson/README.md +15 -0
  32. package/node_modules/@types/geojson/index.d.ts +165 -0
  33. package/node_modules/@types/geojson/package.json +45 -0
  34. package/node_modules/body-parser/HISTORY.md +7 -0
  35. package/node_modules/body-parser/README.md +11 -0
  36. package/node_modules/body-parser/lib/types/urlencoded.js +30 -7
  37. package/node_modules/body-parser/package.json +2 -2
  38. package/node_modules/encodeurl/README.md +19 -38
  39. package/node_modules/encodeurl/index.js +1 -1
  40. package/node_modules/encodeurl/package.json +7 -7
  41. package/node_modules/express/History.md +27 -0
  42. package/node_modules/express/Readme.md +100 -6
  43. package/node_modules/express/lib/response.js +11 -10
  44. package/node_modules/express/package.json +11 -11
  45. package/node_modules/finalhandler/HISTORY.md +15 -0
  46. package/node_modules/finalhandler/README.md +2 -2
  47. package/node_modules/finalhandler/index.js +7 -2
  48. package/node_modules/finalhandler/package.json +8 -7
  49. package/node_modules/merge-descriptors/README.md +4 -3
  50. package/node_modules/merge-descriptors/index.js +3 -3
  51. package/node_modules/merge-descriptors/package.json +14 -7
  52. package/node_modules/mime-db/HISTORY.md +14 -0
  53. package/node_modules/mime-db/README.md +27 -24
  54. package/node_modules/mime-db/db.json +646 -62
  55. package/node_modules/mime-db/package.json +9 -13
  56. package/node_modules/mime-types/node_modules/mime-db/HISTORY.md +507 -0
  57. package/node_modules/mime-types/node_modules/mime-db/LICENSE +23 -0
  58. package/node_modules/mime-types/node_modules/mime-db/README.md +100 -0
  59. package/node_modules/mime-types/node_modules/mime-db/db.json +8519 -0
  60. package/node_modules/mime-types/node_modules/mime-db/index.js +12 -0
  61. package/node_modules/mime-types/node_modules/mime-db/package.json +60 -0
  62. package/node_modules/object-inspect/CHANGELOG.md +15 -0
  63. package/node_modules/object-inspect/index.js +4 -1
  64. package/node_modules/object-inspect/package.json +14 -9
  65. package/node_modules/object-inspect/readme.markdown +9 -11
  66. package/node_modules/path-to-regexp/index.js +57 -40
  67. package/node_modules/path-to-regexp/package.json +2 -2
  68. package/node_modules/qs/.editorconfig +3 -0
  69. package/node_modules/qs/.eslintrc +2 -2
  70. package/node_modules/qs/CHANGELOG.md +59 -5
  71. package/node_modules/qs/README.md +133 -49
  72. package/node_modules/qs/dist/qs.js +56 -2020
  73. package/node_modules/qs/lib/parse.js +46 -13
  74. package/node_modules/qs/lib/stringify.js +53 -28
  75. package/node_modules/qs/lib/utils.js +47 -34
  76. package/node_modules/qs/package.json +26 -12
  77. package/node_modules/qs/test/empty-keys-cases.js +267 -0
  78. package/node_modules/qs/test/parse.js +347 -32
  79. package/node_modules/qs/test/stringify.js +436 -47
  80. package/node_modules/send/HISTORY.md +5 -0
  81. package/node_modules/send/index.js +1 -2
  82. package/node_modules/send/node_modules/encodeurl/LICENSE +22 -0
  83. package/node_modules/send/node_modules/encodeurl/README.md +128 -0
  84. package/node_modules/send/node_modules/encodeurl/index.js +60 -0
  85. package/node_modules/send/node_modules/encodeurl/package.json +40 -0
  86. package/node_modules/send/package.json +1 -1
  87. package/node_modules/serve-static/HISTORY.md +16 -0
  88. package/node_modules/serve-static/index.js +1 -2
  89. package/node_modules/serve-static/package.json +3 -3
  90. package/node_modules/tslib/CopyrightNotice.txt +15 -0
  91. package/node_modules/tslib/LICENSE.txt +12 -0
  92. package/node_modules/tslib/README.md +164 -0
  93. package/node_modules/tslib/SECURITY.md +41 -0
  94. package/node_modules/tslib/modules/index.d.ts +37 -0
  95. package/node_modules/tslib/modules/index.js +68 -0
  96. package/node_modules/tslib/modules/package.json +3 -0
  97. package/node_modules/tslib/package.json +47 -0
  98. package/node_modules/tslib/tslib.d.ts +453 -0
  99. package/node_modules/tslib/tslib.es6.html +1 -0
  100. package/node_modules/tslib/tslib.es6.js +379 -0
  101. package/node_modules/tslib/tslib.es6.mjs +378 -0
  102. package/node_modules/tslib/tslib.html +1 -0
  103. package/node_modules/tslib/tslib.js +429 -0
  104. package/package.json +5 -5
  105. package/worldmap/index.html +1 -1
  106. package/worldmap/leaflet/leaflet.mousecoordinate.js +3 -3
  107. package/worldmap/worldmap.js +123 -36
  108. package/worldmap.html +1 -1
  109. package/worldmap.js +23 -4
  110. package/node_modules/@turf/bezier-spline/dist/es/lib/spline.js +0 -158
  111. package/node_modules/@turf/bezier-spline/dist/es/package.json +0 -1
  112. package/node_modules/@turf/bezier-spline/dist/js/index.js +0 -65
  113. package/node_modules/@turf/bezier-spline/dist/js/lib/spline.d.ts +0 -62
  114. package/node_modules/@turf/bezier-spline/dist/js/lib/spline.js +0 -160
  115. package/node_modules/@turf/helpers/dist/es/lib/geojson.js +0 -7
  116. package/node_modules/@turf/helpers/dist/es/package.json +0 -1
  117. package/node_modules/@turf/helpers/dist/js/index.js +0 -724
  118. package/node_modules/@turf/helpers/dist/js/lib/geojson.d.ts +0 -193
  119. package/node_modules/@turf/helpers/dist/js/lib/geojson.js +0 -9
  120. package/node_modules/@turf/invariant/dist/es/index.js +0 -223
  121. package/node_modules/@turf/invariant/dist/es/package.json +0 -1
  122. package/node_modules/@turf/invariant/dist/js/index.js +0 -233
  123. package/node_modules/path-to-regexp/History.md +0 -36
  124. /package/node_modules/{encodeurl → send/node_modules/encodeurl}/HISTORY.md +0 -0
@@ -1,46 +1,49 @@
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" | "hectares";
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;
1
+ import { Feature, Point, Position, LineString, MultiLineString, Polygon, MultiPolygon, FeatureCollection, Geometry, GeometryCollection, GeometryObject, GeoJsonProperties, BBox, MultiPoint } from 'geojson';
2
+
3
+ /**
4
+ * Id
5
+ *
6
+ * https://tools.ietf.org/html/rfc7946#section-3.2
7
+ * If a Feature has a commonly used identifier, that identifier SHOULD be included as a member of
8
+ * the Feature object with the name "id", and the value of this member is either a JSON string or number.
9
+ *
10
+ * Should be contributed to @types/geojson
11
+ */
12
+ type Id = string | number;
13
+
14
+ type Coord = Feature<Point> | Point | Position;
15
+ type Units = "meters" | "metres" | "millimeters" | "millimetres" | "centimeters" | "centimetres" | "kilometers" | "kilometres" | "miles" | "nauticalmiles" | "inches" | "yards" | "feet" | "radians" | "degrees";
16
+ type AreaUnits = Exclude<Units, "radians" | "degrees"> | "acres" | "hectares";
17
+ type Grid = "point" | "square" | "hex" | "triangle";
18
+ type Corners = "sw" | "se" | "nw" | "ne" | "center" | "centroid";
19
+ type Lines = LineString | MultiLineString | Polygon | MultiPolygon;
20
+ type AllGeoJSON = Feature | FeatureCollection | Geometry | GeometryCollection;
9
21
  /**
10
22
  * @module helpers
11
23
  */
12
24
  /**
13
- * Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
14
- *
25
+ * The Earth radius in kilometers. Used by Turf modules that model the Earth as a sphere. The {@link https://en.wikipedia.org/wiki/Earth_radius#Arithmetic_mean_radius mean radius} was selected because it is {@link https://rosettacode.org/wiki/Haversine_formula#:~:text=This%20value%20is%20recommended recommended } by the Haversine formula (used by turf/distance) to reduce error.
15
26
  * @memberof helpers
16
27
  * @type {number}
17
28
  */
18
- export declare let earthRadius: number;
29
+ declare const earthRadius = 6371008.8;
19
30
  /**
20
- * Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
31
+ * Unit of measurement factors based on earthRadius.
21
32
  *
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.
33
+ * Keys are the name of the unit, values are the number of that unit in a single radian
30
34
  *
31
35
  * @memberof helpers
32
36
  * @type {Object}
33
37
  */
34
- export declare let unitsFactors: {
35
- [key: string]: number;
36
- };
38
+ declare const factors: Record<Units, number>;
37
39
  /**
40
+
38
41
  * Area of measurement factors based on 1 square meter.
39
42
  *
40
43
  * @memberof helpers
41
44
  * @type {Object}
42
45
  */
43
- export declare let areaFactors: any;
46
+ declare const areaFactors: Record<AreaUnits, number>;
44
47
  /**
45
48
  * Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
46
49
  *
@@ -61,7 +64,7 @@ export declare let areaFactors: any;
61
64
  *
62
65
  * //=feature
63
66
  */
64
- export declare function feature<G = Geometry, P = Properties>(geom: G, properties?: P, options?: {
67
+ declare function feature<G extends GeometryObject = Geometry, P extends GeoJsonProperties = GeoJsonProperties>(geom: G | null, properties?: P, options?: {
65
68
  bbox?: BBox;
66
69
  id?: Id;
67
70
  }): Feature<G, P>;
@@ -80,7 +83,7 @@ export declare function feature<G = Geometry, P = Properties>(geom: G, propertie
80
83
  * var geometry = turf.geometry(type, coordinates);
81
84
  * // => geometry
82
85
  */
83
- export declare function geometry(type: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon", coordinates: any[], _options?: Record<string, never>): Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
86
+ declare function geometry(type: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon", coordinates: any[], _options?: Record<string, never>): Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon;
84
87
  /**
85
88
  * Creates a {@link Point} {@link Feature} from a Position.
86
89
  *
@@ -96,7 +99,7 @@ export declare function geometry(type: "Point" | "LineString" | "Polygon" | "Mul
96
99
  *
97
100
  * //=point
98
101
  */
99
- export declare function point<P = Properties>(coordinates: Position, properties?: P, options?: {
102
+ declare function point<P extends GeoJsonProperties = GeoJsonProperties>(coordinates: Position, properties?: P, options?: {
100
103
  bbox?: BBox;
101
104
  id?: Id;
102
105
  }): Feature<Point, P>;
@@ -120,7 +123,7 @@ export declare function point<P = Properties>(coordinates: Position, properties?
120
123
  *
121
124
  * //=points
122
125
  */
123
- export declare function points<P = Properties>(coordinates: Position[], properties?: P, options?: {
126
+ declare function points<P extends GeoJsonProperties = GeoJsonProperties>(coordinates: Position[], properties?: P, options?: {
124
127
  bbox?: BBox;
125
128
  id?: Id;
126
129
  }): FeatureCollection<Point, P>;
@@ -139,7 +142,7 @@ export declare function points<P = Properties>(coordinates: Position[], properti
139
142
  *
140
143
  * //=polygon
141
144
  */
142
- export declare function polygon<P = Properties>(coordinates: Position[][], properties?: P, options?: {
145
+ declare function polygon<P extends GeoJsonProperties = GeoJsonProperties>(coordinates: Position[][], properties?: P, options?: {
143
146
  bbox?: BBox;
144
147
  id?: Id;
145
148
  }): Feature<Polygon, P>;
@@ -161,7 +164,7 @@ export declare function polygon<P = Properties>(coordinates: Position[][], prope
161
164
  *
162
165
  * //=polygons
163
166
  */
164
- export declare function polygons<P = Properties>(coordinates: Position[][][], properties?: P, options?: {
167
+ declare function polygons<P extends GeoJsonProperties = GeoJsonProperties>(coordinates: Position[][][], properties?: P, options?: {
165
168
  bbox?: BBox;
166
169
  id?: Id;
167
170
  }): FeatureCollection<Polygon, P>;
@@ -182,7 +185,7 @@ export declare function polygons<P = Properties>(coordinates: Position[][][], pr
182
185
  * //=linestring1
183
186
  * //=linestring2
184
187
  */
185
- export declare function lineString<P = Properties>(coordinates: Position[], properties?: P, options?: {
188
+ declare function lineString<P extends GeoJsonProperties = GeoJsonProperties>(coordinates: Position[], properties?: P, options?: {
186
189
  bbox?: BBox;
187
190
  id?: Id;
188
191
  }): Feature<LineString, P>;
@@ -205,7 +208,7 @@ export declare function lineString<P = Properties>(coordinates: Position[], prop
205
208
  *
206
209
  * //=linestrings
207
210
  */
208
- export declare function lineStrings<P = Properties>(coordinates: Position[][], properties?: P, options?: {
211
+ declare function lineStrings<P extends GeoJsonProperties = GeoJsonProperties>(coordinates: Position[][], properties?: P, options?: {
209
212
  bbox?: BBox;
210
213
  id?: Id;
211
214
  }): FeatureCollection<LineString, P>;
@@ -231,7 +234,7 @@ export declare function lineStrings<P = Properties>(coordinates: Position[][], p
231
234
  *
232
235
  * //=collection
233
236
  */
234
- export declare function featureCollection<G = Geometry, P = Properties>(features: Array<Feature<G, P>>, options?: {
237
+ declare function featureCollection<G extends GeometryObject = Geometry, P extends GeoJsonProperties = GeoJsonProperties>(features: Array<Feature<G, P>>, options?: {
235
238
  bbox?: BBox;
236
239
  id?: Id;
237
240
  }): FeatureCollection<G, P>;
@@ -252,7 +255,7 @@ export declare function featureCollection<G = Geometry, P = Properties>(features
252
255
  *
253
256
  * //=multiLine
254
257
  */
255
- export declare function multiLineString<P = Properties>(coordinates: Position[][], properties?: P, options?: {
258
+ declare function multiLineString<P extends GeoJsonProperties = GeoJsonProperties>(coordinates: Position[][], properties?: P, options?: {
256
259
  bbox?: BBox;
257
260
  id?: Id;
258
261
  }): Feature<MultiLineString, P>;
@@ -273,7 +276,7 @@ export declare function multiLineString<P = Properties>(coordinates: Position[][
273
276
  *
274
277
  * //=multiPt
275
278
  */
276
- export declare function multiPoint<P = Properties>(coordinates: Position[], properties?: P, options?: {
279
+ declare function multiPoint<P extends GeoJsonProperties = GeoJsonProperties>(coordinates: Position[], properties?: P, options?: {
277
280
  bbox?: BBox;
278
281
  id?: Id;
279
282
  }): Feature<MultiPoint, P>;
@@ -295,7 +298,7 @@ export declare function multiPoint<P = Properties>(coordinates: Position[], prop
295
298
  * //=multiPoly
296
299
  *
297
300
  */
298
- export declare function multiPolygon<P = Properties>(coordinates: Position[][][], properties?: P, options?: {
301
+ declare function multiPolygon<P extends GeoJsonProperties = GeoJsonProperties>(coordinates: Position[][][], properties?: P, options?: {
299
302
  bbox?: BBox;
300
303
  id?: Id;
301
304
  }): Feature<MultiPolygon, P>;
@@ -317,7 +320,7 @@ export declare function multiPolygon<P = Properties>(coordinates: Position[][][]
317
320
  *
318
321
  * // => collection
319
322
  */
320
- export declare function geometryCollection<P = Properties>(geometries: Array<Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon>, properties?: P, options?: {
323
+ declare function geometryCollection<P extends GeoJsonProperties = GeoJsonProperties>(geometries: Array<Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon>, properties?: P, options?: {
321
324
  bbox?: BBox;
322
325
  id?: Id;
323
326
  }): Feature<GeometryCollection, P>;
@@ -334,7 +337,7 @@ export declare function geometryCollection<P = Properties>(geometries: Array<Poi
334
337
  * turf.round(120.4321, 2)
335
338
  * //=120.43
336
339
  */
337
- export declare function round(num: number, precision?: number): number;
340
+ declare function round(num: number, precision?: number): number;
338
341
  /**
339
342
  * Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
340
343
  * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
@@ -345,7 +348,7 @@ export declare function round(num: number, precision?: number): number;
345
348
  * meters, kilometres, kilometers.
346
349
  * @returns {number} distance
347
350
  */
348
- export declare function radiansToLength(radians: number, units?: Units): number;
351
+ declare function radiansToLength(radians: number, units?: Units): number;
349
352
  /**
350
353
  * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
351
354
  * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
@@ -356,7 +359,7 @@ export declare function radiansToLength(radians: number, units?: Units): number;
356
359
  * meters, kilometres, kilometers.
357
360
  * @returns {number} radians
358
361
  */
359
- export declare function lengthToRadians(distance: number, units?: Units): number;
362
+ declare function lengthToRadians(distance: number, units?: Units): number;
360
363
  /**
361
364
  * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
362
365
  * Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
@@ -367,7 +370,7 @@ export declare function lengthToRadians(distance: number, units?: Units): number
367
370
  * meters, kilometres, kilometers.
368
371
  * @returns {number} degrees
369
372
  */
370
- export declare function lengthToDegrees(distance: number, units?: Units): number;
373
+ declare function lengthToDegrees(distance: number, units?: Units): number;
371
374
  /**
372
375
  * Converts any bearing angle from the north line direction (positive clockwise)
373
376
  * and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
@@ -376,7 +379,16 @@ export declare function lengthToDegrees(distance: number, units?: Units): number
376
379
  * @param {number} bearing angle, between -180 and +180 degrees
377
380
  * @returns {number} angle between 0 and 360 degrees
378
381
  */
379
- export declare function bearingToAzimuth(bearing: number): number;
382
+ declare function bearingToAzimuth(bearing: number): number;
383
+ /**
384
+ * Converts any azimuth angle from the north line direction (positive clockwise)
385
+ * and returns an angle between -180 and +180 degrees (positive clockwise), 0 being the north line
386
+ *
387
+ * @name azimuthToBearing
388
+ * @param {number} angle between 0 and 360 degrees
389
+ * @returns {number} bearing between -180 and +180 degrees
390
+ */
391
+ declare function azimuthToBearing(angle: number): number;
380
392
  /**
381
393
  * Converts an angle in radians to degrees
382
394
  *
@@ -384,7 +396,7 @@ export declare function bearingToAzimuth(bearing: number): number;
384
396
  * @param {number} radians angle in radians
385
397
  * @returns {number} degrees between 0 and 360 degrees
386
398
  */
387
- export declare function radiansToDegrees(radians: number): number;
399
+ declare function radiansToDegrees(radians: number): number;
388
400
  /**
389
401
  * Converts an angle in degrees to radians
390
402
  *
@@ -392,7 +404,7 @@ export declare function radiansToDegrees(radians: number): number;
392
404
  * @param {number} degrees angle between 0 and 360 degrees
393
405
  * @returns {number} angle in radians
394
406
  */
395
- export declare function degreesToRadians(degrees: number): number;
407
+ declare function degreesToRadians(degrees: number): number;
396
408
  /**
397
409
  * Converts a length to the requested unit.
398
410
  * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
@@ -402,7 +414,7 @@ export declare function degreesToRadians(degrees: number): number;
402
414
  * @param {Units} [finalUnit="kilometers"] returned unit
403
415
  * @returns {number} the converted length
404
416
  */
405
- export declare function convertLength(length: number, originalUnit?: Units, finalUnit?: Units): number;
417
+ declare function convertLength(length: number, originalUnit?: Units, finalUnit?: Units): number;
406
418
  /**
407
419
  * Converts a area to the requested unit.
408
420
  * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares
@@ -411,7 +423,7 @@ export declare function convertLength(length: number, originalUnit?: Units, fina
411
423
  * @param {Units} [finalUnit="kilometers"] returned unit
412
424
  * @returns {number} the converted area
413
425
  */
414
- export declare function convertArea(area: number, originalUnit?: Units, finalUnit?: Units): number;
426
+ declare function convertArea(area: number, originalUnit?: AreaUnits, finalUnit?: AreaUnits): number;
415
427
  /**
416
428
  * isNumber
417
429
  *
@@ -423,26 +435,26 @@ export declare function convertArea(area: number, originalUnit?: Units, finalUni
423
435
  * turf.isNumber('foo')
424
436
  * //=false
425
437
  */
426
- export declare function isNumber(num: any): boolean;
438
+ declare function isNumber(num: any): boolean;
427
439
  /**
428
440
  * isObject
429
441
  *
430
442
  * @param {*} input variable to validate
431
- * @returns {boolean} true/false
443
+ * @returns {boolean} true/false, including false for Arrays and Functions
432
444
  * @example
433
445
  * turf.isObject({elevation: 10})
434
446
  * //=true
435
447
  * turf.isObject('foo')
436
448
  * //=false
437
449
  */
438
- export declare function isObject(input: any): boolean;
450
+ declare function isObject(input: any): boolean;
439
451
  /**
440
452
  * Validate BBox
441
453
  *
442
454
  * @private
443
455
  * @param {Array<number>} bbox BBox to validate
444
456
  * @returns {void}
445
- * @throws Error if BBox is not valid
457
+ * @throws {Error} if BBox is not valid
446
458
  * @example
447
459
  * validateBBox([-180, -40, 110, 50])
448
460
  * //=OK
@@ -457,14 +469,14 @@ export declare function isObject(input: any): boolean;
457
469
  * validateBBox(undefined)
458
470
  * //=Error
459
471
  */
460
- export declare function validateBBox(bbox: any): void;
472
+ declare function validateBBox(bbox: any): void;
461
473
  /**
462
474
  * Validate Id
463
475
  *
464
476
  * @private
465
477
  * @param {string|number} id Id to validate
466
478
  * @returns {void}
467
- * @throws Error if Id is not valid
479
+ * @throws {Error} if Id is not valid
468
480
  * @example
469
481
  * validateId([-180, -40, 110, 50])
470
482
  * //=Error
@@ -479,4 +491,6 @@ export declare function validateBBox(bbox: any): void;
479
491
  * validateId(undefined)
480
492
  * //=Error
481
493
  */
482
- export declare function validateId(id: any): void;
494
+ declare function validateId(id: any): void;
495
+
496
+ export { type AllGeoJSON, type AreaUnits, type Coord, type Corners, type Grid, type Id, type Lines, type Units, areaFactors, azimuthToBearing, bearingToAzimuth, convertArea, convertLength, degreesToRadians, earthRadius, factors, feature, featureCollection, geometry, geometryCollection, isNumber, isObject, lengthToDegrees, lengthToRadians, lineString, lineStrings, multiLineString, multiPoint, multiPolygon, point, points, polygon, polygons, radiansToDegrees, radiansToLength, round, validateBBox, validateId };
@@ -0,0 +1,308 @@
1
+ // index.ts
2
+ var earthRadius = 63710088e-1;
3
+ var factors = {
4
+ centimeters: earthRadius * 100,
5
+ centimetres: earthRadius * 100,
6
+ degrees: 360 / (2 * Math.PI),
7
+ feet: earthRadius * 3.28084,
8
+ inches: earthRadius * 39.37,
9
+ kilometers: earthRadius / 1e3,
10
+ kilometres: earthRadius / 1e3,
11
+ meters: earthRadius,
12
+ metres: earthRadius,
13
+ miles: earthRadius / 1609.344,
14
+ millimeters: earthRadius * 1e3,
15
+ millimetres: earthRadius * 1e3,
16
+ nauticalmiles: earthRadius / 1852,
17
+ radians: 1,
18
+ yards: earthRadius * 1.0936
19
+ };
20
+ var areaFactors = {
21
+ acres: 247105e-9,
22
+ centimeters: 1e4,
23
+ centimetres: 1e4,
24
+ feet: 10.763910417,
25
+ hectares: 1e-4,
26
+ inches: 1550.003100006,
27
+ kilometers: 1e-6,
28
+ kilometres: 1e-6,
29
+ meters: 1,
30
+ metres: 1,
31
+ miles: 386e-9,
32
+ nauticalmiles: 29155334959812285e-23,
33
+ millimeters: 1e6,
34
+ millimetres: 1e6,
35
+ yards: 1.195990046
36
+ };
37
+ function feature(geom, properties, options = {}) {
38
+ const feat = { type: "Feature" };
39
+ if (options.id === 0 || options.id) {
40
+ feat.id = options.id;
41
+ }
42
+ if (options.bbox) {
43
+ feat.bbox = options.bbox;
44
+ }
45
+ feat.properties = properties || {};
46
+ feat.geometry = geom;
47
+ return feat;
48
+ }
49
+ function geometry(type, coordinates, _options = {}) {
50
+ switch (type) {
51
+ case "Point":
52
+ return point(coordinates).geometry;
53
+ case "LineString":
54
+ return lineString(coordinates).geometry;
55
+ case "Polygon":
56
+ return polygon(coordinates).geometry;
57
+ case "MultiPoint":
58
+ return multiPoint(coordinates).geometry;
59
+ case "MultiLineString":
60
+ return multiLineString(coordinates).geometry;
61
+ case "MultiPolygon":
62
+ return multiPolygon(coordinates).geometry;
63
+ default:
64
+ throw new Error(type + " is invalid");
65
+ }
66
+ }
67
+ function point(coordinates, properties, options = {}) {
68
+ if (!coordinates) {
69
+ throw new Error("coordinates is required");
70
+ }
71
+ if (!Array.isArray(coordinates)) {
72
+ throw new Error("coordinates must be an Array");
73
+ }
74
+ if (coordinates.length < 2) {
75
+ throw new Error("coordinates must be at least 2 numbers long");
76
+ }
77
+ if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) {
78
+ throw new Error("coordinates must contain numbers");
79
+ }
80
+ const geom = {
81
+ type: "Point",
82
+ coordinates
83
+ };
84
+ return feature(geom, properties, options);
85
+ }
86
+ function points(coordinates, properties, options = {}) {
87
+ return featureCollection(
88
+ coordinates.map((coords) => {
89
+ return point(coords, properties);
90
+ }),
91
+ options
92
+ );
93
+ }
94
+ function polygon(coordinates, properties, options = {}) {
95
+ for (const ring of coordinates) {
96
+ if (ring.length < 4) {
97
+ throw new Error(
98
+ "Each LinearRing of a Polygon must have 4 or more Positions."
99
+ );
100
+ }
101
+ if (ring[ring.length - 1].length !== ring[0].length) {
102
+ throw new Error("First and last Position are not equivalent.");
103
+ }
104
+ for (let j = 0; j < ring[ring.length - 1].length; j++) {
105
+ if (ring[ring.length - 1][j] !== ring[0][j]) {
106
+ throw new Error("First and last Position are not equivalent.");
107
+ }
108
+ }
109
+ }
110
+ const geom = {
111
+ type: "Polygon",
112
+ coordinates
113
+ };
114
+ return feature(geom, properties, options);
115
+ }
116
+ function polygons(coordinates, properties, options = {}) {
117
+ return featureCollection(
118
+ coordinates.map((coords) => {
119
+ return polygon(coords, properties);
120
+ }),
121
+ options
122
+ );
123
+ }
124
+ function lineString(coordinates, properties, options = {}) {
125
+ if (coordinates.length < 2) {
126
+ throw new Error("coordinates must be an array of two or more positions");
127
+ }
128
+ const geom = {
129
+ type: "LineString",
130
+ coordinates
131
+ };
132
+ return feature(geom, properties, options);
133
+ }
134
+ function lineStrings(coordinates, properties, options = {}) {
135
+ return featureCollection(
136
+ coordinates.map((coords) => {
137
+ return lineString(coords, properties);
138
+ }),
139
+ options
140
+ );
141
+ }
142
+ function featureCollection(features, options = {}) {
143
+ const fc = { type: "FeatureCollection" };
144
+ if (options.id) {
145
+ fc.id = options.id;
146
+ }
147
+ if (options.bbox) {
148
+ fc.bbox = options.bbox;
149
+ }
150
+ fc.features = features;
151
+ return fc;
152
+ }
153
+ function multiLineString(coordinates, properties, options = {}) {
154
+ const geom = {
155
+ type: "MultiLineString",
156
+ coordinates
157
+ };
158
+ return feature(geom, properties, options);
159
+ }
160
+ function multiPoint(coordinates, properties, options = {}) {
161
+ const geom = {
162
+ type: "MultiPoint",
163
+ coordinates
164
+ };
165
+ return feature(geom, properties, options);
166
+ }
167
+ function multiPolygon(coordinates, properties, options = {}) {
168
+ const geom = {
169
+ type: "MultiPolygon",
170
+ coordinates
171
+ };
172
+ return feature(geom, properties, options);
173
+ }
174
+ function geometryCollection(geometries, properties, options = {}) {
175
+ const geom = {
176
+ type: "GeometryCollection",
177
+ geometries
178
+ };
179
+ return feature(geom, properties, options);
180
+ }
181
+ function round(num, precision = 0) {
182
+ if (precision && !(precision >= 0)) {
183
+ throw new Error("precision must be a positive number");
184
+ }
185
+ const multiplier = Math.pow(10, precision || 0);
186
+ return Math.round(num * multiplier) / multiplier;
187
+ }
188
+ function radiansToLength(radians, units = "kilometers") {
189
+ const factor = factors[units];
190
+ if (!factor) {
191
+ throw new Error(units + " units is invalid");
192
+ }
193
+ return radians * factor;
194
+ }
195
+ function lengthToRadians(distance, units = "kilometers") {
196
+ const factor = factors[units];
197
+ if (!factor) {
198
+ throw new Error(units + " units is invalid");
199
+ }
200
+ return distance / factor;
201
+ }
202
+ function lengthToDegrees(distance, units) {
203
+ return radiansToDegrees(lengthToRadians(distance, units));
204
+ }
205
+ function bearingToAzimuth(bearing) {
206
+ let angle = bearing % 360;
207
+ if (angle < 0) {
208
+ angle += 360;
209
+ }
210
+ return angle;
211
+ }
212
+ function azimuthToBearing(angle) {
213
+ angle = angle % 360;
214
+ if (angle > 0)
215
+ return angle > 180 ? angle - 360 : angle;
216
+ return angle < -180 ? angle + 360 : angle;
217
+ }
218
+ function radiansToDegrees(radians) {
219
+ const degrees = radians % (2 * Math.PI);
220
+ return degrees * 180 / Math.PI;
221
+ }
222
+ function degreesToRadians(degrees) {
223
+ const radians = degrees % 360;
224
+ return radians * Math.PI / 180;
225
+ }
226
+ function convertLength(length, originalUnit = "kilometers", finalUnit = "kilometers") {
227
+ if (!(length >= 0)) {
228
+ throw new Error("length must be a positive number");
229
+ }
230
+ return radiansToLength(lengthToRadians(length, originalUnit), finalUnit);
231
+ }
232
+ function convertArea(area, originalUnit = "meters", finalUnit = "kilometers") {
233
+ if (!(area >= 0)) {
234
+ throw new Error("area must be a positive number");
235
+ }
236
+ const startFactor = areaFactors[originalUnit];
237
+ if (!startFactor) {
238
+ throw new Error("invalid original units");
239
+ }
240
+ const finalFactor = areaFactors[finalUnit];
241
+ if (!finalFactor) {
242
+ throw new Error("invalid final units");
243
+ }
244
+ return area / startFactor * finalFactor;
245
+ }
246
+ function isNumber(num) {
247
+ return !isNaN(num) && num !== null && !Array.isArray(num);
248
+ }
249
+ function isObject(input) {
250
+ return input !== null && typeof input === "object" && !Array.isArray(input);
251
+ }
252
+ function validateBBox(bbox) {
253
+ if (!bbox) {
254
+ throw new Error("bbox is required");
255
+ }
256
+ if (!Array.isArray(bbox)) {
257
+ throw new Error("bbox must be an Array");
258
+ }
259
+ if (bbox.length !== 4 && bbox.length !== 6) {
260
+ throw new Error("bbox must be an Array of 4 or 6 numbers");
261
+ }
262
+ bbox.forEach((num) => {
263
+ if (!isNumber(num)) {
264
+ throw new Error("bbox must only contain numbers");
265
+ }
266
+ });
267
+ }
268
+ function validateId(id) {
269
+ if (!id) {
270
+ throw new Error("id is required");
271
+ }
272
+ if (["string", "number"].indexOf(typeof id) === -1) {
273
+ throw new Error("id must be a number or a string");
274
+ }
275
+ }
276
+ export {
277
+ areaFactors,
278
+ azimuthToBearing,
279
+ bearingToAzimuth,
280
+ convertArea,
281
+ convertLength,
282
+ degreesToRadians,
283
+ earthRadius,
284
+ factors,
285
+ feature,
286
+ featureCollection,
287
+ geometry,
288
+ geometryCollection,
289
+ isNumber,
290
+ isObject,
291
+ lengthToDegrees,
292
+ lengthToRadians,
293
+ lineString,
294
+ lineStrings,
295
+ multiLineString,
296
+ multiPoint,
297
+ multiPolygon,
298
+ point,
299
+ points,
300
+ polygon,
301
+ polygons,
302
+ radiansToDegrees,
303
+ radiansToLength,
304
+ round,
305
+ validateBBox,
306
+ validateId
307
+ };
308
+ //# sourceMappingURL=index.js.map