@hybridcore/ui 1.4.15 → 1.4.16
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/components/geometry-picker/coordinate/index.js +7 -7
- package/dist/components/geometry-picker/edit/index.js +22 -22
- package/dist/components/geometry-picker/parser/index.js +9 -8
- package/dist/components/geometry-picker/parser/logic.js +35 -35
- package/dist/components/map/helpers/wkt.js +19 -11
- package/package.json +1 -1
|
@@ -2,8 +2,8 @@ import { jsxs as l, Fragment as p, jsx as o } from "react/jsx-runtime";
|
|
|
2
2
|
import { Button as a, Box as f } from "@mui/material";
|
|
3
3
|
import u from "../map/index.js";
|
|
4
4
|
import C from "../parser/index.js";
|
|
5
|
-
import { g as y, c as
|
|
6
|
-
import { useState as
|
|
5
|
+
import { g as y, c as h } from "../../../ol-CHaVTXvL.js";
|
|
6
|
+
import { useState as g } from "react";
|
|
7
7
|
import { Add as P } from "@mui/icons-material";
|
|
8
8
|
import { parse as v, convert as x } from "../../map/helpers/wkt.js";
|
|
9
9
|
import T from "lodash";
|
|
@@ -14,7 +14,7 @@ function M({
|
|
|
14
14
|
onCancel: m,
|
|
15
15
|
onSubmit: s
|
|
16
16
|
}) {
|
|
17
|
-
const [t, n] =
|
|
17
|
+
const [t, n] = g(
|
|
18
18
|
r ? y(r) : c
|
|
19
19
|
);
|
|
20
20
|
return /* @__PURE__ */ l(p, { children: [
|
|
@@ -27,7 +27,7 @@ function M({
|
|
|
27
27
|
disableContextMenu: !0,
|
|
28
28
|
defaultExtent: r,
|
|
29
29
|
onDrawEnd: (e) => {
|
|
30
|
-
const i =
|
|
30
|
+
const i = h({ features: e });
|
|
31
31
|
n(i);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -54,7 +54,7 @@ function M({
|
|
|
54
54
|
}
|
|
55
55
|
]
|
|
56
56
|
};
|
|
57
|
-
else if (e.type === "Point")
|
|
57
|
+
else if ((e == null ? void 0 : e.type) === "Point")
|
|
58
58
|
e = {
|
|
59
59
|
type: "GeometryCollection",
|
|
60
60
|
geometries: [
|
|
@@ -65,7 +65,7 @@ function M({
|
|
|
65
65
|
}
|
|
66
66
|
]
|
|
67
67
|
};
|
|
68
|
-
else if (e.type === "GeometryCollection")
|
|
68
|
+
else if ((e == null ? void 0 : e.type) === "GeometryCollection")
|
|
69
69
|
e.geometries.push({
|
|
70
70
|
type: "Point",
|
|
71
71
|
coordinates: [0, 0]
|
|
@@ -75,7 +75,7 @@ function M({
|
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
const i = x(e);
|
|
78
|
-
n(i);
|
|
78
|
+
n(i ?? "");
|
|
79
79
|
},
|
|
80
80
|
children: "Add Coordinate"
|
|
81
81
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as a, jsx as
|
|
1
|
+
import { jsxs as a, jsx as r, Fragment as x } from "react/jsx-runtime";
|
|
2
2
|
import E, { useState as F, useEffect as T } from "react";
|
|
3
3
|
import { Dialog as w, DialogContent as K, DialogActions as j, Button as c, Box as O } from "@mui/material";
|
|
4
4
|
import g from "../map/index.js";
|
|
@@ -16,53 +16,53 @@ function z({
|
|
|
16
16
|
onSubmit: u,
|
|
17
17
|
onChange: d
|
|
18
18
|
}) {
|
|
19
|
-
const
|
|
20
|
-
u && u(
|
|
21
|
-
}, p = (
|
|
22
|
-
const o = P({ features:
|
|
19
|
+
const t = E.useRef(null), [n, k] = F(y), m = () => {
|
|
20
|
+
u && u(n);
|
|
21
|
+
}, p = (e) => {
|
|
22
|
+
const o = P({ features: e });
|
|
23
23
|
k(o), d && d(o);
|
|
24
24
|
}, h = () => {
|
|
25
25
|
var o, v, C;
|
|
26
|
-
const
|
|
27
|
-
if (!_.isArray(
|
|
28
|
-
if (
|
|
29
|
-
const i = B(
|
|
30
|
-
(o =
|
|
26
|
+
const e = S(n);
|
|
27
|
+
if (!_.isArray(e))
|
|
28
|
+
if ((e == null ? void 0 : e.type) === "Point") {
|
|
29
|
+
const i = B(e.coordinates, "EPSG:4326", "EPSG:3857");
|
|
30
|
+
(o = t.current) == null || o.setCenter(i), (v = t.current) == null || v.setZoomLevel(10);
|
|
31
31
|
} else {
|
|
32
|
-
const i = R(
|
|
33
|
-
i && ((C =
|
|
32
|
+
const i = R(n);
|
|
33
|
+
i && ((C = t.current) == null || C.centerToFeature(i[0], [100, 100, 100, 100]));
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
return T(() => (h(), () => {
|
|
37
37
|
}), [h]), W === "dialog" ? /* @__PURE__ */ a(w, { open: !0, maxWidth: "sm", fullWidth: !0, onClose: l, children: [
|
|
38
|
-
/* @__PURE__ */
|
|
38
|
+
/* @__PURE__ */ r(K, { children: /* @__PURE__ */ r(
|
|
39
39
|
g,
|
|
40
40
|
{
|
|
41
41
|
id: f,
|
|
42
|
-
ref:
|
|
43
|
-
drawingWKTData:
|
|
42
|
+
ref: t,
|
|
43
|
+
drawingWKTData: n,
|
|
44
44
|
mapboxAccessToken: s,
|
|
45
45
|
onDrawEnd: p
|
|
46
46
|
}
|
|
47
47
|
) }),
|
|
48
48
|
/* @__PURE__ */ a(j, { children: [
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
/* @__PURE__ */
|
|
49
|
+
/* @__PURE__ */ r(c, { color: "inherit", variant: "contained", onClick: l, children: "Cancel" }),
|
|
50
|
+
/* @__PURE__ */ r(c, { variant: "contained", onClick: m, children: "Ok" })
|
|
51
51
|
] })
|
|
52
52
|
] }) : /* @__PURE__ */ a(x, { children: [
|
|
53
|
-
/* @__PURE__ */
|
|
53
|
+
/* @__PURE__ */ r(
|
|
54
54
|
g,
|
|
55
55
|
{
|
|
56
56
|
id: f,
|
|
57
|
-
ref:
|
|
58
|
-
drawingWKTData:
|
|
57
|
+
ref: t,
|
|
58
|
+
drawingWKTData: n,
|
|
59
59
|
mapboxAccessToken: s,
|
|
60
60
|
onDrawEnd: p
|
|
61
61
|
}
|
|
62
62
|
),
|
|
63
63
|
!D && /* @__PURE__ */ a(O, { display: "flex", justifyContent: "space-between", mt: 3, children: [
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ r(c, { color: "primary", onClick: l, children: "Cancel" }),
|
|
65
|
+
/* @__PURE__ */ r(c, { color: "primary", variant: "contained", onClick: m, children: "Ok" })
|
|
66
66
|
] })
|
|
67
67
|
] });
|
|
68
68
|
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { jsx as e, Fragment as
|
|
1
|
+
import { jsx as e, Fragment as w, jsxs as o } from "react/jsx-runtime";
|
|
2
2
|
import { AccordionSummary as c, Box as a, Typography as s, Tooltip as d, IconButton as h, AccordionDetails as p } from "@mui/material";
|
|
3
3
|
import m from "./coordinate-input/index.js";
|
|
4
|
-
import
|
|
4
|
+
import P from "./logic.js";
|
|
5
5
|
import { GridExpandMoreIcon as f } from "@mui/x-data-grid";
|
|
6
6
|
import { Accordion as u } from "./styled.js";
|
|
7
7
|
import { Close as g } from "@mui/icons-material";
|
|
8
|
-
import { ConditionalWrapper as
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import { ConditionalWrapper as z } from "../../conditional-wrapper/index.js";
|
|
9
|
+
function R(C) {
|
|
10
|
+
var I;
|
|
11
|
+
const { state: y, action: t } = P(C);
|
|
12
|
+
return /* @__PURE__ */ e(w, { children: (I = y.parsed) == null ? void 0 : I.map((r, n) => {
|
|
12
13
|
if (r.type === "Point")
|
|
13
14
|
return /* @__PURE__ */ e(
|
|
14
|
-
|
|
15
|
+
z,
|
|
15
16
|
{
|
|
16
17
|
condition: !C.disableGrouping,
|
|
17
18
|
wrapper: (i) => /* @__PURE__ */ o(u, { defaultExpanded: !0, children: [
|
|
@@ -175,5 +176,5 @@ function M(C) {
|
|
|
175
176
|
}) });
|
|
176
177
|
}
|
|
177
178
|
export {
|
|
178
|
-
|
|
179
|
+
R as default
|
|
179
180
|
};
|
|
@@ -1,80 +1,80 @@
|
|
|
1
1
|
import u from "react";
|
|
2
2
|
import { parse as a, convert as l } from "../../map/helpers/wkt.js";
|
|
3
3
|
import m from "lodash";
|
|
4
|
-
function M({ value: p, onChange:
|
|
5
|
-
const
|
|
4
|
+
function M({ value: p, onChange: s }) {
|
|
5
|
+
const n = u.useMemo(() => {
|
|
6
6
|
let o = a(p);
|
|
7
|
-
return m.isArray(o)
|
|
7
|
+
return o && !m.isArray(o) && (o = [o]), o;
|
|
8
8
|
}, [p]);
|
|
9
9
|
return {
|
|
10
10
|
state: {
|
|
11
|
-
parsed:
|
|
11
|
+
parsed: n
|
|
12
12
|
},
|
|
13
13
|
action: {
|
|
14
|
-
onCoordinateInputChange: (o) => (
|
|
15
|
-
if (
|
|
14
|
+
onCoordinateInputChange: (o) => (c) => {
|
|
15
|
+
if (s) {
|
|
16
16
|
let e;
|
|
17
|
-
const t = [...
|
|
17
|
+
const t = [...n || []];
|
|
18
18
|
t[o] = {
|
|
19
19
|
type: "Point",
|
|
20
|
-
coordinates: [
|
|
20
|
+
coordinates: [c.longitude, c.latitude]
|
|
21
21
|
}, t.length > 1 ? e = l({
|
|
22
22
|
type: "GeometryCollection",
|
|
23
23
|
geometries: t
|
|
24
|
-
}) : e = l(t[0]),
|
|
24
|
+
}) : e = l(t[0]), s(e ?? "");
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
-
onPolygonInputChange: (o,
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
|
|
27
|
+
onPolygonInputChange: (o, c, e) => (t) => {
|
|
28
|
+
if (s) {
|
|
29
|
+
const i = [...n || []], r = [...o[0]];
|
|
30
|
+
r[e] = [t.longitude, t.latitude], i[c] = {
|
|
31
31
|
type: "Polygon",
|
|
32
|
-
coordinates: [
|
|
32
|
+
coordinates: [r]
|
|
33
33
|
};
|
|
34
34
|
const g = l({
|
|
35
35
|
type: "GeometryCollection",
|
|
36
|
-
geometries:
|
|
36
|
+
geometries: i
|
|
37
37
|
});
|
|
38
|
-
|
|
38
|
+
s(g ?? "");
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
-
onMultiPointInputChange: (o,
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
|
|
41
|
+
onMultiPointInputChange: (o, c, e) => (t) => {
|
|
42
|
+
if (s) {
|
|
43
|
+
const i = [...n || []], r = [...o];
|
|
44
|
+
r[e] = [t.longitude, t.latitude], i[c] = {
|
|
45
45
|
type: "MultiPoint",
|
|
46
|
-
coordinates:
|
|
46
|
+
coordinates: r
|
|
47
47
|
};
|
|
48
48
|
const g = l({
|
|
49
49
|
type: "GeometryCollection",
|
|
50
|
-
geometries:
|
|
50
|
+
geometries: i
|
|
51
51
|
});
|
|
52
|
-
|
|
52
|
+
s(g ?? "");
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
|
-
onLineStringInputChange: (o,
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
58
|
-
|
|
55
|
+
onLineStringInputChange: (o, c, e) => (t) => {
|
|
56
|
+
if (s) {
|
|
57
|
+
const i = [...n || []], r = [...o];
|
|
58
|
+
r[e] = [t.longitude, t.latitude], i[c] = {
|
|
59
59
|
type: "LineString",
|
|
60
|
-
coordinates:
|
|
60
|
+
coordinates: r
|
|
61
61
|
};
|
|
62
62
|
const g = l({
|
|
63
63
|
type: "GeometryCollection",
|
|
64
|
-
geometries:
|
|
64
|
+
geometries: i
|
|
65
65
|
});
|
|
66
|
-
|
|
66
|
+
s(g ?? "");
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
|
-
onRemoveItem: (o) => (
|
|
70
|
-
if (
|
|
71
|
-
const e = [...
|
|
69
|
+
onRemoveItem: (o) => (c) => {
|
|
70
|
+
if (c.stopPropagation(), s) {
|
|
71
|
+
const e = [...n || []];
|
|
72
72
|
e.splice(o, 1);
|
|
73
|
-
const
|
|
73
|
+
const i = l({
|
|
74
74
|
type: "GeometryCollection",
|
|
75
75
|
geometries: e
|
|
76
76
|
});
|
|
77
|
-
i
|
|
77
|
+
s(i ?? "");
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import i from "terraformer-wkt-parser";
|
|
2
2
|
import * as o from "@turf/turf";
|
|
3
3
|
const l = (e) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
try {
|
|
5
|
+
if (e.includes("GEOMETRYCOLLECTION")) {
|
|
6
|
+
let t = e.replace("GEOMETRYCOLLECTION(", "");
|
|
7
|
+
t = t.slice(0, -1);
|
|
8
|
+
let r = t.split("),");
|
|
9
|
+
return r = r.filter((n) => n !== "").map((n, c) => (c < r.length - 1 && (n += ")"), n)), r.map((n) => i.parse(n));
|
|
10
|
+
}
|
|
11
|
+
return i.parse(e);
|
|
12
|
+
} catch {
|
|
9
13
|
}
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
}, p = (e) => {
|
|
15
|
+
try {
|
|
16
|
+
return i.convert(e);
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
}, u = (e) => {
|
|
12
20
|
let t = [0, 0];
|
|
13
21
|
if (e.type === "Point")
|
|
14
22
|
return t = e.coordinates, t;
|
|
15
23
|
if (e.type === "Polygon") {
|
|
16
|
-
const
|
|
17
|
-
return t = o.centerOfMass(
|
|
24
|
+
const r = o.polygon(e.coordinates);
|
|
25
|
+
return t = o.centerOfMass(r).geometry.coordinates, t;
|
|
18
26
|
}
|
|
19
27
|
if (e.type === "LineString") {
|
|
20
|
-
const
|
|
21
|
-
return t = o.centerOfMass(
|
|
28
|
+
const r = o.lineString(e.coordinates);
|
|
29
|
+
return t = o.centerOfMass(r).geometry.coordinates, t;
|
|
22
30
|
}
|
|
23
31
|
return e.type === "MultiPoint" ? (t = o.multiPoint(e.coordinates).geometry.coordinates[0], t) : (console.log("Undefined geometry type!", e.type), t);
|
|
24
32
|
};
|