@kalisio/common-geospatial 0.8.0 → 0.9.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/index.mjs CHANGED
@@ -1,149 +1,375 @@
1
- import { assert as u, is as i, has as w, conform as E, optional as p } from "@kalisio/common-core";
2
- import { coordAll as R } from "@turf/meta";
3
- import { convex as de } from "@turf/convex";
4
- import { featureCollection as ve, feature as he } from "@turf/helpers";
5
- import { Heap as pe } from "heap-js";
6
- import Ee from "@turf/truncate";
7
- import ye from "@turf/boolean-clockwise";
8
- import Oe from "@turf/kinks";
9
- const d = {
1
+ import { optional as h, is as l, conform as V, assert as _, object as St } from "@kalisio/common-core";
2
+ import b from "proj4";
3
+ import { coordAll as W } from "@turf/meta";
4
+ import { convex as _t } from "@turf/convex";
5
+ import { featureCollection as ht, feature as bt } from "@turf/helpers";
6
+ import Rt from "@turf/buffer";
7
+ import { Heap as Dt } from "heap-js";
8
+ const ie = typeof process > "u" || process.env?.NODE_ENV !== "production";
9
+ class Ie extends Error {
10
+ constructor(t) {
11
+ super(t), this.name = "AssertionError";
12
+ }
13
+ }
14
+ function ye(e, t, n) {
15
+ if (!t(e)) throw new Ie(n);
16
+ }
17
+ const u = {
18
+ that(e, t, n) {
19
+ ie && ye(e, t, n);
20
+ },
21
+ all(e) {
22
+ if (ie)
23
+ for (const { value: t, validator: n, message: r } of e)
24
+ ye(t, n, r);
25
+ },
26
+ any(e) {
27
+ if (!(!ie || e.length === 0) && !e.some(({ value: t, validator: n }) => n(t)))
28
+ throw new Ie(e.map(({ message: t }) => t).join(" or "));
29
+ }
30
+ }, a = {
31
+ defined(e) {
32
+ return e != null;
33
+ },
34
+ nil(e) {
35
+ return !a.defined(e);
36
+ },
37
+ plainObject(e) {
38
+ return a.defined(e) && typeof e == "object" && !Array.isArray(e) && e.constructor === Object;
39
+ },
40
+ emptyObject(e) {
41
+ return a.plainObject(e) && Object.keys(e).length === 0;
42
+ },
43
+ nonEmptyObject(e) {
44
+ return a.plainObject(e) && Object.keys(e).length > 0;
45
+ },
46
+ boolean(e) {
47
+ return typeof e == "boolean";
48
+ },
49
+ booleanTrue(e) {
50
+ return e === !0;
51
+ },
52
+ booleanFalse(e) {
53
+ return e === !1;
54
+ },
55
+ string(e) {
56
+ return typeof e == "string";
57
+ },
58
+ emptyString(e) {
59
+ return a.string(e) && e.trim().length === 0;
60
+ },
61
+ nonEmptyString(e) {
62
+ return a.string(e) && e.trim().length > 0;
63
+ },
64
+ char(e) {
65
+ return a.string(e) && /^.$/u.test(e);
66
+ },
67
+ hex(e) {
68
+ return a.nonEmptyString(e) && e.length % 2 === 0 && /^[0-9a-fA-F]*$/.test(e);
69
+ },
70
+ dataUri(e) {
71
+ return a.string(e) ? e.startsWith("data:") && e.includes(";base64,") : !1;
72
+ },
73
+ url(e) {
74
+ if (typeof e != "string") return !1;
75
+ const t = /^([a-z][a-z0-9+.-]*:\/\/)([^/?#]+)(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i.exec(e);
76
+ if (!t?.[2].includes(",")) return URL.canParse(e);
77
+ const [, n, r, i = "", s = "", o = ""] = t;
78
+ return r.split(",").every((c, g) => (c = c.trim(), !c || g > 0 && c.includes("@") ? !1 : URL.canParse(`${n}${c}${i}${s}${o}`)));
79
+ },
80
+ email(e) {
81
+ if (!a.string(e)) return !1;
82
+ const t = /^[-!#$%&'*+/0-9=?A-Z^_a-z`{|}~](\.?[-!#$%&'*+/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-?\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/, [n, r] = e.split("@");
83
+ return !n || !r || n.length > 64 || r.length > 255 || r.split(".").some((i) => i.length > 63) ? !1 : t.test(e);
84
+ },
85
+ regularExpression(e) {
86
+ return a.defined(e) && e instanceof RegExp;
87
+ },
88
+ number(e) {
89
+ return typeof e == "number" && !isNaN(e) && isFinite(e);
90
+ },
91
+ positive(e) {
92
+ return a.number(e) && e > 0;
93
+ },
94
+ nonPositive(e) {
95
+ return a.number(e) && e <= 0;
96
+ },
97
+ negative(e) {
98
+ return a.number(e) && e < 0;
99
+ },
100
+ nonNegative(e) {
101
+ return a.number(e) && e >= 0;
102
+ },
103
+ inRange(e, t, n) {
104
+ return u.that(n, (r) => r >= t, "max must be greater than or equal to min"), a.number(e) && e >= t && e <= n;
105
+ },
106
+ inRangeExclusive(e, t, n) {
107
+ return u.that(n, (r) => r > t, "max must be greater than min"), a.number(e) && e > t && e < n;
108
+ },
109
+ inRangeExclusiveMin(e, t, n) {
110
+ return u.that(n, (r) => r > t, "max must be greater than min"), a.number(e) && e > t && e <= n;
111
+ },
112
+ inRangeExclusiveMax(e, t, n) {
113
+ return u.that(n, (r) => r >= t, "max must be greater than or equal to min"), a.number(e) && e >= t && e < n;
114
+ },
115
+ integer(e) {
116
+ return a.number(e) && Number.isInteger(e);
117
+ },
118
+ positiveInteger(e) {
119
+ return a.integer(e) && a.positive(e);
120
+ },
121
+ nonPositiveInteger(e) {
122
+ return a.integer(e) && a.nonPositive(e);
123
+ },
124
+ negativeInteger(e) {
125
+ return a.integer(e) && a.negative(e);
126
+ },
127
+ nonNegativeInteger(e) {
128
+ return a.integer(e) && a.nonNegative(e);
129
+ },
130
+ array(e) {
131
+ return Array.isArray(e);
132
+ },
133
+ emptyArray(e) {
134
+ return a.array(e) && e.length === 0;
135
+ },
136
+ nonEmptyArray(e) {
137
+ return a.array(e) && e.length > 0;
138
+ },
139
+ arrayOfLength(e, t) {
140
+ return u.that(t, a.nonNegativeInteger, "length must be a non negative integer"), a.array(e) && e.length === t;
141
+ },
142
+ arrayOfLengthAtLeast(e, t) {
143
+ return u.that(t, a.nonNegativeInteger, "minLength must be a non negative integer"), a.array(e) && e.length >= t;
144
+ },
145
+ arrayOfLengthAtMost(e, t) {
146
+ return u.that(t, a.nonNegativeInteger, "maxLength must be a non negative integer"), a.array(e) && e.length <= t;
147
+ },
148
+ arrayOfLengthBetween(e, t, n) {
149
+ return u.all([
150
+ { value: t, validator: a.nonNegativeInteger, message: "minLength must be a non negative integer" },
151
+ { value: n, validator: a.nonNegativeInteger, message: "maxLength must be a non negative integer" },
152
+ { value: t, validator: (r) => r <= n, message: "minLength must be less than or equal to maxLength" }
153
+ ]), a.array(e) && e.length >= t && e.length <= n;
154
+ },
155
+ map(e) {
156
+ return a.defined(e) && e instanceof Map;
157
+ },
158
+ emptyMap(e) {
159
+ return a.map(e) && e.size === 0;
160
+ },
161
+ nonEmptyMap(e) {
162
+ return a.map(e) && e.size > 0;
163
+ },
164
+ set(e) {
165
+ return a.defined(e) && e instanceof Set;
166
+ },
167
+ emptySet(e) {
168
+ return a.set(e) && e.size === 0;
169
+ },
170
+ nonEmptySet(e) {
171
+ return a.set(e) && e.size > 0;
172
+ },
173
+ function(e) {
174
+ return typeof e == "function";
175
+ },
176
+ oneOf(e, t) {
177
+ return u.that(t, a.nonEmptyArray, "allowed values must be a non empty array"), t.includes(e);
178
+ },
179
+ empty(e) {
180
+ return a.nil(e) ? !0 : a.string(e) ? a.emptyString(e) : a.array(e) ? a.emptyArray(e) : a.plainObject(e) ? a.emptyObject(e) : a.map(e) ? a.emptyMap(e) : a.set(e) ? a.emptySet(e) : !1;
181
+ }
182
+ }, A = {
183
+ key(e, t) {
184
+ return u.all([
185
+ { value: e, validator: a.plainObject, message: "obj must be an object" },
186
+ { value: t, validator: a.nonEmptyString, message: "key must be a non empty string" }
187
+ ]), Object.hasOwn(e, t);
188
+ },
189
+ keys(e, t) {
190
+ return u.all([
191
+ { value: e, validator: a.plainObject, message: "obj must be an object" },
192
+ { value: t, validator: (n) => a.array(n) && n.length > 0 && n.every(a.nonEmptyString), message: "keys must be an array of non empty strings" }
193
+ ]), t.every((n) => A.key(e, n));
194
+ },
195
+ keyWithValue(e, t) {
196
+ return A.key(e, t) && a.defined(e[t]);
197
+ },
198
+ path(e, t) {
199
+ u.all([
200
+ { value: e, validator: a.plainObject, message: "obj must be an object" },
201
+ { value: t, validator: a.nonEmptyString, message: "path must be a non empty string" }
202
+ ]);
203
+ let n = e;
204
+ for (const r of t.split(".")) {
205
+ if (!n || !a.plainObject(n) || !(r in n)) return !1;
206
+ n = n[r];
207
+ }
208
+ return !0;
209
+ }
210
+ };
211
+ function Ye(e, t, n = "") {
212
+ return Object.entries(t).every(([r, i]) => {
213
+ const s = n ? `${n}.${r}` : r;
214
+ if (!A.key(e, r))
215
+ return i._optional === !0;
216
+ const o = e[r];
217
+ if (a.plainObject(i))
218
+ return a.plainObject(o) && Ye(o, i, s);
219
+ if (typeof i == "function")
220
+ return i(o);
221
+ throw new Ie(`Invalid validator for key "${s}"`);
222
+ });
223
+ }
224
+ const y = {
225
+ schema(e, t) {
226
+ return u.all([
227
+ { value: e, validator: a.plainObject, message: "obj must be an object" },
228
+ { value: t, validator: a.plainObject, message: "schema must be an object" }
229
+ ]), Ye(e, t);
230
+ }
231
+ };
232
+ function N(e) {
233
+ u.that(e, a.function, "validator must be a function");
234
+ function t(n) {
235
+ return a.nil(n) ? !0 : e(n);
236
+ }
237
+ return t._optional = !0, t;
238
+ }
239
+ const O = {
10
240
  LATITUDE: "LAT",
11
241
  LONGITUDE: "LON",
12
242
  ALTITUDE: "ALT"
13
243
  };
14
- function Te(e) {
15
- return u.that(e, i.string, "axis must be a string"), Object.values(d).includes(e);
244
+ function He(e) {
245
+ return u.that(e, a.string, "axis must be a string"), Object.values(O).includes(e);
16
246
  }
17
- function k(e) {
18
- return u.that(e, i.string, "axis must be a string"), e === d.LATITUDE;
247
+ function X(e) {
248
+ return u.that(e, a.string, "axis must be a string"), e === O.LATITUDE;
19
249
  }
20
- function ne(e) {
21
- return u.that(e, i.string, "axis must be a string"), e === d.LONGITUDE;
250
+ function Ee(e) {
251
+ return u.that(e, a.string, "axis must be a string"), e === O.LONGITUDE;
22
252
  }
23
- function Ot(e) {
24
- return u.that(e, i.string, "axis must be a string"), e === d.ALTITUDE;
253
+ function zn(e) {
254
+ return u.that(e, a.string, "axis must be a string"), e === O.ALTITUDE;
25
255
  }
26
- const Ie = { NORTH: { label: "Nord", symbol: "N" }, SOUTH: { label: "Sud", symbol: "S" }, EAST: { label: "Est", symbol: "E" }, WEST: { label: "Ouest", symbol: "O" } }, Le = {
27
- DIRECTIONS: Ie
28
- }, Se = { NORTH: { label: "North", symbol: "N" }, SOUTH: { label: "South", symbol: "S" }, EAST: { label: "East", symbol: "E" }, WEST: { label: "West", symbol: "W" } }, be = {
29
- DIRECTIONS: Se
30
- }, De = {
256
+ const At = { NORTH: { label: "Nord", symbol: "N" }, SOUTH: { label: "Sud", symbol: "S" }, EAST: { label: "Est", symbol: "E" }, WEST: { label: "Ouest", symbol: "O" } }, yt = { EMPTY_OBJECT: "L'objet est vide", UNKNOWN_TYPE: "Le type GeoJSON est inconnu", MISSING_GEOMETRY: "La géométrie est manquante", INVALID_FEATURES_ARRAY: "Le tableau de features est invalide", INVALID_GEOMETRY: "La géométrie est invalide", INVALID_GEOMETRY_TYPE: "Le type de géométrie est invalide", INVALID_COORDINATES_LENGTH: "Le nombre de coordonnées est invalide", INVALID_MULTI_LINESTRING_COORDINATES: "Les coordonnées du MultiLineString sont invalides", INVALID_POLYGON_COORDINATES: "Les coordonnées du Polygon sont invalides", INVALID_MULTIPOLYGON_COORDINATES: "Les coordonnées du MultiPolygon sont invalides", INVALID_GEOMETRYCOLLECTION_GEOMETRIES: "Les géométries de la GeometryCollection sont invalides", RING_NOT_CLOSED: "L'anneau n'est pas fermé", INVALID_WINDING_ORDER: "L'ordre d'orientation de l'anneau est invalide", SELF_INTERSECTION: "Une auto-intersection a été détectée", HOLE_INTERSECTS_SHELL: "Un trou intersecte le contour extérieur", ANTIMERIDIAN_CROSSING: "La géométrie traverse l'antiméridien", DUPLICATE_POSITION: "Une position consécutive est dupliquée", INVALID_POSITION_LENGTH: "Le nombre de coordonnées de la position est invalide", INVALID_POSITION_COORDINATES: "Les coordonnées de la position sont invalides", INVALID_LONGITUDE_RANGE: "La longitude est hors limites", INVALID_LATITUDE_RANGE: "La latitude est hors limites", INVALID_ALTITUDE: "L'altitude est invalide", EXCESSIVE_LONGITUDE_PRECISION: "La précision de la longitude est excessive", EXCESSIVE_LATITUDE_PRECISION: "La précision de la latitude est excessive", INVALID_BBOX_LENGTH: "Le nombre de coordonnées de la boîte englobante est invalide", INVALID_BBOX_LATITUDE_ORDER: "L'ordre des latitudes de la boîte englobante est invalide", INVALID_BBOX_LONGITUDE_ORDER: "L'ordre des longitudes de la boîte englobante est invalide", INVALID_BBOX_ALTITUDE_ORDER: "L'ordre des altitudes de la boîte englobante est invalide", BBOX_ANTIMERIDIAN_CROSSING: "La boîte englobante traverse l'antiméridien", INVALID_CRS_OBJECT: "L'objet CRS est invalide", INVALID_CRS_NAME: "Le nom du CRS est invalide", INVALID_CRS_LINK: "Le lien du CRS est invalide", INVALID_CRS_TYPE: "Le type de CRS est invalide", UNSUPPORTED_CRS: "Le CRS n'est pas pris en charge", UNSUPPORTED_LINK_CRS: "Le lien CRS n'est pas pris en charge", UNSUPPORTED_NESTED_CRS: "Le CRS imbriqué n'est pas pris en charge" }, Ct = {
257
+ DIRECTIONS: At,
258
+ VALIDATION: yt
259
+ }, Gt = { NORTH: { label: "North", symbol: "N" }, SOUTH: { label: "South", symbol: "S" }, EAST: { label: "East", symbol: "E" }, WEST: { label: "West", symbol: "W" } }, Mt = { EMPTY_OBJECT: "Object is empty", UNKNOWN_TYPE: "Unknown GeoJSON type", MISSING_GEOMETRY: "Geometry is missing", INVALID_FEATURES_ARRAY: "Features array is invalid", INVALID_GEOMETRY: "Geometry is invalid", INVALID_GEOMETRY_TYPE: "Geometry type is invalid", INVALID_COORDINATES_LENGTH: "Coordinates length is invalid", INVALID_MULTI_LINESTRING_COORDINATES: "MultiLineString coordinates are invalid", INVALID_POLYGON_COORDINATES: "Polygon coordinates are invalid", INVALID_MULTIPOLYGON_COORDINATES: "MultiPolygon coordinates are invalid", INVALID_GEOMETRYCOLLECTION_GEOMETRIES: "GeometryCollection geometries are invalid", RING_NOT_CLOSED: "Ring is not closed", INVALID_WINDING_ORDER: "Ring winding order is invalid", SELF_INTERSECTION: "Self-intersection detected", HOLE_INTERSECTS_SHELL: "A hole intersects the exterior ring", ANTIMERIDIAN_CROSSING: "Geometry crosses the antimeridian", DUPLICATE_POSITION: "Consecutive position is duplicated", INVALID_POSITION_LENGTH: "Position length is invalid", INVALID_POSITION_COORDINATES: "Position coordinates are invalid", INVALID_LONGITUDE_RANGE: "Longitude is out of range", INVALID_LATITUDE_RANGE: "Latitude is out of range", INVALID_ALTITUDE: "Altitude is invalid", EXCESSIVE_LONGITUDE_PRECISION: "Longitude precision is excessive", EXCESSIVE_LATITUDE_PRECISION: "Latitude precision is excessive", INVALID_BBOX_LENGTH: "Bounding box length is invalid", INVALID_BBOX_LATITUDE_ORDER: "Bounding box latitude order is invalid", INVALID_BBOX_LONGITUDE_ORDER: "Bounding box longitude order is invalid", INVALID_BBOX_ALTITUDE_ORDER: "Bounding box altitude order is invalid", BBOX_ANTIMERIDIAN_CROSSING: "Bounding box crosses the antimeridian", INVALID_CRS_OBJECT: "CRS object is invalid", INVALID_CRS_NAME: "CRS name is invalid", INVALID_CRS_LINK: "CRS link is invalid", INVALID_CRS_TYPE: "CRS type is invalid", UNSUPPORTED_CRS: "CRS is not supported", UNSUPPORTED_LINK_CRS: "CRS link is not supported", UNSUPPORTED_NESTED_CRS: "Nested CRS is not supported" }, We = {
260
+ DIRECTIONS: Gt,
261
+ VALIDATION: Mt
262
+ }, Pt = {
31
263
  DIRECTIONS: {
32
- NORTH: { label: i.string, symbol: i.char },
33
- SOUTH: { label: i.string, symbol: i.char },
34
- EAST: { label: i.string, symbol: i.char },
35
- WEST: { label: i.string, symbol: i.char }
264
+ NORTH: { label: a.string, symbol: a.char },
265
+ SOUTH: { label: a.string, symbol: a.char },
266
+ EAST: { label: a.string, symbol: a.char },
267
+ WEST: { label: a.string, symbol: a.char }
36
268
  }
37
- }, I = {
38
- en: be,
39
- fr: Le
269
+ }, P = {
270
+ en: We,
271
+ fr: Ct
40
272
  };
41
- let S = "en";
42
- const z = "en";
43
- function Tt() {
44
- return Object.keys(I);
273
+ let x = "en";
274
+ const Ce = "en";
275
+ function Kn() {
276
+ return Object.keys(P);
45
277
  }
46
- function It(e, t) {
278
+ function qn(e) {
47
279
  u.all([
48
- { value: e, validator: i.string, message: "code must be a string" },
49
- { value: e, validator: (n) => !w.key(I, n), message: "locale already registered" },
50
- { value: t, validator: i.plainObject, message: "content must be an object" },
51
- { value: t, validator: (n) => E.schema(n, De), message: "content does not conform to schema" }
52
- ]), I[e] = t;
280
+ { value: e, validator: a.string, message: "code must be a string" },
281
+ { value: e, validator: (t) => A.key(P, t), message: "code is unknown" }
282
+ ]), x = e;
53
283
  }
54
- function Lt(e) {
55
- u.all([
56
- { value: e, validator: i.string, message: "code must be a string" },
57
- { value: e, validator: (t) => w.key(I, t), message: "code is unknown" }
58
- ]), S = e;
284
+ function Ut() {
285
+ return x;
59
286
  }
60
- function Re() {
61
- return S;
287
+ function Xe() {
288
+ return x === Ce ? [x] : [x, Ce];
62
289
  }
63
- function B(e) {
290
+ function Zn(e, t) {
291
+ u.all([
292
+ { value: e, validator: a.string, message: "code must be a string" },
293
+ { value: e, validator: (n) => !A.key(P, n), message: "messages already registered" },
294
+ { value: t, validator: a.plainObject, message: "messages must be an object" },
295
+ { value: t, validator: (n) => y.schema(n, Pt), message: "messages do not conform to schema" }
296
+ ]), P[e] = t;
297
+ }
298
+ function Oe(e) {
64
299
  return u.all([
65
- { value: e, validator: i.string, message: "code must be a string" },
66
- { value: e, validator: (t) => w.key(I, t), message: "code is unknown" }
67
- ]), I[e];
300
+ { value: e, validator: a.string, message: "code must be a string" },
301
+ { value: e, validator: (t) => A.key(P, t), message: "code is unknown" }
302
+ ]), P[e];
68
303
  }
69
- function re() {
70
- return S === z ? [S] : [S, z];
304
+ function $() {
305
+ return Oe(Ut()).DIRECTIONS;
71
306
  }
72
- function H(e) {
307
+ function ae(e) {
73
308
  const t = /* @__PURE__ */ new Set();
74
- for (const n of re()) {
75
- const { DIRECTIONS: r } = B(n);
76
- for (const a of e) t.add(r[a].symbol);
309
+ for (const n of Xe()) {
310
+ const { DIRECTIONS: r } = Oe(n);
311
+ for (const i of e) t.add(r[i].symbol);
77
312
  }
78
313
  return [...t];
79
314
  }
80
- function Ae() {
81
- return H(["NORTH", "SOUTH"]);
82
- }
83
- function Me() {
84
- return H(["EAST", "WEST"]);
85
- }
86
- function j() {
87
- return H(["NORTH", "SOUTH", "EAST", "WEST"]);
88
- }
89
- function b() {
90
- return B(Re()).DIRECTIONS;
91
- }
92
- function _(e, t) {
315
+ function te(e, t) {
93
316
  const n = t.toUpperCase();
94
- return re().some((r) => {
95
- const { label: a, symbol: s } = B(r).DIRECTIONS[e];
96
- return n === a.toUpperCase() || n === s.toUpperCase();
317
+ return Xe().some((r) => {
318
+ const { label: i, symbol: s } = Oe(r).DIRECTIONS[e];
319
+ return n === i.toUpperCase() || n === s.toUpperCase();
97
320
  });
98
321
  }
99
- function St(e = null) {
100
- const t = b();
101
- return i.defined(e) ? (u.that(e, Te, "axis must be a valid axis"), k(e) ? [t.SOUTH, t.NORTH] : ne(e) ? [t.EAST, t.WEST] : []) : [t.SOUTH, t.NORTH, t.EAST, t.WEST];
102
- }
103
- function bt() {
104
- return b().NORTH;
322
+ function Qn(e = null) {
323
+ const t = $();
324
+ return a.defined(e) ? (u.that(e, He, "axis must be a valid axis"), X(e) ? [t.SOUTH, t.NORTH] : Ee(e) ? [t.EAST, t.WEST] : []) : [t.SOUTH, t.NORTH, t.EAST, t.WEST];
105
325
  }
106
- function Dt() {
107
- return b().SOUTH;
326
+ function B(e = null) {
327
+ return a.defined(e) ? (u.that(e, He, "axis must be a valid axis"), X(e) ? ae(["NORTH", "SOUTH"]) : Ee(e) ? ae(["EAST", "WEST"]) : []) : ae(["NORTH", "SOUTH", "EAST", "WEST"]);
108
328
  }
109
- function Rt() {
110
- return b().EAST;
329
+ function Jn() {
330
+ return $().NORTH;
111
331
  }
112
- function At() {
113
- return b().WEST;
332
+ function er() {
333
+ return $().SOUTH;
114
334
  }
115
- function O(e) {
116
- return u.that(e, i.string, "dir must be a string"), Ce(e) || ie(e) || V(e) || $(e);
335
+ function tr() {
336
+ return $().EAST;
117
337
  }
118
- function Ce(e) {
119
- return u.that(e, i.string, "dir must be a string"), _("NORTH", e);
338
+ function nr() {
339
+ return $().WEST;
120
340
  }
121
- function ie(e) {
122
- return u.that(e, i.string, "dir must be a string"), _("SOUTH", e);
341
+ function C(e) {
342
+ return u.that(e, a.string, "dir must be a string"), Vt(e) || ze(e) || Ne(e) || ne(e);
123
343
  }
124
- function V(e) {
125
- return u.that(e, i.string, "dir must be a string"), _("EAST", e);
344
+ function Vt(e) {
345
+ return u.that(e, a.string, "dir must be a string"), te("NORTH", e);
126
346
  }
127
- function $(e) {
128
- return u.that(e, i.string, "dir must be a string"), _("WEST", e);
347
+ function ze(e) {
348
+ return u.that(e, a.string, "dir must be a string"), te("SOUTH", e);
129
349
  }
130
350
  function Ne(e) {
131
- return u.that(e, O, "dir must be a direction"), $(e) || V(e) ? d.LONGITUDE : d.LATITUDE;
351
+ return u.that(e, a.string, "dir must be a string"), te("EAST", e);
352
+ }
353
+ function ne(e) {
354
+ return u.that(e, a.string, "dir must be a string"), te("WEST", e);
132
355
  }
133
- const we = {
134
- degrees: i.number,
135
- direction: p(O)
136
- }, _e = /^(-?\d{1,3}(?:\.\d+)?)°?$/;
137
- function $e() {
138
- return new RegExp(`^(\\d{1,3}(?:\\.\\d+)?)°?([${j()}])$`, "i");
356
+ function wt(e) {
357
+ return u.that(e, C, "dir must be a direction"), ne(e) || Ne(e) ? O.LONGITUDE : O.LATITUDE;
358
+ }
359
+ const jt = {
360
+ degrees: l.number,
361
+ direction: h(C)
362
+ }, xt = /^(-?\d{1,3}(?:\.\d+)?)°?$/;
363
+ function kt() {
364
+ return new RegExp(`^(\\d{1,3}(?:\\.\\d+)?)°?([${B()}])$`, "i");
139
365
  }
140
- function D(e) {
366
+ function Y(e) {
141
367
  let t = null, n = null;
142
- if (i.plainObject(e) && E.schema(e, we))
143
- i.defined(e.direction) ? e.degrees >= 0 && (t = e.degrees, n = e.direction) : t = e.degrees;
144
- else if (i.string(e)) {
145
- const r = e.replace(/\s+/g, ""), a = r.match(_e) ?? r.match($e());
146
- a && (t = parseFloat(a[1]), n = a[2] ?? null);
368
+ if (l.plainObject(e) && V.schema(e, jt))
369
+ l.defined(e.direction) ? e.degrees >= 0 && (t = e.degrees, n = e.direction) : t = e.degrees;
370
+ else if (l.string(e)) {
371
+ const r = e.replace(/\s+/g, ""), i = r.match(xt) ?? r.match(kt());
372
+ i && (t = parseFloat(i[1]), n = i[2] ?? null);
147
373
  }
148
374
  return {
149
375
  get degrees() {
@@ -156,32 +382,32 @@ function D(e) {
156
382
  return "DD";
157
383
  },
158
384
  isValid() {
159
- return i.number(t);
385
+ return l.number(t);
160
386
  },
161
387
  toString(r) {
162
- if (u.that(r, i.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
163
- let a = `${t.toFixed(r)}°`;
164
- return n && (a += ` ${n}`), a;
388
+ if (_.that(r, l.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
389
+ let i = `${t.toFixed(r)}°`;
390
+ return n && (i += ` ${n}`), i;
165
391
  },
166
392
  toDecimal() {
167
- return this.isValid() ? D({ degrees: t, direction: n }) : null;
393
+ return this.isValid() ? Y({ degrees: t, direction: n }) : null;
168
394
  }
169
395
  };
170
396
  }
171
- const Fe = {
172
- degrees: i.integer,
173
- minutes: (e) => i.inRangeExclusiveMax(e, 0, 60),
174
- direction: p(O)
175
- }, xe = /^(-?\d{1,3})°(\d{1,2}(?:\.\d+)?)'?$/;
176
- function Ue() {
177
- return new RegExp(`^(\\d{1,3})°(\\d{1,2}(?:\\.\\d+)?)'?([${j().join("")}])$`, "i");
397
+ const Ft = {
398
+ degrees: l.integer,
399
+ minutes: (e) => l.inRangeExclusiveMax(e, 0, 60),
400
+ direction: h(C)
401
+ }, $t = /^(-?\d{1,3})°(\d{1,2}(?:\.\d+)?)'?$/;
402
+ function Bt() {
403
+ return new RegExp(`^(\\d{1,3})°(\\d{1,2}(?:\\.\\d+)?)'?([${B().join("")}])$`, "i");
178
404
  }
179
- function ae(e) {
405
+ function Ke(e) {
180
406
  let t = null, n = null, r = null;
181
- if (i.plainObject(e) && E.schema(e, Fe))
182
- i.defined(e.direction) ? e.degrees >= 0 && (t = e.degrees, n = e.minutes, r = e.direction) : (t = e.degrees, n = e.minutes);
183
- else if (i.string(e)) {
184
- const a = e.replace(/\s+/g, ""), s = a.match(xe) ?? a.match(Ue());
407
+ if (l.plainObject(e) && V.schema(e, Ft))
408
+ l.defined(e.direction) ? e.degrees >= 0 && (t = e.degrees, n = e.minutes, r = e.direction) : (t = e.degrees, n = e.minutes);
409
+ else if (l.string(e)) {
410
+ const i = e.replace(/\s+/g, ""), s = i.match($t) ?? i.match(Bt());
185
411
  s && (t = parseFloat(s[1]), n = parseFloat(s[2]), r = s[3] ?? null);
186
412
  }
187
413
  return {
@@ -198,35 +424,35 @@ function ae(e) {
198
424
  return "DDM";
199
425
  },
200
426
  isValid() {
201
- return i.integer(t) && i.inRangeExclusiveMax(n, 0, 60);
427
+ return l.integer(t) && l.inRangeExclusiveMax(n, 0, 60);
202
428
  },
203
- toString(a) {
204
- if (u.that(a, i.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
205
- let s = `${t}° ${n.toFixed(a)}'`;
429
+ toString(i) {
430
+ if (_.that(i, l.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
431
+ let s = `${t}° ${n.toFixed(i)}'`;
206
432
  return r && (s += ` ${r}`), s;
207
433
  },
208
434
  toDecimal() {
209
- return this.isValid() ? D({ degrees: t + n / 60, direction: r }) : null;
435
+ return this.isValid() ? Y({ degrees: t + n / 60, direction: r }) : null;
210
436
  }
211
437
  };
212
438
  }
213
- const Ge = {
214
- degrees: i.nonNegativeInteger,
215
- minutes: (e) => i.inRangeExclusiveMax(e, 0, 60),
216
- direction: O
439
+ const Yt = {
440
+ degrees: l.nonNegativeInteger,
441
+ minutes: (e) => l.inRangeExclusiveMax(e, 0, 60),
442
+ direction: C
217
443
  };
218
- function ke() {
219
- return new RegExp(`^(\\d{2})(\\d{3})([${Ae().join("")}])$`, "i");
444
+ function Ht() {
445
+ return new RegExp(`^(\\d{2})(\\d{3})([${B(O.LATITUDE).join("")}])$`, "i");
220
446
  }
221
- function Pe() {
222
- return new RegExp(`^(\\d{3})(\\d{3})([${Me().join("")}])$`, "i");
447
+ function Wt() {
448
+ return new RegExp(`^(\\d{3})(\\d{3})([${B(O.LONGITUDE).join("")}])$`, "i");
223
449
  }
224
- function se(e) {
450
+ function qe(e) {
225
451
  let t = null, n = null, r = null;
226
- if (i.plainObject(e) && E.schema(e, Ge))
452
+ if (l.plainObject(e) && V.schema(e, Yt))
227
453
  t = e.degrees, n = e.minutes, r = e.direction;
228
- else if (i.string(e)) {
229
- const a = e.trim(), s = a.match(ke()) ?? a.match(Pe());
454
+ else if (l.string(e)) {
455
+ const i = e.trim(), s = i.match(Ht()) ?? i.match(Wt());
230
456
  s && (t = parseFloat(s[1]), n = parseFloat(s[2]) / 10, r = s[3]);
231
457
  }
232
458
  return {
@@ -243,34 +469,34 @@ function se(e) {
243
469
  return "DDM_AERO";
244
470
  },
245
471
  isValid() {
246
- return i.nonNegativeInteger(t) && i.inRangeExclusiveMax(n, 0, 60) && O(r);
472
+ return l.nonNegativeInteger(t) && l.inRangeExclusiveMax(n, 0, 60) && C(r);
247
473
  },
248
474
  toString() {
249
475
  if (!this.isValid()) return "";
250
- const a = V(r) || $(r), s = String(t).padStart(a ? 3 : 2, "0"), l = Math.floor(n * 10).toString().padStart(3, "0");
251
- return `${s}${l}${r}`;
476
+ const i = Ne(r) || ne(r), s = String(t).padStart(i ? 3 : 2, "0"), o = Math.floor(n * 10).toString().padStart(3, "0");
477
+ return `${s}${o}${r}`;
252
478
  },
253
479
  toDecimal() {
254
- return this.isValid() ? D({ degrees: t + n / 60, direction: r }) : null;
480
+ return this.isValid() ? Y({ degrees: t + n / 60, direction: r }) : null;
255
481
  }
256
482
  };
257
483
  }
258
- const Be = {
259
- degrees: i.integer,
260
- minutes: (e) => i.integer(e) && i.inRange(e, 0, 59),
261
- seconds: (e) => i.inRangeExclusiveMax(e, 0, 60),
262
- direction: p(O)
263
- }, He = /^(-?\d{1,3})°(\d{1,2})'(\d{1,2}(?:\.\d+)?)"?$/;
264
- function je() {
265
- return new RegExp(`^(\\d{1,3})°(\\d{1,2})'(\\d{1,2}(?:\\.\\d+)?)"?([${j().join("")}])$`, "i");
266
- }
267
- function oe(e) {
268
- let t = null, n = null, r = null, a = null;
269
- if (i.plainObject(e) && E.schema(e, Be))
270
- i.defined(e.direction) ? e.degrees >= 0 && (t = e.degrees, n = e.minutes, r = e.seconds, a = e.direction) : (t = e.degrees, n = e.minutes, r = e.seconds);
271
- else if (i.string(e)) {
272
- const s = e.replace(/\s+/g, ""), l = s.match(He) ?? s.match(je());
273
- l && (t = parseFloat(l[1]), n = parseFloat(l[2]), r = parseFloat(l[3]), a = l[4] ?? null);
484
+ const Xt = {
485
+ degrees: l.integer,
486
+ minutes: (e) => l.integer(e) && l.inRange(e, 0, 59),
487
+ seconds: (e) => l.inRangeExclusiveMax(e, 0, 60),
488
+ direction: h(C)
489
+ }, zt = /^(-?\d{1,3})°(\d{1,2})'(\d{1,2}(?:\.\d+)?)"?$/;
490
+ function Kt() {
491
+ return new RegExp(`^(\\d{1,3})°(\\d{1,2})'(\\d{1,2}(?:\\.\\d+)?)"?([${B().join("")}])$`, "i");
492
+ }
493
+ function Ze(e) {
494
+ let t = null, n = null, r = null, i = null;
495
+ if (l.plainObject(e) && V.schema(e, Xt))
496
+ l.defined(e.direction) ? e.degrees >= 0 && (t = e.degrees, n = e.minutes, r = e.seconds, i = e.direction) : (t = e.degrees, n = e.minutes, r = e.seconds);
497
+ else if (l.string(e)) {
498
+ const s = e.replace(/\s+/g, ""), o = s.match(zt) ?? s.match(Kt());
499
+ o && (t = parseFloat(o[1]), n = parseFloat(o[2]), r = parseFloat(o[3]), i = o[4] ?? null);
274
500
  }
275
501
  return {
276
502
  get degrees() {
@@ -283,184 +509,436 @@ function oe(e) {
283
509
  return r;
284
510
  },
285
511
  get direction() {
286
- return a;
512
+ return i;
287
513
  },
288
514
  get format() {
289
515
  return "DMS";
290
516
  },
291
517
  isValid() {
292
- return i.integer(t) && i.integer(n) && i.inRange(n, 0, 59) && i.inRangeExclusiveMax(r, 0, 60);
518
+ return l.integer(t) && l.integer(n) && l.inRange(n, 0, 59) && l.inRangeExclusiveMax(r, 0, 60);
293
519
  },
294
520
  toString(s) {
295
- if (u.that(s, i.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
296
- let l = `${t}° ${n}' ${r.toFixed(s)}"`;
297
- return a && (l += ` ${a}`), l;
521
+ if (_.that(s, l.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
522
+ let o = `${t}° ${n}' ${r.toFixed(s)}"`;
523
+ return i && (o += ` ${i}`), o;
298
524
  },
299
525
  toDecimal() {
300
- return this.isValid() ? D({ degrees: t + n / 60 + r / 3600, direction: a }) : null;
526
+ return this.isValid() ? Y({ degrees: t + n / 60 + r / 3600, direction: i }) : null;
301
527
  }
302
528
  };
303
529
  }
304
- function q(e) {
530
+ function Ge(e) {
305
531
  const t = Math.floor(e.degrees), n = (e.degrees - t) * 60;
306
532
  return { degrees: t, minutes: n, direction: e.direction };
307
533
  }
308
- function Ve(e) {
309
- const t = Math.floor(e.degrees), n = (e.degrees - t) * 60, r = Math.floor(n), a = (n - r) * 60;
310
- return { degrees: t, minutes: r, seconds: a, direction: e.direction };
534
+ function qt(e) {
535
+ const t = Math.floor(e.degrees), n = (e.degrees - t) * 60, r = Math.floor(n), i = (n - r) * 60;
536
+ return { degrees: t, minutes: r, seconds: i, direction: e.direction };
311
537
  }
312
- const Q = {
313
- DD: (e) => (u.that(e, (t) => t.isValid(), "dd must be a valid coordinate"), e),
538
+ const Me = {
539
+ DD: (e) => (_.that(e, (t) => t.isValid(), "dd must be a valid coordinate"), e),
314
540
  DDM: (e) => {
315
- u.that(e, (a) => a.isValid(), "dd must be a valid coordinate");
316
- const { degrees: t, minutes: n, direction: r } = q(e);
317
- return ae(r ? { degrees: t, minutes: n, direction: r } : { degrees: t, minutes: n });
541
+ _.that(e, (i) => i.isValid(), "dd must be a valid coordinate");
542
+ const { degrees: t, minutes: n, direction: r } = Ge(e);
543
+ return Ke(r ? { degrees: t, minutes: n, direction: r } : { degrees: t, minutes: n });
318
544
  },
319
545
  DMS: (e) => {
320
- u.that(e, (s) => s.isValid(), "dd must be a valid coordinate");
321
- const { degrees: t, minutes: n, seconds: r, direction: a } = Ve(e);
322
- return oe(a ? { degrees: t, minutes: n, seconds: r, direction: a } : { degrees: t, minutes: n, seconds: r });
546
+ _.that(e, (s) => s.isValid(), "dd must be a valid coordinate");
547
+ const { degrees: t, minutes: n, seconds: r, direction: i } = qt(e);
548
+ return Ze(i ? { degrees: t, minutes: n, seconds: r, direction: i } : { degrees: t, minutes: n, seconds: r });
323
549
  },
324
550
  DDM_AERO: (e) => {
325
- u.that(e, (a) => a.isValid(), "dd must be a valid coordinate");
326
- const { degrees: t, minutes: n, direction: r } = q(e);
327
- return se({ degrees: t, minutes: n, direction: r });
551
+ _.that(e, (i) => i.isValid(), "dd must be a valid coordinate");
552
+ const { degrees: t, minutes: n, direction: r } = Ge(e);
553
+ return qe({ degrees: t, minutes: n, direction: r });
328
554
  }
329
- }, P = {
555
+ }, fe = {
330
556
  DD: "DD",
331
557
  DDM: "DDM",
332
558
  DDM_AERO: "DDM_AERO",
333
559
  DMS: "DMS"
334
- }, Ye = {
335
- DD: D,
336
- DDM: ae,
337
- DDM_AERO: se,
338
- DMS: oe
339
- }, Y = Array.from({ length: 9 }, (e, t) => 10 ** t);
340
- function Z(e, t) {
341
- if (u.that(e, i.number, "coord must be a number"), i.defined(t))
342
- return u.that(t, O, "dir must be a direction"), Ne(t);
343
- if (Math.abs(e) > 90) return d.LONGITUDE;
344
- }
345
- function J(e) {
346
- u.that(e, i.number, "coord must be a number");
347
- const t = e.toExponential(), [n, r] = t.split("e").map(Number), a = (n.toString().split(".")[1] || "").length;
348
- return Math.max(0, a - r);
349
- }
350
- function Mt(e, t = 7) {
560
+ }, Zt = {
561
+ DD: Y,
562
+ DDM: Ke,
563
+ DDM_AERO: qe,
564
+ DMS: Ze
565
+ }, v = 7, R = 8, Qt = Array.from({ length: R + 1 }, (e, t) => 10 ** t);
566
+ function Pe(e, t) {
567
+ if (u.that(e, a.number, "coord must be a number"), a.defined(t))
568
+ return u.that(t, C, "dir must be a direction"), wt(t);
569
+ if (Math.abs(e) > 90) return O.LONGITUDE;
570
+ }
571
+ function Ue(e) {
572
+ u.that(e, a.number, "coord must be a number");
573
+ const t = e.toExponential(), [n, r] = t.split("e").map(Number), i = (n.toString().split(".")[1] || "").length;
574
+ return Math.max(0, i - r);
575
+ }
576
+ function Qe(e, t = v) {
351
577
  u.all([
352
- { value: e, validator: i.number, message: "coord must be a number" },
353
- { value: t, validator: (r) => i.inRange(r, 0, 8), message: "precision must be in range [0, 8]" }
578
+ {
579
+ value: e,
580
+ validator: a.number,
581
+ message: "coord must be a number"
582
+ },
583
+ {
584
+ value: t,
585
+ validator: (r) => a.inRange(r, 0, R),
586
+ message: `precision must be in range [0, ${R}]`
587
+ }
354
588
  ]);
355
- const n = Y[t];
589
+ const n = Qt[t];
356
590
  return Math.round(e * n) / n;
357
591
  }
358
- function Ct(e, t) {
592
+ function rr(e, t) {
359
593
  if (u.all([
360
- { value: e, validator: i.number, message: "coord must be a number" },
361
- { value: t, validator: (r) => ne(r) || k(r), message: "axis must be either a longitude or latitude" }
362
- ]), k(t))
594
+ { value: e, validator: a.number, message: "coord must be a number" },
595
+ { value: t, validator: (r) => Ee(r) || X(r), message: "axis must be either a longitude or latitude" }
596
+ ]), X(t))
363
597
  return Math.max(-90, Math.min(90, e));
364
598
  let n = ((e + 180) % 360 + 360) % 360 - 180;
365
599
  return n === -180 && (n = 180), Object.is(n, -0) && (n = 0), n;
366
600
  }
367
- function Nt(e, t) {
601
+ function ir(e, t) {
368
602
  u.all([
369
- { value: e, validator: (r) => i.defined(r) && r.isValid(), message: "from must be a valid coordinate" },
370
- { value: t, validator: (r) => w.key(Q, r), message: `unknown format: ${t}` }
603
+ { value: e, validator: (r) => a.defined(r) && r.isValid(), message: "from must be a valid coordinate" },
604
+ { value: t, validator: (r) => A.key(Me, r), message: `unknown format: ${t}` }
371
605
  ]);
372
- const n = e.format === P.DD ? e : e.toDecimal();
373
- return n.isValid() ? t === P.DD ? n : Q[t](n) : null;
606
+ const n = e.format === fe.DD ? e : e.toDecimal();
607
+ return n.isValid() ? t === fe.DD ? n : Me[t](n) : null;
374
608
  }
375
- function We(e) {
376
- u.that(e, i.nonEmptyString, "pattern must be a non empty string");
377
- for (const t of Object.keys(P)) {
378
- const n = Ye[t](e);
609
+ function Jt(e) {
610
+ u.that(e, a.nonEmptyString, "pattern must be a non empty string");
611
+ for (const t of Object.keys(fe)) {
612
+ const n = Zt[t](e);
379
613
  if (n.isValid()) return n;
380
614
  }
381
615
  return null;
382
616
  }
383
- function wt(e) {
384
- u.that(e, (o) => i.nonEmptyString(o), "pattern must be a non-empty string");
617
+ typeof process < "u" && process.versions?.node != null, typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope, typeof ServiceWorkerGlobalScope < "u" && self instanceof ServiceWorkerGlobalScope, typeof process < "u" && process.env.NODE_ENV, typeof process < "u" && process.env.NODE_ENV, typeof process < "u" && process.env.NODE_ENV;
618
+ const T = {
619
+ clamp(e, t, n) {
620
+ return u.all([
621
+ { value: e, validator: a.number, message: "value must be a number" },
622
+ { value: t, validator: a.number, message: "min must be a number" },
623
+ { value: n, validator: a.number, message: "max must be a number" }
624
+ ]), Math.min(Math.max(e, t), n);
625
+ },
626
+ round(e, t = 2) {
627
+ u.all([
628
+ { value: e, validator: a.number, message: "value must be a number" },
629
+ { value: t, validator: a.nonNegativeInteger, message: "precision must be a non-negative integer" }
630
+ ]);
631
+ const n = 10 ** t;
632
+ return Math.round(e * n) / n;
633
+ },
634
+ sign(e, t = 0) {
635
+ return u.all([
636
+ { value: e, validator: a.number, message: "value must be a number" },
637
+ { value: t, validator: a.nonNegative, message: "epsilon must be a non-negative number" }
638
+ ]), e > t ? 1 : e < -t ? -1 : 0;
639
+ },
640
+ percentage(e, t) {
641
+ return u.all([
642
+ { value: e, validator: a.number, message: "value must be a number" },
643
+ { value: t, validator: a.number, message: "total must be a number" }
644
+ ]), T.round(e / t * 100, 2);
645
+ },
646
+ exponential(e, t = 2) {
647
+ if (u.all([
648
+ { value: e, validator: a.number, message: "value must be a number" },
649
+ { value: t, validator: a.nonNegativeInteger, message: "decimals must be a non-negative integer" }
650
+ ]), e === 0) return `0.${"0".repeat(t)}e+0`;
651
+ const n = Math.floor(Math.log10(Math.abs(e)));
652
+ return `${(e / Math.pow(10, n)).toFixed(t)}e${n >= 0 ? "+" : ""}${n}`;
653
+ },
654
+ linear(e, t = 0, n = 1) {
655
+ return u.all([
656
+ { value: e, validator: (r) => a.inRange(r, 0, 1), message: "t must be in range [0, 1]" },
657
+ { value: t, validator: a.number, message: "initial must be a number" },
658
+ { value: n, validator: a.number, message: "final must be a number" }
659
+ ]), t + e * (n - t);
660
+ },
661
+ to: {
662
+ radians(e) {
663
+ return u.that(e, a.number, "degrees must be a number"), e * Math.PI / 180;
664
+ },
665
+ degrees(e) {
666
+ return u.that(e, a.number, "radians must be a number"), e * 180 / Math.PI;
667
+ }
668
+ },
669
+ pow: {
670
+ square(e) {
671
+ return u.that(e, a.number, "value must be a number"), e * e;
672
+ },
673
+ cube(e) {
674
+ return u.that(e, a.number, "value must be a number"), T.pow.square(e) * e;
675
+ }
676
+ },
677
+ ease: {
678
+ in(e, t = 0.5) {
679
+ return u.all([
680
+ { value: e, validator: (n) => a.inRange(n, 0, 1), message: "t must be in range [0, 1]" },
681
+ { value: t, validator: a.number, message: "linearity must be a number" }
682
+ ]), Math.pow(e, 1 / t);
683
+ },
684
+ out(e, t = 0.5) {
685
+ return u.all([
686
+ { value: e, validator: (n) => a.inRange(n, 0, 1), message: "t must be in range [0, 1]" },
687
+ { value: t, validator: a.number, message: "linearity must be a number" }
688
+ ]), 1 - Math.pow(1 - e, 1 / t);
689
+ },
690
+ cubicBezier(e, t = 0.42, n = 0, r = 0.58, i = 1) {
691
+ u.that(e, (g) => a.inRange(g, 0, 1), "t must be in range [0, 1]");
692
+ const s = 1 - e, o = e * e, c = s * s;
693
+ return c * s * n + 3 * c * e * t + 3 * s * o * r + o * e * i;
694
+ }
695
+ },
696
+ stats: {
697
+ sum(e) {
698
+ return u.that(e, a.array, "values must be an array"), e.reduce((t, n) => t + n, 0);
699
+ },
700
+ average(e) {
701
+ return u.that(e, a.nonEmptyArray, "values must be a non-empty array"), T.stats.sum(e) / e.length;
702
+ },
703
+ median(e) {
704
+ u.that(e, a.nonEmptyArray, "values must be a non-empty array");
705
+ const t = [...e].sort((r, i) => r - i), n = Math.floor(t.length / 2);
706
+ return t.length % 2 === 0 ? T.linear(0.5, t[n - 1], t[n]) : t[n];
707
+ }
708
+ }
709
+ };
710
+ N(a.boolean), N(a.boolean), N(a.boolean), N(a.string);
711
+ N(a.boolean), N(a.boolean), N(a.boolean), N(a.string);
712
+ N(a.array);
713
+ const z = T.to.radians(1), en = 1e-12;
714
+ function U(e) {
715
+ const t = e[0] * z, n = e[1] * z, r = Math.cos(n);
716
+ return [r * Math.cos(t), r * Math.sin(t), Math.sin(n)];
717
+ }
718
+ function tn(e) {
719
+ const t = Math.atan2(e[1], e[0]), n = Math.asin(e[2]);
720
+ return [t / z, n / z];
721
+ }
722
+ function j(e, t) {
723
+ return e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
724
+ }
725
+ function k(e, t) {
726
+ return [
727
+ e[1] * t[2] - e[2] * t[1],
728
+ e[2] * t[0] - e[0] * t[2],
729
+ e[0] * t[1] - e[1] * t[0]
730
+ ];
731
+ }
732
+ function Je(e, t) {
733
+ return [e[0] + t[0], e[1] + t[1], e[2] + t[2]];
734
+ }
735
+ function K(e, t) {
736
+ return [e[0] * t, e[1] * t, e[2] * t];
737
+ }
738
+ function q(e) {
739
+ return Math.sqrt(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
740
+ }
741
+ function nn(e) {
742
+ const t = q(e);
743
+ return [e[0] / t, e[1] / t, e[2] / t];
744
+ }
745
+ function rn(e, t) {
746
+ return Math.atan2(q(k(e, t)), j(e, t));
747
+ }
748
+ function an(e) {
749
+ return k(e, et(e));
750
+ }
751
+ function et(e) {
752
+ return nn(k([0, 0, 1], e));
753
+ }
754
+ function sn(e, t) {
755
+ const n = an(e), r = et(e);
756
+ return Je(
757
+ K(n, Math.cos(t)),
758
+ K(r, Math.sin(t))
759
+ );
760
+ }
761
+ function on(e, t, n) {
762
+ const r = sn(e, t);
763
+ return Je(
764
+ K(e, Math.cos(n)),
765
+ K(r, Math.sin(n))
766
+ );
767
+ }
768
+ function tt(e, t, n, r, i = en) {
769
+ const s = k(e, t), o = k(n, r), c = q(s), g = q(o);
770
+ if (c <= i || g <= i) return !1;
771
+ const E = T.sign(j(s, n) / c, i), f = T.sign(j(s, r) / c, i);
772
+ if (E * f !== -1) return !1;
773
+ const I = T.sign(j(o, e) / g, i), D = T.sign(j(o, t) / g, i);
774
+ return I * D === -1;
775
+ }
776
+ const nt = "WGS84", M = "+proj=longlat +datum=WGS84 +no_defs", un = {
777
+ WGS84: M,
778
+ "CRS:84": M,
779
+ CRS84: M,
780
+ "urn:ogc:def:crs:OGC:1.3:CRS84": M,
781
+ "urn:ogc:def:crs:OGC:2:84": M,
782
+ "urn:ogc:def:crs:EPSG::4326": M,
783
+ "EPSG:2154": "+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +units=m +no_defs"
784
+ };
785
+ for (const [e, t] of Object.entries(un))
786
+ b.defs(e) || b.defs(e, t);
787
+ const ln = /^urn:ogc:def:crs:EPSG::(\d+)$/i;
788
+ function rt(e) {
789
+ u.that(e, a.nonEmptyString, "name must be a non empty string");
790
+ const t = e.match(ln);
791
+ return t ? `EPSG:${t[1]}` : e;
792
+ }
793
+ function ar() {
794
+ return Object.keys(b.defs);
795
+ }
796
+ function sr(e, t) {
797
+ u.all([
798
+ {
799
+ value: e,
800
+ validator: a.nonEmptyString,
801
+ message: "name must be a non empty string"
802
+ },
803
+ {
804
+ value: t,
805
+ validator: (n) => a.nonEmptyString(n) || a.nonEmptyObject(n),
806
+ message: "definition must be a non empty string or a non empty object"
807
+ }
808
+ ]), b.defs(e, t);
809
+ }
810
+ function F(e) {
811
+ return u.that(e, a.nonEmptyString, "name must be a non empty string"), a.defined(b.defs(e));
812
+ }
813
+ function or(e) {
814
+ return u.that(e, a.nonEmptyString, "name must be a non empty string"), b.defs(e);
815
+ }
816
+ function it(e) {
817
+ u.that(e, a.nonEmptyString, "name must be a non empty string");
818
+ const t = b.defs(e);
819
+ if (!t) return !1;
820
+ const n = b.defs("EPSG:4326");
821
+ return t.projName === n.projName && t.datumCode === n.datumCode;
822
+ }
823
+ const re = {
824
+ precision: N(a.number),
825
+ consider3D: N(a.boolean)
826
+ }, at = 63710088e-1;
827
+ function ur(e) {
828
+ u.that(e, (E) => a.nonEmptyString(E), "pattern must be a non-empty string");
385
829
  const t = e.split(/[,;|]/);
386
830
  if (t.length !== 2) return null;
387
- const [n, r] = t.map(We);
831
+ const [n, r] = t.map(Jt);
388
832
  if (!n || !r) return null;
389
- const a = n.toDecimal(), s = r.toDecimal(), l = Z(a.degrees, a.direction), m = Z(s.degrees, s.direction), c = (o) => {
390
- const { degrees: v, direction: f } = o;
391
- return f && ($(f) || ie(f)) ? -v : v;
833
+ const i = n.toDecimal(), s = r.toDecimal(), o = Pe(i.degrees, i.direction), c = Pe(s.degrees, s.direction), g = (E) => {
834
+ const { degrees: f, direction: I } = E;
835
+ return I && (ne(I) || ze(I)) ? -f : f;
392
836
  };
393
- if (l === d.LONGITUDE && m === d.LATITUDE) return [c(a), c(s)];
394
- if (m === d.LONGITUDE && l === d.LATITUDE) return [c(s), c(a)];
395
- if (l === d.LONGITUDE && !m) return [c(a), s];
396
- if (l === d.LATITUDE && !m) return [c(s), c(a)];
397
- if (m === d.LONGITUDE && !l) return [c(s), c(a)];
398
- if (m === d.LATITUDE && !l) return [c(a), c(s)];
399
- if (!l && !m)
400
- return [
401
- [c(a), c(s)],
402
- [c(s), c(a)]
403
- ];
404
- }
405
- function y(e) {
406
- return !(!i.arrayOfLengthBetween(e, 2, 3) || !i.number(e[0]) || !i.number(e[1]) || !i.inRange(e[0], -180, 180) || !i.inRange(e[1], -90, 90) || e.length === 3 && !i.number(e[2]));
407
- }
408
- function Xe(e) {
409
- return u.that(e, y, "position must be a valid position"), i.arrayOfLength(e, 3);
410
- }
411
- const Ke = {
412
- precision: p(i.number),
413
- consider3D: p(i.boolean)
414
- };
415
- function _t(e, t, n = {}) {
837
+ return o === O.LONGITUDE && c === O.LATITUDE ? [g(i), g(s)] : c === O.LONGITUDE && o === O.LATITUDE ? [g(s), g(i)] : o === O.LONGITUDE && !c ? [g(i), g(s)] : o === O.LATITUDE && !c ? [g(s), g(i)] : c === O.LONGITUDE && !o ? [g(s), g(i)] : c === O.LATITUDE && !o ? [g(i), g(s)] : !o && !c ? [
838
+ [g(i), g(s)],
839
+ [g(s), g(i)]
840
+ ] : null;
841
+ }
842
+ function S(e) {
843
+ return a.arrayOfLengthBetween(e, 2, 3) ? e.every(a.number) : !1;
844
+ }
845
+ function cn(e) {
846
+ return u.that(e, S, "position must be a valid position"), a.arrayOfLength(e, 3);
847
+ }
848
+ function pe(e, t, n = {}) {
416
849
  u.all([
417
850
  {
418
851
  value: e,
419
- validator: y,
852
+ validator: S,
420
853
  message: "position1 must be a valid position"
421
854
  },
422
855
  {
423
856
  value: t,
424
- validator: y,
857
+ validator: S,
425
858
  message: "position2 must be a valid position"
426
859
  },
427
860
  {
428
861
  value: n,
429
- validator: (l) => E.schema(l, Ke),
862
+ validator: (o) => y.schema(o, re),
430
863
  message: "options must be a valid options object"
431
864
  }
432
865
  ]);
433
- const { precision: r = 10, consider3D: a = !1 } = n, s = a ? Math.max(e.length, t.length) : 2;
866
+ const { precision: r = v, consider3D: i = !1 } = n, s = i ? Math.max(e.length, t.length) : 2;
434
867
  return Array.from(
435
868
  { length: s },
436
- (l, m) => (e[m] ?? 0).toFixed(r) === (t[m] ?? 0).toFixed(r)
869
+ (o, c) => (e[c] ?? 0).toFixed(r) === (t[c] ?? 0).toFixed(r)
437
870
  ).every(Boolean);
438
871
  }
439
- function $t(e, t = 7) {
872
+ function st(e, t = v) {
440
873
  u.all([
441
- { value: e, validator: y, message: "position must be a position" },
442
- { value: t, validator: (r) => i.inRange(r, 0, 8), message: "precision must be in range [0, 8]" }
874
+ {
875
+ value: e,
876
+ validator: S,
877
+ message: "position must be a position"
878
+ },
879
+ {
880
+ value: t,
881
+ validator: (n) => a.inRange(n, 0, R),
882
+ message: `precision must be in range [0, ${R}]`
883
+ }
443
884
  ]);
444
- const n = Y[t];
445
- for (let r = 0; r < e.length; r++)
446
- e[r] = Math.round(e[r] * n) / n;
885
+ for (let n = 0; n < e.length; n++)
886
+ e[n] = Qe(e[n], t);
447
887
  return e;
448
888
  }
449
- function A(e) {
450
- if (!i.arrayOfLength(e, 4) && !i.arrayOfLength(e, 6)) return !1;
889
+ function ot(e, t, n) {
890
+ return u.all([
891
+ {
892
+ value: e,
893
+ validator: S,
894
+ message: "position must be a valid position"
895
+ },
896
+ {
897
+ value: t,
898
+ validator: F,
899
+ message: `unknown source projection: ${t}`
900
+ },
901
+ {
902
+ value: n,
903
+ validator: F,
904
+ message: `unknown target projection: ${n}`
905
+ }
906
+ ]), b(t, n, e);
907
+ }
908
+ function lr(e, t, n) {
909
+ u.all([
910
+ { value: e, validator: S, message: "position must be a valid position" },
911
+ { value: t, validator: a.number, message: "bearing must be a number" },
912
+ { value: n, validator: a.number, message: "distance must be a number" }
913
+ ]);
914
+ const r = on(
915
+ U(e),
916
+ T.to.radians(t),
917
+ n / at
918
+ );
919
+ return tn(r);
920
+ }
921
+ function dn(e, t) {
922
+ return u.all([
923
+ { value: e, validator: S, message: "position1 must be a valid position" },
924
+ { value: t, validator: S, message: "position2 must be a valid position" }
925
+ ]), rn(U(e), U(t)) * at;
926
+ }
927
+ function Z(e) {
928
+ if (!a.arrayOfLength(e, 4) && !a.arrayOfLength(e, 6)) return !1;
451
929
  const t = e.length === 4, n = t ? [e[0], e[1]] : [e[0], e[1], e[2]], r = t ? [e[2], e[3]] : [e[3], e[4], e[5]];
452
- if (!y(n) || !y(r)) return !1;
453
- const [, a] = n, [, s] = r;
454
- return !(a > s || !t && e[2] > e[5]);
930
+ if (!S(n) || !S(r)) return !1;
931
+ const [, i] = n, [, s] = r;
932
+ return !(i > s || !t && e[2] > e[5]);
455
933
  }
456
- function ee(e) {
457
- return u.that(e, A, "bbox must be a valid bounding-box"), i.arrayOfLength(e, 6);
934
+ function Ve(e) {
935
+ return u.that(e, Z, "bbox must be a valid bounding-box"), a.arrayOfLength(e, 6);
458
936
  }
459
- function Ft(e, t) {
937
+ function cr(e, t) {
460
938
  return u.all([
461
- { value: e, validator: A, message: "bbox1 must be a valid bounding-box" },
462
- { value: t, validator: A, message: "bbox2 must be a valid bounding-box" }
463
- ]), ee(e) && ee(t) ? [
939
+ { value: e, validator: Z, message: "bbox1 must be a valid bounding-box" },
940
+ { value: t, validator: Z, message: "bbox2 must be a valid bounding-box" }
941
+ ]), Ve(e) && Ve(t) ? [
464
942
  Math.min(e[0], t[0]),
465
943
  Math.min(e[1], t[1]),
466
944
  Math.min(e[2], t[2]),
@@ -474,66 +952,155 @@ function Ft(e, t) {
474
952
  Math.max(e[3], t[3])
475
953
  ];
476
954
  }
477
- const ze = {
478
- ignore3D: p(i.boolean)
955
+ const fn = {
956
+ ignore3D: N(a.boolean)
479
957
  };
480
- function x(e, t = {}) {
958
+ function se(e, t = {}) {
481
959
  u.all([
482
960
  {
483
961
  value: e,
484
- validator: i.nonEmptyArray,
962
+ validator: a.nonEmptyArray,
485
963
  message: "positions must be a non-empty array"
486
964
  },
487
965
  {
488
966
  value: e,
489
- validator: (a) => a.every(y),
967
+ validator: (i) => i.every(S),
490
968
  message: "positions must be an array of valid positions"
491
969
  },
492
970
  {
493
971
  value: t,
494
- validator: (a) => E.schema(a, ze),
972
+ validator: (i) => y.schema(i, fn),
495
973
  message: "options must be a valid options object"
496
974
  }
497
975
  ]);
498
976
  const { ignore3D: n = !1 } = t;
499
- return !n && e.some(Xe) ? e.reduce((a, s) => [
500
- Math.min(a[0], s[0]),
501
- Math.min(a[1], s[1]),
502
- Math.min(a[2], s[2] ?? 0),
503
- Math.max(a[3], s[0]),
504
- Math.max(a[4], s[1]),
505
- Math.max(a[5], s[2] ?? 0)
506
- ], [1 / 0, 1 / 0, 1 / 0, -1 / 0, -1 / 0, -1 / 0]) : e.reduce((a, s) => [
507
- Math.min(a[0], s[0]),
508
- Math.min(a[1], s[1]),
509
- Math.max(a[2], s[0]),
510
- Math.max(a[3], s[1])
977
+ return !n && e.some(cn) ? e.reduce((i, s) => [
978
+ Math.min(i[0], s[0]),
979
+ Math.min(i[1], s[1]),
980
+ Math.min(i[2], s[2] ?? 0),
981
+ Math.max(i[3], s[0]),
982
+ Math.max(i[4], s[1]),
983
+ Math.max(i[5], s[2] ?? 0)
984
+ ], [1 / 0, 1 / 0, 1 / 0, -1 / 0, -1 / 0, -1 / 0]) : e.reduce((i, s) => [
985
+ Math.min(i[0], s[0]),
986
+ Math.min(i[1], s[1]),
987
+ Math.max(i[2], s[0]),
988
+ Math.max(i[3], s[1])
511
989
  ], [1 / 0, 1 / 0, -1 / 0, -1 / 0]);
512
990
  }
513
- function ue(e, t = 7) {
991
+ function ut(e, t = v) {
514
992
  u.all([
515
- { value: e, validator: A, message: "bbox must be a valid bounding box" },
516
- { value: t, validator: (r) => i.inRange(r, 0, 8), message: "precision must be in range [0, 8]" }
993
+ {
994
+ value: e,
995
+ validator: Z,
996
+ message: "bbox must be a valid bounding box"
997
+ },
998
+ {
999
+ value: t,
1000
+ validator: (n) => a.inRange(n, 0, R),
1001
+ message: `precision must be in range [0, ${R}]`
1002
+ }
517
1003
  ]);
518
- const n = Y[t];
519
- for (let r = 0; r < e.length; r++)
520
- e[r] = Math.round(e[r] * n) / n;
1004
+ for (let n = 0; n < e.length; n++)
1005
+ e[n] = Qe(e[n], t);
521
1006
  return e;
522
1007
  }
523
- const M = {
524
- NAME: "name",
525
- LINK: "link"
1008
+ const mn = {
1009
+ ...re,
1010
+ deduplicate: N(a.boolean)
526
1011
  };
527
- function xt(e) {
528
- return i.plainObject(e) ? e.type === M.NAME ? i.nonEmptyString(e.properties?.name) : e.type === M.LINK ? i.nonEmptyString(e.properties?.href) : !1 : !1;
1012
+ function ve(e) {
1013
+ return a.array(e) && e.every(S);
1014
+ }
1015
+ function lt(e, t = {}) {
1016
+ u.that(t, (s) => y.schema(s, re), "options must be a valid options object");
1017
+ const { precision: n = v, consider3D: r = !1 } = t, i = [];
1018
+ for (const s of e) {
1019
+ const o = i[i.length - 1];
1020
+ (!o || !pe(s, o, { precision: n, consider3D: r })) && i.push(s);
1021
+ }
1022
+ return i;
1023
+ }
1024
+ function me(e, t = {}) {
1025
+ u.all([
1026
+ {
1027
+ value: e,
1028
+ validator: a.array,
1029
+ message: "positions must be an array"
1030
+ },
1031
+ {
1032
+ value: t,
1033
+ validator: (o) => y.schema(o, mn),
1034
+ message: "options must be a valid options object"
1035
+ }
1036
+ ]);
1037
+ const { precision: n = v, deduplicate: r = !1, consider3D: i = !1 } = t, s = e.map((o) => st(o, n));
1038
+ return r ? lt(s, { precision: n, consider3D: i }) : s;
1039
+ }
1040
+ function oe(e, t, n) {
1041
+ return u.that(e, a.array, "positions must be an array"), e.map((r) => ot(r, t, n));
1042
+ }
1043
+ function dr(e) {
1044
+ return a.arrayOfLengthAtLeast(e, 2) && ve(e);
529
1045
  }
530
- function Ut(e) {
531
- return i.arrayOfLengthBetween(e, 2, 3) ? e.every(i.number) : !1;
1046
+ function fr(e) {
1047
+ u.that(e, ve, "line must be a valid array of positions");
1048
+ let t = 0;
1049
+ for (let n = 0; n < e.length - 1; n++)
1050
+ t += dn(e[n], e[n + 1]);
1051
+ return t;
1052
+ }
1053
+ function Q(e, t = {}) {
1054
+ return !a.arrayOfLengthAtLeast(e, 4) || !ve(e) ? !1 : Le(e, t);
1055
+ }
1056
+ function Le(e, t = {}) {
1057
+ if (u.that(t, (i) => y.schema(i, re), "options must be a valid options object"), !a.arrayOfLengthAtLeast(e, 1)) return !1;
1058
+ const n = e[0], r = e[e.length - 1];
1059
+ return pe(n, r, t);
532
1060
  }
533
- function Gt(e) {
534
- return !i.arrayOfLength(e, 4) && !i.arrayOfLength(e, 6) ? !1 : e.every(i.number);
1061
+ function gn(e, t = {}) {
1062
+ return !a.nonEmptyArray(e) || Le(e, t) ? e : [...e, [...e[0]]];
1063
+ }
1064
+ function we(e, t = {}) {
1065
+ const n = me(e, { deduplicate: !0, ...t });
1066
+ return gn(n, t);
1067
+ }
1068
+ function In(e) {
1069
+ u.that(e, Q, "ring must be a valid closed ring of at least 4 positions");
1070
+ let t = 0;
1071
+ for (let n = 0; n < e.length - 1; n++) {
1072
+ const [r, i] = e[n], [s, o] = e[n + 1];
1073
+ t += T.to.radians(s - r) * (2 + Math.sin(T.to.radians(i)) + Math.sin(T.to.radians(o)));
1074
+ }
1075
+ return -t / 2;
535
1076
  }
536
- const g = {
1077
+ function ct(e) {
1078
+ return In(e) < 0;
1079
+ }
1080
+ function dt(e, t) {
1081
+ u.all([
1082
+ { value: e, validator: Q, message: "ring1 must be a valid closed ring" },
1083
+ { value: t, validator: Q, message: "ring2 must be a valid closed ring" }
1084
+ ]);
1085
+ const n = e.map(U), r = t.map(U);
1086
+ for (let i = 0; i < n.length - 1; i++)
1087
+ for (let s = 0; s < r.length - 1; s++)
1088
+ if (tt(n[i], n[i + 1], r[s], r[s + 1]))
1089
+ return !0;
1090
+ return !1;
1091
+ }
1092
+ function ft(e) {
1093
+ u.that(e, Q, "ring must be a valid closed ring");
1094
+ const t = e.map(U), n = [], r = t.length - 1;
1095
+ for (let i = 0; i < r; i++)
1096
+ for (let s = i + 1; s < r; s++)
1097
+ s !== i + 1 && (i === 0 && s === r - 1 || tt(t[i], t[i + 1], t[s], t[s + 1]) && n.push([i, s]));
1098
+ return n;
1099
+ }
1100
+ const J = {
1101
+ NAME: "name",
1102
+ LINK: "link"
1103
+ }, m = {
537
1104
  POINT: "Point",
538
1105
  MULTI_POINT: "MultiPoint",
539
1106
  LINESTRING: "LineString",
@@ -541,519 +1108,815 @@ const g = {
541
1108
  POLYGON: "Polygon",
542
1109
  MULTI_POLYGON: "MultiPolygon",
543
1110
  GEOMETRY_COLLECTION: "GeometryCollection"
544
- };
545
- function qe(e) {
546
- return !i.plainObject(e) || !i.oneOf(e.type, Object.values(g)) ? !1 : e.type === g.GEOMETRY_COLLECTION ? i.array(e.geometries) : i.array(e.coordinates);
547
- }
548
- const h = {
1111
+ }, p = {
549
1112
  FEATURE: "Feature",
550
1113
  FEATURE_COLLECTION: "FeatureCollection"
551
1114
  };
552
- function Qe(e) {
553
- return i.plainObject(e) && e.type === h.FEATURE;
1115
+ function mr(e) {
1116
+ return a.plainObject(e) ? e.type === J.NAME ? a.nonEmptyString(e.properties?.name) : e.type === J.LINK ? a.nonEmptyString(e.properties?.href) : !1 : !1;
554
1117
  }
555
- function Ze(e) {
556
- return i.plainObject(e) && e.type === h.FEATURE_COLLECTION && i.array(e.features);
1118
+ function gr(e) {
1119
+ return S(e);
557
1120
  }
558
- function Je(e) {
559
- return Qe(e) || Ze(e);
1121
+ function Ir(e) {
1122
+ return !a.arrayOfLength(e, 4) && !a.arrayOfLength(e, 6) ? !1 : e.every(a.number);
560
1123
  }
561
- function F(e) {
562
- return Je(e) || qe(e);
1124
+ function En(e) {
1125
+ return !a.plainObject(e) || !a.oneOf(e.type, Object.values(m)) ? !1 : e.type === m.GEOMETRY_COLLECTION ? a.array(e.geometries) : a.array(e.coordinates);
1126
+ }
1127
+ function On(e) {
1128
+ return a.plainObject(e) && e.type === p.FEATURE;
563
1129
  }
564
- const et = {
565
- ignore3D: p(i.boolean)
1130
+ function Nn(e) {
1131
+ return a.plainObject(e) && e.type === p.FEATURE_COLLECTION && a.array(e.features);
1132
+ }
1133
+ function pn(e) {
1134
+ return On(e) || Nn(e);
1135
+ }
1136
+ function G(e) {
1137
+ return pn(e) || En(e);
1138
+ }
1139
+ const vn = {
1140
+ ignore3D: N(a.boolean)
566
1141
  };
567
- function kt(e, t = {}) {
1142
+ function Er(e, t = {}) {
568
1143
  if (u.all([
569
- { value: e, validator: F, message: "geoJson must be a GeoJson object" },
570
- { value: t, validator: (n) => E.schema(n, et), message: "options must be a valid options object" }
571
- ]), e.type === h.FEATURE)
572
- return e.geometry ? x(R(e.geometry), t) : null;
573
- if (e.type === h.FEATURE_COLLECTION) {
574
- const n = R(e);
575
- return n.length ? x(n, t) : null;
1144
+ { value: e, validator: G, message: "geoJson must be a GeoJson object" },
1145
+ { value: t, validator: (n) => y.schema(n, vn), message: "options must be a valid options object" }
1146
+ ]), e.type === p.FEATURE)
1147
+ return e.geometry ? se(W(e.geometry), t) : null;
1148
+ if (e.type === p.FEATURE_COLLECTION) {
1149
+ const n = W(e);
1150
+ return n.length ? se(n, t) : null;
576
1151
  }
577
- return x(R(e), t);
1152
+ return se(W(e), t);
578
1153
  }
579
- function tt(e) {
1154
+ function Ln(e) {
580
1155
  if (e.length === 0) return null;
581
1156
  if (e.length === 1) return { type: "Point", coordinates: e[0] };
582
1157
  if (e.length === 2) return { type: "LineString", coordinates: [e[0], e[1]] };
583
- const t = de(ve(e.map((n) => he({ type: "Point", coordinates: n }))));
1158
+ const t = _t(ht(e.map((n) => bt({ type: "Point", coordinates: n }))));
584
1159
  return t ? t.geometry : { type: "LineString", coordinates: [e[0], e[e.length - 1]] };
585
1160
  }
586
- function nt(e) {
587
- if (u.that(e, F, "geoJson must be a GeoJson object"), e.type === h.FEATURE)
588
- return e.geometry ? nt(e.geometry) : null;
589
- const t = R(e).map((n) => [n[0], n[1]]);
590
- return tt(t);
1161
+ function Tn(e) {
1162
+ if (u.that(e, G, "geoJson must be a GeoJson object"), e.type === p.FEATURE)
1163
+ return e.geometry ? Tn(e.geometry) : null;
1164
+ const t = W(e).map((n) => [n[0], n[1]]);
1165
+ return Ln(t);
1166
+ }
1167
+ function mt(e, t) {
1168
+ return _.that(e, G, "geoJson must be a GeoJson object"), St.lookup(e, t);
1169
+ }
1170
+ function Or(e) {
1171
+ return mt(e, "bbox");
1172
+ }
1173
+ function Sn(e) {
1174
+ const t = mt(e, "crs");
1175
+ if (!l.defined(t)) return nt;
1176
+ const n = t.properties?.name;
1177
+ return l.nonEmptyString(n) ? rt(n) : n;
1178
+ }
1179
+ const d = Object.freeze(
1180
+ Object.fromEntries(
1181
+ Object.keys(We.VALIDATION).map((e) => [e, e])
1182
+ )
1183
+ ), _n = [m.POLYGON, m.MULTI_POLYGON], hn = [
1184
+ m.LINESTRING,
1185
+ m.MULTI_LINESTRING,
1186
+ m.POLYGON,
1187
+ m.MULTI_POLYGON
1188
+ ], ge = [
1189
+ d.INVALID_WINDING_ORDER,
1190
+ d.SELF_INTERSECTION,
1191
+ d.HOLE_INTERSECTS_SHELL,
1192
+ d.DUPLICATE_POSITION
1193
+ ], bn = {
1194
+ validation: l.nonEmptyObject,
1195
+ windingOrder: h(l.boolean),
1196
+ selfIntersection: h(l.boolean),
1197
+ holeIntersectsShell: h(l.boolean),
1198
+ duplicatePosition: h(l.boolean),
1199
+ // Coordinate precision (decimal places) used to decide when two positions are
1200
+ // the same during deduplication -- the same notion validate uses, so fix and
1201
+ // validate stay in lockstep on duplicates.
1202
+ precision: h(l.number)
1203
+ };
1204
+ function je(e, t) {
1205
+ return ct(e) !== t ? (e.reverse(), !0) : !1;
1206
+ }
1207
+ function xe(e) {
1208
+ let t = !1;
1209
+ je(e[0], !1) && (t = !0);
1210
+ for (let n = 1; n < e.length; n++)
1211
+ je(e[n], !0) && (t = !0);
1212
+ return t;
1213
+ }
1214
+ function Rn(e) {
1215
+ if (e.type === m.POLYGON)
1216
+ return xe(e.coordinates);
1217
+ let t = !1;
1218
+ for (const n of e.coordinates)
1219
+ xe(n) && (t = !0);
1220
+ return t;
1221
+ }
1222
+ function Dn(e) {
1223
+ return e.type === m.POLYGON ? e.coordinates : e.coordinates.flat(1);
1224
+ }
1225
+ function An(e) {
1226
+ return e.type === m.POLYGON ? [e.coordinates] : e.coordinates;
1227
+ }
1228
+ function ke(e) {
1229
+ return Dn(e).some((t) => ft(t).length > 0);
1230
+ }
1231
+ function Fe(e) {
1232
+ return An(e).some((t) => {
1233
+ const n = t[0];
1234
+ for (let r = 1; r < t.length; r++)
1235
+ if (dt(n, t[r])) return !0;
1236
+ return !1;
1237
+ });
1238
+ }
1239
+ function yn(e) {
1240
+ const n = Rt({ type: "Feature", properties: {}, geometry: e }, 0);
1241
+ return n ? { type: n.geometry.type, coordinates: n.geometry.coordinates } : null;
1242
+ }
1243
+ function Cn(e, t) {
1244
+ let n = !1;
1245
+ const r = (i) => {
1246
+ const s = i.length, o = lt(i, { precision: t });
1247
+ return o.length !== s && (n = !0), o;
1248
+ };
1249
+ switch (e.type) {
1250
+ case m.LINESTRING:
1251
+ e.coordinates = r(e.coordinates);
1252
+ break;
1253
+ case m.MULTI_LINESTRING:
1254
+ e.coordinates = e.coordinates.map(r);
1255
+ break;
1256
+ case m.POLYGON:
1257
+ e.coordinates = e.coordinates.map(r);
1258
+ break;
1259
+ case m.MULTI_POLYGON:
1260
+ e.coordinates = e.coordinates.map((i) => i.map(r));
1261
+ break;
1262
+ }
1263
+ return n;
1264
+ }
1265
+ function Gn(e, t) {
1266
+ const n = t.selfIntersection, r = t.holeIntersectsShell;
1267
+ if (!n && !r) return [];
1268
+ const i = n && ke(e), s = r && Fe(e), o = [];
1269
+ if (n && !i && o.push(d.SELF_INTERSECTION), r && !s && o.push(d.HOLE_INTERSECTS_SHELL), !i && !s) return o;
1270
+ const c = yn(e);
1271
+ return !c || i && ke(c) || s && Fe(c) || (e.type = c.type, e.coordinates = c.coordinates, i && o.push(d.SELF_INTERSECTION), s && o.push(d.HOLE_INTERSECTS_SHELL)), o;
1272
+ }
1273
+ function Mn(e, t) {
1274
+ const n = [], r = t.precision ?? v;
1275
+ if (t.duplicatePosition && hn.includes(e.type) && Cn(e, r) && n.push({ code: d.DUPLICATE_POSITION }), !_n.includes(e.type))
1276
+ return { fixed: e, corrections: n };
1277
+ t.windingOrder && Rn(e) && n.push({ code: d.INVALID_WINDING_ORDER });
1278
+ for (const i of Gn(e, t))
1279
+ n.push({ code: i });
1280
+ return { fixed: e, corrections: n };
1281
+ }
1282
+ function ue(e, t) {
1283
+ return e.filter((n) => n.path === t || n.path?.startsWith(`${t}/`));
1284
+ }
1285
+ function le(e, t, n, r) {
1286
+ const i = {
1287
+ windingOrder: r.windingOrder !== !1 && t.some((E) => E.code === d.INVALID_WINDING_ORDER),
1288
+ selfIntersection: r.selfIntersection !== !1 && t.some((E) => E.code === d.SELF_INTERSECTION),
1289
+ holeIntersectsShell: r.holeIntersectsShell !== !1 && t.some((E) => E.code === d.HOLE_INTERSECTS_SHELL),
1290
+ duplicatePosition: r.duplicatePosition !== !1 && t.some((E) => E.code === d.DUPLICATE_POSITION),
1291
+ precision: r.precision
1292
+ }, s = i.windingOrder || i.selfIntersection || i.holeIntersectsShell || i.duplicatePosition ? Mn(e, i) : { corrections: [] }, o = new Set(s.corrections.map((E) => E.code)), c = s.corrections.map((E) => ({ ...E, path: n })), g = t.filter((E) => !o.has(E.code));
1293
+ return { corrections: c, unfixed: g };
1294
+ }
1295
+ function Nr(e, t) {
1296
+ _.all([
1297
+ { value: e, validator: G, message: "geoJson must be a GeoJson object" },
1298
+ { value: t, validator: (c) => V.schema(c, bn), message: "options must be a valid options object, with a mandatory validation result" }
1299
+ ]);
1300
+ const n = [...t.validation.errors, ...t.validation.warnings], r = n.filter((c) => ge.includes(c.code)), i = n.filter((c) => !ge.includes(c.code));
1301
+ if (r.length === 0) return { fixed: e, corrections: [], unfixed: i };
1302
+ if (e.type === p.FEATURE_COLLECTION) {
1303
+ const c = [];
1304
+ return e.features.forEach((g, E) => {
1305
+ const f = `/features/${E}/geometry`, I = ue(r, f);
1306
+ if (I.length === 0) return;
1307
+ const D = le(g.geometry, I, f, t);
1308
+ c.push(...D.corrections), i.push(...D.unfixed);
1309
+ }), { fixed: e, corrections: c, unfixed: i };
1310
+ }
1311
+ if (e.type === p.FEATURE) {
1312
+ const c = ue(r, "/geometry"), g = le(e.geometry, c, "/geometry", t);
1313
+ return { fixed: e, corrections: g.corrections, unfixed: [...i, ...g.unfixed] };
1314
+ }
1315
+ const s = ue(r, ""), o = le(e, s, "", t);
1316
+ return { fixed: e, corrections: o.corrections, unfixed: [...i, ...o.unfixed] };
1317
+ }
1318
+ function pr(e) {
1319
+ return _.all([
1320
+ {
1321
+ value: e,
1322
+ validator: l.nonEmptyObject,
1323
+ message: "validation must be a non-empty object"
1324
+ },
1325
+ {
1326
+ value: e?.errors,
1327
+ validator: l.array,
1328
+ message: "validation.errors must be an array"
1329
+ }
1330
+ ]), e.errors.length === 0 ? !1 : e.errors.every(
1331
+ (t) => ge.includes(t.code)
1332
+ );
1333
+ }
1334
+ function Pn(e) {
1335
+ const t = e.match(/^EPSG:(\d+)$/i);
1336
+ return t ? `urn:ogc:def:crs:EPSG::${t[1]}` : e;
1337
+ }
1338
+ function Te(e, t, n) {
1339
+ switch (e.type) {
1340
+ case m.POINT:
1341
+ e.coordinates = ot(e.coordinates, t, n);
1342
+ break;
1343
+ case m.MULTI_POINT:
1344
+ case m.LINESTRING:
1345
+ e.coordinates = oe(e.coordinates, t, n);
1346
+ break;
1347
+ case m.MULTI_LINESTRING:
1348
+ case m.POLYGON:
1349
+ e.coordinates = e.coordinates.map(
1350
+ (r) => oe(r, t, n)
1351
+ );
1352
+ break;
1353
+ case m.MULTI_POLYGON:
1354
+ e.coordinates = e.coordinates.map(
1355
+ (r) => r.map(
1356
+ (i) => oe(i, t, n)
1357
+ )
1358
+ );
1359
+ break;
1360
+ case m.GEOMETRY_COLLECTION:
1361
+ for (const r of e.geometries)
1362
+ Te(r, t, n);
1363
+ break;
1364
+ }
1365
+ return delete e.bbox, delete e.crs, e;
1366
+ }
1367
+ function gt(e, t, n) {
1368
+ if (e.type === p.FEATURE)
1369
+ e.geometry && Te(e.geometry, t, n);
1370
+ else
1371
+ for (const r of e.features)
1372
+ gt(r, t, n);
1373
+ return delete e.bbox, delete e.crs, e;
591
1374
  }
592
- function rt(e, t, n) {
1375
+ function vr(e, t) {
1376
+ u.that(e, G, "geoJson must be a GeoJson object");
1377
+ const n = Sn(e);
1378
+ return u.all([
1379
+ { value: n, validator: F, message: `unknown source projection: ${n}` },
1380
+ { value: t, validator: F, message: `unknown target projection: ${t}` }
1381
+ ]), a.oneOf(e.type, Object.values(m)) ? Te(e, n, t) : gt(e, n, t), it(t) ? delete e.crs : e.crs = {
1382
+ type: "name",
1383
+ properties: { name: Pn(t) }
1384
+ }, e;
1385
+ }
1386
+ const Un = {
1387
+ tolerance: h(l.number),
1388
+ getWeight: h(l.function)
1389
+ };
1390
+ function Vn(e, t, n) {
593
1391
  return Math.abs(
594
1392
  (e[0] * (t[1] - n[1]) + t[0] * (n[1] - e[1]) + n[0] * (e[1] - t[1])) / 2
595
1393
  );
596
1394
  }
597
- function U(e, { tolerance: t = 0, getWeight: n = () => 1 } = {}) {
1395
+ function ce(e, { tolerance: t = 0, getWeight: n = () => 1 } = {}) {
598
1396
  if (e.length <= 2) return e;
599
- const r = e.map((o, v) => ({ coord: o, i: v, area: 1 / 0, removed: !1, prev: null, next: null }));
600
- for (let o = 0; o < r.length; o++)
601
- o > 0 && (r[o].prev = r[o - 1]), o < r.length - 1 && (r[o].next = r[o + 1]);
602
- const a = (o) => !o.prev || !o.next ? 1 / 0 : rt(o.prev.coord, o.coord, o.next.coord) * n(o.coord, o.i), s = new pe((o, v) => o.area - v.area);
603
- for (let o = 1; o < r.length - 1; o++)
604
- r[o].area = a(r[o]), r[o]._currentArea = r[o].area, s.push(r[o]);
605
- let l = 0;
1397
+ const r = e.map((f, I) => ({ coord: f, i: I, area: 1 / 0, removed: !1, prev: null, next: null }));
1398
+ for (let f = 0; f < r.length; f++)
1399
+ f > 0 && (r[f].prev = r[f - 1]), f < r.length - 1 && (r[f].next = r[f + 1]);
1400
+ const i = (f) => !f.prev || !f.next ? 1 / 0 : Vn(f.prev.coord, f.coord, f.next.coord) * n(f.coord, f.i), s = new Dt((f, I) => f.area - I.area), o = (f) => {
1401
+ f.area = i(f), s.push({ node: f, area: f.area });
1402
+ };
1403
+ for (let f = 1; f < r.length - 1; f++) o(r[f]);
1404
+ let c = 0;
606
1405
  for (; s.size() > 0; ) {
607
- const o = s.pop();
608
- if (!o.removed && o.area === o._currentArea) {
609
- if (o.area < l ? o.area = l : l = o.area, o.area >= t) break;
610
- o.removed = !0, o.prev && (o.prev.next = o.next), o.next && (o.next.prev = o.prev), o.prev?.prev && (o.prev.area = a(o.prev), o.prev._currentArea = o.prev.area, s.push(o.prev)), o.next?.next && (o.next.area = a(o.next), o.next._currentArea = o.next.area, s.push(o.next));
1406
+ const f = s.pop(), I = f.node;
1407
+ if (!I.removed && f.area === I.area) {
1408
+ if (I.area < c ? I.area = c : c = I.area, I.area >= t) break;
1409
+ I.removed = !0, I.prev && (I.prev.next = I.next), I.next && (I.next.prev = I.prev), I.prev?.prev && o(I.prev), I.next?.next && o(I.next);
611
1410
  }
612
1411
  }
613
- const m = [];
614
- let c = r[0];
615
- for (; c; )
616
- c.removed || m.push(c.coord), c = c.next;
617
- return m;
618
- }
619
- const it = {
620
- tolerance: p(i.number),
621
- getWeight: p(i.function)
622
- };
623
- function G(e, t = {}) {
624
- if (u.all([
625
- { value: e, validator: F, message: "geoJson must be a GeoJson object" },
626
- { value: t, validator: (n) => E.schema(n, it), message: "options must be a valid options object" }
627
- ]), e.type === h.FEATURE)
628
- return e.geometry && G(e.geometry, t), e;
629
- if (e.type === h.FEATURE_COLLECTION) {
630
- for (const n of e.features) G(n, t);
1412
+ const g = [];
1413
+ let E = r[0];
1414
+ for (; E; )
1415
+ E.removed || g.push(E.coord), E = E.next;
1416
+ return g;
1417
+ }
1418
+ function de(e, t = {}) {
1419
+ if (_.all([
1420
+ { value: e, validator: G, message: "geoJson must be a GeoJson object" },
1421
+ { value: t, validator: (n) => V.schema(n, Un), message: "options must be a valid options object" }
1422
+ ]), e.type === p.FEATURE)
1423
+ return e.geometry && de(e.geometry, t), e;
1424
+ if (e.type === p.FEATURE_COLLECTION) {
1425
+ for (const n of e.features) de(n, t);
631
1426
  return e;
632
1427
  }
633
1428
  switch (e.type) {
634
- case g.LINESTRING:
635
- e.coordinates = U(e.coordinates, t);
1429
+ case m.LINESTRING:
1430
+ e.coordinates = ce(e.coordinates, t);
636
1431
  break;
637
- case g.POLYGON:
638
- case g.MULTI_LINESTRING:
639
- e.coordinates = e.coordinates.map((n) => U(n, t));
1432
+ case m.POLYGON:
1433
+ case m.MULTI_LINESTRING:
1434
+ e.coordinates = e.coordinates.map((n) => ce(n, t));
640
1435
  break;
641
- case g.MULTI_POLYGON:
642
- e.coordinates = e.coordinates.map((n) => n.map((r) => U(r, t)));
1436
+ case m.MULTI_POLYGON:
1437
+ e.coordinates = e.coordinates.map((n) => n.map((r) => ce(r, t)));
643
1438
  break;
644
- case g.GEOMETRY_COLLECTION:
645
- e.geometries.forEach((n) => G(n, t));
1439
+ case m.GEOMETRY_COLLECTION:
1440
+ e.geometries.forEach((n) => de(n, t));
646
1441
  break;
647
1442
  }
648
1443
  return e;
649
1444
  }
650
- function le(e, t = 7) {
651
- const n = Ee(e, { precision: t, mutate: !0 });
652
- return n.bbox && ue(n.bbox, t), n;
1445
+ function Se(e, t, n) {
1446
+ switch (e.type) {
1447
+ case m.POINT:
1448
+ st(e.coordinates, t);
1449
+ break;
1450
+ case m.MULTI_POINT:
1451
+ case m.LINESTRING:
1452
+ me(e.coordinates, { precision: t });
1453
+ break;
1454
+ case m.MULTI_LINESTRING:
1455
+ for (const r of e.coordinates) me(r, { precision: t });
1456
+ break;
1457
+ case m.POLYGON:
1458
+ e.coordinates = e.coordinates.map((r) => we(r, { precision: t, consider3D: n }));
1459
+ break;
1460
+ case m.MULTI_POLYGON:
1461
+ e.coordinates = e.coordinates.map(
1462
+ (r) => r.map((i) => we(i, { precision: t, consider3D: n }))
1463
+ );
1464
+ break;
1465
+ case m.GEOMETRY_COLLECTION:
1466
+ for (const r of e.geometries) Se(r, t, n);
1467
+ break;
1468
+ }
1469
+ return e.bbox && ut(e.bbox, t), e;
653
1470
  }
654
- function ce(e, t) {
655
- if (e.type === h.FEATURE)
656
- e.geometry && le(e.geometry, t);
1471
+ function It(e, t, n) {
1472
+ if (e.type === p.FEATURE)
1473
+ e.geometry && Se(e.geometry, t, n);
657
1474
  else
658
- for (const n of e.features) ce(n, t);
659
- return e.bbox && ue(e.bbox, t), e;
1475
+ for (const r of e.features) It(r, t, n);
1476
+ return e.bbox && ut(e.bbox, t), e;
660
1477
  }
661
- function Pt(e, t = 7) {
1478
+ function Lr(e, t = {}) {
1479
+ const { precision: n = v, consider3D: r = !1 } = t;
662
1480
  return u.all([
663
- { value: e, validator: F, message: "geoJson must be a valid GeoJson" },
664
- { value: t, validator: (n) => i.inRange(n, 0, 8), message: "precision must be in range [0, 8]" }
665
- ]), i.oneOf(e.type, Object.values(g)) ? le(e, t) : ce(e, t);
1481
+ {
1482
+ value: e,
1483
+ validator: G,
1484
+ message: "geoJson must be a valid GeoJson"
1485
+ },
1486
+ {
1487
+ value: n,
1488
+ validator: (i) => a.inRange(i, 0, R),
1489
+ message: `precision must be in range [0, ${R}]`
1490
+ }
1491
+ ]), a.oneOf(e.type, Object.values(m)) ? Se(e, n, r) : It(e, n, r);
666
1492
  }
667
- function C(e) {
668
- if (!i.arrayOfLengthBetween(e, 2, 3))
1493
+ const $e = "/crs";
1494
+ function Et(e, t = "", n = {}) {
1495
+ if (!l.defined(e))
1496
+ return t === $e ? (n.geodesic = !0, { crs: nt, valid: !0 }) : { valid: !0 };
1497
+ if (t !== $e)
669
1498
  return {
670
1499
  valid: !1,
671
- errors: [{ message: "Invalid coordinates: must be an array of 2 or 3 coordinates" }],
1500
+ errors: [{ code: d.UNSUPPORTED_NESTED_CRS, path: t }],
672
1501
  warnings: []
673
1502
  };
674
- if (!i.number(e[0]) || !i.number(e[1]))
1503
+ if (!l.plainObject(e))
675
1504
  return {
676
1505
  valid: !1,
677
- errors: [{ message: "Invalid coordinates: longitude and latitude must be numbers" }],
1506
+ errors: [{ code: d.INVALID_CRS_OBJECT, path: t }],
678
1507
  warnings: []
679
1508
  };
680
- if (!i.inRange(e[0], -180, 180))
1509
+ switch (e.type) {
1510
+ case J.NAME: {
1511
+ if (!l.nonEmptyString(e.properties?.name))
1512
+ return {
1513
+ valid: !1,
1514
+ errors: [{ code: d.INVALID_CRS_NAME, path: t }],
1515
+ warnings: []
1516
+ };
1517
+ const r = rt(e.properties.name);
1518
+ return F(r) ? (n.geodesic = it(r), {
1519
+ crs: r,
1520
+ valid: !0,
1521
+ errors: [],
1522
+ warnings: []
1523
+ }) : {
1524
+ valid: !1,
1525
+ errors: [{
1526
+ code: d.UNSUPPORTED_CRS,
1527
+ path: t,
1528
+ params: { name: e.properties.name }
1529
+ }],
1530
+ warnings: []
1531
+ };
1532
+ }
1533
+ case J.LINK:
1534
+ return l.nonEmptyString(e.properties?.href) ? {
1535
+ valid: !1,
1536
+ errors: [{ code: d.UNSUPPORTED_LINK_CRS, path: t }],
1537
+ warnings: []
1538
+ } : {
1539
+ valid: !1,
1540
+ errors: [{ code: d.INVALID_CRS_LINK, path: t }],
1541
+ warnings: []
1542
+ };
1543
+ default:
1544
+ return {
1545
+ valid: !1,
1546
+ errors: [{
1547
+ code: d.INVALID_CRS_TYPE,
1548
+ path: t,
1549
+ params: { type: e.type }
1550
+ }],
1551
+ warnings: []
1552
+ };
1553
+ }
1554
+ }
1555
+ function ee(e, t = "", n = {}) {
1556
+ const r = n.geodesic;
1557
+ if (!l.arrayOfLengthBetween(e, 2, 3))
681
1558
  return {
682
1559
  valid: !1,
683
- errors: [{ message: "Invalid coordinates: longitude must be in the range -180 to 180" }],
1560
+ errors: [{ code: d.INVALID_POSITION_LENGTH, path: t }],
684
1561
  warnings: []
685
1562
  };
686
- if (!i.inRange(e[1], -90, 90))
1563
+ if (!l.number(e[0]) || !l.number(e[1]))
687
1564
  return {
688
1565
  valid: !1,
689
- errors: [{ message: "Invalid coordinates: latitude must be in the range -90 to 90" }],
1566
+ errors: [{ code: d.INVALID_POSITION_COORDINATES, path: t }],
690
1567
  warnings: []
691
1568
  };
692
- if (e.length === 3 && !i.number(e[2]))
1569
+ if (r) {
1570
+ if (!l.inRange(e[0], -180, 180))
1571
+ return {
1572
+ valid: !1,
1573
+ errors: [{ code: d.INVALID_LONGITUDE_RANGE, path: t, params: { value: e[0] } }],
1574
+ warnings: []
1575
+ };
1576
+ if (!l.inRange(e[1], -90, 90))
1577
+ return {
1578
+ valid: !1,
1579
+ errors: [{ code: d.INVALID_LATITUDE_RANGE, path: t, params: { value: e[1] } }],
1580
+ warnings: []
1581
+ };
1582
+ }
1583
+ if (e.length === 3 && !l.number(e[2]))
693
1584
  return {
694
1585
  valid: !1,
695
- errors: [{ message: "Invalid coordinates: altitude must be a number" }],
1586
+ errors: [{ code: d.INVALID_ALTITUDE, path: t }],
696
1587
  warnings: []
697
1588
  };
698
- const t = { valid: !0, errors: [], warnings: [] }, n = J(e[0]);
699
- n > 6 && t.warnings.push({ message: `longitude precision is high (${n} decimals, max recommended: 6)` });
700
- const r = J(e[1]);
701
- return r > 6 && t.warnings.push({ message: `latitude precision is high (${r} decimals, max recommended: 6)` }), t;
1589
+ const i = { valid: !0, errors: [], warnings: [] };
1590
+ if (r) {
1591
+ const s = n.precision ?? v, o = Ue(e[0]);
1592
+ o > s && i.warnings.push({ code: d.EXCESSIVE_LONGITUDE_PRECISION, path: t, params: { precision: o, max: s } });
1593
+ const c = Ue(e[1]);
1594
+ c > s && i.warnings.push({ code: d.EXCESSIVE_LATITUDE_PRECISION, path: t, params: { precision: c, max: s } });
1595
+ }
1596
+ return i;
702
1597
  }
703
- function at(e) {
704
- if (!i.arrayOfLength(e, 4) && !i.arrayOfLength(e, 6))
1598
+ function Ot(e, t = "", n = {}) {
1599
+ const r = n?.geodesic;
1600
+ if (!l.defined(e))
705
1601
  return {
706
- valid: !1,
707
- errors: [{ message: "Invalid bbox: must be an array of 4 (2D) or 6 (3D) numbers" }],
708
- warnings: []
1602
+ valid: !0
709
1603
  };
710
- const t = e.length === 4, n = t ? [e[0], e[1]] : [e[0], e[1], e[2]], r = t ? [e[2], e[3]] : [e[3], e[4], e[5]], a = C(n);
711
- if (!a.valid)
1604
+ if (!l.arrayOfLength(e, 4) && !l.arrayOfLength(e, 6))
712
1605
  return {
713
1606
  valid: !1,
714
- errors: a.errors.map((f) => ({ ...f, message: `Invalid bbox south-west: ${f.message}` })),
1607
+ errors: [{ code: d.INVALID_BBOX_LENGTH, path: t }],
715
1608
  warnings: []
716
1609
  };
717
- const s = C(r);
718
- if (!s.valid)
1610
+ const i = e.length === 4, s = i ? [e[0], e[1]] : [e[0], e[1], e[2]], o = i ? [e[2], e[3]] : [e[3], e[4], e[5]], c = ee(s, `${t}/min`, n);
1611
+ if (!c.valid)
1612
+ return { valid: !1, errors: c.errors, warnings: [] };
1613
+ const g = ee(o, `${t}/max`, n);
1614
+ if (!g.valid)
1615
+ return { valid: !1, errors: g.errors, warnings: [] };
1616
+ const [E, f] = s, [I, D] = o;
1617
+ if (f > D)
719
1618
  return {
720
1619
  valid: !1,
721
- errors: s.errors.map((f) => ({ ...f, message: `Invalid bbox north-east: ${f.message}` })),
1620
+ errors: [{ code: d.INVALID_BBOX_LATITUDE_ORDER, path: t, params: { south: f, north: D } }],
722
1621
  warnings: []
723
1622
  };
724
- const [l, m] = n, [c, o] = r;
725
- if (m > o)
1623
+ if (!r && E > I)
726
1624
  return {
727
1625
  valid: !1,
728
- errors: [{ message: `Invalid bbox: south (${m}) must be <= north (${o})` }],
1626
+ errors: [{ code: d.INVALID_BBOX_LONGITUDE_ORDER, path: t, params: { west: E, east: I } }],
729
1627
  warnings: []
730
1628
  };
731
- if (!t) {
732
- const f = e[2], K = e[5];
733
- if (f > K)
1629
+ if (!i) {
1630
+ const De = e[2], Ae = e[5];
1631
+ if (De > Ae)
734
1632
  return {
735
1633
  valid: !1,
736
- errors: [{ message: `Invalid bbox: min altitude (${f}) must be <= max altitude (${K})` }],
1634
+ errors: [{ code: d.INVALID_BBOX_ALTITUDE_ORDER, path: t, params: { minAlt: De, maxAlt: Ae } }],
737
1635
  warnings: []
738
1636
  };
739
1637
  }
740
- const v = { valid: !0, errors: [], warnings: [] };
741
- return l > c && v.warnings.push({ message: `bbox crosses the antimeridian (west: ${l} > east: ${c})` }), v.warnings.push(...a.warnings.map((f) => ({ ...f, message: `south-west: ${f.message}` }))), v.warnings.push(...s.warnings.map((f) => ({ ...f, message: `north-east: ${f.message}` }))), v;
1638
+ const H = { valid: !0, errors: [], warnings: [] };
1639
+ return r && E > I && H.warnings.push({ code: d.BBOX_ANTIMERIDIAN_CROSSING, path: t, params: { west: E, east: I } }), H.warnings.push(...c.warnings), H.warnings.push(...g.warnings), H;
742
1640
  }
743
- function st(e) {
744
- if (!i.plainObject(e))
745
- return {
746
- valid: !1,
747
- errors: [{ message: "Invalid crs: must be an object" }],
748
- warnings: []
749
- };
750
- switch (e.type) {
751
- case M.NAME:
752
- return i.nonEmptyString(e.properties?.name) ? { valid: !0, errors: [], warnings: [] } : {
753
- valid: !1,
754
- errors: [{ message: "Invalid crs: linked crs must have a non-empty properties.name string" }],
755
- warnings: []
756
- };
757
- case M.LINK:
758
- return i.nonEmptyString(e.properties?.href) ? { valid: !0, errors: [], warnings: [] } : {
759
- valid: !1,
760
- errors: [{ message: "Invalid crs: linked crs must have a non-empty properties.href string" }],
761
- warnings: []
762
- };
763
- default:
764
- return {
765
- valid: !1,
766
- errors: [{ message: `Invalid crs: unknown type: ${e.type}` }],
767
- warnings: []
768
- };
769
- }
770
- }
771
- function T() {
1641
+ function _e() {
772
1642
  return { Feature: 0, FeatureCollection: 0, geometries: {} };
773
1643
  }
774
- function ot(...e) {
775
- const t = T();
1644
+ function he() {
1645
+ return {
1646
+ crs: void 0,
1647
+ valid: !0,
1648
+ errors: [],
1649
+ warnings: [],
1650
+ statistics: _e()
1651
+ };
1652
+ }
1653
+ function Nt(...e) {
1654
+ const t = _e();
776
1655
  for (const n of e) {
777
1656
  const r = n.statistics;
778
1657
  if (r) {
779
1658
  t.Feature += r.Feature ?? 0, t.FeatureCollection += r.FeatureCollection ?? 0;
780
- for (const [a, s] of Object.entries(r.geometries ?? {}))
781
- t.geometries[a] = (t.geometries[a] ?? 0) + s;
1659
+ for (const [i, s] of Object.entries(r.geometries ?? {}))
1660
+ t.geometries[i] = (t.geometries[i] ?? 0) + s;
782
1661
  }
783
1662
  }
784
1663
  return t;
785
1664
  }
786
- function L(e, t, n = "") {
1665
+ function L(e, ...t) {
1666
+ for (const n of t)
1667
+ e.valid = e.valid && (n.valid ?? !0), n.errors && e.errors.push(...n.errors), n.warnings && e.warnings.push(...n.warnings), n.crs !== void 0 && (e.crs = n.crs);
1668
+ return e.statistics = Nt(e, ...t), e;
1669
+ }
1670
+ function w(e, t, n = "") {
787
1671
  const r = {
788
1672
  valid: !0,
789
1673
  errors: [],
790
1674
  warnings: [],
791
- statistics: T()
1675
+ statistics: _e()
792
1676
  };
793
- for (let a = 0; a < e.length; a++) {
794
- const s = `${n}/${a}`, l = t(e[a], s, a);
795
- if (l.statistics && (r.statistics = ot(r, l)), !l.valid) {
796
- r.valid = !1, r.errors = r.errors.concat(l.errors.map((m) => ({ ...m, path: m.path || s, index: a })));
797
- continue;
798
- }
799
- i.empty(l.warnings) || (r.warnings = r.warnings.concat(l.warnings.map((m) => ({ ...m, path: m.path || s, index: a }))));
1677
+ for (let i = 0; i < e.length; i++) {
1678
+ const s = `${n}/${i}`, o = t(e[i], s, i);
1679
+ o.statistics && (r.statistics = Nt(r, o)), o.valid || (r.valid = !1, r.errors = r.errors.concat(o.errors.map((c) => ({ ...c, path: c.path || s, index: i })))), l.empty(o.warnings) || (r.warnings = r.warnings.concat(o.warnings.map((c) => ({ ...c, path: c.path || s, index: i }))));
800
1680
  }
801
1681
  return r;
802
1682
  }
803
- function te(e, t) {
804
- if (!i.defined(e.crs)) return t;
805
- const n = st(e.crs);
806
- return n.valid || (t.valid = !1, t.errors.push(...n.errors.map((r) => ({ ...r, path: "/crs" })))), t.warnings.push(...n.warnings.map((r) => ({ ...r, path: "/crs" }))), t;
1683
+ function Be(e, t = 0, n = v) {
1684
+ for (let r = t; r < e.length - 1; r++)
1685
+ if (pe(e[r], e[r + 1], { precision: n })) return r;
1686
+ return -1;
807
1687
  }
808
- function N(e, t, n = "") {
809
- if (!i.defined(e.bbox)) return t;
810
- const r = at(e.bbox);
811
- return r.valid || (t.valid = !1, t.errors.push(...r.errors.map((a) => ({ ...a, path: `${n}/bbox` })))), t.warnings.push(...r.warnings.map((a) => ({ ...a, path: `${n}/bbox` }))), t;
1688
+ function pt(e, t, n, r = v) {
1689
+ let i = Be(e, 0, r);
1690
+ for (; i !== -1; )
1691
+ n.push({ code: d.DUPLICATE_POSITION, path: `${t}/${i}` }), i = Be(e, i + 1, r);
812
1692
  }
813
- function W(e, t = 0, n = "") {
814
- return i.arrayOfLengthAtLeast(e, t) ? L(e, C, n) : {
1693
+ function be(e, t = 0, n = "", r = {}) {
1694
+ return l.arrayOfLengthAtLeast(e, t) ? w(e, (i, s) => ee(i, s, r), n) : {
815
1695
  valid: !1,
816
- errors: [{ message: `Invalid coordinates: must have at least ${t} positions`, path: n }],
1696
+ errors: [{ code: d.INVALID_COORDINATES_LENGTH, path: n, params: { minimumLength: t } }],
817
1697
  warnings: []
818
1698
  };
819
1699
  }
820
- function me(e, t = "") {
821
- const n = W(e, 2, t);
822
- if (!n.valid) return n;
823
- for (let r = 0; r < e.length - 1; r++) {
824
- const a = e[r][0], s = e[r + 1][0];
825
- Math.abs(s - a) > 180 && n.warnings.push({
826
- message: `LineString crosses the antimeridian between positions ${r} and ${r + 1}, consider using MultiLineString`,
827
- path: `${t}/${r}`
828
- });
829
- }
830
- return n;
1700
+ function vt(e, t = "", n = {}) {
1701
+ const r = be(e, 2, t, n);
1702
+ if (!r.valid) return r;
1703
+ if (pt(e, t, r.warnings, n.precision ?? v), n.geodesic ?? !0)
1704
+ for (let i = 0; i < e.length - 1; i++) {
1705
+ const s = e[i][0], o = e[i + 1][0];
1706
+ Math.abs(o - s) > 180 && r.warnings.push({ code: d.ANTIMERIDIAN_CROSSING, path: `${t}/${i}` });
1707
+ }
1708
+ return r;
831
1709
  }
832
- function ut(e, t = "") {
833
- return i.nonEmptyArray(e) ? L(e, me, t) : {
1710
+ function wn(e, t = "", n = {}) {
1711
+ return l.nonEmptyArray(e) ? w(e, (r, i) => vt(r, i, n), t) : {
834
1712
  valid: !1,
835
- errors: [{ message: "Invalid MultiLineString: coordinates must be a non empty array", path: t }],
1713
+ errors: [{ code: d.INVALID_MULTI_LINESTRING_COORDINATES, path: t }],
836
1714
  warnings: []
837
1715
  };
838
1716
  }
839
- function lt(e, t, n = "") {
840
- const r = W(e, 4, n);
841
- if (!r.valid) return r;
842
- const a = e[0], s = e[e.length - 1];
843
- if (a[0] !== s[0] || a[1] !== s[1])
844
- return r.valid = !1, r.errors.push({ message: "Invalid LinearRing: first and last position must be identical", path: n }), r;
845
- const m = ye(e) ? "clockwise" : "counter-clockwise";
846
- m !== t && r.warnings.push({ message: `Ring must be ${t} but is ${m}`, path: n });
847
- const c = Oe({ type: "Polygon", coordinates: [e] });
848
- return c.features.length > 0 && (r.valid = !1, r.errors.push({ message: `Invalid LinearRing: ${c.features.length} self-intersection(s) detected`, path: n })), r;
849
- }
850
- function fe(e, t = "") {
851
- return i.nonEmptyArray(e) ? L(e, (n, r, a) => lt(n, a === 0 ? "counter-clockwise" : "clockwise", r), t) : {
852
- valid: !1,
853
- errors: [{ message: "Invalid Polygon: coordinates must be a non empty array", path: t }],
854
- warnings: []
855
- };
1717
+ function jn(e, t, n = "", r = {}) {
1718
+ const i = r.precision ?? v, s = r.geodesic ?? !0, o = be(e, 4, n, r);
1719
+ if (!o.valid) return o;
1720
+ if (!Le(e, { precision: i }))
1721
+ return o.valid = !1, o.errors.push({ code: d.RING_NOT_CLOSED, path: n }), o;
1722
+ if (pt(e, n, o.warnings, i), s) {
1723
+ const c = ct(e) ? "clockwise" : "counter-clockwise";
1724
+ c !== t && (o.valid = !1, o.errors.push({
1725
+ code: d.INVALID_WINDING_ORDER,
1726
+ path: n,
1727
+ params: { expected: t, actual: c }
1728
+ }));
1729
+ const g = ft(e);
1730
+ g.length > 0 && (o.valid = !1, o.errors.push({
1731
+ code: d.SELF_INTERSECTION,
1732
+ path: n,
1733
+ params: { count: g.length }
1734
+ }));
1735
+ }
1736
+ return o;
856
1737
  }
857
- function ct(e, t = "") {
858
- return i.nonEmptyArray(e) ? L(e, (n, r) => fe(n, r), t) : {
1738
+ function Lt(e, t = "", n = {}) {
1739
+ if (!l.nonEmptyArray(e))
1740
+ return {
1741
+ valid: !1,
1742
+ errors: [{ code: d.INVALID_POLYGON_COORDINATES, path: t }],
1743
+ warnings: []
1744
+ };
1745
+ const r = w(e, (i, s, o) => jn(i, o === 0 ? "counter-clockwise" : "clockwise", s, n), t);
1746
+ if ((n.geodesic ?? !0) && r.valid && e.length > 1) {
1747
+ const i = e[0];
1748
+ for (let s = 1; s < e.length; s++)
1749
+ dt(i, e[s]) && (r.valid = !1, r.errors.push({ code: d.HOLE_INTERSECTS_SHELL, path: `${t}/${s}` }));
1750
+ }
1751
+ return r;
1752
+ }
1753
+ function xn(e, t = "", n = {}) {
1754
+ return l.nonEmptyArray(e) ? w(e, (r, i) => Lt(r, i, n), t) : {
859
1755
  valid: !1,
860
- errors: [{ message: "Invalid MultiPolygon: coordinates must be a non empty array", path: t }],
1756
+ errors: [{ code: d.INVALID_MULTIPOLYGON_COORDINATES, path: t }],
861
1757
  warnings: []
862
1758
  };
863
1759
  }
864
- function mt(e, t = "") {
865
- return i.nonEmptyArray(e) ? L(e, (n, r) => X(n, r), t) : {
1760
+ function kn(e, t = "", n = {}) {
1761
+ return l.nonEmptyArray(e) ? w(e, (r, i) => Re(r, i, n), t) : {
866
1762
  valid: !1,
867
- errors: [{ message: "Invalid geometries: geometries must be a non empty array", path: t }],
1763
+ errors: [{ code: d.INVALID_GEOMETRYCOLLECTION_GEOMETRIES, path: t }],
868
1764
  warnings: []
869
1765
  };
870
1766
  }
871
- function X(e, t = "") {
872
- if (!i.nonEmptyObject(e))
873
- return {
874
- valid: !1,
875
- errors: [{ message: "Invalid geometry: geometry must be a non empty object", path: t }],
876
- warnings: []
877
- };
878
- const n = `${t}/coordinates`;
879
- let r;
1767
+ function Re(e, t = "", n = {}) {
1768
+ let r = he();
1769
+ if (!l.nonEmptyObject(e))
1770
+ return r.valid = !1, r.errors.push({ code: d.INVALID_GEOMETRY, path: t }), r;
1771
+ r = L(r, Et(e.crs, `${t}/crs`, n)), r = L(r, Ot(e.bbox, `${t}/bbox`, n));
1772
+ const i = `${t}/coordinates`;
880
1773
  switch (e.type) {
881
- case g.POINT: {
882
- const a = C(e.coordinates);
883
- r = {
884
- valid: a.valid,
885
- errors: a.errors.map((s) => ({ ...s, path: n })),
886
- warnings: a.warnings.map((s) => ({ ...s, path: n }))
887
- };
1774
+ case m.POINT:
1775
+ r = L(r, ee(e.coordinates, i, n));
888
1776
  break;
889
- }
890
- case g.MULTI_POINT: {
891
- r = W(e.coordinates, 0, n);
1777
+ case m.MULTI_POINT:
1778
+ r = L(r, be(e.coordinates, 0, i, n));
892
1779
  break;
893
- }
894
- case g.LINESTRING: {
895
- r = me(e.coordinates, n);
1780
+ case m.LINESTRING:
1781
+ r = L(r, vt(e.coordinates, i, n));
896
1782
  break;
897
- }
898
- case g.MULTI_LINESTRING: {
899
- r = ut(e.coordinates, n);
1783
+ case m.MULTI_LINESTRING:
1784
+ r = L(r, wn(e.coordinates, i, n));
900
1785
  break;
901
- }
902
- case g.POLYGON: {
903
- r = fe(e.coordinates, n);
1786
+ case m.POLYGON:
1787
+ r = L(r, Lt(e.coordinates, i, n));
904
1788
  break;
905
- }
906
- case g.MULTI_POLYGON: {
907
- r = ct(e.coordinates, n);
1789
+ case m.MULTI_POLYGON:
1790
+ r = L(r, xn(e.coordinates, i, n));
908
1791
  break;
909
- }
910
- case g.GEOMETRY_COLLECTION: {
911
- r = mt(e.geometries, `${t}/geometries`);
1792
+ case m.GEOMETRY_COLLECTION:
1793
+ r = L(r, kn(e.geometries, `${t}/geometries`, n));
912
1794
  break;
913
- }
914
1795
  default:
915
- return {
916
- valid: !1,
917
- errors: [{ message: `Invalid geometry type: ${e.type}`, path: t }],
918
- warnings: []
919
- };
920
- }
921
- return r = N(e, r, t), r.statistics = { geometries: { [e.type]: 1 } }, r;
922
- }
923
- function ge(e, t = "") {
924
- if (!i.nonEmptyObject(e))
925
- return {
926
- valid: !1,
927
- errors: [{ message: "Invalid feature: must be a non empty object", path: t }],
928
- warnings: [],
929
- statistics: T()
930
- };
931
- if (e.type === h.FEATURE) {
932
- if (i.nonEmptyObject(e.geometry)) {
933
- const n = X(e.geometry, `${t}/geometry`);
934
- return {
935
- ...N(e, n, t),
936
- statistics: {
937
- Feature: 1,
938
- FeatureCollection: 0,
939
- // Geometry counting is owned by validateGeometry.
940
- geometries: { ...n.statistics.geometries }
941
- }
942
- };
943
- }
944
- return {
945
- valid: !0,
946
- errors: [],
947
- warnings: [{ message: "Feature has no geometry", path: t }],
948
- statistics: { Feature: 1, FeatureCollection: 0, geometries: {} }
949
- };
950
- }
951
- if (e.type === h.FEATURE_COLLECTION) {
952
- if (i.nonEmptyArray(e.features)) {
953
- const n = L(e.features, ge, `${t}/features`);
954
- return {
955
- ...N(e, n, t),
956
- statistics: { ...n.statistics, FeatureCollection: n.statistics.FeatureCollection + 1 }
957
- };
958
- }
959
- return {
960
- valid: !1,
961
- errors: [{ message: "Invalid FeatureCollection: features must be a non empty array", path: t }],
962
- warnings: [],
963
- statistics: T()
964
- };
965
- }
966
- return {
967
- valid: !1,
968
- errors: [{ message: `Invalid feature: unknown type: ${e.type}`, path: t }],
969
- warnings: [],
970
- statistics: T()
971
- };
972
- }
973
- function Bt(e) {
974
- if (u.that(e, i.nonEmptyObject, "geojson must be a non empty object"), i.oneOf(e.type, Object.values(g))) {
975
- const t = X(e, ""), n = N(e, t, "");
976
- return {
977
- ...te(e, n),
978
- // Geometry counting is owned by validateGeometry.
979
- statistics: { Feature: 0, FeatureCollection: 0, geometries: { ...t.statistics.geometries } }
980
- };
1796
+ return r.valid = !1, r.errors.push({ code: d.INVALID_GEOMETRY_TYPE, path: t, params: { type: e.type } }), r;
981
1797
  }
982
- if (e.type === h.FEATURE || e.type === h.FEATURE_COLLECTION) {
983
- const t = ge(e, "");
984
- return te(e, t);
985
- }
986
- return {
1798
+ return r.statistics = { Feature: 0, FeatureCollection: 0, geometries: { [e.type]: 1 } }, r;
1799
+ }
1800
+ function Tt(e, t, n) {
1801
+ let r = he();
1802
+ return l.nonEmptyObject(e) ? (r = L(r, Et(e.crs, `${t}/crs`, n)), r = L(r, Ot(e.bbox, `${t}/bbox`, n)), e.type === p.FEATURE ? (r.statistics.Feature++, l.nonEmptyObject(e.geometry) ? r = L(r, Re(e.geometry, `${t}/geometry`, n)) : r.warnings.push({
1803
+ code: d.MISSING_GEOMETRY,
1804
+ path: t
1805
+ }), r) : (r.statistics.FeatureCollection++, l.nonEmptyArray(e.features) ? r = L(r, w(e.features, (i, s) => Tt(i, s, n), `${t}/features`)) : l.array(e.features) || (r.valid = !1, r.errors.push({
1806
+ code: d.INVALID_FEATURES_ARRAY,
1807
+ path: t
1808
+ })), r)) : (r.valid = !1, r.errors.push({
1809
+ code: d.EMPTY_OBJECT,
1810
+ path: t
1811
+ }), r);
1812
+ }
1813
+ function Tr(e, t = {}) {
1814
+ _.that(e, l.nonEmptyObject, "geojson must be a non empty object");
1815
+ const { precision: n = v } = t;
1816
+ return e.type === p.FEATURE || e.type === p.FEATURE_COLLECTION ? Tt(e, "", { precision: n }) : l.oneOf(e.type, Object.values(m)) ? Re(e, "", { precision: n }) : {
1817
+ ...he(),
987
1818
  valid: !1,
988
- errors: [{ message: "Invalid GeoJson: type must be either a Geometry, a Feature or a FeatureCollection", path: "" }],
989
- warnings: [],
990
- statistics: T()
1819
+ errors: [{
1820
+ code: d.UNKNOWN_TYPE,
1821
+ path: "",
1822
+ params: { type: e.type }
1823
+ }]
991
1824
  };
992
1825
  }
993
1826
  export {
994
- d as AXES,
995
- P as COORDINATE_FORMATS,
996
- Ye as COORDINATE_MODELS,
997
- Y as COORDINATE_TRUNCATION_FACTORS,
998
- M as CRS_TYPES,
999
- h as FEATURE_TYPES,
1000
- g as GEOMETRY_TYPES,
1001
- x as computeBBox,
1002
- kt as computeGeoJsonBoundingBox,
1003
- nt as computeGeoJsonConvexHull,
1004
- Nt as convertCoordinate,
1005
- re as getActiveLocales,
1006
- j as getAllDirectionSymbols,
1007
- J as getCoordinatePrecision,
1008
- Ne as getDirectionAxis,
1009
- St as getDirections,
1010
- Rt as getEast,
1011
- Ae as getLatitudeSymbols,
1012
- Re as getLocale,
1013
- B as getLocaleByCode,
1014
- Me as getLongitudeSymbols,
1015
- bt as getNorth,
1016
- Dt as getSouth,
1017
- At as getWest,
1018
- Z as guessCoordinateAxis,
1019
- ee as is3DBBox,
1020
- Xe as is3DPosition,
1021
- Ot as isAltitude,
1022
- Te as isAxis,
1023
- O as isDirection,
1024
- V as isEast,
1025
- k as isLatitude,
1026
- Gt as isLikeBBox,
1027
- xt as isLikeCRS,
1028
- Qe as isLikeFeature,
1029
- Ze as isLikeFeatureCollection,
1030
- Je as isLikeFeatureOrFeatureCollection,
1031
- F as isLikeGeoJson,
1032
- qe as isLikeGeometry,
1033
- Ut as isLikePosition,
1034
- ne as isLongitude,
1035
- Ce as isNorth,
1036
- _t as isSamePosition,
1037
- ie as isSouth,
1038
- A as isValidBBox,
1039
- y as isValidPosition,
1040
- $ as isWest,
1041
- Tt as listLocales,
1042
- Ft as mergeBBox,
1043
- Ct as normalizeCoordinate,
1044
- We as parseCoordinate,
1045
- wt as parsePosition,
1046
- It as registerLocale,
1047
- Lt as setLocale,
1048
- G as simplifyGeoJson,
1049
- ue as truncateBBox,
1050
- Mt as truncateCoordinate,
1051
- Pt as truncateGeoJson,
1052
- $t as truncatePosition,
1053
- at as validateBBox,
1054
- st as validateCRS,
1055
- Bt as validateGeoJson,
1056
- X as validateGeometry,
1057
- C as validatePosition
1827
+ O as AXES,
1828
+ fe as COORDINATE_FORMATS,
1829
+ Zt as COORDINATE_MODELS,
1830
+ Qt as COORDINATE_TRUNCATION_FACTORS,
1831
+ J as CRS_TYPES,
1832
+ v as DEFAULT_COORDINATE_PRECISION,
1833
+ at as EARTH_RADIUS,
1834
+ p as FEATURE_TYPES,
1835
+ m as GEOMETRY_TYPES,
1836
+ re as IS_SAME_POSITION_OPTIONS_SCHEMA,
1837
+ R as MAX_COORDINATE_PRECISION,
1838
+ mn as TRUNCATE_POSITIONS_OPTIONS_SCHEMA,
1839
+ d as VALIDATION_CODES,
1840
+ nt as WGS84,
1841
+ gn as closeRing,
1842
+ se as computeBBox,
1843
+ Er as computeGeoJsonBoundingBox,
1844
+ Tn as computeGeoJsonConvexHull,
1845
+ ir as convertCoordinate,
1846
+ lt as deduplicatePositions,
1847
+ sr as defineProjection,
1848
+ lr as destinationFromPosition,
1849
+ dn as distanceBetweenPositions,
1850
+ Or as extractGeoJsonBBox,
1851
+ Sn as extractGeoJsonCRS,
1852
+ mt as extractGeoJsonNode,
1853
+ Nr as fixGeoJson,
1854
+ Xe as getActiveLocales,
1855
+ Ue as getCoordinatePrecision,
1856
+ wt as getDirectionAxis,
1857
+ B as getDirectionSymbols,
1858
+ Qn as getDirections,
1859
+ tr as getEast,
1860
+ Ut as getLocale,
1861
+ Oe as getMessages,
1862
+ Jn as getNorth,
1863
+ or as getProjection,
1864
+ er as getSouth,
1865
+ nr as getWest,
1866
+ Pe as guessCoordinateAxis,
1867
+ F as hasProjection,
1868
+ Ve as is3DBBox,
1869
+ cn as is3DPosition,
1870
+ zn as isAltitude,
1871
+ ct as isClockwiseRing,
1872
+ Le as isClosedRing,
1873
+ Ne as isEast,
1874
+ pr as isGeoJsonFixable,
1875
+ X as isLatitude,
1876
+ Ir as isLikeBBox,
1877
+ mr as isLikeCRS,
1878
+ On as isLikeFeature,
1879
+ Nn as isLikeFeatureCollection,
1880
+ pn as isLikeFeatureOrFeatureCollection,
1881
+ G as isLikeGeoJson,
1882
+ En as isLikeGeometry,
1883
+ gr as isLikePosition,
1884
+ Ee as isLongitude,
1885
+ Vt as isNorth,
1886
+ pe as isSamePosition,
1887
+ ze as isSouth,
1888
+ He as isValidAxis,
1889
+ Z as isValidBBox,
1890
+ C as isValidDirection,
1891
+ dr as isValidLine,
1892
+ S as isValidPosition,
1893
+ ve as isValidPositions,
1894
+ Q as isValidRing,
1895
+ it as isWGS84Projection,
1896
+ ne as isWest,
1897
+ fr as lineLength,
1898
+ Kn as listLocales,
1899
+ ar as listProjections,
1900
+ cr as mergeBBox,
1901
+ rr as normalizeCoordinate,
1902
+ rt as normalizeCrsName,
1903
+ Jt as parseCoordinate,
1904
+ ur as parsePosition,
1905
+ Zn as registerMessages,
1906
+ vr as reprojectGeoJson,
1907
+ ot as reprojectPosition,
1908
+ oe as reprojectPositions,
1909
+ ft as ringSelfIntersections,
1910
+ dt as ringsIntersect,
1911
+ qn as setLocale,
1912
+ de as simplifyGeoJson,
1913
+ In as sphericalRingArea,
1914
+ ut as truncateBBox,
1915
+ Qe as truncateCoordinate,
1916
+ Lr as truncateGeoJson,
1917
+ st as truncatePosition,
1918
+ me as truncatePositions,
1919
+ we as truncateRing,
1920
+ Tr as validateGeoJson
1058
1921
  };
1059
1922
  //# sourceMappingURL=index.mjs.map