openlayers-style-editor 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3483 -0
- package/dist/index.js +3437 -0
- package/package.json +1 -1
- package/dist/auto-BpR47GuV.js +0 -8153
- package/dist/index.es.js +0 -30224
- package/dist/index.umd.js +0 -1662
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3483 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("primereact/api/api.esm.js"), require("react"), require("primereact/dialog/dialog.esm.js"), require("ol/color.js"), require("primereact/slider/slider.esm.js"), require("react-best-gradient-color-picker"), require("react-i18next"), require("react/jsx-runtime"), require("primereact/button/button.esm.js"), require("primereact/dropdown/dropdown.esm.js"), require("primereact/checkbox/checkbox.esm.js"), require("primereact/datatable/datatable.esm.js"), require("primereact/column/column.esm.js"), require("primereact/chart/chart.esm.js"), require("primereact/inputnumber/inputnumber.esm.js"), require("primereact/toast/toast.esm.js"), require("geobuckets/dist/src/index.js"), require("primereact/scrollpanel/scrollpanel.esm.js"), require("primereact/panel/panel.esm.js"), require("primereact/fieldset/fieldset.esm.js"), require("primereact/inputtext/inputtext.esm.js"), require("primereact/radiobutton/radiobutton.esm.js"), require("json-logic-js"), require("i18next")) : typeof define === "function" && define.amd ? define([
|
|
3
|
+
"exports",
|
|
4
|
+
"primereact/api/api.esm.js",
|
|
5
|
+
"react",
|
|
6
|
+
"primereact/dialog/dialog.esm.js",
|
|
7
|
+
"ol/color.js",
|
|
8
|
+
"primereact/slider/slider.esm.js",
|
|
9
|
+
"react-best-gradient-color-picker",
|
|
10
|
+
"react-i18next",
|
|
11
|
+
"react/jsx-runtime",
|
|
12
|
+
"primereact/button/button.esm.js",
|
|
13
|
+
"primereact/dropdown/dropdown.esm.js",
|
|
14
|
+
"primereact/checkbox/checkbox.esm.js",
|
|
15
|
+
"primereact/datatable/datatable.esm.js",
|
|
16
|
+
"primereact/column/column.esm.js",
|
|
17
|
+
"primereact/chart/chart.esm.js",
|
|
18
|
+
"primereact/inputnumber/inputnumber.esm.js",
|
|
19
|
+
"primereact/toast/toast.esm.js",
|
|
20
|
+
"geobuckets/dist/src/index.js",
|
|
21
|
+
"primereact/scrollpanel/scrollpanel.esm.js",
|
|
22
|
+
"primereact/panel/panel.esm.js",
|
|
23
|
+
"primereact/fieldset/fieldset.esm.js",
|
|
24
|
+
"primereact/inputtext/inputtext.esm.js",
|
|
25
|
+
"primereact/radiobutton/radiobutton.esm.js",
|
|
26
|
+
"json-logic-js",
|
|
27
|
+
"i18next"
|
|
28
|
+
], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["OpenLayers Style Editor"] = {}, global.primereact_api_api_esm_js, global.React, global.primereact_dialog_dialog_esm_js, global.ol_color_js, global.primereact_slider_slider_esm_js, global.react_best_gradient_color_picker, global.react_i18next, global.react_jsx_runtime, global.primereact_button_button_esm_js, global.primereact_dropdown_dropdown_esm_js, global.primereact_checkbox_checkbox_esm_js, global.primereact_datatable_datatable_esm_js, global.primereact_column_column_esm_js, global.primereact_chart_chart_esm_js, global.primereact_inputnumber_inputnumber_esm_js, global.primereact_toast_toast_esm_js, global.geobuckets_dist_src_index_js, global.primereact_scrollpanel_scrollpanel_esm_js, global.primereact_panel_panel_esm_js, global.primereact_fieldset_fieldset_esm_js, global.primereact_inputtext_inputtext_esm_js, global.primereact_radiobutton_radiobutton_esm_js, global.json_logic_js, global.i18next));
|
|
29
|
+
})(this, function(exports, primereact_api_api_esm_js, react, primereact_dialog_dialog_esm_js, ol_color_js, primereact_slider_slider_esm_js, react_best_gradient_color_picker, react_i18next, react_jsx_runtime, primereact_button_button_esm_js, primereact_dropdown_dropdown_esm_js, primereact_checkbox_checkbox_esm_js, primereact_datatable_datatable_esm_js, primereact_column_column_esm_js, primereact_chart_chart_esm_js, primereact_inputnumber_inputnumber_esm_js, primereact_toast_toast_esm_js, geobuckets_dist_src_index_js, primereact_scrollpanel_scrollpanel_esm_js, primereact_panel_panel_esm_js, primereact_fieldset_fieldset_esm_js, primereact_inputtext_inputtext_esm_js, primereact_radiobutton_radiobutton_esm_js, json_logic_js, i18next) {
|
|
30
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
31
|
+
//#region \0rolldown/runtime.js
|
|
32
|
+
var __create = Object.create;
|
|
33
|
+
var __defProp = Object.defineProperty;
|
|
34
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
35
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
36
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
37
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
38
|
+
var __copyProps = (to, from, except, desc) => {
|
|
39
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
40
|
+
key = keys[i];
|
|
41
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
42
|
+
get: ((k) => from[k]).bind(null, key),
|
|
43
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return to;
|
|
47
|
+
};
|
|
48
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
49
|
+
value: mod,
|
|
50
|
+
enumerable: true
|
|
51
|
+
}) : target, mod));
|
|
52
|
+
//#endregion
|
|
53
|
+
react = __toESM(react);
|
|
54
|
+
react_best_gradient_color_picker = __toESM(react_best_gradient_color_picker);
|
|
55
|
+
json_logic_js = __toESM(json_logic_js);
|
|
56
|
+
i18next = __toESM(i18next);
|
|
57
|
+
//#region src/components/myColorPicker.tsx
|
|
58
|
+
var MyColorPicker = (props) => {
|
|
59
|
+
const { color, onChange, hideAlpha } = props;
|
|
60
|
+
const [visible, setVisible] = (0, react.useState)(false);
|
|
61
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
62
|
+
const selectColor = t("color_picker.select_color");
|
|
63
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
64
|
+
style: { backgroundColor: (0, ol_color_js.asString)(color) },
|
|
65
|
+
className: "color-picker",
|
|
66
|
+
onClick: () => setVisible(true)
|
|
67
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dialog_dialog_esm_js.Dialog, {
|
|
68
|
+
header: selectColor,
|
|
69
|
+
onHide: () => setVisible(false),
|
|
70
|
+
visible,
|
|
71
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_best_gradient_color_picker.default, {
|
|
72
|
+
value: (0, ol_color_js.asString)(color),
|
|
73
|
+
onChange,
|
|
74
|
+
hideOpacity: hideAlpha,
|
|
75
|
+
hideControls: true
|
|
76
|
+
})
|
|
77
|
+
})] });
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/rendererUtils.ts
|
|
81
|
+
var AttributeTypeEnum = /* @__PURE__ */ function(AttributeTypeEnum) {
|
|
82
|
+
AttributeTypeEnum[AttributeTypeEnum["STRING"] = 0] = "STRING";
|
|
83
|
+
AttributeTypeEnum[AttributeTypeEnum["INTEGER"] = 1] = "INTEGER";
|
|
84
|
+
AttributeTypeEnum[AttributeTypeEnum["FLOAT"] = 2] = "FLOAT";
|
|
85
|
+
AttributeTypeEnum[AttributeTypeEnum["BOOLEAN"] = 3] = "BOOLEAN";
|
|
86
|
+
AttributeTypeEnum[AttributeTypeEnum["DATE"] = 4] = "DATE";
|
|
87
|
+
AttributeTypeEnum[AttributeTypeEnum["JSON"] = 5] = "JSON";
|
|
88
|
+
return AttributeTypeEnum;
|
|
89
|
+
}({});
|
|
90
|
+
var RenderType = /* @__PURE__ */ function(RenderType) {
|
|
91
|
+
RenderType["Unique"] = "Unique";
|
|
92
|
+
RenderType["Categorized"] = "Categorized";
|
|
93
|
+
RenderType["Graduated"] = "Graduated";
|
|
94
|
+
RenderType["ByRules"] = "ByRules";
|
|
95
|
+
return RenderType;
|
|
96
|
+
}({});
|
|
97
|
+
var GraduatedModes = /* @__PURE__ */ function(GraduatedModes) {
|
|
98
|
+
GraduatedModes["Manual"] = "Manual";
|
|
99
|
+
GraduatedModes["EqualInterval"] = "EqualInterval";
|
|
100
|
+
GraduatedModes["DefinedInterval"] = "DefinedInterval";
|
|
101
|
+
GraduatedModes["Quantile"] = "Quantile";
|
|
102
|
+
GraduatedModes["NaturalBreaks"] = "NaturalBreaks";
|
|
103
|
+
GraduatedModes["GeometricInterval"] = "GeometricInterval";
|
|
104
|
+
GraduatedModes["StandardDeviation"] = "StandardDeviation";
|
|
105
|
+
return GraduatedModes;
|
|
106
|
+
}({});
|
|
107
|
+
function getCategorizedStyle(attribute, colors, outlineColor, outlineWidth, defaultColor) {
|
|
108
|
+
let outlineColorCopy = outlineColor ? outlineColor : void 0;
|
|
109
|
+
if (outlineWidth == 0 && outlineColorCopy != void 0) outlineColorCopy[3] = 0;
|
|
110
|
+
else if (outlineWidth != void 0 && outlineWidth > 0 && outlineColorCopy) outlineColorCopy[3] = 1;
|
|
111
|
+
let aux = [];
|
|
112
|
+
aux.push("match");
|
|
113
|
+
aux.push(["get", attribute]);
|
|
114
|
+
colors.forEach((color) => {
|
|
115
|
+
aux.push(color.value);
|
|
116
|
+
aux.push(color.color);
|
|
117
|
+
});
|
|
118
|
+
aux.push(defaultColor || (0, ol_color_js.fromString)("#333333"));
|
|
119
|
+
return {
|
|
120
|
+
"stroke-color": [
|
|
121
|
+
"case",
|
|
122
|
+
[
|
|
123
|
+
"==",
|
|
124
|
+
["var", "highlightedId"],
|
|
125
|
+
["id"]
|
|
126
|
+
],
|
|
127
|
+
"white",
|
|
128
|
+
outlineColorCopy || "#000000"
|
|
129
|
+
],
|
|
130
|
+
"stroke-width": [
|
|
131
|
+
"case",
|
|
132
|
+
[
|
|
133
|
+
"==",
|
|
134
|
+
["var", "highlightedId"],
|
|
135
|
+
["id"]
|
|
136
|
+
],
|
|
137
|
+
2,
|
|
138
|
+
outlineWidth == void 0 ? 1 : outlineWidth
|
|
139
|
+
],
|
|
140
|
+
"fill-color": aux
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function singleColorStyle(color, outlineColor, outlineWidth) {
|
|
144
|
+
let outlineColorCopy = outlineColor ? outlineColor : void 0;
|
|
145
|
+
if (outlineWidth == 0 && outlineColorCopy != void 0) outlineColorCopy[3] = 0;
|
|
146
|
+
else if (outlineWidth != void 0 && outlineWidth > 0 && outlineColorCopy) outlineColorCopy[3] = 1;
|
|
147
|
+
return {
|
|
148
|
+
"stroke-color": [
|
|
149
|
+
"case",
|
|
150
|
+
[
|
|
151
|
+
"==",
|
|
152
|
+
["var", "highlightedId"],
|
|
153
|
+
["id"]
|
|
154
|
+
],
|
|
155
|
+
"white",
|
|
156
|
+
outlineColorCopy || "#000000"
|
|
157
|
+
],
|
|
158
|
+
"stroke-width": [
|
|
159
|
+
"case",
|
|
160
|
+
[
|
|
161
|
+
"==",
|
|
162
|
+
["var", "highlightedId"],
|
|
163
|
+
["id"]
|
|
164
|
+
],
|
|
165
|
+
2,
|
|
166
|
+
outlineWidth == void 0 ? 1 : outlineWidth
|
|
167
|
+
],
|
|
168
|
+
"stroke-offset": 0,
|
|
169
|
+
"fill-color": color
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function singleColorStyleForLines(color) {
|
|
173
|
+
return {
|
|
174
|
+
"stroke-color": color,
|
|
175
|
+
"stroke-width": 1,
|
|
176
|
+
"stroke-offset": 0
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function getGraduatedStyle(attribute, ramp, outlineColor, outlineWidth) {
|
|
180
|
+
let outlineColorCopy = outlineColor ? outlineColor : void 0;
|
|
181
|
+
if (outlineWidth == 0 && outlineColorCopy != void 0) outlineColorCopy[3] = 0;
|
|
182
|
+
else if (outlineWidth != void 0 && outlineWidth > 0 && outlineColorCopy) outlineColorCopy[3] = 1;
|
|
183
|
+
let aux = [];
|
|
184
|
+
aux.push("interpolate");
|
|
185
|
+
aux.push(["linear"]);
|
|
186
|
+
aux.push(["get", attribute]);
|
|
187
|
+
ramp.forEach((stop) => {
|
|
188
|
+
aux.push(stop.value);
|
|
189
|
+
aux.push(stop.color);
|
|
190
|
+
});
|
|
191
|
+
const res = {
|
|
192
|
+
"stroke-color": [
|
|
193
|
+
"case",
|
|
194
|
+
[
|
|
195
|
+
"==",
|
|
196
|
+
["var", "highlightedId"],
|
|
197
|
+
["id"]
|
|
198
|
+
],
|
|
199
|
+
"white",
|
|
200
|
+
outlineColorCopy || "#000000"
|
|
201
|
+
],
|
|
202
|
+
"stroke-width": [
|
|
203
|
+
"case",
|
|
204
|
+
[
|
|
205
|
+
"==",
|
|
206
|
+
["var", "highlightedId"],
|
|
207
|
+
["id"]
|
|
208
|
+
],
|
|
209
|
+
2,
|
|
210
|
+
outlineWidth == void 0 ? 1 : outlineWidth
|
|
211
|
+
],
|
|
212
|
+
"fill-color": aux
|
|
213
|
+
};
|
|
214
|
+
console.log(res);
|
|
215
|
+
return res;
|
|
216
|
+
}
|
|
217
|
+
function getRendererOpacity(renderer) {
|
|
218
|
+
if (renderer.type == RenderType.Unique) return renderer.rendererOL["fill-color"][3] * 100;
|
|
219
|
+
if (renderer.type == RenderType.Categorized) return renderer.rendererOL["fill-color"][3][3] * 100;
|
|
220
|
+
if (renderer.type == RenderType.Graduated) return renderer.rendererOL["fill-color"][4][3] * 100;
|
|
221
|
+
return 100;
|
|
222
|
+
}
|
|
223
|
+
function changeRendererOpacity(renderer, opacity) {
|
|
224
|
+
let newRenderer = renderer;
|
|
225
|
+
if (renderer.type == RenderType.Unique) {
|
|
226
|
+
let aux = renderer.rendererOL["fill-color"];
|
|
227
|
+
aux = [...aux];
|
|
228
|
+
aux[3] = opacity / 100;
|
|
229
|
+
newRenderer = {
|
|
230
|
+
...renderer,
|
|
231
|
+
rendererOL: {
|
|
232
|
+
...renderer.rendererOL,
|
|
233
|
+
["fill-color"]: aux
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
if (renderer.type == RenderType.Categorized) {
|
|
238
|
+
let aux = renderer.rendererOL["fill-color"].slice(3);
|
|
239
|
+
let newAux = [...aux];
|
|
240
|
+
for (let i = 0; i < aux.length; i += 2) {
|
|
241
|
+
let color = [...aux[i]];
|
|
242
|
+
color[3] = opacity / 100;
|
|
243
|
+
newAux[i] = color;
|
|
244
|
+
}
|
|
245
|
+
newRenderer = {
|
|
246
|
+
...renderer,
|
|
247
|
+
rendererOL: {
|
|
248
|
+
...renderer.rendererOL,
|
|
249
|
+
["fill-color"]: renderer.rendererOL["fill-color"].slice(0, 3).concat(newAux)
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
if (renderer.type == RenderType.Graduated) {
|
|
254
|
+
let aux = renderer.rendererOL["fill-color"].slice(4);
|
|
255
|
+
let newAux = [...aux];
|
|
256
|
+
for (let i = 0; i < aux.length; i += 2) {
|
|
257
|
+
let color = [...aux[i]];
|
|
258
|
+
color[3] = opacity / 100;
|
|
259
|
+
newAux[i] = color;
|
|
260
|
+
}
|
|
261
|
+
newRenderer = {
|
|
262
|
+
...renderer,
|
|
263
|
+
rendererOL: {
|
|
264
|
+
...renderer.rendererOL,
|
|
265
|
+
["fill-color"]: renderer.rendererOL["fill-color"].slice(0, 4).concat(newAux)
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
return newRenderer;
|
|
270
|
+
}
|
|
271
|
+
function getStyleColorsAndValues(style, type) {
|
|
272
|
+
let colors = [];
|
|
273
|
+
if (type == RenderType.Categorized) {
|
|
274
|
+
for (let i = 2; i < style["fill-color"].length - 1; i += 2) colors.push({
|
|
275
|
+
value: style["fill-color"][i],
|
|
276
|
+
color: style["fill-color"][i + 1]
|
|
277
|
+
});
|
|
278
|
+
colors.push({
|
|
279
|
+
value: "Nulo",
|
|
280
|
+
color: style["fill-color"][style["fill-color"].length - 1]
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
if (type == RenderType.Graduated) {
|
|
284
|
+
for (let i = 3; i < style["fill-color"].length - 1; i += 2) colors.push({
|
|
285
|
+
value: style["fill-color"][i],
|
|
286
|
+
color: style["fill-color"][i + 1]
|
|
287
|
+
});
|
|
288
|
+
colors.push({
|
|
289
|
+
value: "Nulo",
|
|
290
|
+
color: style["fill-color"][style["fill-color"].length - 1]
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
if (type == RenderType.Unique) colors = [{
|
|
294
|
+
value: "Único",
|
|
295
|
+
color: style["fill-color"]
|
|
296
|
+
}];
|
|
297
|
+
return colors;
|
|
298
|
+
}
|
|
299
|
+
function getRendererColorAndSizeStroke(renderer) {
|
|
300
|
+
return {
|
|
301
|
+
color: renderer.rendererOL["stroke-color"][3],
|
|
302
|
+
size: renderer.rendererOL["stroke-width"][3]
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function generateRandomColor() {
|
|
306
|
+
return (0, ol_color_js.fromString)("#" + (16777216 + Math.random() * 16777215).toString(16).substr(1, 6));
|
|
307
|
+
}
|
|
308
|
+
function getByRulesStyle(filters, idFieldName, elseFilter) {
|
|
309
|
+
if (filters.length === 0) if (elseFilter) {
|
|
310
|
+
let fillColor = getStyleColorsAndValues(elseFilter.symbol.rendererOL, RenderType.Unique)[0].color;
|
|
311
|
+
let stroke = getRendererColorAndSizeStroke(elseFilter.symbol);
|
|
312
|
+
return {
|
|
313
|
+
"stroke-color": Object.values(stroke.color),
|
|
314
|
+
"stroke-width": stroke.size,
|
|
315
|
+
"fill-color": fillColor
|
|
316
|
+
};
|
|
317
|
+
} else return {
|
|
318
|
+
"stroke-color": (0, ol_color_js.fromString)("#000000"),
|
|
319
|
+
"stroke-width": 1,
|
|
320
|
+
"fill-color": (0, ol_color_js.fromString)("#ffffff")
|
|
321
|
+
};
|
|
322
|
+
let fillColorArray = ["case"];
|
|
323
|
+
let strokeColorArray = ["case"];
|
|
324
|
+
let strokeWidthArray = ["case"];
|
|
325
|
+
filters.forEach((filter) => {
|
|
326
|
+
if (filter.ids.length > 0) {
|
|
327
|
+
let fillColor = getStyleColorsAndValues(filter.filter.symbol.rendererOL, RenderType.Unique)[0].color;
|
|
328
|
+
let cond = [
|
|
329
|
+
"in",
|
|
330
|
+
["get", idFieldName],
|
|
331
|
+
filter.ids
|
|
332
|
+
];
|
|
333
|
+
fillColorArray.push(cond);
|
|
334
|
+
fillColorArray.push(fillColor);
|
|
335
|
+
let stroke = getRendererColorAndSizeStroke(filter.filter.symbol);
|
|
336
|
+
strokeColorArray.push(cond);
|
|
337
|
+
strokeColorArray.push(Object.values(stroke.color));
|
|
338
|
+
strokeWidthArray.push(cond);
|
|
339
|
+
strokeWidthArray.push(stroke.size);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
if (elseFilter) {
|
|
343
|
+
let fillColor = getStyleColorsAndValues(elseFilter.symbol.rendererOL, RenderType.Unique)[0].color;
|
|
344
|
+
fillColorArray.push(fillColor);
|
|
345
|
+
let stroke = getRendererColorAndSizeStroke(elseFilter.symbol);
|
|
346
|
+
strokeColorArray.push(Object.values(stroke.color));
|
|
347
|
+
strokeWidthArray.push(stroke.size);
|
|
348
|
+
} else {
|
|
349
|
+
fillColorArray.push((0, ol_color_js.fromString)("#ffffff"));
|
|
350
|
+
strokeColorArray.push((0, ol_color_js.fromString)("#000000"));
|
|
351
|
+
strokeWidthArray.push(1);
|
|
352
|
+
}
|
|
353
|
+
return {
|
|
354
|
+
"stroke-color": strokeColorArray,
|
|
355
|
+
"stroke-width": strokeWidthArray,
|
|
356
|
+
"fill-color": fillColorArray
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/components/uniqueSymbol.tsx
|
|
361
|
+
var UniqueSymbol = (props) => {
|
|
362
|
+
const { layerCurrentRenderer, applyRenderer, setVisible } = props;
|
|
363
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
364
|
+
const fillColorLabel = t("unique_symbol.fill_color");
|
|
365
|
+
const strokeColorLabel = t("categorized.stroke_color");
|
|
366
|
+
const strokeWidthLabel = t("categorized.stroke_width");
|
|
367
|
+
const concludeLabel = t("common.conclude");
|
|
368
|
+
const start = "#18d7ba";
|
|
369
|
+
const currentStyle = layerCurrentRenderer.field ? null : layerCurrentRenderer.rendererOL;
|
|
370
|
+
const [color, setColor] = (0, react.useState)(currentStyle ? currentStyle["fill-color"] : (0, ol_color_js.fromString)(start));
|
|
371
|
+
let auxBorder;
|
|
372
|
+
if (currentStyle) if (currentStyle["stroke-color"]) if (currentStyle["stroke-color"][0] == "case") auxBorder = currentStyle["stroke-color"][3];
|
|
373
|
+
else auxBorder = currentStyle["stroke-color"];
|
|
374
|
+
else auxBorder = (0, ol_color_js.fromString)("#000000");
|
|
375
|
+
else auxBorder = (0, ol_color_js.fromString)("#000000");
|
|
376
|
+
const [borderColor, setBorderColor] = (0, react.useState)(auxBorder);
|
|
377
|
+
let auxBorderWidth;
|
|
378
|
+
if (currentStyle) if (currentStyle["stroke-width"] instanceof Array) auxBorderWidth = currentStyle["stroke-width"][3];
|
|
379
|
+
else auxBorderWidth = currentStyle["stroke-width"];
|
|
380
|
+
else auxBorderWidth = 0;
|
|
381
|
+
const [borderThickness, setBorderThickness] = (0, react.useState)(auxBorderWidth);
|
|
382
|
+
function createRenderUnique(color, outlineColor, outlineWidth) {
|
|
383
|
+
return singleColorStyle(color, outlineColor, outlineWidth);
|
|
384
|
+
}
|
|
385
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
386
|
+
className: "container",
|
|
387
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
388
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
389
|
+
className: "flex-row-unique",
|
|
390
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [fillColorLabel, ":"] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MyColorPicker, {
|
|
391
|
+
color,
|
|
392
|
+
onChange: (e) => setColor((0, ol_color_js.fromString)(e))
|
|
393
|
+
}) })]
|
|
394
|
+
}),
|
|
395
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
396
|
+
className: "flex-row-unique",
|
|
397
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [strokeColorLabel, ":"] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MyColorPicker, {
|
|
398
|
+
color: (() => {
|
|
399
|
+
if (borderColor.at(3) < 1) return [
|
|
400
|
+
borderColor[0],
|
|
401
|
+
borderColor[1],
|
|
402
|
+
borderColor[2],
|
|
403
|
+
1
|
|
404
|
+
];
|
|
405
|
+
return borderColor;
|
|
406
|
+
})(),
|
|
407
|
+
hideAlpha: true,
|
|
408
|
+
onChange: (e) => setBorderColor((0, ol_color_js.fromString)(e))
|
|
409
|
+
}) })]
|
|
410
|
+
}),
|
|
411
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
412
|
+
className: "flex-column-gap-7",
|
|
413
|
+
children: [
|
|
414
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [strokeWidthLabel, ": "] }) }),
|
|
415
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_slider_slider_esm_js.Slider, {
|
|
416
|
+
max: 10,
|
|
417
|
+
min: 0,
|
|
418
|
+
className: "slider-wrapper",
|
|
419
|
+
value: borderThickness,
|
|
420
|
+
onChange: (e) => setBorderThickness(e.value)
|
|
421
|
+
}),
|
|
422
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [borderThickness, " px"] })
|
|
423
|
+
]
|
|
424
|
+
})
|
|
425
|
+
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
426
|
+
className: "button-wrapper",
|
|
427
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
428
|
+
label: concludeLabel,
|
|
429
|
+
onClick: () => {
|
|
430
|
+
applyRenderer({
|
|
431
|
+
type: RenderType.Unique,
|
|
432
|
+
rendererOL: createRenderUnique(color, borderColor, borderThickness)
|
|
433
|
+
});
|
|
434
|
+
setVisible(false);
|
|
435
|
+
}
|
|
436
|
+
})
|
|
437
|
+
})]
|
|
438
|
+
});
|
|
439
|
+
};
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/components/rampColors.ts
|
|
442
|
+
function getColorRampString(ramp) {
|
|
443
|
+
let rampString = "linear-gradient(90deg, ";
|
|
444
|
+
ramp.forEach((color, index) => {
|
|
445
|
+
rampString += (0, ol_color_js.asString)(color.color) + " " + color.offset * 100 + "%";
|
|
446
|
+
if (index < ramp.length - 1) rampString += ", ";
|
|
447
|
+
});
|
|
448
|
+
rampString += ")";
|
|
449
|
+
return rampString;
|
|
450
|
+
}
|
|
451
|
+
function hexToRgb(hex) {
|
|
452
|
+
return {
|
|
453
|
+
r: hex[0],
|
|
454
|
+
g: hex[1],
|
|
455
|
+
b: hex[2]
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
function rgbToHex({ r, g, b }) {
|
|
459
|
+
return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;
|
|
460
|
+
}
|
|
461
|
+
function interpolateColor(color1, color2, factor) {
|
|
462
|
+
return {
|
|
463
|
+
r: Math.round(color1.r + (color2.r - color1.r) * factor),
|
|
464
|
+
g: Math.round(color1.g + (color2.g - color1.g) * factor),
|
|
465
|
+
b: Math.round(color1.b + (color2.b - color1.b) * factor)
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
function generateGradient(stops, numberOfSteps) {
|
|
469
|
+
const rgbStops = stops.map(({ color, offset }) => ({
|
|
470
|
+
rgb: hexToRgb(color),
|
|
471
|
+
offset
|
|
472
|
+
}));
|
|
473
|
+
const start = rgbStops[0].offset;
|
|
474
|
+
const range = rgbStops[rgbStops.length - 1].offset - start;
|
|
475
|
+
const normalizedStops = rgbStops.map((stop) => ({
|
|
476
|
+
...stop,
|
|
477
|
+
normalizedPosition: (stop.offset - start) / range
|
|
478
|
+
}));
|
|
479
|
+
const result = [];
|
|
480
|
+
const stepIncrement = 1 / (numberOfSteps - 1);
|
|
481
|
+
for (let i = 0; i < numberOfSteps; i++) {
|
|
482
|
+
const stepPosition = i * stepIncrement;
|
|
483
|
+
const lowerStop = normalizedStops.find((stop) => stop.normalizedPosition <= stepPosition);
|
|
484
|
+
const upperStop = normalizedStops.find((stop) => stop.normalizedPosition >= stepPosition);
|
|
485
|
+
if (lowerStop.normalizedPosition === upperStop.normalizedPosition) result.push(rgbToHex(lowerStop.rgb));
|
|
486
|
+
else {
|
|
487
|
+
const segmentProgress = (stepPosition - lowerStop.normalizedPosition) / (upperStop.normalizedPosition - lowerStop.normalizedPosition);
|
|
488
|
+
const interpolatedColor = interpolateColor(lowerStop.rgb, upperStop.rgb, segmentProgress);
|
|
489
|
+
result.push(rgbToHex(interpolatedColor));
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return result;
|
|
493
|
+
}
|
|
494
|
+
var colorRamps = [
|
|
495
|
+
{
|
|
496
|
+
id: 0,
|
|
497
|
+
name: "Blues",
|
|
498
|
+
palette: [
|
|
499
|
+
{
|
|
500
|
+
offset: .13,
|
|
501
|
+
color: (0, ol_color_js.fromString)("rgb(222,235,247)")
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
offset: .26,
|
|
505
|
+
color: (0, ol_color_js.fromString)("rgb(198,219,239)")
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
offset: .39,
|
|
509
|
+
color: (0, ol_color_js.fromString)("rgb(158,202,225)")
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
offset: .52,
|
|
513
|
+
color: (0, ol_color_js.fromString)("rgb(107,174,214)")
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
offset: .65,
|
|
517
|
+
color: (0, ol_color_js.fromString)("rgb(66,146,198)")
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
offset: .78,
|
|
521
|
+
color: (0, ol_color_js.fromString)("rgb(33,113,181)")
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
offset: .9,
|
|
525
|
+
color: (0, ol_color_js.fromString)("rgb(8,81,156)")
|
|
526
|
+
}
|
|
527
|
+
]
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
id: 1,
|
|
531
|
+
name: "BrBG",
|
|
532
|
+
palette: [
|
|
533
|
+
{
|
|
534
|
+
offset: .25,
|
|
535
|
+
color: (0, ol_color_js.fromString)("rgb(223,194,125)")
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
offset: .5,
|
|
539
|
+
color: (0, ol_color_js.fromString)("rgb(245,245,245)")
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
offset: .75,
|
|
543
|
+
color: (0, ol_color_js.fromString)("rgb(128,205,193)")
|
|
544
|
+
}
|
|
545
|
+
]
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
id: 2,
|
|
549
|
+
name: "BuGn",
|
|
550
|
+
palette: [
|
|
551
|
+
{
|
|
552
|
+
offset: .25,
|
|
553
|
+
color: (0, ol_color_js.fromString)("rgb(178,226,226)")
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
offset: .5,
|
|
557
|
+
color: (0, ol_color_js.fromString)("rgb(102,194,164)")
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
offset: .75,
|
|
561
|
+
color: (0, ol_color_js.fromString)("rgb(44,162,95)")
|
|
562
|
+
}
|
|
563
|
+
]
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
id: 3,
|
|
567
|
+
name: "BuPu",
|
|
568
|
+
palette: [
|
|
569
|
+
{
|
|
570
|
+
offset: .25,
|
|
571
|
+
color: (0, ol_color_js.fromString)("rgb(179,205,227)")
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
offset: .5,
|
|
575
|
+
color: (0, ol_color_js.fromString)("rgb(140,150,198)")
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
offset: .75,
|
|
579
|
+
color: (0, ol_color_js.fromString)("rgb(136,86,167)")
|
|
580
|
+
}
|
|
581
|
+
]
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
id: 4,
|
|
585
|
+
name: "GnBu",
|
|
586
|
+
palette: [
|
|
587
|
+
{
|
|
588
|
+
offset: .25,
|
|
589
|
+
color: (0, ol_color_js.fromString)("rgb(186,228,188)")
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
offset: .5,
|
|
593
|
+
color: (0, ol_color_js.fromString)("rgb(123,204,196)")
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
offset: .75,
|
|
597
|
+
color: (0, ol_color_js.fromString)("rgb(67,162,202)")
|
|
598
|
+
}
|
|
599
|
+
]
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
id: 5,
|
|
603
|
+
name: "Greens",
|
|
604
|
+
palette: [
|
|
605
|
+
{
|
|
606
|
+
offset: .13,
|
|
607
|
+
color: (0, ol_color_js.fromString)("rgb(229,245,224)")
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
offset: .26,
|
|
611
|
+
color: (0, ol_color_js.fromString)("rgb(199,233,192)")
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
offset: .39,
|
|
615
|
+
color: (0, ol_color_js.fromString)("rgb(161,217,155)")
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
offset: .52,
|
|
619
|
+
color: (0, ol_color_js.fromString)("rgb(116,196,118)")
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
offset: .65,
|
|
623
|
+
color: (0, ol_color_js.fromString)("rgb(65,171,93)")
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
offset: .78,
|
|
627
|
+
color: (0, ol_color_js.fromString)("rgb(35,139,69)")
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
offset: .9,
|
|
631
|
+
color: (0, ol_color_js.fromString)("rgb(0,109,44)")
|
|
632
|
+
}
|
|
633
|
+
]
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
id: 6,
|
|
637
|
+
name: "Greys",
|
|
638
|
+
palette: [{
|
|
639
|
+
offset: 0,
|
|
640
|
+
color: (0, ol_color_js.fromString)("rgb(250,250,250)")
|
|
641
|
+
}, {
|
|
642
|
+
offset: 1,
|
|
643
|
+
color: (0, ol_color_js.fromString)("rgb(5,5,5)")
|
|
644
|
+
}]
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
id: 7,
|
|
648
|
+
name: "OrRd",
|
|
649
|
+
palette: [
|
|
650
|
+
{
|
|
651
|
+
offset: .25,
|
|
652
|
+
color: (0, ol_color_js.fromString)("rgb(253,204,138)")
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
offset: .5,
|
|
656
|
+
color: (0, ol_color_js.fromString)("rgb(252,141,89)")
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
offset: .75,
|
|
660
|
+
color: (0, ol_color_js.fromString)("rgb(227,74,51)")
|
|
661
|
+
}
|
|
662
|
+
]
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
id: 8,
|
|
666
|
+
name: "Oranges",
|
|
667
|
+
palette: [
|
|
668
|
+
{
|
|
669
|
+
offset: .13,
|
|
670
|
+
color: (0, ol_color_js.fromString)("rgb(254,230,206)")
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
offset: .26,
|
|
674
|
+
color: (0, ol_color_js.fromString)("rgb(253,208,162)")
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
offset: .39,
|
|
678
|
+
color: (0, ol_color_js.fromString)("rgb(253,174,107)")
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
offset: .52,
|
|
682
|
+
color: (0, ol_color_js.fromString)("rgb(253,141,60)")
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
offset: .65,
|
|
686
|
+
color: (0, ol_color_js.fromString)("rgb(241,105,19)")
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
offset: .78,
|
|
690
|
+
color: (0, ol_color_js.fromString)("rgb(217,72,1)")
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
offset: .9,
|
|
694
|
+
color: (0, ol_color_js.fromString)("rgb(166,54,3)")
|
|
695
|
+
}
|
|
696
|
+
]
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
id: 9,
|
|
700
|
+
name: "PRGn",
|
|
701
|
+
palette: [
|
|
702
|
+
{
|
|
703
|
+
offset: .25,
|
|
704
|
+
color: (0, ol_color_js.fromString)("rgb(194,165,207)")
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
offset: .5,
|
|
708
|
+
color: (0, ol_color_js.fromString)("rgb(247,247,247)")
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
offset: .75,
|
|
712
|
+
color: (0, ol_color_js.fromString)("rgb(166,219,160)")
|
|
713
|
+
}
|
|
714
|
+
]
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
id: 10,
|
|
718
|
+
name: "PiYG",
|
|
719
|
+
palette: [
|
|
720
|
+
{
|
|
721
|
+
offset: .25,
|
|
722
|
+
color: (0, ol_color_js.fromString)("rgb(241,182,218)")
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
offset: .5,
|
|
726
|
+
color: (0, ol_color_js.fromString)("rgb(247,247,247)")
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
offset: .75,
|
|
730
|
+
color: (0, ol_color_js.fromString)("rgb(184,225,134)")
|
|
731
|
+
}
|
|
732
|
+
]
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
id: 11,
|
|
736
|
+
name: "PuBu",
|
|
737
|
+
palette: [
|
|
738
|
+
{
|
|
739
|
+
offset: .25,
|
|
740
|
+
color: (0, ol_color_js.fromString)("rgb(189,201,225)")
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
offset: .5,
|
|
744
|
+
color: (0, ol_color_js.fromString)("rgb(116,169,207)")
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
offset: .75,
|
|
748
|
+
color: (0, ol_color_js.fromString)("rgb(43,140,190)")
|
|
749
|
+
}
|
|
750
|
+
]
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
id: 12,
|
|
754
|
+
name: "PuBuGn",
|
|
755
|
+
palette: [
|
|
756
|
+
{
|
|
757
|
+
offset: .25,
|
|
758
|
+
color: (0, ol_color_js.fromString)("rgb(189,201,225)")
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
offset: .5,
|
|
762
|
+
color: (0, ol_color_js.fromString)("rgb(103,169,207)")
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
offset: .75,
|
|
766
|
+
color: (0, ol_color_js.fromString)("rgb(28,144,153)")
|
|
767
|
+
}
|
|
768
|
+
]
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
id: 13,
|
|
772
|
+
name: "PuOr",
|
|
773
|
+
palette: [
|
|
774
|
+
{
|
|
775
|
+
offset: .25,
|
|
776
|
+
color: (0, ol_color_js.fromString)("rgb(230,97,1)")
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
offset: .5,
|
|
780
|
+
color: (0, ol_color_js.fromString)("rgb(94,60,153)")
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
offset: .75,
|
|
784
|
+
color: (0, ol_color_js.fromString)("rgb(178,171,210)")
|
|
785
|
+
}
|
|
786
|
+
]
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
id: 14,
|
|
790
|
+
name: "PuRd",
|
|
791
|
+
palette: [
|
|
792
|
+
{
|
|
793
|
+
offset: .25,
|
|
794
|
+
color: (0, ol_color_js.fromString)("rgb(215,181,216)")
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
offset: .5,
|
|
798
|
+
color: (0, ol_color_js.fromString)("rgb(223,101,176)")
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
offset: .75,
|
|
802
|
+
color: (0, ol_color_js.fromString)("rgb(221,28,119)")
|
|
803
|
+
}
|
|
804
|
+
]
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
id: 15,
|
|
808
|
+
name: "Purples",
|
|
809
|
+
palette: [
|
|
810
|
+
{
|
|
811
|
+
offset: .13,
|
|
812
|
+
color: (0, ol_color_js.fromString)("rgb(239,237,245)")
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
offset: .26,
|
|
816
|
+
color: (0, ol_color_js.fromString)("rgb(218,218,235)")
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
offset: .39,
|
|
820
|
+
color: (0, ol_color_js.fromString)("rgb(188,189,220)")
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
offset: .52,
|
|
824
|
+
color: (0, ol_color_js.fromString)("rgb(158,154,200)")
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
offset: .65,
|
|
828
|
+
color: (0, ol_color_js.fromString)("rgb(128,125,186)")
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
offset: .75,
|
|
832
|
+
color: (0, ol_color_js.fromString)("rgb(106,81,163)")
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
offset: .9,
|
|
836
|
+
color: (0, ol_color_js.fromString)("rgb(84,39,143)")
|
|
837
|
+
}
|
|
838
|
+
]
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
id: 16,
|
|
842
|
+
name: "RdBu",
|
|
843
|
+
palette: [
|
|
844
|
+
{
|
|
845
|
+
offset: .25,
|
|
846
|
+
color: (0, ol_color_js.fromString)("rgb(244,165,130)")
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
offset: .5,
|
|
850
|
+
color: (0, ol_color_js.fromString)("rgb(247,247,247)")
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
offset: .75,
|
|
854
|
+
color: (0, ol_color_js.fromString)("rgb(146,197,222)")
|
|
855
|
+
}
|
|
856
|
+
]
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
id: 17,
|
|
860
|
+
name: "RdGy",
|
|
861
|
+
palette: [
|
|
862
|
+
{
|
|
863
|
+
offset: .25,
|
|
864
|
+
color: (0, ol_color_js.fromString)("rgb(244,165,130)")
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
offset: .5,
|
|
868
|
+
color: (0, ol_color_js.fromString)("rgb(255,255,255)")
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
offset: .75,
|
|
872
|
+
color: (0, ol_color_js.fromString)("rgb(186,186,186)")
|
|
873
|
+
}
|
|
874
|
+
]
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
id: 18,
|
|
878
|
+
name: "RdPu",
|
|
879
|
+
palette: [
|
|
880
|
+
{
|
|
881
|
+
offset: .25,
|
|
882
|
+
color: (0, ol_color_js.fromString)("rgb(253,180,185)")
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
offset: .5,
|
|
886
|
+
color: (0, ol_color_js.fromString)("rgb(247,104,161)")
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
offset: .75,
|
|
890
|
+
color: (0, ol_color_js.fromString)("rgb(197,27,138)")
|
|
891
|
+
}
|
|
892
|
+
]
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
id: 19,
|
|
896
|
+
name: "RdYlBu",
|
|
897
|
+
palette: [
|
|
898
|
+
{
|
|
899
|
+
offset: .25,
|
|
900
|
+
color: (0, ol_color_js.fromString)("rgb(253,184,99)")
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
offset: .5,
|
|
904
|
+
color: (0, ol_color_js.fromString)("rgb(255,255,191)")
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
offset: .75,
|
|
908
|
+
color: (0, ol_color_js.fromString)("rgb(171,217,233)")
|
|
909
|
+
}
|
|
910
|
+
]
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
id: 20,
|
|
914
|
+
name: "RdYlGn",
|
|
915
|
+
palette: [
|
|
916
|
+
{
|
|
917
|
+
offset: .25,
|
|
918
|
+
color: (0, ol_color_js.fromString)("rgb(253,174,97)")
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
offset: .5,
|
|
922
|
+
color: (0, ol_color_js.fromString)("rgb(255,255,192)")
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
offset: .75,
|
|
926
|
+
color: (0, ol_color_js.fromString)("rgb(166,217,106)")
|
|
927
|
+
}
|
|
928
|
+
]
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
id: 21,
|
|
932
|
+
name: "Reds",
|
|
933
|
+
palette: [
|
|
934
|
+
{
|
|
935
|
+
offset: .13,
|
|
936
|
+
color: (0, ol_color_js.fromString)("rgb(254,224,210)")
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
offset: .26,
|
|
940
|
+
color: (0, ol_color_js.fromString)("rgb(252,187,161)")
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
offset: .39,
|
|
944
|
+
color: (0, ol_color_js.fromString)("rgb(252,146,114)")
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
offset: .52,
|
|
948
|
+
color: (0, ol_color_js.fromString)("rgb(251,106,74)")
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
offset: .65,
|
|
952
|
+
color: (0, ol_color_js.fromString)("rgb(239,59,44)")
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
offset: .78,
|
|
956
|
+
color: (0, ol_color_js.fromString)("rgb(203,24,29)")
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
offset: .9,
|
|
960
|
+
color: (0, ol_color_js.fromString)("rgb(165,15,21)")
|
|
961
|
+
}
|
|
962
|
+
]
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
id: 22,
|
|
966
|
+
name: "Spectral",
|
|
967
|
+
palette: [
|
|
968
|
+
{
|
|
969
|
+
offset: .25,
|
|
970
|
+
color: (0, ol_color_js.fromString)("rgb(253,174,97)")
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
offset: .5,
|
|
974
|
+
color: (0, ol_color_js.fromString)("rgb(255,255,191)")
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
offset: .75,
|
|
978
|
+
color: (0, ol_color_js.fromString)("rgb(171,221,164)")
|
|
979
|
+
}
|
|
980
|
+
]
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
id: 23,
|
|
984
|
+
name: "YlGn",
|
|
985
|
+
palette: [
|
|
986
|
+
{
|
|
987
|
+
offset: .25,
|
|
988
|
+
color: (0, ol_color_js.fromString)("rgb(194,230,153)")
|
|
989
|
+
},
|
|
990
|
+
{
|
|
991
|
+
offset: .5,
|
|
992
|
+
color: (0, ol_color_js.fromString)("rgb(120,198,121)")
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
offset: .75,
|
|
996
|
+
color: (0, ol_color_js.fromString)("rgb(49,163,84)")
|
|
997
|
+
}
|
|
998
|
+
]
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
id: 24,
|
|
1002
|
+
name: "YlGnBu",
|
|
1003
|
+
palette: [
|
|
1004
|
+
{
|
|
1005
|
+
offset: .25,
|
|
1006
|
+
color: (0, ol_color_js.fromString)("rgb(161,218,180)")
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
offset: .5,
|
|
1010
|
+
color: (0, ol_color_js.fromString)("rgb(65,182,196)")
|
|
1011
|
+
},
|
|
1012
|
+
{
|
|
1013
|
+
offset: .75,
|
|
1014
|
+
color: (0, ol_color_js.fromString)("rgb(44,127,184)")
|
|
1015
|
+
}
|
|
1016
|
+
]
|
|
1017
|
+
},
|
|
1018
|
+
{
|
|
1019
|
+
id: 25,
|
|
1020
|
+
name: "YlOrBr",
|
|
1021
|
+
palette: [
|
|
1022
|
+
{
|
|
1023
|
+
offset: .25,
|
|
1024
|
+
color: (0, ol_color_js.fromString)("rgb(254,217,142)")
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
offset: .5,
|
|
1028
|
+
color: (0, ol_color_js.fromString)("rgb(254,153,41)")
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
offset: .75,
|
|
1032
|
+
color: (0, ol_color_js.fromString)("rgb(217,95,14)")
|
|
1033
|
+
}
|
|
1034
|
+
]
|
|
1035
|
+
},
|
|
1036
|
+
{
|
|
1037
|
+
id: 26,
|
|
1038
|
+
name: "YlOrRd",
|
|
1039
|
+
palette: [
|
|
1040
|
+
{
|
|
1041
|
+
offset: .25,
|
|
1042
|
+
color: (0, ol_color_js.fromString)("rgb(254,204,92)")
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
offset: .5,
|
|
1046
|
+
color: (0, ol_color_js.fromString)("rgb(253,141,60)")
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
offset: .75,
|
|
1050
|
+
color: (0, ol_color_js.fromString)("rgb(240,59,32)")
|
|
1051
|
+
}
|
|
1052
|
+
]
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
id: 27,
|
|
1056
|
+
name: "Semaphore",
|
|
1057
|
+
palette: [
|
|
1058
|
+
{
|
|
1059
|
+
offset: .1,
|
|
1060
|
+
color: (0, ol_color_js.fromString)("rgb(215,48,39)")
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
offset: .3,
|
|
1064
|
+
color: (0, ol_color_js.fromString)("rgb(252,141,89)")
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
offset: .5,
|
|
1068
|
+
color: (0, ol_color_js.fromString)("rgb(218,225,12)")
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
offset: .7,
|
|
1072
|
+
color: (0, ol_color_js.fromString)("rgb(145,207,96)")
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
offset: .9,
|
|
1076
|
+
color: (0, ol_color_js.fromString)("rgb(26,152,80)")
|
|
1077
|
+
}
|
|
1078
|
+
]
|
|
1079
|
+
}
|
|
1080
|
+
];
|
|
1081
|
+
//#endregion
|
|
1082
|
+
//#region src/components/categorized.tsx
|
|
1083
|
+
var Categorized = (props) => {
|
|
1084
|
+
const { attr, layerCurrentRenderer, showPreDefinedRamps, predefinedStyles, moreRamps, applyRenderer, setVisible } = props;
|
|
1085
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
1086
|
+
const nullText = t("common.null");
|
|
1087
|
+
const errorRamps = t("errors.error_ramps_same_name");
|
|
1088
|
+
const predefinedStylesLabel = t("categorized.predefined_styles");
|
|
1089
|
+
const colorRampLabel = t("categorized.color_ramps");
|
|
1090
|
+
const strokeColorLabel = t("categorized.stroke_color");
|
|
1091
|
+
const strokeWidthLabel = t("categorized.stroke_width");
|
|
1092
|
+
const attributeLabel = t("categorized.attribute");
|
|
1093
|
+
const selectAttributeLabel = t("categorized.select_attribute");
|
|
1094
|
+
const updateColorsLabel = t("categorized.update_colors");
|
|
1095
|
+
const colorOpacityLabel = t("categorized.color_opacity");
|
|
1096
|
+
const selectSpectrumLabel = t("categorized.select_spectrum");
|
|
1097
|
+
const concludeLabel = t("common.conclude");
|
|
1098
|
+
const colorLabel = t("graduated.color");
|
|
1099
|
+
const customStyleLabel = t("categorized.custom_style");
|
|
1100
|
+
const valueLabel = t("graduated.value");
|
|
1101
|
+
const reverseColorsLabel = t("categorized.reverse_colors");
|
|
1102
|
+
const colorStyleLabel = t("categorized.color_style");
|
|
1103
|
+
const currentRender = layerCurrentRenderer.type != RenderType.Categorized ? [] : layerCurrentRenderer.rendererOL["fill-color"];
|
|
1104
|
+
const valuesAndColors = [];
|
|
1105
|
+
for (let i = 2; i < currentRender.length - 1; i += 2) valuesAndColors.push({
|
|
1106
|
+
value: currentRender[i],
|
|
1107
|
+
color: currentRender[i + 1],
|
|
1108
|
+
visible: true
|
|
1109
|
+
});
|
|
1110
|
+
if (currentRender.length > 0) valuesAndColors.push({
|
|
1111
|
+
value: nullText,
|
|
1112
|
+
color: currentRender[currentRender.length - 1],
|
|
1113
|
+
visible: true
|
|
1114
|
+
});
|
|
1115
|
+
const stroke = getRendererColorAndSizeStroke(layerCurrentRenderer);
|
|
1116
|
+
const [selectedSpectrumColors, setSelectedSpectrumColors] = (0, react.useState)({
|
|
1117
|
+
label: customStyleLabel,
|
|
1118
|
+
value: []
|
|
1119
|
+
});
|
|
1120
|
+
const [table, setTable] = (0, react.useState)(valuesAndColors);
|
|
1121
|
+
const [selectedAttr, setSelectedAttr] = (0, react.useState)(layerCurrentRenderer.field ? attr.find((at) => at.name == layerCurrentRenderer.field) : void 0);
|
|
1122
|
+
const [rowClick] = (0, react.useState)(false);
|
|
1123
|
+
const currentStyle = layerCurrentRenderer.type != RenderType.Categorized ? null : layerCurrentRenderer.rendererOL;
|
|
1124
|
+
const [borderColor, setBorderColor] = (0, react.useState)(currentStyle ? stroke.color : (0, ol_color_js.fromString)("#000000"));
|
|
1125
|
+
const [borderThickness, setBorderThickness] = (0, react.useState)(currentStyle ? stroke.size : 1);
|
|
1126
|
+
const [fillOpacity, setFillOpacity] = (0, react.useState)(currentStyle ? getRendererOpacity(layerCurrentRenderer) : 100);
|
|
1127
|
+
const [isReversed, setIsReversed] = (0, react.useState)(false);
|
|
1128
|
+
let allRamps;
|
|
1129
|
+
if (showPreDefinedRamps) if (moreRamps) allRamps = moreRamps.concat(colorRamps);
|
|
1130
|
+
else allRamps = colorRamps;
|
|
1131
|
+
else if (moreRamps) allRamps = moreRamps;
|
|
1132
|
+
else allRamps = [];
|
|
1133
|
+
const existingRenderers = allRamps.filter((ramp, _index, self) => self.filter((r) => r.name === ramp.name).length > 1);
|
|
1134
|
+
if (existingRenderers.length > 0) {
|
|
1135
|
+
console.error(errorRamps + existingRenderers.map((ramp) => ramp.name));
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
const preDefinedPalettes = [
|
|
1139
|
+
{
|
|
1140
|
+
label: customStyleLabel,
|
|
1141
|
+
items: [{
|
|
1142
|
+
label: customStyleLabel,
|
|
1143
|
+
value: {
|
|
1144
|
+
label: customStyleLabel,
|
|
1145
|
+
value: []
|
|
1146
|
+
}
|
|
1147
|
+
}]
|
|
1148
|
+
},
|
|
1149
|
+
{
|
|
1150
|
+
label: predefinedStylesLabel,
|
|
1151
|
+
items: predefinedStyles.map((renderer) => {
|
|
1152
|
+
return {
|
|
1153
|
+
label: renderer.name,
|
|
1154
|
+
value: {
|
|
1155
|
+
label: renderer.name,
|
|
1156
|
+
value: renderer.renderer
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
})
|
|
1160
|
+
},
|
|
1161
|
+
{
|
|
1162
|
+
label: colorRampLabel,
|
|
1163
|
+
items: allRamps.map((ramp) => {
|
|
1164
|
+
return {
|
|
1165
|
+
label: ramp.name,
|
|
1166
|
+
value: {
|
|
1167
|
+
label: ramp.name,
|
|
1168
|
+
value: ramp.palette
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
})
|
|
1172
|
+
}
|
|
1173
|
+
];
|
|
1174
|
+
const itemTemplate = (option) => {
|
|
1175
|
+
if (option.value.value.length > 0 && "offset" in option.value.value[0]) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1176
|
+
style: {
|
|
1177
|
+
display: "flex",
|
|
1178
|
+
gap: "3px",
|
|
1179
|
+
alignItems: "center"
|
|
1180
|
+
},
|
|
1181
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: {
|
|
1182
|
+
background: getColorRampString(option.value.value),
|
|
1183
|
+
width: "90px",
|
|
1184
|
+
height: "20px"
|
|
1185
|
+
} }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: option.label })]
|
|
1186
|
+
});
|
|
1187
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: option.label });
|
|
1188
|
+
};
|
|
1189
|
+
const visibleColumnTemplate = (tr) => {
|
|
1190
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_checkbox_checkbox_esm_js.Checkbox, { checked: tr.visible });
|
|
1191
|
+
};
|
|
1192
|
+
const updateColorPicker = (newColor, tableRow) => {
|
|
1193
|
+
const tableUpdated = [];
|
|
1194
|
+
table.forEach(({ value, visible, color }) => {
|
|
1195
|
+
if (value === tableRow.value) tableUpdated.push({
|
|
1196
|
+
value,
|
|
1197
|
+
visible,
|
|
1198
|
+
color: newColor
|
|
1199
|
+
});
|
|
1200
|
+
else tableUpdated.push({
|
|
1201
|
+
value,
|
|
1202
|
+
visible,
|
|
1203
|
+
color
|
|
1204
|
+
});
|
|
1205
|
+
});
|
|
1206
|
+
setTable(tableUpdated);
|
|
1207
|
+
};
|
|
1208
|
+
const colorColumnTemplate = (tr) => {
|
|
1209
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1210
|
+
hidden: !tr.visible,
|
|
1211
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MyColorPicker, {
|
|
1212
|
+
onChange: (e) => updateColorPicker((0, ol_color_js.fromString)(e), tr),
|
|
1213
|
+
color: tr.color
|
|
1214
|
+
})
|
|
1215
|
+
});
|
|
1216
|
+
};
|
|
1217
|
+
function updateColorsByColorRamp(colorRampInput, reversed) {
|
|
1218
|
+
const colorRamp = {
|
|
1219
|
+
label: colorRampInput.label,
|
|
1220
|
+
value: [...colorRampInput.value]
|
|
1221
|
+
};
|
|
1222
|
+
if (reversed) colorRamp.value.reverse();
|
|
1223
|
+
if (colorRamp.value.length > 0 && "offset" in colorRamp.value[0]) {
|
|
1224
|
+
const colors = generateGradient(colorRamp.value.map((stop) => ({
|
|
1225
|
+
offset: stop.offset,
|
|
1226
|
+
color: stop.color
|
|
1227
|
+
})), table.filter((row) => row.visible).length);
|
|
1228
|
+
const tableUpdated = [];
|
|
1229
|
+
let i = 0;
|
|
1230
|
+
table.forEach(({ value, visible }) => {
|
|
1231
|
+
if (visible) tableUpdated.push({
|
|
1232
|
+
value,
|
|
1233
|
+
visible,
|
|
1234
|
+
color: (0, ol_color_js.fromString)(colors[i++])
|
|
1235
|
+
});
|
|
1236
|
+
else tableUpdated.push({
|
|
1237
|
+
value,
|
|
1238
|
+
visible,
|
|
1239
|
+
color: (0, ol_color_js.fromString)("white")
|
|
1240
|
+
});
|
|
1241
|
+
});
|
|
1242
|
+
setTable(tableUpdated);
|
|
1243
|
+
} else if (colorRamp.value.length > 0) {
|
|
1244
|
+
const colors = getStyleColorsAndValues(getCategorizedStyle(selectedAttr?.name, colorRamp.value), RenderType.Categorized);
|
|
1245
|
+
const tableUpdated = [];
|
|
1246
|
+
table.forEach(({ value, visible }) => {
|
|
1247
|
+
const color = colors.find((c) => c.value == value);
|
|
1248
|
+
if (color) tableUpdated.push({
|
|
1249
|
+
value,
|
|
1250
|
+
visible,
|
|
1251
|
+
color: color.color
|
|
1252
|
+
});
|
|
1253
|
+
else tableUpdated.push({
|
|
1254
|
+
value,
|
|
1255
|
+
visible,
|
|
1256
|
+
color: (0, ol_color_js.fromString)("white")
|
|
1257
|
+
});
|
|
1258
|
+
});
|
|
1259
|
+
setTable(tableUpdated);
|
|
1260
|
+
} else {
|
|
1261
|
+
const tableUpdated = [];
|
|
1262
|
+
table.forEach(({ value, visible }) => {
|
|
1263
|
+
tableUpdated.push({
|
|
1264
|
+
value,
|
|
1265
|
+
visible,
|
|
1266
|
+
color: generateRandomColor()
|
|
1267
|
+
});
|
|
1268
|
+
});
|
|
1269
|
+
setTable(tableUpdated);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
function revertColors() {
|
|
1273
|
+
setIsReversed(!isReversed);
|
|
1274
|
+
updateColorsByColorRamp(selectedSpectrumColors, !isReversed);
|
|
1275
|
+
}
|
|
1276
|
+
function changeColorsOfValues(e) {
|
|
1277
|
+
const colorRamp = e;
|
|
1278
|
+
setIsReversed(false);
|
|
1279
|
+
setSelectedSpectrumColors(colorRamp);
|
|
1280
|
+
updateColorsByColorRamp(colorRamp, false);
|
|
1281
|
+
}
|
|
1282
|
+
function changeAttribute(e) {
|
|
1283
|
+
let attribute = attr.find((a) => a.name == e.value.name);
|
|
1284
|
+
setSelectedAttr(attribute);
|
|
1285
|
+
setSelectedSpectrumColors({
|
|
1286
|
+
label: customStyleLabel,
|
|
1287
|
+
value: []
|
|
1288
|
+
});
|
|
1289
|
+
let tableValues = [];
|
|
1290
|
+
attribute.values.forEach((value) => {
|
|
1291
|
+
if (value && value != "") tableValues.push({
|
|
1292
|
+
visible: true,
|
|
1293
|
+
value,
|
|
1294
|
+
color: generateRandomColor()
|
|
1295
|
+
});
|
|
1296
|
+
});
|
|
1297
|
+
tableValues.push({
|
|
1298
|
+
value: nullText,
|
|
1299
|
+
color: generateRandomColor(),
|
|
1300
|
+
visible: true
|
|
1301
|
+
});
|
|
1302
|
+
setTable(tableValues);
|
|
1303
|
+
}
|
|
1304
|
+
const changeVisibility = (trs) => {
|
|
1305
|
+
let tableValues = [];
|
|
1306
|
+
table.forEach((tr) => {
|
|
1307
|
+
let found = trs.some((trs) => trs === tr);
|
|
1308
|
+
tableValues.push({
|
|
1309
|
+
value: tr.value,
|
|
1310
|
+
visible: found,
|
|
1311
|
+
color: found ? tr.color : [
|
|
1312
|
+
0,
|
|
1313
|
+
0,
|
|
1314
|
+
0,
|
|
1315
|
+
0
|
|
1316
|
+
]
|
|
1317
|
+
});
|
|
1318
|
+
});
|
|
1319
|
+
setTable(tableValues);
|
|
1320
|
+
};
|
|
1321
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1322
|
+
className: "categorized-container",
|
|
1323
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1324
|
+
className: "attribute-container",
|
|
1325
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1326
|
+
style: { width: "auto" },
|
|
1327
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [attributeLabel, ":"] })
|
|
1328
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dropdown_dropdown_esm_js.Dropdown, {
|
|
1329
|
+
value: selectedAttr,
|
|
1330
|
+
onChange: (e) => changeAttribute(e),
|
|
1331
|
+
options: attr,
|
|
1332
|
+
optionLabel: "name",
|
|
1333
|
+
itemTemplate: (option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
1334
|
+
option.name,
|
|
1335
|
+
" (",
|
|
1336
|
+
option.values.length,
|
|
1337
|
+
")"
|
|
1338
|
+
] }),
|
|
1339
|
+
placeholder: selectAttributeLabel
|
|
1340
|
+
})]
|
|
1341
|
+
}), table.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
1342
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1343
|
+
className: "stroke-row",
|
|
1344
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1345
|
+
className: "stroke-color-container",
|
|
1346
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [strokeColorLabel, ":"] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MyColorPicker, {
|
|
1347
|
+
color: (() => {
|
|
1348
|
+
if (borderColor.at(3) < 1) return [
|
|
1349
|
+
borderColor[0],
|
|
1350
|
+
borderColor[1],
|
|
1351
|
+
borderColor[2],
|
|
1352
|
+
1
|
|
1353
|
+
];
|
|
1354
|
+
return borderColor;
|
|
1355
|
+
})(),
|
|
1356
|
+
hideAlpha: true,
|
|
1357
|
+
onChange: (e) => setBorderColor((0, ol_color_js.fromString)(e))
|
|
1358
|
+
}) })]
|
|
1359
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1360
|
+
className: "stroke-width-container",
|
|
1361
|
+
children: [
|
|
1362
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [strokeWidthLabel, ":"] }) }),
|
|
1363
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_slider_slider_esm_js.Slider, {
|
|
1364
|
+
max: 10,
|
|
1365
|
+
min: 0,
|
|
1366
|
+
className: "stroke-slider",
|
|
1367
|
+
value: borderThickness,
|
|
1368
|
+
onChange: (e) => setBorderThickness(e.value)
|
|
1369
|
+
}),
|
|
1370
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [borderThickness, " px"] })
|
|
1371
|
+
]
|
|
1372
|
+
})]
|
|
1373
|
+
}),
|
|
1374
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1375
|
+
className: "opacity-container",
|
|
1376
|
+
children: [
|
|
1377
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [colorOpacityLabel, ":"] }) }),
|
|
1378
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_slider_slider_esm_js.Slider, {
|
|
1379
|
+
max: 100,
|
|
1380
|
+
min: 0,
|
|
1381
|
+
className: "opacity-slider",
|
|
1382
|
+
value: fillOpacity,
|
|
1383
|
+
onChange: (e) => {
|
|
1384
|
+
setFillOpacity(e.value);
|
|
1385
|
+
setTable([...table].map((tr) => {
|
|
1386
|
+
let aux2 = [];
|
|
1387
|
+
aux2.push(tr.color[0]);
|
|
1388
|
+
aux2.push(tr.color[1]);
|
|
1389
|
+
aux2.push(tr.color[2]);
|
|
1390
|
+
aux2.push(e.value / 100);
|
|
1391
|
+
return {
|
|
1392
|
+
...tr,
|
|
1393
|
+
color: aux2
|
|
1394
|
+
};
|
|
1395
|
+
}));
|
|
1396
|
+
}
|
|
1397
|
+
}),
|
|
1398
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [fillOpacity, "%"] })
|
|
1399
|
+
]
|
|
1400
|
+
}),
|
|
1401
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1402
|
+
className: "spectrum-container",
|
|
1403
|
+
children: [
|
|
1404
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1405
|
+
style: { width: "auto" },
|
|
1406
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [colorStyleLabel, ":"] })
|
|
1407
|
+
}),
|
|
1408
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dropdown_dropdown_esm_js.Dropdown, {
|
|
1409
|
+
value: selectedSpectrumColors,
|
|
1410
|
+
options: preDefinedPalettes,
|
|
1411
|
+
onChange: (e) => changeColorsOfValues(e.value),
|
|
1412
|
+
placeholder: selectSpectrumLabel,
|
|
1413
|
+
optionLabel: "label",
|
|
1414
|
+
optionGroupLabel: "label",
|
|
1415
|
+
itemTemplate
|
|
1416
|
+
}),
|
|
1417
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
1418
|
+
text: true,
|
|
1419
|
+
icon: "pi pi-refresh",
|
|
1420
|
+
disabled: !selectedSpectrumColors,
|
|
1421
|
+
tooltip: updateColorsLabel,
|
|
1422
|
+
onClick: () => updateColorsByColorRamp(selectedSpectrumColors, isReversed)
|
|
1423
|
+
}),
|
|
1424
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
1425
|
+
text: true,
|
|
1426
|
+
icon: "pi pi-arrow-right-arrow-left",
|
|
1427
|
+
disabled: !selectedSpectrumColors,
|
|
1428
|
+
tooltip: reverseColorsLabel,
|
|
1429
|
+
onClick: () => revertColors()
|
|
1430
|
+
})
|
|
1431
|
+
]
|
|
1432
|
+
}),
|
|
1433
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1434
|
+
className: "table-container",
|
|
1435
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(primereact_datatable_datatable_esm_js.DataTable, {
|
|
1436
|
+
value: table,
|
|
1437
|
+
selectionMode: rowClick ? null : "checkbox",
|
|
1438
|
+
tableStyle: { minWidth: "25rem" },
|
|
1439
|
+
selection: table.filter((tr) => tr.visible),
|
|
1440
|
+
onSelectionChange: (event) => {
|
|
1441
|
+
const value = event.value;
|
|
1442
|
+
changeVisibility(value);
|
|
1443
|
+
},
|
|
1444
|
+
reorderableRows: true,
|
|
1445
|
+
onRowReorder: (e) => setTable(e.value),
|
|
1446
|
+
children: [
|
|
1447
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_column_column_esm_js.Column, {
|
|
1448
|
+
rowReorder: true,
|
|
1449
|
+
style: { width: "3rem" }
|
|
1450
|
+
}),
|
|
1451
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_column_column_esm_js.Column, {
|
|
1452
|
+
selectionMode: "multiple",
|
|
1453
|
+
field: "visible",
|
|
1454
|
+
body: visibleColumnTemplate
|
|
1455
|
+
}),
|
|
1456
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_column_column_esm_js.Column, {
|
|
1457
|
+
field: "color",
|
|
1458
|
+
header: colorLabel,
|
|
1459
|
+
body: colorColumnTemplate
|
|
1460
|
+
}),
|
|
1461
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_column_column_esm_js.Column, {
|
|
1462
|
+
field: "value",
|
|
1463
|
+
header: valueLabel,
|
|
1464
|
+
sortable: true
|
|
1465
|
+
})
|
|
1466
|
+
]
|
|
1467
|
+
})
|
|
1468
|
+
})
|
|
1469
|
+
] })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1470
|
+
className: "footer-container",
|
|
1471
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
1472
|
+
label: concludeLabel,
|
|
1473
|
+
onClick: () => {
|
|
1474
|
+
applyRenderer({
|
|
1475
|
+
type: RenderType.Categorized,
|
|
1476
|
+
field: selectedAttr?.name,
|
|
1477
|
+
rendererOL: getCategorizedStyle(selectedAttr?.name, table.filter((row) => row.value != nullText && row.visible).map((tr) => ({
|
|
1478
|
+
value: tr.value,
|
|
1479
|
+
color: tr.color
|
|
1480
|
+
})), borderColor, borderThickness, table.find((row) => row.value == nullText).color)
|
|
1481
|
+
});
|
|
1482
|
+
setVisible(false);
|
|
1483
|
+
}
|
|
1484
|
+
})
|
|
1485
|
+
})]
|
|
1486
|
+
});
|
|
1487
|
+
};
|
|
1488
|
+
//#endregion
|
|
1489
|
+
//#region src/components/graduated.tsx
|
|
1490
|
+
var Graduated = (props) => {
|
|
1491
|
+
const { attr, applyRenderer, setVisible, layerCurrentRenderer, moreRamps, showPreDefinedRamps, numbersLocale } = props;
|
|
1492
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
1493
|
+
const errorRamps = t("errors.error_ramps_same_name");
|
|
1494
|
+
const colorRampLabel = t("categorized.color_ramps");
|
|
1495
|
+
const errorDiffLabel = t("errors.error_diff");
|
|
1496
|
+
const errorSumLabel = t("errors.error_sum");
|
|
1497
|
+
const errorSum2Label = t("errors.error_sum2");
|
|
1498
|
+
const amountValuesLabel = t("graduated.amount_values");
|
|
1499
|
+
const valuesLabel = t("graduated.values");
|
|
1500
|
+
const amountLabel = t("graduated.amount");
|
|
1501
|
+
const attributeLabel = t("categorized.attribute");
|
|
1502
|
+
const selectAttributeLabel = t("categorized.select_attribute");
|
|
1503
|
+
const selectModeLabel = t("graduated.select_mode");
|
|
1504
|
+
const whichModeLabel = t("graduated.which_mode");
|
|
1505
|
+
const intervalSizeLabel = t("graduated.interval_size");
|
|
1506
|
+
const classesNumberLabel = t("graduated.classes_number");
|
|
1507
|
+
const colorsSpectrumLabel = t("categorized.colors_spectrum");
|
|
1508
|
+
const selectSpectrumLabel = t("categorized.select_spectrum");
|
|
1509
|
+
const invertColorsLabel = t("graduated.invert_colors");
|
|
1510
|
+
const gradientIntervalsLabel = t("graduated.gradient_intervals");
|
|
1511
|
+
const valueLabel = t("graduated.value");
|
|
1512
|
+
const strokeColorLabel = t("categorized.stroke_color");
|
|
1513
|
+
const strokeWidthLabel = t("categorized.stroke_width");
|
|
1514
|
+
const colorOpacityLabel = t("categorized.color_opacity");
|
|
1515
|
+
const concludeLabel = t("common.conclude");
|
|
1516
|
+
const previewLabel = t("graduated.preview");
|
|
1517
|
+
const errorValuesLabel = t("errors.error_values");
|
|
1518
|
+
const minValueLabel = t("graduated.min_value");
|
|
1519
|
+
const maxValueLabel = t("graduated.max_value");
|
|
1520
|
+
const colorLabel = t("graduated.color");
|
|
1521
|
+
const modeLabel = t("graduated.mode");
|
|
1522
|
+
const locale = numbersLocale;
|
|
1523
|
+
const toast = (0, react.useRef)(null);
|
|
1524
|
+
const showToast = (message, severity) => {
|
|
1525
|
+
toast.current?.show({
|
|
1526
|
+
severity,
|
|
1527
|
+
summary: "Error",
|
|
1528
|
+
detail: message
|
|
1529
|
+
});
|
|
1530
|
+
};
|
|
1531
|
+
const currentRender = layerCurrentRenderer.type != RenderType.Graduated ? [] : layerCurrentRenderer.rendererOL["fill-color"];
|
|
1532
|
+
const valuesAndColors = [];
|
|
1533
|
+
for (let i = 3; i < currentRender.length - 1; i += 2) valuesAndColors.push({
|
|
1534
|
+
value: currentRender[i],
|
|
1535
|
+
color: currentRender[i + 1]
|
|
1536
|
+
});
|
|
1537
|
+
const currentStyle = layerCurrentRenderer.type != RenderType.Graduated ? null : layerCurrentRenderer.rendererOL;
|
|
1538
|
+
const stroke = getRendererColorAndSizeStroke(layerCurrentRenderer);
|
|
1539
|
+
const [opacity, setOpacity] = (0, react.useState)(currentStyle ? getRendererOpacity(layerCurrentRenderer) : 100);
|
|
1540
|
+
const [stops, setStops] = (0, react.useState)(valuesAndColors);
|
|
1541
|
+
const [selectedAttr, setSelectedAttr] = (0, react.useState)(layerCurrentRenderer.field ? attr.find((at) => at.name == layerCurrentRenderer.field) : void 0);
|
|
1542
|
+
const [selectedMode, setSelectedMode] = (0, react.useState)(layerCurrentRenderer.type == RenderType.Graduated ? layerCurrentRenderer.graduatedType : void 0);
|
|
1543
|
+
const [intervals, setIntervals] = (0, react.useState)([]);
|
|
1544
|
+
const [classNo, setClassNo] = (0, react.useState)(layerCurrentRenderer.type == RenderType.Graduated ? valuesAndColors.length - 1 : 5);
|
|
1545
|
+
const [intervalSize, setIntervalSize] = (0, react.useState)(0);
|
|
1546
|
+
const [selectedSpectrumColors, setSelectedSpectrumColors] = (0, react.useState)();
|
|
1547
|
+
const [borderColor, setBorderColor] = (0, react.useState)(currentStyle ? stroke.color : (0, ol_color_js.fromString)("#000000"));
|
|
1548
|
+
const [borderThickness, setBorderThickness] = (0, react.useState)(currentStyle ? stroke.size : 1);
|
|
1549
|
+
const [chartData, setChartData] = (0, react.useState)({});
|
|
1550
|
+
const [chartOptions, setChartOptions] = (0, react.useState)({});
|
|
1551
|
+
let allRamps;
|
|
1552
|
+
if (showPreDefinedRamps) if (moreRamps) allRamps = moreRamps.concat(colorRamps);
|
|
1553
|
+
else allRamps = colorRamps;
|
|
1554
|
+
else if (moreRamps) allRamps = moreRamps;
|
|
1555
|
+
else allRamps = [];
|
|
1556
|
+
const existingRenderers = allRamps.filter((ramp, _index, self) => self.filter((r) => r.name === ramp.name).length > 1);
|
|
1557
|
+
if (existingRenderers.length > 0) {
|
|
1558
|
+
console.error(errorRamps + existingRenderers.map((ramp) => ramp.name));
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1561
|
+
const preDefinedPalettes = [{
|
|
1562
|
+
label: colorRampLabel,
|
|
1563
|
+
items: allRamps.map((ramp) => {
|
|
1564
|
+
return {
|
|
1565
|
+
label: ramp.name,
|
|
1566
|
+
value: {
|
|
1567
|
+
label: ramp.name,
|
|
1568
|
+
value: ramp.palette
|
|
1569
|
+
}
|
|
1570
|
+
};
|
|
1571
|
+
})
|
|
1572
|
+
}];
|
|
1573
|
+
const itemTemplate = (option) => {
|
|
1574
|
+
if (option.value.value.length > 0 && "offset" in option.value.value[0]) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1575
|
+
style: {
|
|
1576
|
+
display: "flex",
|
|
1577
|
+
gap: "3px",
|
|
1578
|
+
alignItems: "center"
|
|
1579
|
+
},
|
|
1580
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: {
|
|
1581
|
+
background: getColorRampString(option.value.value),
|
|
1582
|
+
width: "90px",
|
|
1583
|
+
height: "20px"
|
|
1584
|
+
} }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: option.label })]
|
|
1585
|
+
});
|
|
1586
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: option.label });
|
|
1587
|
+
};
|
|
1588
|
+
function applyRampToStops(ramp, invert) {
|
|
1589
|
+
const aux = [...stops];
|
|
1590
|
+
if (invert) {
|
|
1591
|
+
const inverse = aux.map((s) => s.color).reverse();
|
|
1592
|
+
setStops(aux.map((tr, index) => {
|
|
1593
|
+
const aux2 = [];
|
|
1594
|
+
const color = inverse[index];
|
|
1595
|
+
aux2.push(color[0]);
|
|
1596
|
+
aux2.push(color[1]);
|
|
1597
|
+
aux2.push(color[2]);
|
|
1598
|
+
aux2.push(opacity / 100);
|
|
1599
|
+
return {
|
|
1600
|
+
...tr,
|
|
1601
|
+
color: aux2
|
|
1602
|
+
};
|
|
1603
|
+
}));
|
|
1604
|
+
return;
|
|
1605
|
+
}
|
|
1606
|
+
const colors = generateGradient(ramp.value, aux.length);
|
|
1607
|
+
setStops(aux.map((tr, index) => {
|
|
1608
|
+
const aux2 = [];
|
|
1609
|
+
const color = (0, ol_color_js.fromString)(colors[index]);
|
|
1610
|
+
aux2.push(color[0]);
|
|
1611
|
+
aux2.push(color[1]);
|
|
1612
|
+
aux2.push(color[2]);
|
|
1613
|
+
aux2.push(opacity / 100);
|
|
1614
|
+
return {
|
|
1615
|
+
...tr,
|
|
1616
|
+
color: aux2
|
|
1617
|
+
};
|
|
1618
|
+
}));
|
|
1619
|
+
}
|
|
1620
|
+
function countNumbers(list) {
|
|
1621
|
+
const counting = {};
|
|
1622
|
+
list.filter((n) => n != null).forEach((num) => {
|
|
1623
|
+
const rounded = Math.round(num);
|
|
1624
|
+
counting[rounded] = (counting[rounded] || 0) + 1;
|
|
1625
|
+
});
|
|
1626
|
+
const maxNumber = Math.round(Math.max(...list));
|
|
1627
|
+
const minNumber = Math.round(Math.min(...list));
|
|
1628
|
+
if (maxNumber - minNumber <= 0) showToast(errorDiffLabel + (maxNumber - minNumber), "error");
|
|
1629
|
+
const result = new Array(maxNumber - minNumber).fill(0);
|
|
1630
|
+
Object.entries(counting).forEach(([n, times]) => {
|
|
1631
|
+
result[Number(n) - minNumber] = times;
|
|
1632
|
+
});
|
|
1633
|
+
let intervals = result.map((value, index) => {
|
|
1634
|
+
return {
|
|
1635
|
+
min: index + minNumber,
|
|
1636
|
+
max: index + minNumber + 1,
|
|
1637
|
+
count: value
|
|
1638
|
+
};
|
|
1639
|
+
});
|
|
1640
|
+
if (list.length != intervals.reduce((acc, curr) => acc + curr.count, 0)) showToast(errorSumLabel, "error");
|
|
1641
|
+
const reduceFactor = 2;
|
|
1642
|
+
while (intervals.length > 100) {
|
|
1643
|
+
const newIntervals = [];
|
|
1644
|
+
for (let i = 0; i <= intervals.length - reduceFactor; i += reduceFactor) {
|
|
1645
|
+
const min = intervals[i].min;
|
|
1646
|
+
let max;
|
|
1647
|
+
const isLast = i == intervals.length - reduceFactor || i + reduceFactor > intervals.length - reduceFactor;
|
|
1648
|
+
if (isLast) max = intervals[intervals.length - 1].max;
|
|
1649
|
+
else max = intervals[i + reduceFactor].min;
|
|
1650
|
+
const count = intervals.slice(i, isLast ? intervals.length : i + reduceFactor).reduce((acc, curr) => acc + curr.count, 0);
|
|
1651
|
+
newIntervals.push({
|
|
1652
|
+
min,
|
|
1653
|
+
max,
|
|
1654
|
+
count
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
intervals = newIntervals;
|
|
1658
|
+
}
|
|
1659
|
+
const lastInterval = intervals[intervals.length - 1];
|
|
1660
|
+
intervals.push({
|
|
1661
|
+
min: lastInterval.max,
|
|
1662
|
+
max: lastInterval.max + (lastInterval.max - lastInterval.min),
|
|
1663
|
+
count: 0
|
|
1664
|
+
});
|
|
1665
|
+
const total = intervals.reduce((acc, curr) => acc + curr.count, 0);
|
|
1666
|
+
if (list.length != total) showToast(errorSum2Label + (list.length - total), "error");
|
|
1667
|
+
intervals = intervals.map((i) => {
|
|
1668
|
+
return {
|
|
1669
|
+
min: i.min,
|
|
1670
|
+
max: i.max,
|
|
1671
|
+
count: i.count * 100 / list.length
|
|
1672
|
+
};
|
|
1673
|
+
});
|
|
1674
|
+
return intervals;
|
|
1675
|
+
}
|
|
1676
|
+
async function calculateStopsByMode(mode, nClasses, intervalSize) {
|
|
1677
|
+
let stops = [];
|
|
1678
|
+
let values = selectedAttr?.values.map(Number) || [];
|
|
1679
|
+
values = values.filter((v) => !isNaN(v) && v != null);
|
|
1680
|
+
const min = Math.min(...values);
|
|
1681
|
+
const max = Math.max(...values);
|
|
1682
|
+
const range = max - min;
|
|
1683
|
+
switch (mode) {
|
|
1684
|
+
case GraduatedModes.EqualInterval:
|
|
1685
|
+
case GraduatedModes.Manual: {
|
|
1686
|
+
const interval2 = range / nClasses;
|
|
1687
|
+
for (let i = 0; i < nClasses; i++) stops.push({
|
|
1688
|
+
value: min + interval2 * i,
|
|
1689
|
+
color: (0, ol_color_js.fromString)("rgb(0,0,0)")
|
|
1690
|
+
});
|
|
1691
|
+
stops.push({
|
|
1692
|
+
value: max,
|
|
1693
|
+
color: (0, ol_color_js.fromString)("rgb(0,0,0)")
|
|
1694
|
+
});
|
|
1695
|
+
break;
|
|
1696
|
+
}
|
|
1697
|
+
case GraduatedModes.DefinedInterval: {
|
|
1698
|
+
const interval = range / intervalSize;
|
|
1699
|
+
console.log("interval", interval, intervalSize);
|
|
1700
|
+
for (let i = 0; i <= interval; i++) stops.push({
|
|
1701
|
+
value: min + intervalSize * i,
|
|
1702
|
+
color: (0, ol_color_js.fromString)("rgb(0,0,0)")
|
|
1703
|
+
});
|
|
1704
|
+
break;
|
|
1705
|
+
}
|
|
1706
|
+
case GraduatedModes.NaturalBreaks:
|
|
1707
|
+
stops = (await (0, geobuckets_dist_src_index_js.jenksBuckets)(values, nClasses)).map((value) => {
|
|
1708
|
+
return {
|
|
1709
|
+
value,
|
|
1710
|
+
color: (0, ol_color_js.fromString)("rgb(0,0,0)")
|
|
1711
|
+
};
|
|
1712
|
+
});
|
|
1713
|
+
break;
|
|
1714
|
+
case GraduatedModes.Quantile:
|
|
1715
|
+
stops = (await (0, geobuckets_dist_src_index_js.quantileBuckets)(values, nClasses)).map((value) => {
|
|
1716
|
+
return {
|
|
1717
|
+
value,
|
|
1718
|
+
color: (0, ol_color_js.fromString)("rgb(0,0,0)")
|
|
1719
|
+
};
|
|
1720
|
+
});
|
|
1721
|
+
break;
|
|
1722
|
+
case GraduatedModes.StandardDeviation:
|
|
1723
|
+
stops = (await (0, geobuckets_dist_src_index_js.standardDeviationBuckets)(values, nClasses)).map((value) => {
|
|
1724
|
+
return {
|
|
1725
|
+
value,
|
|
1726
|
+
color: (0, ol_color_js.fromString)("rgb(0,0,0)")
|
|
1727
|
+
};
|
|
1728
|
+
});
|
|
1729
|
+
break;
|
|
1730
|
+
default: break;
|
|
1731
|
+
}
|
|
1732
|
+
setIntervals(countNumbers(values || []));
|
|
1733
|
+
return stops;
|
|
1734
|
+
}
|
|
1735
|
+
(0, react.useEffect)(() => {
|
|
1736
|
+
if (stops.length > 0) {
|
|
1737
|
+
let values = selectedAttr?.values.map(Number) || [];
|
|
1738
|
+
values = values.filter((v) => !isNaN(v) && v != null);
|
|
1739
|
+
setIntervals(countNumbers(values || []));
|
|
1740
|
+
}
|
|
1741
|
+
}, []);
|
|
1742
|
+
(0, react.useEffect)(() => {
|
|
1743
|
+
if (intervals && intervals.length > 0) {
|
|
1744
|
+
setChartData({
|
|
1745
|
+
labels: intervals.map((i) => i.min.toString()),
|
|
1746
|
+
datasets: [{
|
|
1747
|
+
label: amountValuesLabel,
|
|
1748
|
+
data: intervals.map((i) => i.count),
|
|
1749
|
+
backgroundColor: "rgb(54, 162, 235)",
|
|
1750
|
+
borderWidth: 2,
|
|
1751
|
+
borderColor: "rgb(54, 162, 235)"
|
|
1752
|
+
}]
|
|
1753
|
+
});
|
|
1754
|
+
setChartOptions({
|
|
1755
|
+
responsive: true,
|
|
1756
|
+
scales: {
|
|
1757
|
+
x: {
|
|
1758
|
+
title: {
|
|
1759
|
+
display: true,
|
|
1760
|
+
text: valuesLabel
|
|
1761
|
+
},
|
|
1762
|
+
ticks: {
|
|
1763
|
+
autoSkip: false,
|
|
1764
|
+
color: function(val) {
|
|
1765
|
+
return val.index % 2 === 0 ? "#000" : "rgba(255,255,255,0)";
|
|
1766
|
+
}
|
|
1767
|
+
},
|
|
1768
|
+
grid: {
|
|
1769
|
+
display: true,
|
|
1770
|
+
drawTicks: true,
|
|
1771
|
+
color: function(context) {
|
|
1772
|
+
if (context.tick) {
|
|
1773
|
+
const value = Number.parseInt(context.tick.label);
|
|
1774
|
+
return stops.map((stop) => intervals.find((i) => i.min <= stop.value && stop.value < i.max)).find((i) => i?.min <= value && value < i.max) ? "#ea1010" : "rgba(0,0,0,0)";
|
|
1775
|
+
} else return "rgba(0,0,0,0)";
|
|
1776
|
+
},
|
|
1777
|
+
drawBorder: false
|
|
1778
|
+
}
|
|
1779
|
+
},
|
|
1780
|
+
y: { title: {
|
|
1781
|
+
display: true,
|
|
1782
|
+
text: amountLabel
|
|
1783
|
+
} }
|
|
1784
|
+
}
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
}, [intervals, stops.map((s) => s.value).join(", ")]);
|
|
1788
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1789
|
+
className: "flex-column",
|
|
1790
|
+
children: [
|
|
1791
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1792
|
+
className: "flex-row",
|
|
1793
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1794
|
+
className: "flex-row-small-gap",
|
|
1795
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1796
|
+
className: "auto-width-span",
|
|
1797
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [attributeLabel, ":"] })
|
|
1798
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dropdown_dropdown_esm_js.Dropdown, {
|
|
1799
|
+
value: selectedAttr,
|
|
1800
|
+
onChange: (e) => {
|
|
1801
|
+
setStops([]);
|
|
1802
|
+
setSelectedAttr(e.value);
|
|
1803
|
+
setSelectedMode(void 0);
|
|
1804
|
+
setSelectedSpectrumColors(void 0);
|
|
1805
|
+
},
|
|
1806
|
+
options: attr.filter((a) => a.type === AttributeTypeEnum.INTEGER || a.type === AttributeTypeEnum.FLOAT),
|
|
1807
|
+
optionLabel: "name",
|
|
1808
|
+
placeholder: selectAttributeLabel
|
|
1809
|
+
})]
|
|
1810
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1811
|
+
className: "flex-row-small-gap",
|
|
1812
|
+
children: [
|
|
1813
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1814
|
+
className: "auto-width-span",
|
|
1815
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [modeLabel, ":"] })
|
|
1816
|
+
}),
|
|
1817
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dropdown_dropdown_esm_js.Dropdown, {
|
|
1818
|
+
disabled: !selectedAttr,
|
|
1819
|
+
value: selectedMode,
|
|
1820
|
+
onChange: async (e) => {
|
|
1821
|
+
let iSize = Math.round(Math.max(...selectedAttr.values.map(Number).filter((v) => v != null && !isNaN(v))) / 10);
|
|
1822
|
+
if (iSize == 0) iSize = 1;
|
|
1823
|
+
setIntervalSize(iSize);
|
|
1824
|
+
const classNumber = selectedAttr.values.length > 5 ? 5 : selectedAttr.values.length - 1;
|
|
1825
|
+
setClassNo(classNumber);
|
|
1826
|
+
setStops(await calculateStopsByMode(e.value, classNumber, iSize));
|
|
1827
|
+
setSelectedMode(e.value);
|
|
1828
|
+
setSelectedSpectrumColors(void 0);
|
|
1829
|
+
},
|
|
1830
|
+
options: Object.values(GraduatedModes).filter((m) => m != GraduatedModes.GeometricInterval),
|
|
1831
|
+
itemTemplate: (option) => {
|
|
1832
|
+
return t(`graduate_modes.${option}`);
|
|
1833
|
+
},
|
|
1834
|
+
valueTemplate: (option) => {
|
|
1835
|
+
if (option) return t(`graduate_modes.${option}`);
|
|
1836
|
+
else return selectModeLabel;
|
|
1837
|
+
},
|
|
1838
|
+
placeholder: selectModeLabel
|
|
1839
|
+
}),
|
|
1840
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
1841
|
+
href: "https://resources.arcgis.com/en/help/main/10.2/index.html#//00s50000001r000000",
|
|
1842
|
+
target: "_blank",
|
|
1843
|
+
children: whichModeLabel
|
|
1844
|
+
})
|
|
1845
|
+
]
|
|
1846
|
+
})]
|
|
1847
|
+
}),
|
|
1848
|
+
selectedMode && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
1849
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1850
|
+
className: "flex-row-small-gap",
|
|
1851
|
+
children: [selectedAttr && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
1852
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [minValueLabel, ":"] }),
|
|
1853
|
+
" ",
|
|
1854
|
+
Math.min(...selectedAttr.values.map(Number).filter((v) => !isNaN(v) && v != null)).toLocaleString(locale)
|
|
1855
|
+
] }), selectedAttr && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
1856
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [maxValueLabel, ":"] }),
|
|
1857
|
+
" ",
|
|
1858
|
+
Math.max(...selectedAttr.values.map(Number).filter((v) => !isNaN(v) && v != null)).toLocaleString(locale)
|
|
1859
|
+
] })]
|
|
1860
|
+
}),
|
|
1861
|
+
(selectedMode == GraduatedModes.Manual || selectedMode == GraduatedModes.EqualInterval || selectedMode == GraduatedModes.Quantile || selectedMode == GraduatedModes.NaturalBreaks || selectedMode == GraduatedModes.GeometricInterval) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1862
|
+
className: "flex-row-gap-15",
|
|
1863
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1864
|
+
className: "auto-width-span",
|
|
1865
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [classesNumberLabel, ":"] })
|
|
1866
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_inputnumber_inputnumber_esm_js.InputNumber, {
|
|
1867
|
+
value: classNo,
|
|
1868
|
+
locale,
|
|
1869
|
+
onChange: async (e) => {
|
|
1870
|
+
setClassNo(e.value);
|
|
1871
|
+
setSelectedSpectrumColors(void 0);
|
|
1872
|
+
setStops(await calculateStopsByMode(selectedMode, e.value, intervalSize));
|
|
1873
|
+
}
|
|
1874
|
+
})]
|
|
1875
|
+
}),
|
|
1876
|
+
(selectedMode == GraduatedModes.DefinedInterval || selectedMode == GraduatedModes.StandardDeviation) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1877
|
+
className: "auto-width-span",
|
|
1878
|
+
children: [intervalSizeLabel, ":"]
|
|
1879
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_inputnumber_inputnumber_esm_js.InputNumber, {
|
|
1880
|
+
value: intervalSize,
|
|
1881
|
+
locale,
|
|
1882
|
+
onChange: async (e) => {
|
|
1883
|
+
setIntervalSize(e.value);
|
|
1884
|
+
setSelectedSpectrumColors(void 0);
|
|
1885
|
+
setStops(await calculateStopsByMode(selectedMode, classNo, e.value));
|
|
1886
|
+
}
|
|
1887
|
+
})] })
|
|
1888
|
+
] }),
|
|
1889
|
+
selectedMode && selectedAttr && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_chart_chart_esm_js.Chart, {
|
|
1890
|
+
className: "chart-wrapper",
|
|
1891
|
+
type: "bar",
|
|
1892
|
+
data: chartData,
|
|
1893
|
+
options: chartOptions
|
|
1894
|
+
}),
|
|
1895
|
+
stops.length > 0 && selectedMode && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1896
|
+
className: "flex-column-gap-15px",
|
|
1897
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1898
|
+
className: "flex-row-gap-50px",
|
|
1899
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1900
|
+
className: "flex-row-center",
|
|
1901
|
+
children: [
|
|
1902
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1903
|
+
className: "auto-width-span",
|
|
1904
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [colorsSpectrumLabel, ":"] })
|
|
1905
|
+
}),
|
|
1906
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dropdown_dropdown_esm_js.Dropdown, {
|
|
1907
|
+
value: selectedSpectrumColors,
|
|
1908
|
+
options: preDefinedPalettes,
|
|
1909
|
+
onChange: (e) => {
|
|
1910
|
+
setSelectedSpectrumColors(e.value);
|
|
1911
|
+
applyRampToStops(e.value);
|
|
1912
|
+
},
|
|
1913
|
+
placeholder: selectSpectrumLabel,
|
|
1914
|
+
optionLabel: "label",
|
|
1915
|
+
optionGroupLabel: "label",
|
|
1916
|
+
itemTemplate
|
|
1917
|
+
}),
|
|
1918
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
1919
|
+
text: true,
|
|
1920
|
+
icon: "pi pi-arrow-right-arrow-left",
|
|
1921
|
+
tooltip: invertColorsLabel,
|
|
1922
|
+
disabled: !selectedSpectrumColors,
|
|
1923
|
+
onClick: () => applyRampToStops(selectedSpectrumColors, true)
|
|
1924
|
+
})
|
|
1925
|
+
]
|
|
1926
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1927
|
+
className: "flex-column-small-gap",
|
|
1928
|
+
children: [
|
|
1929
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1930
|
+
className: "auto-width-span",
|
|
1931
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [gradientIntervalsLabel, ":"] })
|
|
1932
|
+
}),
|
|
1933
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1934
|
+
className: "flex-row-small-gap",
|
|
1935
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1936
|
+
className: "auto-width-span",
|
|
1937
|
+
children: [valueLabel, " "]
|
|
1938
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1939
|
+
className: "auto-width-span",
|
|
1940
|
+
children: colorLabel
|
|
1941
|
+
})]
|
|
1942
|
+
}),
|
|
1943
|
+
stops.map((value, index) => {
|
|
1944
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1945
|
+
className: "flex-row-small-small-gap",
|
|
1946
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_inputnumber_inputnumber_esm_js.InputNumber, {
|
|
1947
|
+
placeholder: valueLabel,
|
|
1948
|
+
allowEmpty: false,
|
|
1949
|
+
locale,
|
|
1950
|
+
min: stops[0].value,
|
|
1951
|
+
max: index < stops.length - 1 ? stops[index + 1]?.value - .001 : stops[stops.length]?.value,
|
|
1952
|
+
disabled: index === 0 || selectedMode != GraduatedModes.Manual || index === stops.length - 1,
|
|
1953
|
+
onChange: (e) => {
|
|
1954
|
+
const aux = [...stops];
|
|
1955
|
+
aux[index].value = e.value;
|
|
1956
|
+
setStops(aux);
|
|
1957
|
+
},
|
|
1958
|
+
value: value.value
|
|
1959
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MyColorPicker, {
|
|
1960
|
+
color: value.color,
|
|
1961
|
+
onChange: (e) => {
|
|
1962
|
+
const aux = [...stops];
|
|
1963
|
+
aux[index].color = (0, ol_color_js.fromString)(e);
|
|
1964
|
+
setStops(aux);
|
|
1965
|
+
}
|
|
1966
|
+
})]
|
|
1967
|
+
}, index);
|
|
1968
|
+
})
|
|
1969
|
+
]
|
|
1970
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1971
|
+
className: "flex-row-gap-50px",
|
|
1972
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
1973
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1974
|
+
className: "color-picker-wrapper",
|
|
1975
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [strokeColorLabel, ":"] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MyColorPicker, {
|
|
1976
|
+
color: (() => {
|
|
1977
|
+
if (borderColor.at(3) < 1) return [
|
|
1978
|
+
borderColor[0],
|
|
1979
|
+
borderColor[1],
|
|
1980
|
+
borderColor[2],
|
|
1981
|
+
1
|
|
1982
|
+
];
|
|
1983
|
+
return borderColor;
|
|
1984
|
+
})(),
|
|
1985
|
+
hideAlpha: true,
|
|
1986
|
+
onChange: (e) => setBorderColor((0, ol_color_js.fromString)(e))
|
|
1987
|
+
}) })]
|
|
1988
|
+
}),
|
|
1989
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1990
|
+
className: "flex-column-gap-7px",
|
|
1991
|
+
children: [
|
|
1992
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [strokeWidthLabel, ":"] }) }),
|
|
1993
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_slider_slider_esm_js.Slider, {
|
|
1994
|
+
max: 10,
|
|
1995
|
+
min: 0,
|
|
1996
|
+
className: "slider-wrapper",
|
|
1997
|
+
value: borderThickness,
|
|
1998
|
+
onChange: (e) => setBorderThickness(e.value)
|
|
1999
|
+
}),
|
|
2000
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [borderThickness, " px"] })
|
|
2001
|
+
]
|
|
2002
|
+
}),
|
|
2003
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2004
|
+
className: "flex-column-gap-7px",
|
|
2005
|
+
children: [
|
|
2006
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [colorOpacityLabel, ":"] }) }),
|
|
2007
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_slider_slider_esm_js.Slider, {
|
|
2008
|
+
max: 100,
|
|
2009
|
+
min: 0,
|
|
2010
|
+
className: "slider-wrapper",
|
|
2011
|
+
value: opacity,
|
|
2012
|
+
onChange: (e) => {
|
|
2013
|
+
setOpacity(e.value);
|
|
2014
|
+
setStops([...stops].map((tr) => {
|
|
2015
|
+
const aux2 = [];
|
|
2016
|
+
aux2.push(tr.color[0]);
|
|
2017
|
+
aux2.push(tr.color[1]);
|
|
2018
|
+
aux2.push(tr.color[2]);
|
|
2019
|
+
aux2.push(e.value / 100);
|
|
2020
|
+
return {
|
|
2021
|
+
...tr,
|
|
2022
|
+
color: aux2
|
|
2023
|
+
};
|
|
2024
|
+
}));
|
|
2025
|
+
}
|
|
2026
|
+
}),
|
|
2027
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [opacity, "%"] })
|
|
2028
|
+
]
|
|
2029
|
+
}),
|
|
2030
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2031
|
+
className: "flex-column-gap-7px",
|
|
2032
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [previewLabel, ":"] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2033
|
+
style: { background: getColorRampString(stops.map((stop, index) => {
|
|
2034
|
+
return {
|
|
2035
|
+
offset: index / stops.length,
|
|
2036
|
+
color: stop.color
|
|
2037
|
+
};
|
|
2038
|
+
})) },
|
|
2039
|
+
className: "preview-color-ramp"
|
|
2040
|
+
})]
|
|
2041
|
+
})
|
|
2042
|
+
] })
|
|
2043
|
+
})]
|
|
2044
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2045
|
+
className: "button-wrapper",
|
|
2046
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
2047
|
+
label: concludeLabel,
|
|
2048
|
+
onClick: () => {
|
|
2049
|
+
let allGood = true;
|
|
2050
|
+
stops.forEach((stop, index) => {
|
|
2051
|
+
if (index < stops.length - 1 && stop.value >= stops[index + 1].value) {
|
|
2052
|
+
showToast(errorValuesLabel, "error");
|
|
2053
|
+
allGood = false;
|
|
2054
|
+
}
|
|
2055
|
+
});
|
|
2056
|
+
if (allGood) {
|
|
2057
|
+
applyRenderer({
|
|
2058
|
+
type: RenderType.Graduated,
|
|
2059
|
+
graduatedType: selectedMode,
|
|
2060
|
+
field: selectedAttr?.name,
|
|
2061
|
+
rendererOL: getGraduatedStyle(selectedAttr?.name, stops, borderColor, borderThickness)
|
|
2062
|
+
});
|
|
2063
|
+
setVisible(false);
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
})
|
|
2067
|
+
})]
|
|
2068
|
+
})
|
|
2069
|
+
]
|
|
2070
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_toast_toast_esm_js.Toast, { ref: toast })] });
|
|
2071
|
+
};
|
|
2072
|
+
//#endregion
|
|
2073
|
+
//#region src/components/filters/filterWidgetContext.tsx
|
|
2074
|
+
var FilterWidgetContext = (0, react.createContext)(null);
|
|
2075
|
+
function FilterWidgetContextProvider({ children, attributes }) {
|
|
2076
|
+
const initial = {
|
|
2077
|
+
title: "",
|
|
2078
|
+
attributes,
|
|
2079
|
+
expressionSet: [{
|
|
2080
|
+
id: 0,
|
|
2081
|
+
conditions: [0],
|
|
2082
|
+
expression: {
|
|
2083
|
+
conditions: [{
|
|
2084
|
+
attribute: "",
|
|
2085
|
+
op: "",
|
|
2086
|
+
value: ""
|
|
2087
|
+
}],
|
|
2088
|
+
isAll: void 0
|
|
2089
|
+
}
|
|
2090
|
+
}],
|
|
2091
|
+
expressionsComponents: [0]
|
|
2092
|
+
};
|
|
2093
|
+
const [queryWidget, setQueryWidget] = (0, react.useState)(initial);
|
|
2094
|
+
function setTitle(value) {
|
|
2095
|
+
setQueryWidget({
|
|
2096
|
+
...queryWidget,
|
|
2097
|
+
title: value
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
function setExpressionSet(value) {
|
|
2101
|
+
setQueryWidget({
|
|
2102
|
+
...queryWidget,
|
|
2103
|
+
expressionSet: value
|
|
2104
|
+
});
|
|
2105
|
+
}
|
|
2106
|
+
function setExpressionsComponents(value) {
|
|
2107
|
+
setQueryWidget({
|
|
2108
|
+
...queryWidget,
|
|
2109
|
+
expressionsComponents: value
|
|
2110
|
+
});
|
|
2111
|
+
}
|
|
2112
|
+
function setAttributes(value) {
|
|
2113
|
+
setQueryWidget({
|
|
2114
|
+
...queryWidget,
|
|
2115
|
+
attributes: value
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2118
|
+
function reset() {
|
|
2119
|
+
setQueryWidget(initial);
|
|
2120
|
+
}
|
|
2121
|
+
function addAttributes(atts) {
|
|
2122
|
+
let aux = queryWidget.attributes;
|
|
2123
|
+
aux.push(...atts);
|
|
2124
|
+
setAttributes(aux);
|
|
2125
|
+
}
|
|
2126
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterWidgetContext.Provider, {
|
|
2127
|
+
value: {
|
|
2128
|
+
queryWidget,
|
|
2129
|
+
setTitle,
|
|
2130
|
+
setExpressionSet,
|
|
2131
|
+
setExpressionsComponents,
|
|
2132
|
+
reset,
|
|
2133
|
+
setAttributes,
|
|
2134
|
+
addAttributes
|
|
2135
|
+
},
|
|
2136
|
+
children
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
//#endregion
|
|
2140
|
+
//#region src/components/filters/conditionOnFilter.tsx
|
|
2141
|
+
var ConditionOnFilter = (props) => {
|
|
2142
|
+
const { parentID, id, deleteF } = props;
|
|
2143
|
+
const { queryWidget, setExpressionSet } = (0, react.useContext)(FilterWidgetContext);
|
|
2144
|
+
const toast = (0, react.useRef)(null);
|
|
2145
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
2146
|
+
const [selectedAttribute, setSelectedAttribute] = (0, react.useState)();
|
|
2147
|
+
const [selectedFunction, setSelectedFunction] = (0, react.useState)();
|
|
2148
|
+
const functionsBooleans = [{
|
|
2149
|
+
name: t("filters.yes"),
|
|
2150
|
+
logic: "true"
|
|
2151
|
+
}, {
|
|
2152
|
+
name: t("filters.no"),
|
|
2153
|
+
logic: "false"
|
|
2154
|
+
}];
|
|
2155
|
+
const functionsTexts = [
|
|
2156
|
+
{
|
|
2157
|
+
name: t("filters.is"),
|
|
2158
|
+
logic: "=="
|
|
2159
|
+
},
|
|
2160
|
+
{
|
|
2161
|
+
name: t("filters.is_not"),
|
|
2162
|
+
logic: "!="
|
|
2163
|
+
},
|
|
2164
|
+
{
|
|
2165
|
+
name: t("filters.starts_with"),
|
|
2166
|
+
logic: "startsWith"
|
|
2167
|
+
},
|
|
2168
|
+
{
|
|
2169
|
+
name: t("filters.ends_with"),
|
|
2170
|
+
logic: "endsWith"
|
|
2171
|
+
},
|
|
2172
|
+
{
|
|
2173
|
+
name: t("filters.contains"),
|
|
2174
|
+
logic: "in"
|
|
2175
|
+
},
|
|
2176
|
+
{
|
|
2177
|
+
name: t("filters.does_not_contain"),
|
|
2178
|
+
logic: "!in"
|
|
2179
|
+
},
|
|
2180
|
+
{
|
|
2181
|
+
name: t("filters.is_null"),
|
|
2182
|
+
logic: "null"
|
|
2183
|
+
}
|
|
2184
|
+
];
|
|
2185
|
+
const functionsNumbers = [
|
|
2186
|
+
{
|
|
2187
|
+
name: t("filters.is"),
|
|
2188
|
+
logic: "=="
|
|
2189
|
+
},
|
|
2190
|
+
{
|
|
2191
|
+
name: t("filters.is_not"),
|
|
2192
|
+
logic: "!="
|
|
2193
|
+
},
|
|
2194
|
+
{
|
|
2195
|
+
name: t("filters.is_at_least"),
|
|
2196
|
+
logic: ">="
|
|
2197
|
+
},
|
|
2198
|
+
{
|
|
2199
|
+
name: t("filters.is_less_than"),
|
|
2200
|
+
logic: "<"
|
|
2201
|
+
},
|
|
2202
|
+
{
|
|
2203
|
+
name: t("filters.is_at_most"),
|
|
2204
|
+
logic: "<="
|
|
2205
|
+
},
|
|
2206
|
+
{
|
|
2207
|
+
name: t("filters.is_greater_than"),
|
|
2208
|
+
logic: ">"
|
|
2209
|
+
},
|
|
2210
|
+
{
|
|
2211
|
+
name: t("filters.is_null"),
|
|
2212
|
+
logic: "null"
|
|
2213
|
+
}
|
|
2214
|
+
];
|
|
2215
|
+
const [selectedValue, setSelectedValue] = (0, react.useState)();
|
|
2216
|
+
const [values, setValues] = (0, react.useState)();
|
|
2217
|
+
(0, react.useEffect)(() => {
|
|
2218
|
+
if (selectedAttribute != void 0) {
|
|
2219
|
+
let aux = queryWidget.attributes.filter((feature) => feature.name == selectedAttribute.name)[0];
|
|
2220
|
+
setValues(aux?.values.filter((i) => i != null));
|
|
2221
|
+
}
|
|
2222
|
+
}, [queryWidget.attributes, selectedAttribute]);
|
|
2223
|
+
(0, react.useEffect)(() => {
|
|
2224
|
+
const fullExp = queryWidget.expressionSet.find((item) => item.id === parentID);
|
|
2225
|
+
if (!fullExp) return;
|
|
2226
|
+
const conditionIndex = fullExp.conditions.findIndex((c) => c === id);
|
|
2227
|
+
if (conditionIndex === -1) return;
|
|
2228
|
+
const condition = fullExp.expression.conditions[conditionIndex];
|
|
2229
|
+
const foundAttribute = queryWidget.attributes.find((a) => a.name === condition.attribute);
|
|
2230
|
+
if (foundAttribute) setSelectedAttribute(foundAttribute);
|
|
2231
|
+
let functionSet;
|
|
2232
|
+
if (foundAttribute?.type === AttributeTypeEnum.STRING || foundAttribute?.type === AttributeTypeEnum.JSON) functionSet = functionsTexts;
|
|
2233
|
+
else if (foundAttribute?.type === AttributeTypeEnum.BOOLEAN) functionSet = functionsBooleans;
|
|
2234
|
+
else functionSet = functionsNumbers;
|
|
2235
|
+
const foundFunction = functionSet.find((f) => f.logic === condition.op);
|
|
2236
|
+
if (foundFunction) setSelectedFunction(foundFunction);
|
|
2237
|
+
if (condition.value) setSelectedValue(condition.value);
|
|
2238
|
+
}, [
|
|
2239
|
+
queryWidget.expressionSet,
|
|
2240
|
+
queryWidget.attributes,
|
|
2241
|
+
id
|
|
2242
|
+
]);
|
|
2243
|
+
function update(funct, value, attribute) {
|
|
2244
|
+
let fullExp = queryWidget.expressionSet.find((item) => item.id === parentID);
|
|
2245
|
+
let expression = fullExp.expression;
|
|
2246
|
+
let condition = expression.conditions.at(fullExp.conditions?.findIndex((c) => c == id));
|
|
2247
|
+
if (funct) condition.op = funct.logic;
|
|
2248
|
+
if (value) if (value.includes("'") || value.includes("\"")) toast.current?.show({
|
|
2249
|
+
severity: "error",
|
|
2250
|
+
summary: "Error",
|
|
2251
|
+
detail: t("filters.invalid_chars_error", { id: parentID + "." + id })
|
|
2252
|
+
});
|
|
2253
|
+
else condition.value = value;
|
|
2254
|
+
if (attribute) if (attribute.name != null) condition.attribute = attribute.name;
|
|
2255
|
+
else toast.current?.show({
|
|
2256
|
+
severity: "error",
|
|
2257
|
+
summary: "Error",
|
|
2258
|
+
detail: t("filters.invalid_attribute_error")
|
|
2259
|
+
});
|
|
2260
|
+
queryWidget.expressionSet.splice(queryWidget.expressionSet.findIndex((item) => item.id === parentID), 1, {
|
|
2261
|
+
id: parentID,
|
|
2262
|
+
conditions: fullExp.conditions,
|
|
2263
|
+
expression
|
|
2264
|
+
});
|
|
2265
|
+
setExpressionSet(queryWidget.expressionSet);
|
|
2266
|
+
}
|
|
2267
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2268
|
+
style: {
|
|
2269
|
+
position: "relative",
|
|
2270
|
+
paddingBottom: "5px"
|
|
2271
|
+
},
|
|
2272
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2273
|
+
style: {
|
|
2274
|
+
position: "absolute",
|
|
2275
|
+
right: 0
|
|
2276
|
+
},
|
|
2277
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
2278
|
+
icon: "pi pi-times",
|
|
2279
|
+
onClick: () => {
|
|
2280
|
+
return deleteF(id);
|
|
2281
|
+
}
|
|
2282
|
+
})
|
|
2283
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_fieldset_fieldset_esm_js.Fieldset, {
|
|
2284
|
+
legend: t("filters.condition") + (id + 1),
|
|
2285
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
2286
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dropdown_dropdown_esm_js.Dropdown, {
|
|
2287
|
+
value: selectedAttribute,
|
|
2288
|
+
onChange: (e) => {
|
|
2289
|
+
setSelectedFunction(void 0);
|
|
2290
|
+
setSelectedAttribute(e.value);
|
|
2291
|
+
setSelectedValue(void 0);
|
|
2292
|
+
update(void 0, void 0, e.value);
|
|
2293
|
+
},
|
|
2294
|
+
options: queryWidget.attributes,
|
|
2295
|
+
optionLabel: "name",
|
|
2296
|
+
placeholder: t("filters.select_attribute"),
|
|
2297
|
+
className: "w-full md:w-14rem"
|
|
2298
|
+
}),
|
|
2299
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dropdown_dropdown_esm_js.Dropdown, {
|
|
2300
|
+
value: selectedFunction,
|
|
2301
|
+
onChange: (e) => {
|
|
2302
|
+
setSelectedFunction(e.value);
|
|
2303
|
+
if (e.value.logic == "null") setSelectedValue(void 0);
|
|
2304
|
+
update(e.value, void 0, void 0);
|
|
2305
|
+
},
|
|
2306
|
+
options: selectedAttribute?.type == AttributeTypeEnum.STRING || selectedAttribute?.type == AttributeTypeEnum.JSON ? functionsTexts : selectedAttribute?.type == AttributeTypeEnum.BOOLEAN ? functionsBooleans : functionsNumbers,
|
|
2307
|
+
disabled: selectedAttribute == void 0,
|
|
2308
|
+
optionLabel: "name",
|
|
2309
|
+
placeholder: t("filters.select_operator")
|
|
2310
|
+
}),
|
|
2311
|
+
selectedAttribute?.type != AttributeTypeEnum.BOOLEAN && selectedFunction?.name != t("filters.is_null") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dropdown_dropdown_esm_js.Dropdown, {
|
|
2312
|
+
value: selectedValue,
|
|
2313
|
+
editable: true,
|
|
2314
|
+
onChange: (e) => {
|
|
2315
|
+
setSelectedValue(e.value);
|
|
2316
|
+
update(void 0, e.value, void 0);
|
|
2317
|
+
},
|
|
2318
|
+
options: values?.length < 200 ? values : values?.slice(0, 200),
|
|
2319
|
+
filter: true,
|
|
2320
|
+
placeholder: t("filters.select_value"),
|
|
2321
|
+
disabled: selectedFunction == void 0,
|
|
2322
|
+
className: "w-full md:w-14rem"
|
|
2323
|
+
})
|
|
2324
|
+
] })
|
|
2325
|
+
})]
|
|
2326
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_toast_toast_esm_js.Toast, { ref: toast })] });
|
|
2327
|
+
};
|
|
2328
|
+
//#endregion
|
|
2329
|
+
//#region src/components/filters/expressionOnFilter.tsx
|
|
2330
|
+
var ExpressionOnFilter = (props) => {
|
|
2331
|
+
const { id } = props;
|
|
2332
|
+
const { queryWidget, setExpressionSet } = (0, react.useContext)(FilterWidgetContext);
|
|
2333
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
2334
|
+
const [selectedOp, setSelectedOp] = (0, react.useState)(null);
|
|
2335
|
+
const ops = [{ name: t("filters.all_true") }, { name: t("filters.any_true") }];
|
|
2336
|
+
(0, react.useEffect)(() => {
|
|
2337
|
+
const currentExp = queryWidget.expressionSet.find((item) => item.id === id);
|
|
2338
|
+
if (currentExp?.expression.isAll !== void 0) setSelectedOp(currentExp.expression.isAll ? ops[0] : ops[1]);
|
|
2339
|
+
}, [queryWidget.expressionSet, id]);
|
|
2340
|
+
const currentExp = queryWidget.expressionSet.find((item) => item.id === id);
|
|
2341
|
+
function addCondition() {
|
|
2342
|
+
if (currentExp.conditions.length < 10) {
|
|
2343
|
+
let expression = queryWidget.expressionSet.find((item) => item.id === id)?.expression;
|
|
2344
|
+
expression.conditions?.push({
|
|
2345
|
+
attribute: "",
|
|
2346
|
+
op: "",
|
|
2347
|
+
value: ""
|
|
2348
|
+
});
|
|
2349
|
+
queryWidget.expressionSet.splice(queryWidget.expressionSet.findIndex((item) => item.id === id), 1, {
|
|
2350
|
+
id,
|
|
2351
|
+
conditions: [...currentExp.conditions, currentExp.conditions.at(currentExp.conditions.length - 1) + 1],
|
|
2352
|
+
expression
|
|
2353
|
+
});
|
|
2354
|
+
setExpressionSet(queryWidget.expressionSet);
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
function deleteCondition(idCond) {
|
|
2358
|
+
if (currentExp.conditions.length > 1) {
|
|
2359
|
+
let index = currentExp.conditions.findIndex((item) => item === idCond);
|
|
2360
|
+
let expression = queryWidget.expressionSet.find((item) => item.id === id)?.expression;
|
|
2361
|
+
expression.conditions?.splice(index, 1);
|
|
2362
|
+
queryWidget.expressionSet.splice(queryWidget.expressionSet.findIndex((item) => item.id === id), 1, {
|
|
2363
|
+
id,
|
|
2364
|
+
conditions: currentExp.conditions.filter((item) => item !== idCond),
|
|
2365
|
+
expression
|
|
2366
|
+
});
|
|
2367
|
+
setExpressionSet(queryWidget.expressionSet);
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
function update(op) {
|
|
2371
|
+
let expression = queryWidget.expressionSet.find((item) => item.id === id)?.expression;
|
|
2372
|
+
expression.isAll = op === t("filters.all_true");
|
|
2373
|
+
queryWidget.expressionSet.splice(queryWidget.expressionSet.findIndex((item) => item.id === id), 1, {
|
|
2374
|
+
id,
|
|
2375
|
+
conditions: currentExp.conditions,
|
|
2376
|
+
expression
|
|
2377
|
+
});
|
|
2378
|
+
setExpressionSet(queryWidget.expressionSet);
|
|
2379
|
+
}
|
|
2380
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2381
|
+
style: {
|
|
2382
|
+
position: "relative",
|
|
2383
|
+
paddingBottom: "5px"
|
|
2384
|
+
},
|
|
2385
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_panel_panel_esm_js.Panel, {
|
|
2386
|
+
header: t("filters.expression"),
|
|
2387
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2388
|
+
style: {
|
|
2389
|
+
display: "flex",
|
|
2390
|
+
flexDirection: "column"
|
|
2391
|
+
},
|
|
2392
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_scrollpanel_scrollpanel_esm_js.ScrollPanel, {
|
|
2393
|
+
style: {
|
|
2394
|
+
width: "100%",
|
|
2395
|
+
height: "90%"
|
|
2396
|
+
},
|
|
2397
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
2398
|
+
style: { paddingLeft: "0" },
|
|
2399
|
+
children: currentExp.conditions.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConditionOnFilter, {
|
|
2400
|
+
id: item,
|
|
2401
|
+
parentID: id,
|
|
2402
|
+
deleteF: deleteCondition
|
|
2403
|
+
}) }, index))
|
|
2404
|
+
})
|
|
2405
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2406
|
+
style: {
|
|
2407
|
+
display: "flex",
|
|
2408
|
+
flexDirection: "column",
|
|
2409
|
+
width: "230px",
|
|
2410
|
+
gap: "5px"
|
|
2411
|
+
},
|
|
2412
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
2413
|
+
label: t("filters.add_condition"),
|
|
2414
|
+
outlined: true,
|
|
2415
|
+
onClick: addCondition
|
|
2416
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dropdown_dropdown_esm_js.Dropdown, {
|
|
2417
|
+
style: { paddingBottom: "5px" },
|
|
2418
|
+
value: selectedOp,
|
|
2419
|
+
onChange: (e) => {
|
|
2420
|
+
setSelectedOp(e.value);
|
|
2421
|
+
update(e.value.name);
|
|
2422
|
+
},
|
|
2423
|
+
options: ops,
|
|
2424
|
+
optionLabel: "name",
|
|
2425
|
+
placeholder: t("filters.select_operator"),
|
|
2426
|
+
className: "w-full md:w-14rem"
|
|
2427
|
+
})]
|
|
2428
|
+
})]
|
|
2429
|
+
})
|
|
2430
|
+
})
|
|
2431
|
+
}) });
|
|
2432
|
+
};
|
|
2433
|
+
var filterWidget_module_default = {
|
|
2434
|
+
expressions: "_expressions_14903_1",
|
|
2435
|
+
text: "_text_14903_7",
|
|
2436
|
+
menu: "_menu_14903_15",
|
|
2437
|
+
alignCenter: "_alignCenter_14903_22",
|
|
2438
|
+
dialogDimensions: "_dialogDimensions_14903_27",
|
|
2439
|
+
addExpression: "_addExpression_14903_32",
|
|
2440
|
+
conclude: "_conclude_14903_39"
|
|
2441
|
+
};
|
|
2442
|
+
//#endregion
|
|
2443
|
+
//#region src/components/uniqueSymbolComponent.tsx
|
|
2444
|
+
function UniqueSymbolComponent(props) {
|
|
2445
|
+
const { currentStyle, setColor, setBorderColor, setBorderThickness, borderThickness, color, borderColor } = props;
|
|
2446
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
2447
|
+
const fillColorLabel = t("unique_symbol.fill_color");
|
|
2448
|
+
const strokeColorLabel = t("categorized.stroke_color");
|
|
2449
|
+
const strokeWidthLabel = t("categorized.stroke_width");
|
|
2450
|
+
const start = "#18d7ba";
|
|
2451
|
+
(0, react.useEffect)(() => {
|
|
2452
|
+
setColor(currentStyle ? currentStyle["fill-color"] : (0, ol_color_js.fromString)(start));
|
|
2453
|
+
let auxBorder;
|
|
2454
|
+
if (currentStyle) if (currentStyle["stroke-color"]) if (currentStyle["stroke-color"][0] == "case") auxBorder = currentStyle["stroke-color"][3];
|
|
2455
|
+
else auxBorder = currentStyle["stroke-color"];
|
|
2456
|
+
else auxBorder = (0, ol_color_js.fromString)("#000000");
|
|
2457
|
+
else auxBorder = (0, ol_color_js.fromString)("#000000");
|
|
2458
|
+
setBorderColor(auxBorder);
|
|
2459
|
+
let auxBorderWidth;
|
|
2460
|
+
if (currentStyle) if (currentStyle["stroke-width"] instanceof Array) auxBorderWidth = currentStyle["stroke-width"][3];
|
|
2461
|
+
else auxBorderWidth = currentStyle["stroke-width"];
|
|
2462
|
+
else auxBorderWidth = 1;
|
|
2463
|
+
setBorderThickness(auxBorderWidth);
|
|
2464
|
+
}, []);
|
|
2465
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2466
|
+
className: "container2",
|
|
2467
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
2468
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2469
|
+
className: "flex-row-unique",
|
|
2470
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [fillColorLabel, ":"] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: color && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MyColorPicker, {
|
|
2471
|
+
color,
|
|
2472
|
+
onChange: (e) => setColor((0, ol_color_js.fromString)(e))
|
|
2473
|
+
}) })]
|
|
2474
|
+
}),
|
|
2475
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2476
|
+
className: "flex-row-unique",
|
|
2477
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [strokeColorLabel, ":"] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: borderColor && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MyColorPicker, {
|
|
2478
|
+
color: borderColor,
|
|
2479
|
+
hideAlpha: true,
|
|
2480
|
+
onChange: (e) => setBorderColor((0, ol_color_js.fromString)(e))
|
|
2481
|
+
}) })]
|
|
2482
|
+
}),
|
|
2483
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2484
|
+
className: "flex-column-gap-7",
|
|
2485
|
+
children: [
|
|
2486
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [strokeWidthLabel, ": "] }) }),
|
|
2487
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_slider_slider_esm_js.Slider, {
|
|
2488
|
+
max: 10,
|
|
2489
|
+
min: 0,
|
|
2490
|
+
className: "slider-wrapper",
|
|
2491
|
+
value: borderThickness,
|
|
2492
|
+
onChange: (e) => setBorderThickness(e.value)
|
|
2493
|
+
}),
|
|
2494
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [borderThickness, " px"] })
|
|
2495
|
+
]
|
|
2496
|
+
})
|
|
2497
|
+
] })
|
|
2498
|
+
}) });
|
|
2499
|
+
}
|
|
2500
|
+
//#endregion
|
|
2501
|
+
//#region src/components/filters/filterWidget.tsx
|
|
2502
|
+
var FilterWidget = (props) => {
|
|
2503
|
+
const [isDataLoaded, setIsDataLoaded] = (0, react.useState)(false);
|
|
2504
|
+
const { visible, setVisible, filter, setFilter, canBeElse } = props;
|
|
2505
|
+
const { queryWidget, setTitle, setExpressionSet, setExpressionsComponents, reset } = (0, react.useContext)(FilterWidgetContext);
|
|
2506
|
+
const toast = (0, react.useRef)(null);
|
|
2507
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
2508
|
+
const [color, setColor] = (0, react.useState)();
|
|
2509
|
+
const [borderColor, setBorderColor] = (0, react.useState)();
|
|
2510
|
+
const [borderThickness, setBorderThickness] = (0, react.useState)();
|
|
2511
|
+
const [isElse, setIsElse] = (0, react.useState)(false);
|
|
2512
|
+
function constructJsonString(operator, attribute, value) {
|
|
2513
|
+
if (value === "") return `{"==": [{"var": "${attribute}"}, null]}`;
|
|
2514
|
+
return !isNaN(parseFloat(value)) ? constructJsonStringNumerical(operator, attribute, parseFloat(value)) : constructJsonStringText(operator, attribute, value);
|
|
2515
|
+
}
|
|
2516
|
+
function constructJsonStringNumerical(operator, attribute, value) {
|
|
2517
|
+
return `{
|
|
2518
|
+
"${operator}": [{ "var": "${attribute}" }, ${value}]
|
|
2519
|
+
}`;
|
|
2520
|
+
}
|
|
2521
|
+
function constructJsonStringText(operator, attribute, value) {
|
|
2522
|
+
switch (operator) {
|
|
2523
|
+
case "startsWith": return `{
|
|
2524
|
+
"==": [
|
|
2525
|
+
{ "substr": [{ "var": "${attribute}" }, 0, ${value.length}] },
|
|
2526
|
+
"${value}"
|
|
2527
|
+
]
|
|
2528
|
+
}`;
|
|
2529
|
+
case "endsWith": return `{
|
|
2530
|
+
"==": [
|
|
2531
|
+
{ "substr": [{ "var": "${attribute}" }, -${value.length}] },
|
|
2532
|
+
"${value}"
|
|
2533
|
+
]
|
|
2534
|
+
}`;
|
|
2535
|
+
case "!in": return `{
|
|
2536
|
+
"!": {
|
|
2537
|
+
"in": [${JSON.stringify(value)}, { "var": "${attribute}" }]
|
|
2538
|
+
}
|
|
2539
|
+
}`;
|
|
2540
|
+
default: return `{"${operator}": ["${value}", { "var": "${attribute}" }]}`;
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
function buildJsonLogicRule(conditions, isAll) {
|
|
2544
|
+
if (conditions.length === 0) return "";
|
|
2545
|
+
return `{ "${isAll ? "and" : "or"}": [${conditions.join(", ")}] }`;
|
|
2546
|
+
}
|
|
2547
|
+
function generateRulesFromExpression(expression) {
|
|
2548
|
+
const conditionGroups = [];
|
|
2549
|
+
if (!expression || !Array.isArray(expression.conditions)) return "";
|
|
2550
|
+
expression.conditions.forEach((condition) => {
|
|
2551
|
+
const { type, op, attribute, value } = condition;
|
|
2552
|
+
const jsonString = constructJsonString(op, attribute, value);
|
|
2553
|
+
conditionGroups.push(jsonString);
|
|
2554
|
+
});
|
|
2555
|
+
return buildJsonLogicRule(conditionGroups, expression.isAll);
|
|
2556
|
+
}
|
|
2557
|
+
function deconstructRule(rule) {
|
|
2558
|
+
const parsedRule = JSON.parse(rule);
|
|
2559
|
+
const isAll = parsedRule.hasOwnProperty("and");
|
|
2560
|
+
return {
|
|
2561
|
+
isAll,
|
|
2562
|
+
conditions: parsedRule[isAll ? "and" : "or"].map((condition) => {
|
|
2563
|
+
const operator = Object.keys(condition)[0];
|
|
2564
|
+
const value = condition[operator];
|
|
2565
|
+
if (operator === "==" && value[0].hasOwnProperty("substr")) {
|
|
2566
|
+
const substr = value[0].substr;
|
|
2567
|
+
const valueString = value[1];
|
|
2568
|
+
if (substr[1] < 0) return {
|
|
2569
|
+
operator: "endsWith",
|
|
2570
|
+
attribute: substr[0].var,
|
|
2571
|
+
value: valueString
|
|
2572
|
+
};
|
|
2573
|
+
else return {
|
|
2574
|
+
operator: "startsWith",
|
|
2575
|
+
attribute: substr[0].var,
|
|
2576
|
+
value: valueString
|
|
2577
|
+
};
|
|
2578
|
+
}
|
|
2579
|
+
if (operator === "!") {
|
|
2580
|
+
const innerCondition = value[Object.keys(value)[0]];
|
|
2581
|
+
return {
|
|
2582
|
+
operator: "!in",
|
|
2583
|
+
attribute: innerCondition[1].var,
|
|
2584
|
+
value: innerCondition[0]
|
|
2585
|
+
};
|
|
2586
|
+
}
|
|
2587
|
+
if (operator === "==") {
|
|
2588
|
+
if (value[0] === null) return {
|
|
2589
|
+
operator: "null",
|
|
2590
|
+
attribute: value[1].var
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
const max = value[0];
|
|
2594
|
+
if (max.hasOwnProperty("var")) return {
|
|
2595
|
+
operator,
|
|
2596
|
+
attribute: max.var,
|
|
2597
|
+
value: value[1]
|
|
2598
|
+
};
|
|
2599
|
+
return {
|
|
2600
|
+
operator,
|
|
2601
|
+
attribute: value[1].var,
|
|
2602
|
+
value: max
|
|
2603
|
+
};
|
|
2604
|
+
})
|
|
2605
|
+
};
|
|
2606
|
+
}
|
|
2607
|
+
(0, react.useEffect)(() => {
|
|
2608
|
+
if (!filter) {
|
|
2609
|
+
setIsDataLoaded(true);
|
|
2610
|
+
return;
|
|
2611
|
+
}
|
|
2612
|
+
setTitle(filter.name);
|
|
2613
|
+
setIsElse(filter.isElse);
|
|
2614
|
+
queryWidget.title = filter.name;
|
|
2615
|
+
if (filter && !filter.isElse) {
|
|
2616
|
+
const allConditions = [];
|
|
2617
|
+
deconstructRule(filter.filterJson).conditions.forEach((condition) => {
|
|
2618
|
+
allConditions.push({
|
|
2619
|
+
attribute: condition.attribute || "",
|
|
2620
|
+
op: condition.operator || "==",
|
|
2621
|
+
value: condition.value
|
|
2622
|
+
});
|
|
2623
|
+
});
|
|
2624
|
+
setExpressionSet([{
|
|
2625
|
+
id: 0,
|
|
2626
|
+
conditions: allConditions.map((_, index) => index),
|
|
2627
|
+
expression: {
|
|
2628
|
+
conditions: allConditions,
|
|
2629
|
+
isAll: filter.isAll
|
|
2630
|
+
}
|
|
2631
|
+
}]);
|
|
2632
|
+
}
|
|
2633
|
+
if (queryWidget.title === filter.name && queryWidget.expressionSet.length > 0) setIsDataLoaded(true);
|
|
2634
|
+
}, [filter]);
|
|
2635
|
+
(0, react.useEffect)(() => {
|
|
2636
|
+
setExpressionsComponents(queryWidget.expressionSet.map((exp) => exp.id));
|
|
2637
|
+
}, [queryWidget.expressionSet]);
|
|
2638
|
+
function addPolygons() {
|
|
2639
|
+
if (queryWidget.title === "") {
|
|
2640
|
+
toast.current?.show({
|
|
2641
|
+
severity: "info",
|
|
2642
|
+
summary: "Info",
|
|
2643
|
+
detail: t("filters.title_empty_error")
|
|
2644
|
+
});
|
|
2645
|
+
return;
|
|
2646
|
+
}
|
|
2647
|
+
let hasToStop = false;
|
|
2648
|
+
if (!isElse) {
|
|
2649
|
+
const exps = queryWidget.expressionSet;
|
|
2650
|
+
if (exps.length === 0) {
|
|
2651
|
+
toast.current?.show({
|
|
2652
|
+
severity: "info",
|
|
2653
|
+
summary: "Info",
|
|
2654
|
+
detail: t("filters.min_one_expression_error")
|
|
2655
|
+
});
|
|
2656
|
+
return;
|
|
2657
|
+
}
|
|
2658
|
+
exps.forEach((tuple, expIndex) => {
|
|
2659
|
+
if (tuple.expression.isAll == void 0) {
|
|
2660
|
+
toast.current?.show({
|
|
2661
|
+
severity: "info",
|
|
2662
|
+
summary: "Info",
|
|
2663
|
+
detail: t("filters.select_and_or_error", { id: tuple.id })
|
|
2664
|
+
});
|
|
2665
|
+
hasToStop = true;
|
|
2666
|
+
return;
|
|
2667
|
+
}
|
|
2668
|
+
tuple.expression.conditions?.forEach((cond, index) => {
|
|
2669
|
+
if (cond.attribute == "") {
|
|
2670
|
+
toast.current?.show({
|
|
2671
|
+
severity: "info",
|
|
2672
|
+
summary: "Info",
|
|
2673
|
+
detail: t("filters.select_attribute_error", { id: expIndex + "." + index })
|
|
2674
|
+
});
|
|
2675
|
+
hasToStop = true;
|
|
2676
|
+
return;
|
|
2677
|
+
}
|
|
2678
|
+
if (cond.op == "") {
|
|
2679
|
+
toast.current?.show({
|
|
2680
|
+
severity: "info",
|
|
2681
|
+
summary: "Info",
|
|
2682
|
+
detail: t("filters.select_function_error", { id: expIndex + "." + index })
|
|
2683
|
+
});
|
|
2684
|
+
hasToStop = true;
|
|
2685
|
+
return;
|
|
2686
|
+
}
|
|
2687
|
+
let aux = cond.op == "null" || cond.op == "true" || cond.op == "false";
|
|
2688
|
+
if (cond.value == void 0 && !aux) {
|
|
2689
|
+
toast.current?.show({
|
|
2690
|
+
severity: "info",
|
|
2691
|
+
summary: "Info",
|
|
2692
|
+
detail: t("filters.select_value_error", { id: expIndex + "." + index })
|
|
2693
|
+
});
|
|
2694
|
+
hasToStop = true;
|
|
2695
|
+
return;
|
|
2696
|
+
}
|
|
2697
|
+
});
|
|
2698
|
+
});
|
|
2699
|
+
}
|
|
2700
|
+
if (!hasToStop) {
|
|
2701
|
+
let dto;
|
|
2702
|
+
if (isElse) dto = {
|
|
2703
|
+
name: queryWidget.title,
|
|
2704
|
+
isElse,
|
|
2705
|
+
symbol: {
|
|
2706
|
+
type: RenderType.Unique,
|
|
2707
|
+
rendererOL: singleColorStyle(color, borderColor, borderThickness)
|
|
2708
|
+
}
|
|
2709
|
+
};
|
|
2710
|
+
else {
|
|
2711
|
+
let rule = generateRulesFromExpression(queryWidget.expressionSet.map((tuple) => tuple.expression)[0]);
|
|
2712
|
+
dto = {
|
|
2713
|
+
name: queryWidget.title,
|
|
2714
|
+
filterJson: rule,
|
|
2715
|
+
isAll: queryWidget.expressionSet[0].expression.isAll,
|
|
2716
|
+
isElse,
|
|
2717
|
+
symbol: {
|
|
2718
|
+
type: RenderType.Unique,
|
|
2719
|
+
rendererOL: singleColorStyle(color, borderColor, borderThickness)
|
|
2720
|
+
}
|
|
2721
|
+
};
|
|
2722
|
+
}
|
|
2723
|
+
setFilter(dto);
|
|
2724
|
+
close();
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
function close() {
|
|
2728
|
+
reset();
|
|
2729
|
+
setIsElse(false);
|
|
2730
|
+
setVisible(false);
|
|
2731
|
+
}
|
|
2732
|
+
return isDataLoaded ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(primereact_dialog_dialog_esm_js.Dialog, {
|
|
2733
|
+
header: t("filters.add_filter"),
|
|
2734
|
+
visible,
|
|
2735
|
+
className: filterWidget_module_default.dialogDimensions,
|
|
2736
|
+
onHide: () => close(),
|
|
2737
|
+
children: [
|
|
2738
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2739
|
+
className: filterWidget_module_default.text,
|
|
2740
|
+
children: [
|
|
2741
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2742
|
+
className: "p-float-label",
|
|
2743
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_inputtext_inputtext_esm_js.InputText, {
|
|
2744
|
+
id: "title",
|
|
2745
|
+
value: queryWidget.title,
|
|
2746
|
+
onChange: (e) => setTitle(e.target.value)
|
|
2747
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
2748
|
+
htmlFor: "title",
|
|
2749
|
+
children: t("filters.name")
|
|
2750
|
+
})]
|
|
2751
|
+
}),
|
|
2752
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2753
|
+
className: "flex align-items-center",
|
|
2754
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_radiobutton_radiobutton_esm_js.RadioButton, {
|
|
2755
|
+
inputId: "filter1",
|
|
2756
|
+
name: "filterType",
|
|
2757
|
+
value: t("filters.filter"),
|
|
2758
|
+
onChange: (e) => setIsElse(false),
|
|
2759
|
+
checked: !isElse
|
|
2760
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
2761
|
+
htmlFor: "filter1",
|
|
2762
|
+
children: t("filters.filter")
|
|
2763
|
+
})]
|
|
2764
|
+
}),
|
|
2765
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2766
|
+
className: "flex align-items-center",
|
|
2767
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_radiobutton_radiobutton_esm_js.RadioButton, {
|
|
2768
|
+
inputId: "filter2",
|
|
2769
|
+
name: "filterType",
|
|
2770
|
+
value: t("filters.all_other_geometries"),
|
|
2771
|
+
disabled: !canBeElse,
|
|
2772
|
+
onChange: (e) => setIsElse(true),
|
|
2773
|
+
checked: isElse
|
|
2774
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
2775
|
+
htmlFor: "filter2",
|
|
2776
|
+
children: t("filters.all_other_geometries")
|
|
2777
|
+
})]
|
|
2778
|
+
})
|
|
2779
|
+
]
|
|
2780
|
+
}),
|
|
2781
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "bor-radio-buttons" }),
|
|
2782
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UniqueSymbolComponent, {
|
|
2783
|
+
color,
|
|
2784
|
+
setColor,
|
|
2785
|
+
borderColor,
|
|
2786
|
+
setBorderColor,
|
|
2787
|
+
currentStyle: filter?.symbol.rendererOL,
|
|
2788
|
+
borderThickness,
|
|
2789
|
+
setBorderThickness
|
|
2790
|
+
}),
|
|
2791
|
+
!isElse && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_scrollpanel_scrollpanel_esm_js.ScrollPanel, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
2792
|
+
className: filterWidget_module_default.expressions,
|
|
2793
|
+
style: { paddingLeft: "0" },
|
|
2794
|
+
children: queryWidget.expressionsComponents.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExpressionOnFilter, { id: item }) }, index))
|
|
2795
|
+
}) }),
|
|
2796
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2797
|
+
className: filterWidget_module_default.conclude,
|
|
2798
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
2799
|
+
label: t("common.conclude"),
|
|
2800
|
+
onClick: addPolygons
|
|
2801
|
+
})
|
|
2802
|
+
})
|
|
2803
|
+
]
|
|
2804
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_toast_toast_esm_js.Toast, { ref: toast })] }) : null;
|
|
2805
|
+
};
|
|
2806
|
+
//#endregion
|
|
2807
|
+
//#region src/components/basedOnRules.tsx
|
|
2808
|
+
function BasedOnRules(props) {
|
|
2809
|
+
const { setVisible, features, applyRenderer, layerCurrentRenderer, attributes } = props;
|
|
2810
|
+
const [rules, setRules] = (0, react.useState)(layerCurrentRenderer.type == RenderType.ByRules ? layerCurrentRenderer.filters ? layerCurrentRenderer.filters : [] : []);
|
|
2811
|
+
const [selectedRule, setSelectedRule] = (0, react.useState)();
|
|
2812
|
+
const [showDialog, setShowDialog] = (0, react.useState)(false);
|
|
2813
|
+
const [isAdding, setIsAdding] = (0, react.useState)(false);
|
|
2814
|
+
const [selectedAttribute, setSelectedAttribute] = (0, react.useState)(attributes.find((a) => a.name === layerCurrentRenderer.field));
|
|
2815
|
+
(0, react.useEffect)(() => {
|
|
2816
|
+
if (!selectedAttribute && layerCurrentRenderer.field && attributes.length > 0) {
|
|
2817
|
+
const attr = attributes.find((a) => a.name === layerCurrentRenderer.field);
|
|
2818
|
+
if (attr) setSelectedAttribute(attr);
|
|
2819
|
+
}
|
|
2820
|
+
}, [attributes, layerCurrentRenderer.field]);
|
|
2821
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
2822
|
+
const nameLabel = t("based_on_rules.name");
|
|
2823
|
+
const typeLabel = t("based_on_rules.type");
|
|
2824
|
+
const previewLabel = t("based_on_rules.preview");
|
|
2825
|
+
const expressionLabel = t("based_on_rules.expression");
|
|
2826
|
+
const allOtherGeometriesLabel = t("based_on_rules.all_other_geometries");
|
|
2827
|
+
const filterLabel = t("based_on_rules.filter");
|
|
2828
|
+
const selectIdAttributeLabel = t("based_on_rules.select_id_attribute");
|
|
2829
|
+
const idsNotUniqueLabel = t("based_on_rules.ids_not_unique");
|
|
2830
|
+
const addRuleLabel = t("based_on_rules.add_rule");
|
|
2831
|
+
const removeRuleLabel = t("based_on_rules.remove_rule");
|
|
2832
|
+
const editRuleLabel = t("based_on_rules.edit_rule");
|
|
2833
|
+
const concludeLabel = t("common.conclude");
|
|
2834
|
+
const columns = [
|
|
2835
|
+
{
|
|
2836
|
+
field: "name",
|
|
2837
|
+
header: nameLabel
|
|
2838
|
+
},
|
|
2839
|
+
{
|
|
2840
|
+
field: "isElse",
|
|
2841
|
+
header: typeLabel,
|
|
2842
|
+
body: (data) => data.isElse ? allOtherGeometriesLabel : filterLabel
|
|
2843
|
+
},
|
|
2844
|
+
{
|
|
2845
|
+
field: "symbol",
|
|
2846
|
+
header: previewLabel,
|
|
2847
|
+
body: (data) => {
|
|
2848
|
+
const color = getStyleColorsAndValues(data.symbol.rendererOL, RenderType.Unique);
|
|
2849
|
+
const stroke = getRendererColorAndSizeStroke(data.symbol);
|
|
2850
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2851
|
+
style: {
|
|
2852
|
+
backgroundColor: (0, ol_color_js.asString)(color.at(0).color),
|
|
2853
|
+
borderColor: (0, ol_color_js.asString)(stroke.color),
|
|
2854
|
+
borderWidth: stroke.size
|
|
2855
|
+
},
|
|
2856
|
+
className: "bor-preview"
|
|
2857
|
+
});
|
|
2858
|
+
}
|
|
2859
|
+
},
|
|
2860
|
+
{
|
|
2861
|
+
field: "filterJson",
|
|
2862
|
+
header: expressionLabel,
|
|
2863
|
+
body: (data) => {
|
|
2864
|
+
if (!data.filterJson) return "";
|
|
2865
|
+
try {
|
|
2866
|
+
const parsed = JSON.parse(data.filterJson);
|
|
2867
|
+
const formatCondition = (cond) => {
|
|
2868
|
+
const operator = Object.keys(cond)[0];
|
|
2869
|
+
const value = cond[operator];
|
|
2870
|
+
if (operator === "!" && value.hasOwnProperty("in")) {
|
|
2871
|
+
const innerCondition = value["in"];
|
|
2872
|
+
return `${innerCondition[1].var} not in ${JSON.stringify(innerCondition[0])}`;
|
|
2873
|
+
}
|
|
2874
|
+
if (operator === "==" && Array.isArray(value) && value[0] && value[0].hasOwnProperty("substr")) {
|
|
2875
|
+
const substr = value[0].substr;
|
|
2876
|
+
const valueString = value[1];
|
|
2877
|
+
return `${substr[0].var} ${substr[1] < 0 ? "endsWith" : "startsWith"} "${valueString}"`;
|
|
2878
|
+
}
|
|
2879
|
+
if (operator === "==" && Array.isArray(value) && value[0] === null) return `${value[1].var} is null`;
|
|
2880
|
+
const max = Array.isArray(value) ? value[0] : null;
|
|
2881
|
+
if (max && max.hasOwnProperty("var")) return `${max.var} ${operator} ${JSON.stringify(value[1])}`;
|
|
2882
|
+
if (Array.isArray(value) && value[1] && value[1].hasOwnProperty("var")) return `${value[1].var} ${operator} ${JSON.stringify(max)}`;
|
|
2883
|
+
return JSON.stringify(cond);
|
|
2884
|
+
};
|
|
2885
|
+
const isAll = parsed.hasOwnProperty("and");
|
|
2886
|
+
const isAny = parsed.hasOwnProperty("or");
|
|
2887
|
+
if (isAll || isAny) {
|
|
2888
|
+
const operator = isAll ? " AND " : " OR ";
|
|
2889
|
+
return parsed[isAll ? "and" : "or"].map(formatCondition).join(operator);
|
|
2890
|
+
} else return formatCondition(parsed);
|
|
2891
|
+
} catch (e) {
|
|
2892
|
+
return data.filterJson;
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
];
|
|
2897
|
+
function addFilter(filter) {
|
|
2898
|
+
setRules([...rules, filter]);
|
|
2899
|
+
}
|
|
2900
|
+
function editFilter(filter) {
|
|
2901
|
+
const index = rules.findIndex((r) => r === selectedRule);
|
|
2902
|
+
if (index >= 0) {
|
|
2903
|
+
const newRules = [...rules];
|
|
2904
|
+
newRules[index] = filter;
|
|
2905
|
+
setRules(newRules);
|
|
2906
|
+
}
|
|
2907
|
+
setSelectedRule(void 0);
|
|
2908
|
+
}
|
|
2909
|
+
function hasUniqueIDs(features, IDAttribute) {
|
|
2910
|
+
const idSet = /* @__PURE__ */ new Set();
|
|
2911
|
+
for (const feature of features) {
|
|
2912
|
+
const id = feature.get(IDAttribute.name);
|
|
2913
|
+
if (id === void 0 || id === null) return false;
|
|
2914
|
+
if (idSet.has(id)) return false;
|
|
2915
|
+
idSet.add(id);
|
|
2916
|
+
}
|
|
2917
|
+
return true;
|
|
2918
|
+
}
|
|
2919
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2920
|
+
className: "container-bor",
|
|
2921
|
+
children: [
|
|
2922
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2923
|
+
className: "bor-id",
|
|
2924
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dropdown_dropdown_esm_js.Dropdown, {
|
|
2925
|
+
options: attributes,
|
|
2926
|
+
optionLabel: "name",
|
|
2927
|
+
value: selectedAttribute,
|
|
2928
|
+
placeholder: selectIdAttributeLabel,
|
|
2929
|
+
onChange: (e) => setSelectedAttribute(e.value)
|
|
2930
|
+
}), selectedAttribute && !hasUniqueIDs(features, selectedAttribute) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2931
|
+
className: "bor-id",
|
|
2932
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
|
|
2933
|
+
className: "pi pi-exclamation-triangle",
|
|
2934
|
+
style: { color: "orange" }
|
|
2935
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: idsNotUniqueLabel }) })]
|
|
2936
|
+
})]
|
|
2937
|
+
}),
|
|
2938
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2939
|
+
className: "bor-buttons",
|
|
2940
|
+
children: [
|
|
2941
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
2942
|
+
label: addRuleLabel,
|
|
2943
|
+
icon: "pi pi-plus",
|
|
2944
|
+
outlined: true,
|
|
2945
|
+
onClick: () => {
|
|
2946
|
+
setIsAdding(true);
|
|
2947
|
+
setShowDialog(true);
|
|
2948
|
+
}
|
|
2949
|
+
}),
|
|
2950
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
2951
|
+
label: removeRuleLabel,
|
|
2952
|
+
disabled: !selectedRule,
|
|
2953
|
+
icon: "pi pi-minus",
|
|
2954
|
+
outlined: true,
|
|
2955
|
+
onClick: () => {
|
|
2956
|
+
if (selectedRule) {
|
|
2957
|
+
setRules(rules.filter((r) => r !== selectedRule));
|
|
2958
|
+
setSelectedRule(void 0);
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
}),
|
|
2962
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
2963
|
+
label: editRuleLabel,
|
|
2964
|
+
disabled: !selectedRule,
|
|
2965
|
+
icon: "pi pi-pencil",
|
|
2966
|
+
outlined: true,
|
|
2967
|
+
onClick: () => {
|
|
2968
|
+
if (selectedRule) {
|
|
2969
|
+
setIsAdding(false);
|
|
2970
|
+
setShowDialog(true);
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
})
|
|
2974
|
+
]
|
|
2975
|
+
}),
|
|
2976
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_datatable_datatable_esm_js.DataTable, {
|
|
2977
|
+
value: rules,
|
|
2978
|
+
selectionMode: "single",
|
|
2979
|
+
selection: selectedRule,
|
|
2980
|
+
onSelectionChange: (e) => setSelectedRule(e.value),
|
|
2981
|
+
children: columns.map((col) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_column_column_esm_js.Column, {
|
|
2982
|
+
field: col.field,
|
|
2983
|
+
header: col.header,
|
|
2984
|
+
body: col.body
|
|
2985
|
+
}, col.field))
|
|
2986
|
+
}),
|
|
2987
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2988
|
+
className: "footer-container",
|
|
2989
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
2990
|
+
label: concludeLabel,
|
|
2991
|
+
disabled: !selectedAttribute || !hasUniqueIDs(features, selectedAttribute),
|
|
2992
|
+
onClick: () => {
|
|
2993
|
+
const appliedFilters = [];
|
|
2994
|
+
rules.filter((r) => !r.isElse).forEach((filter) => {
|
|
2995
|
+
const res = [];
|
|
2996
|
+
try {
|
|
2997
|
+
const parsedLogic = JSON.parse(filter.filterJson);
|
|
2998
|
+
features.forEach((feature) => {
|
|
2999
|
+
if (json_logic_js.default.apply(parsedLogic, feature.getProperties())) res.push(feature.get(selectedAttribute.name));
|
|
3000
|
+
});
|
|
3001
|
+
} catch (e) {
|
|
3002
|
+
console.error("Error evaluating jsonLogic rule", e);
|
|
3003
|
+
}
|
|
3004
|
+
appliedFilters.push({
|
|
3005
|
+
filter,
|
|
3006
|
+
ids: res
|
|
3007
|
+
});
|
|
3008
|
+
});
|
|
3009
|
+
applyRenderer({
|
|
3010
|
+
type: RenderType.ByRules,
|
|
3011
|
+
field: selectedAttribute.name,
|
|
3012
|
+
filters: rules,
|
|
3013
|
+
rendererOL: getByRulesStyle(appliedFilters, selectedAttribute.name, rules.find((r) => r.isElse))
|
|
3014
|
+
});
|
|
3015
|
+
setVisible(false);
|
|
3016
|
+
}
|
|
3017
|
+
})
|
|
3018
|
+
})
|
|
3019
|
+
]
|
|
3020
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterWidget, {
|
|
3021
|
+
visible: showDialog,
|
|
3022
|
+
setVisible: setShowDialog,
|
|
3023
|
+
filter: isAdding ? void 0 : selectedRule,
|
|
3024
|
+
setFilter: isAdding ? addFilter : editFilter,
|
|
3025
|
+
canBeElse: !isAdding && selectedRule?.isElse || rules.find((r) => r.isElse) == void 0
|
|
3026
|
+
})] });
|
|
3027
|
+
}
|
|
3028
|
+
//#endregion
|
|
3029
|
+
//#region src/components/geometryEditor.tsx
|
|
3030
|
+
var GeometryEditor = (props) => {
|
|
3031
|
+
const { layerCurrentRenderer, layerDefaultRenderer, moreRamps, predefinedStyles, showPreDefinedRamps, applyRenderer, setVisible, numbersLocale, features } = props;
|
|
3032
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
3033
|
+
const uniqueSymbol = t("common.unique_symbol");
|
|
3034
|
+
const categorized = t("common.categorized");
|
|
3035
|
+
const graduated = t("common.graduated");
|
|
3036
|
+
const resetStyle = t("common.reset_style");
|
|
3037
|
+
const selectStyle = t("common.select_type");
|
|
3038
|
+
const styleType = t("common.style_type");
|
|
3039
|
+
const basedOnRules = t("common.based_on_rules");
|
|
3040
|
+
const [attr, setAttr] = (0, react.useState)(props.attributes);
|
|
3041
|
+
(0, react.useEffect)(() => {
|
|
3042
|
+
setAttr(props.attributes);
|
|
3043
|
+
}, [props.attributes]);
|
|
3044
|
+
const [currentRenderer, setCurrentRenderer] = (0, react.useState)(layerCurrentRenderer);
|
|
3045
|
+
const options = [
|
|
3046
|
+
{
|
|
3047
|
+
label: uniqueSymbol,
|
|
3048
|
+
code: 0
|
|
3049
|
+
},
|
|
3050
|
+
{
|
|
3051
|
+
label: categorized,
|
|
3052
|
+
code: 1
|
|
3053
|
+
},
|
|
3054
|
+
{
|
|
3055
|
+
label: graduated,
|
|
3056
|
+
code: 2
|
|
3057
|
+
},
|
|
3058
|
+
{
|
|
3059
|
+
label: basedOnRules,
|
|
3060
|
+
code: 3
|
|
3061
|
+
}
|
|
3062
|
+
];
|
|
3063
|
+
const [activeIndex, setActiveIndex] = (0, react.useState)(layerCurrentRenderer.type == RenderType.Categorized ? options[1] : layerCurrentRenderer.type == RenderType.Graduated ? options[2] : layerCurrentRenderer.type == RenderType.ByRules ? options[3] : options[0]);
|
|
3064
|
+
(0, react.useEffect)(() => {
|
|
3065
|
+
setActiveIndex(currentRenderer.type == RenderType.Categorized ? options[1] : currentRenderer.type == RenderType.Graduated ? options[2] : layerCurrentRenderer.type == RenderType.ByRules ? options[3] : options[0]);
|
|
3066
|
+
}, [currentRenderer]);
|
|
3067
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3068
|
+
className: "geometry-editor",
|
|
3069
|
+
children: [
|
|
3070
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3071
|
+
className: "dropdown",
|
|
3072
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3073
|
+
className: "style-type",
|
|
3074
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("b", { children: [styleType, ":"] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dropdown_dropdown_esm_js.Dropdown, {
|
|
3075
|
+
options,
|
|
3076
|
+
placeholder: selectStyle,
|
|
3077
|
+
optionLabel: "label",
|
|
3078
|
+
value: activeIndex,
|
|
3079
|
+
onChange: (e) => setActiveIndex(e.value)
|
|
3080
|
+
})]
|
|
3081
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_button_button_esm_js.Button, {
|
|
3082
|
+
label: resetStyle,
|
|
3083
|
+
disabled: currentRenderer == layerDefaultRenderer,
|
|
3084
|
+
onClick: () => {
|
|
3085
|
+
applyRenderer(layerDefaultRenderer);
|
|
3086
|
+
setCurrentRenderer(layerDefaultRenderer);
|
|
3087
|
+
}
|
|
3088
|
+
})]
|
|
3089
|
+
}),
|
|
3090
|
+
activeIndex?.code == 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UniqueSymbol, {
|
|
3091
|
+
layerCurrentRenderer: currentRenderer,
|
|
3092
|
+
layerDefaultRenderer,
|
|
3093
|
+
applyRenderer,
|
|
3094
|
+
setVisible
|
|
3095
|
+
}),
|
|
3096
|
+
activeIndex?.code == 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Categorized, {
|
|
3097
|
+
attr,
|
|
3098
|
+
layerCurrentRenderer: currentRenderer,
|
|
3099
|
+
layerDefaultRenderer,
|
|
3100
|
+
applyRenderer,
|
|
3101
|
+
setVisible,
|
|
3102
|
+
moreRamps,
|
|
3103
|
+
predefinedStyles,
|
|
3104
|
+
showPreDefinedRamps
|
|
3105
|
+
}),
|
|
3106
|
+
activeIndex?.code == 2 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Graduated, {
|
|
3107
|
+
attr,
|
|
3108
|
+
setAttr,
|
|
3109
|
+
applyRenderer,
|
|
3110
|
+
moreRamps,
|
|
3111
|
+
setVisible,
|
|
3112
|
+
showPreDefinedRamps,
|
|
3113
|
+
layerCurrentRenderer,
|
|
3114
|
+
numbersLocale
|
|
3115
|
+
}),
|
|
3116
|
+
activeIndex?.code == 3 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterWidgetContextProvider, {
|
|
3117
|
+
attributes: attr,
|
|
3118
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BasedOnRules, {
|
|
3119
|
+
applyRenderer,
|
|
3120
|
+
layerCurrentRenderer,
|
|
3121
|
+
setVisible,
|
|
3122
|
+
features,
|
|
3123
|
+
attributes: attr
|
|
3124
|
+
})
|
|
3125
|
+
})
|
|
3126
|
+
]
|
|
3127
|
+
}) });
|
|
3128
|
+
};
|
|
3129
|
+
//#endregion
|
|
3130
|
+
//#region src/components/utills.ts
|
|
3131
|
+
function mapFeaturesToSEAttributes(features) {
|
|
3132
|
+
const attributeMap = {};
|
|
3133
|
+
features.forEach((feature) => {
|
|
3134
|
+
const properties = feature.getProperties();
|
|
3135
|
+
Object.keys(properties).forEach((key) => {
|
|
3136
|
+
if (key === "geometry") return;
|
|
3137
|
+
if (!attributeMap[key]) attributeMap[key] = /* @__PURE__ */ new Set();
|
|
3138
|
+
attributeMap[key].add(properties[key]);
|
|
3139
|
+
});
|
|
3140
|
+
});
|
|
3141
|
+
return Object.keys(attributeMap).map((key, index) => {
|
|
3142
|
+
const valuesArray = Array.from(attributeMap[key]);
|
|
3143
|
+
return {
|
|
3144
|
+
id: index,
|
|
3145
|
+
name: key,
|
|
3146
|
+
type: determineAttributeType(valuesArray),
|
|
3147
|
+
values: valuesArray.map(String)
|
|
3148
|
+
};
|
|
3149
|
+
});
|
|
3150
|
+
}
|
|
3151
|
+
function determineAttributeType(values) {
|
|
3152
|
+
if (values.length === 0) return AttributeTypeEnum.STRING;
|
|
3153
|
+
const sampleValue = values[0];
|
|
3154
|
+
if (typeof sampleValue === "string") return AttributeTypeEnum.STRING;
|
|
3155
|
+
else if (typeof sampleValue === "number") return Number.isInteger(sampleValue) ? AttributeTypeEnum.INTEGER : AttributeTypeEnum.FLOAT;
|
|
3156
|
+
else if (typeof sampleValue === "boolean") return AttributeTypeEnum.BOOLEAN;
|
|
3157
|
+
else if (sampleValue instanceof Date) return AttributeTypeEnum.DATE;
|
|
3158
|
+
else if (typeof sampleValue === "object") return AttributeTypeEnum.JSON;
|
|
3159
|
+
else return AttributeTypeEnum.STRING;
|
|
3160
|
+
}
|
|
3161
|
+
//#endregion
|
|
3162
|
+
//#region src/components/main/StyleEditorComponent.tsx
|
|
3163
|
+
var StyleEditorComponent = (props) => {
|
|
3164
|
+
const { layerDefaultRenderer, layerCurrentRenderer, applyRenderer, showPreDefinedRamps, moreRamps, predefinedStyles, addingToHeader, features, visible, setVisible, numbersLocale } = props;
|
|
3165
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
3166
|
+
const titleHeader = t("common.style_editor");
|
|
3167
|
+
const [activeIndex] = (0, react.useState)(1);
|
|
3168
|
+
const [attributesAndValues, setAttributesAndValues] = (0, react.useState)([]);
|
|
3169
|
+
(0, react.useEffect)(() => {
|
|
3170
|
+
setAttributesAndValues(mapFeaturesToSEAttributes(features));
|
|
3171
|
+
}, [features]);
|
|
3172
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_dialog_dialog_esm_js.Dialog, {
|
|
3173
|
+
visible: props.visible,
|
|
3174
|
+
header: titleHeader + (addingToHeader ? " - " + addingToHeader : ""),
|
|
3175
|
+
style: {
|
|
3176
|
+
height: "90%",
|
|
3177
|
+
width: "80%"
|
|
3178
|
+
},
|
|
3179
|
+
onHide: () => {
|
|
3180
|
+
props.setVisible(false);
|
|
3181
|
+
},
|
|
3182
|
+
children: activeIndex === 1 && attributesAndValues && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GeometryEditor, {
|
|
3183
|
+
attributes: attributesAndValues,
|
|
3184
|
+
visible,
|
|
3185
|
+
layerCurrentRenderer,
|
|
3186
|
+
applyRenderer,
|
|
3187
|
+
setVisible,
|
|
3188
|
+
layerDefaultRenderer,
|
|
3189
|
+
moreRamps,
|
|
3190
|
+
numbersLocale,
|
|
3191
|
+
features,
|
|
3192
|
+
predefinedStyles: predefinedStyles ? predefinedStyles : [],
|
|
3193
|
+
showPreDefinedRamps
|
|
3194
|
+
})
|
|
3195
|
+
}) });
|
|
3196
|
+
};
|
|
3197
|
+
//#endregion
|
|
3198
|
+
//#region src/i18n.ts
|
|
3199
|
+
i18next.default.use(react_i18next.initReactI18next).init({
|
|
3200
|
+
lng: "en",
|
|
3201
|
+
fallbackLng: "en",
|
|
3202
|
+
debug: true,
|
|
3203
|
+
resources: {
|
|
3204
|
+
pt: { translation: {
|
|
3205
|
+
common: {
|
|
3206
|
+
"style_editor": "Editor de Estilos",
|
|
3207
|
+
"reset_style": "Repor Estilo",
|
|
3208
|
+
"conclude": "Concluir",
|
|
3209
|
+
"unique_symbol": "Símbolo Único",
|
|
3210
|
+
"categorized": "Categorizado",
|
|
3211
|
+
"graduated": "Quantitativo",
|
|
3212
|
+
"null": "Nulo",
|
|
3213
|
+
"select_type": "Selecionar um tipo de estilo",
|
|
3214
|
+
"style_type": "Tipo de Estilo",
|
|
3215
|
+
"based_on_rules": "Baseado em regras"
|
|
3216
|
+
},
|
|
3217
|
+
errors: {
|
|
3218
|
+
"error_ramps_same_name": "Existem rampas com o mesmo nome: ",
|
|
3219
|
+
"error_diff": "A diferença entre os valores máximo e mínimo deve ser maior do que 0, é: ",
|
|
3220
|
+
"error_sum": "A soma das contagens dos intervalos deve ser igual ao número de valores",
|
|
3221
|
+
"error_sum2": "A soma das contagens está incorreta: ",
|
|
3222
|
+
"error_values": "Os valores dos intervalos devem ser crescentes."
|
|
3223
|
+
},
|
|
3224
|
+
categorized: {
|
|
3225
|
+
"predefined_styles": "Estilos Pré-definidos",
|
|
3226
|
+
"color_ramps": "Rampas de Cores",
|
|
3227
|
+
"stroke_color": "Cor do Contorno",
|
|
3228
|
+
"stroke_width": "Largura do Contorno",
|
|
3229
|
+
"attribute": "Atributo",
|
|
3230
|
+
"select_attribute": "Selecionar um atributo",
|
|
3231
|
+
"update_colors": "Atualizar cores",
|
|
3232
|
+
"color_opacity": "Opacidade da Cor",
|
|
3233
|
+
"colors_spectrum": "Espetro de Cores",
|
|
3234
|
+
"select_spectrum": "Selecionar um espetro",
|
|
3235
|
+
"custom_style": "Estilo Personalizado",
|
|
3236
|
+
"reverse_colors": "Inverter cores",
|
|
3237
|
+
"color_style": "Estilo de Cores"
|
|
3238
|
+
},
|
|
3239
|
+
unique_symbol: { "fill_color": "Cor de Preenchimento" },
|
|
3240
|
+
color_picker: { "select_color": "Selecionar uma cor" },
|
|
3241
|
+
graduated: {
|
|
3242
|
+
"amount_values": "Quantidade de valores (%)",
|
|
3243
|
+
"values": "Valores",
|
|
3244
|
+
"amount": "Quantidade (%)",
|
|
3245
|
+
"select_mode": "Selecionar um modo",
|
|
3246
|
+
"which_mode": "Qual modo escolher?",
|
|
3247
|
+
"interval_size": "Tamanho do intervalo",
|
|
3248
|
+
"classes_number": "Nº de classes",
|
|
3249
|
+
"invert_colors": "Inverter cores do espetro",
|
|
3250
|
+
"gradient_intervals": "Intervalos de Gradiente",
|
|
3251
|
+
"value": "Valor",
|
|
3252
|
+
"preview": "Pré-visualização",
|
|
3253
|
+
"min_value": "Valor Mínimo",
|
|
3254
|
+
"max_value": "Valor Máximo",
|
|
3255
|
+
"color": "Cor",
|
|
3256
|
+
"mode": "Modo"
|
|
3257
|
+
},
|
|
3258
|
+
graduate_modes: {
|
|
3259
|
+
"EqualInterval": "Intervalos Iguais",
|
|
3260
|
+
"Quantile": "Quantil",
|
|
3261
|
+
"NaturalBreaks": "Quebras Naturais (Jenks)",
|
|
3262
|
+
"DefinedInterval": "Intervalos Definidos",
|
|
3263
|
+
"Manual": "Manual",
|
|
3264
|
+
"GeometricInterval": "Intervalo Geométrico",
|
|
3265
|
+
"StandardDeviation": "Desvio Padrão"
|
|
3266
|
+
},
|
|
3267
|
+
based_on_rules: {
|
|
3268
|
+
"name": "Nome",
|
|
3269
|
+
"type": "Tipo",
|
|
3270
|
+
"preview": "Pré-visualização",
|
|
3271
|
+
"expression": "Expressão",
|
|
3272
|
+
"all_other_geometries": "Todas as restantes geometrias",
|
|
3273
|
+
"filter": "Filtro",
|
|
3274
|
+
"select_id_attribute": "Selecione o atributo de ID",
|
|
3275
|
+
"ids_not_unique": "Os IDs não são únicos",
|
|
3276
|
+
"add_rule": "Adicionar Regra",
|
|
3277
|
+
"remove_rule": "Remover Regra",
|
|
3278
|
+
"edit_rule": "Editar Regra"
|
|
3279
|
+
},
|
|
3280
|
+
filters: {
|
|
3281
|
+
"yes": "Sim",
|
|
3282
|
+
"no": "Não",
|
|
3283
|
+
"is": "é",
|
|
3284
|
+
"is_not": "não é",
|
|
3285
|
+
"starts_with": "começa com",
|
|
3286
|
+
"ends_with": "acaba com",
|
|
3287
|
+
"contains": "contém",
|
|
3288
|
+
"does_not_contain": "não contém",
|
|
3289
|
+
"is_null": "é nulo",
|
|
3290
|
+
"is_at_least": "é pelo menos",
|
|
3291
|
+
"is_less_than": "é menor que",
|
|
3292
|
+
"is_at_most": "é no máximo",
|
|
3293
|
+
"is_greater_than": "é maior que",
|
|
3294
|
+
"condition": "Condição ",
|
|
3295
|
+
"select_attribute": "Selecione o atributo",
|
|
3296
|
+
"select_operator": "Selecione o operador",
|
|
3297
|
+
"select_value": "Selecione um valor",
|
|
3298
|
+
"invalid_chars_error": "A condição {{id}} contém caracteres inválidos.",
|
|
3299
|
+
"invalid_attribute_error": "A condição tem um atributo inválido",
|
|
3300
|
+
"all_true": "Todas verdadeiras",
|
|
3301
|
+
"any_true": "Pelo menos uma verdadeira",
|
|
3302
|
+
"expression": "Expressão",
|
|
3303
|
+
"add_condition": "Adicionar Condição",
|
|
3304
|
+
"add_filter": "Adicionar Filtro",
|
|
3305
|
+
"name": "Nome",
|
|
3306
|
+
"filter": "Filtro",
|
|
3307
|
+
"all_other_geometries": "Todas as restantes geometrias",
|
|
3308
|
+
"title_empty_error": "Título não pode ser vazio!",
|
|
3309
|
+
"min_one_expression_error": "Tenha pelo menos uma expressão!",
|
|
3310
|
+
"select_and_or_error": "Selecione se a expressão {{id}} é \"E\" ou \"OU\"",
|
|
3311
|
+
"select_attribute_error": "Selecione um atributo para a condição {{id}}",
|
|
3312
|
+
"select_function_error": "Selecione uma função para a condição {{id}}",
|
|
3313
|
+
"select_value_error": "Selecione um valor para a condição {{id}}"
|
|
3314
|
+
}
|
|
3315
|
+
} },
|
|
3316
|
+
en: { translation: {
|
|
3317
|
+
common: {
|
|
3318
|
+
"style_editor": "Style Editor",
|
|
3319
|
+
"reset_style": "Reset Style",
|
|
3320
|
+
"conclude": "Apply",
|
|
3321
|
+
"unique_symbol": "Unique Symbol",
|
|
3322
|
+
"categorized": "Categorized",
|
|
3323
|
+
"graduated": "Quantitative",
|
|
3324
|
+
"null": "Null",
|
|
3325
|
+
"select_type": "Select a style type",
|
|
3326
|
+
"style_type": "Style Type",
|
|
3327
|
+
"based_on_rules": "Based on rules"
|
|
3328
|
+
},
|
|
3329
|
+
errors: {
|
|
3330
|
+
"error_ramps_same_name": "There are ramps with the same name: ",
|
|
3331
|
+
"error_diff": "The difference between the max and min values must be greater than 0, it is: ",
|
|
3332
|
+
"error_sum": "The sum of the counts of the intervals must be equal to the number of values",
|
|
3333
|
+
"error_sum2": "The sum of the counts is wrong: ",
|
|
3334
|
+
"error_values": "The interval values must be increasing."
|
|
3335
|
+
},
|
|
3336
|
+
categorized: {
|
|
3337
|
+
"predefined_styles": "Predefined Styles",
|
|
3338
|
+
"color_ramps": "Color Ramps",
|
|
3339
|
+
"stroke_color": "Stroke Color",
|
|
3340
|
+
"stroke_width": "Stroke Width",
|
|
3341
|
+
"attribute": "Attribute",
|
|
3342
|
+
"select_attribute": "Select an attribute",
|
|
3343
|
+
"update_colors": "Update colors",
|
|
3344
|
+
"color_opacity": "Color Opacity",
|
|
3345
|
+
"colors_spectrum": "Colors Spectrum",
|
|
3346
|
+
"select_spectrum": "Select a spectrum",
|
|
3347
|
+
"custom_style": "Custom Style",
|
|
3348
|
+
"reverse_colors": "Reverse colors",
|
|
3349
|
+
"color_style": "Color Style"
|
|
3350
|
+
},
|
|
3351
|
+
unique_symbol: { "fill_color": "Fill Color" },
|
|
3352
|
+
color_picker: { "select_color": "Select a color" },
|
|
3353
|
+
graduated: {
|
|
3354
|
+
"amount_values": "Amount of values (%)",
|
|
3355
|
+
"values": "Values",
|
|
3356
|
+
"amount": "Amount (%)",
|
|
3357
|
+
"select_mode": "Select a mode",
|
|
3358
|
+
"which_mode": "Which mode to choose?",
|
|
3359
|
+
"interval_size": "Interval size",
|
|
3360
|
+
"classes_number": "Number of classes",
|
|
3361
|
+
"invert_colors": "Invert colors of the spectrum",
|
|
3362
|
+
"gradient_intervals": "Gradient Intervals",
|
|
3363
|
+
"value": "Value",
|
|
3364
|
+
"preview": "Preview",
|
|
3365
|
+
"min_value": "Minimum Value",
|
|
3366
|
+
"max_value": "Maximum Value",
|
|
3367
|
+
"color": "Color",
|
|
3368
|
+
"mode": "Mode"
|
|
3369
|
+
},
|
|
3370
|
+
graduate_modes: {
|
|
3371
|
+
"EqualInterval": "Equal Intervals",
|
|
3372
|
+
"Quantile": "Quantile",
|
|
3373
|
+
"NaturalBreaks": "Natural Breaks (Jenks)",
|
|
3374
|
+
"DefinedInterval": "Defined Intervals",
|
|
3375
|
+
"Manual": "Manual",
|
|
3376
|
+
"GeometricInterval": "Geometric Interval",
|
|
3377
|
+
"StandardDeviation": "Standard Deviation"
|
|
3378
|
+
},
|
|
3379
|
+
based_on_rules: {
|
|
3380
|
+
"name": "Name",
|
|
3381
|
+
"type": "Type",
|
|
3382
|
+
"preview": "Preview",
|
|
3383
|
+
"expression": "Expression",
|
|
3384
|
+
"all_other_geometries": "All other geometries",
|
|
3385
|
+
"filter": "Filter",
|
|
3386
|
+
"select_id_attribute": "Select the ID attribute",
|
|
3387
|
+
"ids_not_unique": "IDs are not unique",
|
|
3388
|
+
"add_rule": "Add Rule",
|
|
3389
|
+
"remove_rule": "Remove Rule",
|
|
3390
|
+
"edit_rule": "Edit Rule"
|
|
3391
|
+
},
|
|
3392
|
+
filters: {
|
|
3393
|
+
"yes": "Yes",
|
|
3394
|
+
"no": "No",
|
|
3395
|
+
"is": "is",
|
|
3396
|
+
"is_not": "is not",
|
|
3397
|
+
"starts_with": "starts with",
|
|
3398
|
+
"ends_with": "ends with",
|
|
3399
|
+
"contains": "contains",
|
|
3400
|
+
"does_not_contain": "does not contain",
|
|
3401
|
+
"is_null": "is null",
|
|
3402
|
+
"is_at_least": "is at least",
|
|
3403
|
+
"is_less_than": "is less than",
|
|
3404
|
+
"is_at_most": "is at most",
|
|
3405
|
+
"is_greater_than": "is greater than",
|
|
3406
|
+
"condition": "Condition ",
|
|
3407
|
+
"select_attribute": "Select the attribute",
|
|
3408
|
+
"select_operator": "Select the operator",
|
|
3409
|
+
"select_value": "Select a value",
|
|
3410
|
+
"invalid_chars_error": "Condition {{id}} contains invalid characters.",
|
|
3411
|
+
"invalid_attribute_error": "The condition has an invalid attribute",
|
|
3412
|
+
"all_true": "All true",
|
|
3413
|
+
"any_true": "At least one true",
|
|
3414
|
+
"expression": "Expression",
|
|
3415
|
+
"add_condition": "Add Condition",
|
|
3416
|
+
"add_filter": "Add Filter",
|
|
3417
|
+
"name": "Name",
|
|
3418
|
+
"filter": "Filter",
|
|
3419
|
+
"all_other_geometries": "All other geometries",
|
|
3420
|
+
"title_empty_error": "Title cannot be empty!",
|
|
3421
|
+
"min_one_expression_error": "Have at least one expression!",
|
|
3422
|
+
"select_and_or_error": "Select whether the expression {{id}} is \"AND\" or \"OR\"",
|
|
3423
|
+
"select_attribute_error": "Select an attribute for condition {{id}}",
|
|
3424
|
+
"select_function_error": "Select a function for condition {{id}}",
|
|
3425
|
+
"select_value_error": "Select a value for condition {{id}}"
|
|
3426
|
+
}
|
|
3427
|
+
} }
|
|
3428
|
+
},
|
|
3429
|
+
interpolation: { escapeValue: false }
|
|
3430
|
+
});
|
|
3431
|
+
var i18n_default = i18next.default;
|
|
3432
|
+
//#endregion
|
|
3433
|
+
//#region src/components/main/StyleEditor.tsx
|
|
3434
|
+
function StyleEditor(props) {
|
|
3435
|
+
const { visible, setVisible, layerDefaultRenderer, layerCurrentRenderer, addingToHeader, applyRenderer, features, showPreDefinedRamps, moreRamps, predefinedStyles, primeReactTheme, numbersLocale, textLocale, customLocale } = props;
|
|
3436
|
+
const addLink = (href) => {
|
|
3437
|
+
const link = document.createElement("link");
|
|
3438
|
+
link.rel = "stylesheet";
|
|
3439
|
+
link.id = "theme-link";
|
|
3440
|
+
link.href = href;
|
|
3441
|
+
document.head.appendChild(link);
|
|
3442
|
+
};
|
|
3443
|
+
if (document.getElementById("primeTheme") == null) if (primeReactTheme == void 0) addLink("https://land-it.github.io/openlayers-style-editor/themes/lara-light-green/theme.css");
|
|
3444
|
+
else addLink("https://land-it.github.io/openlayers-style-editor/themes/" + primeReactTheme + "/theme.css");
|
|
3445
|
+
(0, react.useEffect)(() => {
|
|
3446
|
+
if (textLocale == "custom" && customLocale) {
|
|
3447
|
+
i18n_default.addResourceBundle("custom", "translation", customLocale, true, true);
|
|
3448
|
+
i18n_default.changeLanguage("custom");
|
|
3449
|
+
} else i18n_default.changeLanguage(textLocale ? textLocale : "en");
|
|
3450
|
+
}, []);
|
|
3451
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_i18next.I18nextProvider, {
|
|
3452
|
+
i18n: i18n_default,
|
|
3453
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(primereact_api_api_esm_js.PrimeReactProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyleEditorComponent, {
|
|
3454
|
+
visible,
|
|
3455
|
+
setVisible,
|
|
3456
|
+
layerDefaultRenderer,
|
|
3457
|
+
moreRamps,
|
|
3458
|
+
predefinedStyles,
|
|
3459
|
+
showPreDefinedRamps,
|
|
3460
|
+
applyRenderer,
|
|
3461
|
+
features,
|
|
3462
|
+
layerCurrentRenderer,
|
|
3463
|
+
addingToHeader,
|
|
3464
|
+
numbersLocale: numbersLocale ? numbersLocale : "en-US"
|
|
3465
|
+
}) })
|
|
3466
|
+
}) });
|
|
3467
|
+
}
|
|
3468
|
+
//#endregion
|
|
3469
|
+
exports.AttributeTypeEnum = AttributeTypeEnum;
|
|
3470
|
+
exports.GraduatedModes = GraduatedModes;
|
|
3471
|
+
exports.RenderType = RenderType;
|
|
3472
|
+
exports.StyleEditor = StyleEditor;
|
|
3473
|
+
exports.changeRendererOpacity = changeRendererOpacity;
|
|
3474
|
+
exports.generateRandomColor = generateRandomColor;
|
|
3475
|
+
exports.getByRulesStyle = getByRulesStyle;
|
|
3476
|
+
exports.getCategorizedStyle = getCategorizedStyle;
|
|
3477
|
+
exports.getGraduatedStyle = getGraduatedStyle;
|
|
3478
|
+
exports.getRendererColorAndSizeStroke = getRendererColorAndSizeStroke;
|
|
3479
|
+
exports.getRendererOpacity = getRendererOpacity;
|
|
3480
|
+
exports.getStyleColorsAndValues = getStyleColorsAndValues;
|
|
3481
|
+
exports.singleColorStyle = singleColorStyle;
|
|
3482
|
+
exports.singleColorStyleForLines = singleColorStyleForLines;
|
|
3483
|
+
});
|