@octostar/map-component 0.1.27 → 0.1.29
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 +926 -567
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +926 -567
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +24 -3
- package/dist/types/components/cluster-pie-chart.d.ts +10 -2
- package/dist/types/components/cluster-pie-chart.d.ts.map +1 -1
- package/dist/types/components/layers-panel.d.ts +16 -2
- package/dist/types/components/layers-panel.d.ts.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/components/properties-panel.d.ts +8 -1
- package/dist/types/components/properties-panel.d.ts.map +1 -1
- package/dist/types/components/timebar.d.ts.map +1 -1
- package/dist/types/lib/color-utils.d.ts +37 -0
- package/dist/types/lib/color-utils.d.ts.map +1 -0
- package/dist/types/lib/map-editor-api.d.ts +62 -0
- package/dist/types/lib/map-editor-api.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1574,11 +1574,133 @@ function ColorPickerPopover({ value, onChange, testId }) {
|
|
|
1574
1574
|
}
|
|
1575
1575
|
);
|
|
1576
1576
|
}
|
|
1577
|
+
function categoricalKey(raw) {
|
|
1578
|
+
if (raw == null) return null;
|
|
1579
|
+
if (typeof raw === "string") return raw === "" ? null : raw;
|
|
1580
|
+
return String(raw);
|
|
1581
|
+
}
|
|
1582
|
+
const SELECTION_HUE = 187;
|
|
1583
|
+
const SELECTION_HUE_HALF_WIDTH = 12;
|
|
1584
|
+
function fnv1aHash(str) {
|
|
1585
|
+
let hash = 2166136261;
|
|
1586
|
+
for (let i = 0; i < str.length; i++) {
|
|
1587
|
+
hash ^= str.charCodeAt(i);
|
|
1588
|
+
hash = Math.imul(hash, 16777619);
|
|
1589
|
+
}
|
|
1590
|
+
return hash >>> 0;
|
|
1591
|
+
}
|
|
1592
|
+
function hslToHex(h, s, l) {
|
|
1593
|
+
const sNorm = s / 100;
|
|
1594
|
+
const lNorm = l / 100;
|
|
1595
|
+
const k = (n) => (n + h / 30) % 12;
|
|
1596
|
+
const a = sNorm * Math.min(lNorm, 1 - lNorm);
|
|
1597
|
+
const f = (n) => {
|
|
1598
|
+
const value = lNorm - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
1599
|
+
return Math.round(value * 255);
|
|
1600
|
+
};
|
|
1601
|
+
const toHex = (n) => n.toString(16).padStart(2, "0");
|
|
1602
|
+
return `#${toHex(f(0))}${toHex(f(8))}${toHex(f(4))}`;
|
|
1603
|
+
}
|
|
1604
|
+
function hashStringToColor(str) {
|
|
1605
|
+
const hash = fnv1aHash(str);
|
|
1606
|
+
let hue = hash * 137.508 % 360;
|
|
1607
|
+
if (hue < 0) hue += 360;
|
|
1608
|
+
const delta = (hue - SELECTION_HUE + 540) % 360 - 180;
|
|
1609
|
+
if (Math.abs(delta) < SELECTION_HUE_HALF_WIDTH) {
|
|
1610
|
+
hue = (SELECTION_HUE + (delta >= 0 ? SELECTION_HUE_HALF_WIDTH : -SELECTION_HUE_HALF_WIDTH) + 360) % 360;
|
|
1611
|
+
}
|
|
1612
|
+
const sat = 60 + (hash >>> 8) % 30;
|
|
1613
|
+
const light = 45 + (hash >>> 16) % 18;
|
|
1614
|
+
return hslToHex(hue, sat, light);
|
|
1615
|
+
}
|
|
1577
1616
|
const MAP_STYLES = [
|
|
1578
1617
|
{ id: "streets", name: "Streets", icon: lucideReact.Map },
|
|
1579
1618
|
{ id: "satellite", name: "Satellite", icon: lucideReact.Satellite },
|
|
1580
1619
|
{ id: "dark", name: "Dark", icon: lucideReact.Map }
|
|
1581
1620
|
];
|
|
1621
|
+
const LEGEND_MAX_VALUES = 50;
|
|
1622
|
+
const LEGEND_INITIAL_VISIBLE = 8;
|
|
1623
|
+
function ColorByFieldLegend({
|
|
1624
|
+
layerId,
|
|
1625
|
+
fieldName,
|
|
1626
|
+
getFieldValueDistribution
|
|
1627
|
+
}) {
|
|
1628
|
+
const [expanded, setExpanded] = react.useState(false);
|
|
1629
|
+
const [filter, setFilter] = react.useState("");
|
|
1630
|
+
react.useEffect(() => {
|
|
1631
|
+
setFilter("");
|
|
1632
|
+
setExpanded(false);
|
|
1633
|
+
}, [layerId, fieldName]);
|
|
1634
|
+
const distribution = react.useMemo(
|
|
1635
|
+
() => getFieldValueDistribution(layerId, fieldName, LEGEND_MAX_VALUES),
|
|
1636
|
+
[getFieldValueDistribution, layerId, fieldName]
|
|
1637
|
+
);
|
|
1638
|
+
const filtered = react.useMemo(() => {
|
|
1639
|
+
const q = filter.trim().toLowerCase();
|
|
1640
|
+
if (!q) return distribution;
|
|
1641
|
+
return distribution.filter((d) => d.value.toLowerCase().includes(q));
|
|
1642
|
+
}, [distribution, filter]);
|
|
1643
|
+
if (distribution.length === 0) return null;
|
|
1644
|
+
const visible = expanded ? filtered : filtered.slice(0, LEGEND_INITIAL_VISIBLE);
|
|
1645
|
+
const hiddenCount = filtered.length - visible.length;
|
|
1646
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1647
|
+
"div",
|
|
1648
|
+
{
|
|
1649
|
+
className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5",
|
|
1650
|
+
"data-testid": `legend-color-by-${layerId}`,
|
|
1651
|
+
children: [
|
|
1652
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-[10px] uppercase tracking-wide text-muted-foreground mb-1", children: [
|
|
1653
|
+
"Legend",
|
|
1654
|
+
distribution.length >= LEGEND_MAX_VALUES ? ` (top ${LEGEND_MAX_VALUES})` : ""
|
|
1655
|
+
] }),
|
|
1656
|
+
(distribution.length > LEGEND_INITIAL_VISIBLE || expanded) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1657
|
+
antd.Input,
|
|
1658
|
+
{
|
|
1659
|
+
size: "small",
|
|
1660
|
+
allowClear: true,
|
|
1661
|
+
placeholder: "Filter values…",
|
|
1662
|
+
value: filter,
|
|
1663
|
+
onChange: (e) => setFilter(e.target.value),
|
|
1664
|
+
className: "mb-1 !text-[11px]",
|
|
1665
|
+
"data-testid": `legend-filter-${layerId}`
|
|
1666
|
+
}
|
|
1667
|
+
),
|
|
1668
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5 max-h-40 overflow-y-auto", children: [
|
|
1669
|
+
visible.map(({ value, count }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1670
|
+
"div",
|
|
1671
|
+
{
|
|
1672
|
+
className: "flex items-center gap-1.5 text-[11px]",
|
|
1673
|
+
title: `${value} (${count})`,
|
|
1674
|
+
children: [
|
|
1675
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1676
|
+
"span",
|
|
1677
|
+
{
|
|
1678
|
+
className: "inline-block w-2.5 h-2.5 rounded-sm shrink-0 border border-black/10",
|
|
1679
|
+
style: { backgroundColor: hashStringToColor(value) }
|
|
1680
|
+
}
|
|
1681
|
+
),
|
|
1682
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate flex-1 text-foreground", children: value }),
|
|
1683
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground tabular-nums", children: count })
|
|
1684
|
+
]
|
|
1685
|
+
},
|
|
1686
|
+
value
|
|
1687
|
+
)),
|
|
1688
|
+
visible.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[11px] text-muted-foreground italic", children: "No matches" })
|
|
1689
|
+
] }),
|
|
1690
|
+
(hiddenCount > 0 || expanded && filtered.length > LEGEND_INITIAL_VISIBLE) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1691
|
+
"button",
|
|
1692
|
+
{
|
|
1693
|
+
type: "button",
|
|
1694
|
+
className: "mt-1 text-[11px] text-primary hover:underline",
|
|
1695
|
+
onClick: () => setExpanded((e) => !e),
|
|
1696
|
+
"data-testid": `legend-toggle-${layerId}`,
|
|
1697
|
+
children: expanded ? "Show less" : `Show all (${filtered.length})`
|
|
1698
|
+
}
|
|
1699
|
+
)
|
|
1700
|
+
]
|
|
1701
|
+
}
|
|
1702
|
+
);
|
|
1703
|
+
}
|
|
1582
1704
|
function LayersPanel({
|
|
1583
1705
|
layers,
|
|
1584
1706
|
onAddLayer,
|
|
@@ -1606,6 +1728,7 @@ function LayersPanel({
|
|
|
1606
1728
|
onUpdateTraceConfig,
|
|
1607
1729
|
getAvailableTraceFields,
|
|
1608
1730
|
getLayerFields,
|
|
1731
|
+
getFieldValueDistribution,
|
|
1609
1732
|
onUpdateHeatmapConfig,
|
|
1610
1733
|
onUpdateClusterConfig,
|
|
1611
1734
|
onUpdateVisualConfig,
|
|
@@ -1622,6 +1745,7 @@ function LayersPanel({
|
|
|
1622
1745
|
hideBasemapSwitcher = false,
|
|
1623
1746
|
externalPersistence = false,
|
|
1624
1747
|
customGlobalMenuItems,
|
|
1748
|
+
extraLayerToolbarButtons,
|
|
1625
1749
|
layerBadgeProvider,
|
|
1626
1750
|
featureCountProvider
|
|
1627
1751
|
}) {
|
|
@@ -1714,7 +1838,7 @@ function LayersPanel({
|
|
|
1714
1838
|
});
|
|
1715
1839
|
}, [onRemoveLayer]);
|
|
1716
1840
|
const renderLayerItem = (layer) => {
|
|
1717
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _
|
|
1841
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba;
|
|
1718
1842
|
const customCount = featureCountProvider == null ? void 0 : featureCountProvider(layer.id);
|
|
1719
1843
|
const featureCount = customCount != null ? customCount : getFeatureCount(layer.id);
|
|
1720
1844
|
const isExpanded = expandedLayers.has(layer.id);
|
|
@@ -1909,6 +2033,8 @@ function LayersPanel({
|
|
|
1909
2033
|
groupByField: val === "all" ? null : val
|
|
1910
2034
|
}),
|
|
1911
2035
|
className: "w-full text-xs",
|
|
2036
|
+
showSearch: true,
|
|
2037
|
+
optionFilterProp: "label",
|
|
1912
2038
|
options: [
|
|
1913
2039
|
{ value: "all", label: "Connect all points" },
|
|
1914
2040
|
...getAvailableTraceFields(layer.id).map((f) => ({ value: f, label: `Group by ${f}` }))
|
|
@@ -1925,12 +2051,11 @@ function LayersPanel({
|
|
|
1925
2051
|
size: "small",
|
|
1926
2052
|
checked: ((_d = layer.heatmapConfig) == null ? void 0 : _d.enabled) ?? false,
|
|
1927
2053
|
onChange: (checked) => {
|
|
1928
|
-
var _a2, _b2
|
|
2054
|
+
var _a2, _b2;
|
|
1929
2055
|
return onUpdateHeatmapConfig(layer.id, {
|
|
1930
2056
|
enabled: checked,
|
|
1931
2057
|
intensity: ((_a2 = layer.heatmapConfig) == null ? void 0 : _a2.intensity) ?? 1,
|
|
1932
|
-
radius: ((_b2 = layer.heatmapConfig) == null ? void 0 : _b2.radius) ?? 20
|
|
1933
|
-
hideFeatures: ((_c2 = layer.heatmapConfig) == null ? void 0 : _c2.hideFeatures) ?? false
|
|
2058
|
+
radius: ((_b2 = layer.heatmapConfig) == null ? void 0 : _b2.radius) ?? 20
|
|
1934
2059
|
});
|
|
1935
2060
|
},
|
|
1936
2061
|
"data-testid": `switch-heatmap-${layer.id}`
|
|
@@ -1972,20 +2097,6 @@ function LayersPanel({
|
|
|
1972
2097
|
})
|
|
1973
2098
|
}
|
|
1974
2099
|
)
|
|
1975
|
-
] }),
|
|
1976
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1977
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1978
|
-
antd.Switch,
|
|
1979
|
-
{
|
|
1980
|
-
size: "small",
|
|
1981
|
-
checked: layer.heatmapConfig.hideFeatures ?? false,
|
|
1982
|
-
onChange: (checked) => onUpdateHeatmapConfig(layer.id, {
|
|
1983
|
-
...layer.heatmapConfig,
|
|
1984
|
-
hideFeatures: checked
|
|
1985
|
-
})
|
|
1986
|
-
}
|
|
1987
|
-
),
|
|
1988
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px]", children: "Hide points" })
|
|
1989
2100
|
] })
|
|
1990
2101
|
] })
|
|
1991
2102
|
] }),
|
|
@@ -2021,6 +2132,8 @@ function LayersPanel({
|
|
|
2021
2132
|
groupByField: val === "count" ? null : val
|
|
2022
2133
|
}),
|
|
2023
2134
|
className: "w-full text-xs",
|
|
2135
|
+
showSearch: true,
|
|
2136
|
+
optionFilterProp: "label",
|
|
2024
2137
|
options: [
|
|
2025
2138
|
{ value: "count", label: "Simple count" },
|
|
2026
2139
|
...getLayerFields(layer.id).filter((f) => !f.isNumeric).map((f) => ({ value: f.name, label: `Pie by ${f.name}` }))
|
|
@@ -2122,6 +2235,8 @@ function LayersPanel({
|
|
|
2122
2235
|
}),
|
|
2123
2236
|
className: "w-full text-sm",
|
|
2124
2237
|
placeholder: "Select field...",
|
|
2238
|
+
showSearch: true,
|
|
2239
|
+
optionFilterProp: "label",
|
|
2125
2240
|
options: getLayerFields(layer.id).map((f) => ({ value: f.name, label: f.name })),
|
|
2126
2241
|
"data-testid": `select-label-field-${layer.id}`
|
|
2127
2242
|
}
|
|
@@ -2173,6 +2288,8 @@ function LayersPanel({
|
|
|
2173
2288
|
}),
|
|
2174
2289
|
className: "w-full text-sm",
|
|
2175
2290
|
placeholder: "Select numeric field...",
|
|
2291
|
+
showSearch: true,
|
|
2292
|
+
optionFilterProp: "label",
|
|
2176
2293
|
options: getLayerFields(layer.id).filter((f) => f.isNumeric).map((f) => ({ value: f.name, label: f.name })),
|
|
2177
2294
|
"data-testid": `select-size-field-${layer.id}`
|
|
2178
2295
|
}
|
|
@@ -2216,25 +2333,37 @@ function LayersPanel({
|
|
|
2216
2333
|
"data-testid": `select-color-mode-${layer.id}`
|
|
2217
2334
|
}
|
|
2218
2335
|
),
|
|
2219
|
-
((_K = (_J = layer.visualConfig) == null ? void 0 : _J.color) == null ? void 0 : _K.mode) === "field" && /* @__PURE__ */ jsxRuntime.
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2336
|
+
((_K = (_J = layer.visualConfig) == null ? void 0 : _J.color) == null ? void 0 : _K.mode) === "field" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2337
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2338
|
+
antd.Select,
|
|
2339
|
+
{
|
|
2340
|
+
size: "small",
|
|
2341
|
+
value: ((_M = (_L = layer.visualConfig) == null ? void 0 : _L.color) == null ? void 0 : _M.fieldName) ?? "",
|
|
2342
|
+
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
2343
|
+
...layer.visualConfig,
|
|
2344
|
+
color: { mode: "field", fieldName: val }
|
|
2345
|
+
}),
|
|
2346
|
+
className: "w-full text-sm",
|
|
2347
|
+
placeholder: "Select field...",
|
|
2348
|
+
showSearch: true,
|
|
2349
|
+
optionFilterProp: "label",
|
|
2350
|
+
options: getLayerFields(layer.id).map((f) => ({ value: f.name, label: f.name })),
|
|
2351
|
+
"data-testid": `select-color-field-${layer.id}`
|
|
2352
|
+
}
|
|
2353
|
+
),
|
|
2354
|
+
((_O = (_N = layer.visualConfig) == null ? void 0 : _N.color) == null ? void 0 : _O.fieldName) && getFieldValueDistribution && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2355
|
+
ColorByFieldLegend,
|
|
2356
|
+
{
|
|
2357
|
+
layerId: layer.id,
|
|
2358
|
+
fieldName: layer.visualConfig.color.fieldName,
|
|
2359
|
+
getFieldValueDistribution
|
|
2360
|
+
}
|
|
2361
|
+
)
|
|
2362
|
+
] }),
|
|
2363
|
+
((_Q = (_P = layer.visualConfig) == null ? void 0 : _P.color) == null ? void 0 : _Q.mode) === "fixed" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2235
2364
|
ColorPickerPopover,
|
|
2236
2365
|
{
|
|
2237
|
-
value: ((
|
|
2366
|
+
value: ((_S = (_R = layer.visualConfig) == null ? void 0 : _R.color) == null ? void 0 : _S.fixedColor) ?? "#3b82f6",
|
|
2238
2367
|
onChange: (color) => {
|
|
2239
2368
|
onUpdateVisualConfig == null ? void 0 : onUpdateVisualConfig(layer.id, {
|
|
2240
2369
|
...layer.visualConfig,
|
|
@@ -2247,7 +2376,7 @@ function LayersPanel({
|
|
|
2247
2376
|
testId: `color-fixed-${layer.id}`
|
|
2248
2377
|
}
|
|
2249
2378
|
),
|
|
2250
|
-
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((
|
|
2379
|
+
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((_T = layer.metadata) == null ? void 0 : _T.hidePointFeatures) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2251
2380
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground pt-0.5", children: [
|
|
2252
2381
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Smile, { className: "w-3.5 h-3.5" }),
|
|
2253
2382
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Point Icon" })
|
|
@@ -2257,7 +2386,7 @@ function LayersPanel({
|
|
|
2257
2386
|
antd.Switch,
|
|
2258
2387
|
{
|
|
2259
2388
|
size: "small",
|
|
2260
|
-
checked: ((
|
|
2389
|
+
checked: ((_V = (_U = layer.visualConfig) == null ? void 0 : _U.icon) == null ? void 0 : _V.enabled) ?? false,
|
|
2261
2390
|
onChange: (checked) => {
|
|
2262
2391
|
var _a2, _b2, _c2, _d2;
|
|
2263
2392
|
onUpdateVisualConfig == null ? void 0 : onUpdateVisualConfig(layer.id, {
|
|
@@ -2272,11 +2401,11 @@ function LayersPanel({
|
|
|
2272
2401
|
"data-testid": `switch-icon-${layer.id}`
|
|
2273
2402
|
}
|
|
2274
2403
|
),
|
|
2275
|
-
((
|
|
2404
|
+
((_X = (_W = layer.visualConfig) == null ? void 0 : _W.icon) == null ? void 0 : _X.enabled) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 flex-1", children: [
|
|
2276
2405
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2277
2406
|
IconPicker,
|
|
2278
2407
|
{
|
|
2279
|
-
value: ((
|
|
2408
|
+
value: ((_Z = (_Y = layer.visualConfig) == null ? void 0 : _Y.icon) == null ? void 0 : _Z.icon) ?? "📍",
|
|
2280
2409
|
onChange: (icon) => {
|
|
2281
2410
|
var _a2, _b2;
|
|
2282
2411
|
onUpdateVisualConfig == null ? void 0 : onUpdateVisualConfig(layer.id, {
|
|
@@ -2293,7 +2422,7 @@ function LayersPanel({
|
|
|
2293
2422
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2294
2423
|
antd.Slider,
|
|
2295
2424
|
{
|
|
2296
|
-
value: ((
|
|
2425
|
+
value: ((_$ = (__ = layer.visualConfig) == null ? void 0 : __.icon) == null ? void 0 : _$.size) ?? 24,
|
|
2297
2426
|
min: 12,
|
|
2298
2427
|
max: 48,
|
|
2299
2428
|
step: 2,
|
|
@@ -2311,7 +2440,7 @@ function LayersPanel({
|
|
|
2311
2440
|
}
|
|
2312
2441
|
}
|
|
2313
2442
|
),
|
|
2314
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm w-6 text-right", children: ((
|
|
2443
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm w-6 text-right", children: ((_ba = (_aa = layer.visualConfig) == null ? void 0 : _aa.icon) == null ? void 0 : _ba.size) ?? 24 })
|
|
2315
2444
|
] })
|
|
2316
2445
|
] })
|
|
2317
2446
|
] })
|
|
@@ -2393,6 +2522,7 @@ function LayersPanel({
|
|
|
2393
2522
|
) })
|
|
2394
2523
|
}
|
|
2395
2524
|
),
|
|
2525
|
+
extraLayerToolbarButtons,
|
|
2396
2526
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2397
2527
|
antd.Dropdown,
|
|
2398
2528
|
{
|
|
@@ -2675,6 +2805,56 @@ function getFeatureTypeIcon(geometryType, kind, size = "sm") {
|
|
|
2675
2805
|
return null;
|
|
2676
2806
|
}
|
|
2677
2807
|
}
|
|
2808
|
+
function colorPickerNoHexPanel(_panel, extra) {
|
|
2809
|
+
const { Picker, Presets } = extra.components;
|
|
2810
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 min-w-[220px]", children: [
|
|
2811
|
+
/* @__PURE__ */ jsxRuntime.jsx(Picker, {}),
|
|
2812
|
+
/* @__PURE__ */ jsxRuntime.jsx(Presets, {})
|
|
2813
|
+
] });
|
|
2814
|
+
}
|
|
2815
|
+
function LatLngFields(props) {
|
|
2816
|
+
const { latitude, longitude, isEditable, testIdPrefix } = props;
|
|
2817
|
+
if (!isEditable) {
|
|
2818
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2819
|
+
"div",
|
|
2820
|
+
{
|
|
2821
|
+
className: "flex items-center gap-2 text-[13px] font-mono text-foreground px-1 py-1",
|
|
2822
|
+
"data-testid": `${testIdPrefix}-display`,
|
|
2823
|
+
children: [
|
|
2824
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": `${testIdPrefix}-latitude-text`, children: latitude || "—" }),
|
|
2825
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "/" }),
|
|
2826
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": `${testIdPrefix}-longitude-text`, children: longitude || "—" })
|
|
2827
|
+
]
|
|
2828
|
+
}
|
|
2829
|
+
);
|
|
2830
|
+
}
|
|
2831
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1", children: [
|
|
2832
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2833
|
+
antd.Input,
|
|
2834
|
+
{
|
|
2835
|
+
value: latitude,
|
|
2836
|
+
onChange: (e) => props.onLatChange(e.target.value),
|
|
2837
|
+
onFocus: props.onLatFocus,
|
|
2838
|
+
onBlur: props.onLatBlur,
|
|
2839
|
+
placeholder: "Latitude",
|
|
2840
|
+
className: "!h-6 text-[13px] flex-1",
|
|
2841
|
+
"data-testid": `${testIdPrefix}-latitude`
|
|
2842
|
+
}
|
|
2843
|
+
),
|
|
2844
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2845
|
+
antd.Input,
|
|
2846
|
+
{
|
|
2847
|
+
value: longitude,
|
|
2848
|
+
onChange: (e) => props.onLngChange(e.target.value),
|
|
2849
|
+
onFocus: props.onLngFocus,
|
|
2850
|
+
onBlur: props.onLngBlur,
|
|
2851
|
+
placeholder: "Longitude",
|
|
2852
|
+
className: "!h-6 text-[13px] flex-1",
|
|
2853
|
+
"data-testid": `${testIdPrefix}-longitude`
|
|
2854
|
+
}
|
|
2855
|
+
)
|
|
2856
|
+
] });
|
|
2857
|
+
}
|
|
2678
2858
|
function PointColorDot({ color, size = 20 }) {
|
|
2679
2859
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: size, height: size, viewBox: "0 0 20 20", className: "shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "10", cy: "10", r: "7", fill: color, stroke: color, strokeWidth: "2", opacity: "0.9" }) });
|
|
2680
2860
|
}
|
|
@@ -2728,8 +2908,21 @@ const RECORD_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
|
|
|
2728
2908
|
"entityType",
|
|
2729
2909
|
"startDate",
|
|
2730
2910
|
"endDate",
|
|
2731
|
-
|
|
2911
|
+
// The feature's color is already conveyed by the colored dot in the panel
|
|
2912
|
+
// header; showing it again as a property row (`#0C66E4`) is just noise.
|
|
2913
|
+
"color"
|
|
2914
|
+
// NOTE: 'description' intentionally NOT excluded — we surface it as a regular
|
|
2915
|
+
// property row instead of giving it its own labelled section.
|
|
2732
2916
|
]);
|
|
2917
|
+
function buildKeyExclusionPredicate(set) {
|
|
2918
|
+
const lowered = new Set(Array.from(set, (k) => k.toLowerCase()));
|
|
2919
|
+
return (key) => {
|
|
2920
|
+
if (set.has(key)) return true;
|
|
2921
|
+
const normalized = key.toLowerCase().replace(/^[^a-z0-9_-]+/, "");
|
|
2922
|
+
return lowered.has(normalized);
|
|
2923
|
+
};
|
|
2924
|
+
}
|
|
2925
|
+
const isExcludedRecordKey = buildKeyExclusionPredicate(RECORD_EXCLUDE_KEYS);
|
|
2733
2926
|
const RECORD_FIELDS_HIDDEN_PREFIXES = ["_", "os_"];
|
|
2734
2927
|
function parseRecordFields(feature) {
|
|
2735
2928
|
const raw = feature.properties._recordFields;
|
|
@@ -2756,14 +2949,14 @@ function RecordFieldsSection({ feature }) {
|
|
|
2756
2949
|
antd.Collapse,
|
|
2757
2950
|
{
|
|
2758
2951
|
size: "small",
|
|
2759
|
-
defaultActiveKey: [
|
|
2952
|
+
defaultActiveKey: [],
|
|
2760
2953
|
ghost: true,
|
|
2761
2954
|
className: "[&_.ant-collapse-header]:!px-0 [&_.ant-collapse-header]:!py-1 [&_.ant-collapse-content-box]:!px-0 [&_.ant-collapse-content-box]:!py-1",
|
|
2762
2955
|
items: [{
|
|
2763
2956
|
key: "record-fields",
|
|
2764
2957
|
label: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
2765
2958
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { className: "w-3 h-3 text-foreground" }),
|
|
2766
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-
|
|
2959
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-bold uppercase tracking-wide text-foreground", children: "Record Fields" }),
|
|
2767
2960
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[10px] text-muted-foreground ml-1", children: [
|
|
2768
2961
|
"(",
|
|
2769
2962
|
fields.length,
|
|
@@ -2779,7 +2972,7 @@ function RecordFieldsSection({ feature }) {
|
|
|
2779
2972
|
);
|
|
2780
2973
|
}
|
|
2781
2974
|
let persistedTabPreference = "properties";
|
|
2782
|
-
function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometry, onClose, isEditMode = true, isReadOnlyLayer = false, layerName, layerId, autoFocusLabel = false, entityCardProvider, typePickerProvider, featureSaveProvider, featureRefreshProvider, onFeatureSaved, onDeleteFeatures, onOpenInNewTab, onEntityContextMenu, layers, onMoveFeaturesToLayer, onCopyFeaturesToLayer, onCreateLayerAndMoveFeatures, onCreateLayerAndCopyFeatures }) {
|
|
2975
|
+
function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometry, onClose, isEditMode = true, isReadOnlyLayer = false, layerName, layerId, autoFocusLabel = false, entityCardProvider, typePickerProvider, featureSaveProvider, featureRefreshProvider, onFeatureSaved, onDeleteFeatures, onOpenInNewTab, onEntityContextMenu, layers, onMoveFeaturesToLayer, onCopyFeaturesToLayer, onCreateLayerAndMoveFeatures, onCreateLayerAndCopyFeatures, getFeatureColor }) {
|
|
2783
2976
|
var _a, _b, _c, _d, _e;
|
|
2784
2977
|
const feature = selectedFeatures[0];
|
|
2785
2978
|
const { toast } = useToast();
|
|
@@ -2854,6 +3047,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
2854
3047
|
const [endDate, setEndDate] = react.useState("");
|
|
2855
3048
|
const [customProperties, setCustomProperties] = react.useState([]);
|
|
2856
3049
|
const [newPropertyKey, setNewPropertyKey] = react.useState("");
|
|
3050
|
+
const headerDotColor = feature && (getFeatureColor == null ? void 0 : getFeatureColor(feature.id)) || (feature == null ? void 0 : feature.properties.stroke) || "#3b82f6";
|
|
2857
3051
|
const [strokeColor, setStrokeColor] = react.useState("#3b82f6");
|
|
2858
3052
|
const [strokeWidth, setStrokeWidth] = react.useState(2);
|
|
2859
3053
|
const [strokeOpacity, setStrokeOpacity] = react.useState(1);
|
|
@@ -2912,10 +3106,46 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
2912
3106
|
setLatitude("");
|
|
2913
3107
|
}
|
|
2914
3108
|
}
|
|
2915
|
-
const reserved =
|
|
3109
|
+
const reserved = /* @__PURE__ */ new Set([
|
|
3110
|
+
"name",
|
|
3111
|
+
"description",
|
|
3112
|
+
"startDate",
|
|
3113
|
+
"endDate",
|
|
3114
|
+
"stroke",
|
|
3115
|
+
"stroke-width",
|
|
3116
|
+
"stroke-opacity",
|
|
3117
|
+
"fill",
|
|
3118
|
+
"fill-opacity",
|
|
3119
|
+
"kind",
|
|
3120
|
+
"label",
|
|
3121
|
+
"fontSize",
|
|
3122
|
+
"fontColor",
|
|
3123
|
+
"fontWeight",
|
|
3124
|
+
"arrowSize",
|
|
3125
|
+
"circleCenter",
|
|
3126
|
+
"circleRadius",
|
|
3127
|
+
"icon",
|
|
3128
|
+
"iconSize",
|
|
3129
|
+
"pointIcon",
|
|
3130
|
+
"pointIconSize",
|
|
3131
|
+
"entityType",
|
|
3132
|
+
"entity_id",
|
|
3133
|
+
"entity_type",
|
|
3134
|
+
"entity_label",
|
|
3135
|
+
"os_workspace",
|
|
3136
|
+
"workspace",
|
|
3137
|
+
"source_name",
|
|
3138
|
+
"id",
|
|
3139
|
+
"latitude",
|
|
3140
|
+
"longitude",
|
|
3141
|
+
// The marker color is shown via the colored dot in the panel header,
|
|
3142
|
+
// so we don't repeat it as an editable property row.
|
|
3143
|
+
"color"
|
|
3144
|
+
]);
|
|
3145
|
+
const isReservedKey = buildKeyExclusionPredicate(reserved);
|
|
2916
3146
|
const custom = [];
|
|
2917
3147
|
Object.entries(feature.properties).forEach(([key, value]) => {
|
|
2918
|
-
if (!
|
|
3148
|
+
if (!isReservedKey(key) && value !== void 0 && value !== null && !key.startsWith("_") && !key.startsWith("os_") && !key.startsWith("isHidden")) {
|
|
2919
3149
|
custom.push({ key, value: String(value) });
|
|
2920
3150
|
}
|
|
2921
3151
|
});
|
|
@@ -3099,7 +3329,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3099
3329
|
handleRefresh(true);
|
|
3100
3330
|
}, [feature == null ? void 0 : feature.id, isRecord, featureRefreshProvider, feature, handleRefresh]);
|
|
3101
3331
|
const recordProperties = feature ? Object.entries(feature.properties).filter(
|
|
3102
|
-
([key, value]) => !
|
|
3332
|
+
([key, value]) => !isExcludedRecordKey(key) && value !== void 0 && value !== null && !key.startsWith("_") && !key.startsWith("os_") && !key.startsWith("isHidden")
|
|
3103
3333
|
).map(([key, value]) => ({ key, value: String(value) })) : [];
|
|
3104
3334
|
const entityCardsContent = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2 space-y-2", children: entityCardProvider ? selectedFeatures.map((f) => {
|
|
3105
3335
|
const geoFeature = {
|
|
@@ -3116,7 +3346,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3116
3346
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3117
3347
|
"div",
|
|
3118
3348
|
{
|
|
3119
|
-
className: "absolute top-4 right-4 z-10 w-
|
|
3349
|
+
className: "absolute top-4 right-4 z-10 w-80 bg-background/95 floating-panel rounded-lg shadow-lg border border-border",
|
|
3120
3350
|
"data-testid": "panel-properties",
|
|
3121
3351
|
children: [
|
|
3122
3352
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2 px-2.5 py-2 border-b border-border", children: [
|
|
@@ -3152,21 +3382,20 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3152
3382
|
onMoveFeaturesToLayer && /* @__PURE__ */ jsxRuntime.jsx(antd.Dropdown, { menu: { items: buildLayerMenuItems("move") }, trigger: ["click"], placement: "bottomRight", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Tooltip, { title: "Move to layer", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FolderInput, { className: "w-3.5 h-3.5" }), className: "!w-5 !h-5 !min-w-0 !p-0", "data-testid": "button-move-to-layer-prop" }) }) })
|
|
3153
3383
|
] })
|
|
3154
3384
|
] }),
|
|
3155
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-
|
|
3156
|
-
isRecord ? /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { color: "cyan", className: "!text-[
|
|
3157
|
-
isUnsaved && /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { color: "orange", className: "!text-[
|
|
3385
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
3386
|
+
isRecord ? /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { color: "cyan", className: "!text-[12px] !px-2.5 !py-0.5 !leading-5 !m-0 !font-semibold", children: "Octostar record" }) : /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { color: "blue", className: "!text-[12px] !px-2.5 !py-0.5 !leading-5 !m-0 !font-semibold", children: "Local map feature" }),
|
|
3387
|
+
isUnsaved && /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { color: "orange", className: "!text-[12px] !px-2.5 !py-0.5 !leading-5 !border-0 !m-0 !font-semibold", children: "Unsaved" }),
|
|
3158
3388
|
!isRecord && featureSaveProvider && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3159
3389
|
antd.Button,
|
|
3160
3390
|
{
|
|
3161
3391
|
type: "primary",
|
|
3162
|
-
size: "
|
|
3163
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "w-3 h-3" }),
|
|
3392
|
+
size: "middle",
|
|
3393
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "w-3.5 h-3.5" }),
|
|
3164
3394
|
loading: isSaving,
|
|
3165
3395
|
onClick: handleFeatureSave,
|
|
3166
|
-
className: "!h-
|
|
3167
|
-
style: { padding: "1px 6px" },
|
|
3396
|
+
className: "!h-7 !px-3 !text-[12px] !font-medium",
|
|
3168
3397
|
"data-testid": "button-save-feature",
|
|
3169
|
-
children: "Create entity
|
|
3398
|
+
children: "Create entity"
|
|
3170
3399
|
}
|
|
3171
3400
|
)
|
|
3172
3401
|
] })
|
|
@@ -3250,92 +3479,57 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3250
3479
|
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-xs text-muted-foreground", children: "Lat / Lng" }),
|
|
3251
3480
|
feature.geometry.type !== "Point" && /* @__PURE__ */ jsxRuntime.jsx(antd.Tooltip, { title: "Lat and Lng refer to the centroid of this feature", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[13px] text-muted-foreground cursor-help", children: "*" }) })
|
|
3252
3481
|
] }),
|
|
3253
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3482
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3483
|
+
LatLngFields,
|
|
3484
|
+
{
|
|
3485
|
+
latitude,
|
|
3486
|
+
longitude,
|
|
3487
|
+
isEditable: feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer,
|
|
3488
|
+
testIdPrefix: "input-feature",
|
|
3489
|
+
onLatChange: setLatitude,
|
|
3490
|
+
onLngChange: setLongitude,
|
|
3491
|
+
onLatFocus: () => {
|
|
3492
|
+
latInputFocused.current = true;
|
|
3493
|
+
},
|
|
3494
|
+
onLngFocus: () => {
|
|
3495
|
+
lngInputFocused.current = true;
|
|
3496
|
+
},
|
|
3497
|
+
onLatBlur: () => {
|
|
3498
|
+
latInputFocused.current = false;
|
|
3499
|
+
if (feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer && onUpdateGeometry) {
|
|
3500
|
+
const lat = parseFloat(latitude);
|
|
3501
|
+
const lng = parseFloat(longitude);
|
|
3502
|
+
const coords = feature.geometry.coordinates;
|
|
3503
|
+
if (isNaN(lat)) {
|
|
3504
|
+
toast({ title: "Invalid latitude", description: "Please enter a valid number", variant: "destructive" });
|
|
3505
|
+
setLatitude(coords[1].toFixed(6));
|
|
3506
|
+
} else if (lat < -90 || lat > 90) {
|
|
3507
|
+
toast({ title: "Invalid latitude", description: "Latitude must be between -90 and 90", variant: "destructive" });
|
|
3508
|
+
setLatitude(coords[1].toFixed(6));
|
|
3509
|
+
} else if (isNaN(lng) || lng < -180 || lng > 180) ;
|
|
3510
|
+
else {
|
|
3511
|
+
onUpdateGeometry(feature.id, { type: "Point", coordinates: [lng, lat] });
|
|
3281
3512
|
}
|
|
3282
|
-
}
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
"
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
if (feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer && onUpdateGeometry) {
|
|
3300
|
-
const lat = parseFloat(latitude);
|
|
3301
|
-
const lng = parseFloat(longitude);
|
|
3302
|
-
const coords = feature.geometry.coordinates;
|
|
3303
|
-
if (isNaN(lng)) {
|
|
3304
|
-
toast({ title: "Invalid longitude", description: "Please enter a valid number", variant: "destructive" });
|
|
3305
|
-
setLongitude(coords[0].toFixed(6));
|
|
3306
|
-
} else if (lng < -180 || lng > 180) {
|
|
3307
|
-
toast({ title: "Invalid longitude", description: "Longitude must be between -180 and 180", variant: "destructive" });
|
|
3308
|
-
setLongitude(coords[0].toFixed(6));
|
|
3309
|
-
} else if (isNaN(lat) || lat < -90 || lat > 90) ;
|
|
3310
|
-
else {
|
|
3311
|
-
onUpdateGeometry(feature.id, {
|
|
3312
|
-
type: "Point",
|
|
3313
|
-
coordinates: [lng, lat]
|
|
3314
|
-
});
|
|
3315
|
-
}
|
|
3513
|
+
}
|
|
3514
|
+
},
|
|
3515
|
+
onLngBlur: () => {
|
|
3516
|
+
lngInputFocused.current = false;
|
|
3517
|
+
if (feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer && onUpdateGeometry) {
|
|
3518
|
+
const lat = parseFloat(latitude);
|
|
3519
|
+
const lng = parseFloat(longitude);
|
|
3520
|
+
const coords = feature.geometry.coordinates;
|
|
3521
|
+
if (isNaN(lng)) {
|
|
3522
|
+
toast({ title: "Invalid longitude", description: "Please enter a valid number", variant: "destructive" });
|
|
3523
|
+
setLongitude(coords[0].toFixed(6));
|
|
3524
|
+
} else if (lng < -180 || lng > 180) {
|
|
3525
|
+
toast({ title: "Invalid longitude", description: "Longitude must be between -180 and 180", variant: "destructive" });
|
|
3526
|
+
setLongitude(coords[0].toFixed(6));
|
|
3527
|
+
} else if (isNaN(lat) || lat < -90 || lat > 90) ;
|
|
3528
|
+
else {
|
|
3529
|
+
onUpdateGeometry(feature.id, { type: "Point", coordinates: [lng, lat] });
|
|
3316
3530
|
}
|
|
3317
|
-
}
|
|
3318
|
-
placeholder: "Longitude",
|
|
3319
|
-
readOnly: feature.geometry.type !== "Point" || !isEditMode || isReadOnlyLayer,
|
|
3320
|
-
className: "!h-6 text-[13px] flex-1",
|
|
3321
|
-
"data-testid": "input-feature-longitude"
|
|
3531
|
+
}
|
|
3322
3532
|
}
|
|
3323
|
-
)
|
|
3324
|
-
] })
|
|
3325
|
-
] }),
|
|
3326
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
|
|
3327
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "feature-description", className: "text-xs text-muted-foreground", children: "Description" }),
|
|
3328
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3329
|
-
TextArea,
|
|
3330
|
-
{
|
|
3331
|
-
id: "feature-description",
|
|
3332
|
-
value: description,
|
|
3333
|
-
onChange: (e) => setDescription(e.target.value),
|
|
3334
|
-
onBlur: () => handleSave(),
|
|
3335
|
-
placeholder: isEditMode ? "Add description..." : "No description",
|
|
3336
|
-
className: "!min-h-[50px] resize-none text-[13px]",
|
|
3337
|
-
readOnly: !isEditMode,
|
|
3338
|
-
"data-testid": "input-feature-description"
|
|
3339
3533
|
}
|
|
3340
3534
|
)
|
|
3341
3535
|
] }),
|
|
@@ -3351,7 +3545,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3351
3545
|
key: "temporal",
|
|
3352
3546
|
label: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
3353
3547
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Calendar, { className: "w-3 h-3 text-foreground" }),
|
|
3354
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-
|
|
3548
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-bold uppercase tracking-wide text-foreground", children: "Temporal" }),
|
|
3355
3549
|
(startDate || endDate) && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[10px] text-muted-foreground ml-1", children: [
|
|
3356
3550
|
"(",
|
|
3357
3551
|
startDate && endDate ? "2 dates" : "1 date",
|
|
@@ -3438,10 +3632,10 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3438
3632
|
}
|
|
3439
3633
|
),
|
|
3440
3634
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-1.5" }),
|
|
3441
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
3635
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3442
3636
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
3443
3637
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Palette, { className: "w-3 h-3 text-foreground" }),
|
|
3444
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-
|
|
3638
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-bold uppercase tracking-wide text-foreground", children: "Style" })
|
|
3445
3639
|
] }),
|
|
3446
3640
|
feature.properties.kind === "text" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3447
3641
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
@@ -3558,6 +3752,8 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3558
3752
|
disabled: !isEditMode,
|
|
3559
3753
|
size: "small",
|
|
3560
3754
|
showText: false,
|
|
3755
|
+
disabledAlpha: true,
|
|
3756
|
+
panelRender: colorPickerNoHexPanel,
|
|
3561
3757
|
"data-testid": "color-picker-stroke"
|
|
3562
3758
|
}
|
|
3563
3759
|
) }) }),
|
|
@@ -3632,6 +3828,8 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3632
3828
|
disabled: !isEditMode,
|
|
3633
3829
|
size: "small",
|
|
3634
3830
|
showText: false,
|
|
3831
|
+
disabledAlpha: true,
|
|
3832
|
+
panelRender: colorPickerNoHexPanel,
|
|
3635
3833
|
"data-testid": "color-picker-fill"
|
|
3636
3834
|
}
|
|
3637
3835
|
) }) }),
|
|
@@ -3688,49 +3886,67 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3688
3886
|
] })
|
|
3689
3887
|
] }),
|
|
3690
3888
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-1.5" }),
|
|
3691
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
3692
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3889
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3890
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-bold uppercase tracking-wide text-foreground", children: "Properties" }),
|
|
3891
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
3892
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-1", children: [
|
|
3893
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[13px] font-mono text-muted-foreground shrink-0 w-24 px-1 leading-6 select-none", children: "description" }),
|
|
3894
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3895
|
+
TextArea,
|
|
3896
|
+
{
|
|
3897
|
+
id: "feature-description",
|
|
3898
|
+
value: description,
|
|
3899
|
+
onChange: (e) => setDescription(e.target.value),
|
|
3900
|
+
onBlur: () => handleSave(),
|
|
3901
|
+
autoSize: { minRows: 1, maxRows: 5 },
|
|
3902
|
+
placeholder: isEditMode ? "—" : "",
|
|
3903
|
+
readOnly: !isEditMode,
|
|
3904
|
+
className: "flex-1 !text-[13px] !px-1.5 !py-0.5 resize-none",
|
|
3905
|
+
"data-testid": "input-feature-description"
|
|
3906
|
+
}
|
|
3907
|
+
)
|
|
3908
|
+
] }),
|
|
3909
|
+
customProperties.map((prop, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
3910
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3911
|
+
antd.Input,
|
|
3912
|
+
{
|
|
3913
|
+
value: prop.key,
|
|
3914
|
+
onChange: (e) => handlePropertyKeyChange(index, e.target.value),
|
|
3915
|
+
onBlur: () => handleSave(),
|
|
3916
|
+
placeholder: "Key",
|
|
3917
|
+
className: "shrink-0 w-24 text-[13px] font-mono !h-6 !px-1",
|
|
3918
|
+
readOnly: !isEditMode,
|
|
3919
|
+
"data-testid": `input-property-key-${index}`
|
|
3920
|
+
}
|
|
3921
|
+
),
|
|
3922
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3923
|
+
antd.Input,
|
|
3924
|
+
{
|
|
3925
|
+
value: prop.value,
|
|
3926
|
+
onChange: (e) => handlePropertyValueChange(index, e.target.value),
|
|
3927
|
+
onBlur: () => handleSave(),
|
|
3928
|
+
placeholder: "Value",
|
|
3929
|
+
className: "flex-1 text-[13px] !h-6 !px-1.5",
|
|
3930
|
+
readOnly: !isEditMode,
|
|
3931
|
+
"data-testid": `input-property-value-${index}`
|
|
3932
|
+
}
|
|
3933
|
+
),
|
|
3934
|
+
isEditMode && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3935
|
+
"button",
|
|
3936
|
+
{
|
|
3937
|
+
type: "button",
|
|
3938
|
+
onClick: () => {
|
|
3939
|
+
handleRemoveProperty(index);
|
|
3940
|
+
setTimeout(() => handleSave(), 0);
|
|
3941
|
+
},
|
|
3942
|
+
className: "text-destructive shrink-0 h-6 w-6 flex items-center justify-center rounded hover:bg-destructive/10 transition-colors",
|
|
3943
|
+
"data-testid": `button-remove-property-${index}`,
|
|
3944
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "w-3 h-3" })
|
|
3945
|
+
}
|
|
3946
|
+
)
|
|
3947
|
+
] }, index))
|
|
3948
|
+
] }),
|
|
3949
|
+
isEditMode && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 pt-0.5", children: [
|
|
3734
3950
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3735
3951
|
antd.Input,
|
|
3736
3952
|
{
|
|
@@ -3742,8 +3958,8 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3742
3958
|
handleAddProperty();
|
|
3743
3959
|
}
|
|
3744
3960
|
},
|
|
3745
|
-
placeholder: "New property
|
|
3746
|
-
className: "flex-1 text-[13px] !h-
|
|
3961
|
+
placeholder: "New property…",
|
|
3962
|
+
className: "flex-1 text-[13px] !h-6 !px-1.5",
|
|
3747
3963
|
"data-testid": "input-new-property-key"
|
|
3748
3964
|
}
|
|
3749
3965
|
),
|
|
@@ -3753,9 +3969,9 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3753
3969
|
type: "button",
|
|
3754
3970
|
onClick: handleAddProperty,
|
|
3755
3971
|
disabled: !newPropertyKey.trim(),
|
|
3756
|
-
className: "h-
|
|
3972
|
+
className: "h-6 w-6 flex items-center justify-center border border-border rounded disabled:opacity-50 hover:bg-muted transition-colors",
|
|
3757
3973
|
"data-testid": "button-add-property",
|
|
3758
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-
|
|
3974
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-3 h-3" })
|
|
3759
3975
|
}
|
|
3760
3976
|
)
|
|
3761
3977
|
] })
|
|
@@ -3775,7 +3991,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3775
3991
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[12px] text-muted-foreground", children: "Layer:" }),
|
|
3776
3992
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[12px] text-foreground truncate", children: layerName })
|
|
3777
3993
|
] }),
|
|
3778
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-
|
|
3994
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 flex-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { color: "cyan", className: "!text-[12px] !px-2.5 !py-0.5 !leading-5 !m-0 !font-semibold", children: "Octostar record" }) })
|
|
3779
3995
|
] }),
|
|
3780
3996
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-1.5" }),
|
|
3781
3997
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
@@ -3796,93 +4012,73 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3796
4012
|
) })
|
|
3797
4013
|
] }) }),
|
|
3798
4014
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-1.5" }),
|
|
3799
|
-
feature.properties.description && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3800
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
|
|
3801
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-xs text-muted-foreground", children: "Description" }),
|
|
3802
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[13px] text-foreground whitespace-pre-wrap break-words m-0", children: String(feature.properties.description) })
|
|
3803
|
-
] }),
|
|
3804
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-1.5" })
|
|
3805
|
-
] }),
|
|
3806
4015
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
|
|
3807
4016
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
3808
4017
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { className: "w-3 h-3 text-muted-foreground" }),
|
|
3809
4018
|
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-xs text-muted-foreground", children: "Lat / Lng" }),
|
|
3810
4019
|
feature.geometry.type !== "Point" && /* @__PURE__ */ jsxRuntime.jsx(antd.Tooltip, { title: "Lat and Lng refer to the centroid of this feature", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[13px] text-muted-foreground cursor-help", children: "*" }) })
|
|
3811
4020
|
] }),
|
|
3812
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
4021
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4022
|
+
LatLngFields,
|
|
4023
|
+
{
|
|
4024
|
+
latitude,
|
|
4025
|
+
longitude,
|
|
4026
|
+
isEditable: feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer,
|
|
4027
|
+
testIdPrefix: "input-record",
|
|
4028
|
+
onLatChange: setLatitude,
|
|
4029
|
+
onLngChange: setLongitude,
|
|
4030
|
+
onLatFocus: () => {
|
|
4031
|
+
latInputFocused.current = true;
|
|
4032
|
+
},
|
|
4033
|
+
onLngFocus: () => {
|
|
4034
|
+
lngInputFocused.current = true;
|
|
4035
|
+
},
|
|
4036
|
+
onLatBlur: () => {
|
|
4037
|
+
latInputFocused.current = false;
|
|
4038
|
+
if (feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer && onUpdateGeometry) {
|
|
4039
|
+
const lat = parseFloat(latitude);
|
|
4040
|
+
const lng = parseFloat(longitude);
|
|
4041
|
+
const coords = feature.geometry.coordinates;
|
|
4042
|
+
if (isNaN(lat)) {
|
|
4043
|
+
toast({ title: "Invalid latitude", description: "Please enter a valid number", variant: "destructive" });
|
|
4044
|
+
setLatitude(coords[1].toFixed(6));
|
|
4045
|
+
} else if (lat < -90 || lat > 90) {
|
|
4046
|
+
toast({ title: "Invalid latitude", description: "Latitude must be between -90 and 90", variant: "destructive" });
|
|
4047
|
+
setLatitude(coords[1].toFixed(6));
|
|
4048
|
+
} else if (isNaN(lng) || lng < -180 || lng > 180) ;
|
|
4049
|
+
else {
|
|
4050
|
+
onUpdateGeometry(feature.id, { type: "Point", coordinates: [lng, lat] });
|
|
3837
4051
|
}
|
|
3838
|
-
}
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
"
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
if (feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer && onUpdateGeometry) {
|
|
3856
|
-
const lat = parseFloat(latitude);
|
|
3857
|
-
const lng = parseFloat(longitude);
|
|
3858
|
-
const coords = feature.geometry.coordinates;
|
|
3859
|
-
if (isNaN(lng)) {
|
|
3860
|
-
toast({ title: "Invalid longitude", description: "Please enter a valid number", variant: "destructive" });
|
|
3861
|
-
setLongitude(coords[0].toFixed(6));
|
|
3862
|
-
} else if (lng < -180 || lng > 180) {
|
|
3863
|
-
toast({ title: "Invalid longitude", description: "Longitude must be between -180 and 180", variant: "destructive" });
|
|
3864
|
-
setLongitude(coords[0].toFixed(6));
|
|
3865
|
-
} else if (isNaN(lat) || lat < -90 || lat > 90) ;
|
|
3866
|
-
else {
|
|
3867
|
-
onUpdateGeometry(feature.id, { type: "Point", coordinates: [lng, lat] });
|
|
3868
|
-
}
|
|
4052
|
+
}
|
|
4053
|
+
},
|
|
4054
|
+
onLngBlur: () => {
|
|
4055
|
+
lngInputFocused.current = false;
|
|
4056
|
+
if (feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer && onUpdateGeometry) {
|
|
4057
|
+
const lat = parseFloat(latitude);
|
|
4058
|
+
const lng = parseFloat(longitude);
|
|
4059
|
+
const coords = feature.geometry.coordinates;
|
|
4060
|
+
if (isNaN(lng)) {
|
|
4061
|
+
toast({ title: "Invalid longitude", description: "Please enter a valid number", variant: "destructive" });
|
|
4062
|
+
setLongitude(coords[0].toFixed(6));
|
|
4063
|
+
} else if (lng < -180 || lng > 180) {
|
|
4064
|
+
toast({ title: "Invalid longitude", description: "Longitude must be between -180 and 180", variant: "destructive" });
|
|
4065
|
+
setLongitude(coords[0].toFixed(6));
|
|
4066
|
+
} else if (isNaN(lat) || lat < -90 || lat > 90) ;
|
|
4067
|
+
else {
|
|
4068
|
+
onUpdateGeometry(feature.id, { type: "Point", coordinates: [lng, lat] });
|
|
3869
4069
|
}
|
|
3870
|
-
}
|
|
3871
|
-
placeholder: "Longitude",
|
|
3872
|
-
readOnly: feature.geometry.type !== "Point" || !isEditMode || isReadOnlyLayer,
|
|
3873
|
-
className: "!h-6 text-[13px] flex-1",
|
|
3874
|
-
"data-testid": "input-record-longitude"
|
|
4070
|
+
}
|
|
3875
4071
|
}
|
|
3876
|
-
|
|
3877
|
-
|
|
4072
|
+
}
|
|
4073
|
+
)
|
|
3878
4074
|
] }),
|
|
3879
4075
|
recordProperties.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3880
4076
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-1.5" }),
|
|
3881
4077
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
3882
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-
|
|
4078
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-bold uppercase tracking-wide text-foreground", children: "Properties" }),
|
|
3883
4079
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0.5", children: recordProperties.map(({ key, value }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2 py-0.5", children: [
|
|
3884
4080
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] text-muted-foreground shrink-0 pt-px min-w-[80px]", children: formatPropertyKey(key) }),
|
|
3885
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[13px] text-foreground break-
|
|
4081
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[13px] text-foreground whitespace-pre-wrap break-words", children: value })
|
|
3886
4082
|
] }, key)) })
|
|
3887
4083
|
] })
|
|
3888
4084
|
] }),
|
|
@@ -3902,7 +4098,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3902
4098
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3903
4099
|
"div",
|
|
3904
4100
|
{
|
|
3905
|
-
className: "absolute top-4 right-4 z-10 w-
|
|
4101
|
+
className: "absolute top-4 right-4 z-10 w-80 bg-background/95 floating-panel rounded-lg shadow-lg border border-border flex flex-col overflow-hidden",
|
|
3906
4102
|
style: { maxHeight: "calc(100vh - 6rem)" },
|
|
3907
4103
|
"data-testid": "panel-properties",
|
|
3908
4104
|
children: [
|
|
@@ -3971,7 +4167,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3971
4167
|
e.currentTarget.style.borderColor = "transparent";
|
|
3972
4168
|
},
|
|
3973
4169
|
"data-testid": "button-title-icon-picker",
|
|
3974
|
-
children: pointIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xl leading-none", children: pointIcon }) : /* @__PURE__ */ jsxRuntime.jsx(PointColorDot, { color:
|
|
4170
|
+
children: pointIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xl leading-none", children: pointIcon }) : /* @__PURE__ */ jsxRuntime.jsx(PointColorDot, { color: headerDotColor, size: 24 })
|
|
3975
4171
|
}
|
|
3976
4172
|
) }),
|
|
3977
4173
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3988,7 +4184,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3988
4184
|
}
|
|
3989
4185
|
)
|
|
3990
4186
|
] }),
|
|
3991
|
-
!hasMultipleSelection && feature.geometry.type === "Point" && feature.properties.kind !== "text" && !isEditMode && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 w-9 h-9 flex items-center justify-center", children: pointIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xl leading-none", children: pointIcon }) : /* @__PURE__ */ jsxRuntime.jsx(PointColorDot, { color:
|
|
4187
|
+
!hasMultipleSelection && feature.geometry.type === "Point" && feature.properties.kind !== "text" && !isEditMode && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 w-9 h-9 flex items-center justify-center", children: pointIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xl leading-none", children: pointIcon }) : /* @__PURE__ */ jsxRuntime.jsx(PointColorDot, { color: headerDotColor, size: 24 }) }),
|
|
3992
4188
|
!hasMultipleSelection && (feature.geometry.type !== "Point" || feature.properties.kind === "text") && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-primary shrink-0 w-9 h-9 flex items-center justify-center", children: getFeatureTypeIcon(feature.geometry.type, feature.properties.kind, "lg") }),
|
|
3993
4189
|
onDeleteFeatures && /* @__PURE__ */ jsxRuntime.jsx(antd.Tooltip, { title: `Delete ${selectedFeatures.length} feature${selectedFeatures.length > 1 ? "s" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", danger: true, icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "w-4 h-4" }), onClick: onDeleteFeatures, className: "!w-6 !h-6 !min-w-0 !p-0", "data-testid": "button-delete-features" }) }),
|
|
3994
4190
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-4 h-4" }), onClick: onClose, className: "!w-6 !h-6 !min-w-0 !p-0 shrink-0", "data-testid": "button-close-properties" })
|
|
@@ -4035,7 +4231,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
4035
4231
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4036
4232
|
"div",
|
|
4037
4233
|
{
|
|
4038
|
-
className: "absolute top-4 right-4 z-10 w-
|
|
4234
|
+
className: "absolute top-4 right-4 z-10 w-72 bg-background/95 floating-panel rounded-lg shadow-lg border border-border flex flex-col overflow-hidden",
|
|
4039
4235
|
style: { maxHeight: "calc(100vh - 6rem)" },
|
|
4040
4236
|
"data-testid": "panel-properties",
|
|
4041
4237
|
children: [
|
|
@@ -4101,7 +4297,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
4101
4297
|
e.currentTarget.style.borderColor = "transparent";
|
|
4102
4298
|
},
|
|
4103
4299
|
"data-testid": "button-title-icon-picker",
|
|
4104
|
-
children: pointIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xl leading-none", children: pointIcon }) : /* @__PURE__ */ jsxRuntime.jsx(PointColorDot, { color:
|
|
4300
|
+
children: pointIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xl leading-none", children: pointIcon }) : /* @__PURE__ */ jsxRuntime.jsx(PointColorDot, { color: headerDotColor, size: 24 })
|
|
4105
4301
|
}
|
|
4106
4302
|
) }),
|
|
4107
4303
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4118,7 +4314,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
4118
4314
|
}
|
|
4119
4315
|
)
|
|
4120
4316
|
] }),
|
|
4121
|
-
feature.geometry.type === "Point" && feature.properties.kind !== "text" && !isEditMode && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 w-9 h-9 flex items-center justify-center", children: pointIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xl leading-none", children: pointIcon }) : /* @__PURE__ */ jsxRuntime.jsx(PointColorDot, { color:
|
|
4317
|
+
feature.geometry.type === "Point" && feature.properties.kind !== "text" && !isEditMode && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 w-9 h-9 flex items-center justify-center", children: pointIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xl leading-none", children: pointIcon }) : /* @__PURE__ */ jsxRuntime.jsx(PointColorDot, { color: headerDotColor, size: 24 }) }),
|
|
4122
4318
|
(feature.geometry.type !== "Point" || feature.properties.kind === "text") && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-primary shrink-0 w-9 h-9 flex items-center justify-center", children: getFeatureTypeIcon(feature.geometry.type, feature.properties.kind, "lg") }),
|
|
4123
4319
|
onDeleteFeatures && /* @__PURE__ */ jsxRuntime.jsx(antd.Tooltip, { title: "Delete feature", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", danger: true, icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "w-4 h-4" }), onClick: onDeleteFeatures, className: "!w-6 !h-6 !min-w-0 !p-0", "data-testid": "button-delete-features" }) }),
|
|
4124
4320
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-4 h-4" }), onClick: onClose, className: "!w-6 !h-6 !min-w-0 !p-0 shrink-0", "data-testid": "button-close-properties" })
|
|
@@ -4466,12 +4662,11 @@ function formatDateTime(date) {
|
|
|
4466
4662
|
minute: "2-digit"
|
|
4467
4663
|
});
|
|
4468
4664
|
}
|
|
4469
|
-
function Histogram({ bins, maxCount,
|
|
4665
|
+
function Histogram({ bins, maxCount, colorGroupedBins }) {
|
|
4470
4666
|
const [hoveredBin, setHoveredBin] = react.useState(null);
|
|
4471
4667
|
const containerRef = react.useRef(null);
|
|
4472
4668
|
if (bins.length === 0 || maxCount === 0) return null;
|
|
4473
4669
|
const hasColorGroups = colorGroupedBins && colorGroupedBins.length > 0 && colorGroupedBins.some((group) => group.bins.some((count) => count > 0));
|
|
4474
|
-
const hasSelection = !hasColorGroups && selectedBins && selectedBins.length > 0 && selectedBins.some((count) => count > 0);
|
|
4475
4670
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative h-16", ref: containerRef, children: [
|
|
4476
4671
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-end gap-px", children: bins.map((bin, i) => {
|
|
4477
4672
|
const height = bin.count / maxCount * 100;
|
|
@@ -4511,22 +4706,6 @@ function Histogram({ bins, maxCount, selectedBins, colorGroupedBins }) {
|
|
|
4511
4706
|
groupIndex
|
|
4512
4707
|
);
|
|
4513
4708
|
}) }),
|
|
4514
|
-
hasSelection && /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "absolute inset-0 pointer-events-none w-full h-full", viewBox: "0 0 100 100", preserveAspectRatio: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4515
|
-
"polyline",
|
|
4516
|
-
{
|
|
4517
|
-
fill: "none",
|
|
4518
|
-
stroke: "hsl(var(--foreground))",
|
|
4519
|
-
strokeWidth: "1.5",
|
|
4520
|
-
strokeLinejoin: "round",
|
|
4521
|
-
strokeLinecap: "round",
|
|
4522
|
-
vectorEffect: "non-scaling-stroke",
|
|
4523
|
-
points: selectedBins.map((count, i) => {
|
|
4524
|
-
const x = (i + 0.5) * (100 / bins.length);
|
|
4525
|
-
const y = 100 - count / maxCount * 100;
|
|
4526
|
-
return `${x},${y}`;
|
|
4527
|
-
}).join(" ")
|
|
4528
|
-
}
|
|
4529
|
-
) }),
|
|
4530
4709
|
hoveredBin !== null && bins[hoveredBin] && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4531
4710
|
"div",
|
|
4532
4711
|
{
|
|
@@ -4542,12 +4721,7 @@ function Histogram({ bins, maxCount, selectedBins, colorGroupedBins }) {
|
|
|
4542
4721
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-muted-foreground", children: [
|
|
4543
4722
|
bins[hoveredBin].count,
|
|
4544
4723
|
" event",
|
|
4545
|
-
bins[hoveredBin].count !== 1 ? "s" : ""
|
|
4546
|
-
selectedBins && selectedBins[hoveredBin] > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-1 text-foreground font-medium", children: [
|
|
4547
|
-
"(",
|
|
4548
|
-
selectedBins[hoveredBin],
|
|
4549
|
-
" selected)"
|
|
4550
|
-
] })
|
|
4724
|
+
bins[hoveredBin].count !== 1 ? "s" : ""
|
|
4551
4725
|
] })
|
|
4552
4726
|
]
|
|
4553
4727
|
}
|
|
@@ -4579,13 +4753,32 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
4579
4753
|
rangeStart,
|
|
4580
4754
|
rangeEnd,
|
|
4581
4755
|
isPlaying,
|
|
4582
|
-
histogramBins,
|
|
4756
|
+
histogramBins: storeHistogramBins,
|
|
4583
4757
|
setRange,
|
|
4584
4758
|
setPlaying
|
|
4585
4759
|
} = useTimelineStore();
|
|
4586
|
-
const
|
|
4760
|
+
const hasSelection = selectedFeatureIds.length > 0;
|
|
4761
|
+
const selectedTemporalFeatures = react.useMemo(() => {
|
|
4762
|
+
if (!hasSelection) return temporalFeatures;
|
|
4587
4763
|
const selectedSet = new Set(selectedFeatureIds);
|
|
4588
|
-
|
|
4764
|
+
return temporalFeatures.filter((f) => selectedSet.has(f.id));
|
|
4765
|
+
}, [hasSelection, selectedFeatureIds, temporalFeatures]);
|
|
4766
|
+
const histogramBins = react.useMemo(() => {
|
|
4767
|
+
if (!hasSelection || storeHistogramBins.length === 0) return storeHistogramBins;
|
|
4768
|
+
return storeHistogramBins.map((bin, binIndex) => {
|
|
4769
|
+
const isLastBin = binIndex === storeHistogramBins.length - 1;
|
|
4770
|
+
let count = 0;
|
|
4771
|
+
for (const f of selectedTemporalFeatures) {
|
|
4772
|
+
if (!f.startDate) continue;
|
|
4773
|
+
const t = f.startDate.getTime();
|
|
4774
|
+
if (t >= bin.start.getTime() && (isLastBin ? t <= bin.end.getTime() : t < bin.end.getTime())) {
|
|
4775
|
+
count++;
|
|
4776
|
+
}
|
|
4777
|
+
}
|
|
4778
|
+
return { ...bin, count };
|
|
4779
|
+
});
|
|
4780
|
+
}, [hasSelection, storeHistogramBins, selectedTemporalFeatures]);
|
|
4781
|
+
const colorGroupedBins = histogramBins.length > 0 && hasSelection && selectedFeatureColors && selectedFeatureColors.size > 0 && globalMinDate && globalMaxDate ? (() => {
|
|
4589
4782
|
if (selectedTemporalFeatures.length === 0) return [];
|
|
4590
4783
|
const colorGroups = /* @__PURE__ */ new Map();
|
|
4591
4784
|
selectedTemporalFeatures.forEach((f) => {
|
|
@@ -4593,6 +4786,7 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
4593
4786
|
if (!colorGroups.has(color)) colorGroups.set(color, []);
|
|
4594
4787
|
colorGroups.get(color).push(f);
|
|
4595
4788
|
});
|
|
4789
|
+
if (colorGroups.size <= 1) return [];
|
|
4596
4790
|
const result = [];
|
|
4597
4791
|
colorGroups.forEach((features, color) => {
|
|
4598
4792
|
const bins = histogramBins.map((bin, binIndex) => {
|
|
@@ -4609,21 +4803,6 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
4609
4803
|
});
|
|
4610
4804
|
return result;
|
|
4611
4805
|
})() : [];
|
|
4612
|
-
const selectedBins = histogramBins.length > 0 && selectedFeatureIds.length > 0 && (!selectedFeatureColors || selectedFeatureColors.size === 0) && globalMinDate && globalMaxDate ? (() => {
|
|
4613
|
-
const selectedSet = new Set(selectedFeatureIds);
|
|
4614
|
-
const selectedTemporalFeatures = temporalFeatures.filter((f) => selectedSet.has(f.id));
|
|
4615
|
-
if (selectedTemporalFeatures.length === 0) return [];
|
|
4616
|
-
return histogramBins.map((bin, binIndex) => {
|
|
4617
|
-
let count = 0;
|
|
4618
|
-
const isLastBin = binIndex === histogramBins.length - 1;
|
|
4619
|
-
selectedTemporalFeatures.forEach((f) => {
|
|
4620
|
-
if (!f.startDate) return;
|
|
4621
|
-
const t = f.startDate.getTime();
|
|
4622
|
-
if (t >= bin.start.getTime() && (isLastBin ? t <= bin.end.getTime() : t < bin.end.getTime())) count++;
|
|
4623
|
-
});
|
|
4624
|
-
return count;
|
|
4625
|
-
});
|
|
4626
|
-
})() : [];
|
|
4627
4806
|
const animationFrameRef = react.useRef(null);
|
|
4628
4807
|
const lastFrameTimeRef = react.useRef(0);
|
|
4629
4808
|
const playbackDuration = 1e4;
|
|
@@ -4724,7 +4903,6 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
4724
4903
|
{
|
|
4725
4904
|
bins: histogramBins,
|
|
4726
4905
|
maxCount: maxBinCount,
|
|
4727
|
-
selectedBins,
|
|
4728
4906
|
colorGroupedBins
|
|
4729
4907
|
}
|
|
4730
4908
|
),
|
|
@@ -4774,11 +4952,14 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
4774
4952
|
className: "!h-7 !w-7 !p-0 !min-w-0"
|
|
4775
4953
|
}
|
|
4776
4954
|
),
|
|
4777
|
-
/* @__PURE__ */ jsxRuntime.
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4955
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4956
|
+
"span",
|
|
4957
|
+
{
|
|
4958
|
+
className: "text-xs text-muted-foreground ml-1",
|
|
4959
|
+
"data-testid": "text-timeline-feature-count",
|
|
4960
|
+
children: hasSelection ? `${selectedTemporalFeatures.length} of ${temporalFeatures.length} selected` : `${temporalFeatures.length} feature${temporalFeatures.length !== 1 ? "s" : ""}`
|
|
4961
|
+
}
|
|
4962
|
+
)
|
|
4782
4963
|
] }),
|
|
4783
4964
|
timebarExtra,
|
|
4784
4965
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground font-mono", children: [
|
|
@@ -4872,6 +5053,12 @@ function MapDropZone({ onDrop, children }) {
|
|
|
4872
5053
|
}
|
|
4873
5054
|
);
|
|
4874
5055
|
}
|
|
5056
|
+
const OTHER_BUCKET_KEY = "__other__";
|
|
5057
|
+
const OTHER_BUCKET_LABEL = "Other";
|
|
5058
|
+
const OTHER_BUCKET_COLOR = "#9ca3af";
|
|
5059
|
+
function toDisplayName(name) {
|
|
5060
|
+
return name === OTHER_BUCKET_KEY ? OTHER_BUCKET_LABEL : name;
|
|
5061
|
+
}
|
|
4875
5062
|
function createPieSVG(categories, total, size = 44, onSliceHover) {
|
|
4876
5063
|
const container = document.createElement("div");
|
|
4877
5064
|
container.style.width = `${size}px`;
|
|
@@ -4890,8 +5077,41 @@ function createPieSVG(categories, total, size = 44, onSliceHover) {
|
|
|
4890
5077
|
bgCircle.setAttribute("r", String(radius));
|
|
4891
5078
|
bgCircle.setAttribute("fill", "white");
|
|
4892
5079
|
svg.appendChild(bgCircle);
|
|
5080
|
+
const slicesSum = categories.reduce((s, c) => s + c.count, 0);
|
|
5081
|
+
const remainder = Math.max(0, total - slicesSum);
|
|
5082
|
+
const renderList = remainder > 0 ? [...categories, { name: "__remainder__", displayName: "Other", count: remainder, color: OTHER_BUCKET_COLOR }] : categories;
|
|
5083
|
+
const nonZeroSlices = renderList.filter((c) => c.count > 0);
|
|
5084
|
+
const isSingleFullSlice = nonZeroSlices.length === 1 && nonZeroSlices[0].count >= total;
|
|
5085
|
+
if (isSingleFullSlice) {
|
|
5086
|
+
const cat = nonZeroSlices[0];
|
|
5087
|
+
const ring = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
5088
|
+
const d = [
|
|
5089
|
+
`M 0 ${radius}`,
|
|
5090
|
+
`a ${radius} ${radius} 0 1 0 ${radius * 2} 0`,
|
|
5091
|
+
`a ${radius} ${radius} 0 1 0 ${-radius * 2} 0`,
|
|
5092
|
+
`M ${radius - innerRadius} ${radius}`,
|
|
5093
|
+
`a ${innerRadius} ${innerRadius} 0 1 1 ${innerRadius * 2} 0`,
|
|
5094
|
+
`a ${innerRadius} ${innerRadius} 0 1 1 ${-innerRadius * 2} 0`,
|
|
5095
|
+
"Z"
|
|
5096
|
+
].join(" ");
|
|
5097
|
+
ring.setAttribute("d", d);
|
|
5098
|
+
ring.setAttribute("fill-rule", "evenodd");
|
|
5099
|
+
ring.setAttribute("fill", cat.color);
|
|
5100
|
+
ring.setAttribute("stroke", "white");
|
|
5101
|
+
ring.setAttribute("stroke-width", "1");
|
|
5102
|
+
ring.style.transition = "opacity 0.15s";
|
|
5103
|
+
ring.addEventListener("mouseenter", (e) => {
|
|
5104
|
+
ring.style.opacity = "0.8";
|
|
5105
|
+
if (onSliceHover) onSliceHover(cat, e);
|
|
5106
|
+
});
|
|
5107
|
+
ring.addEventListener("mouseleave", (e) => {
|
|
5108
|
+
ring.style.opacity = "1";
|
|
5109
|
+
if (onSliceHover) onSliceHover(null, e);
|
|
5110
|
+
});
|
|
5111
|
+
svg.appendChild(ring);
|
|
5112
|
+
}
|
|
4893
5113
|
let currentAngle = -90;
|
|
4894
|
-
|
|
5114
|
+
(isSingleFullSlice ? [] : renderList).forEach((cat) => {
|
|
4895
5115
|
if (cat.count === 0) return;
|
|
4896
5116
|
const sliceAngle = cat.count / total * 360;
|
|
4897
5117
|
const startAngle = currentAngle;
|
|
@@ -4970,12 +5190,20 @@ function showTooltip(cat, x, y) {
|
|
|
4970
5190
|
`;
|
|
4971
5191
|
document.body.appendChild(tooltipEl);
|
|
4972
5192
|
}
|
|
4973
|
-
tooltipEl.
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
5193
|
+
while (tooltipEl.firstChild) tooltipEl.removeChild(tooltipEl.firstChild);
|
|
5194
|
+
const row = document.createElement("div");
|
|
5195
|
+
row.style.cssText = "display: flex; align-items: center; gap: 6px;";
|
|
5196
|
+
const swatch = document.createElement("span");
|
|
5197
|
+
swatch.style.cssText = "width: 10px; height: 10px; border-radius: 2px;";
|
|
5198
|
+
swatch.style.backgroundColor = cat.color;
|
|
5199
|
+
row.appendChild(swatch);
|
|
5200
|
+
const label = document.createElement("span");
|
|
5201
|
+
const name = document.createElement("strong");
|
|
5202
|
+
name.textContent = cat.displayName;
|
|
5203
|
+
label.appendChild(name);
|
|
5204
|
+
label.appendChild(document.createTextNode(`: ${cat.count}`));
|
|
5205
|
+
row.appendChild(label);
|
|
5206
|
+
tooltipEl.appendChild(row);
|
|
4979
5207
|
tooltipEl.style.left = `${x + 12}px`;
|
|
4980
5208
|
tooltipEl.style.top = `${y - 10}px`;
|
|
4981
5209
|
tooltipEl.style.display = "block";
|
|
@@ -4985,67 +5213,114 @@ function hideTooltip() {
|
|
|
4985
5213
|
tooltipEl.style.display = "none";
|
|
4986
5214
|
}
|
|
4987
5215
|
}
|
|
5216
|
+
function fingerprintCluster(pointCount, counts, size) {
|
|
5217
|
+
return `${size}|${pointCount}|${counts.join(",")}`;
|
|
5218
|
+
}
|
|
5219
|
+
function buildPieElement(categories, pointCount, size, source, clusterId, map, coords) {
|
|
5220
|
+
const el = createPieSVG(categories, pointCount, size, (cat, event) => {
|
|
5221
|
+
if (cat) {
|
|
5222
|
+
showTooltip(cat, event.clientX, event.clientY);
|
|
5223
|
+
} else {
|
|
5224
|
+
hideTooltip();
|
|
5225
|
+
}
|
|
5226
|
+
});
|
|
5227
|
+
el.addEventListener("click", () => {
|
|
5228
|
+
source.getClusterExpansionZoom(clusterId).then((zoom) => {
|
|
5229
|
+
if (typeof zoom === "number") {
|
|
5230
|
+
map.easeTo({ center: coords, zoom: zoom + 0.5 });
|
|
5231
|
+
}
|
|
5232
|
+
}).catch(() => {
|
|
5233
|
+
});
|
|
5234
|
+
});
|
|
5235
|
+
return el;
|
|
5236
|
+
}
|
|
5237
|
+
function renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers) {
|
|
5238
|
+
const source = map.getSource(sourceId);
|
|
5239
|
+
if (!source) return;
|
|
5240
|
+
const clusters = map.querySourceFeatures(sourceId, {
|
|
5241
|
+
filter: ["has", "point_count"]
|
|
5242
|
+
});
|
|
5243
|
+
const visibleClusterIds = /* @__PURE__ */ new Set();
|
|
5244
|
+
clusters.forEach((feature) => {
|
|
5245
|
+
var _a, _b;
|
|
5246
|
+
const clusterId = (_a = feature.properties) == null ? void 0 : _a.cluster_id;
|
|
5247
|
+
if (clusterId === void 0) return;
|
|
5248
|
+
const clusterKey = `${clusterId}`;
|
|
5249
|
+
visibleClusterIds.add(clusterKey);
|
|
5250
|
+
const coords = feature.geometry.coordinates;
|
|
5251
|
+
const pointCount = ((_b = feature.properties) == null ? void 0 : _b.point_count) || 0;
|
|
5252
|
+
const allCounts = categoryValues.map((_, i) => {
|
|
5253
|
+
var _a2;
|
|
5254
|
+
return Number(((_a2 = feature.properties) == null ? void 0 : _a2[`cat_${i}`]) || 0);
|
|
5255
|
+
});
|
|
5256
|
+
const categories = categoryValues.map((cat, i) => ({
|
|
5257
|
+
name: cat,
|
|
5258
|
+
displayName: toDisplayName(cat),
|
|
5259
|
+
count: allCounts[i],
|
|
5260
|
+
color: categoryColorMap[cat] || "#3b82f6"
|
|
5261
|
+
})).filter((c) => c.count > 0);
|
|
5262
|
+
const size = pointCount < 100 ? 40 : pointCount < 750 ? 50 : 60;
|
|
5263
|
+
const fingerprint = fingerprintCluster(pointCount, allCounts, size);
|
|
5264
|
+
const existing = markers.get(clusterKey);
|
|
5265
|
+
if (existing && existing.fingerprint === fingerprint) {
|
|
5266
|
+
existing.marker.setLngLat(coords);
|
|
5267
|
+
return;
|
|
5268
|
+
}
|
|
5269
|
+
const el = buildPieElement(categories, pointCount, size, source, clusterId, map, coords);
|
|
5270
|
+
if (existing) {
|
|
5271
|
+
existing.marker.remove();
|
|
5272
|
+
}
|
|
5273
|
+
const marker = new maplibregl.Marker({ element: el }).setLngLat(coords).addTo(map);
|
|
5274
|
+
markers.set(clusterKey, { marker, fingerprint });
|
|
5275
|
+
});
|
|
5276
|
+
markers.forEach((entry, key) => {
|
|
5277
|
+
if (!visibleClusterIds.has(key)) {
|
|
5278
|
+
entry.marker.remove();
|
|
5279
|
+
markers.delete(key);
|
|
5280
|
+
}
|
|
5281
|
+
});
|
|
5282
|
+
}
|
|
5283
|
+
function createClusterPieManager(map, sourceId, categoryValues, categoryColorMap) {
|
|
5284
|
+
const markers = /* @__PURE__ */ new Map();
|
|
5285
|
+
let updateScheduled = false;
|
|
5286
|
+
function scheduleUpdate() {
|
|
5287
|
+
if (updateScheduled) return;
|
|
5288
|
+
updateScheduled = true;
|
|
5289
|
+
requestAnimationFrame(() => {
|
|
5290
|
+
updateScheduled = false;
|
|
5291
|
+
renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers);
|
|
5292
|
+
});
|
|
5293
|
+
}
|
|
5294
|
+
function onData(e) {
|
|
5295
|
+
if (e.sourceId === sourceId) {
|
|
5296
|
+
scheduleUpdate();
|
|
5297
|
+
}
|
|
5298
|
+
}
|
|
5299
|
+
map.on("moveend", scheduleUpdate);
|
|
5300
|
+
map.on("data", onData);
|
|
5301
|
+
scheduleUpdate();
|
|
5302
|
+
return {
|
|
5303
|
+
update: scheduleUpdate,
|
|
5304
|
+
destroy: () => {
|
|
5305
|
+
map.off("moveend", scheduleUpdate);
|
|
5306
|
+
map.off("data", onData);
|
|
5307
|
+
markers.forEach((entry) => entry.marker.remove());
|
|
5308
|
+
markers.clear();
|
|
5309
|
+
hideTooltip();
|
|
5310
|
+
}
|
|
5311
|
+
};
|
|
5312
|
+
}
|
|
4988
5313
|
function ClusterPieManager(props) {
|
|
4989
|
-
const { map, sourceId,
|
|
5314
|
+
const { map, sourceId, categoryValues, categoryColorMap, visible } = props;
|
|
4990
5315
|
const markersRef = react.useRef(/* @__PURE__ */ new Map());
|
|
4991
5316
|
const updateScheduled = react.useRef(false);
|
|
4992
5317
|
const updateMarkers = react.useCallback(() => {
|
|
4993
5318
|
if (!map || !visible) {
|
|
4994
|
-
markersRef.current.forEach((
|
|
5319
|
+
markersRef.current.forEach((entry) => entry.marker.remove());
|
|
4995
5320
|
markersRef.current.clear();
|
|
4996
5321
|
return;
|
|
4997
5322
|
}
|
|
4998
|
-
|
|
4999
|
-
if (!source) return;
|
|
5000
|
-
const clusters = map.querySourceFeatures(sourceId, {
|
|
5001
|
-
filter: ["has", "point_count"]
|
|
5002
|
-
});
|
|
5003
|
-
const visibleClusterIds = /* @__PURE__ */ new Set();
|
|
5004
|
-
clusters.forEach((feature) => {
|
|
5005
|
-
var _a, _b;
|
|
5006
|
-
const clusterId = (_a = feature.properties) == null ? void 0 : _a.cluster_id;
|
|
5007
|
-
if (clusterId === void 0) return;
|
|
5008
|
-
const clusterKey = `${clusterId}`;
|
|
5009
|
-
visibleClusterIds.add(clusterKey);
|
|
5010
|
-
const coords = feature.geometry.coordinates;
|
|
5011
|
-
const pointCount = ((_b = feature.properties) == null ? void 0 : _b.point_count) || 0;
|
|
5012
|
-
const categories = categoryValues.map((cat, i) => {
|
|
5013
|
-
var _a2;
|
|
5014
|
-
return {
|
|
5015
|
-
name: cat,
|
|
5016
|
-
count: ((_a2 = feature.properties) == null ? void 0 : _a2[`cat_${i}`]) || 0,
|
|
5017
|
-
color: categoryColorMap[cat] || "#3b82f6"
|
|
5018
|
-
};
|
|
5019
|
-
}).filter((c) => c.count > 0);
|
|
5020
|
-
const size = pointCount < 100 ? 40 : pointCount < 750 ? 50 : 60;
|
|
5021
|
-
const existingMarker = markersRef.current.get(clusterKey);
|
|
5022
|
-
if (existingMarker) {
|
|
5023
|
-
existingMarker.setLngLat(coords);
|
|
5024
|
-
} else {
|
|
5025
|
-
const el = createPieSVG(categories, pointCount, size, (cat, event) => {
|
|
5026
|
-
if (cat) {
|
|
5027
|
-
showTooltip(cat, event.clientX, event.clientY);
|
|
5028
|
-
} else {
|
|
5029
|
-
hideTooltip();
|
|
5030
|
-
}
|
|
5031
|
-
});
|
|
5032
|
-
el.addEventListener("click", () => {
|
|
5033
|
-
source.getClusterExpansionZoom(clusterId, (err, zoom) => {
|
|
5034
|
-
if (!err) {
|
|
5035
|
-
map.easeTo({ center: coords, zoom: zoom + 0.5 });
|
|
5036
|
-
}
|
|
5037
|
-
});
|
|
5038
|
-
});
|
|
5039
|
-
const marker = new maplibregl.Marker({ element: el }).setLngLat(coords).addTo(map);
|
|
5040
|
-
markersRef.current.set(clusterKey, marker);
|
|
5041
|
-
}
|
|
5042
|
-
});
|
|
5043
|
-
markersRef.current.forEach((marker, key) => {
|
|
5044
|
-
if (!visibleClusterIds.has(key)) {
|
|
5045
|
-
marker.remove();
|
|
5046
|
-
markersRef.current.delete(key);
|
|
5047
|
-
}
|
|
5048
|
-
});
|
|
5323
|
+
renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markersRef.current);
|
|
5049
5324
|
}, [map, sourceId, categoryValues, categoryColorMap, visible]);
|
|
5050
5325
|
react.useEffect(() => {
|
|
5051
5326
|
if (!map) return;
|
|
@@ -5057,23 +5332,25 @@ function ClusterPieManager(props) {
|
|
|
5057
5332
|
updateMarkers();
|
|
5058
5333
|
});
|
|
5059
5334
|
};
|
|
5060
|
-
|
|
5061
|
-
map.on("moveend", scheduleUpdate);
|
|
5062
|
-
map.on("data", (e) => {
|
|
5335
|
+
const onData = (e) => {
|
|
5063
5336
|
if (e.sourceId === sourceId) {
|
|
5064
5337
|
scheduleUpdate();
|
|
5065
5338
|
}
|
|
5066
|
-
}
|
|
5339
|
+
};
|
|
5340
|
+
scheduleUpdate();
|
|
5341
|
+
map.on("moveend", scheduleUpdate);
|
|
5342
|
+
map.on("data", onData);
|
|
5067
5343
|
return () => {
|
|
5068
5344
|
map.off("moveend", scheduleUpdate);
|
|
5069
|
-
|
|
5345
|
+
map.off("data", onData);
|
|
5346
|
+
markersRef.current.forEach((entry) => entry.marker.remove());
|
|
5070
5347
|
markersRef.current.clear();
|
|
5071
5348
|
hideTooltip();
|
|
5072
5349
|
};
|
|
5073
5350
|
}, [map, sourceId, updateMarkers]);
|
|
5074
5351
|
react.useEffect(() => {
|
|
5075
5352
|
if (!visible) {
|
|
5076
|
-
markersRef.current.forEach((
|
|
5353
|
+
markersRef.current.forEach((entry) => entry.marker.remove());
|
|
5077
5354
|
markersRef.current.clear();
|
|
5078
5355
|
hideTooltip();
|
|
5079
5356
|
} else {
|
|
@@ -5082,89 +5359,6 @@ function ClusterPieManager(props) {
|
|
|
5082
5359
|
}, [visible, updateMarkers]);
|
|
5083
5360
|
return null;
|
|
5084
5361
|
}
|
|
5085
|
-
function createClusterPieManager(map, sourceId, categoryValues, categoryColorMap) {
|
|
5086
|
-
const markers = /* @__PURE__ */ new Map();
|
|
5087
|
-
let updateScheduled = false;
|
|
5088
|
-
function update() {
|
|
5089
|
-
const source = map.getSource(sourceId);
|
|
5090
|
-
if (!source) return;
|
|
5091
|
-
const clusters = map.querySourceFeatures(sourceId, {
|
|
5092
|
-
filter: ["has", "point_count"]
|
|
5093
|
-
});
|
|
5094
|
-
const visibleClusterIds = /* @__PURE__ */ new Set();
|
|
5095
|
-
clusters.forEach((feature) => {
|
|
5096
|
-
var _a, _b;
|
|
5097
|
-
const clusterId = (_a = feature.properties) == null ? void 0 : _a.cluster_id;
|
|
5098
|
-
if (clusterId === void 0) return;
|
|
5099
|
-
const clusterKey = `${clusterId}`;
|
|
5100
|
-
visibleClusterIds.add(clusterKey);
|
|
5101
|
-
const coords = feature.geometry.coordinates;
|
|
5102
|
-
const pointCount = ((_b = feature.properties) == null ? void 0 : _b.point_count) || 0;
|
|
5103
|
-
const categories = categoryValues.map((cat, i) => {
|
|
5104
|
-
var _a2;
|
|
5105
|
-
return {
|
|
5106
|
-
name: cat,
|
|
5107
|
-
count: ((_a2 = feature.properties) == null ? void 0 : _a2[`cat_${i}`]) || 0,
|
|
5108
|
-
color: categoryColorMap[cat] || "#3b82f6"
|
|
5109
|
-
};
|
|
5110
|
-
}).filter((c) => c.count > 0);
|
|
5111
|
-
const size = pointCount < 100 ? 40 : pointCount < 750 ? 50 : 60;
|
|
5112
|
-
const existingMarker = markers.get(clusterKey);
|
|
5113
|
-
if (existingMarker) {
|
|
5114
|
-
existingMarker.setLngLat(coords);
|
|
5115
|
-
} else {
|
|
5116
|
-
const el = createPieSVG(categories, pointCount, size, (cat, event) => {
|
|
5117
|
-
if (cat) {
|
|
5118
|
-
showTooltip(cat, event.clientX, event.clientY);
|
|
5119
|
-
} else {
|
|
5120
|
-
hideTooltip();
|
|
5121
|
-
}
|
|
5122
|
-
});
|
|
5123
|
-
el.addEventListener("click", () => {
|
|
5124
|
-
source.getClusterExpansionZoom(clusterId, (err, zoom) => {
|
|
5125
|
-
if (!err) {
|
|
5126
|
-
map.easeTo({ center: coords, zoom: zoom + 0.5 });
|
|
5127
|
-
}
|
|
5128
|
-
});
|
|
5129
|
-
});
|
|
5130
|
-
const marker = new maplibregl.Marker({ element: el }).setLngLat(coords).addTo(map);
|
|
5131
|
-
markers.set(clusterKey, marker);
|
|
5132
|
-
}
|
|
5133
|
-
});
|
|
5134
|
-
markers.forEach((marker, key) => {
|
|
5135
|
-
if (!visibleClusterIds.has(key)) {
|
|
5136
|
-
marker.remove();
|
|
5137
|
-
markers.delete(key);
|
|
5138
|
-
}
|
|
5139
|
-
});
|
|
5140
|
-
}
|
|
5141
|
-
function scheduleUpdate() {
|
|
5142
|
-
if (updateScheduled) return;
|
|
5143
|
-
updateScheduled = true;
|
|
5144
|
-
requestAnimationFrame(() => {
|
|
5145
|
-
updateScheduled = false;
|
|
5146
|
-
update();
|
|
5147
|
-
});
|
|
5148
|
-
}
|
|
5149
|
-
function onData(e) {
|
|
5150
|
-
if (e.sourceId === sourceId) {
|
|
5151
|
-
scheduleUpdate();
|
|
5152
|
-
}
|
|
5153
|
-
}
|
|
5154
|
-
map.on("moveend", scheduleUpdate);
|
|
5155
|
-
map.on("data", onData);
|
|
5156
|
-
scheduleUpdate();
|
|
5157
|
-
return {
|
|
5158
|
-
update: scheduleUpdate,
|
|
5159
|
-
destroy: () => {
|
|
5160
|
-
map.off("moveend", scheduleUpdate);
|
|
5161
|
-
map.off("data", onData);
|
|
5162
|
-
markers.forEach((marker) => marker.remove());
|
|
5163
|
-
markers.clear();
|
|
5164
|
-
hideTooltip();
|
|
5165
|
-
}
|
|
5166
|
-
};
|
|
5167
|
-
}
|
|
5168
5362
|
proj4.defs("EPSG:27700", "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
|
|
5169
5363
|
proj4.defs("EPSG:3857", "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs");
|
|
5170
5364
|
proj4.defs("EPSG:32630", "+proj=utm +zone=30 +datum=WGS84 +units=m +no_defs");
|
|
@@ -5571,6 +5765,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
5571
5765
|
enableProperties = true,
|
|
5572
5766
|
toastProvider,
|
|
5573
5767
|
customGlobalMenuItems,
|
|
5768
|
+
extraLayerToolbarButtons,
|
|
5574
5769
|
layerBadgeProvider,
|
|
5575
5770
|
featureCountProvider,
|
|
5576
5771
|
fitBoundsProvider,
|
|
@@ -5653,6 +5848,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
5653
5848
|
const [cursorCoords, setCursorCoords] = react.useState(null);
|
|
5654
5849
|
const [contextMenu, setContextMenu] = react.useState(null);
|
|
5655
5850
|
const timelineStore = useTimelineStore();
|
|
5851
|
+
react.useEffect(() => () => useTimelineStore.getState().reset(), []);
|
|
5656
5852
|
const { toast: internalToast } = useToast();
|
|
5657
5853
|
const toast = toastProvider ?? internalToast;
|
|
5658
5854
|
react.useEffect(() => {
|
|
@@ -5829,56 +6025,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
5829
6025
|
const timelineVisibleIdsRef = react.useRef(null);
|
|
5830
6026
|
const syncRef = react.useRef(() => {
|
|
5831
6027
|
});
|
|
5832
|
-
const hashStringToColor = react.useCallback((str) =>
|
|
5833
|
-
const palette = [
|
|
5834
|
-
"#4e79a7",
|
|
5835
|
-
// steel blue
|
|
5836
|
-
"#f28e2b",
|
|
5837
|
-
// orange
|
|
5838
|
-
"#e15759",
|
|
5839
|
-
// red
|
|
5840
|
-
"#76b7b2",
|
|
5841
|
-
// teal
|
|
5842
|
-
"#59a14f",
|
|
5843
|
-
// green
|
|
5844
|
-
"#edc948",
|
|
5845
|
-
// yellow
|
|
5846
|
-
"#b07aa1",
|
|
5847
|
-
// purple
|
|
5848
|
-
"#ff9da7",
|
|
5849
|
-
// pink
|
|
5850
|
-
"#9c755f",
|
|
5851
|
-
// brown
|
|
5852
|
-
"#bab0ac",
|
|
5853
|
-
// gray
|
|
5854
|
-
"#5fa2ce",
|
|
5855
|
-
// light blue
|
|
5856
|
-
"#ffbe7d",
|
|
5857
|
-
// light orange
|
|
5858
|
-
"#ff9888",
|
|
5859
|
-
// salmon
|
|
5860
|
-
"#8cd17d",
|
|
5861
|
-
// light green
|
|
5862
|
-
"#b6992d",
|
|
5863
|
-
// olive
|
|
5864
|
-
"#f1ce63",
|
|
5865
|
-
// gold
|
|
5866
|
-
"#d4a6c8",
|
|
5867
|
-
// lavender
|
|
5868
|
-
"#86bcb6",
|
|
5869
|
-
// aqua
|
|
5870
|
-
"#d37295",
|
|
5871
|
-
// rose
|
|
5872
|
-
"#499894"
|
|
5873
|
-
// dark teal
|
|
5874
|
-
];
|
|
5875
|
-
let hash = 0;
|
|
5876
|
-
for (let i = 0; i < str.length; i++) {
|
|
5877
|
-
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
5878
|
-
hash = hash & hash;
|
|
5879
|
-
}
|
|
5880
|
-
return palette[Math.abs(hash) % palette.length];
|
|
5881
|
-
}, []);
|
|
6028
|
+
const hashStringToColor$1 = react.useCallback((str) => hashStringToColor(str), []);
|
|
5882
6029
|
const selectedFeatureColors = react.useMemo(() => {
|
|
5883
6030
|
if (selectedFeatureIds.length === 0) return /* @__PURE__ */ new Map();
|
|
5884
6031
|
const colorMap = /* @__PURE__ */ new Map();
|
|
@@ -5936,16 +6083,16 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
5936
6083
|
if (colorConfig.mode === "fixed" && colorConfig.fixedColor) {
|
|
5937
6084
|
color = colorConfig.fixedColor;
|
|
5938
6085
|
} else if (colorConfig.mode === "field" && colorConfig.fieldName && feature.properties) {
|
|
5939
|
-
const
|
|
5940
|
-
if (
|
|
5941
|
-
color = hashStringToColor(
|
|
6086
|
+
const key = categoricalKey(feature.properties[colorConfig.fieldName]);
|
|
6087
|
+
if (key !== null) {
|
|
6088
|
+
color = hashStringToColor$1(key);
|
|
5942
6089
|
}
|
|
5943
6090
|
}
|
|
5944
6091
|
}
|
|
5945
6092
|
colorMap.set(fid, color);
|
|
5946
6093
|
});
|
|
5947
6094
|
return colorMap;
|
|
5948
|
-
}, [selectedFeatureIds, layers, getAllFeatures, hashStringToColor]);
|
|
6095
|
+
}, [selectedFeatureIds, layers, getAllFeatures, hashStringToColor$1]);
|
|
5949
6096
|
const isSyncingRef = react.useRef(false);
|
|
5950
6097
|
const syncFeaturesToCustomLayers = react.useCallback(() => {
|
|
5951
6098
|
if (!map.current) return;
|
|
@@ -6065,7 +6212,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6065
6212
|
const sourceData = {
|
|
6066
6213
|
type: "FeatureCollection",
|
|
6067
6214
|
features: allFeatures.map((f) => {
|
|
6068
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l
|
|
6215
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
6069
6216
|
const featureId = String(f.id);
|
|
6070
6217
|
const layer = featureToLayer.get(featureId);
|
|
6071
6218
|
const visualConfig = layer == null ? void 0 : layer.visualConfig;
|
|
@@ -6077,9 +6224,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6077
6224
|
if (colorConfig.mode === "fixed" && colorConfig.fixedColor) {
|
|
6078
6225
|
strokeColor = colorConfig.fixedColor;
|
|
6079
6226
|
} else if (colorConfig.mode === "field" && colorConfig.fieldName && f.properties) {
|
|
6080
|
-
const
|
|
6081
|
-
if (
|
|
6082
|
-
strokeColor = hashStringToColor(
|
|
6227
|
+
const key = categoricalKey(f.properties[colorConfig.fieldName]);
|
|
6228
|
+
if (key !== null) {
|
|
6229
|
+
strokeColor = hashStringToColor$1(key);
|
|
6083
6230
|
}
|
|
6084
6231
|
}
|
|
6085
6232
|
}
|
|
@@ -6137,8 +6284,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6137
6284
|
featureIconSize = iconConfig.size ?? 24;
|
|
6138
6285
|
}
|
|
6139
6286
|
const isPoint = f.geometry.type === "Point";
|
|
6140
|
-
const hideByHeatmap = isPoint && ((_i = layer == null ? void 0 : layer.heatmapConfig) == null ? void 0 : _i.enabled)
|
|
6141
|
-
const hideByCluster = isPoint && ((
|
|
6287
|
+
const hideByHeatmap = isPoint && ((_i = layer == null ? void 0 : layer.heatmapConfig) == null ? void 0 : _i.enabled) === true;
|
|
6288
|
+
const hideByCluster = isPoint && ((_j = layer == null ? void 0 : layer.clusterConfig) == null ? void 0 : _j.enabled) === true && !((_k = layer == null ? void 0 : layer.clusterConfig) == null ? void 0 : _k.showPointDots);
|
|
6142
6289
|
const isSelected = selectedIds.includes(featureId);
|
|
6143
6290
|
const hideByTrace = false;
|
|
6144
6291
|
const isLine = f.geometry.type === "LineString" || f.geometry.type === "MultiLineString";
|
|
@@ -6169,7 +6316,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6169
6316
|
id: featureId,
|
|
6170
6317
|
name: labelText,
|
|
6171
6318
|
isSelected: isFeatureSelected,
|
|
6172
|
-
isHiddenByHeatmap: hideByHeatmap ?
|
|
6319
|
+
isHiddenByHeatmap: hideByHeatmap ? 1 : 0,
|
|
6173
6320
|
isHiddenByCluster: hideByCluster ? 1 : 0,
|
|
6174
6321
|
isHiddenByTrace: hideByTrace ? true : false,
|
|
6175
6322
|
isTracePoint: isTracePoint ? true : false,
|
|
@@ -6180,7 +6327,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6180
6327
|
"stroke-width": strokeWidth,
|
|
6181
6328
|
"stroke-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? baseOpacity : 0,
|
|
6182
6329
|
fill: strokeColor,
|
|
6183
|
-
"fill-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? ((
|
|
6330
|
+
"fill-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? ((_l = f.properties) == null ? void 0 : _l["fill-opacity"]) ?? 0.2 : 0,
|
|
6184
6331
|
pointRadius,
|
|
6185
6332
|
isHiddenFor3DOnly: hideFlatFor3DOnly ? 1 : 0,
|
|
6186
6333
|
isTimelineHidden: isTimelineVisible ? 0 : 1
|
|
@@ -6406,7 +6553,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6406
6553
|
} finally {
|
|
6407
6554
|
isSyncingRef.current = false;
|
|
6408
6555
|
}
|
|
6409
|
-
}, [layers, hashStringToColor, autoLabelConfig]);
|
|
6556
|
+
}, [layers, hashStringToColor$1, autoLabelConfig]);
|
|
6410
6557
|
const update3DFlightPaths = react.useCallback(() => {
|
|
6411
6558
|
if (!map.current || !is3DTerrainEnabled) {
|
|
6412
6559
|
if (map.current && flightPath3DLayerId.current) {
|
|
@@ -6566,8 +6713,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6566
6713
|
attributionControl: false,
|
|
6567
6714
|
boxZoom: false,
|
|
6568
6715
|
// Disable default box zoom - we use shift+drag for selection instead
|
|
6569
|
-
maxPitch: 80
|
|
6716
|
+
maxPitch: 80,
|
|
6570
6717
|
// Allow steep camera angles for 3D terrain viewing
|
|
6718
|
+
// Required for `getCanvas().toDataURL()` (used by `captureScreenshot()`
|
|
6719
|
+
// on the imperative handle) to return a populated image instead of a
|
|
6720
|
+
// blank one. In maplibre-gl v5 this lives under
|
|
6721
|
+
// `canvasContextAttributes`, not at the top level. Modern desktop GPUs
|
|
6722
|
+
// absorb the small extra cost without measurable impact on this
|
|
6723
|
+
// editor-grade map.
|
|
6724
|
+
canvasContextAttributes: { preserveDrawingBuffer: true }
|
|
6571
6725
|
});
|
|
6572
6726
|
const attrCtrl = new maplibregl.AttributionControl({
|
|
6573
6727
|
compact: true,
|
|
@@ -6674,6 +6828,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6674
6828
|
0,
|
|
6675
6829
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
6676
6830
|
0,
|
|
6831
|
+
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
6832
|
+
0,
|
|
6677
6833
|
["!=", ["get", "icon"], ""],
|
|
6678
6834
|
0,
|
|
6679
6835
|
["+", ["coalesce", ["get", "pointRadius"], 5], 1.5]
|
|
@@ -6683,6 +6839,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6683
6839
|
"case",
|
|
6684
6840
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
6685
6841
|
0,
|
|
6842
|
+
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
6843
|
+
0,
|
|
6686
6844
|
["!=", ["get", "icon"], ""],
|
|
6687
6845
|
0,
|
|
6688
6846
|
["coalesce", ["get", "stroke-opacity"], 1]
|
|
@@ -6703,6 +6861,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6703
6861
|
0,
|
|
6704
6862
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
6705
6863
|
0,
|
|
6864
|
+
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
6865
|
+
0,
|
|
6706
6866
|
["!=", ["get", "icon"], ""],
|
|
6707
6867
|
0,
|
|
6708
6868
|
["coalesce", ["get", "pointRadius"], 5]
|
|
@@ -6711,6 +6871,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6711
6871
|
"case",
|
|
6712
6872
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
6713
6873
|
0,
|
|
6874
|
+
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
6875
|
+
0,
|
|
6714
6876
|
["!=", ["get", "icon"], ""],
|
|
6715
6877
|
0,
|
|
6716
6878
|
["coalesce", ["get", "stroke-opacity"], 1]
|
|
@@ -6722,6 +6884,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6722
6884
|
0,
|
|
6723
6885
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
6724
6886
|
0,
|
|
6887
|
+
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
6888
|
+
0,
|
|
6725
6889
|
["!=", ["get", "icon"], ""],
|
|
6726
6890
|
0,
|
|
6727
6891
|
["==", ["get", "isSelected"], 1],
|
|
@@ -6732,6 +6896,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6732
6896
|
"case",
|
|
6733
6897
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
6734
6898
|
0,
|
|
6899
|
+
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
6900
|
+
0,
|
|
6735
6901
|
["!=", ["get", "icon"], ""],
|
|
6736
6902
|
0,
|
|
6737
6903
|
1
|
|
@@ -6754,6 +6920,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6754
6920
|
"case",
|
|
6755
6921
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
6756
6922
|
0,
|
|
6923
|
+
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
6924
|
+
0,
|
|
6757
6925
|
["coalesce", ["get", "stroke-opacity"], 1]
|
|
6758
6926
|
]
|
|
6759
6927
|
}
|
|
@@ -6762,7 +6930,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6762
6930
|
id: "custom-point-icon-selection",
|
|
6763
6931
|
type: "circle",
|
|
6764
6932
|
source: "custom-features",
|
|
6765
|
-
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["==", "isSelected", 1]],
|
|
6933
|
+
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["==", "isSelected", 1], ["!=", "isHiddenByHeatmap", 1]],
|
|
6766
6934
|
paint: {
|
|
6767
6935
|
"circle-color": "transparent",
|
|
6768
6936
|
"circle-radius": ["/", ["coalesce", ["get", "iconSize"], 24], 1.6],
|
|
@@ -6804,6 +6972,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6804
6972
|
"case",
|
|
6805
6973
|
["==", ["get", "isHiddenByTrace"], true],
|
|
6806
6974
|
"",
|
|
6975
|
+
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
6976
|
+
"",
|
|
6977
|
+
["==", ["get", "isHiddenByCluster"], 1],
|
|
6978
|
+
"",
|
|
6807
6979
|
["==", ["get", "kind"], "arrow"],
|
|
6808
6980
|
"",
|
|
6809
6981
|
// Arrows use custom-arrow-labels layer
|
|
@@ -6826,7 +6998,26 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6826
6998
|
// Text features: center anchor; others: top anchor
|
|
6827
6999
|
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
6828
7000
|
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
6829
|
-
|
|
7001
|
+
// Collision behaviour for entity labels.
|
|
7002
|
+
//
|
|
7003
|
+
// `kind === 'text'` features are sticky-note style annotations
|
|
7004
|
+
// where the text IS the content (this layer has no icon-image,
|
|
7005
|
+
// and `text-optional` cannot fall back to anything). If we let
|
|
7006
|
+
// collision detection hide them, the user is left with a tiny
|
|
7007
|
+
// 5px circle and no visible note. Same for trace endpoint
|
|
7008
|
+
// labels — the label IS the meaningful marker.
|
|
7009
|
+
//
|
|
7010
|
+
// Plain entity-name labels are supplementary to the icon/dot,
|
|
7011
|
+
// so it's safe to let MapLibre thin them out in dense areas
|
|
7012
|
+
// (this is the "no more black mass of stacked labels" win).
|
|
7013
|
+
"text-allow-overlap": [
|
|
7014
|
+
"case",
|
|
7015
|
+
["==", ["get", "kind"], "text"],
|
|
7016
|
+
true,
|
|
7017
|
+
["==", ["get", "isTraceLabel"], true],
|
|
7018
|
+
true,
|
|
7019
|
+
false
|
|
7020
|
+
],
|
|
6830
7021
|
"text-ignore-placement": false,
|
|
6831
7022
|
"text-optional": true,
|
|
6832
7023
|
// Bold font for text features with fontWeight=bold, trace labels, others regular
|
|
@@ -7349,12 +7540,26 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7349
7540
|
mapInstance.addLayer(newLayer, beforeLayer);
|
|
7350
7541
|
addedLayerIds.push(prefixedLayerId);
|
|
7351
7542
|
} catch (e) {
|
|
7543
|
+
console.warn(
|
|
7544
|
+
`[map-component] failed to add basemap layer ${prefixedLayerId}:`,
|
|
7545
|
+
(e == null ? void 0 : e.message) ?? e
|
|
7546
|
+
);
|
|
7352
7547
|
}
|
|
7353
7548
|
}
|
|
7354
7549
|
}
|
|
7355
7550
|
}
|
|
7356
7551
|
basemapLayerIds.current.set(baseMapStyle, addedLayerIds);
|
|
7357
7552
|
loadedBasemaps.current.add(baseMapStyle);
|
|
7553
|
+
const triggerResize = () => {
|
|
7554
|
+
try {
|
|
7555
|
+
mapInstance.resize();
|
|
7556
|
+
} catch {
|
|
7557
|
+
}
|
|
7558
|
+
};
|
|
7559
|
+
requestAnimationFrame(triggerResize);
|
|
7560
|
+
setTimeout(triggerResize, 200);
|
|
7561
|
+
setTimeout(triggerResize, 600);
|
|
7562
|
+
setTimeout(triggerResize, 1500);
|
|
7358
7563
|
}).catch((err) => {
|
|
7359
7564
|
console.error("Failed to load initial basemap:", err);
|
|
7360
7565
|
});
|
|
@@ -7641,7 +7846,19 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7641
7846
|
}, 0);
|
|
7642
7847
|
});
|
|
7643
7848
|
mapInstance.on("error", (e) => {
|
|
7644
|
-
|
|
7849
|
+
var _a, _b;
|
|
7850
|
+
const err = e == null ? void 0 : e.error;
|
|
7851
|
+
const details = {
|
|
7852
|
+
message: err == null ? void 0 : err.message,
|
|
7853
|
+
name: err == null ? void 0 : err.name,
|
|
7854
|
+
stack: err == null ? void 0 : err.stack,
|
|
7855
|
+
status: err == null ? void 0 : err.status,
|
|
7856
|
+
url: err == null ? void 0 : err.url,
|
|
7857
|
+
sourceId: e == null ? void 0 : e.sourceId,
|
|
7858
|
+
tileId: ((_b = (_a = e == null ? void 0 : e.tile) == null ? void 0 : _a.tileID) == null ? void 0 : _b.canonical) ? `${e.tile.tileID.canonical.z}/${e.tile.tileID.canonical.x}/${e.tile.tileID.canonical.y}` : void 0
|
|
7859
|
+
};
|
|
7860
|
+
for (const k of Object.keys(details)) if (details[k] === void 0) delete details[k];
|
|
7861
|
+
console.error("Map error:", details, e);
|
|
7645
7862
|
});
|
|
7646
7863
|
} catch (error) {
|
|
7647
7864
|
console.error("Failed to initialize map:", error);
|
|
@@ -7719,6 +7936,101 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7719
7936
|
if (!map.current || !isMapLoadedRef.current) return;
|
|
7720
7937
|
map.current.flyTo({ center: coords, zoom: zoom ?? map.current.getZoom(), duration: (options == null ? void 0 : options.duration) ?? 2e3 });
|
|
7721
7938
|
},
|
|
7939
|
+
updateLayerConfig: (layerId, config) => {
|
|
7940
|
+
const idx = layersRef.current.findIndex((l) => l.id === layerId);
|
|
7941
|
+
if (idx < 0) return false;
|
|
7942
|
+
const current = layersRef.current[idx];
|
|
7943
|
+
const next = { ...current };
|
|
7944
|
+
if ("visible" in config) {
|
|
7945
|
+
const wantedVisible = config.visible ?? true;
|
|
7946
|
+
if (wantedVisible !== current.visible && !current.readOnly && draw.current) {
|
|
7947
|
+
if (wantedVisible) {
|
|
7948
|
+
const hidden = hiddenFeatures.current.get(layerId) || [];
|
|
7949
|
+
const newIds = [];
|
|
7950
|
+
isApiAddingRef.current = true;
|
|
7951
|
+
try {
|
|
7952
|
+
hidden.forEach((f) => {
|
|
7953
|
+
const ids = draw.current.add(f);
|
|
7954
|
+
newIds.push(ids[0]);
|
|
7955
|
+
});
|
|
7956
|
+
} finally {
|
|
7957
|
+
isApiAddingRef.current = false;
|
|
7958
|
+
}
|
|
7959
|
+
hiddenFeatures.current.delete(layerId);
|
|
7960
|
+
next.visible = true;
|
|
7961
|
+
next.featureIds = newIds;
|
|
7962
|
+
} else {
|
|
7963
|
+
const features = current.featureIds.map((id) => draw.current.get(id)).filter(Boolean);
|
|
7964
|
+
hiddenFeatures.current.set(layerId, features);
|
|
7965
|
+
current.featureIds.forEach((id) => {
|
|
7966
|
+
try {
|
|
7967
|
+
draw.current.delete(id);
|
|
7968
|
+
} catch {
|
|
7969
|
+
}
|
|
7970
|
+
});
|
|
7971
|
+
next.visible = false;
|
|
7972
|
+
next.featureIds = [];
|
|
7973
|
+
}
|
|
7974
|
+
} else {
|
|
7975
|
+
next.visible = wantedVisible;
|
|
7976
|
+
}
|
|
7977
|
+
}
|
|
7978
|
+
if ("visualConfig" in config) next.visualConfig = config.visualConfig;
|
|
7979
|
+
if ("traceConfig" in config) next.traceConfig = config.traceConfig;
|
|
7980
|
+
if ("heatmapConfig" in config) next.heatmapConfig = config.heatmapConfig;
|
|
7981
|
+
if ("clusterConfig" in config) next.clusterConfig = config.clusterConfig;
|
|
7982
|
+
if ("altitudeDisplayMode" in config) next.altitudeDisplayMode = config.altitudeDisplayMode;
|
|
7983
|
+
const updated = [...layersRef.current];
|
|
7984
|
+
updated[idx] = next;
|
|
7985
|
+
layersRef.current = updated;
|
|
7986
|
+
setLayers(updated);
|
|
7987
|
+
if ("visible" in config) {
|
|
7988
|
+
updateFeatureCount();
|
|
7989
|
+
scheduleTimelineUpdate();
|
|
7990
|
+
}
|
|
7991
|
+
requestAnimationFrame(() => syncRef.current());
|
|
7992
|
+
return true;
|
|
7993
|
+
},
|
|
7994
|
+
captureScreenshot: async (options) => {
|
|
7995
|
+
const m = map.current;
|
|
7996
|
+
if (!m || !isMapLoadedRef.current) {
|
|
7997
|
+
toast({
|
|
7998
|
+
title: "Screenshot failed",
|
|
7999
|
+
description: "Map is not ready yet.",
|
|
8000
|
+
variant: "destructive"
|
|
8001
|
+
});
|
|
8002
|
+
throw new Error("Map is not ready");
|
|
8003
|
+
}
|
|
8004
|
+
const SCREENSHOT_RENDER_TIMEOUT_MS = 1e4;
|
|
8005
|
+
try {
|
|
8006
|
+
await new Promise((resolve, reject) => {
|
|
8007
|
+
const onRender = () => {
|
|
8008
|
+
clearTimeout(timeoutId);
|
|
8009
|
+
resolve();
|
|
8010
|
+
};
|
|
8011
|
+
const timeoutId = setTimeout(() => {
|
|
8012
|
+
try {
|
|
8013
|
+
m.off("render", onRender);
|
|
8014
|
+
} catch {
|
|
8015
|
+
}
|
|
8016
|
+
reject(new Error("Screenshot timed out waiting for render (map may have been destroyed)"));
|
|
8017
|
+
}, SCREENSHOT_RENDER_TIMEOUT_MS);
|
|
8018
|
+
m.once("render", onRender);
|
|
8019
|
+
m.triggerRepaint();
|
|
8020
|
+
});
|
|
8021
|
+
} catch (err) {
|
|
8022
|
+
toast({
|
|
8023
|
+
title: "Screenshot failed",
|
|
8024
|
+
description: err instanceof Error ? err.message : "The map did not render in time. Please try again.",
|
|
8025
|
+
variant: "destructive"
|
|
8026
|
+
});
|
|
8027
|
+
throw err;
|
|
8028
|
+
}
|
|
8029
|
+
const canvas = m.getCanvas();
|
|
8030
|
+
const fmt = (options == null ? void 0 : options.format) === "jpeg" ? "image/jpeg" : "image/png";
|
|
8031
|
+
const dataUrl = fmt === "image/jpeg" ? canvas.toDataURL(fmt, options == null ? void 0 : options.quality) : canvas.toDataURL(fmt);
|
|
8032
|
+
return { dataUrl, width: canvas.width, height: canvas.height };
|
|
8033
|
+
},
|
|
7722
8034
|
fitToData: (layerIds) => {
|
|
7723
8035
|
if (!map.current || !isMapLoadedRef.current) return;
|
|
7724
8036
|
const drawFeatures = draw.current ? draw.current.getAll().features : [];
|
|
@@ -7757,11 +8069,25 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7757
8069
|
const newLayer = {
|
|
7758
8070
|
id: layerId,
|
|
7759
8071
|
name,
|
|
7760
|
-
visible
|
|
8072
|
+
// Default to visible. The optional `visible` flag lets restore-flows
|
|
8073
|
+
// recreate a layer that the user had previously hidden, without
|
|
8074
|
+
// racing a follow-up `setLayerVisibility(id, false)` call (which
|
|
8075
|
+
// briefly flashes the layer on screen between addLayer and the
|
|
8076
|
+
// visibility toggle).
|
|
8077
|
+
visible: (options == null ? void 0 : options.visible) ?? true,
|
|
7761
8078
|
featureIds: [],
|
|
7762
8079
|
readOnly: options == null ? void 0 : options.readOnly,
|
|
7763
8080
|
group: options == null ? void 0 : options.group,
|
|
7764
|
-
metadata: options == null ? void 0 : options.metadata
|
|
8081
|
+
metadata: options == null ? void 0 : options.metadata,
|
|
8082
|
+
// Per-layer visual configs are passed through verbatim so that hosts
|
|
8083
|
+
// restoring a saved map (workspace auto-save, file merge, etc.) can
|
|
8084
|
+
// recreate heatmap / cluster / color-by-field / label / size / trace
|
|
8085
|
+
// settings without a follow-up "update visual config" round-trip.
|
|
8086
|
+
visualConfig: options == null ? void 0 : options.visualConfig,
|
|
8087
|
+
traceConfig: options == null ? void 0 : options.traceConfig,
|
|
8088
|
+
heatmapConfig: options == null ? void 0 : options.heatmapConfig,
|
|
8089
|
+
clusterConfig: options == null ? void 0 : options.clusterConfig,
|
|
8090
|
+
altitudeDisplayMode: options == null ? void 0 : options.altitudeDisplayMode
|
|
7765
8091
|
};
|
|
7766
8092
|
if (geojson) {
|
|
7767
8093
|
if (options == null ? void 0 : options.readOnly) {
|
|
@@ -7800,6 +8126,17 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7800
8126
|
}
|
|
7801
8127
|
}
|
|
7802
8128
|
}
|
|
8129
|
+
if (newLayer.visible === false && !(options == null ? void 0 : options.readOnly) && draw.current && newLayer.featureIds.length > 0) {
|
|
8130
|
+
const features = newLayer.featureIds.map((id) => draw.current.get(id)).filter(Boolean);
|
|
8131
|
+
hiddenFeatures.current.set(layerId, features);
|
|
8132
|
+
newLayer.featureIds.forEach((id) => {
|
|
8133
|
+
try {
|
|
8134
|
+
draw.current.delete(id);
|
|
8135
|
+
} catch {
|
|
8136
|
+
}
|
|
8137
|
+
});
|
|
8138
|
+
newLayer.featureIds = [];
|
|
8139
|
+
}
|
|
7803
8140
|
const updatedLayers = [...layersRef.current, newLayer];
|
|
7804
8141
|
layersRef.current = updatedLayers;
|
|
7805
8142
|
setLayers(updatedLayers);
|
|
@@ -9613,6 +9950,31 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9613
9950
|
});
|
|
9614
9951
|
return Array.from(fieldsMap.entries()).map(([name, isNumeric]) => ({ name, isNumeric })).sort((a, b) => a.name.localeCompare(b.name));
|
|
9615
9952
|
}, [layers]);
|
|
9953
|
+
const getFieldValueDistribution = react.useCallback(
|
|
9954
|
+
(layerId, fieldName, maxValues = 50) => {
|
|
9955
|
+
var _a;
|
|
9956
|
+
const layer = layers.find((l) => l.id === layerId);
|
|
9957
|
+
if (!layer) return [];
|
|
9958
|
+
let features = [];
|
|
9959
|
+
if (layer.readOnly) {
|
|
9960
|
+
features = readOnlyFeatures.current.get(layerId) || [];
|
|
9961
|
+
} else if (layer.visible) {
|
|
9962
|
+
features = draw.current ? layer.featureIds.map((id) => draw.current.get(id)) : [];
|
|
9963
|
+
} else {
|
|
9964
|
+
features = hiddenFeatures.current.get(layerId) || [];
|
|
9965
|
+
}
|
|
9966
|
+
const MAX_SAMPLES = 1e4;
|
|
9967
|
+
const sample = features.slice(0, MAX_SAMPLES);
|
|
9968
|
+
const counts = /* @__PURE__ */ new Map();
|
|
9969
|
+
for (const f of sample) {
|
|
9970
|
+
const key = categoricalKey((_a = f == null ? void 0 : f.properties) == null ? void 0 : _a[fieldName]);
|
|
9971
|
+
if (key === null) continue;
|
|
9972
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
9973
|
+
}
|
|
9974
|
+
return Array.from(counts.entries()).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, maxValues).map(([value, count]) => ({ value, count }));
|
|
9975
|
+
},
|
|
9976
|
+
[layers]
|
|
9977
|
+
);
|
|
9616
9978
|
const handleFitToLayerFeatures = react.useCallback((layerId) => {
|
|
9617
9979
|
if (!map.current) return;
|
|
9618
9980
|
const customBounds = fitBoundsProvider == null ? void 0 : fitBoundsProvider(layerId);
|
|
@@ -11449,45 +11811,38 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11449
11811
|
}
|
|
11450
11812
|
if (pointFeatures.length === 0) return;
|
|
11451
11813
|
const groupByField = (_b = layer.clusterConfig) == null ? void 0 : _b.groupByField;
|
|
11452
|
-
const
|
|
11453
|
-
|
|
11454
|
-
"#ef4444",
|
|
11455
|
-
"#22c55e",
|
|
11456
|
-
"#f59e0b",
|
|
11457
|
-
"#8b5cf6",
|
|
11458
|
-
"#ec4899",
|
|
11459
|
-
"#06b6d4",
|
|
11460
|
-
"#f97316",
|
|
11461
|
-
"#84cc16",
|
|
11462
|
-
"#6366f1",
|
|
11463
|
-
"#14b8a6",
|
|
11464
|
-
"#d946ef",
|
|
11465
|
-
"#0ea5e9",
|
|
11466
|
-
"#a855f7",
|
|
11467
|
-
"#10b981"
|
|
11468
|
-
];
|
|
11814
|
+
const OTHER_COLOR = OTHER_BUCKET_COLOR;
|
|
11815
|
+
const MAX_CATEGORIES = 15;
|
|
11469
11816
|
try {
|
|
11470
11817
|
const layerColor = ((_d = (_c = layer.visualConfig) == null ? void 0 : _c.color) == null ? void 0 : _d.fixedColor) || "#3b82f6";
|
|
11471
11818
|
let clusterProperties = {};
|
|
11472
11819
|
let categoryValues = [];
|
|
11473
11820
|
let categoryColorMap = {};
|
|
11821
|
+
let hasOtherBucket = false;
|
|
11474
11822
|
if (groupByField) {
|
|
11475
|
-
const
|
|
11823
|
+
const counts = /* @__PURE__ */ new Map();
|
|
11476
11824
|
pointFeatures.forEach((f) => {
|
|
11477
11825
|
var _a2;
|
|
11478
|
-
const
|
|
11479
|
-
if (
|
|
11480
|
-
|
|
11481
|
-
}
|
|
11826
|
+
const key = categoricalKey((_a2 = f.properties) == null ? void 0 : _a2[groupByField]);
|
|
11827
|
+
if (key === null) return;
|
|
11828
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
11482
11829
|
});
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11830
|
+
const sorted = Array.from(counts.entries()).sort((a, b) => b[1] - a[1]);
|
|
11831
|
+
const topKeys = sorted.slice(0, MAX_CATEGORIES).map(([k]) => k);
|
|
11832
|
+
categoryValues = [...topKeys];
|
|
11833
|
+
hasOtherBucket = true;
|
|
11834
|
+
const fieldAsString = ["to-string", ["coalesce", ["get", groupByField], ""]];
|
|
11835
|
+
topKeys.forEach((cat, i) => {
|
|
11836
|
+
categoryColorMap[cat] = hashStringToColor$1(cat);
|
|
11486
11837
|
clusterProperties[`cat_${i}`] = [
|
|
11487
11838
|
"+",
|
|
11488
|
-
["case", ["==",
|
|
11839
|
+
["case", ["==", fieldAsString, cat], 1, 0]
|
|
11489
11840
|
];
|
|
11490
11841
|
});
|
|
11842
|
+
categoryValues.push(OTHER_BUCKET_KEY);
|
|
11843
|
+
categoryColorMap[OTHER_BUCKET_KEY] = OTHER_COLOR;
|
|
11844
|
+
const otherExpr = topKeys.length === 0 ? 1 : ["match", fieldAsString, topKeys, 0, 1];
|
|
11845
|
+
clusterProperties[`cat_${categoryValues.length - 1}`] = ["+", otherExpr];
|
|
11491
11846
|
}
|
|
11492
11847
|
const mapStyleMaxZoom = typeof mapInstance.getMaxZoom === "function" ? mapInstance.getMaxZoom() : 24;
|
|
11493
11848
|
const clusterMaxZoom = Math.min(24, Math.max(1, mapStyleMaxZoom - 1));
|
|
@@ -11561,11 +11916,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11561
11916
|
}
|
|
11562
11917
|
});
|
|
11563
11918
|
}
|
|
11564
|
-
const
|
|
11919
|
+
const renderableTopKeys = categoryValues.filter((c) => c !== OTHER_BUCKET_KEY);
|
|
11920
|
+
const unclusteredColor = groupByField && renderableTopKeys.length > 0 ? [
|
|
11565
11921
|
"match",
|
|
11566
|
-
["get", groupByField],
|
|
11567
|
-
...
|
|
11568
|
-
layerColor
|
|
11922
|
+
["to-string", ["coalesce", ["get", groupByField], ""]],
|
|
11923
|
+
...renderableTopKeys.flatMap((cat) => [cat, categoryColorMap[cat] || layerColor]),
|
|
11924
|
+
hasOtherBucket ? OTHER_COLOR : layerColor
|
|
11569
11925
|
] : layerColor;
|
|
11570
11926
|
mapInstance.addLayer({
|
|
11571
11927
|
id: unclusteredLayerId,
|
|
@@ -11621,7 +11977,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11621
11977
|
} catch {
|
|
11622
11978
|
}
|
|
11623
11979
|
};
|
|
11624
|
-
}, [isMapLoaded, layers, currentMapStyle]);
|
|
11980
|
+
}, [isMapLoaded, layers, currentMapStyle, hashStringToColor$1]);
|
|
11625
11981
|
if (mapError) {
|
|
11626
11982
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex items-center justify-center h-full bg-muted/30 ${className || ""}`, "data-testid": "map-error", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Card, { className: "max-w-md", children: [
|
|
11627
11983
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 border-b border-border", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
@@ -12004,6 +12360,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12004
12360
|
onMapStyleChange: handleMapStyleChange,
|
|
12005
12361
|
onUpdateTraceConfig: handleUpdateTraceConfig,
|
|
12006
12362
|
getAvailableTraceFields,
|
|
12363
|
+
getFieldValueDistribution,
|
|
12007
12364
|
onUpdateHeatmapConfig: handleUpdateHeatmapConfig,
|
|
12008
12365
|
onUpdateClusterConfig: handleUpdateClusterConfig,
|
|
12009
12366
|
hasPointFeatures,
|
|
@@ -12022,6 +12379,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12022
12379
|
hideBasemapSwitcher,
|
|
12023
12380
|
externalPersistence,
|
|
12024
12381
|
customGlobalMenuItems,
|
|
12382
|
+
extraLayerToolbarButtons,
|
|
12025
12383
|
layerBadgeProvider,
|
|
12026
12384
|
featureCountProvider
|
|
12027
12385
|
}
|
|
@@ -12062,7 +12420,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12062
12420
|
onMoveFeaturesToLayer: handleMoveFeaturesToLayer,
|
|
12063
12421
|
onCopyFeaturesToLayer: handleCopyFeaturesToLayer,
|
|
12064
12422
|
onCreateLayerAndMoveFeatures: handleCreateLayerAndMoveFeatures,
|
|
12065
|
-
onCreateLayerAndCopyFeatures: handleCreateLayerAndCopyFeatures
|
|
12423
|
+
onCreateLayerAndCopyFeatures: handleCreateLayerAndCopyFeatures,
|
|
12424
|
+
getFeatureColor: (featureId) => selectedFeatureColors.get(featureId)
|
|
12066
12425
|
}
|
|
12067
12426
|
);
|
|
12068
12427
|
})(),
|