node-red-contrib-web-worldmap 4.9.0 → 5.0.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.
Files changed (124) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/README.md +6 -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,724 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * @module helpers
5
- */
6
- /**
7
- * Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
8
- *
9
- * @memberof helpers
10
- * @type {number}
11
- */
12
- exports.earthRadius = 6371008.8;
13
- /**
14
- * Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
15
- *
16
- * @memberof helpers
17
- * @type {Object}
18
- */
19
- exports.factors = {
20
- centimeters: exports.earthRadius * 100,
21
- centimetres: exports.earthRadius * 100,
22
- degrees: exports.earthRadius / 111325,
23
- feet: exports.earthRadius * 3.28084,
24
- inches: exports.earthRadius * 39.37,
25
- kilometers: exports.earthRadius / 1000,
26
- kilometres: exports.earthRadius / 1000,
27
- meters: exports.earthRadius,
28
- metres: exports.earthRadius,
29
- miles: exports.earthRadius / 1609.344,
30
- millimeters: exports.earthRadius * 1000,
31
- millimetres: exports.earthRadius * 1000,
32
- nauticalmiles: exports.earthRadius / 1852,
33
- radians: 1,
34
- yards: exports.earthRadius * 1.0936,
35
- };
36
- /**
37
- * Units of measurement factors based on 1 meter.
38
- *
39
- * @memberof helpers
40
- * @type {Object}
41
- */
42
- exports.unitsFactors = {
43
- centimeters: 100,
44
- centimetres: 100,
45
- degrees: 1 / 111325,
46
- feet: 3.28084,
47
- inches: 39.37,
48
- kilometers: 1 / 1000,
49
- kilometres: 1 / 1000,
50
- meters: 1,
51
- metres: 1,
52
- miles: 1 / 1609.344,
53
- millimeters: 1000,
54
- millimetres: 1000,
55
- nauticalmiles: 1 / 1852,
56
- radians: 1 / exports.earthRadius,
57
- yards: 1.0936133,
58
- };
59
- /**
60
- * Area of measurement factors based on 1 square meter.
61
- *
62
- * @memberof helpers
63
- * @type {Object}
64
- */
65
- exports.areaFactors = {
66
- acres: 0.000247105,
67
- centimeters: 10000,
68
- centimetres: 10000,
69
- feet: 10.763910417,
70
- hectares: 0.0001,
71
- inches: 1550.003100006,
72
- kilometers: 0.000001,
73
- kilometres: 0.000001,
74
- meters: 1,
75
- metres: 1,
76
- miles: 3.86e-7,
77
- millimeters: 1000000,
78
- millimetres: 1000000,
79
- yards: 1.195990046,
80
- };
81
- /**
82
- * Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
83
- *
84
- * @name feature
85
- * @param {Geometry} geometry input geometry
86
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
87
- * @param {Object} [options={}] Optional Parameters
88
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
89
- * @param {string|number} [options.id] Identifier associated with the Feature
90
- * @returns {Feature} a GeoJSON Feature
91
- * @example
92
- * var geometry = {
93
- * "type": "Point",
94
- * "coordinates": [110, 50]
95
- * };
96
- *
97
- * var feature = turf.feature(geometry);
98
- *
99
- * //=feature
100
- */
101
- function feature(geom, properties, options) {
102
- if (options === void 0) { options = {}; }
103
- var feat = { type: "Feature" };
104
- if (options.id === 0 || options.id) {
105
- feat.id = options.id;
106
- }
107
- if (options.bbox) {
108
- feat.bbox = options.bbox;
109
- }
110
- feat.properties = properties || {};
111
- feat.geometry = geom;
112
- return feat;
113
- }
114
- exports.feature = feature;
115
- /**
116
- * Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.
117
- * For GeometryCollection type use `helpers.geometryCollection`
118
- *
119
- * @name geometry
120
- * @param {string} type Geometry Type
121
- * @param {Array<any>} coordinates Coordinates
122
- * @param {Object} [options={}] Optional Parameters
123
- * @returns {Geometry} a GeoJSON Geometry
124
- * @example
125
- * var type = "Point";
126
- * var coordinates = [110, 50];
127
- * var geometry = turf.geometry(type, coordinates);
128
- * // => geometry
129
- */
130
- function geometry(type, coordinates, _options) {
131
- if (_options === void 0) { _options = {}; }
132
- switch (type) {
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");
147
- }
148
- }
149
- exports.geometry = geometry;
150
- /**
151
- * Creates a {@link Point} {@link Feature} from a Position.
152
- *
153
- * @name point
154
- * @param {Array<number>} coordinates longitude, latitude position (each in decimal degrees)
155
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
156
- * @param {Object} [options={}] Optional Parameters
157
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
158
- * @param {string|number} [options.id] Identifier associated with the Feature
159
- * @returns {Feature<Point>} a Point feature
160
- * @example
161
- * var point = turf.point([-75.343, 39.984]);
162
- *
163
- * //=point
164
- */
165
- function point(coordinates, properties, options) {
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
- }
179
- var geom = {
180
- type: "Point",
181
- coordinates: coordinates,
182
- };
183
- return feature(geom, properties, options);
184
- }
185
- exports.point = point;
186
- /**
187
- * Creates a {@link Point} {@link FeatureCollection} from an Array of Point coordinates.
188
- *
189
- * @name points
190
- * @param {Array<Array<number>>} coordinates an array of Points
191
- * @param {Object} [properties={}] Translate these properties to each Feature
192
- * @param {Object} [options={}] Optional Parameters
193
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north]
194
- * associated with the FeatureCollection
195
- * @param {string|number} [options.id] Identifier associated with the FeatureCollection
196
- * @returns {FeatureCollection<Point>} Point Feature
197
- * @example
198
- * var points = turf.points([
199
- * [-75, 39],
200
- * [-80, 45],
201
- * [-78, 50]
202
- * ]);
203
- *
204
- * //=points
205
- */
206
- function points(coordinates, properties, options) {
207
- if (options === void 0) { options = {}; }
208
- return featureCollection(coordinates.map(function (coords) {
209
- return point(coords, properties);
210
- }), options);
211
- }
212
- exports.points = points;
213
- /**
214
- * Creates a {@link Polygon} {@link Feature} from an Array of LinearRings.
215
- *
216
- * @name polygon
217
- * @param {Array<Array<Array<number>>>} coordinates an array of LinearRings
218
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
219
- * @param {Object} [options={}] Optional Parameters
220
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
221
- * @param {string|number} [options.id] Identifier associated with the Feature
222
- * @returns {Feature<Polygon>} Polygon Feature
223
- * @example
224
- * var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], { name: 'poly1' });
225
- *
226
- * //=polygon
227
- */
228
- function polygon(coordinates, properties, options) {
229
- if (options === void 0) { options = {}; }
230
- for (var _i = 0, coordinates_1 = coordinates; _i < coordinates_1.length; _i++) {
231
- var ring = coordinates_1[_i];
232
- if (ring.length < 4) {
233
- throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
234
- }
235
- for (var j = 0; j < ring[ring.length - 1].length; j++) {
236
- // Check if first point of Polygon contains two numbers
237
- if (ring[ring.length - 1][j] !== ring[0][j]) {
238
- throw new Error("First and last Position are not equivalent.");
239
- }
240
- }
241
- }
242
- var geom = {
243
- type: "Polygon",
244
- coordinates: coordinates,
245
- };
246
- return feature(geom, properties, options);
247
- }
248
- exports.polygon = polygon;
249
- /**
250
- * Creates a {@link Polygon} {@link FeatureCollection} from an Array of Polygon coordinates.
251
- *
252
- * @name polygons
253
- * @param {Array<Array<Array<Array<number>>>>} coordinates an array of Polygon coordinates
254
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
255
- * @param {Object} [options={}] Optional Parameters
256
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
257
- * @param {string|number} [options.id] Identifier associated with the FeatureCollection
258
- * @returns {FeatureCollection<Polygon>} Polygon FeatureCollection
259
- * @example
260
- * var polygons = turf.polygons([
261
- * [[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]],
262
- * [[[-15, 42], [-14, 46], [-12, 41], [-17, 44], [-15, 42]]],
263
- * ]);
264
- *
265
- * //=polygons
266
- */
267
- function polygons(coordinates, properties, options) {
268
- if (options === void 0) { options = {}; }
269
- return featureCollection(coordinates.map(function (coords) {
270
- return polygon(coords, properties);
271
- }), options);
272
- }
273
- exports.polygons = polygons;
274
- /**
275
- * Creates a {@link LineString} {@link Feature} from an Array of Positions.
276
- *
277
- * @name lineString
278
- * @param {Array<Array<number>>} coordinates an array of Positions
279
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
280
- * @param {Object} [options={}] Optional Parameters
281
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
282
- * @param {string|number} [options.id] Identifier associated with the Feature
283
- * @returns {Feature<LineString>} LineString Feature
284
- * @example
285
- * var linestring1 = turf.lineString([[-24, 63], [-23, 60], [-25, 65], [-20, 69]], {name: 'line 1'});
286
- * var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]], {name: 'line 2'});
287
- *
288
- * //=linestring1
289
- * //=linestring2
290
- */
291
- function lineString(coordinates, properties, options) {
292
- if (options === void 0) { options = {}; }
293
- if (coordinates.length < 2) {
294
- throw new Error("coordinates must be an array of two or more positions");
295
- }
296
- var geom = {
297
- type: "LineString",
298
- coordinates: coordinates,
299
- };
300
- return feature(geom, properties, options);
301
- }
302
- exports.lineString = lineString;
303
- /**
304
- * Creates a {@link LineString} {@link FeatureCollection} from an Array of LineString coordinates.
305
- *
306
- * @name lineStrings
307
- * @param {Array<Array<Array<number>>>} coordinates an array of LinearRings
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]
311
- * associated with the FeatureCollection
312
- * @param {string|number} [options.id] Identifier associated with the FeatureCollection
313
- * @returns {FeatureCollection<LineString>} LineString FeatureCollection
314
- * @example
315
- * var linestrings = turf.lineStrings([
316
- * [[-24, 63], [-23, 60], [-25, 65], [-20, 69]],
317
- * [[-14, 43], [-13, 40], [-15, 45], [-10, 49]]
318
- * ]);
319
- *
320
- * //=linestrings
321
- */
322
- function lineStrings(coordinates, properties, options) {
323
- if (options === void 0) { options = {}; }
324
- return featureCollection(coordinates.map(function (coords) {
325
- return lineString(coords, properties);
326
- }), options);
327
- }
328
- exports.lineStrings = lineStrings;
329
- /**
330
- * Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.
331
- *
332
- * @name featureCollection
333
- * @param {Feature[]} features input features
334
- * @param {Object} [options={}] Optional Parameters
335
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
336
- * @param {string|number} [options.id] Identifier associated with the Feature
337
- * @returns {FeatureCollection} FeatureCollection of Features
338
- * @example
339
- * var locationA = turf.point([-75.343, 39.984], {name: 'Location A'});
340
- * var locationB = turf.point([-75.833, 39.284], {name: 'Location B'});
341
- * var locationC = turf.point([-75.534, 39.123], {name: 'Location C'});
342
- *
343
- * var collection = turf.featureCollection([
344
- * locationA,
345
- * locationB,
346
- * locationC
347
- * ]);
348
- *
349
- * //=collection
350
- */
351
- function featureCollection(features, options) {
352
- if (options === void 0) { options = {}; }
353
- var fc = { type: "FeatureCollection" };
354
- if (options.id) {
355
- fc.id = options.id;
356
- }
357
- if (options.bbox) {
358
- fc.bbox = options.bbox;
359
- }
360
- fc.features = features;
361
- return fc;
362
- }
363
- exports.featureCollection = featureCollection;
364
- /**
365
- * Creates a {@link Feature<MultiLineString>} based on a
366
- * coordinate array. Properties can be added optionally.
367
- *
368
- * @name multiLineString
369
- * @param {Array<Array<Array<number>>>} coordinates an array of LineStrings
370
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
371
- * @param {Object} [options={}] Optional Parameters
372
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
373
- * @param {string|number} [options.id] Identifier associated with the Feature
374
- * @returns {Feature<MultiLineString>} a MultiLineString feature
375
- * @throws {Error} if no coordinates are passed
376
- * @example
377
- * var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
378
- *
379
- * //=multiLine
380
- */
381
- function multiLineString(coordinates, properties, options) {
382
- if (options === void 0) { options = {}; }
383
- var geom = {
384
- type: "MultiLineString",
385
- coordinates: coordinates,
386
- };
387
- return feature(geom, properties, options);
388
- }
389
- exports.multiLineString = multiLineString;
390
- /**
391
- * Creates a {@link Feature<MultiPoint>} based on a
392
- * coordinate array. Properties can be added optionally.
393
- *
394
- * @name multiPoint
395
- * @param {Array<Array<number>>} coordinates an array of Positions
396
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
397
- * @param {Object} [options={}] Optional Parameters
398
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
399
- * @param {string|number} [options.id] Identifier associated with the Feature
400
- * @returns {Feature<MultiPoint>} a MultiPoint feature
401
- * @throws {Error} if no coordinates are passed
402
- * @example
403
- * var multiPt = turf.multiPoint([[0,0],[10,10]]);
404
- *
405
- * //=multiPt
406
- */
407
- function multiPoint(coordinates, properties, options) {
408
- if (options === void 0) { options = {}; }
409
- var geom = {
410
- type: "MultiPoint",
411
- coordinates: coordinates,
412
- };
413
- return feature(geom, properties, options);
414
- }
415
- exports.multiPoint = multiPoint;
416
- /**
417
- * Creates a {@link Feature<MultiPolygon>} based on a
418
- * coordinate array. Properties can be added optionally.
419
- *
420
- * @name multiPolygon
421
- * @param {Array<Array<Array<Array<number>>>>} coordinates an array of Polygons
422
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
423
- * @param {Object} [options={}] Optional Parameters
424
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
425
- * @param {string|number} [options.id] Identifier associated with the Feature
426
- * @returns {Feature<MultiPolygon>} a multipolygon feature
427
- * @throws {Error} if no coordinates are passed
428
- * @example
429
- * var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
430
- *
431
- * //=multiPoly
432
- *
433
- */
434
- function multiPolygon(coordinates, properties, options) {
435
- if (options === void 0) { options = {}; }
436
- var geom = {
437
- type: "MultiPolygon",
438
- coordinates: coordinates,
439
- };
440
- return feature(geom, properties, options);
441
- }
442
- exports.multiPolygon = multiPolygon;
443
- /**
444
- * Creates a {@link Feature<GeometryCollection>} based on a
445
- * coordinate array. Properties can be added optionally.
446
- *
447
- * @name geometryCollection
448
- * @param {Array<Geometry>} geometries an array of GeoJSON Geometries
449
- * @param {Object} [properties={}] an Object of key-value pairs to add as properties
450
- * @param {Object} [options={}] Optional Parameters
451
- * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
452
- * @param {string|number} [options.id] Identifier associated with the Feature
453
- * @returns {Feature<GeometryCollection>} a GeoJSON GeometryCollection Feature
454
- * @example
455
- * var pt = turf.geometry("Point", [100, 0]);
456
- * var line = turf.geometry("LineString", [[101, 0], [102, 1]]);
457
- * var collection = turf.geometryCollection([pt, line]);
458
- *
459
- * // => collection
460
- */
461
- function geometryCollection(geometries, properties, options) {
462
- if (options === void 0) { options = {}; }
463
- var geom = {
464
- type: "GeometryCollection",
465
- geometries: geometries,
466
- };
467
- return feature(geom, properties, options);
468
- }
469
- exports.geometryCollection = geometryCollection;
470
- /**
471
- * Round number to precision
472
- *
473
- * @param {number} num Number
474
- * @param {number} [precision=0] Precision
475
- * @returns {number} rounded number
476
- * @example
477
- * turf.round(120.4321)
478
- * //=120
479
- *
480
- * turf.round(120.4321, 2)
481
- * //=120.43
482
- */
483
- function round(num, precision) {
484
- if (precision === void 0) { precision = 0; }
485
- if (precision && !(precision >= 0)) {
486
- throw new Error("precision must be a positive number");
487
- }
488
- var multiplier = Math.pow(10, precision || 0);
489
- return Math.round(num * multiplier) / multiplier;
490
- }
491
- exports.round = round;
492
- /**
493
- * Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
494
- * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
495
- *
496
- * @name radiansToLength
497
- * @param {number} radians in radians across the sphere
498
- * @param {string} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
499
- * meters, kilometres, kilometers.
500
- * @returns {number} distance
501
- */
502
- function radiansToLength(radians, units) {
503
- if (units === void 0) { units = "kilometers"; }
504
- var factor = exports.factors[units];
505
- if (!factor) {
506
- throw new Error(units + " units is invalid");
507
- }
508
- return radians * factor;
509
- }
510
- exports.radiansToLength = radiansToLength;
511
- /**
512
- * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
513
- * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
514
- *
515
- * @name lengthToRadians
516
- * @param {number} distance in real units
517
- * @param {string} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
518
- * meters, kilometres, kilometers.
519
- * @returns {number} radians
520
- */
521
- function lengthToRadians(distance, units) {
522
- if (units === void 0) { units = "kilometers"; }
523
- var factor = exports.factors[units];
524
- if (!factor) {
525
- throw new Error(units + " units is invalid");
526
- }
527
- return distance / factor;
528
- }
529
- exports.lengthToRadians = lengthToRadians;
530
- /**
531
- * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
532
- * Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
533
- *
534
- * @name lengthToDegrees
535
- * @param {number} distance in real units
536
- * @param {string} [units="kilometers"] can be degrees, radians, miles, inches, yards, metres,
537
- * meters, kilometres, kilometers.
538
- * @returns {number} degrees
539
- */
540
- function lengthToDegrees(distance, units) {
541
- return radiansToDegrees(lengthToRadians(distance, units));
542
- }
543
- exports.lengthToDegrees = lengthToDegrees;
544
- /**
545
- * Converts any bearing angle from the north line direction (positive clockwise)
546
- * and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
547
- *
548
- * @name bearingToAzimuth
549
- * @param {number} bearing angle, between -180 and +180 degrees
550
- * @returns {number} angle between 0 and 360 degrees
551
- */
552
- function bearingToAzimuth(bearing) {
553
- var angle = bearing % 360;
554
- if (angle < 0) {
555
- angle += 360;
556
- }
557
- return angle;
558
- }
559
- exports.bearingToAzimuth = bearingToAzimuth;
560
- /**
561
- * Converts an angle in radians to degrees
562
- *
563
- * @name radiansToDegrees
564
- * @param {number} radians angle in radians
565
- * @returns {number} degrees between 0 and 360 degrees
566
- */
567
- function radiansToDegrees(radians) {
568
- var degrees = radians % (2 * Math.PI);
569
- return (degrees * 180) / Math.PI;
570
- }
571
- exports.radiansToDegrees = radiansToDegrees;
572
- /**
573
- * Converts an angle in degrees to radians
574
- *
575
- * @name degreesToRadians
576
- * @param {number} degrees angle between 0 and 360 degrees
577
- * @returns {number} angle in radians
578
- */
579
- function degreesToRadians(degrees) {
580
- var radians = degrees % 360;
581
- return (radians * Math.PI) / 180;
582
- }
583
- exports.degreesToRadians = degreesToRadians;
584
- /**
585
- * Converts a length to the requested unit.
586
- * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
587
- *
588
- * @param {number} length to be converted
589
- * @param {Units} [originalUnit="kilometers"] of the length
590
- * @param {Units} [finalUnit="kilometers"] returned unit
591
- * @returns {number} the converted length
592
- */
593
- function convertLength(length, originalUnit, finalUnit) {
594
- if (originalUnit === void 0) { originalUnit = "kilometers"; }
595
- if (finalUnit === void 0) { finalUnit = "kilometers"; }
596
- if (!(length >= 0)) {
597
- throw new Error("length must be a positive number");
598
- }
599
- return radiansToLength(lengthToRadians(length, originalUnit), finalUnit);
600
- }
601
- exports.convertLength = convertLength;
602
- /**
603
- * Converts a area to the requested unit.
604
- * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches, hectares
605
- * @param {number} area to be converted
606
- * @param {Units} [originalUnit="meters"] of the distance
607
- * @param {Units} [finalUnit="kilometers"] returned unit
608
- * @returns {number} the converted area
609
- */
610
- function convertArea(area, originalUnit, finalUnit) {
611
- if (originalUnit === void 0) { originalUnit = "meters"; }
612
- if (finalUnit === void 0) { finalUnit = "kilometers"; }
613
- if (!(area >= 0)) {
614
- throw new Error("area must be a positive number");
615
- }
616
- var startFactor = exports.areaFactors[originalUnit];
617
- if (!startFactor) {
618
- throw new Error("invalid original units");
619
- }
620
- var finalFactor = exports.areaFactors[finalUnit];
621
- if (!finalFactor) {
622
- throw new Error("invalid final units");
623
- }
624
- return (area / startFactor) * finalFactor;
625
- }
626
- exports.convertArea = convertArea;
627
- /**
628
- * isNumber
629
- *
630
- * @param {*} num Number to validate
631
- * @returns {boolean} true/false
632
- * @example
633
- * turf.isNumber(123)
634
- * //=true
635
- * turf.isNumber('foo')
636
- * //=false
637
- */
638
- function isNumber(num) {
639
- return !isNaN(num) && num !== null && !Array.isArray(num);
640
- }
641
- exports.isNumber = isNumber;
642
- /**
643
- * isObject
644
- *
645
- * @param {*} input variable to validate
646
- * @returns {boolean} true/false
647
- * @example
648
- * turf.isObject({elevation: 10})
649
- * //=true
650
- * turf.isObject('foo')
651
- * //=false
652
- */
653
- function isObject(input) {
654
- return !!input && input.constructor === Object;
655
- }
656
- exports.isObject = isObject;
657
- /**
658
- * Validate BBox
659
- *
660
- * @private
661
- * @param {Array<number>} bbox BBox to validate
662
- * @returns {void}
663
- * @throws Error if BBox is not valid
664
- * @example
665
- * validateBBox([-180, -40, 110, 50])
666
- * //=OK
667
- * validateBBox([-180, -40])
668
- * //=Error
669
- * validateBBox('Foo')
670
- * //=Error
671
- * validateBBox(5)
672
- * //=Error
673
- * validateBBox(null)
674
- * //=Error
675
- * validateBBox(undefined)
676
- * //=Error
677
- */
678
- function validateBBox(bbox) {
679
- if (!bbox) {
680
- throw new Error("bbox is required");
681
- }
682
- if (!Array.isArray(bbox)) {
683
- throw new Error("bbox must be an Array");
684
- }
685
- if (bbox.length !== 4 && bbox.length !== 6) {
686
- throw new Error("bbox must be an Array of 4 or 6 numbers");
687
- }
688
- bbox.forEach(function (num) {
689
- if (!isNumber(num)) {
690
- throw new Error("bbox must only contain numbers");
691
- }
692
- });
693
- }
694
- exports.validateBBox = validateBBox;
695
- /**
696
- * Validate Id
697
- *
698
- * @private
699
- * @param {string|number} id Id to validate
700
- * @returns {void}
701
- * @throws Error if Id is not valid
702
- * @example
703
- * validateId([-180, -40, 110, 50])
704
- * //=Error
705
- * validateId([-180, -40])
706
- * //=Error
707
- * validateId('Foo')
708
- * //=OK
709
- * validateId(5)
710
- * //=OK
711
- * validateId(null)
712
- * //=Error
713
- * validateId(undefined)
714
- * //=Error
715
- */
716
- function validateId(id) {
717
- if (!id) {
718
- throw new Error("id is required");
719
- }
720
- if (["string", "number"].indexOf(typeof id) === -1) {
721
- throw new Error("id must be a number or a string");
722
- }
723
- }
724
- exports.validateId = validateId;