@kalisio/common-geospatial 0.6.0 → 0.7.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,116 +1,146 @@
1
- import { assert as l, is as i, has as M, conform as T, optional as $ } from "@kalisio/common-core";
2
- import { getLogger as j } from "@logtape/logtape";
3
- import { Heap as se } from "heap-js";
4
- import ae from "@turf/truncate";
5
- import oe from "@turf/boolean-clockwise";
6
- import le from "@turf/kinks";
1
+ import { assert as u, is as i, has as A, conform as T, optional as $ } from "@kalisio/common-core";
2
+ import { getLogger as Q } from "@logtape/logtape";
3
+ import { Heap as fe } from "heap-js";
4
+ import me from "@turf/truncate";
5
+ import de from "@turf/boolean-clockwise";
6
+ import pe from "@turf/kinks";
7
7
  const d = {
8
8
  LATITUDE: "LAT",
9
9
  LONGITUDE: "LON",
10
10
  ALTITUDE: "ALT"
11
11
  };
12
- function ue(e) {
13
- return l.that(e, i.string, "axis must be a string"), Object.values(d).includes(e);
12
+ function ve(e) {
13
+ return u.that(e, i.string, "axis must be a string"), Object.values(d).includes(e);
14
14
  }
15
- function N(e) {
16
- return l.that(e, i.string, "axis must be a string"), e === d.LATITUDE;
15
+ function M(e) {
16
+ return u.that(e, i.string, "axis must be a string"), e === d.LATITUDE;
17
17
  }
18
- function Y(e) {
19
- return l.that(e, i.string, "axis must be a string"), e === d.LONGITUDE;
18
+ function Z(e) {
19
+ return u.that(e, i.string, "axis must be a string"), e === d.LONGITUDE;
20
20
  }
21
- function et(e) {
22
- return l.that(e, i.string, "axis must be a string"), e === d.ALTITUDE;
21
+ function ut(e) {
22
+ return u.that(e, i.string, "axis must be a string"), e === d.ALTITUDE;
23
23
  }
24
- const ce = { NORTH: { label: "Nord", symbol: "N" }, SOUTH: { label: "Sud", symbol: "S" }, EAST: { label: "Est", symbol: "E" }, WEST: { label: "Ouest", symbol: "O" } }, ge = {
25
- DIRECTIONS: ce
26
- }, fe = { NORTH: { label: "North", symbol: "N" }, SOUTH: { label: "South", symbol: "S" }, EAST: { label: "East", symbol: "E" }, WEST: { label: "West", symbol: "W" } }, me = {
27
- DIRECTIONS: fe
28
- }, de = {
24
+ const Ee = { NORTH: { label: "Nord", symbol: "N" }, SOUTH: { label: "Sud", symbol: "S" }, EAST: { label: "Est", symbol: "E" }, WEST: { label: "Ouest", symbol: "O" } }, be = {
25
+ DIRECTIONS: Ee
26
+ }, he = { NORTH: { label: "North", symbol: "N" }, SOUTH: { label: "South", symbol: "S" }, EAST: { label: "East", symbol: "E" }, WEST: { label: "West", symbol: "W" } }, ye = {
27
+ DIRECTIONS: he
28
+ }, Oe = {
29
29
  DIRECTIONS: {
30
- NORTH: { label: i.string, symbol: i.string },
31
- SOUTH: { label: i.string, symbol: i.string },
32
- EAST: { label: i.string, symbol: i.string },
33
- WEST: { label: i.string, symbol: i.string }
30
+ NORTH: { label: i.string, symbol: i.char },
31
+ SOUTH: { label: i.string, symbol: i.char },
32
+ EAST: { label: i.string, symbol: i.char },
33
+ WEST: { label: i.string, symbol: i.char }
34
34
  }
35
- }, O = {
36
- en: me,
37
- fr: ge
35
+ }, h = {
36
+ en: ye,
37
+ fr: be
38
38
  };
39
- let A = "en";
40
- function tt() {
41
- return Object.keys(O);
39
+ let O = "en";
40
+ const Y = "en";
41
+ function lt() {
42
+ return Object.keys(h);
42
43
  }
43
- function nt(e, t) {
44
- l.all([
44
+ function ct(e, t) {
45
+ u.all([
45
46
  { value: e, validator: i.string, message: "code must be a string" },
46
- { value: e, validator: (r) => !M.key(O, r), message: "locale already registered" },
47
+ { value: e, validator: (r) => !A.key(h, r), message: "locale already registered" },
47
48
  { value: t, validator: i.plainObject, message: "content must be an object" },
48
- { value: t, validator: (r) => T.schema(r, de), message: "content does not conform to schema" }
49
- ]), O[e] = t;
49
+ { value: t, validator: (r) => T.schema(r, Oe), message: "content does not conform to schema" }
50
+ ]), h[e] = t;
50
51
  }
51
- function rt(e) {
52
- l.all([
52
+ function gt(e) {
53
+ u.all([
53
54
  { value: e, validator: i.string, message: "code must be a string" },
54
- { value: e, validator: (t) => M.key(O, t), message: "code is unknown" }
55
- ]), A = e;
55
+ { value: e, validator: (t) => A.key(h, t), message: "code is unknown" }
56
+ ]), O = e;
56
57
  }
57
- function pe() {
58
- return {
59
- code: A,
60
- content: O[A]
61
- };
58
+ function Te() {
59
+ return O;
62
60
  }
63
- function b() {
64
- return pe().content.DIRECTIONS;
61
+ function U(e) {
62
+ return u.all([
63
+ { value: e, validator: i.string, message: "code must be a string" },
64
+ { value: e, validator: (t) => A.key(h, t), message: "code is unknown" }
65
+ ]), h[e];
65
66
  }
66
- function R(e, t) {
67
- const r = b(), n = r[e].label.toUpperCase(), s = r[e].symbol.toUpperCase();
68
- return t.toUpperCase() === n || t.toUpperCase() === s;
67
+ function J() {
68
+ return O === Y ? [O] : [O, Y];
69
69
  }
70
- function it(e = null) {
71
- const t = b();
72
- return i.defined(e) ? (l.that(e, ue, "axis must be a valid axis"), N(e) ? [t.SOUTH, t.NORTH] : Y(e) ? [t.EAST, t.WEST] : []) : [t.SOUTH, t.NORTH, t.EAST, t.WEST];
70
+ function _(e) {
71
+ const t = /* @__PURE__ */ new Set();
72
+ for (const r of J()) {
73
+ const { DIRECTIONS: n } = U(r);
74
+ for (const s of e) t.add(n[s].symbol);
75
+ }
76
+ return [...t];
73
77
  }
74
- function st() {
75
- return b().NORTH;
78
+ function Ie() {
79
+ return _(["NORTH", "SOUTH"]);
76
80
  }
77
- function at() {
78
- return b().SOUTH;
81
+ function Le() {
82
+ return _(["EAST", "WEST"]);
79
83
  }
80
- function ot() {
81
- return b().EAST;
84
+ function F() {
85
+ return _(["NORTH", "SOUTH", "EAST", "WEST"]);
82
86
  }
83
- function lt() {
84
- return b().WEST;
87
+ function I() {
88
+ return U(Te()).DIRECTIONS;
89
+ }
90
+ function w(e, t) {
91
+ const r = t.toUpperCase();
92
+ return J().some((n) => {
93
+ const { label: s, symbol: o } = U(n).DIRECTIONS[e];
94
+ return r === s.toUpperCase() || r === o.toUpperCase();
95
+ });
96
+ }
97
+ function ft(e = null) {
98
+ const t = I();
99
+ return i.defined(e) ? (u.that(e, ve, "axis must be a valid axis"), M(e) ? [t.SOUTH, t.NORTH] : Z(e) ? [t.EAST, t.WEST] : []) : [t.SOUTH, t.NORTH, t.EAST, t.WEST];
100
+ }
101
+ function mt() {
102
+ return I().NORTH;
103
+ }
104
+ function dt() {
105
+ return I().SOUTH;
106
+ }
107
+ function pt() {
108
+ return I().EAST;
109
+ }
110
+ function vt() {
111
+ return I().WEST;
85
112
  }
86
113
  function E(e) {
87
- return l.that(e, i.string, "dir must be a string"), ve(e) || B(e) || X(e) || _(e);
114
+ return u.that(e, i.string, "dir must be a string"), Se(e) || ee(e) || k(e) || C(e);
88
115
  }
89
- function ve(e) {
90
- return l.that(e, i.string, "dir must be a string"), R("NORTH", e);
116
+ function Se(e) {
117
+ return u.that(e, i.string, "dir must be a string"), w("NORTH", e);
91
118
  }
92
- function B(e) {
93
- return l.that(e, i.string, "dir must be a string"), R("SOUTH", e);
119
+ function ee(e) {
120
+ return u.that(e, i.string, "dir must be a string"), w("SOUTH", e);
94
121
  }
95
- function X(e) {
96
- return l.that(e, i.string, "dir must be a string"), R("EAST", e);
122
+ function k(e) {
123
+ return u.that(e, i.string, "dir must be a string"), w("EAST", e);
97
124
  }
98
- function _(e) {
99
- return l.that(e, i.string, "dir must be a string"), R("WEST", e);
125
+ function C(e) {
126
+ return u.that(e, i.string, "dir must be a string"), w("WEST", e);
100
127
  }
101
- function Ee(e) {
102
- return l.that(e, E, "dir must be a direction"), _(e) || X(e) ? d.LONGITUDE : d.LATITUDE;
128
+ function Re(e) {
129
+ return u.that(e, E, "dir must be a direction"), C(e) || k(e) ? d.LONGITUDE : d.LATITUDE;
103
130
  }
104
- const be = {
131
+ const De = {
105
132
  degrees: i.number,
106
133
  direction: $(E)
107
- }, he = /^(-?\d{1,3}(?:\.\d+)?)°?$/, ye = /^(\d{1,3}(?:\.\d+)?)°?([NSEW])$/;
108
- function I(e) {
134
+ }, Ae = /^(-?\d{1,3}(?:\.\d+)?)°?$/;
135
+ function we() {
136
+ return new RegExp(`^(\\d{1,3}(?:\\.\\d+)?)°?([${F()}])$`, "i");
137
+ }
138
+ function L(e) {
109
139
  let t = null, r = null;
110
- if (i.plainObject(e) && T.schema(e, be))
140
+ if (i.plainObject(e) && T.schema(e, De))
111
141
  i.defined(e.direction) ? e.degrees >= 0 && (t = e.degrees, r = e.direction) : t = e.degrees;
112
142
  else if (i.string(e)) {
113
- const n = e.replace(/\s+/g, ""), s = n.match(he) ?? n.match(ye);
143
+ const n = e.replace(/\s+/g, ""), s = n.match(Ae) ?? n.match(we());
114
144
  s && (t = parseFloat(s[1]), r = s[2] ?? null);
115
145
  }
116
146
  return {
@@ -127,26 +157,29 @@ function I(e) {
127
157
  return i.number(t);
128
158
  },
129
159
  toString(n) {
130
- if (l.that(n, i.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
160
+ if (u.that(n, i.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
131
161
  let s = `${t.toFixed(n)}°`;
132
162
  return r && (s += ` ${r}`), s;
133
163
  },
134
164
  toDecimal() {
135
- return this.isValid() ? I({ degrees: t, direction: r }) : null;
165
+ return this.isValid() ? L({ degrees: t, direction: r }) : null;
136
166
  }
137
167
  };
138
168
  }
139
- const Oe = {
169
+ const Ce = {
140
170
  degrees: i.integer,
141
171
  minutes: (e) => i.inRangeExclusiveMax(e, 0, 60),
142
172
  direction: $(E)
143
- }, Te = /^(-?\d{1,3})°(\d{1,2}(?:\.\d+)?)'?$/, Ie = /^(\d{1,3})°(\d{1,2}(?:\.\d+)?)'?([NSEW])$/;
144
- function K(e) {
173
+ }, Ne = /^(-?\d{1,3})°(\d{1,2}(?:\.\d+)?)'?$/;
174
+ function Me() {
175
+ return new RegExp(`^(\\d{1,3})°(\\d{1,2}(?:\\.\\d+)?)'?([${F().join("")}])$`, "i");
176
+ }
177
+ function te(e) {
145
178
  let t = null, r = null, n = null;
146
- if (i.plainObject(e) && T.schema(e, Oe))
179
+ if (i.plainObject(e) && T.schema(e, Ce))
147
180
  i.defined(e.direction) ? e.degrees >= 0 && (t = e.degrees, r = e.minutes, n = e.direction) : (t = e.degrees, r = e.minutes);
148
181
  else if (i.string(e)) {
149
- const s = e.replace(/\s+/g, ""), o = s.match(Te) ?? s.match(Ie);
182
+ const s = e.replace(/\s+/g, ""), o = s.match(Ne) ?? s.match(Me());
150
183
  o && (t = parseFloat(o[1]), r = parseFloat(o[2]), n = o[3] ?? null);
151
184
  }
152
185
  return {
@@ -166,26 +199,32 @@ function K(e) {
166
199
  return i.integer(t) && i.inRangeExclusiveMax(r, 0, 60);
167
200
  },
168
201
  toString(s) {
169
- if (l.that(s, i.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
202
+ if (u.that(s, i.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
170
203
  let o = `${t}° ${r.toFixed(s)}'`;
171
204
  return n && (o += ` ${n}`), o;
172
205
  },
173
206
  toDecimal() {
174
- return this.isValid() ? I({ degrees: t + r / 60, direction: n }) : null;
207
+ return this.isValid() ? L({ degrees: t + r / 60, direction: n }) : null;
175
208
  }
176
209
  };
177
210
  }
178
- const Le = {
211
+ const xe = {
179
212
  degrees: i.nonNegativeInteger,
180
213
  minutes: (e) => i.inRangeExclusiveMax(e, 0, 60),
181
214
  direction: E
182
- }, De = /^(\d{2})(\d{3})([NS])$/, Re = /^(\d{3})(\d{3})([EW])$/;
183
- function z(e) {
215
+ };
216
+ function $e() {
217
+ return new RegExp(`^(\\d{2})(\\d{3})([${Ie().join("")}])$`, "i");
218
+ }
219
+ function Ue() {
220
+ return new RegExp(`^(\\d{3})(\\d{3})([${Le().join("")}])$`, "i");
221
+ }
222
+ function ne(e) {
184
223
  let t = null, r = null, n = null;
185
- if (i.plainObject(e) && T.schema(e, Le))
224
+ if (i.plainObject(e) && T.schema(e, xe))
186
225
  t = e.degrees, r = e.minutes, n = e.direction;
187
226
  else if (i.string(e)) {
188
- const s = e.trim(), o = s.match(De) ?? s.match(Re);
227
+ const s = e.trim(), o = s.match($e()) ?? s.match(Ue());
189
228
  o && (t = parseFloat(o[1]), r = parseFloat(o[2]) / 10, n = o[3]);
190
229
  }
191
230
  return {
@@ -206,27 +245,30 @@ function z(e) {
206
245
  },
207
246
  toString() {
208
247
  if (!this.isValid()) return "";
209
- const s = n === "E" || n === "W", o = String(t).padStart(s ? 3 : 2, "0"), u = Math.floor(r * 10).toString().padStart(3, "0");
210
- return `${o}${u}${n}`;
248
+ const s = k(n) || C(n), o = String(t).padStart(s ? 3 : 2, "0"), l = Math.floor(r * 10).toString().padStart(3, "0");
249
+ return `${o}${l}${n}`;
211
250
  },
212
251
  toDecimal() {
213
- return this.isValid() ? I({ degrees: t + r / 60, direction: n }) : null;
252
+ return this.isValid() ? L({ degrees: t + r / 60, direction: n }) : null;
214
253
  }
215
254
  };
216
255
  }
217
- const Se = {
256
+ const _e = {
218
257
  degrees: i.integer,
219
258
  minutes: (e) => i.integer(e) && i.inRange(e, 0, 59),
220
259
  seconds: (e) => i.inRangeExclusiveMax(e, 0, 60),
221
260
  direction: $(E)
222
- }, Ne = /^(-?\d{1,3})°(\d{1,2})'(\d{1,2}(?:\.\d+)?)"?$/, Ae = /^(\d{1,3})°(\d{1,2})'(\d{1,2}(?:\.\d+)?)"?([NSEW])$/;
223
- function q(e) {
261
+ }, Fe = /^(-?\d{1,3})°(\d{1,2})'(\d{1,2}(?:\.\d+)?)"?$/;
262
+ function ke() {
263
+ return new RegExp(`^(\\d{1,3})°(\\d{1,2})'(\\d{1,2}(?:\\.\\d+)?)"?([${F().join("")}])$`, "i");
264
+ }
265
+ function re(e) {
224
266
  let t = null, r = null, n = null, s = null;
225
- if (i.plainObject(e) && T.schema(e, Se))
267
+ if (i.plainObject(e) && T.schema(e, _e))
226
268
  i.defined(e.direction) ? e.degrees >= 0 && (t = e.degrees, r = e.minutes, n = e.seconds, s = e.direction) : (t = e.degrees, r = e.minutes, n = e.seconds);
227
269
  else if (i.string(e)) {
228
- const o = e.replace(/\s+/g, ""), u = o.match(Ne) ?? o.match(Ae);
229
- u && (t = parseFloat(u[1]), r = parseFloat(u[2]), n = parseFloat(u[3]), s = u[4] ?? null);
270
+ const o = e.replace(/\s+/g, ""), l = o.match(Fe) ?? o.match(ke());
271
+ l && (t = parseFloat(l[1]), r = parseFloat(l[2]), n = parseFloat(l[3]), s = l[4] ?? null);
230
272
  }
231
273
  return {
232
274
  get degrees() {
@@ -248,127 +290,127 @@ function q(e) {
248
290
  return i.integer(t) && i.integer(r) && i.inRange(r, 0, 59) && i.inRangeExclusiveMax(n, 0, 60);
249
291
  },
250
292
  toString(o) {
251
- if (l.that(o, i.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
252
- let u = `${t}° ${r}' ${n.toFixed(o)}"`;
253
- return s && (u += ` ${s}`), u;
293
+ if (u.that(o, i.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
294
+ let l = `${t}° ${r}' ${n.toFixed(o)}"`;
295
+ return s && (l += ` ${s}`), l;
254
296
  },
255
297
  toDecimal() {
256
- return this.isValid() ? I({ degrees: t + r / 60 + n / 3600, direction: s }) : null;
298
+ return this.isValid() ? L({ degrees: t + r / 60 + n / 3600, direction: s }) : null;
257
299
  }
258
300
  };
259
301
  }
260
- function P(e) {
302
+ function W(e) {
261
303
  const t = Math.floor(e.degrees), r = (e.degrees - t) * 60;
262
304
  return { degrees: t, minutes: r, direction: e.direction };
263
305
  }
264
- function Ce(e) {
306
+ function Ge(e) {
265
307
  const t = Math.floor(e.degrees), r = (e.degrees - t) * 60, n = Math.floor(r), s = (r - n) * 60;
266
308
  return { degrees: t, minutes: n, seconds: s, direction: e.direction };
267
309
  }
268
- const H = {
269
- DD: (e) => (l.that(e, (t) => t.isValid(), "dd must be a valid coordinate"), e),
310
+ const K = {
311
+ DD: (e) => (u.that(e, (t) => t.isValid(), "dd must be a valid coordinate"), e),
270
312
  DDM: (e) => {
271
- l.that(e, (s) => s.isValid(), "dd must be a valid coordinate");
272
- const { degrees: t, minutes: r, direction: n } = P(e);
273
- return K(n ? { degrees: t, minutes: r, direction: n } : { degrees: t, minutes: r });
313
+ u.that(e, (s) => s.isValid(), "dd must be a valid coordinate");
314
+ const { degrees: t, minutes: r, direction: n } = W(e);
315
+ return te(n ? { degrees: t, minutes: r, direction: n } : { degrees: t, minutes: r });
274
316
  },
275
317
  DMS: (e) => {
276
- l.that(e, (o) => o.isValid(), "dd must be a valid coordinate");
277
- const { degrees: t, minutes: r, seconds: n, direction: s } = Ce(e);
278
- return q(s ? { degrees: t, minutes: r, seconds: n, direction: s } : { degrees: t, minutes: r, seconds: n });
318
+ u.that(e, (o) => o.isValid(), "dd must be a valid coordinate");
319
+ const { degrees: t, minutes: r, seconds: n, direction: s } = Ge(e);
320
+ return re(s ? { degrees: t, minutes: r, seconds: n, direction: s } : { degrees: t, minutes: r, seconds: n });
279
321
  },
280
322
  DDM_AERO: (e) => {
281
- l.that(e, (s) => s.isValid(), "dd must be a valid coordinate");
282
- const { degrees: t, minutes: r, direction: n } = P(e);
283
- return z({ degrees: t, minutes: r, direction: n });
323
+ u.that(e, (s) => s.isValid(), "dd must be a valid coordinate");
324
+ const { degrees: t, minutes: r, direction: n } = W(e);
325
+ return ne({ degrees: t, minutes: r, direction: n });
284
326
  }
285
- }, C = {
327
+ }, x = {
286
328
  DD: "DD",
287
329
  DDM: "DDM",
288
330
  DDM_AERO: "DDM_AERO",
289
331
  DMS: "DMS"
290
- }, we = {
291
- DD: I,
292
- DDM: K,
293
- DDM_AERO: z,
294
- DMS: q
295
- }, x = Array.from({ length: 9 }, (e, t) => 10 ** t);
296
- function V(e, t) {
297
- if (l.that(e, i.number, "coord must be a number"), i.defined(t))
298
- return l.that(t, E, "dir must be a direction"), Ee(t);
332
+ }, Pe = {
333
+ DD: L,
334
+ DDM: te,
335
+ DDM_AERO: ne,
336
+ DMS: re
337
+ }, G = Array.from({ length: 9 }, (e, t) => 10 ** t);
338
+ function X(e, t) {
339
+ if (u.that(e, i.number, "coord must be a number"), i.defined(t))
340
+ return u.that(t, E, "dir must be a direction"), Re(t);
299
341
  if (Math.abs(e) > 90) return d.LONGITUDE;
300
342
  }
301
- function W(e) {
302
- l.that(e, i.number, "coord must be a number");
343
+ function z(e) {
344
+ u.that(e, i.number, "coord must be a number");
303
345
  const t = e.toExponential(), [r, n] = t.split("e").map(Number), s = (r.toString().split(".")[1] || "").length;
304
346
  return Math.max(0, s - n);
305
347
  }
306
- function ut(e, t = 7) {
307
- l.all([
348
+ function Et(e, t = 7) {
349
+ u.all([
308
350
  { value: e, validator: i.number, message: "coord must be a number" },
309
351
  { value: t, validator: (n) => i.inRange(n, 0, 8), message: "precision must be in range [0, 8]" }
310
352
  ]);
311
- const r = x[t];
353
+ const r = G[t];
312
354
  return Math.round(e * r) / r;
313
355
  }
314
- function ct(e, t) {
315
- if (l.all([
356
+ function bt(e, t) {
357
+ if (u.all([
316
358
  { value: e, validator: i.number, message: "coord must be a number" },
317
- { value: t, validator: (n) => Y(n) || N(n), message: "axis must be either a longitude or latitude" }
318
- ]), N(t))
359
+ { value: t, validator: (n) => Z(n) || M(n), message: "axis must be either a longitude or latitude" }
360
+ ]), M(t))
319
361
  return Math.max(-90, Math.min(90, e));
320
362
  let r = ((e + 180) % 360 + 360) % 360 - 180;
321
363
  return r === -180 && (r = 180), Object.is(r, -0) && (r = 0), r;
322
364
  }
323
- function gt(e, t) {
324
- l.all([
365
+ function ht(e, t) {
366
+ u.all([
325
367
  { value: e, validator: (n) => i.defined(n) && n.isValid(), message: "from must be a valid coordinate" },
326
- { value: t, validator: (n) => M.key(H, n), message: `unknown format: ${t}` }
368
+ { value: t, validator: (n) => A.key(K, n), message: `unknown format: ${t}` }
327
369
  ]);
328
- const r = e.format === C.DD ? e : e.toDecimal();
329
- return r.isValid() ? t === C.DD ? r : H[t](r) : null;
370
+ const r = e.format === x.DD ? e : e.toDecimal();
371
+ return r.isValid() ? t === x.DD ? r : K[t](r) : null;
330
372
  }
331
- function Me(e) {
332
- l.that(e, i.nonEmptyString, "pattern must be a non empty string");
333
- for (const t of Object.keys(C)) {
334
- const r = we[t](e);
373
+ function He(e) {
374
+ u.that(e, i.nonEmptyString, "pattern must be a non empty string");
375
+ for (const t of Object.keys(x)) {
376
+ const r = Pe[t](e);
335
377
  if (r.isValid()) return r;
336
378
  }
337
379
  return null;
338
380
  }
339
- function ft(e) {
340
- l.that(e, (a) => i.nonEmptyString(a), "pattern must be a non-empty string");
381
+ function yt(e) {
382
+ u.that(e, (a) => i.nonEmptyString(a), "pattern must be a non-empty string");
341
383
  const t = e.split(/[,;|]/);
342
384
  if (t.length !== 2) return null;
343
- const [r, n] = t.map(Me);
385
+ const [r, n] = t.map(He);
344
386
  if (!r || !n) return null;
345
- const s = r.toDecimal(), o = n.toDecimal(), u = V(s.degrees, s.direction), g = V(o.degrees, o.direction), c = (a) => {
346
- const { degrees: p, direction: m } = a;
347
- return m && (_(m) || B(m)) ? -p : p;
387
+ const s = r.toDecimal(), o = n.toDecimal(), l = X(s.degrees, s.direction), g = X(o.degrees, o.direction), c = (a) => {
388
+ const { degrees: p, direction: f } = a;
389
+ return f && (C(f) || ee(f)) ? -p : p;
348
390
  };
349
- if (u === d.LONGITUDE && g === d.LATITUDE) return [c(s), c(o)];
350
- if (g === d.LONGITUDE && u === d.LATITUDE) return [c(o), c(s)];
351
- if (u === d.LONGITUDE && !g) return [c(s), o];
352
- if (u === d.LATITUDE && !g) return [c(o), c(s)];
353
- if (g === d.LONGITUDE && !u) return [c(o), c(s)];
354
- if (g === d.LATITUDE && !u) return [c(s), c(o)];
355
- if (!u && !g)
391
+ if (l === d.LONGITUDE && g === d.LATITUDE) return [c(s), c(o)];
392
+ if (g === d.LONGITUDE && l === d.LATITUDE) return [c(o), c(s)];
393
+ if (l === d.LONGITUDE && !g) return [c(s), o];
394
+ if (l === d.LATITUDE && !g) return [c(o), c(s)];
395
+ if (g === d.LONGITUDE && !l) return [c(o), c(s)];
396
+ if (g === d.LATITUDE && !l) return [c(s), c(o)];
397
+ if (!l && !g)
356
398
  return [
357
399
  [c(s), c(o)],
358
400
  [c(o), c(s)]
359
401
  ];
360
402
  }
361
- function $e(e) {
403
+ function Ve(e) {
362
404
  return !i.arrayOfLength(e, 4) && !i.arrayOfLength(e, 6) ? !1 : e.every(i.number);
363
405
  }
364
- const L = {
406
+ const S = {
365
407
  NAME: "name",
366
408
  LINK: "link"
367
409
  };
368
- function mt(e) {
369
- return i.plainObject(e) ? e.type === L.NAME ? i.nonEmptyString(e.properties?.name) : e.type === L.LINK ? i.nonEmptyString(e.properties?.href) : !1 : !1;
410
+ function Ot(e) {
411
+ return i.plainObject(e) ? e.type === S.NAME ? i.nonEmptyString(e.properties?.name) : e.type === S.LINK ? i.nonEmptyString(e.properties?.href) : !1 : !1;
370
412
  }
371
- const f = {
413
+ const m = {
372
414
  POINT: "Point",
373
415
  MULTI_POINT: "MultiPoint",
374
416
  LINESTRING: "LineString",
@@ -377,43 +419,43 @@ const f = {
377
419
  MULTI_POLYGON: "MultiPolygon",
378
420
  GEOMETRY_COLLECTION: "GeometryCollection"
379
421
  };
380
- function G(e) {
381
- return !i.plainObject(e) || !i.oneOf(e.type, Object.values(f)) ? !1 : e.type === f.GEOMETRY_COLLECTION ? i.array(e.geometries) : i.array(e.coordinates);
422
+ function P(e) {
423
+ return !i.plainObject(e) || !i.oneOf(e.type, Object.values(m)) ? !1 : e.type === m.GEOMETRY_COLLECTION ? i.array(e.geometries) : i.array(e.coordinates);
382
424
  }
383
425
  const v = {
384
426
  FEATURE: "Feature",
385
427
  FEATURE_COLLECTION: "FeatureCollection"
386
428
  };
387
- function _e(e) {
429
+ function je(e) {
388
430
  return i.plainObject(e) ? v.FEATURE === e.type : !1;
389
431
  }
390
- function xe(e) {
432
+ function Be(e) {
391
433
  return !i.plainObject(e) || e.type !== v.FEATURE_COLLECTION ? !1 : i.array(e.features);
392
434
  }
393
- function Q(e) {
394
- return i.plainObject(e) ? G(e) || _e(e) ? !0 : xe(e) : !1;
435
+ function ie(e) {
436
+ return i.plainObject(e) ? P(e) || je(e) ? !0 : Be(e) : !1;
395
437
  }
396
- function Ge(e) {
438
+ function Ye(e) {
397
439
  return i.arrayOfLengthBetween(e, 2, 3) ? e.every(i.number) : !1;
398
440
  }
399
- function Ue(e, t, r) {
441
+ function We(e, t, r) {
400
442
  return Math.abs(
401
443
  (e[0] * (t[1] - r[1]) + t[0] * (r[1] - e[1]) + r[0] * (e[1] - t[1])) / 2
402
444
  );
403
445
  }
404
- function S(e, { tolerance: t = 0, getWeight: r = () => 1 } = {}) {
446
+ function N(e, { tolerance: t = 0, getWeight: r = () => 1 } = {}) {
405
447
  if (e.length <= 2) return e;
406
448
  const n = e.map((a, p) => ({ coord: a, i: p, area: 1 / 0, removed: !1, prev: null, next: null }));
407
449
  for (let a = 0; a < n.length; a++)
408
450
  a > 0 && (n[a].prev = n[a - 1]), a < n.length - 1 && (n[a].next = n[a + 1]);
409
- const s = (a) => !a.prev || !a.next ? 1 / 0 : Ue(a.prev.coord, a.coord, a.next.coord) * r(a.coord, a.i), o = new se((a, p) => a.area - p.area);
451
+ const s = (a) => !a.prev || !a.next ? 1 / 0 : We(a.prev.coord, a.coord, a.next.coord) * r(a.coord, a.i), o = new fe((a, p) => a.area - p.area);
410
452
  for (let a = 1; a < n.length - 1; a++)
411
453
  n[a].area = s(n[a]), n[a]._currentArea = n[a].area, o.push(n[a]);
412
- let u = 0;
454
+ let l = 0;
413
455
  for (; o.size() > 0; ) {
414
456
  const a = o.pop();
415
457
  if (!a.removed && a.area === a._currentArea) {
416
- if (a.area < u ? a.area = u : u = a.area, a.area >= t) break;
458
+ if (a.area < l ? a.area = l : l = a.area, a.area >= t) break;
417
459
  a.removed = !0, a.prev && (a.prev.next = a.next), a.next && (a.next.prev = a.prev), a.prev?.prev && (a.prev.area = s(a.prev), a.prev._currentArea = a.prev.area, o.push(a.prev)), a.next?.next && (a.next.area = s(a.next), a.next._currentArea = a.next.area, o.push(a.next));
418
460
  }
419
461
  }
@@ -423,92 +465,98 @@ function S(e, { tolerance: t = 0, getWeight: r = () => 1 } = {}) {
423
465
  c.removed || g.push(c.coord), c = c.next;
424
466
  return g;
425
467
  }
426
- function U(e, t) {
427
- switch (l.all([
428
- { value: e, validator: G, message: "geometry must be a GeoJson geometry" }
468
+ function H(e, t) {
469
+ switch (u.all([
470
+ { value: e, validator: P, message: "geometry must be a GeoJson geometry" }
429
471
  ]), e.type) {
430
- case f.LINESTRING:
431
- e.coordinates = S(e.coordinates, t);
472
+ case m.LINESTRING:
473
+ e.coordinates = N(e.coordinates, t);
432
474
  break;
433
- case f.POLYGON:
434
- case f.MULTI_LINESTRING:
435
- e.coordinates = e.coordinates.map((r) => S(r, t));
475
+ case m.POLYGON:
476
+ case m.MULTI_LINESTRING:
477
+ e.coordinates = e.coordinates.map((r) => N(r, t));
436
478
  break;
437
- case f.MULTI_POLYGON:
438
- e.coordinates = e.coordinates.map((r) => r.map((n) => S(n, t)));
479
+ case m.MULTI_POLYGON:
480
+ e.coordinates = e.coordinates.map((r) => r.map((n) => N(n, t)));
439
481
  break;
440
- case f.GEOMETRY_COLLECTION:
441
- e.geometries.forEach((r) => U(r, t));
482
+ case m.GEOMETRY_COLLECTION:
483
+ e.geometries.forEach((r) => H(r, t));
442
484
  break;
443
485
  }
444
486
  return e;
445
487
  }
446
- const Fe = j(["common-ekosystem", "simplify", "geojson"]);
447
- function Z(e, t) {
488
+ const Ke = Q(["common-ekosystem", "simplify", "geojson"]);
489
+ function se(e, t) {
448
490
  if (e.type === v.FEATURE)
449
- e.geometry && U(e.geometry, t);
491
+ e.geometry && H(e.geometry, t);
450
492
  else if (e.type === v.FEATURE_COLLECTION)
451
- for (const r of e.features) Z(r, t);
493
+ for (const r of e.features) se(r, t);
452
494
  else
453
- Fe.warn('Unknown feature type "{type}", skipping.', { type: e.type });
495
+ Ke.warn('Unknown feature type "{type}", skipping.', { type: e.type });
454
496
  return e;
455
497
  }
456
- function dt(e, t) {
457
- return l.all([
458
- { value: e, validator: Q, message: "geoJson must be a GeoJson object" }
459
- ]), i.oneOf(e.type, Object.values(f)) ? U(e, t) : Z(e, t);
498
+ function Tt(e, t) {
499
+ return u.all([
500
+ { value: e, validator: ie, message: "geoJson must be a GeoJson object" }
501
+ ]), i.oneOf(e.type, Object.values(m)) ? H(e, t) : se(e, t);
460
502
  }
461
- function J(e, t = 7) {
462
- l.all([
463
- { value: e, validator: $e, message: "bbox must be bounding box" },
503
+ function ae(e, t = 7) {
504
+ u.all([
505
+ { value: e, validator: Ve, message: "bbox must be bounding box" },
464
506
  { value: t, validator: (n) => i.inRange(n, 0, 8), message: "precision must be in range [0, 8]" }
465
507
  ]);
466
- const r = x[t];
508
+ const r = G[t];
467
509
  for (let n = 0; n < e.length; n++)
468
510
  e[n] = Math.round(e[n] * r) / r;
469
511
  return e;
470
512
  }
471
- function ee(e, t = 7) {
472
- l.all([
473
- { value: e, validator: G, message: "geometry must be a GeoJson geometry" },
513
+ function oe(e, t = 7) {
514
+ u.all([
515
+ { value: e, validator: P, message: "geometry must be a GeoJson geometry" },
474
516
  { value: t, validator: (n) => i.inRange(n, 0, 8), message: "precision must be in range [0, 8]" }
475
517
  ]);
476
- const r = ae(e, { precision: t, mutate: !0 });
477
- return r.bbox && J(r.bbox, t), r;
518
+ const r = me(e, { precision: t, mutate: !0 });
519
+ return r.bbox && ae(r.bbox, t), r;
478
520
  }
479
- const ke = j(["common-ekosystem", "truncate", "geojson"]);
480
- function te(e, t) {
521
+ const Xe = Q(["common-ekosystem", "truncate", "geojson"]);
522
+ function ue(e, t) {
481
523
  if (e.type === v.FEATURE)
482
- e.geometry && ee(e.geometry, t);
524
+ e.geometry && oe(e.geometry, t);
483
525
  else if (e.type === v.FEATURE_COLLECTION)
484
- for (const r of e.features) te(r, t);
526
+ for (const r of e.features) ue(r, t);
485
527
  else
486
- ke.warn('Unknown feature type "{type}", skipping.', { type: e.type });
487
- return e.bbox && J(e.bbox, t), e;
528
+ Xe.warn('Unknown feature type "{type}", skipping.', { type: e.type });
529
+ return e.bbox && ae(e.bbox, t), e;
488
530
  }
489
- function pt(e, t = 7) {
490
- return l.all([
491
- { value: e, validator: Q, message: "geoJson must be a valid GeoJson" },
531
+ function It(e, t = 7) {
532
+ return u.all([
533
+ { value: e, validator: ie, message: "geoJson must be a valid GeoJson" },
492
534
  { value: t, validator: (r) => i.inRange(r, 0, 8), message: "precision must be in range [0, 8]" }
493
- ]), i.oneOf(e.type, Object.values(f)) ? ee(e, t) : te(e, t);
535
+ ]), i.oneOf(e.type, Object.values(m)) ? oe(e, t) : ue(e, t);
494
536
  }
495
- function vt(e, t = 7) {
496
- l.all([
497
- { value: e, validator: Ge, message: "position must be a position" },
537
+ function Lt(e, t = 7) {
538
+ u.all([
539
+ { value: e, validator: Ye, message: "position must be a position" },
498
540
  { value: t, validator: (n) => i.inRange(n, 0, 8), message: "precision must be in range [0, 8]" }
499
541
  ]);
500
- const r = x[t];
542
+ const r = G[t];
501
543
  for (let n = 0; n < e.length; n++)
502
544
  e[n] = Math.round(e[n] * r) / r;
503
545
  return e;
504
546
  }
505
- function D(e) {
547
+ function R(e) {
506
548
  if (!i.arrayOfLengthBetween(e, 2, 3))
507
549
  return {
508
550
  valid: !1,
509
551
  errors: [{ message: "Invalid coordinates: must be an array of 2 or 3 coordinates" }],
510
552
  warnings: []
511
553
  };
554
+ if (!i.number(e[0]) || !i.number(e[1]))
555
+ return {
556
+ valid: !1,
557
+ errors: [{ message: "Invalid coordinates: longitude and latitude must be numbers" }],
558
+ warnings: []
559
+ };
512
560
  if (!i.inRange(e[0], -180, 180))
513
561
  return {
514
562
  valid: !1,
@@ -527,43 +575,52 @@ function D(e) {
527
575
  errors: [{ message: "Invalid coordinates: altitude must be a number" }],
528
576
  warnings: []
529
577
  };
530
- const t = { valid: !0, errors: [], warnings: [] }, r = W(e[0]);
578
+ const t = { valid: !0, errors: [], warnings: [] }, r = z(e[0]);
531
579
  r > 6 && t.warnings.push({ message: `longitude precision is high (${r} decimals, max recommended: 6)` });
532
- const n = W(e[1]);
580
+ const n = z(e[1]);
533
581
  return n > 6 && t.warnings.push({ message: `latitude precision is high (${n} decimals, max recommended: 6)` }), t;
534
582
  }
535
- function Pe(e) {
583
+ function ze(e) {
536
584
  if (!i.arrayOfLength(e, 4) && !i.arrayOfLength(e, 6))
537
585
  return {
538
586
  valid: !1,
539
587
  errors: [{ message: "Invalid bbox: must be an array of 4 (2D) or 6 (3D) numbers" }],
540
588
  warnings: []
541
589
  };
542
- const t = e.length === 4, r = t ? [e[0], e[1]] : [e[0], e[1], e[2]], n = t ? [e[2], e[3]] : [e[3], e[4], e[5]], s = D(r);
590
+ const t = e.length === 4, r = t ? [e[0], e[1]] : [e[0], e[1], e[2]], n = t ? [e[2], e[3]] : [e[3], e[4], e[5]], s = R(r);
543
591
  if (!s.valid)
544
592
  return {
545
593
  valid: !1,
546
- errors: s.errors.map((m) => ({ ...m, message: `Invalid bbox south-west: ${m.message}` })),
594
+ errors: s.errors.map((f) => ({ ...f, message: `Invalid bbox south-west: ${f.message}` })),
547
595
  warnings: []
548
596
  };
549
- const o = D(n);
597
+ const o = R(n);
550
598
  if (!o.valid)
551
599
  return {
552
600
  valid: !1,
553
- errors: o.errors.map((m) => ({ ...m, message: `Invalid bbox north-east: ${m.message}` })),
601
+ errors: o.errors.map((f) => ({ ...f, message: `Invalid bbox north-east: ${f.message}` })),
554
602
  warnings: []
555
603
  };
556
- const [u, g] = r, [c, a] = n;
604
+ const [l, g] = r, [c, a] = n;
557
605
  if (g > a)
558
606
  return {
559
607
  valid: !1,
560
608
  errors: [{ message: `Invalid bbox: south (${g}) must be <= north (${a})` }],
561
609
  warnings: []
562
610
  };
611
+ if (!t) {
612
+ const f = e[2], B = e[5];
613
+ if (f > B)
614
+ return {
615
+ valid: !1,
616
+ errors: [{ message: `Invalid bbox: min altitude (${f}) must be <= max altitude (${B})` }],
617
+ warnings: []
618
+ };
619
+ }
563
620
  const p = { valid: !0, errors: [], warnings: [] };
564
- return u > c && p.warnings.push({ message: `bbox crosses the antimeridian (west: ${u} > east: ${c})` }), p.warnings.push(...s.warnings.map((m) => ({ ...m, message: `south-west: ${m.message}` }))), p.warnings.push(...o.warnings.map((m) => ({ ...m, message: `north-east: ${m.message}` }))), p;
621
+ return l > c && p.warnings.push({ message: `bbox crosses the antimeridian (west: ${l} > east: ${c})` }), p.warnings.push(...s.warnings.map((f) => ({ ...f, message: `south-west: ${f.message}` }))), p.warnings.push(...o.warnings.map((f) => ({ ...f, message: `north-east: ${f.message}` }))), p;
565
622
  }
566
- function He(e) {
623
+ function qe(e) {
567
624
  if (!i.plainObject(e))
568
625
  return {
569
626
  valid: !1,
@@ -571,13 +628,13 @@ function He(e) {
571
628
  warnings: []
572
629
  };
573
630
  switch (e.type) {
574
- case L.NAME:
631
+ case S.NAME:
575
632
  return i.nonEmptyString(e.properties?.name) ? { valid: !0, errors: [], warnings: [] } : {
576
633
  valid: !1,
577
634
  errors: [{ message: "Invalid crs: linked crs must have a non-empty properties.name string" }],
578
635
  warnings: []
579
636
  };
580
- case L.LINK:
637
+ case S.LINK:
581
638
  return i.nonEmptyString(e.properties?.href) ? { valid: !0, errors: [], warnings: [] } : {
582
639
  valid: !1,
583
640
  errors: [{ message: "Invalid crs: linked crs must have a non-empty properties.href string" }],
@@ -591,11 +648,11 @@ function He(e) {
591
648
  };
592
649
  }
593
650
  }
594
- function y() {
651
+ function b() {
595
652
  return { Feature: 0, FeatureCollection: 0, geometries: {} };
596
653
  }
597
- function Ve(...e) {
598
- const t = y();
654
+ function Qe(...e) {
655
+ const t = b();
599
656
  for (const r of e) {
600
657
  const n = r.statistics;
601
658
  if (n) {
@@ -606,41 +663,42 @@ function Ve(...e) {
606
663
  }
607
664
  return t;
608
665
  }
609
- function h(e, t, r = "") {
666
+ function y(e, t, r = "") {
610
667
  const n = {
611
668
  valid: !0,
612
669
  errors: [],
613
- warnings: []
670
+ warnings: [],
671
+ statistics: b()
614
672
  };
615
673
  for (let s = 0; s < e.length; s++) {
616
- const o = `${r}/${s}`, u = t(e[s], o, s);
617
- if (!u.valid) {
618
- n.valid = !1, n.errors = n.errors.concat(u.errors.map((g) => ({ ...g, path: g.path || o, index: s })));
674
+ const o = `${r}/${s}`, l = t(e[s], o, s);
675
+ if (l.statistics && (n.statistics = Qe(n, l)), !l.valid) {
676
+ n.valid = !1, n.errors = n.errors.concat(l.errors.map((g) => ({ ...g, path: g.path || o, index: s })));
619
677
  continue;
620
678
  }
621
- i.empty(u.warnings) || (n.warnings = n.warnings.concat(u.warnings.map((g) => ({ ...g, path: g.path || o, index: s })))), u.statistics && (n.statistics = Ve(n, u));
679
+ i.empty(l.warnings) || (n.warnings = n.warnings.concat(l.warnings.map((g) => ({ ...g, path: g.path || o, index: s }))));
622
680
  }
623
681
  return n;
624
682
  }
625
- function We(e, t) {
683
+ function q(e, t) {
626
684
  if (!i.defined(e.crs)) return t;
627
- const r = He(e.crs);
685
+ const r = qe(e.crs);
628
686
  return r.valid || (t.valid = !1, t.errors.push(...r.errors.map((n) => ({ ...n, path: "/crs" })))), t.warnings.push(...r.warnings.map((n) => ({ ...n, path: "/crs" }))), t;
629
687
  }
630
- function w(e, t, r = "") {
688
+ function D(e, t, r = "") {
631
689
  if (!i.defined(e.bbox)) return t;
632
- const n = Pe(e.bbox);
690
+ const n = ze(e.bbox);
633
691
  return n.valid || (t.valid = !1, t.errors.push(...n.errors.map((s) => ({ ...s, path: `${r}/bbox` })))), t.warnings.push(...n.warnings.map((s) => ({ ...s, path: `${r}/bbox` }))), t;
634
692
  }
635
- function F(e, t = 0, r = "") {
636
- return i.arrayOfLengthAtLeast(e, t) ? h(e, D, r) : {
693
+ function V(e, t = 0, r = "") {
694
+ return i.arrayOfLengthAtLeast(e, t) ? y(e, R, r) : {
637
695
  valid: !1,
638
696
  errors: [{ message: `Invalid coordinates: must have at least ${t} positions`, path: r }],
639
697
  warnings: []
640
698
  };
641
699
  }
642
- function ne(e, t = "") {
643
- const r = F(e, 2, t);
700
+ function le(e, t = "") {
701
+ const r = V(e, 2, t);
644
702
  if (!r.valid) return r;
645
703
  for (let n = 0; n < e.length - 1; n++) {
646
704
  const s = e[n][0], o = e[n + 1][0];
@@ -651,46 +709,46 @@ function ne(e, t = "") {
651
709
  }
652
710
  return r;
653
711
  }
654
- function je(e, t = "") {
655
- return i.nonEmptyArray(e) ? h(e, ne, t) : {
712
+ function Ze(e, t = "") {
713
+ return i.nonEmptyArray(e) ? y(e, le, t) : {
656
714
  valid: !1,
657
715
  errors: [{ message: "Invalid MultiLineString: coordinates must be a non empty array", path: t }],
658
716
  warnings: []
659
717
  };
660
718
  }
661
- function Ye(e, t, r = "") {
662
- const n = F(e, 4, r);
719
+ function Je(e, t, r = "") {
720
+ const n = V(e, 4, r);
663
721
  if (!n.valid) return n;
664
722
  const s = e[0], o = e[e.length - 1];
665
723
  if (s[0] !== o[0] || s[1] !== o[1])
666
724
  return n.valid = !1, n.errors.push({ message: "Invalid LinearRing: first and last position must be identical", path: r }), n;
667
- const g = oe(e) ? "clockwise" : "counter-clockwise";
725
+ const g = de(e) ? "clockwise" : "counter-clockwise";
668
726
  g !== t && n.warnings.push({ message: `Ring must be ${t} but is ${g}`, path: r });
669
- const c = le({ type: "Polygon", coordinates: [e] });
727
+ const c = pe({ type: "Polygon", coordinates: [e] });
670
728
  return c.features.length > 0 && (n.valid = !1, n.errors.push({ message: `Invalid LinearRing: ${c.features.length} self-intersection(s) detected`, path: r })), n;
671
729
  }
672
- function re(e, t = "") {
673
- return i.nonEmptyArray(e) ? h(e, (r, n, s) => Ye(r, s === 0 ? "counter-clockwise" : "clockwise", n), t) : {
730
+ function ce(e, t = "") {
731
+ return i.nonEmptyArray(e) ? y(e, (r, n, s) => Je(r, s === 0 ? "counter-clockwise" : "clockwise", n), t) : {
674
732
  valid: !1,
675
733
  errors: [{ message: "Invalid Polygon: coordinates must be a non empty array", path: t }],
676
734
  warnings: []
677
735
  };
678
736
  }
679
- function Be(e, t = "") {
680
- return i.nonEmptyArray(e) ? h(e, (r, n) => re(r, n), t) : {
737
+ function et(e, t = "") {
738
+ return i.nonEmptyArray(e) ? y(e, (r, n) => ce(r, n), t) : {
681
739
  valid: !1,
682
740
  errors: [{ message: "Invalid MultiPolygon: coordinates must be a non empty array", path: t }],
683
741
  warnings: []
684
742
  };
685
743
  }
686
- function Xe(e, t = "") {
687
- return i.nonEmptyArray(e) ? h(e, (r, n) => k(r, n), t) : {
744
+ function tt(e, t = "") {
745
+ return i.nonEmptyArray(e) ? y(e, (r, n) => j(r, n), t) : {
688
746
  valid: !1,
689
747
  errors: [{ message: "Invalid geometries: geometries must be a non empty array", path: t }],
690
748
  warnings: []
691
749
  };
692
750
  }
693
- function k(e, t = "") {
751
+ function j(e, t = "") {
694
752
  if (!i.nonEmptyObject(e))
695
753
  return {
696
754
  valid: !1,
@@ -700,8 +758,8 @@ function k(e, t = "") {
700
758
  const r = `${t}/coordinates`;
701
759
  let n;
702
760
  switch (e.type) {
703
- case f.POINT: {
704
- const s = D(e.coordinates);
761
+ case m.POINT: {
762
+ const s = R(e.coordinates);
705
763
  n = {
706
764
  valid: s.valid,
707
765
  errors: s.errors.map((o) => ({ ...o, path: r })),
@@ -709,28 +767,28 @@ function k(e, t = "") {
709
767
  };
710
768
  break;
711
769
  }
712
- case f.MULTI_POINT: {
713
- n = F(e.coordinates, 0, r);
770
+ case m.MULTI_POINT: {
771
+ n = V(e.coordinates, 0, r);
714
772
  break;
715
773
  }
716
- case f.LINESTRING: {
717
- n = ne(e.coordinates, r);
774
+ case m.LINESTRING: {
775
+ n = le(e.coordinates, r);
718
776
  break;
719
777
  }
720
- case f.MULTI_LINESTRING: {
721
- n = je(e.coordinates, r);
778
+ case m.MULTI_LINESTRING: {
779
+ n = Ze(e.coordinates, r);
722
780
  break;
723
781
  }
724
- case f.POLYGON: {
725
- n = re(e.coordinates, r);
782
+ case m.POLYGON: {
783
+ n = ce(e.coordinates, r);
726
784
  break;
727
785
  }
728
- case f.MULTI_POLYGON: {
729
- n = Be(e.coordinates, r);
786
+ case m.MULTI_POLYGON: {
787
+ n = et(e.coordinates, r);
730
788
  break;
731
789
  }
732
- case f.GEOMETRY_COLLECTION: {
733
- n = Xe(e.geometries, `${t}/geometries`);
790
+ case m.GEOMETRY_COLLECTION: {
791
+ n = tt(e.geometries, `${t}/geometries`);
734
792
  break;
735
793
  }
736
794
  default:
@@ -740,25 +798,26 @@ function k(e, t = "") {
740
798
  warnings: []
741
799
  };
742
800
  }
743
- return w(e, n, t);
801
+ return n = D(e, n, t), n.statistics = { geometries: { [e.type]: 1 } }, n;
744
802
  }
745
- function ie(e, t = "") {
803
+ function ge(e, t = "") {
746
804
  if (!i.nonEmptyObject(e))
747
805
  return {
748
806
  valid: !1,
749
807
  errors: [{ message: "Invalid feature: must be a non empty object", path: t }],
750
808
  warnings: [],
751
- statistics: y()
809
+ statistics: b()
752
810
  };
753
811
  if (e.type === v.FEATURE) {
754
812
  if (i.nonEmptyObject(e.geometry)) {
755
- const r = k(e.geometry, `${t}/geometry`);
813
+ const r = j(e.geometry, `${t}/geometry`);
756
814
  return {
757
- ...w(e, r, t),
815
+ ...D(e, r, t),
758
816
  statistics: {
759
817
  Feature: 1,
760
818
  FeatureCollection: 0,
761
- geometries: { [e.geometry.type]: 1 }
819
+ // Geometry counting is owned by validateGeometry.
820
+ geometries: { ...r.statistics.geometries }
762
821
  }
763
822
  };
764
823
  }
@@ -771,9 +830,9 @@ function ie(e, t = "") {
771
830
  }
772
831
  if (e.type === v.FEATURE_COLLECTION) {
773
832
  if (i.nonEmptyArray(e.features)) {
774
- const r = h(e.features, ie, `${t}/features`);
833
+ const r = y(e.features, ge, `${t}/features`);
775
834
  return {
776
- ...w(e, r, t),
835
+ ...D(e, r, t),
777
836
  statistics: { ...r.statistics, FeatureCollection: r.statistics.FeatureCollection + 1 }
778
837
  };
779
838
  }
@@ -781,84 +840,92 @@ function ie(e, t = "") {
781
840
  valid: !1,
782
841
  errors: [{ message: "Invalid FeatureCollection: features must be a non empty array", path: t }],
783
842
  warnings: [],
784
- statistics: y()
843
+ statistics: b()
785
844
  };
786
845
  }
787
846
  return {
788
847
  valid: !1,
789
848
  errors: [{ message: `Invalid feature: unknown type: ${e.type}`, path: t }],
790
849
  warnings: [],
791
- statistics: y()
850
+ statistics: b()
792
851
  };
793
852
  }
794
- function Et(e) {
795
- if (l.that(e, i.nonEmptyObject, "geojson must be a non empty object"), i.oneOf(e.type, Object.values(f)))
853
+ function St(e) {
854
+ if (u.that(e, i.nonEmptyObject, "geojson must be a non empty object"), i.oneOf(e.type, Object.values(m))) {
855
+ const t = j(e, ""), r = D(e, t, "");
796
856
  return {
797
- ...k(e, ""),
798
- statistics: { Feature: 0, FeatureCollection: 0, geometries: { [e.type]: 1 } }
857
+ ...q(e, r),
858
+ // Geometry counting is owned by validateGeometry.
859
+ statistics: { Feature: 0, FeatureCollection: 0, geometries: { ...t.statistics.geometries } }
799
860
  };
861
+ }
800
862
  if (e.type === v.FEATURE || e.type === v.FEATURE_COLLECTION) {
801
- const t = ie(e, "");
802
- return We(e, t);
863
+ const t = ge(e, "");
864
+ return q(e, t);
803
865
  }
804
866
  return {
805
867
  valid: !1,
806
- errors: [{ message: "Invalid GeoJson: type must be either a Geometry, a Feature or a FeatureCollection" }],
868
+ errors: [{ message: "Invalid GeoJson: type must be either a Geometry, a Feature or a FeatureCollection", path: "" }],
807
869
  warnings: [],
808
- statistics: y()
870
+ statistics: b()
809
871
  };
810
872
  }
811
873
  export {
812
874
  d as AXES,
813
- C as COORDINATE_FORMATS,
814
- we as COORDINATE_MODELS,
815
- x as COORDINATE_TRUNCATION_FACTORS,
816
- L as CRS_TYPES,
875
+ x as COORDINATE_FORMATS,
876
+ Pe as COORDINATE_MODELS,
877
+ G as COORDINATE_TRUNCATION_FACTORS,
878
+ S as CRS_TYPES,
817
879
  v as FEATURE_TYPES,
818
- f as GEOMETRY_TYPES,
819
- gt as convertCoordinate,
820
- W as getCoordinatePrecision,
821
- Ee as getDirectionAxis,
822
- it as getDirections,
823
- ot as getEast,
824
- pe as getLocale,
825
- st as getNorth,
826
- at as getSouth,
827
- lt as getWest,
828
- V as guessCoordinateAxis,
829
- et as isAltitude,
830
- ue as isAxis,
880
+ m as GEOMETRY_TYPES,
881
+ ht as convertCoordinate,
882
+ J as getActiveLocales,
883
+ F as getAllDirectionSymbols,
884
+ z as getCoordinatePrecision,
885
+ Re as getDirectionAxis,
886
+ ft as getDirections,
887
+ pt as getEast,
888
+ Ie as getLatitudeSymbols,
889
+ Te as getLocale,
890
+ U as getLocaleByCode,
891
+ Le as getLongitudeSymbols,
892
+ mt as getNorth,
893
+ dt as getSouth,
894
+ vt as getWest,
895
+ X as guessCoordinateAxis,
896
+ ut as isAltitude,
897
+ ve as isAxis,
831
898
  E as isDirection,
832
- X as isEast,
833
- N as isLatitude,
834
- $e as isLikeBBox,
835
- mt as isLikeCRS,
836
- _e as isLikeFeature,
837
- xe as isLikeFeatureCollection,
838
- Q as isLikeGeoJson,
839
- G as isLikeGeometry,
840
- Ge as isLikePosition,
841
- Y as isLongitude,
842
- ve as isNorth,
843
- B as isSouth,
844
- _ as isWest,
845
- tt as listLocales,
846
- ct as normalizeCoordinate,
847
- Me as parseCoordinate,
848
- ft as parsePosition,
849
- nt as registerLocale,
850
- rt as setLocale,
851
- dt as simplifyGeoJson,
852
- U as simplifyGeometry,
853
- J as truncateBBox,
854
- ut as truncateCoordinate,
855
- pt as truncateGeoJson,
856
- ee as truncateGeometry,
857
- vt as truncatePosition,
858
- Pe as validateBBox,
859
- He as validateCRS,
860
- Et as validateGeoJson,
861
- k as validateGeometry,
862
- D as validatePosition
899
+ k as isEast,
900
+ M as isLatitude,
901
+ Ve as isLikeBBox,
902
+ Ot as isLikeCRS,
903
+ je as isLikeFeature,
904
+ Be as isLikeFeatureCollection,
905
+ ie as isLikeGeoJson,
906
+ P as isLikeGeometry,
907
+ Ye as isLikePosition,
908
+ Z as isLongitude,
909
+ Se as isNorth,
910
+ ee as isSouth,
911
+ C as isWest,
912
+ lt as listLocales,
913
+ bt as normalizeCoordinate,
914
+ He as parseCoordinate,
915
+ yt as parsePosition,
916
+ ct as registerLocale,
917
+ gt as setLocale,
918
+ Tt as simplifyGeoJson,
919
+ H as simplifyGeometry,
920
+ ae as truncateBBox,
921
+ Et as truncateCoordinate,
922
+ It as truncateGeoJson,
923
+ oe as truncateGeometry,
924
+ Lt as truncatePosition,
925
+ ze as validateBBox,
926
+ qe as validateCRS,
927
+ St as validateGeoJson,
928
+ j as validateGeometry,
929
+ R as validatePosition
863
930
  };
864
931
  //# sourceMappingURL=index.mjs.map