@wemap/geo 14.6.0-beta.3 → 14.6.0-beta.4
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.js
CHANGED
|
@@ -47,19 +47,37 @@ var Level_default = class e {
|
|
|
47
47
|
if (y === null) return null;
|
|
48
48
|
if (typeof y != "string" || !y.length) throw Error(`argument must be a non empty string, got ${typeof y}`);
|
|
49
49
|
if (!isNaN(Number(y))) return parseFloat(y);
|
|
50
|
-
let b =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
50
|
+
let b = (e) => {
|
|
51
|
+
let b = e.map((e) => Number(e));
|
|
52
|
+
if (b.some((e) => Number.isNaN(e)) || e.some((e) => !e.length)) throw Error(`Cannot parse following level: ${y}`);
|
|
53
|
+
return b;
|
|
54
|
+
}, x = y.split(";");
|
|
55
|
+
if (x.length > 1) {
|
|
56
|
+
let y = b(x), S = Math.min(...y), C = Math.max(...y);
|
|
57
|
+
return e.checkType([S, C]), [S, C];
|
|
54
58
|
} else {
|
|
55
|
-
let
|
|
56
|
-
if (
|
|
57
|
-
let
|
|
58
|
-
return e.checkType([
|
|
59
|
+
let x = y.substring(1).indexOf("-") + 1;
|
|
60
|
+
if (x > 0) {
|
|
61
|
+
let [S, C] = b([y.substring(0, x), y.substring(x + 1)]);
|
|
62
|
+
return e.checkType([S, C]), [S, C];
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
throw Error(`Cannot parse following level: ${y}`);
|
|
62
66
|
}
|
|
67
|
+
static parse(y) {
|
|
68
|
+
if (y == null) return null;
|
|
69
|
+
if (typeof y == "number") {
|
|
70
|
+
if (Number.isNaN(y)) throw Error("level number must not be NaN");
|
|
71
|
+
return y;
|
|
72
|
+
}
|
|
73
|
+
if (Array.isArray(y)) {
|
|
74
|
+
if (y.length !== 2) throw Error(`level range must have exactly 2 elements, got ${y.length}`);
|
|
75
|
+
let b = [y[0], y[1]];
|
|
76
|
+
return e.checkType(b), e.clone(b);
|
|
77
|
+
}
|
|
78
|
+
if (typeof y == "string") return e.fromString(y);
|
|
79
|
+
throw Error(`Cannot parse level from ${typeof y}`);
|
|
80
|
+
}
|
|
63
81
|
static contains(y, b) {
|
|
64
82
|
return e.VERIFY_TYPING && (e.checkType(y), e.checkType(b)), y === b ? !0 : Array.isArray(y) ? Array.isArray(b) ? y[0] <= b[0] && y[1] >= b[1] : b === null ? !1 : y[0] <= b && y[1] >= b : y === null || b === null ? !1 : y <= b[0] && y >= b[1];
|
|
65
83
|
}
|
|
@@ -16,6 +16,11 @@ declare class Level {
|
|
|
16
16
|
* Create a level from a string (eg. 1, -2, 1;2, -2;3, 2;-1, 0.5;1 ...)
|
|
17
17
|
*/
|
|
18
18
|
static fromString(str: string | null): Level_t;
|
|
19
|
+
/**
|
|
20
|
+
* Parse a level from unknown input (GeoJSON properties, JSON APIs, etc.).
|
|
21
|
+
* Accepts: null, undefined, number (non-NaN), [min, max], non-empty string.
|
|
22
|
+
*/
|
|
23
|
+
static parse(value: unknown): Level_t;
|
|
19
24
|
/**
|
|
20
25
|
* Returns if a level is contained in another
|
|
21
26
|
* @param {null|number|[number, number]} container The container level
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Level.d.ts","sourceRoot":"","sources":["../../../src/coordinates/Level.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;GAIG;AACH,cAAM,KAAK;IAEP,MAAM,CAAC,aAAa,UAAS;IAE7B,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO;IAoB/B;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAOzD,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAcrC;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MA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AC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO;IAmBvD,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM;CAyC9D;AAED,eAAe,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wemap/geo",
|
|
3
|
-
"version": "14.6.0-beta.
|
|
3
|
+
"version": "14.6.0-beta.4",
|
|
4
4
|
"description": "Geospatial primitives (coordinates, levels, bounding boxes) for the Wemap SDK.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Wemap SAS",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@turf/boolean-point-in-polygon": "^7.3.4",
|
|
41
|
-
"@wemap/maths": "14.6.0-beta.
|
|
42
|
-
"@wemap/utils": "14.6.0-beta.
|
|
41
|
+
"@wemap/maths": "14.6.0-beta.4",
|
|
42
|
+
"@wemap/utils": "14.6.0-beta.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/geojson": "^7946.0.14",
|