@kalisio/common-geospatial 0.8.0 → 0.10.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/README.md +9 -3
- package/dist/foundation/index.cjs +2 -0
- package/dist/foundation/index.cjs.map +1 -0
- package/dist/foundation/index.mjs +77 -0
- package/dist/foundation/index.mjs.map +1 -0
- package/dist/geojson-CJ6QZ9pN.js +647 -0
- package/dist/geojson-CJ6QZ9pN.js.map +1 -0
- package/dist/geojson-QgqoCFjn.cjs +2 -0
- package/dist/geojson-QgqoCFjn.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +99 -1056
- package/dist/index.mjs.map +1 -1
- package/dist/io/index.cjs +11 -0
- package/dist/io/index.cjs.map +1 -0
- package/dist/io/index.mjs +539 -0
- package/dist/io/index.mjs.map +1 -0
- package/dist/line-CcfAx7LP.js +16 -0
- package/dist/line-CcfAx7LP.js.map +1 -0
- package/dist/line-Doxbvzns.cjs +2 -0
- package/dist/line-Doxbvzns.cjs.map +1 -0
- package/dist/operators/index.cjs +2 -0
- package/dist/operators/index.cjs.map +1 -0
- package/dist/operators/index.mjs +28 -0
- package/dist/operators/index.mjs.map +1 -0
- package/dist/ring-Cks2pGr8.js +1334 -0
- package/dist/ring-Cks2pGr8.js.map +1 -0
- package/dist/ring-CnFBeolv.cjs +2 -0
- package/dist/ring-CnFBeolv.cjs.map +1 -0
- package/dist/truncate-Cb17e4VI.cjs +2 -0
- package/dist/truncate-Cb17e4VI.cjs.map +1 -0
- package/dist/truncate-Cs8jmwOi.js +139 -0
- package/dist/truncate-Cs8jmwOi.js.map +1 -0
- package/package.json +25 -7
package/dist/index.mjs
CHANGED
|
@@ -1,1059 +1,102 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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 = {
|
|
10
|
-
LATITUDE: "LAT",
|
|
11
|
-
LONGITUDE: "LON",
|
|
12
|
-
ALTITUDE: "ALT"
|
|
13
|
-
};
|
|
14
|
-
function Te(e) {
|
|
15
|
-
return u.that(e, i.string, "axis must be a string"), Object.values(d).includes(e);
|
|
16
|
-
}
|
|
17
|
-
function k(e) {
|
|
18
|
-
return u.that(e, i.string, "axis must be a string"), e === d.LATITUDE;
|
|
19
|
-
}
|
|
20
|
-
function ne(e) {
|
|
21
|
-
return u.that(e, i.string, "axis must be a string"), e === d.LONGITUDE;
|
|
22
|
-
}
|
|
23
|
-
function Ot(e) {
|
|
24
|
-
return u.that(e, i.string, "axis must be a string"), e === d.ALTITUDE;
|
|
25
|
-
}
|
|
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 = {
|
|
31
|
-
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 }
|
|
36
|
-
}
|
|
37
|
-
}, I = {
|
|
38
|
-
en: be,
|
|
39
|
-
fr: Le
|
|
40
|
-
};
|
|
41
|
-
let S = "en";
|
|
42
|
-
const z = "en";
|
|
43
|
-
function Tt() {
|
|
44
|
-
return Object.keys(I);
|
|
45
|
-
}
|
|
46
|
-
function It(e, t) {
|
|
47
|
-
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;
|
|
53
|
-
}
|
|
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;
|
|
59
|
-
}
|
|
60
|
-
function Re() {
|
|
61
|
-
return S;
|
|
62
|
-
}
|
|
63
|
-
function B(e) {
|
|
64
|
-
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];
|
|
68
|
-
}
|
|
69
|
-
function re() {
|
|
70
|
-
return S === z ? [S] : [S, z];
|
|
71
|
-
}
|
|
72
|
-
function H(e) {
|
|
73
|
-
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);
|
|
77
|
-
}
|
|
78
|
-
return [...t];
|
|
79
|
-
}
|
|
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) {
|
|
93
|
-
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();
|
|
97
|
-
});
|
|
98
|
-
}
|
|
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;
|
|
105
|
-
}
|
|
106
|
-
function Dt() {
|
|
107
|
-
return b().SOUTH;
|
|
108
|
-
}
|
|
109
|
-
function Rt() {
|
|
110
|
-
return b().EAST;
|
|
111
|
-
}
|
|
112
|
-
function At() {
|
|
113
|
-
return b().WEST;
|
|
114
|
-
}
|
|
115
|
-
function O(e) {
|
|
116
|
-
return u.that(e, i.string, "dir must be a string"), Ce(e) || ie(e) || V(e) || $(e);
|
|
117
|
-
}
|
|
118
|
-
function Ce(e) {
|
|
119
|
-
return u.that(e, i.string, "dir must be a string"), _("NORTH", e);
|
|
120
|
-
}
|
|
121
|
-
function ie(e) {
|
|
122
|
-
return u.that(e, i.string, "dir must be a string"), _("SOUTH", e);
|
|
123
|
-
}
|
|
124
|
-
function V(e) {
|
|
125
|
-
return u.that(e, i.string, "dir must be a string"), _("EAST", e);
|
|
126
|
-
}
|
|
127
|
-
function $(e) {
|
|
128
|
-
return u.that(e, i.string, "dir must be a string"), _("WEST", e);
|
|
129
|
-
}
|
|
130
|
-
function Ne(e) {
|
|
131
|
-
return u.that(e, O, "dir must be a direction"), $(e) || V(e) ? d.LONGITUDE : d.LATITUDE;
|
|
132
|
-
}
|
|
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");
|
|
139
|
-
}
|
|
140
|
-
function D(e) {
|
|
141
|
-
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);
|
|
147
|
-
}
|
|
148
|
-
return {
|
|
149
|
-
get degrees() {
|
|
150
|
-
return t;
|
|
151
|
-
},
|
|
152
|
-
get direction() {
|
|
153
|
-
return n;
|
|
154
|
-
},
|
|
155
|
-
get format() {
|
|
156
|
-
return "DD";
|
|
157
|
-
},
|
|
158
|
-
isValid() {
|
|
159
|
-
return i.number(t);
|
|
160
|
-
},
|
|
161
|
-
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;
|
|
165
|
-
},
|
|
166
|
-
toDecimal() {
|
|
167
|
-
return this.isValid() ? D({ degrees: t, direction: n }) : null;
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
}
|
|
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");
|
|
178
|
-
}
|
|
179
|
-
function ae(e) {
|
|
180
|
-
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());
|
|
185
|
-
s && (t = parseFloat(s[1]), n = parseFloat(s[2]), r = s[3] ?? null);
|
|
186
|
-
}
|
|
187
|
-
return {
|
|
188
|
-
get degrees() {
|
|
189
|
-
return t;
|
|
190
|
-
},
|
|
191
|
-
get minutes() {
|
|
192
|
-
return n;
|
|
193
|
-
},
|
|
194
|
-
get direction() {
|
|
195
|
-
return r;
|
|
196
|
-
},
|
|
197
|
-
get format() {
|
|
198
|
-
return "DDM";
|
|
199
|
-
},
|
|
200
|
-
isValid() {
|
|
201
|
-
return i.integer(t) && i.inRangeExclusiveMax(n, 0, 60);
|
|
202
|
-
},
|
|
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)}'`;
|
|
206
|
-
return r && (s += ` ${r}`), s;
|
|
207
|
-
},
|
|
208
|
-
toDecimal() {
|
|
209
|
-
return this.isValid() ? D({ degrees: t + n / 60, direction: r }) : null;
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
const Ge = {
|
|
214
|
-
degrees: i.nonNegativeInteger,
|
|
215
|
-
minutes: (e) => i.inRangeExclusiveMax(e, 0, 60),
|
|
216
|
-
direction: O
|
|
217
|
-
};
|
|
218
|
-
function ke() {
|
|
219
|
-
return new RegExp(`^(\\d{2})(\\d{3})([${Ae().join("")}])$`, "i");
|
|
220
|
-
}
|
|
221
|
-
function Pe() {
|
|
222
|
-
return new RegExp(`^(\\d{3})(\\d{3})([${Me().join("")}])$`, "i");
|
|
223
|
-
}
|
|
224
|
-
function se(e) {
|
|
225
|
-
let t = null, n = null, r = null;
|
|
226
|
-
if (i.plainObject(e) && E.schema(e, Ge))
|
|
227
|
-
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());
|
|
230
|
-
s && (t = parseFloat(s[1]), n = parseFloat(s[2]) / 10, r = s[3]);
|
|
231
|
-
}
|
|
232
|
-
return {
|
|
233
|
-
get degrees() {
|
|
234
|
-
return t;
|
|
235
|
-
},
|
|
236
|
-
get minutes() {
|
|
237
|
-
return n;
|
|
238
|
-
},
|
|
239
|
-
get direction() {
|
|
240
|
-
return r;
|
|
241
|
-
},
|
|
242
|
-
get format() {
|
|
243
|
-
return "DDM_AERO";
|
|
244
|
-
},
|
|
245
|
-
isValid() {
|
|
246
|
-
return i.nonNegativeInteger(t) && i.inRangeExclusiveMax(n, 0, 60) && O(r);
|
|
247
|
-
},
|
|
248
|
-
toString() {
|
|
249
|
-
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}`;
|
|
252
|
-
},
|
|
253
|
-
toDecimal() {
|
|
254
|
-
return this.isValid() ? D({ degrees: t + n / 60, direction: r }) : null;
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
}
|
|
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);
|
|
274
|
-
}
|
|
275
|
-
return {
|
|
276
|
-
get degrees() {
|
|
277
|
-
return t;
|
|
278
|
-
},
|
|
279
|
-
get minutes() {
|
|
280
|
-
return n;
|
|
281
|
-
},
|
|
282
|
-
get seconds() {
|
|
283
|
-
return r;
|
|
284
|
-
},
|
|
285
|
-
get direction() {
|
|
286
|
-
return a;
|
|
287
|
-
},
|
|
288
|
-
get format() {
|
|
289
|
-
return "DMS";
|
|
290
|
-
},
|
|
291
|
-
isValid() {
|
|
292
|
-
return i.integer(t) && i.integer(n) && i.inRange(n, 0, 59) && i.inRangeExclusiveMax(r, 0, 60);
|
|
293
|
-
},
|
|
294
|
-
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;
|
|
298
|
-
},
|
|
299
|
-
toDecimal() {
|
|
300
|
-
return this.isValid() ? D({ degrees: t + n / 60 + r / 3600, direction: a }) : null;
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
function q(e) {
|
|
305
|
-
const t = Math.floor(e.degrees), n = (e.degrees - t) * 60;
|
|
306
|
-
return { degrees: t, minutes: n, direction: e.direction };
|
|
307
|
-
}
|
|
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 };
|
|
311
|
-
}
|
|
312
|
-
const Q = {
|
|
313
|
-
DD: (e) => (u.that(e, (t) => t.isValid(), "dd must be a valid coordinate"), e),
|
|
314
|
-
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 });
|
|
318
|
-
},
|
|
319
|
-
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 });
|
|
323
|
-
},
|
|
324
|
-
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 });
|
|
328
|
-
}
|
|
329
|
-
}, P = {
|
|
330
|
-
DD: "DD",
|
|
331
|
-
DDM: "DDM",
|
|
332
|
-
DDM_AERO: "DDM_AERO",
|
|
333
|
-
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) {
|
|
351
|
-
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]" }
|
|
354
|
-
]);
|
|
355
|
-
const n = Y[t];
|
|
356
|
-
return Math.round(e * n) / n;
|
|
357
|
-
}
|
|
358
|
-
function Ct(e, t) {
|
|
359
|
-
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))
|
|
363
|
-
return Math.max(-90, Math.min(90, e));
|
|
364
|
-
let n = ((e + 180) % 360 + 360) % 360 - 180;
|
|
365
|
-
return n === -180 && (n = 180), Object.is(n, -0) && (n = 0), n;
|
|
366
|
-
}
|
|
367
|
-
function Nt(e, t) {
|
|
368
|
-
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}` }
|
|
371
|
-
]);
|
|
372
|
-
const n = e.format === P.DD ? e : e.toDecimal();
|
|
373
|
-
return n.isValid() ? t === P.DD ? n : Q[t](n) : null;
|
|
374
|
-
}
|
|
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);
|
|
379
|
-
if (n.isValid()) return n;
|
|
380
|
-
}
|
|
381
|
-
return null;
|
|
382
|
-
}
|
|
383
|
-
function wt(e) {
|
|
384
|
-
u.that(e, (o) => i.nonEmptyString(o), "pattern must be a non-empty string");
|
|
385
|
-
const t = e.split(/[,;|]/);
|
|
386
|
-
if (t.length !== 2) return null;
|
|
387
|
-
const [n, r] = t.map(We);
|
|
388
|
-
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;
|
|
392
|
-
};
|
|
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 = {}) {
|
|
416
|
-
u.all([
|
|
417
|
-
{
|
|
418
|
-
value: e,
|
|
419
|
-
validator: y,
|
|
420
|
-
message: "position1 must be a valid position"
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
value: t,
|
|
424
|
-
validator: y,
|
|
425
|
-
message: "position2 must be a valid position"
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
value: n,
|
|
429
|
-
validator: (l) => E.schema(l, Ke),
|
|
430
|
-
message: "options must be a valid options object"
|
|
431
|
-
}
|
|
432
|
-
]);
|
|
433
|
-
const { precision: r = 10, consider3D: a = !1 } = n, s = a ? Math.max(e.length, t.length) : 2;
|
|
434
|
-
return Array.from(
|
|
435
|
-
{ length: s },
|
|
436
|
-
(l, m) => (e[m] ?? 0).toFixed(r) === (t[m] ?? 0).toFixed(r)
|
|
437
|
-
).every(Boolean);
|
|
438
|
-
}
|
|
439
|
-
function $t(e, t = 7) {
|
|
440
|
-
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]" }
|
|
443
|
-
]);
|
|
444
|
-
const n = Y[t];
|
|
445
|
-
for (let r = 0; r < e.length; r++)
|
|
446
|
-
e[r] = Math.round(e[r] * n) / n;
|
|
447
|
-
return e;
|
|
448
|
-
}
|
|
449
|
-
function A(e) {
|
|
450
|
-
if (!i.arrayOfLength(e, 4) && !i.arrayOfLength(e, 6)) return !1;
|
|
451
|
-
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]);
|
|
455
|
-
}
|
|
456
|
-
function ee(e) {
|
|
457
|
-
return u.that(e, A, "bbox must be a valid bounding-box"), i.arrayOfLength(e, 6);
|
|
458
|
-
}
|
|
459
|
-
function Ft(e, t) {
|
|
460
|
-
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) ? [
|
|
464
|
-
Math.min(e[0], t[0]),
|
|
465
|
-
Math.min(e[1], t[1]),
|
|
466
|
-
Math.min(e[2], t[2]),
|
|
467
|
-
Math.max(e[3], t[3]),
|
|
468
|
-
Math.max(e[4], t[4]),
|
|
469
|
-
Math.max(e[5], t[5])
|
|
470
|
-
] : [
|
|
471
|
-
Math.min(e[0], t[0]),
|
|
472
|
-
Math.min(e[1], t[1]),
|
|
473
|
-
Math.max(e[2], t[2]),
|
|
474
|
-
Math.max(e[3], t[3])
|
|
475
|
-
];
|
|
476
|
-
}
|
|
477
|
-
const ze = {
|
|
478
|
-
ignore3D: p(i.boolean)
|
|
479
|
-
};
|
|
480
|
-
function x(e, t = {}) {
|
|
481
|
-
u.all([
|
|
482
|
-
{
|
|
483
|
-
value: e,
|
|
484
|
-
validator: i.nonEmptyArray,
|
|
485
|
-
message: "positions must be a non-empty array"
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
value: e,
|
|
489
|
-
validator: (a) => a.every(y),
|
|
490
|
-
message: "positions must be an array of valid positions"
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
value: t,
|
|
494
|
-
validator: (a) => E.schema(a, ze),
|
|
495
|
-
message: "options must be a valid options object"
|
|
496
|
-
}
|
|
497
|
-
]);
|
|
498
|
-
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])
|
|
511
|
-
], [1 / 0, 1 / 0, -1 / 0, -1 / 0]);
|
|
512
|
-
}
|
|
513
|
-
function ue(e, t = 7) {
|
|
514
|
-
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]" }
|
|
517
|
-
]);
|
|
518
|
-
const n = Y[t];
|
|
519
|
-
for (let r = 0; r < e.length; r++)
|
|
520
|
-
e[r] = Math.round(e[r] * n) / n;
|
|
521
|
-
return e;
|
|
522
|
-
}
|
|
523
|
-
const M = {
|
|
524
|
-
NAME: "name",
|
|
525
|
-
LINK: "link"
|
|
526
|
-
};
|
|
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;
|
|
529
|
-
}
|
|
530
|
-
function Ut(e) {
|
|
531
|
-
return i.arrayOfLengthBetween(e, 2, 3) ? e.every(i.number) : !1;
|
|
532
|
-
}
|
|
533
|
-
function Gt(e) {
|
|
534
|
-
return !i.arrayOfLength(e, 4) && !i.arrayOfLength(e, 6) ? !1 : e.every(i.number);
|
|
535
|
-
}
|
|
536
|
-
const g = {
|
|
537
|
-
POINT: "Point",
|
|
538
|
-
MULTI_POINT: "MultiPoint",
|
|
539
|
-
LINESTRING: "LineString",
|
|
540
|
-
MULTI_LINESTRING: "MultiLineString",
|
|
541
|
-
POLYGON: "Polygon",
|
|
542
|
-
MULTI_POLYGON: "MultiPolygon",
|
|
543
|
-
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 = {
|
|
549
|
-
FEATURE: "Feature",
|
|
550
|
-
FEATURE_COLLECTION: "FeatureCollection"
|
|
551
|
-
};
|
|
552
|
-
function Qe(e) {
|
|
553
|
-
return i.plainObject(e) && e.type === h.FEATURE;
|
|
554
|
-
}
|
|
555
|
-
function Ze(e) {
|
|
556
|
-
return i.plainObject(e) && e.type === h.FEATURE_COLLECTION && i.array(e.features);
|
|
557
|
-
}
|
|
558
|
-
function Je(e) {
|
|
559
|
-
return Qe(e) || Ze(e);
|
|
560
|
-
}
|
|
561
|
-
function F(e) {
|
|
562
|
-
return Je(e) || qe(e);
|
|
563
|
-
}
|
|
564
|
-
const et = {
|
|
565
|
-
ignore3D: p(i.boolean)
|
|
566
|
-
};
|
|
567
|
-
function kt(e, t = {}) {
|
|
568
|
-
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;
|
|
576
|
-
}
|
|
577
|
-
return x(R(e), t);
|
|
578
|
-
}
|
|
579
|
-
function tt(e) {
|
|
580
|
-
if (e.length === 0) return null;
|
|
581
|
-
if (e.length === 1) return { type: "Point", coordinates: e[0] };
|
|
582
|
-
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 }))));
|
|
584
|
-
return t ? t.geometry : { type: "LineString", coordinates: [e[0], e[e.length - 1]] };
|
|
585
|
-
}
|
|
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);
|
|
591
|
-
}
|
|
592
|
-
function rt(e, t, n) {
|
|
593
|
-
return Math.abs(
|
|
594
|
-
(e[0] * (t[1] - n[1]) + t[0] * (n[1] - e[1]) + n[0] * (e[1] - t[1])) / 2
|
|
595
|
-
);
|
|
596
|
-
}
|
|
597
|
-
function U(e, { tolerance: t = 0, getWeight: n = () => 1 } = {}) {
|
|
598
|
-
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;
|
|
606
|
-
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));
|
|
611
|
-
}
|
|
612
|
-
}
|
|
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);
|
|
631
|
-
return e;
|
|
632
|
-
}
|
|
633
|
-
switch (e.type) {
|
|
634
|
-
case g.LINESTRING:
|
|
635
|
-
e.coordinates = U(e.coordinates, t);
|
|
636
|
-
break;
|
|
637
|
-
case g.POLYGON:
|
|
638
|
-
case g.MULTI_LINESTRING:
|
|
639
|
-
e.coordinates = e.coordinates.map((n) => U(n, t));
|
|
640
|
-
break;
|
|
641
|
-
case g.MULTI_POLYGON:
|
|
642
|
-
e.coordinates = e.coordinates.map((n) => n.map((r) => U(r, t)));
|
|
643
|
-
break;
|
|
644
|
-
case g.GEOMETRY_COLLECTION:
|
|
645
|
-
e.geometries.forEach((n) => G(n, t));
|
|
646
|
-
break;
|
|
647
|
-
}
|
|
648
|
-
return e;
|
|
649
|
-
}
|
|
650
|
-
function le(e, t = 7) {
|
|
651
|
-
const n = Ee(e, { precision: t, mutate: !0 });
|
|
652
|
-
return n.bbox && ue(n.bbox, t), n;
|
|
653
|
-
}
|
|
654
|
-
function ce(e, t) {
|
|
655
|
-
if (e.type === h.FEATURE)
|
|
656
|
-
e.geometry && le(e.geometry, t);
|
|
657
|
-
else
|
|
658
|
-
for (const n of e.features) ce(n, t);
|
|
659
|
-
return e.bbox && ue(e.bbox, t), e;
|
|
660
|
-
}
|
|
661
|
-
function Pt(e, t = 7) {
|
|
662
|
-
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);
|
|
666
|
-
}
|
|
667
|
-
function C(e) {
|
|
668
|
-
if (!i.arrayOfLengthBetween(e, 2, 3))
|
|
669
|
-
return {
|
|
670
|
-
valid: !1,
|
|
671
|
-
errors: [{ message: "Invalid coordinates: must be an array of 2 or 3 coordinates" }],
|
|
672
|
-
warnings: []
|
|
673
|
-
};
|
|
674
|
-
if (!i.number(e[0]) || !i.number(e[1]))
|
|
675
|
-
return {
|
|
676
|
-
valid: !1,
|
|
677
|
-
errors: [{ message: "Invalid coordinates: longitude and latitude must be numbers" }],
|
|
678
|
-
warnings: []
|
|
679
|
-
};
|
|
680
|
-
if (!i.inRange(e[0], -180, 180))
|
|
681
|
-
return {
|
|
682
|
-
valid: !1,
|
|
683
|
-
errors: [{ message: "Invalid coordinates: longitude must be in the range -180 to 180" }],
|
|
684
|
-
warnings: []
|
|
685
|
-
};
|
|
686
|
-
if (!i.inRange(e[1], -90, 90))
|
|
687
|
-
return {
|
|
688
|
-
valid: !1,
|
|
689
|
-
errors: [{ message: "Invalid coordinates: latitude must be in the range -90 to 90" }],
|
|
690
|
-
warnings: []
|
|
691
|
-
};
|
|
692
|
-
if (e.length === 3 && !i.number(e[2]))
|
|
693
|
-
return {
|
|
694
|
-
valid: !1,
|
|
695
|
-
errors: [{ message: "Invalid coordinates: altitude must be a number" }],
|
|
696
|
-
warnings: []
|
|
697
|
-
};
|
|
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;
|
|
702
|
-
}
|
|
703
|
-
function at(e) {
|
|
704
|
-
if (!i.arrayOfLength(e, 4) && !i.arrayOfLength(e, 6))
|
|
705
|
-
return {
|
|
706
|
-
valid: !1,
|
|
707
|
-
errors: [{ message: "Invalid bbox: must be an array of 4 (2D) or 6 (3D) numbers" }],
|
|
708
|
-
warnings: []
|
|
709
|
-
};
|
|
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)
|
|
712
|
-
return {
|
|
713
|
-
valid: !1,
|
|
714
|
-
errors: a.errors.map((f) => ({ ...f, message: `Invalid bbox south-west: ${f.message}` })),
|
|
715
|
-
warnings: []
|
|
716
|
-
};
|
|
717
|
-
const s = C(r);
|
|
718
|
-
if (!s.valid)
|
|
719
|
-
return {
|
|
720
|
-
valid: !1,
|
|
721
|
-
errors: s.errors.map((f) => ({ ...f, message: `Invalid bbox north-east: ${f.message}` })),
|
|
722
|
-
warnings: []
|
|
723
|
-
};
|
|
724
|
-
const [l, m] = n, [c, o] = r;
|
|
725
|
-
if (m > o)
|
|
726
|
-
return {
|
|
727
|
-
valid: !1,
|
|
728
|
-
errors: [{ message: `Invalid bbox: south (${m}) must be <= north (${o})` }],
|
|
729
|
-
warnings: []
|
|
730
|
-
};
|
|
731
|
-
if (!t) {
|
|
732
|
-
const f = e[2], K = e[5];
|
|
733
|
-
if (f > K)
|
|
734
|
-
return {
|
|
735
|
-
valid: !1,
|
|
736
|
-
errors: [{ message: `Invalid bbox: min altitude (${f}) must be <= max altitude (${K})` }],
|
|
737
|
-
warnings: []
|
|
738
|
-
};
|
|
739
|
-
}
|
|
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;
|
|
742
|
-
}
|
|
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() {
|
|
772
|
-
return { Feature: 0, FeatureCollection: 0, geometries: {} };
|
|
773
|
-
}
|
|
774
|
-
function ot(...e) {
|
|
775
|
-
const t = T();
|
|
776
|
-
for (const n of e) {
|
|
777
|
-
const r = n.statistics;
|
|
778
|
-
if (r) {
|
|
779
|
-
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;
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
return t;
|
|
785
|
-
}
|
|
786
|
-
function L(e, t, n = "") {
|
|
787
|
-
const r = {
|
|
788
|
-
valid: !0,
|
|
789
|
-
errors: [],
|
|
790
|
-
warnings: [],
|
|
791
|
-
statistics: T()
|
|
792
|
-
};
|
|
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 }))));
|
|
800
|
-
}
|
|
801
|
-
return r;
|
|
802
|
-
}
|
|
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;
|
|
807
|
-
}
|
|
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;
|
|
812
|
-
}
|
|
813
|
-
function W(e, t = 0, n = "") {
|
|
814
|
-
return i.arrayOfLengthAtLeast(e, t) ? L(e, C, n) : {
|
|
815
|
-
valid: !1,
|
|
816
|
-
errors: [{ message: `Invalid coordinates: must have at least ${t} positions`, path: n }],
|
|
817
|
-
warnings: []
|
|
818
|
-
};
|
|
819
|
-
}
|
|
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;
|
|
831
|
-
}
|
|
832
|
-
function ut(e, t = "") {
|
|
833
|
-
return i.nonEmptyArray(e) ? L(e, me, t) : {
|
|
834
|
-
valid: !1,
|
|
835
|
-
errors: [{ message: "Invalid MultiLineString: coordinates must be a non empty array", path: t }],
|
|
836
|
-
warnings: []
|
|
837
|
-
};
|
|
838
|
-
}
|
|
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
|
-
};
|
|
856
|
-
}
|
|
857
|
-
function ct(e, t = "") {
|
|
858
|
-
return i.nonEmptyArray(e) ? L(e, (n, r) => fe(n, r), t) : {
|
|
859
|
-
valid: !1,
|
|
860
|
-
errors: [{ message: "Invalid MultiPolygon: coordinates must be a non empty array", path: t }],
|
|
861
|
-
warnings: []
|
|
862
|
-
};
|
|
863
|
-
}
|
|
864
|
-
function mt(e, t = "") {
|
|
865
|
-
return i.nonEmptyArray(e) ? L(e, (n, r) => X(n, r), t) : {
|
|
866
|
-
valid: !1,
|
|
867
|
-
errors: [{ message: "Invalid geometries: geometries must be a non empty array", path: t }],
|
|
868
|
-
warnings: []
|
|
869
|
-
};
|
|
870
|
-
}
|
|
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;
|
|
880
|
-
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
|
-
};
|
|
888
|
-
break;
|
|
889
|
-
}
|
|
890
|
-
case g.MULTI_POINT: {
|
|
891
|
-
r = W(e.coordinates, 0, n);
|
|
892
|
-
break;
|
|
893
|
-
}
|
|
894
|
-
case g.LINESTRING: {
|
|
895
|
-
r = me(e.coordinates, n);
|
|
896
|
-
break;
|
|
897
|
-
}
|
|
898
|
-
case g.MULTI_LINESTRING: {
|
|
899
|
-
r = ut(e.coordinates, n);
|
|
900
|
-
break;
|
|
901
|
-
}
|
|
902
|
-
case g.POLYGON: {
|
|
903
|
-
r = fe(e.coordinates, n);
|
|
904
|
-
break;
|
|
905
|
-
}
|
|
906
|
-
case g.MULTI_POLYGON: {
|
|
907
|
-
r = ct(e.coordinates, n);
|
|
908
|
-
break;
|
|
909
|
-
}
|
|
910
|
-
case g.GEOMETRY_COLLECTION: {
|
|
911
|
-
r = mt(e.geometries, `${t}/geometries`);
|
|
912
|
-
break;
|
|
913
|
-
}
|
|
914
|
-
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
|
-
};
|
|
981
|
-
}
|
|
982
|
-
if (e.type === h.FEATURE || e.type === h.FEATURE_COLLECTION) {
|
|
983
|
-
const t = ge(e, "");
|
|
984
|
-
return te(e, t);
|
|
985
|
-
}
|
|
986
|
-
return {
|
|
987
|
-
valid: !1,
|
|
988
|
-
errors: [{ message: "Invalid GeoJson: type must be either a Geometry, a Feature or a FeatureCollection", path: "" }],
|
|
989
|
-
warnings: [],
|
|
990
|
-
statistics: T()
|
|
991
|
-
};
|
|
992
|
-
}
|
|
1
|
+
import { A as e, C as i, a as o, b as t, D as n, E as r, I as c, M as l, T as C, W as S, c as g, d, e as O, f as P, g as A, h as E, i as R, j as T, k as u, l as I, m as x, n as N, o as _, p as L, q as m, r as B, s as G, t as D, u as p, v as J, w as F, x as f, y as k, z as j, B as M, F as V, G as h, H as b, J as v, K as U, L as H, N as W, O as Y, P as y, Q as z, R as w, S as X, U as q, V as K, X as Q, Y as Z, Z as $, _ as ss, $ as as, a0 as es, a1 as is, a2 as os, a3 as ts, a4 as ns, a5 as rs, a6 as cs, a7 as ls, a8 as Cs, a9 as Ss, aa as gs, ab as ds, ac as Os, ad as Ps, ae as As, af as Es } from "./ring-Cks2pGr8.js";
|
|
2
|
+
import { i as Ts, l as us } from "./line-CcfAx7LP.js";
|
|
3
|
+
import { C as xs, F as Ns, G as _s, V as Ls, c as ms, f as Bs, i as Gs, a as Ds, b as ps, d as Js, e as Fs, g as fs, h as ks, j as js, k as Ms, s as Vs, v as hs } from "./geojson-CJ6QZ9pN.js";
|
|
4
|
+
import { c as vs, e as Us, a as Hs, b as Ws, r as Ys, t as ys } from "./truncate-Cs8jmwOi.js";
|
|
993
5
|
export {
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
6
|
+
e as AXES,
|
|
7
|
+
i as COORDINATE_FORMATS,
|
|
8
|
+
o as COORDINATE_MODELS,
|
|
9
|
+
t as COORDINATE_TRUNCATION_FACTORS,
|
|
10
|
+
xs as CRS_TYPES,
|
|
11
|
+
n as DEFAULT_COORDINATE_PRECISION,
|
|
12
|
+
r as EARTH_RADIUS,
|
|
13
|
+
Ns as FEATURE_TYPES,
|
|
14
|
+
_s as GEOMETRY_TYPES,
|
|
15
|
+
c as IS_SAME_POSITION_OPTIONS_SCHEMA,
|
|
16
|
+
l as MAX_COORDINATE_PRECISION,
|
|
17
|
+
C as TRUNCATE_POSITIONS_OPTIONS_SCHEMA,
|
|
18
|
+
Ls as VALIDATION_CODES,
|
|
19
|
+
S as WGS84,
|
|
20
|
+
g as closeRing,
|
|
21
|
+
d as computeBBox,
|
|
22
|
+
ms as computeGeoJsonBoundingBox,
|
|
23
|
+
vs as computeGeoJsonConvexHull,
|
|
24
|
+
O as convertCoordinate,
|
|
25
|
+
P as deduplicatePositions,
|
|
26
|
+
A as defineProjection,
|
|
27
|
+
E as denormalizeCrsName,
|
|
28
|
+
R as destinationFromPosition,
|
|
29
|
+
T as distanceBetweenPositions,
|
|
30
|
+
Us as extractGeoJsonBBox,
|
|
31
|
+
Hs as extractGeoJsonCRS,
|
|
32
|
+
Ws as extractGeoJsonNode,
|
|
33
|
+
Bs as fixGeoJson,
|
|
34
|
+
u as getActiveLocales,
|
|
35
|
+
I as getCoordinatePrecision,
|
|
36
|
+
x as getDirectionAxis,
|
|
37
|
+
N as getDirectionSymbols,
|
|
38
|
+
_ as getDirections,
|
|
39
|
+
L as getEast,
|
|
40
|
+
m as getLocale,
|
|
41
|
+
B as getMessages,
|
|
42
|
+
G as getNorth,
|
|
43
|
+
D as getProjection,
|
|
44
|
+
p as getSouth,
|
|
45
|
+
J as getWest,
|
|
46
|
+
F as guessCoordinateAxis,
|
|
47
|
+
f as hasProjection,
|
|
48
|
+
k as is3DBBox,
|
|
49
|
+
j as is3DPosition,
|
|
50
|
+
M as isAltitude,
|
|
51
|
+
V as isClockwiseRing,
|
|
52
|
+
h as isClosedRing,
|
|
53
|
+
b as isEast,
|
|
54
|
+
Gs as isGeoJsonFixable,
|
|
55
|
+
v as isLatitude,
|
|
56
|
+
Ds as isLikeBBox,
|
|
57
|
+
ps as isLikeCRS,
|
|
58
|
+
Js as isLikeFeature,
|
|
59
|
+
Fs as isLikeFeatureCollection,
|
|
60
|
+
fs as isLikeFeatureOrFeatureCollection,
|
|
61
|
+
ks as isLikeGeoJson,
|
|
62
|
+
js as isLikeGeometry,
|
|
63
|
+
Ms as isLikePosition,
|
|
64
|
+
U as isLongitude,
|
|
65
|
+
H as isNorth,
|
|
66
|
+
W as isSamePosition,
|
|
67
|
+
Y as isSouth,
|
|
68
|
+
y as isValidAxis,
|
|
69
|
+
z as isValidBBox,
|
|
70
|
+
w as isValidDirection,
|
|
71
|
+
Ts as isValidLine,
|
|
72
|
+
X as isValidPosition,
|
|
73
|
+
q as isValidPositions,
|
|
74
|
+
K as isValidRing,
|
|
75
|
+
Q as isWGS84Projection,
|
|
76
|
+
Z as isWest,
|
|
77
|
+
us as lineLength,
|
|
78
|
+
$ as listLocales,
|
|
79
|
+
ss as listProjections,
|
|
80
|
+
as as mergeBBox,
|
|
81
|
+
es as normalizeCoordinate,
|
|
82
|
+
is as normalizeCrsName,
|
|
83
|
+
os as parseCoordinate,
|
|
84
|
+
ts as parsePosition,
|
|
85
|
+
ns as registerMessages,
|
|
86
|
+
Ys as reprojectGeoJson,
|
|
87
|
+
rs as reprojectPosition,
|
|
88
|
+
cs as reprojectPositions,
|
|
89
|
+
ls as ringSelfIntersections,
|
|
90
|
+
Cs as ringsIntersect,
|
|
91
|
+
Ss as setLocale,
|
|
92
|
+
Vs as simplifyGeoJson,
|
|
93
|
+
gs as sphericalRingArea,
|
|
94
|
+
ds as truncateBBox,
|
|
95
|
+
Os as truncateCoordinate,
|
|
96
|
+
ys as truncateGeoJson,
|
|
97
|
+
Ps as truncatePosition,
|
|
98
|
+
As as truncatePositions,
|
|
99
|
+
Es as truncateRing,
|
|
100
|
+
hs as validateGeoJson
|
|
1058
101
|
};
|
|
1059
102
|
//# sourceMappingURL=index.mjs.map
|