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