@evergis/react 3.0.24 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/core/attributes/index.d.ts +1 -2
  2. package/dist/core/attributes/types.d.ts +2 -5
  3. package/dist/core/index.d.ts +1 -5
  4. package/dist/index.d.ts +2 -17
  5. package/dist/react.cjs.development.js +3 -4860
  6. package/dist/react.cjs.development.js.map +1 -1
  7. package/dist/react.cjs.production.min.js +1 -1
  8. package/dist/react.cjs.production.min.js.map +1 -1
  9. package/dist/react.esm.js +4 -4616
  10. package/dist/react.esm.js.map +1 -1
  11. package/dist/utils/index.d.ts +3 -0
  12. package/package.json +4 -7
  13. package/dist/components/Legend/Legend.d.ts +0 -3
  14. package/dist/components/Legend/components/ClusterSymbolPreview.d.ts +0 -8
  15. package/dist/components/Legend/components/LegendChildren.d.ts +0 -3
  16. package/dist/components/Legend/components/LegendHeaderButtons.d.ts +0 -8
  17. package/dist/components/Legend/components/LegendParameterDescription.d.ts +0 -6
  18. package/dist/components/Legend/components/LegendSection.d.ts +0 -3
  19. package/dist/components/Legend/components/LegendSymbolRenderer.d.ts +0 -6
  20. package/dist/components/Legend/components/MaximizedLegend.d.ts +0 -3
  21. package/dist/components/Legend/components/MinimizedLegend.d.ts +0 -3
  22. package/dist/components/Legend/components/SvgSymbol.d.ts +0 -3
  23. package/dist/components/Legend/components/SymbolByType.d.ts +0 -9
  24. package/dist/components/Legend/components/index.d.ts +0 -9
  25. package/dist/components/Legend/constants.d.ts +0 -44
  26. package/dist/components/Legend/hooks/useSvgSymbol.d.ts +0 -16
  27. package/dist/components/Legend/index.d.ts +0 -6
  28. package/dist/components/Legend/styled.d.ts +0 -54
  29. package/dist/components/Legend/types.d.ts +0 -106
  30. package/dist/components/Legend/utils/getConditionAttribute.d.ts +0 -2
  31. package/dist/components/Legend/utils/getLegendText.d.ts +0 -5
  32. package/dist/components/Legend/utils/isHiddenLegend.d.ts +0 -1
  33. package/dist/components/Symbol/StyleSymbol.d.ts +0 -8
  34. package/dist/components/Symbol/Symbol.d.ts +0 -6
  35. package/dist/components/Symbol/index.d.ts +0 -3
  36. package/dist/components/Symbol/styled.d.ts +0 -9
  37. package/dist/components/index.d.ts +0 -2
  38. package/dist/contexts/LegendContext.d.ts +0 -8
  39. package/dist/contexts/index.d.ts +0 -1
  40. package/dist/core/attributes/format.d.ts +0 -2
  41. package/dist/core/attributes/utils.d.ts +0 -3
  42. package/dist/core/classification/ClassificationCondition.d.ts +0 -15
  43. package/dist/core/classification/ClassificationManager.d.ts +0 -14
  44. package/dist/core/classification/getClassifications.d.ts +0 -4
  45. package/dist/core/classification/index.d.ts +0 -6
  46. package/dist/core/classification/parameter.d.ts +0 -4
  47. package/dist/core/classification/parameterValue.d.ts +0 -9
  48. package/dist/core/classification/printClass.d.ts +0 -2
  49. package/dist/core/classification/types.d.ts +0 -40
  50. package/dist/core/classification/unClassify.d.ts +0 -2
  51. package/dist/core/feature/evaluateCondition.d.ts +0 -2
  52. package/dist/core/feature/getFeatureSymbol.d.ts +0 -7
  53. package/dist/core/feature/index.d.ts +0 -1
  54. package/dist/core/legend/FilterCondition.d.ts +0 -11
  55. package/dist/core/legend/createCondition.d.ts +0 -8
  56. package/dist/core/legend/createValueTitle.d.ts +0 -2
  57. package/dist/core/legend/index.d.ts +0 -3
  58. package/dist/core/legend/isValidParameter.d.ts +0 -2
  59. package/dist/core/legend/types.d.ts +0 -45
  60. package/dist/core/style/EvergisStyle.d.ts +0 -18
  61. package/dist/core/style/compositeSymbol.d.ts +0 -7
  62. package/dist/core/style/index.d.ts +0 -3
  63. package/dist/core/style/types/brush.d.ts +0 -27
  64. package/dist/core/style/types/index.d.ts +0 -8
  65. package/dist/core/style/types/label.d.ts +0 -19
  66. package/dist/core/style/types/miters.d.ts +0 -47
  67. package/dist/core/style/types/offset.d.ts +0 -7
  68. package/dist/core/style/types/parameterValue.d.ts +0 -29
  69. package/dist/core/style/types/style.d.ts +0 -11
  70. package/dist/core/style/types/symbol.d.ts +0 -78
  71. package/dist/core/style/types/utils.d.ts +0 -32
  72. package/dist/hooks/index.d.ts +0 -5
  73. package/dist/hooks/useCanvas.d.ts +0 -6
  74. package/dist/hooks/useMount.d.ts +0 -6
  75. package/dist/hooks/useNode.d.ts +0 -2
  76. package/dist/hooks/useSymbol.d.ts +0 -11
  77. package/dist/hooks/useToggle.d.ts +0 -1
  78. package/dist/i18n/index.d.ts +0 -7
  79. package/dist/symbols/Evergis/SGisBrushFill.d.ts +0 -8
  80. package/dist/symbols/Evergis/SGisImageFill.d.ts +0 -7
  81. package/dist/symbols/Evergis/SGisPolygonSymbol.d.ts +0 -7
  82. package/dist/symbols/Evergis/SGisPolylineSymbol.d.ts +0 -13
  83. package/dist/symbols/Evergis/index.d.ts +0 -4
  84. package/dist/symbols/LineMiters/ArrowLineMiterRender.d.ts +0 -8
  85. package/dist/symbols/LineMiters/CircleLineMiterRender.d.ts +0 -8
  86. package/dist/symbols/LineMiters/LineMiterRender.d.ts +0 -27
  87. package/dist/symbols/LineMiters/SquareLineMiterRender.d.ts +0 -8
  88. package/dist/symbols/LineMiters/getLineMiterRender.d.ts +0 -2
  89. package/dist/symbols/LineMiters/index.d.ts +0 -4
  90. package/dist/symbols/LineMiters/miterStyle.d.ts +0 -7
  91. package/dist/symbols/LineMiters/updateRingsForMiter.d.ts +0 -3
  92. package/dist/symbols/SVGPoly/index.d.ts +0 -25
  93. package/dist/symbols/SVGPoly/types.d.ts +0 -37
  94. package/dist/symbols/Selected/SelectedPointSymbol.d.ts +0 -19
  95. package/dist/symbols/Selected/SelectedPolySymbol.d.ts +0 -21
  96. package/dist/symbols/Selected/index.d.ts +0 -3
  97. package/dist/symbols/Selected/selectedSymbols.d.ts +0 -5
  98. package/dist/symbols/Shadowed/ShadowedPointSymbol.d.ts +0 -22
  99. package/dist/symbols/Shadowed/ShadowedPolySymbol.d.ts +0 -37
  100. package/dist/symbols/Shadowed/getEditorPointRenderer.d.ts +0 -5
  101. package/dist/symbols/Shadowed/index.d.ts +0 -2
  102. package/dist/symbols/adjustSymbol.d.ts +0 -6
  103. package/dist/symbols/deserializeSymbol.d.ts +0 -5
  104. package/dist/symbols/getSymbolRenders.d.ts +0 -5
  105. package/dist/symbols/guards.d.ts +0 -11
  106. package/dist/symbols/index.d.ts +0 -14
  107. package/dist/symbols/mockFeatures.d.ts +0 -35
  108. package/dist/symbols/previewLimits.d.ts +0 -4
  109. package/dist/symbols/renderSymbolToCanvas.d.ts +0 -3
  110. package/dist/symbols/strokeStyle.d.ts +0 -23
  111. package/dist/symbols/types.d.ts +0 -16
  112. package/dist/utils/color.d.ts +0 -1
  113. package/dist/utils/format.d.ts +0 -1
  114. package/dist/utils/isParameterType.d.ts +0 -3
  115. package/dist/utils/legend.d.ts +0 -82
  116. package/dist/utils/math.d.ts +0 -1
  117. package/dist/utils/metersToPixels.d.ts +0 -8
  118. package/dist/utils/polygonCircleFromPoint.d.ts +0 -2
  119. package/dist/utils/svg.d.ts +0 -12
  120. package/dist/utils/url.d.ts +0 -13
@@ -2,437 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var React = require('react');
8
- var React__default = _interopDefault(React);
9
- var styled = require('styled-components');
10
- var styled__default = _interopDefault(styled);
11
- var icons = require('@evergis/icons');
12
- var svg_js = require('@svgdotjs/svg.js');
13
- var Color = require('@evergis/color/es/Color');
14
- var api = require('@evergis/api');
15
5
  var dateFns = require('date-fns');
16
- var condition = require('@evergis/condition');
17
- var i18n = _interopDefault(require('i18next'));
18
- var reactI18next = require('react-i18next');
19
- var LanguageDetector = _interopDefault(require('i18next-browser-languagedetector'));
20
- var get = _interopDefault(require('lodash/get'));
21
- var lodash = require('lodash');
22
- var BrushFill = require('@evergis/sgis/es/symbols/polygon/BrushFill');
23
- var color = require('@evergis/color');
24
- var ImageFill = require('@evergis/sgis/es/symbols/polygon/ImageFill');
25
- var Simple = require('@evergis/sgis/es/symbols/polygon/Simple');
26
- var PolylineSymbol = require('@evergis/sgis/es/symbols/PolylineSymbol');
27
- var Poly = require('@evergis/sgis/es/renders/Poly');
28
- var geotools = require('@evergis/sgis/es/geotools');
29
- var math = require('@evergis/sgis/es/utils/math');
30
- var Poly$1 = require('@evergis/sgis/es/features/Poly');
31
- var Point = require('@evergis/sgis/es/symbols/point/Point');
32
- var PointFeature = require('@evergis/sgis/es/features/PointFeature');
33
- var Arc = require('@evergis/sgis/es/renders/Arc');
34
- var _Symbol = require('@evergis/sgis/es/symbols/Symbol');
35
- var Render = require('@evergis/sgis/es/renders/Render');
36
- var SvgRender = require('@evergis/sgis/es/painters/DomPainter/SvgRender');
37
- var domEvent = require('@evergis/sgis/es/utils/domEvent');
38
- var EventHandler = require('@evergis/sgis/es/EventHandler');
39
- var Crs = require('@evergis/sgis/es/Crs');
40
- var StaticImageSymbol = require('@evergis/sgis/es/symbols/point/StaticImageSymbol');
41
- var Square = require('@evergis/sgis/es/symbols/point/Square');
42
- var MaskedImage = require('@evergis/sgis/es/symbols/point/MaskedImage');
43
- var H3Symbol = require('@evergis/sgis/es/symbols/H3Symbol');
44
- var CombinedPolylineSymbol = require('@evergis/sgis/es/symbols/CombinedPolylineSymbol');
45
- var Polygon = require('@evergis/sgis/es/features/Polygon');
46
- var Polyline = require('@evergis/sgis/es/features/Polyline');
47
- var H3Feature = require('@evergis/sgis/es/features/H3Feature');
48
- var CombinedPolyline = require('@evergis/sgis/es/features/CombinedPolyline');
49
- var Canvas = require('@evergis/sgis/es/painters/DomPainter/Canvas');
50
-
51
- function _classCallCheck(instance, Constructor) {
52
- if (!(instance instanceof Constructor)) {
53
- throw new TypeError("Cannot call a class as a function");
54
- }
55
- }
56
-
57
- function _defineProperties(target, props) {
58
- for (var i = 0; i < props.length; i++) {
59
- var descriptor = props[i];
60
- descriptor.enumerable = descriptor.enumerable || false;
61
- descriptor.configurable = true;
62
- if ("value" in descriptor) descriptor.writable = true;
63
- Object.defineProperty(target, descriptor.key, descriptor);
64
- }
65
- }
66
-
67
- function _createClass(Constructor, protoProps, staticProps) {
68
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
69
- if (staticProps) _defineProperties(Constructor, staticProps);
70
- return Constructor;
71
- }
72
-
73
- function _extends() {
74
- _extends = Object.assign || function (target) {
75
- for (var i = 1; i < arguments.length; i++) {
76
- var source = arguments[i];
77
-
78
- for (var key in source) {
79
- if (Object.prototype.hasOwnProperty.call(source, key)) {
80
- target[key] = source[key];
81
- }
82
- }
83
- }
84
-
85
- return target;
86
- };
87
-
88
- return _extends.apply(this, arguments);
89
- }
90
-
91
- function _inherits(subClass, superClass) {
92
- if (typeof superClass !== "function" && superClass !== null) {
93
- throw new TypeError("Super expression must either be null or a function");
94
- }
95
-
96
- subClass.prototype = Object.create(superClass && superClass.prototype, {
97
- constructor: {
98
- value: subClass,
99
- writable: true,
100
- configurable: true
101
- }
102
- });
103
- if (superClass) _setPrototypeOf(subClass, superClass);
104
- }
105
-
106
- function _getPrototypeOf(o) {
107
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
108
- return o.__proto__ || Object.getPrototypeOf(o);
109
- };
110
- return _getPrototypeOf(o);
111
- }
112
-
113
- function _setPrototypeOf(o, p) {
114
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
115
- o.__proto__ = p;
116
- return o;
117
- };
118
-
119
- return _setPrototypeOf(o, p);
120
- }
121
-
122
- function _isNativeReflectConstruct() {
123
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
124
- if (Reflect.construct.sham) return false;
125
- if (typeof Proxy === "function") return true;
126
-
127
- try {
128
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
129
- return true;
130
- } catch (e) {
131
- return false;
132
- }
133
- }
134
-
135
- function _objectWithoutPropertiesLoose(source, excluded) {
136
- if (source == null) return {};
137
- var target = {};
138
- var sourceKeys = Object.keys(source);
139
- var key, i;
140
-
141
- for (i = 0; i < sourceKeys.length; i++) {
142
- key = sourceKeys[i];
143
- if (excluded.indexOf(key) >= 0) continue;
144
- target[key] = source[key];
145
- }
146
-
147
- return target;
148
- }
149
-
150
- function _assertThisInitialized(self) {
151
- if (self === void 0) {
152
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
153
- }
154
-
155
- return self;
156
- }
157
-
158
- function _possibleConstructorReturn(self, call) {
159
- if (call && (typeof call === "object" || typeof call === "function")) {
160
- return call;
161
- }
162
-
163
- return _assertThisInitialized(self);
164
- }
165
-
166
- function _createSuper(Derived) {
167
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
168
-
169
- return function _createSuperInternal() {
170
- var Super = _getPrototypeOf(Derived),
171
- result;
172
-
173
- if (hasNativeReflectConstruct) {
174
- var NewTarget = _getPrototypeOf(this).constructor;
175
-
176
- result = Reflect.construct(Super, arguments, NewTarget);
177
- } else {
178
- result = Super.apply(this, arguments);
179
- }
180
-
181
- return _possibleConstructorReturn(this, result);
182
- };
183
- }
184
-
185
- function _superPropBase(object, property) {
186
- while (!Object.prototype.hasOwnProperty.call(object, property)) {
187
- object = _getPrototypeOf(object);
188
- if (object === null) break;
189
- }
190
-
191
- return object;
192
- }
193
-
194
- function _get(target, property, receiver) {
195
- if (typeof Reflect !== "undefined" && Reflect.get) {
196
- _get = Reflect.get;
197
- } else {
198
- _get = function _get(target, property, receiver) {
199
- var base = _superPropBase(target, property);
200
-
201
- if (!base) return;
202
- var desc = Object.getOwnPropertyDescriptor(base, property);
203
-
204
- if (desc.get) {
205
- return desc.get.call(receiver);
206
- }
207
-
208
- return desc.value;
209
- };
210
- }
211
-
212
- return _get(target, property, receiver || target);
213
- }
214
-
215
- function _taggedTemplateLiteralLoose(strings, raw) {
216
- if (!raw) {
217
- raw = strings.slice(0);
218
- }
219
6
 
220
- strings.raw = raw;
221
- return strings;
222
- }
223
-
224
- const isParameterType = (types, parameter) => {
225
- var _parameter$toLowerCas;
226
-
227
- return (typeof types === 'string' ? parameter == null ? void 0 : (_parameter$toLowerCas = parameter.toLowerCase()) == null ? void 0 : _parameter$toLowerCas.includes(types.toLowerCase()) : types.some(type => {
228
- var _parameter$toLowerCas2;
229
-
230
- return parameter == null ? void 0 : (_parameter$toLowerCas2 = parameter.toLowerCase()) == null ? void 0 : _parameter$toLowerCas2.includes(type.toLowerCase());
231
- })) || false;
232
- };
233
-
234
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33, _templateObject34, _templateObject35, _templateObject36, _templateObject37, _templateObject38;
235
- const MapLegendDescription = /*#__PURE__*/styled__default.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 0.75rem;\n"])));
236
- const ItemText = /*#__PURE__*/styled__default.div(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n max-width: calc(100% - 2rem);\n font: ", ";\n"])), (_ref) => {
237
- let {
238
- theme: {
239
- fonts
240
- }
241
- } = _ref;
242
- return fonts.description;
243
- });
244
- const ItemSeparator = /*#__PURE__*/styled__default.div(_templateObject3 || (_templateObject3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n :after {\n content: '-';\n margin: 0 0.5rem;\n font-size: 0.75rem;\n }\n"])));
245
- const SymbolContainer = /*#__PURE__*/styled__default('span')(_templateObject4 || (_templateObject4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: center;\n min-width: 1.5rem;\n margin-right: 0.5rem;\n"])));
246
- const ClassifiedItem = /*#__PURE__*/styled__default.div(_templateObject5 || (_templateObject5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n align-items: center;\n cursor: ", ";\n pointer-events: ", ";\n\n :not(:last-of-type) {\n margin-bottom: 0.25rem;\n }\n\n ", ", ", " {\n transition: opacity 150ms;\n }\n\n ", " {\n opacity: ", ";\n }\n\n ", " {\n opacity: ", ";\n }\n\n :hover {\n ", ", ", " {\n opacity: 1;\n }\n }\n\n ", " {\n margin-left: 0.5rem;\n }\n"])), (_ref2) => {
247
- let {
248
- isClusterFillColor
249
- } = _ref2;
250
- return isClusterFillColor ? 'default' : 'pointer';
251
- }, (_ref3) => {
252
- let {
253
- isClusterFillColor
254
- } = _ref3;
255
- return isClusterFillColor ? 'none' : 'auto';
256
- }, ItemText, SymbolContainer, ItemText, (_ref4) => {
257
- let {
258
- isHidden
259
- } = _ref4;
260
- return isHidden ? 0.28 : 0.65;
261
- }, SymbolContainer, (_ref5) => {
262
- let {
263
- isHidden
264
- } = _ref5;
265
- return isHidden ? 0.28 : 1;
266
- }, ItemText, SymbolContainer, icons.IconButton);
267
- const SymbolButtonWithClick = /*#__PURE__*/styled.css(_templateObject6 || (_templateObject6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 3.875rem;\n height: 3.875rem;\n cursor: pointer;\n\n &:hover {\n background-color: ", ";\n }\n"])), (_ref6) => {
268
- let {
269
- theme: {
270
- palette
271
- }
272
- } = _ref6;
273
- return palette.elementDeep;
274
- });
275
- const SymbolButton = /*#__PURE__*/styled__default.span(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background-color 150ms;\n ", ";\n\n svg {\n max-width: 4rem;\n max-height: 4rem;\n }\n"])), (_ref7) => {
276
- let {
277
- onClick
278
- } = _ref7;
279
- return !!onClick && SymbolButtonWithClick;
280
- });
281
- const MapLegendContainer = /*#__PURE__*/styled__default.div(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n width: 100%;\n padding-bottom: 1rem;\n box-sizing: border-box;\n\n canvas {\n height: 1.625rem;\n width: 1.625rem;\n }\n"])));
282
- const MapLegendHeader = /*#__PURE__*/styled__default.div(_templateObject9 || (_templateObject9 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n max-width: 15rem;\n margin-bottom: 0.25rem;\n font-size: 0.75rem;\n font-weight: bold;\n"])));
283
- const MapLegendDescriptionContainer = /*#__PURE__*/styled__default.div(_templateObject10 || (_templateObject10 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-bottom: 0.5rem;\n font-weight: 400;\n font-size: 0.625rem;\n color: rgba(48, 69, 79, 0.65);\n"])));
284
- const MapLegendBadge = /*#__PURE__*/styled__default.span(_templateObject11 || (_templateObject11 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n min-width: 0.5rem;\n height: 0.75rem;\n display: inline-block;\n margin-left: 0.25rem;\n padding: 0.125rem 0.25rem;\n border-radius: ", ";\n background-color: ", ";\n color: ", ";\n text-align: center;\n"])), (_ref8) => {
285
- let {
286
- theme: {
287
- borderRadius
288
- }
289
- } = _ref8;
290
- return borderRadius.xSmall;
291
- }, (_ref9) => {
292
- let {
293
- theme: {
294
- palette
295
- }
296
- } = _ref9;
297
- return palette.element;
298
- }, (_ref10) => {
299
- let {
300
- theme: {
301
- palette
302
- }
303
- } = _ref10;
304
- return palette.textPrimary;
305
- });
306
- const MaximizedLegendContainer = /*#__PURE__*/styled__default.div(_templateObject12 || (_templateObject12 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: ", ";\n top: 0;\n opacity: ", ";\n visibility: ", ";\n overflow: hidden;\n transition: opacity 0.5s, visibility 0.5s;\n"])), (_ref11) => {
307
- let {
308
- isShown
309
- } = _ref11;
310
- return isShown ? 'relative' : 'absolute';
311
- }, (_ref12) => {
312
- let {
313
- isShown
314
- } = _ref12;
315
- return isShown ? 1 : 0;
316
- }, (_ref13) => {
317
- let {
318
- isShown
319
- } = _ref13;
320
- return isShown ? 'visible' : 'hidden';
321
- });
322
- const MinimizedLegendContainer = /*#__PURE__*/styled__default(MaximizedLegendContainer)(_templateObject13 || (_templateObject13 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: calc(100% - 1.5rem);\n padding-right: 1.5rem;\n"])));
323
- const LegendHeaderButton = /*#__PURE__*/styled__default.span(_templateObject14 || (_templateObject14 = /*#__PURE__*/_taggedTemplateLiteralLoose([""])));
324
- const MapLegendSectionContainer = /*#__PURE__*/styled__default.div(_templateObject15 || (_templateObject15 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 100%;\n\n :not(:last-child) {\n margin-bottom: 1rem;\n }\n\n ", " {\n padding-left: 0.75rem;\n visibility: hidden;\n\n :first-child {\n padding-left: 1rem;\n }\n\n :last-child {\n margin-left: 0.75rem;\n border-left: 1px ", " solid;\n }\n }\n \n :hover {\n ", " {\n visibility: visible;\n }\n }\n"])), LegendHeaderButton, (_ref14) => {
325
- let {
326
- theme: {
327
- palette
328
- }
329
- } = _ref14;
330
- return palette.elementDeep;
331
- }, LegendHeaderButton);
332
- const MapLegendSectionItems = /*#__PURE__*/styled__default.div(_templateObject16 || (_templateObject16 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n height: ", "px;\n overflow: ", ";\n transition: height 0.5s;\n"])), (_ref15) => {
333
- let {
334
- minHeight,
335
- maxHeight,
336
- isExpanded
337
- } = _ref15;
338
- return isExpanded ? (maxHeight || 0) + 4 : minHeight;
339
- }, (_ref16) => {
340
- let {
341
- isExpanded
342
- } = _ref16;
343
- return isExpanded ? 'none' : 'hidden';
344
- });
345
- const MapLegendValueDescr = /*#__PURE__*/styled__default.div(_templateObject17 || (_templateObject17 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n min-height: 1rem;\n margin-bottom: 0.25rem;\n font-size: 0.75rem;\n font-weight: 600;\n line-height: 1rem;\n"])));
346
-
347
- const SizeLegendItemMixin = function SizeLegendItemMixin(value) {
348
- if (value === void 0) {
349
- value = 0;
350
- }
351
-
352
- return styled.css(_templateObject18 || (_templateObject18 = _taggedTemplateLiteralLoose(["\n position: absolute;\n bottom: 0;\n left: 50%;\n display: flex;\n align-items: flex-end;\n flex: none;\n height: inherit;\n width: inherit;\n margin: 0 auto;\n background: none;\n border: none;\n\n :after {\n content: '';\n display: flex;\n border: 1px rgba(48, 69, 79, 0.28) solid;\n border-radius: 50%;\n margin: 0 0 0 -", "px;\n width: ", "px;\n height: ", "px;\n }\n"])), value / 2, value, value);
353
- };
354
-
355
- const StrokeWidthLegendItemMixin = function StrokeWidthLegendItemMixin(value) {
356
- if (value === void 0) {
357
- value = 0;
358
- }
359
-
360
- return styled.css(_templateObject19 || (_templateObject19 = _taggedTemplateLiteralLoose(["\n position: relative;\n background: none;\n border: none;\n display: flex;\n align-items: center;\n flex: none;\n width: calc(100% - 2rem);\n height: ", "px;\n margin: 0 0 0.25rem 0;\n padding-left: 2rem;\n font-size: 0.75rem;\n\n :first-child,\n :last-child {\n height: auto;\n }\n\n :after {\n content: '';\n position: absolute;\n top: 50%;\n left: 0;\n width: 1.5rem;\n height: ", "px;\n margin-top: -", "px;\n background: rgb(224, 224, 224);\n }\n"])), value, value, Math.round(value / 2));
361
- };
362
-
363
- const StrokeColorLegendItemMixin = /*#__PURE__*/styled.css(_templateObject20 || (_templateObject20 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-right: 0.5rem;\n width: 1.5rem;\n"])));
364
- const MapLegendItem = /*#__PURE__*/styled__default.div(_templateObject21 || (_templateObject21 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex: 1;\n height: ", "rem;\n background: ", ";\n border: 1px rgba(48, 69, 79, 0.1) solid;\n margin-right: -1px;\n color: rgba(48, 69, 79, 0.65);\n opacity: ", ";\n\n ", "\n\n ", "\n"])), (_ref17) => {
365
- let {
366
- parameter
367
- } = _ref17;
368
- return isParameterType(['strokeColor', 'stroke.color'], parameter) ? 0.25 : 1;
369
- }, (_ref18) => {
370
- let {
371
- value
372
- } = _ref18;
373
- return typeof value === 'number' ? 'none' : value;
374
- }, (_ref19) => {
375
- let {
376
- isHidden
377
- } = _ref19;
378
- return isHidden ? 0.28 : 1;
379
- }, (_ref20) => {
380
- let {
381
- value,
382
- parameter
383
- } = _ref20;
384
- return isParameterType('size', parameter) && SizeLegendItemMixin(value);
385
- }, (_ref21) => {
386
- let {
387
- value,
388
- parameter
389
- } = _ref21;
390
- return isParameterType(['strokeWidth', 'stroke.width'], parameter) && StrokeWidthLegendItemMixin(value);
391
- });
392
- const MapLegendOther = /*#__PURE__*/styled__default(MapLegendItem)(_templateObject22 || (_templateObject22 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n flex: none;\n position: relative;\n width: 1rem;\n margin-left: 0.25rem;\n border-radius: 0.125rem;\n"])));
393
- const SizeLegendItemsMixin = /*#__PURE__*/styled.css(_templateObject23 || (_templateObject23 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n width: 2rem;\n height: 2rem;\n margin: 0 auto;\n\n ", " {\n width: auto;\n margin-left: 0;\n }\n"])), MapLegendOther);
394
- const StrokeWidthLegendItemsMixin = /*#__PURE__*/styled.css(_templateObject24 || (_templateObject24 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n flex-direction: column;\n width: auto;\n\n ", " {\n width: calc(100% - 2rem);\n margin-left: 0;\n }\n"])), MapLegendOther);
395
- const SizeMinimizedLegend = /*#__PURE__*/styled__default.div(_templateObject25 || (_templateObject25 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-wrap: nowrap;\n align-items: center;\n margin: 0.5rem 0 0.25rem;\n"])));
396
- const SizeMinimizedLegendSymbol = /*#__PURE__*/styled__default.div(_templateObject26 || (_templateObject26 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 4rem;\n margin-right: 0.75rem;\n"])));
397
- const SizeMinimizedLegendLabel = /*#__PURE__*/styled__default.div(_templateObject27 || (_templateObject27 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n max-width: 9.75rem;\n font-size: 0.75rem;\n"])));
398
- const SizeMinimizedLegendDown = /*#__PURE__*/styled__default.div(_templateObject28 || (_templateObject28 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: rgba(48, 69, 79, 0.65);\n"])));
399
- const SizeMinimizedLegendUp = /*#__PURE__*/styled__default(SizeMinimizedLegendDown)(_templateObject29 || (_templateObject29 = /*#__PURE__*/_taggedTemplateLiteralLoose([""])));
400
- const SingleSizeLegendItemsMixin = /*#__PURE__*/styled.css(_templateObject30 || (_templateObject30 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 4rem;\n margin-right: 0.75rem;\n\n ", ":after {\n margin: 0 auto;\n }\n"])), MapLegendItem);
401
- const SingleLegendItemsMixin = /*#__PURE__*/styled.css(_templateObject31 || (_templateObject31 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n justify-content: center;\n width: 2rem;\n height: auto;\n margin: 0;\n ", "\n\n ", " {\n position: relative;\n top: 0;\n left: 0;\n display: flex;\n align-content: center;\n justify-content: center;\n margin: 0;\n height: auto;\n width: auto;\n\n ", "\n }\n"])), (_ref22) => {
402
- let {
403
- isSize
404
- } = _ref22;
405
- return isSize && SingleSizeLegendItemsMixin;
406
- }, MapLegendItem, (_ref23) => {
407
- let {
408
- parameter
409
- } = _ref23;
410
- return isParameterType(['strokeColor', 'stroke.color'], parameter) && StrokeColorLegendItemMixin;
411
- });
412
- const MapLegendItems = /*#__PURE__*/styled__default.div(_templateObject32 || (_templateObject32 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n width: 100%;\n border-radius: 0.125rem;\n\n ", ";\n ", ";\n ", ";\n"])), (_ref24) => {
413
- let {
414
- isSize
415
- } = _ref24;
416
- return isSize && SizeLegendItemsMixin;
417
- }, (_ref25) => {
418
- let {
419
- isStrokeWidth
420
- } = _ref25;
421
- return isStrokeWidth && StrokeWidthLegendItemsMixin;
422
- }, (_ref26) => {
423
- let {
424
- isSingle
425
- } = _ref26;
426
- return isSingle && SingleLegendItemsMixin;
427
- });
428
- const MapLegendItemsContainer = /*#__PURE__*/styled__default.div(_templateObject33 || (_templateObject33 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n width: 100%;\n\n ", " {\n :first-child {\n border-top-left-radius: 0.125rem;\n border-bottom-left-radius: 0.125rem;\n }\n\n :last-child {\n border-top-right-radius: 0.125rem;\n border-bottom-right-radius: 0.125rem;\n }\n }\n"])), MapLegendItem);
429
- const MapLegendValues = /*#__PURE__*/styled__default.div(_templateObject34 || (_templateObject34 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n width: 100%;\n margin-top: 0.5rem;\n font-size: 0.75rem;\n color: rgba(48, 69, 79, 0.65);\n"])));
430
- const MapLegendValuesRange = /*#__PURE__*/styled__default.div(_templateObject35 || (_templateObject35 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: space-between;\n width: calc(100% - 1.25rem);\n\n div {\n flex: 1;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n\n :first-child {\n margin-right: 0.5rem;\n }\n\n :last-child {\n margin-left: 0.5rem;\n text-align: right;\n }\n }\n"])));
431
- const MapLegendValuesOther = /*#__PURE__*/styled__default(MapLegendOther)(_templateObject36 || (_templateObject36 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n justify-content: center;\n border: 0;\n overflow: visible;\n"])));
432
- const MapLegendExpandButton = /*#__PURE__*/styled__default.div(_templateObject37 || (_templateObject37 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n cursor: pointer;\n margin-top: 0.1rem;\n font-size: 0.625rem;\n color: #1fb3aa;\n"])));
433
- const ClusterLegendContainer = /*#__PURE__*/styled__default.div(_templateObject38 || (_templateObject38 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: -0.9rem;\n transform: scale(0.5);\n"])));
434
-
435
- const NO_CONTENT_VALUE = '—';
7
+ const NO_CONTENT_VALUE = "—";
436
8
 
437
9
  (function (DateFormat) {
438
10
  DateFormat["ClientDefaultFormat"] = "dd.MM.yyyy HH:mm";
@@ -474,4444 +46,15 @@ const formatDate = function formatDate(date, _temp) {
474
46
  return defaultValue.toString();
475
47
  };
476
48
 
477
- function numberWithSpaces(x, fractionDigits, delim) {
478
- if (fractionDigits === void 0) {
479
- fractionDigits = 2;
480
- }
481
-
482
- if (delim === void 0) {
483
- delim = ',';
484
- }
485
-
486
- const [num, frac] = x.toFixed(fractionDigits).split('.');
487
- const numWithSpaces = num.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
488
- return [numWithSpaces, frac].join(delim);
489
- }
490
-
491
- function matchPhone(value) {
492
- const phoneRegexp = /((8|\+7)[- ]?)?(\(?\d{3,4}\)?[- ]?)?[\d\- ]{7,10}/g;
493
- return !isStringAsInn(value) && value.match(phoneRegexp);
494
- }
495
- function isStringAsInn(value) {
496
- const innRegexp = /^(([0-9]{12})|([0-9]{10}))$/;
497
- return innRegexp.test(value);
498
- }
499
- function isStringAsKpp(value) {
500
- const kppRegexp = /^(([0-9]{9}))$/;
501
- return kppRegexp.test(value);
502
- }
503
- function isStringAsOgrn(value) {
504
- const ogrnRegexp = /^([0-9]{13})?$/;
505
- return ogrnRegexp.test((+value).toString());
506
- }
507
- function isStringContainsDate(value) {
508
- const dateRegexp = /\d{4}(-|\/)\d{2}(-|\/)\d{2}/g;
509
- return dateRegexp.test(value);
510
- }
511
- function isRequisiteNumbers(value) {
512
- return isStringAsInn(value) || isStringAsKpp(value) || isStringAsOgrn(value);
513
- }
514
- function isStringAsPhone(value) {
515
- const phoneRegexp = /^((8|\+7)[- ]?)?(\(?\d{3,4}\)?[- ]?)?[\d\- ]{7,10}/;
516
- return !isRequisiteNumbers(value) && !isStringContainsDate(value) && phoneRegexp.test(value);
517
- }
518
- function isStringAsMail(value) {
519
- return isStringAsUrl(value) && value.includes('@');
520
- }
521
- function isStringAsUrl(value) {
522
- if (isValidUrl(value)) {
523
- return true;
524
- }
525
-
526
- const urlRegexp = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g;
527
- const urlKind = value.match(urlRegexp);
528
- return urlKind !== null;
529
- }
530
- function isValidUrl(value) {
531
- try {
532
- new URL(value);
533
- } catch (_) {
534
- return false;
535
- }
536
-
537
- return true;
538
- }
539
- const mailHref = mail => "mailto:" + mail;
540
- const phoneHref = mail => "tel:" + mail;
541
- const urlHref = url => isValidUrl(url) ? url : "//" + url;
542
-
543
- const stringAttribute = value => ({
544
- type: 0
545
- /* String */
546
- ,
547
- value
548
- });
549
-
550
- const urlAttribute = value => ({
551
- type: 2
552
- /* Url */
553
- ,
554
- value
555
- });
556
-
557
- const mailAttribute = value => ({
558
- type: 3
559
- /* Mail */
560
- ,
561
- value
562
- });
563
-
564
- const phoneAttribute = value => ({
565
- type: 1
566
- /* Phone */
567
- ,
568
- value
569
- });
570
-
571
- const convertStringAttribute = value => {
572
- if (isStringAsMail(value)) {
573
- return mailAttribute(value);
574
- }
575
-
576
- if (isStringAsUrl(value)) {
577
- return urlAttribute(value);
578
- }
579
-
580
- if (isStringAsPhone(value)) {
581
- return phoneAttribute(value);
582
- }
583
-
584
- return stringAttribute(value);
585
- };
586
-
587
- const formatStringAttribute = value => {
588
- const phones = matchPhone(value);
589
-
590
- if (!isRequisiteNumbers(value) && !isStringContainsDate(value) && phones && phones.length) {
591
- return phones.map(phoneAttribute);
592
- }
593
-
594
- const attributeValues = value.split(/[\s|]/).map(convertStringAttribute);
595
-
596
- if (attributeValues.every((_ref) => {
597
- let {
598
- type
599
- } = _ref;
600
- return type === 0;
601
- }
602
- /* String */
603
- )) {
604
- return [stringAttribute(attributeValues.map((_ref2) => {
605
- let {
606
- value
607
- } = _ref2;
608
- return isNaN(+value) || isRequisiteNumbers(value) ? isStringAsOgrn(value) ? +value : value : numberWithSpaces(+value, 0, '');
609
- }).join(' '))];
610
- }
611
-
612
- return attributeValues;
613
- };
614
-
615
- const formatDateTimeAttribute = value => stringAttribute(value.toString());
616
-
617
- const formatIntAttribute = value => stringAttribute(numberWithSpaces(value, 0, ''));
618
-
619
- const DOUBLE_FRACTIONS = 2;
620
-
621
- const formatDoubleAttribute = value => stringAttribute(numberWithSpaces(value, DOUBLE_FRACTIONS, '.'));
622
-
623
- const isNullOrUndefined = value => value === null || value === undefined;
624
-
625
- const NO_CONTENT_ATTRIBUTE = {
626
- type: 0
627
- /* String */
628
- ,
629
- value: NO_CONTENT_VALUE
630
- };
631
- const formatAttributeValue = attribute => {
632
- if (isNullOrUndefined(attribute.value)) {
633
- return [NO_CONTENT_ATTRIBUTE];
634
- }
635
-
636
- switch (attribute.type) {
637
- case 'String':
638
- return formatStringAttribute(attribute.value);
639
-
640
- case 'DateTime':
641
- return [formatDateTimeAttribute(attribute.value)];
642
-
643
- case 'Int32':
644
- case 'Int64':
645
- return [formatIntAttribute(attribute.value)];
646
-
647
- case 'Double':
648
- return [formatDoubleAttribute(attribute.value)];
649
-
650
- default:
651
- return [NO_CONTENT_ATTRIBUTE];
652
- }
653
- };
654
-
655
- function isRangeClass(value) {
656
- return Boolean(value && 'from' in value);
657
- }
658
- function isUniqueClass(value) {
659
- return Boolean(value && 'uniqueValue' in value);
660
- }
661
-
662
- const NULL_EXPRESSION = {
663
- // @ts-ignore TODO
664
- attribute: null,
665
- // @ts-ignore TODO
666
- operation: null,
667
- value: null
668
- };
669
- let ClassificationCondition = /*#__PURE__*/function () {
670
- function ClassificationCondition(condition$1) {
671
- _classCallCheck(this, ClassificationCondition);
672
-
673
- this.expressions = [];
674
- this.condition = condition$1;
675
- const conditionResult = new condition.ConditionInterpreter(condition$1).value;
676
- this.expressions = conditionResult instanceof Error ? [] : conditionResult.expressions;
677
- }
678
-
679
- _createClass(ClassificationCondition, [{
680
- key: "attributeName",
681
- get: function get() {
682
- return this.leftExpression.attribute;
683
- }
684
- }, {
685
- key: "uniqueValue",
686
- get: function get() {
687
- if (this.isUnique()) {
688
- const {
689
- value
690
- } = this.leftExpression;
691
- return typeof value === 'string' ? value : '';
692
- }
693
-
694
- console.warn("Trying to get unique from range condition " + this.condition);
695
- return '';
696
- }
697
- }, {
698
- key: "range",
699
- get: function get() {
700
- if (!this.isRange()) {
701
- console.warn("Trying to get range from unique condition " + this.condition);
702
- return [0, 0];
703
- }
704
-
705
- if (this.expressions.length === 2) {
706
- const {
707
- value: from
708
- } = this.leftExpression;
709
- const {
710
- value: to
711
- } = this.rightExpression;
712
- return [from, to];
713
- }
714
-
715
- if (this.expressions.length === 1) {
716
- const {
717
- operation,
718
- value
719
- } = this.leftExpression;
720
- const isFrom = operation === condition.TokenType.ArGr;
721
- return [isFrom ? value : null, isFrom ? null : value];
722
- }
723
-
724
- return [0, 0];
725
- }
726
- }, {
727
- key: "type",
728
- get: function get() {
729
- return this.isUnique() ? 1
730
- /* Unique */
731
- : 0
732
- /* Range */
733
- ;
734
- }
735
- }, {
736
- key: "isUnique",
737
- value: function isUnique() {
738
- return this.leftExpression.operation === condition.TokenType.ArEq;
739
- }
740
- }, {
741
- key: "isRange",
742
- value: function isRange() {
743
- return [condition.TokenType.ArGr, condition.TokenType.ArGre, condition.TokenType.ArLs, condition.TokenType.ArLse].includes(this.leftExpression.operation);
744
- }
745
- }, {
746
- key: "toString",
747
- value: function toString() {
748
- return this.condition;
749
- }
750
- }, {
751
- key: "leftExpression",
752
- get: function get() {
753
- return this.expressions.length > 0 ? this.expressions[0] : NULL_EXPRESSION;
754
- }
755
- }, {
756
- key: "rightExpression",
757
- get: function get() {
758
- return this.expressions.length > 1 ? this.expressions[1] : NULL_EXPRESSION;
759
- }
760
- }]);
761
-
762
- return ClassificationCondition;
763
- }();
764
-
765
- const PARAMETER_SEPARATOR = '.';
766
- const parameterToPaths = parameter => parameter.split(PARAMETER_SEPARATOR);
767
- const pathsToParameter = paths => paths.join(PARAMETER_SEPARATOR);
49
+ const isNumeric = number => !isNaN(parseFloat(number)) && isFinite(number);
768
50
 
769
51
  function isObject(value) {
770
- return typeof value === 'object' && value !== null && !Array.isArray(value);
771
- }
772
-
773
- const isParameterByAttribute = value => Boolean(isObject(value) && (value == null ? void 0 : value.type) === 'byAttribute');
774
- const isCalculatedParameter = value => Boolean(isObject(value) && (value == null ? void 0 : value.type) === 'calculated');
775
- const getParameterValue = value => {
776
- if (isParameterByAttribute(value) || isCalculatedParameter(value)) {
777
- return value.defaultValue;
778
- }
779
-
780
- return value;
781
- };
782
- const symbolParameterWalker = valueModifier => (symbol, parameter) => {
783
- const paths = Array.isArray(parameter) ? parameter : parameterToPaths(parameter);
784
- const [firstKey, ...restKeys] = paths; // @ts-ignore
785
-
786
- const symbolPart = symbol[firstKey];
787
-
788
- if (restKeys.length) {
789
- const goDeeper = symbolParameterWalker(valueModifier);
790
- return _extends({}, symbol, {
791
- [firstKey]: goDeeper(symbolPart, restKeys) || symbolPart
792
- });
793
- }
794
-
795
- return _extends({}, symbol, {
796
- [firstKey]: valueModifier(symbolPart) || symbolPart
797
- });
798
- };
799
- const setDefaultParameterValue = /*#__PURE__*/symbolParameterWalker(getParameterValue);
800
- const setParameterValue = (symbol, path, value) => symbolParameterWalker(() => value)(symbol, path);
801
- function applyParameterValue(symbol, path, value) {
802
- if (path === 'symbol') {
803
- return value;
804
- }
805
-
806
- return setParameterValue(symbol, path, value);
52
+ return typeof value === "object" && value !== null && !Array.isArray(value);
807
53
  }
808
54
 
809
- const symbolTypeGuard = type => symbol => symbol && symbol.type === type;
810
-
811
- const isPointLabelSymbol = /*#__PURE__*/symbolTypeGuard('labelPointSymbol');
812
- const isPolygonLabelSymbol = /*#__PURE__*/symbolTypeGuard('polygonLabelSymbol');
813
- const isPolylineLabelSymbol = /*#__PURE__*/symbolTypeGuard('polylineLabelSymbol');
814
- const isLabelSymbol = symbol => Boolean(symbol && (isPointLabelSymbol(symbol) || isPolygonLabelSymbol(symbol) || isPolylineLabelSymbol(symbol)));
815
-
816
- const _excluded = ["ignoreLabel", "label", "symbol", "raster", "children"];
817
- const createCompositeSymbol = childSymbols => ({
818
- type: 'compositeSymbol',
819
- childSymbols
820
- });
821
- const getChildSymbols = symbol => {
822
- if (!symbol || !isCompositeSymbol(symbol)) return [];
823
- return symbol.childSymbols || [];
824
- };
825
- const extractSymbol = symbol => {
826
- const childSymbols = getChildSymbols(symbol);
827
- return {
828
- // @ts-ignore
829
- symbol: childSymbols.find(isSimpleSymbol),
830
- label: childSymbols.find(isLabelSymbol) || null,
831
- raster: childSymbols.find(isRasterSymbol) || null
832
- };
833
- };
834
- const extractStyle = style => {
835
- // @ts-ignore
836
- if (isCompositeSymbol(style.symbol)) {
837
- return _extends({}, style, extractSymbol(style.symbol), {
838
- // @ts-ignore
839
- children: style.children && style.children.map(extractStyle)
840
- });
841
- } // NOTE: for cases when style is exist style object should have same reference for all extractStyle calls
842
-
843
-
844
- return style || {};
845
- };
846
- const packStyle = style => {
847
- const {
848
- ignoreLabel,
849
- label,
850
- symbol,
851
- raster,
852
- children
853
- } = style,
854
- styleDc = _objectWithoutPropertiesLoose(style, _excluded);
855
-
856
- const childSymbols = [!ignoreLabel && label, raster].filter(Boolean);
857
- return _extends({}, styleDc, {
858
- symbol: childSymbols.length ? // @ts-ignore
859
- createCompositeSymbol([symbol, ...childSymbols]) : symbol,
860
- // @ts-ignore
861
- children: children ? // @ts-ignore
862
- children.map(childStyle => packStyle(_extends({}, childStyle, {
863
- ignoreLabel,
864
- label
865
- }))) : children
866
- });
867
- };
868
-
869
- const isPointSymbol = /*#__PURE__*/symbolTypeGuard('circlePointSymbol');
870
- const isSquareSymbol = /*#__PURE__*/symbolTypeGuard('squarePointSymbol');
871
- const isMaskedImageSymbol = /*#__PURE__*/symbolTypeGuard('maskedImagePointSymbol');
872
- const isStaticImageSymbol = /*#__PURE__*/symbolTypeGuard('imagePointSymbol');
873
- const isCombinedPolylineSymbol = /*#__PURE__*/symbolTypeGuard("combinedPolylineSymbol");
874
- const isPolygonSymbol = /*#__PURE__*/symbolTypeGuard('polygonSymbol');
875
- const isSimplePolylineSymbol = /*#__PURE__*/symbolTypeGuard('simplePolylineSymbol');
876
- const isPolylineSymbols = symbol => Boolean(symbol && (isCombinedPolylineSymbol(symbol) || isSimplePolylineSymbol(symbol)));
877
- const isCompositeSymbol = /*#__PURE__*/symbolTypeGuard('compositeSymbol');
878
- const isRasterSymbol = /*#__PURE__*/symbolTypeGuard('rasterSymbol');
879
- const isImageSymbol = symbol => Boolean(symbol && (isMaskedImageSymbol(symbol) || isStaticImageSymbol(symbol)));
880
- const isTwoDimensionalSymbol = symbol => Boolean(symbol && 'width' in symbol);
881
- const isSizableSymbol = symbol => Boolean(symbol && 'size' in symbol);
882
- const isStrokeStyledSymbol = symbol => Boolean(symbol && (isPolygonSymbol(symbol) || isPolylineSymbols(symbol)));
883
- const isScalablePolylineSymbol = symbol => symbol.beginning !== null && symbol.ending !== null || symbol.stroke && symbol.stroke.type !== 'solid';
884
- const isSimpleSymbol = symbol => Boolean(symbol && !isLabelSymbol(symbol) && !isCompositeSymbol(symbol) && !isRasterSymbol(symbol));
885
- const isH3GridSymbol = /*#__PURE__*/symbolTypeGuard("h3grid");
886
- const isSvgPointSymbol = /*#__PURE__*/symbolTypeGuard("svgPointSymbol");
887
- const isClusterSymbol = /*#__PURE__*/symbolTypeGuard("cluster");
888
- const isClusterFillColor = (symbol, parameter) => {
889
- return isClusterSymbol(symbol) && parameter === "fillColor";
890
- };
891
- const getExtractedSymbol = function getExtractedSymbol(symbol, extractCluster) {
892
- var _extractSymbol;
893
-
894
- if (extractCluster === void 0) {
895
- extractCluster = false;
896
- }
897
-
898
- const extracted = isCompositeSymbol(symbol) ? (_extractSymbol = extractSymbol(symbol)) == null ? void 0 : _extractSymbol.symbol : symbol;
899
- return extractCluster && isClusterSymbol(extracted) ? extracted.singleObjectSymbol : extracted;
900
- };
901
-
902
- const isHatchBrush = /*#__PURE__*/symbolTypeGuard('hatch');
903
- const isPatternBrush = /*#__PURE__*/symbolTypeGuard('pattern');
904
- const isDashedBrush = /*#__PURE__*/symbolTypeGuard('dashed');
905
- const isSolidBrush = /*#__PURE__*/symbolTypeGuard('solid');
906
- const isPolygonHasPatternBrush = symbol => Boolean(symbol && isPolygonSymbol(symbol) && isPatternBrush(symbol.fill));
907
- const isPolygonHasHatchBrush = symbol => Boolean(symbol && isPolygonSymbol(symbol) && isHatchBrush(symbol.fill));
908
-
909
- const isMiterExist = miter => Boolean(miter && miter.type !== api.LineEndingType.None);
910
- const isFilledLineMitter = miter => miter.type === api.LineEndingType.FilledCircle || miter.type === api.LineEndingType.FilledArrow || miter.type === api.LineEndingType.FilledSquare;
911
- const isArrowLineMiter = miter => miter.type === api.LineEndingType.Arrow || miter.type === api.LineEndingType.FilledArrow;
912
- const isSquareLineMiter = miter => miter.type === api.LineEndingType.Square || miter.type === api.LineEndingType.FilledSquare;
913
- const isCircleLineMiter = miter => miter.type === api.LineEndingType.Circle || miter.type === api.LineEndingType.FilledCircle;
914
-
915
- const isSimpleOffset = offset => offset && !isParameterByAttribute(offset[0]) && !isParameterByAttribute(offset[1]);
916
- const isSymbolWithOffset = symbol => Boolean(symbol && 'offset' in symbol);
917
-
918
- const isStringParameterValue = parameterValue => typeof parameterValue === 'string';
919
- const isParameterValueSimple = parameterValue => typeof parameterValue === 'number' || typeof parameterValue === 'string';
920
- const isParameterValueSymbol = parameterValue => !isParameterValueSimple(parameterValue);
921
-
922
- const isStyle = value => 'symbol' in value;
923
-
924
- let EvergisStyle = /*#__PURE__*/function () {
925
- function EvergisStyle(style) {
926
- _classCallCheck(this, EvergisStyle);
927
-
928
- this.style = extractStyle(style);
929
- this.classificationManager = new ClassificationManager(this.style);
930
- }
931
-
932
- _createClass(EvergisStyle, [{
933
- key: "serialize",
934
- value: function serialize() {
935
- return packStyle(this.style);
936
- }
937
- }, {
938
- key: "hasRasters",
939
- value: function hasRasters() {
940
- return !!(this.style.raster || (this.style.children || []).some(style => style.raster));
941
- }
942
- }, {
943
- key: "symbol",
944
- get: function get() {
945
- return this.style.symbol;
946
- }
947
- }, {
948
- key: "raster",
949
- get: function get() {
950
- return this.style.raster;
951
- }
952
- }, {
953
- key: "label",
954
- get: function get() {
955
- return this.style.label;
956
- }
957
- }, {
958
- key: "children",
959
- get: function get() {
960
- return this.style.children;
961
- }
962
- }, {
963
- key: "title",
964
- get: function get() {
965
- return this.style.title;
966
- }
967
- }, {
968
- key: "condition",
969
- get: function get() {
970
- return this.style.condition;
971
- }
972
- }, {
973
- key: "ignoreLabel",
974
- get: function get() {
975
- return this.style.ignoreLabel;
976
- }
977
- }, {
978
- key: "resolution",
979
- get: function get() {
980
- const {
981
- minResolution,
982
- maxResolution
983
- } = this.style;
984
- return minResolution === void 0 || maxResolution === void 0 ? null : [minResolution, maxResolution];
985
- }
986
- }]);
987
-
988
- return EvergisStyle;
989
- }();
990
-
991
- const toClassificationClass = (parameterValue, title, condition) => _extends({
992
- parameterValue,
993
- title
994
- }, condition.isUnique() ? {
995
- uniqueValue: condition.uniqueValue
996
- } : {
997
- from: condition.range[0],
998
- to: condition.range[1]
999
- });
1000
-
1001
- const DEFAULT_EXTRAS = {
1002
- defaultTitle: '',
1003
- // @ts-ignore
1004
- defaultValue: null
1005
- };
1006
- const toClassification = function toClassification(values, parameter, extras) {
1007
- if (extras === void 0) {
1008
- extras = DEFAULT_EXTRAS;
1009
- }
1010
-
1011
- return (// @ts-ignore
1012
- values.reduce( // @ts-ignore
1013
- (classification, value) => {
1014
- const classificationCondition = new ClassificationCondition(value.condition || '');
1015
- const classificationValue = toClassificationClass(isStyle(value) ? value.symbol : value.value, // @ts-ignore
1016
- value.title, classificationCondition);
1017
- classification.values.push(classificationValue);
1018
- return _extends({}, classification, {
1019
- type: classification.type || classificationCondition.type,
1020
- attribute: classification.attribute || classificationCondition.attributeName
1021
- });
1022
- }, _extends({}, extras, {
1023
- attribute: null,
1024
- parameter,
1025
- type: null,
1026
- values: []
1027
- }))
1028
- );
1029
- };
1030
- const getClassifications = function getClassifications(symbol, pathContext) {
1031
- if (pathContext === void 0) {
1032
- pathContext = [];
1033
- }
1034
-
1035
- return Object.entries(symbol).reduce((classifications, _ref) => {
1036
- let [parameter, parameterValue] = _ref;
1037
- const skipHeight = isTwoDimensionalSymbol(symbol) && parameter === 'height';
1038
- const skip = !isObject(parameterValue) || skipHeight;
1039
-
1040
- if (skip) {
1041
- return classifications;
1042
- }
1043
-
1044
- if (!isParameterByAttribute(parameterValue)) {
1045
- return [...classifications, // @ts-ignore
1046
- ...getClassifications(symbol[parameter], [...pathContext, parameter])];
1047
- }
1048
-
1049
- const classification = toClassification(parameterValue.values, pathsToParameter([...pathContext, parameter]), {
1050
- // @ts-ignore
1051
- defaultTitle: parameterValue.title,
1052
- defaultValue: parameterValue.defaultValue
1053
- });
1054
- return [...classifications, classification];
1055
- }, []);
1056
- };
1057
-
1058
- let ClassificationManager = /*#__PURE__*/function () {
1059
- function ClassificationManager(style) {
1060
- _classCallCheck(this, ClassificationManager);
1061
-
1062
- this.style = style;
1063
- this.classifications = [];
1064
- this.collectClassifications();
1065
- }
1066
-
1067
- _createClass(ClassificationManager, [{
1068
- key: "values",
1069
- get: function get() {
1070
- return this.classifications;
1071
- }
1072
- }, {
1073
- key: "find",
1074
- value: function find(predicate) {
1075
- for (const classification of this.classifications) {
1076
- if (predicate(classification)) {
1077
- return classification;
1078
- }
1079
- }
1080
-
1081
- return null;
1082
- }
1083
- }, {
1084
- key: "filter",
1085
- value: function filter(callback) {
1086
- return this.classifications.filter(callback);
1087
- }
1088
- }, {
1089
- key: "map",
1090
- value: function map(callback) {
1091
- return this.classifications.map(callback);
1092
- }
1093
- }, {
1094
- key: "reduce",
1095
- value: function reduce(callback, initial) {
1096
- return this.classifications.reduce(callback, initial);
1097
- }
1098
- }, {
1099
- key: "hasClassifications",
1100
- value: function hasClassifications() {
1101
- return this.classifications.length > 0;
1102
- }
1103
- }, {
1104
- key: "collectClassifications",
1105
- value: function collectClassifications() {
1106
- if (this.style.children && this.style.children.length) {
1107
- this.classifications.push(toClassification(this.style.children, 'symbol'));
1108
- }
1109
-
1110
- if (this.style.symbol) {
1111
- this.classifications.push(...getClassifications(this.style.symbol));
1112
- }
1113
- }
1114
- }]);
1115
-
1116
- return ClassificationManager;
1117
- }();
1118
-
1119
- const unClassify = symbol => Object.entries(symbol).reduce((flatSymbol, _ref) => {
1120
- let [parameter, parameterValue] = _ref;
1121
- let result = Array.isArray(parameterValue) ? parameterValue.map(getParameterValue) : getParameterValue(parameterValue);
1122
-
1123
- if (isObject(result)) {
1124
- return _extends({}, flatSymbol, {
1125
- [parameter]: unClassify(parameterValue)
1126
- });
1127
- }
1128
-
1129
- return _extends({}, flatSymbol, {
1130
- [parameter]: result
1131
- });
1132
- }, {});
1133
-
1134
- const DEFAULT_LANGUAGE = "ru";
1135
- const resources = {
1136
- en: {},
1137
- ru: {}
1138
- };
1139
- i18n.use(LanguageDetector).use(reactI18next.initReactI18next).init({
1140
- fallbackLng: DEFAULT_LANGUAGE,
1141
- ns: Object.keys(resources[DEFAULT_LANGUAGE]),
1142
- interpolation: {
1143
- escapeValue: false
1144
- },
1145
- resources,
1146
- supportedLngs: Object.keys(resources)
1147
- });
1148
-
1149
- const printRangeClass = (value, index) => {
1150
- var _value$attribute, _value$attribute2;
1151
-
1152
- const isDouble = Boolean(((_value$attribute = value.attribute) == null ? void 0 : _value$attribute.type) === 'Double');
1153
- const isDate = Boolean(((_value$attribute2 = value.attribute) == null ? void 0 : _value$attribute2.type) === 'DateTime');
1154
- const {
1155
- from,
1156
- to
1157
- } = getRangeValues(value, isDouble, isDate, index);
1158
-
1159
- if (from === null) {
1160
- return to + " " + (isDate ? i18n.t("andBefore", {
1161
- ns: "style"
1162
- }) : i18n.t("andLess", {
1163
- ns: "style"
1164
- }));
1165
- }
1166
-
1167
- if (to === null) {
1168
- return (isDate ? i18n.t("after", {
1169
- ns: "style"
1170
- }) : i18n.t("more", {
1171
- ns: "style"
1172
- })) + " " + from;
1173
- }
1174
-
1175
- return from === to ? "" + from : from + " - " + to;
1176
- };
1177
-
1178
- function getRangeValues(_ref, isDouble, isDate, index) {
1179
- let {
1180
- from,
1181
- to
1182
- } = _ref;
1183
- return {
1184
- from: from !== null && index !== 0 ? isDate ? from : isDouble ? +from : +from + 1 : from,
1185
- to
1186
- };
1187
- }
1188
-
1189
- function evaluateCondition(condition$1, attributes) {
1190
- try {
1191
- const evaluator = new condition.ConditionEvaluator(attributes);
1192
- const result = evaluator.evaluate(condition$1);
1193
-
1194
- if (result instanceof Error) {
1195
- return null;
1196
- }
1197
-
1198
- return result;
1199
- } catch (_unused) {
1200
- return null;
1201
- }
1202
- }
1203
-
1204
- function getAttributeValue(attributes, attributeName) {
1205
- const attributeMeta = attributes.find((_ref) => {
1206
- let {
1207
- name
1208
- } = _ref;
1209
- return name === attributeName;
1210
- });
1211
- return attributeMeta ? attributeMeta.value : null;
1212
- }
1213
-
1214
- const getAttributeNameFromCondition = condition => new ClassificationCondition(condition).attributeName;
1215
- const getAttributeNameFromClassified = values => values.length > 0 ? getAttributeNameFromCondition(values[0].condition) : null;
1216
-
1217
- function findFeatureValue(parameterValues, _ref2) {
1218
- let [name, value] = _ref2;
1219
- return value !== null ? parameterValues.find((_ref3) => {
1220
- let {
1221
- condition
1222
- } = _ref3;
1223
- return value !== undefined && evaluateCondition(condition, {
1224
- [name]: value
1225
- });
1226
- }) : null;
1227
- }
1228
-
1229
- function extractValuesAttribute(parameterValues, attributes) {
1230
- const name = getAttributeNameFromClassified(parameterValues) || '';
1231
- const value = name && getAttributeValue(attributes, name);
1232
- return [name, value];
1233
- }
1234
-
1235
- function evaluateFeatureSymbol(attributes) {
1236
- // @ts-ignore
1237
- function calc(result, _ref4) {
1238
- let [parameterName, parameterValue] = _ref4;
1239
- let newParameterValue;
1240
-
1241
- if (isParameterByAttribute(parameterValue)) {
1242
- const [attributeName, attributeValue] = extractValuesAttribute(parameterValue.values, attributes);
1243
- const featureValue = findFeatureValue(parameterValue.values, [attributeName, attributeValue]);
1244
- newParameterValue = featureValue ? featureValue.value : parameterValue.defaultValue;
1245
- } else if (isObject(parameterValue)) {
1246
- // @ts-ignore
1247
- newParameterValue = Object.entries(parameterValue).reduce(calc, parameterValue);
1248
- }
1249
-
1250
- return newParameterValue !== undefined ? _extends({}, result, {
1251
- [parameterName]: newParameterValue
1252
- }) : result;
1253
- }
1254
-
1255
- return calc;
1256
- }
1257
-
1258
- function findChildFeatureStyle(childStyles, attributes) {
1259
- return (childStyles || []).find((_ref5) => {
1260
- let {
1261
- condition
1262
- } = _ref5;
1263
- const attributeName = condition && getAttributeNameFromCondition(condition);
1264
- const attributeValue = attributeName && getAttributeValue(attributes, attributeName);
1265
-
1266
- if (condition && attributeName && attributeValue !== undefined) {
1267
- return evaluateCondition(condition, {
1268
- [attributeName]: attributeValue
1269
- });
1270
- }
1271
-
1272
- return false;
1273
- }) || null;
1274
- }
1275
- function findChildFeatureSymbol(childStyles, attributes) {
1276
- const featureStyle = findChildFeatureStyle(childStyles, attributes);
1277
- return featureStyle ? featureStyle.symbol : null;
1278
- }
1279
- function getFeatureSymbol(style, attributes) {
1280
- if (!style || !style.symbol) {
1281
- return null;
1282
- }
1283
-
1284
- if (style.children !== null) {
1285
- return findChildFeatureSymbol(style.children, attributes) || style.symbol;
1286
- }
1287
-
1288
- return Object.entries(style.symbol).reduce(evaluateFeatureSymbol(attributes), style.symbol);
1289
- }
1290
-
1291
- function createValueTitle(value, index) {
1292
- if (value.title) return value.title;
1293
- if (isRangeClass(value)) return printRangeClass(value, index);
1294
- if (isUniqueClass(value)) return value.uniqueValue;
1295
- return '';
1296
- }
1297
-
1298
- function isValidParameter(parameter) {
1299
- return !(parameter != null && parameter.includes("labelSymbol")) && !(parameter != null && parameter.includes("singleObjectSymbol"));
1300
- }
1301
-
1302
- (function (FilterConditionOperation) {
1303
- FilterConditionOperation["AND"] = "&&";
1304
- FilterConditionOperation["OR"] = "||";
1305
- })(exports.FilterConditionOperation || (exports.FilterConditionOperation = {}));
1306
-
1307
- (function (ComparisonOperator) {
1308
- /** `==` */
1309
- ComparisonOperator["Equals"] = "Equals";
1310
- /** `!=` */
1311
-
1312
- ComparisonOperator["NotEquals"] = "NotEquals";
1313
- /** `>` */
1314
-
1315
- ComparisonOperator["GreaterThan"] = "GreaterThan";
1316
- /** `<` */
1317
-
1318
- ComparisonOperator["LessThan"] = "LessThan";
1319
- /** `>=` */
1320
-
1321
- ComparisonOperator["GreaterOrEquals"] = "GreaterOrEquals";
1322
- /** `<=` */
1323
-
1324
- ComparisonOperator["LessOrEquals"] = "LessOrEquals";
1325
- ComparisonOperator["Filled"] = "Filled";
1326
- ComparisonOperator["Empty"] = "Empty";
1327
- /** `==` */
1328
-
1329
- ComparisonOperator["Contains"] = "Contains";
1330
- /** `!=` */
1331
-
1332
- ComparisonOperator["NotContains"] = "NotContains";
1333
- ComparisonOperator["StartsWith"] = "StartsWith";
1334
- ComparisonOperator["NotStartsWith"] = "NotStartsWith";
1335
- ComparisonOperator["EndsWith"] = "EndsWith";
1336
- ComparisonOperator["NotEndsWith"] = "NotEndsWith";
1337
- ComparisonOperator["Between"] = "Between";
1338
- ComparisonOperator["Outside"] = "Outside";
1339
- })(exports.ComparisonOperator || (exports.ComparisonOperator = {}));
1340
-
1341
- const DEFAULT_LEGEND_SYMBOL_SIZE = 26;
1342
- const EXTRA_BORDER_SIZE = 4;
1343
- const DEFAULT_SYMBOL_SIZE = 20;
1344
- const DEFAULT_SYMBOL_WITH_BG_SIZE = 24;
1345
- const DEFAULT_SYMBOL_FILL_COLOR = 'rgba(0, 163, 245, 1)';
1346
- const DEFAULT_SYMBOL_STROKE_COLOR = 'rgb(255, 255, 255)';
1347
- const DEFAULT_SYMBOL_OFFSET = [0, 0];
1348
- const DEFAULT_CLUSTER_SVG = "\n<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 56 56\" width=\"56px\" height=\"56px\">\n <circle cx=\"28\" cy=\"28\" r=\"22\" fill=\"#00AAFF\" stroke=\"#00AAFF\" stroke-opacity=\"0.28\" stroke-width=\"12\" id=\"symbol-bg\" />\n</svg>\n";
1349
- const SYMBOL_CLASSIFICATION = {
1350
- [api.GeometryType.Polygon]: ['fill.color', 'stroke.color', 'stroke.width'],
1351
- [api.GeometryType.Polyline]: ['stroke.color', 'stroke.width'],
1352
- [api.GeometryType.Point]: ['angle', 'size', 'fill.color', 'fillColor', 'background.fillColor', 'background.strokeColor', 'background.strokeWidth', 'figure.fillColor', 'figure.strokeColor', 'figure.strokeWidth', 'singleObjectSymbol.size', 'singleObjectSymbol.figure.fillColor', 'singleObjectSymbol.figure.strokeColor', 'singleObjectSymbol.figure.strokeWidth', 'singleObjectSymbol.background.fillColor', 'singleObjectSymbol.background.strokeColor', 'singleObjectSymbol.background.strokeWidth']
1353
- };
1354
- const SYMBOL_LIMITS = {
1355
- SIZE_MIN: 1,
1356
- SIZE_MAX: 64,
1357
- SIZE_STEP: 1,
1358
- GRID_SIZE_MIN: 0.1,
1359
- GRID_SIZE_MAX: 120,
1360
- MIN_OBJECTS_COUNT: 2,
1361
- MAX_OBJECTS_COUNT: 10000,
1362
- MIN_CLUSTER_SIZE: 16,
1363
- MAX_CLUSTER_SIZE: 120,
1364
- STROKE_WIDTH_MIN: 0,
1365
- STROKE_WIDTH_MAX: 32,
1366
- STROKE_WIDTH_STEP: 0.25,
1367
- ANGLE_MIN: -360,
1368
- ANGLE_MAX: 360,
1369
- ANGLE_STEP: 1,
1370
- PREVIEW_SIZE_MAX: 32,
1371
- PREVIEW_SIZE_MAX_WIDTH: 26
1372
- };
1373
- const DEFAULT_PARAMETER_INFO = {
1374
- classifyAble: true,
1375
- min: SYMBOL_LIMITS.STROKE_WIDTH_MIN,
1376
- max: SYMBOL_LIMITS.STROKE_WIDTH_MAX,
1377
- step: SYMBOL_LIMITS.STROKE_WIDTH_STEP,
1378
- units: "px"
1379
- /* Pixels */
1380
- ,
1381
- serialize: value => value,
1382
- deserialize: value => value
1383
- };
1384
- const PARAMETER_INFOS = {
1385
- size: /*#__PURE__*/_extends({}, DEFAULT_PARAMETER_INFO, {
1386
- min: SYMBOL_LIMITS.SIZE_MIN,
1387
- max: SYMBOL_LIMITS.SIZE_MAX,
1388
- step: SYMBOL_LIMITS.SIZE_STEP,
1389
- units: "px"
1390
- /* Pixels */
1391
-
1392
- })
1393
- };
1394
- const OPERATOR_CONDITION_REMAP = {
1395
- [exports.ComparisonOperator.Equals]: '==',
1396
- [exports.ComparisonOperator.NotEquals]: '!=',
1397
- [exports.ComparisonOperator.GreaterThan]: '>',
1398
- [exports.ComparisonOperator.GreaterOrEquals]: '>=',
1399
- [exports.ComparisonOperator.LessThan]: '<',
1400
- [exports.ComparisonOperator.LessOrEquals]: '<=',
1401
- [exports.ComparisonOperator.Filled]: '!=',
1402
- [exports.ComparisonOperator.Empty]: '==',
1403
- [exports.ComparisonOperator.Contains]: '==',
1404
- [exports.ComparisonOperator.NotContains]: '!=',
1405
- [exports.ComparisonOperator.StartsWith]: '==',
1406
- [exports.ComparisonOperator.NotStartsWith]: '!=',
1407
- [exports.ComparisonOperator.EndsWith]: '==',
1408
- [exports.ComparisonOperator.NotEndsWith]: '!=',
1409
- [exports.ComparisonOperator.Between]: 'between',
1410
- [exports.ComparisonOperator.Outside]: '!between'
1411
- };
1412
- const BASE_OPERATORS = [exports.ComparisonOperator.Equals, exports.ComparisonOperator.NotEquals];
1413
- const CONTAINS_OPERATORS = [exports.ComparisonOperator.Contains, exports.ComparisonOperator.NotContains];
1414
- const FILLED_OPERATORS = [exports.ComparisonOperator.Filled, exports.ComparisonOperator.Empty];
1415
- const STARTS_WITH_OPERATORS = [exports.ComparisonOperator.StartsWith, exports.ComparisonOperator.NotStartsWith];
1416
- const ENDS_WITH_OPERATORS = [exports.ComparisonOperator.EndsWith, exports.ComparisonOperator.NotEndsWith];
1417
- const RANGE_OPERATORS = [exports.ComparisonOperator.LessThan, exports.ComparisonOperator.LessOrEquals, exports.ComparisonOperator.GreaterThan, exports.ComparisonOperator.GreaterOrEquals];
1418
- const BETWEEN_OPERATORS = [exports.ComparisonOperator.Between, exports.ComparisonOperator.Outside];
1419
- const numberComparisonOperators = [...BASE_OPERATORS, ...RANGE_OPERATORS, ...FILLED_OPERATORS, ...BETWEEN_OPERATORS];
1420
- const dateComparisonOperators = [...BASE_OPERATORS, ...RANGE_OPERATORS, ...FILLED_OPERATORS, ...BETWEEN_OPERATORS];
1421
- const textComparisonOperators = [...BASE_OPERATORS, ...CONTAINS_OPERATORS, ...STARTS_WITH_OPERATORS, ...ENDS_WITH_OPERATORS, ...FILLED_OPERATORS];
1422
-
1423
- (function (SvgSymbolBg) {
1424
- SvgSymbolBg["Rect"] = "rect";
1425
- SvgSymbolBg["Circle"] = "circle";
1426
- })(exports.SvgSymbolBg || (exports.SvgSymbolBg = {}));
1427
-
1428
- const DEFAULT_STROKE_OPACITY = 0.28;
1429
- const convertSvgToBase64 = svg => "data:image/svg+xml;base64," + window.btoa(svg);
1430
- const createSvgGradient = (svg, values) => svg.gradient('linear', add => {
1431
- values == null ? void 0 : values.forEach((_ref, index) => {
1432
- let {
1433
- value
1434
- } = _ref;
1435
- add.stop(index / ((values == null ? void 0 : values.length) - 1), value);
1436
- });
1437
- }).from(0, 0).to(1, 1); // eslint-disable-next-line max-lines-per-function
1438
-
1439
- const manipulateSvgSymbol = (_ref2) => {
1440
- var _$exec2;
1441
-
1442
- let {
1443
- SVGContainer,
1444
- symbol,
1445
- svg,
1446
- bg,
1447
- isClassified
1448
- } = _ref2;
1449
- if (!symbol) return SVGContainer;
1450
- const symbolData = getParameterValue(svg || symbol.data);
1451
- if (!symbolData) return SVGContainer;
1452
- SVGContainer.clear();
1453
- const {
1454
- size,
1455
- angle,
1456
- background,
1457
- figure
1458
- } = symbol;
1459
- const isUploadedFile = !bg && !symbolData.includes('symbol-bg') && !symbolData.includes('symbol-figure');
1460
- const innerSvg = symbolData.replace(/<\?xml[^?]*\?>|<svg[^>]*>|<\/svg>/g, '');
1461
-
1462
- if (isUploadedFile) {
1463
- var _$exec;
1464
-
1465
- SVGContainer.svg(innerSvg);
1466
- const uploadedViewBox = (_$exec = /viewBox="([^"]+)"/g.exec(symbolData)) == null ? void 0 : _$exec[1];
1467
-
1468
- if (uploadedViewBox != null && uploadedViewBox[1]) {
1469
- SVGContainer.viewbox(uploadedViewBox);
1470
- }
1471
-
1472
- SVGContainer.size(size);
1473
- } else {
1474
- const hasBg = bg || (innerSvg == null ? void 0 : innerSvg.includes('symbol-bg'));
1475
- let defaultSize = hasBg ? DEFAULT_SYMBOL_WITH_BG_SIZE : DEFAULT_SYMBOL_SIZE;
1476
- const currentSize = size || defaultSize;
1477
- let viewBox = [0, 0, defaultSize, defaultSize];
1478
- const strokeWidth = getParameterValue(background == null ? void 0 : background.strokeWidth) || (typeof (background == null ? void 0 : background.strokeColor) === 'object' ? 1 : 0);
1479
-
1480
- if (strokeWidth) {
1481
- defaultSize += strokeWidth;
1482
- viewBox = [-strokeWidth / 2, -strokeWidth / 2, defaultSize, defaultSize];
1483
- }
1484
-
1485
- if (hasBg) {
1486
- SVGContainer.size(currentSize + "px", currentSize + "px").viewbox(viewBox.join(' '));
1487
- const currentBg = bg || (background == null ? void 0 : background.type);
1488
-
1489
- if (currentBg) {
1490
- const strokeColor = getParameterValue(background == null ? void 0 : background.strokeColor);
1491
- const fillColor = getParameterValue(background == null ? void 0 : background.fillColor);
1492
- SVGContainer.svg(currentBg === exports.SvgSymbolBg.Circle ? "<circle\n id=\"symbol-bg\"\n cx=\"" + DEFAULT_SYMBOL_WITH_BG_SIZE / 2 + "\"\n cy=\"" + DEFAULT_SYMBOL_WITH_BG_SIZE / 2 + "\"\n r=\"" + DEFAULT_SYMBOL_WITH_BG_SIZE / 2 + "\"\n fill=\"" + (fillColor || DEFAULT_SYMBOL_FILL_COLOR) + "\"\n stroke=\"" + (strokeColor || DEFAULT_SYMBOL_STROKE_COLOR) + "\"\n stroke-width=\"" + strokeWidth + "\"\n />" : "<rect\n id=\"symbol-bg\"\n width=\"" + DEFAULT_SYMBOL_WITH_BG_SIZE + "\"\n height=\"" + DEFAULT_SYMBOL_WITH_BG_SIZE + "\"\n rx=\"4\"\n fill=\"" + (fillColor || DEFAULT_SYMBOL_FILL_COLOR) + "\"\n stroke=\"" + (strokeColor || DEFAULT_SYMBOL_STROKE_COLOR) + "\"\n stroke-width=\"" + strokeWidth + "\"\n />");
1493
- SVGContainer.svg(innerSvg);
1494
- SVGContainer.find('#symbol-bg:not(:first-child)').each(item => item.remove());
1495
- SVGContainer.find(':not(#symbol-bg)').each(item => item.center(DEFAULT_SYMBOL_WITH_BG_SIZE / 2, DEFAULT_SYMBOL_WITH_BG_SIZE / 2).fill('white'));
1496
- const symbolBg = SVGContainer.find('#symbol-bg')[0];
1497
-
1498
- if (isClassified) {
1499
- symbolBg == null ? void 0 : symbolBg.stroke({
1500
- opacity: DEFAULT_STROKE_OPACITY
1501
- });
1502
- } // eslint-disable-next-line max-depth
1503
-
1504
-
1505
- if (isParameterByAttribute(background == null ? void 0 : background.fillColor)) {
1506
- var _background$fillColor;
1507
-
1508
- symbolBg == null ? void 0 : symbolBg.fill(createSvgGradient(SVGContainer, background == null ? void 0 : (_background$fillColor = background.fillColor) == null ? void 0 : _background$fillColor.values));
1509
- }
1510
-
1511
- if (isParameterByAttribute(background == null ? void 0 : background.strokeColor)) {
1512
- var _background$strokeCol;
1513
-
1514
- symbolBg == null ? void 0 : symbolBg.stroke({
1515
- color: createSvgGradient(SVGContainer, background == null ? void 0 : (_background$strokeCol = background.strokeColor) == null ? void 0 : _background$strokeCol.values)
1516
- });
1517
- }
1518
- } else {
1519
- SVGContainer.svg(innerSvg);
1520
- }
1521
- } else {
1522
- const strokeColor = getParameterValue(figure == null ? void 0 : figure.strokeColor);
1523
- const strokeWidth = getParameterValue(figure == null ? void 0 : figure.strokeWidth) || (typeof (figure == null ? void 0 : figure.strokeColor) === 'object' ? 1 : 0);
1524
- const fillColor = getParameterValue(figure == null ? void 0 : figure.fillColor);
1525
- SVGContainer.size(currentSize + "px", currentSize + "px").viewbox(viewBox.join(' '));
1526
- SVGContainer.svg(innerSvg);
1527
- SVGContainer.find('#symbol-figure').each(item => {
1528
- item.center(DEFAULT_SYMBOL_SIZE / 2, DEFAULT_SYMBOL_SIZE / 2).fill(fillColor || DEFAULT_SYMBOL_FILL_COLOR).stroke({
1529
- color: strokeColor,
1530
- width: strokeWidth
1531
- });
1532
-
1533
- if (isParameterByAttribute(figure == null ? void 0 : figure.fillColor)) {
1534
- var _figure$fillColor;
1535
-
1536
- item == null ? void 0 : item.fill(createSvgGradient(SVGContainer, figure == null ? void 0 : (_figure$fillColor = figure.fillColor) == null ? void 0 : _figure$fillColor.values));
1537
- }
1538
-
1539
- if (isParameterByAttribute(figure == null ? void 0 : figure.strokeColor)) {
1540
- var _figure$strokeColor;
1541
-
1542
- item == null ? void 0 : item.stroke({
1543
- color: createSvgGradient(SVGContainer, figure == null ? void 0 : (_figure$strokeColor = figure.strokeColor) == null ? void 0 : _figure$strokeColor.values)
1544
- });
1545
- }
1546
- });
1547
- }
1548
- }
1549
-
1550
- const rootTransform = (_$exec2 = /<svg[^>]*transform="([^"]+)"/g.exec(symbolData)) == null ? void 0 : _$exec2[1];
1551
-
1552
- if (rootTransform) {
1553
- const transformParts = rootTransform.slice(0, -1).split('(');
1554
- SVGContainer.transform({
1555
- [transformParts[0]]: transformParts[1].split(',')
1556
- });
1557
- }
1558
-
1559
- const rotatedAngle = SVGContainer.transform('rotate');
1560
-
1561
- if (rotatedAngle) {
1562
- SVGContainer.rotate(-rotatedAngle, 0, 0);
1563
- }
1564
-
1565
- if (angle !== undefined) {
1566
- SVGContainer.rotate(angle * (180 / Math.PI), 0, 0);
1567
- }
1568
-
1569
- return SVGContainer;
1570
- };
1571
-
1572
- const isNumeric = number => !isNaN(parseFloat(number)) && isFinite(number);
1573
-
1574
- const comparisonOperatorMapReversed = {
1575
- [condition.TokenType.ArEq]: exports.ComparisonOperator.Equals,
1576
- [condition.TokenType.ArNotEq]: exports.ComparisonOperator.NotEquals,
1577
- [condition.TokenType.ArGr]: exports.ComparisonOperator.GreaterThan,
1578
- [condition.TokenType.ArLs]: exports.ComparisonOperator.LessThan,
1579
- [condition.TokenType.ArGre]: exports.ComparisonOperator.GreaterOrEquals,
1580
- [condition.TokenType.ArLse]: exports.ComparisonOperator.LessOrEquals,
1581
- [condition.TokenType.Between]: exports.ComparisonOperator.Between,
1582
- [condition.TokenType.Outside]: exports.ComparisonOperator.Outside
1583
- };
1584
- const NUMERIC_ATTRIBUTE_TYPES = [api.AttributeType.Int32, api.AttributeType.Int64, api.AttributeType.DateTime, api.AttributeType.Double];
1585
-
1586
- const formatValue = (value, isDate) => {
1587
- return isDate ? "#'" + formatDate(value, {
1588
- dateFormat: exports.DateFormat.UTC,
1589
- defaultValue: value
1590
- }) + "'" : value ? value.toString() : 0;
1591
- };
1592
-
1593
- function formatCondition(condition$1) {
1594
- const {
1595
- comparisonOperator,
1596
- value,
1597
- type,
1598
- attribute
1599
- } = condition$1;
1600
- const operator = OPERATOR_CONDITION_REMAP[comparisonOperator] || comparisonOperator;
1601
- const preparedValue = typeof value === "string" && value.includes(" - ") ? value.split(" - ") : value;
1602
- const isDate = type === api.AttributeType.DateTime;
1603
- const isBetweenOutside = BETWEEN_OPERATORS.includes(comparisonOperator);
1604
- const escapeValue = !NUMERIC_ATTRIBUTE_TYPES.includes(type) && preparedValue !== null;
1605
-
1606
- if (isBetweenOutside && Array.isArray(preparedValue) && preparedValue[0] !== undefined) {
1607
- return OPERATOR_CONDITION_REMAP[comparisonOperator] + "(" + attribute + ", " + formatValue(preparedValue[0], isDate) + ", " + formatValue(preparedValue[1], isDate) + ")";
1608
- }
1609
-
1610
- const formattedValue = Array.isArray(preparedValue) ? preparedValue.map(val => formatValue(val, isDate)) : formatValue(preparedValue, isDate);
1611
- const nulledValue = lodash.isNil(preparedValue) ? "{null}" : formattedValue;
1612
- const valueEscaped = escapeValue && typeof nulledValue === "string" ? "'" + condition.Char.escapeSpecChars(addOperationToValue(nulledValue, comparisonOperator)) + "'" : nulledValue;
1613
- return attribute + " " + operator + " " + valueEscaped;
1614
- }
1615
- function createConditionString(condition) {
1616
- if (Array.isArray(condition)) {
1617
- return "( " + formatCondition(condition[0]) + " " + condition[0].operation + " " + formatCondition(condition[1]) + " )";
1618
- }
1619
-
1620
- return formatCondition(condition);
1621
- }
1622
- function createCondition(_ref) {
1623
- let {
1624
- attribute,
1625
- operation,
1626
- value
1627
- } = _ref;
1628
- const comparisonOperator = comparisonOperatorMapReversed[operation];
1629
- const convertedResult = convertOperatorValue(value, comparisonOperator);
1630
- return _extends({
1631
- attribute
1632
- }, convertedResult);
1633
- }
1634
-
1635
- function convertOperatorValue(value, comparisonOperator) {
1636
- if (typeof value === "string") {
1637
- const operatorIndex = +(comparisonOperator === exports.ComparisonOperator.NotEquals);
1638
-
1639
- if (value.startsWith(condition.Char.PERCENTAGE) && value.endsWith(condition.Char.PERCENTAGE)) {
1640
- return {
1641
- value: value.slice(1, -1),
1642
- comparisonOperator: CONTAINS_OPERATORS[operatorIndex]
1643
- };
1644
- }
1645
-
1646
- if (value.startsWith(condition.Char.PERCENTAGE)) {
1647
- return {
1648
- value: value.slice(1),
1649
- comparisonOperator: ENDS_WITH_OPERATORS[operatorIndex]
1650
- };
1651
- }
1652
-
1653
- if (value.endsWith(condition.Char.PERCENTAGE)) {
1654
- return {
1655
- value: value.slice(0, -1),
1656
- comparisonOperator: STARTS_WITH_OPERATORS[operatorIndex]
1657
- };
1658
- }
1659
- }
1660
-
1661
- return {
1662
- value,
1663
- comparisonOperator
1664
- };
1665
- }
1666
-
1667
- const addContains = value => "%" + value + "%";
1668
-
1669
- const addStartsWith = value => value + "%";
1670
-
1671
- const addEndsWith = value => "%" + value;
1672
-
1673
- function addOperationToValue(value, operator) {
1674
- switch (operator) {
1675
- case exports.ComparisonOperator.Contains:
1676
- case exports.ComparisonOperator.NotContains:
1677
- return addContains(value);
1678
-
1679
- case exports.ComparisonOperator.StartsWith:
1680
- case exports.ComparisonOperator.NotStartsWith:
1681
- return addStartsWith(value);
1682
-
1683
- case exports.ComparisonOperator.EndsWith:
1684
- case exports.ComparisonOperator.NotEndsWith:
1685
- return addEndsWith(value);
1686
-
1687
- case exports.ComparisonOperator.Between:
1688
- return condition.Char.BETWEEN;
1689
-
1690
- case exports.ComparisonOperator.Outside:
1691
- return condition.Char.OUTSIDE;
1692
-
1693
- default:
1694
- return value;
1695
- }
1696
- }
1697
-
1698
- let FilterCondition = /*#__PURE__*/function () {
1699
- function FilterCondition(condition$1) {
1700
- if (condition$1 === void 0) {
1701
- condition$1 = null;
1702
- }
1703
-
1704
- _classCallCheck(this, FilterCondition);
1705
-
1706
- this.condition = condition$1;
1707
- this.conditionInterpreter = new condition.ConditionInterpreter(condition$1);
1708
- }
1709
-
1710
- _createClass(FilterCondition, [{
1711
- key: "conditions",
1712
- get: function get() {
1713
- const {
1714
- value
1715
- } = this.conditionInterpreter;
1716
-
1717
- if (value instanceof Error) {
1718
- // TODO handle errors in client notifications
1719
- console.warn(value.message);
1720
- }
1721
-
1722
- return value instanceof Error ? [] : value.expressions.map(createCondition);
1723
- }
1724
- }, {
1725
- key: "conditionOperation",
1726
- get: function get() {
1727
- const {
1728
- value
1729
- } = this.conditionInterpreter;
1730
-
1731
- if (value instanceof Error) {
1732
- return null;
1733
- }
1734
-
1735
- const isOrCondition = value.boolOperations.includes(condition.TokenType.BoolOr);
1736
- const isAndCondition = value.boolOperations.includes(condition.TokenType.BoolAnd);
1737
-
1738
- if (isOrCondition && isAndCondition) {
1739
- return null;
1740
- }
1741
-
1742
- return isOrCondition ? exports.FilterConditionOperation.OR : isAndCondition ? exports.FilterConditionOperation.AND : null;
1743
- }
1744
- }, {
1745
- key: "isParsingError",
1746
- value: function isParsingError() {
1747
- return this.conditionInterpreter.value instanceof Error;
1748
- }
1749
- }, {
1750
- key: "toString",
1751
- value: function toString() {
1752
- return this.condition;
1753
- }
1754
- }], [{
1755
- key: "from",
1756
- value: function from(conditions, operation) {
1757
- const condition = (conditions == null ? void 0 : conditions.map(createConditionString).join(" " + operation + " ")) || null;
1758
- return new FilterCondition(condition);
1759
- }
1760
- }]);
1761
-
1762
- return FilterCondition;
1763
- }();
1764
-
1765
- const isLayerService = value => isObject(value) && 'name' in value;
1766
- const getAttributeFromCondition = condition => {
1767
- const parts = condition.split(' ');
1768
- return parts[0].startsWith('(') ? parts[0].slice(1) : parts[0];
1769
- };
1770
- const getExprFromCondition = (condition, partIndex) => {
1771
- var _expr;
1772
-
1773
- let expr;
1774
-
1775
- if (partIndex) {
1776
- const parts = condition.split(' && ').map(part => part.slice(1, -1));
1777
- expr = parts[partIndex - 1];
1778
- } else {
1779
- expr = condition;
1780
- }
1781
-
1782
- return (_expr = expr) == null ? void 0 : _expr.split(' ');
1783
- };
1784
- const getSignFromConditionPart = (condition, partIndex) => {
1785
- var _getExprFromCondition;
1786
-
1787
- return (_getExprFromCondition = getExprFromCondition(condition, partIndex)) == null ? void 0 : _getExprFromCondition[1];
1788
- };
1789
- const getValueFromConditionPart = (condition, partIndex) => {
1790
- var _getExprFromCondition2;
1791
-
1792
- return (_getExprFromCondition2 = getExprFromCondition(condition, partIndex)) == null ? void 0 : _getExprFromCondition2[2];
1793
- };
1794
- const isRangeCondition = condition => (condition == null ? void 0 : condition.includes('(')) || false;
1795
- const getSymbolParameterInfo = parameter => {
1796
- return PARAMETER_INFOS[parameter] || DEFAULT_PARAMETER_INFO;
1797
- };
1798
- const formatUniqueClassValue = (value, formatValue) => {
1799
- const {
1800
- attribute,
1801
- uniqueValue
1802
- } = value;
1803
- return attribute && formatValue ? formatValue(attribute.type, uniqueValue, attribute.stringFormat) : uniqueValue;
1804
- };
1805
- const getRangeValues$1 = (_ref, isDouble, isDate, index) => {
1806
- let {
1807
- from,
1808
- to
1809
- } = _ref;
1810
- return {
1811
- from: from !== null && index !== 0 ? isDate ? from : isDouble ? +from : +from + 1 : from,
1812
- to
1813
- };
1814
- };
1815
- const formatRangeClassValue = (value, formatValue, index) => {
1816
- var _value$attribute, _value$attribute2, _value$attribute3, _value$attribute4, _value$attribute5, _value$attribute6;
1817
-
1818
- const isDouble = ((_value$attribute = value.attribute) == null ? void 0 : _value$attribute.type) === 'Double';
1819
- const isDate = ((_value$attribute2 = value.attribute) == null ? void 0 : _value$attribute2.type) === 'DateTime';
1820
- const {
1821
- from,
1822
- to
1823
- } = getRangeValues$1(value, isDouble, isDate, index);
1824
- const formattedFrom = formatValue ? formatValue((_value$attribute3 = value.attribute) == null ? void 0 : _value$attribute3.type, from, (_value$attribute4 = value.attribute) == null ? void 0 : _value$attribute4.stringFormat) : from;
1825
- const formattedTo = formatValue ? formatValue((_value$attribute5 = value.attribute) == null ? void 0 : _value$attribute5.type, to, (_value$attribute6 = value.attribute) == null ? void 0 : _value$attribute6.stringFormat) : to;
1826
-
1827
- if (from === null) {
1828
- return "" + formattedTo + (!isDate ? " " + i18n.t("andLess", {
1829
- ns: "style"
1830
- }) : '');
1831
- }
1832
-
1833
- if (to === null) {
1834
- return "" + (!isDate ? i18n.t("more", {
1835
- ns: "style"
1836
- }) + " " : '') + formattedFrom;
1837
- }
1838
-
1839
- return from === to ? "" + formattedFrom : formattedFrom + " - " + formattedTo;
1840
- };
1841
- const checkLayerHasLegend = layerInfo => {
1842
- var _SYMBOL_CLASSIFICATIO;
1843
-
1844
- return ((_SYMBOL_CLASSIFICATIO = SYMBOL_CLASSIFICATION[layerInfo.geometryType]) == null ? void 0 : _SYMBOL_CLASSIFICATIO.some(param => {
1845
- var _layerInfo$style;
1846
-
1847
- const paramValue = get((_layerInfo$style = layerInfo.style) == null ? void 0 : _layerInfo$style.symbol, param);
1848
- return (paramValue == null ? void 0 : paramValue.type) === 'byAttribute';
1849
- })) || false;
1850
- };
1851
- const getTitleFromCondition = (_ref2) => {
1852
- let {
1853
- condition,
1854
- attribute,
1855
- formatValue
1856
- } = _ref2;
1857
- const parts = condition == null ? void 0 : condition.split(' == ');
1858
- const uniqueValue = parts != null && parts[1] ? parts[1].startsWith("'") && parts[1].endsWith("'") ? parts[1].slice(1, -1) : parts[1] : '';
1859
- return attribute && formatValue ? formatValue(attribute.type, uniqueValue, attribute.stringFormat) : uniqueValue;
1860
- };
1861
- function createValueTitleFromCondition(paramValue, attribute, formatValue, index) {
1862
- if (!attribute) return '';
1863
- if (paramValue.title) return paramValue.title;
1864
- const value = {
1865
- parameterValue: getParameterValue(paramValue.value),
1866
- attribute
1867
- };
1868
- const sign = getSignFromConditionPart(paramValue.condition, 1);
1869
- const isFirstFrom = sign.includes('>');
1870
- value.from = isFirstFrom ? getValueFromConditionPart(paramValue.condition, 1) : null;
1871
- value.to = paramValue.condition.includes(' && ') && isFirstFrom ? getValueFromConditionPart(paramValue.condition, 2) : !isFirstFrom ? getValueFromConditionPart(paramValue.condition, 1) : null;
1872
- if (isRangeClass(value)) return formatRangeClassValue(value, formatValue, index);
1873
- if (isUniqueClass(value)) return formatUniqueClassValue(value, formatValue);
1874
- return '';
1875
- } // Основывается на http://cf.everpoint.ru/pages/viewpage.action?pageId=45024217 ->
1876
- // пункт "Настраиваемые значения параметров символики в системе"
1877
- // Для добавления подготовленных значений размеров символов нужно использовать константу PREPARED_SYMBOL_SIZES
1878
-
1879
- const DEFAULT_LEGEND_STYLES = {
1880
- [0
1881
- /* Point */
1882
- ]: {
1883
- fillColor: '#00000047',
1884
- strokeWidth: 1,
1885
- strokeColor: '#0000001f'
1886
- },
1887
- [1
1888
- /* ImagePoint */
1889
- ]: {
1890
- maskedColor: '#00000047'
1891
- },
1892
- [2
1893
- /* Line */
1894
- ]: {
1895
- stroke: {
1896
- width: 2,
1897
- color: '#00000047'
1898
- }
1899
- },
1900
- [3
1901
- /* Polygon */
1902
- ]: {
1903
- fill: {
1904
- color: '#00000000',
1905
- hatchColor: '#00000000'
1906
- },
1907
- stroke: {
1908
- width: 1,
1909
- color: '#0000001f'
1910
- }
1911
- }
1912
- };
1913
- const SYMBOL_SIZE_PARAMETERS = ['size', 'width', 'height']; // Основывается на http://cf.everpoint.ru/pages/viewpage.action?pageId=45024217 -> пункт "Библиотека символов"
1914
-
1915
- const DEFAULT_LEGEND_SIZES = {
1916
- circlePointSymbol: 8,
1917
- squarePointSymbol: 12,
1918
- imagePointSymbol: 24,
1919
- maskedImagePointSymbol: 24,
1920
- svgPointSymbol: 24
1921
- };
1922
-
1923
- const getNonClassifiedParamValue = (baseSymbol, parameter, classificationsParams, type) => {
1924
- if (classificationsParams.includes(parameter)) {
1925
- const defaultParameterValue = getParameterFromSymbol(DEFAULT_LEGEND_STYLES[type], parameter);
1926
-
1927
- if (defaultParameterValue) {
1928
- return defaultParameterValue;
1929
- }
1930
-
1931
- if (SYMBOL_SIZE_PARAMETERS.includes(parameter) && DEFAULT_LEGEND_SIZES[baseSymbol.type]) {
1932
- return DEFAULT_LEGEND_SIZES[baseSymbol.type];
1933
- }
1934
- }
1935
-
1936
- return getParameterValue(getParameterFromSymbol(baseSymbol, parameter));
1937
- };
1938
-
1939
- const updateSymbolParameter = (symbol, path, value) => symbolParameterWalker(() => value)(symbol, path);
1940
-
1941
- const createPointSymbol = (baseSymbol, parameter, classificationsParams, parameterValue) => {
1942
- return updateSymbolParameter(_extends({}, baseSymbol, {
1943
- fillColor: getNonClassifiedParamValue(baseSymbol, 'fillColor', classificationsParams, 0
1944
- /* Point */
1945
- ),
1946
- strokeColor: getNonClassifiedParamValue(baseSymbol, 'strokeColor', classificationsParams, 0
1947
- /* Point */
1948
- ),
1949
- strokeWidth: getNonClassifiedParamValue(baseSymbol, 'strokeWidth', classificationsParams, 0
1950
- /* Point */
1951
- ),
1952
- size: getNonClassifiedParamValue(baseSymbol, 'size', classificationsParams, 0
1953
- /* Point */
1954
- ),
1955
- offset: [0, 0]
1956
- }), parameter, parameterValue);
1957
- };
1958
-
1959
- function getDimensions(symbol, size) {
1960
- const height = getParameterValue(symbol.height);
1961
- const width = getParameterValue(symbol.width);
1962
-
1963
- if (width === height) {
1964
- return {
1965
- width: size,
1966
- height: size
1967
- };
1968
- }
1969
-
1970
- const ratio = height / width;
1971
-
1972
- if (width < height) {
1973
- return {
1974
- width: size,
1975
- height: height + (size - width) * ratio
1976
- };
1977
- }
1978
-
1979
- return {
1980
- width: width + (size - height) * ratio,
1981
- height: size
1982
- };
1983
- }
1984
-
1985
- const createImagePointSymbol = (baseSymbol, parameter, classificationsParams, parameterValue) => {
1986
- let symbol = _extends({}, baseSymbol);
1987
-
1988
- if (isMaskedImageSymbol(symbol)) {
1989
- symbol.maskedColor = getNonClassifiedParamValue(baseSymbol, 'maskedColor', classificationsParams, 1
1990
- /* ImagePoint */
1991
- );
1992
- }
1993
-
1994
- if (parameter === 'height' || parameter === 'width') {
1995
- const {
1996
- height,
1997
- width
1998
- } = getDimensions(baseSymbol, parameterValue);
1999
- symbol.height = height;
2000
- symbol.width = width;
2001
- } else {
2002
- symbol.width = getNonClassifiedParamValue(baseSymbol, 'width', classificationsParams, 1
2003
- /* ImagePoint */
2004
- );
2005
- symbol.height = symbol.width;
2006
- symbol = updateSymbolParameter(symbol, parameter, parameterValue);
2007
- }
2008
-
2009
- symbol.offset = [getParameterValue(symbol.height) / 2, getParameterValue(symbol.width) / 2];
2010
- return symbol;
2011
- };
2012
-
2013
- const createLineSymbol = (baseSymbol, parameter, classificationsParams, parameterValue) => {
2014
- return updateSymbolParameter(_extends({}, baseSymbol, {
2015
- type: 'simplePolylineSymbol',
2016
- stroke: {
2017
- color: getNonClassifiedParamValue(baseSymbol, 'stroke.color', classificationsParams, 2
2018
- /* Line */
2019
- ),
2020
- width: getNonClassifiedParamValue(baseSymbol, 'stroke.width', classificationsParams, 2
2021
- /* Line */
2022
- )
2023
- }
2024
- }), parameter, parameterValue);
2025
- };
2026
-
2027
- const createPolygonSymbol = (baseSymbol, parameter, classificationsParams, parameterValue) => {
2028
- return updateSymbolParameter(_extends({}, baseSymbol, {
2029
- fill: {
2030
- color: getNonClassifiedParamValue(baseSymbol, 'fill.color', classificationsParams, 3
2031
- /* Polygon */
2032
- ),
2033
- hatchColor: getNonClassifiedParamValue(baseSymbol, 'fill.hatchColor', classificationsParams, 3
2034
- /* Polygon */
2035
- )
2036
- },
2037
- stroke: {
2038
- color: getNonClassifiedParamValue(baseSymbol, 'stroke.color', classificationsParams, 3
2039
- /* Polygon */
2040
- ),
2041
- width: getNonClassifiedParamValue(baseSymbol, 'stroke.width', classificationsParams, 3
2042
- /* Polygon */
2043
- )
2044
- }
2045
- }), parameter, parameterValue);
2046
- };
2047
-
2048
- const createH3Symbol = (baseSymbol, parameter, classificationsParams, parameterValue) => {
2049
- return updateSymbolParameter(_extends({}, baseSymbol, {
2050
- fill: {
2051
- color: getNonClassifiedParamValue(baseSymbol, 'fill.color', classificationsParams, 3
2052
- /* Polygon */
2053
- )
2054
- },
2055
- stroke: {
2056
- color: getNonClassifiedParamValue(baseSymbol, 'stroke.color', classificationsParams, 3
2057
- /* Polygon */
2058
- ),
2059
- width: getNonClassifiedParamValue(baseSymbol, 'stroke.width', classificationsParams, 3
2060
- /* Polygon */
2061
- )
2062
- }
2063
- }), parameter, parameterValue);
2064
- };
2065
-
2066
- const createClusterSymbol = (baseSymbol, parameter, classificationsParams, parameterValue) => {
2067
- return updateSymbolParameter(_extends({}, baseSymbol, {
2068
- fillColor: getNonClassifiedParamValue(baseSymbol, 'fillColor', classificationsParams, 0
2069
- /* Point */
2070
- )
2071
- }), parameter, parameterValue);
2072
- };
2073
-
2074
- const createLegendSymbol = (parameterValue, parameter, classificationsParams, baseSymbol) => {
2075
- if (isParameterValueSymbol(parameterValue)) {
2076
- return parameterValue;
2077
- }
2078
-
2079
- if (isClusterSymbol(baseSymbol)) {
2080
- return createClusterSymbol(baseSymbol, parameter, classificationsParams, parameterValue);
2081
- }
2082
-
2083
- if (isSizableSymbol(baseSymbol)) {
2084
- return createPointSymbol(baseSymbol, parameter, classificationsParams, parameterValue);
2085
- }
2086
-
2087
- if (isTwoDimensionalSymbol(baseSymbol)) {
2088
- return createImagePointSymbol(baseSymbol, parameter, classificationsParams, parameterValue);
2089
- }
2090
-
2091
- if (isPolylineSymbols(baseSymbol)) {
2092
- return createLineSymbol(baseSymbol, parameter, classificationsParams, parameterValue);
2093
- }
2094
-
2095
- if (isPolygonSymbol(baseSymbol)) {
2096
- return createPolygonSymbol(baseSymbol, parameter, classificationsParams, parameterValue);
2097
- }
2098
-
2099
- if (isH3GridSymbol(baseSymbol)) {
2100
- return createH3Symbol(baseSymbol, parameter, classificationsParams, parameterValue);
2101
- }
2102
-
2103
- return null;
2104
- };
2105
- function createHiddenCondition(attributeName, attributeType, value) {
2106
- let newValue;
2107
- let comparisonOperator;
2108
-
2109
- if (isRangeClass(value)) {
2110
- if (value.from && value.to) {
2111
- newValue = [value.from, value.to];
2112
- comparisonOperator = exports.ComparisonOperator.Outside;
2113
- } else if (value.from) {
2114
- newValue = value.from;
2115
- comparisonOperator = exports.ComparisonOperator.LessThan;
2116
- } else if (value.to) {
2117
- newValue = value.to;
2118
- comparisonOperator = exports.ComparisonOperator.GreaterThan;
2119
- }
2120
- } else {
2121
- newValue = value.uniqueValue || value.title;
2122
- comparisonOperator = exports.ComparisonOperator.NotEquals;
2123
- }
2124
-
2125
- return new FilterCondition(createConditionString({
2126
- attribute: attributeName,
2127
- type: attributeType,
2128
- comparisonOperator: comparisonOperator,
2129
- value: newValue
2130
- })).toString();
2131
- }
2132
- const createOtherHiddenCondition = (values, attributeName, attributeType) => {
2133
- const value = values[values.length - 1];
2134
- let hiddenCondition;
2135
-
2136
- if (isRangeClass(value)) {
2137
- hiddenCondition = new FilterCondition(createConditionString({
2138
- attribute: attributeName,
2139
- type: attributeType,
2140
- comparisonOperator: exports.ComparisonOperator.LessOrEquals,
2141
- value: value.to || value.from
2142
- })).toString();
2143
- } else {
2144
- const conditions = values.map(val => new FilterCondition(createConditionString({
2145
- attribute: attributeName,
2146
- type: attributeType,
2147
- comparisonOperator: exports.ComparisonOperator.Equals,
2148
- value: val.uniqueValue
2149
- })).toString());
2150
- hiddenCondition = "( " + conditions.filter(Boolean).join(" " + exports.FilterConditionOperation.OR + " ") + " )";
2151
- }
2152
-
2153
- return hiddenCondition;
2154
- };
2155
- const getMinimizedLegendValues = (attribute, classified, formatValue, index, otherTitle) => {
2156
- const other = {
2157
- title: otherTitle,
2158
- parameterValue: classified.defaultValue,
2159
- hiddenCondition: createOtherHiddenCondition(classified.values.map(val => getClassificationValue(val.value, otherTitle, new ClassificationCondition(val.condition))), attribute.name, attribute.type)
2160
- };
2161
- const items = classified.values.map(paramValue => {
2162
- const parameterValue = getParameterValue(paramValue.value);
2163
- const result = {
2164
- parameterValue,
2165
- attribute
2166
- };
2167
-
2168
- if (isRangeCondition(paramValue.condition)) {
2169
- const from = getValueFromConditionPart(paramValue.condition, 1);
2170
- const to = getValueFromConditionPart(paramValue.condition, 2);
2171
- result.from = from ? isNumeric(from) ? +from : formatDate(from) : null;
2172
- result.to = to ? isNumeric(to) ? +to : formatDate(to) : null;
2173
- result.title = createValueTitleFromCondition(paramValue, attribute, formatValue, index);
2174
- return result;
2175
- }
2176
-
2177
- result.uniqueValue = formatValue ? formatValue(attribute.type, paramValue.value, attribute.stringFormat) : paramValue.value.toString();
2178
- result.title = getTitleFromCondition({
2179
- condition: paramValue.condition
2180
- });
2181
- result.hiddenCondition = createHiddenCondition(attribute.name, attribute.type, getClassificationValue(paramValue.value, result.title, new ClassificationCondition(paramValue.condition)));
2182
- return result;
2183
- });
2184
- return [...items, other];
2185
- };
2186
- const getMaximizedLegendValues = (attribute, param, params, classified, symbol, formatValue, sectionIndex, otherTitle) => {
2187
- const other = {
2188
- title: otherTitle,
2189
- symbol: createLegendSymbol(classified.defaultValue, param, params, symbol),
2190
- hiddenCondition: createOtherHiddenCondition(classified.values.map(val => getClassificationValue(val.value, otherTitle, new ClassificationCondition(val.condition))), attribute.name, attribute.type)
2191
- };
2192
- const items = classified.values.map((paramValue, index) => {
2193
- const result = {
2194
- symbol: createLegendSymbol(paramValue.value, param, params, symbol)
2195
- };
2196
- result.title = isRangeCondition(paramValue.condition) ? createValueTitleFromCondition(paramValue, attribute, formatValue, sectionIndex) : getTitleFromCondition({
2197
- condition: paramValue.condition
2198
- });
2199
- result.hiddenCondition = createHiddenCondition(attribute.name, attribute.type, getClassificationValue(paramValue.value, result.title, new ClassificationCondition(classified.values[index].condition)));
2200
- return result;
2201
- });
2202
- return [...items, other];
2203
- };
2204
- const classifyParamsReduce = (symbol, classifyParams, index) => {
2205
- return classifyParams == null ? void 0 : classifyParams.reduce((result, classified) => {
2206
- const param = get(symbol, classified);
2207
- return (param == null ? void 0 : param.type) === 'byAttribute' ? _extends({}, result, {
2208
- [classified]: _extends({
2209
- index
2210
- }, param)
2211
- }) : result;
2212
- }, {});
2213
- };
2214
- const getClassified = layerInfo => {
2215
- var _layerInfo$style2, _layerInfo$style2$chi, _layerInfo$style4, _layerInfo$style5;
2216
-
2217
- if (!layerInfo) return undefined;
2218
-
2219
- if ((_layerInfo$style2 = layerInfo.style) != null && (_layerInfo$style2$chi = _layerInfo$style2.children) != null && _layerInfo$style2$chi.length) {
2220
- var _layerInfo$style3;
2221
-
2222
- return {
2223
- symbol: {
2224
- type: 'byAttribute',
2225
- defaultValue: layerInfo.style.symbol,
2226
- title: null,
2227
- values: (_layerInfo$style3 = layerInfo.style) == null ? void 0 : _layerInfo$style3.children
2228
- }
2229
- };
2230
- }
2231
-
2232
- const classifyParams = SYMBOL_CLASSIFICATION[layerInfo.geometryType];
2233
-
2234
- if ((_layerInfo$style4 = layerInfo.style) != null && _layerInfo$style4.symbol && isCombinedPolylineSymbol(layerInfo.style.symbol)) {
2235
- var _layerInfo$style$symb;
2236
-
2237
- if (!((_layerInfo$style$symb = layerInfo.style.symbol.values) != null && _layerInfo$style$symb.length)) return undefined;
2238
- return layerInfo.style.symbol.values.reduce((result, polyline, index) => {
2239
- return _extends({}, result, classifyParamsReduce(polyline, classifyParams, index));
2240
- }, {});
2241
- }
2242
-
2243
- return classifyParamsReduce((_layerInfo$style5 = layerInfo.style) == null ? void 0 : _layerInfo$style5.symbol, classifyParams);
2244
- };
2245
- const getSymbolStrokeWidth = symbol => {
2246
- var _symbol$background;
2247
-
2248
- return isSvgPointSymbol(symbol) ? (_symbol$background = symbol.background) == null ? void 0 : _symbol$background.strokeWidth : symbol.strokeWidth;
2249
- };
2250
- const getParameterFromSymbol = (symbol, parameter) => {
2251
- let parameterFromSymbol = {};
2252
- symbolParameterWalker(parameterValue => {
2253
- parameterFromSymbol = parameterValue;
2254
- })(symbol, parameter);
2255
- return parameterFromSymbol;
2256
- };
2257
- const getLegendSymbolSize = symbol => {
2258
- let size = 0;
2259
-
2260
- if (isSvgPointSymbol(symbol)) {
2261
- size = getParameterValue(symbol.size);
2262
- }
2263
-
2264
- if (isH3GridSymbol(symbol)) {
2265
- size = getParameterValue(symbol.cellSize);
2266
- }
2267
-
2268
- if (isTwoDimensionalSymbol(symbol)) {
2269
- size = Math.max(getParameterValue(symbol.width), getParameterValue(symbol.height));
2270
- }
2271
-
2272
- if (isSizableSymbol(symbol)) {
2273
- const strokeWidth = getSymbolStrokeWidth(symbol);
2274
- size = getParameterValue(symbol.size) + (strokeWidth ? getParameterValue(strokeWidth) + EXTRA_BORDER_SIZE : 0);
2275
- }
2276
-
2277
- if (isPolylineSymbols(symbol)) {
2278
- size = getParameterValue(getParameterFromSymbol(symbol, 'stroke.width'));
2279
- }
2280
-
2281
- return Math.max(DEFAULT_LEGEND_SYMBOL_SIZE, size);
2282
- };
2283
- const serializeSvgPointSymbol = symbol => {
2284
- var _symbol$figure, _symbol$background2, _symbol$background3, _symbol$background4, _symbol$background5, _symbol$figure2, _symbol$figure3;
2285
-
2286
- if (!symbol) return null;
2287
- const figureFillColor = ((_symbol$figure = symbol.figure) == null ? void 0 : _symbol$figure.fillColor) || null;
2288
- const bgFillColor = ((_symbol$background2 = symbol.background) == null ? void 0 : _symbol$background2.fillColor) || null;
2289
- return _extends({
2290
- type: 'svgPointSymbol',
2291
- size: symbol.size,
2292
- offset: symbol.offset,
2293
- angle: symbol.angle
2294
- }, bgFillColor ? {
2295
- background: {
2296
- id: 'symbol-bg',
2297
- fillColor: bgFillColor,
2298
- strokeColor: ((_symbol$background3 = symbol.background) == null ? void 0 : _symbol$background3.strokeColor) || null,
2299
- strokeWidth: ((_symbol$background4 = symbol.background) == null ? void 0 : _symbol$background4.strokeWidth) || null,
2300
- type: ((_symbol$background5 = symbol.background) == null ? void 0 : _symbol$background5.type) || exports.SvgSymbolBg.Circle
2301
- }
2302
- } : {}, figureFillColor ? {
2303
- figure: {
2304
- id: 'symbol-figure',
2305
- fillColor: figureFillColor,
2306
- strokeColor: ((_symbol$figure2 = symbol.figure) == null ? void 0 : _symbol$figure2.strokeColor) || null,
2307
- strokeWidth: ((_symbol$figure3 = symbol.figure) == null ? void 0 : _symbol$figure3.strokeWidth) || null
2308
- }
2309
- } : {});
2310
- };
2311
- const SIZE_PARAMETERS = ['size', 'height', 'strokeWidth', 'stroke.width'];
2312
- const isSizeClassification = parameter => SIZE_PARAMETERS.includes(parameter);
2313
- const getServiceConfiguration = layer => {
2314
- const emptyServiceConfiguration = {
2315
- name: ''
2316
- };
2317
- if (!isLayerService(layer) || !('configuration' in layer)) return emptyServiceConfiguration;
2318
- return _extends({}, emptyServiceConfiguration, layer.configuration || {});
2319
- };
2320
- /** default attribute name which use for geometry info */
2321
-
2322
- const GEOMETRY_ATTRIBUTE = 'geometry';
2323
- /** default attribute name which contains unique id info */
2324
-
2325
- const DEFAULT_ID_ATTRIBUTE_NAME = 'gid';
2326
- const getClassificationValue = (parameterValue, title, condition) => _extends({
2327
- parameterValue,
2328
- title
2329
- }, condition.isUnique() ? {
2330
- uniqueValue: condition.uniqueValue
2331
- } : {
2332
- from: condition.range[0],
2333
- to: condition.range[1]
2334
- });
2335
-
2336
- const getHexColor = colorString => colorString ? new color.Color(colorString).toString('hex') : undefined;
2337
-
2338
- // TODO reduce
2339
- const PREVIEW_LIMITS = {
2340
- STROKE_WIDTH_MIN: 0.25,
2341
- STROKE_WIDTH_MAX: 6.5
2342
- };
2343
-
2344
- function clamp(num, min, max) {
2345
- return Math.min(Math.max(num, min), max);
2346
- }
2347
-
2348
- /* eslint-disable @typescript-eslint/no-magic-numbers */
2349
- const SOLID_INTERVALS = [];
2350
- const solidStrokeStylePreset = {
2351
- style: 0
2352
- /* Solid */
2353
- ,
2354
- type: 'solid',
2355
- intervals: SOLID_INTERVALS
2356
- };
2357
- const strokeStylePresets = [solidStrokeStylePreset, {
2358
- style: 2
2359
- /* Dot */
2360
- ,
2361
- type: 'dashed',
2362
- intervals: [2, 2]
2363
- }, {
2364
- style: 1
2365
- /* Dash */
2366
- ,
2367
- type: 'dashed',
2368
- intervals: [3, 3, 3, 3]
2369
- }, {
2370
- style: 3
2371
- /* DashDot */
2372
- ,
2373
- type: 'dashed',
2374
- intervals: [5, 2, 1, 2]
2375
- }, {
2376
- style: 4
2377
- /* DashDotDot */
2378
- ,
2379
- type: 'dashed',
2380
- intervals: [5, 2, 1, 1, 1, 2]
2381
- }, {
2382
- style: 5
2383
- /* Custom */
2384
- ,
2385
- type: 'dashed',
2386
- intervals: [5, 4]
2387
- }];
2388
-
2389
- const walkByNumbersGroup = (numbers, offset, walker) => {
2390
- if (!numbers || !numbers.length) return [];
2391
- const newNumbers = [];
2392
-
2393
- for (let i = 0; i < numbers.length; i++) {
2394
- if (i % 2) {
2395
- newNumbers.push(...walker([numbers[i - 1], numbers[i]], offset));
2396
- }
2397
- }
2398
-
2399
- return newNumbers;
2400
- };
2401
-
2402
- const toIntervals = (numbers, width) => walkByNumbersGroup(numbers, clamp(getParameterValue(width), PREVIEW_LIMITS.STROKE_WIDTH_MIN, PREVIEW_LIMITS.STROKE_WIDTH_MAX), (_ref, offset) => {
2403
- let [length, gap] = _ref;
2404
- return [length * offset, gap * offset];
2405
- });
2406
- const toLineDash = (numbers, width) => walkByNumbersGroup(numbers, clamp(getParameterValue(width), PREVIEW_LIMITS.STROKE_WIDTH_MIN, PREVIEW_LIMITS.STROKE_WIDTH_MAX), (_ref2, offset) => {
2407
- let [length, gap] = _ref2;
2408
- return [Math.round(length / Math.max(1, Math.min(offset, 16) / 4)), Math.round(gap + 1 + Math.max(1, Math.min(offset, 16) / 2))];
2409
- });
2410
- const getLineDash = brush => {
2411
- if (!brush || brush.type === 'solid') return []; // @ts-ignore
2412
-
2413
- return toLineDash(brush.intervals, brush.width);
2414
- };
2415
- const defineStrokeStylePreset = intervals => {
2416
- if (!intervals.length) return solidStrokeStylePreset;
2417
- return strokeStylePresets.find(preset => {
2418
- if (preset.intervals.length !== intervals.length) return false;
2419
- const uniqueStrokeWidths = preset.intervals.map((presetInterval, i) => intervals[i] / presetInterval).filter(api.unique);
2420
- return uniqueStrokeWidths.length === 1;
2421
- });
2422
- };
2423
- const getDashStylePreset = dashStyle => strokeStylePresets.find(preset => preset.style === dashStyle);
2424
-
2425
- const ALPHA_NORMALIZER = 65025;
2426
-
2427
- const sum = numbers => numbers.reduce((result, num) => result + num, 0);
2428
-
2429
- const shouldFillMatrixCell = (matrixSize, hatchAngle, x, y) => {
2430
- const center = Math.round(matrixSize / 2);
2431
-
2432
- if ((hatchAngle === 0 || hatchAngle === Math.PI) && x === center) {
2433
- return true;
2434
- }
2435
-
2436
- if (hatchAngle === Math.PI / 4 && y === x) {
2437
- return true;
2438
- }
2439
-
2440
- if (hatchAngle === Math.PI / 2 && y === center) {
2441
- return true;
2442
- }
2443
-
2444
- return hatchAngle === 3 * Math.PI / 4 && matrixSize - 1 - y === x;
2445
- };
2446
-
2447
- const createEmptyMatrix = size => Array(size).fill(null).map(() => Array(size));
2448
-
2449
- const fillMatrix = (matrix, filler) => {
2450
- const matrixSize = matrix.length;
2451
-
2452
- for (let x = 0; x < matrixSize; x++) {
2453
- for (let y = 0; y < matrixSize; y++) {
2454
- matrix[x][y] = filler(x, y, matrixSize);
2455
- }
2456
- }
2457
- };
2458
-
2459
- const createFillBrushMatrix = (hatchAngle, hatchWidth, scalingFactor) => {
2460
- const matrixSize = Math.max(Math.round(sum([Math.max(...scalingFactor), hatchWidth])), hatchWidth);
2461
- const matrix = createEmptyMatrix(matrixSize);
2462
- fillMatrix(matrix, (x, y, size) => shouldFillMatrixCell(size, hatchAngle, x, y) ? 255 : 0);
2463
- return matrix;
2464
- };
2465
-
2466
- const createSymbolFillBrush = fillBrush => {
2467
- if (fillBrush.type !== 'hatch') return undefined;
2468
- return createFillBrushMatrix( // @ts-ignore
2469
- getParameterValue(fillBrush.hatchAngle), // @ts-ignore
2470
- Math.round(fillBrush.hatchWidth), fillBrush.scalingFactor);
2471
- };
2472
-
2473
- let SGisBrushFill = /*#__PURE__*/function (_sBrushFill) {
2474
- _inherits(SGisBrushFill, _sBrushFill);
2475
-
2476
- var _super = /*#__PURE__*/_createSuper(SGisBrushFill);
2477
-
2478
- function SGisBrushFill(originalSymbol) {
2479
- var _originalSymbol$strok, _originalSymbol$strok2, _originalSymbol$fill, _originalSymbol$fill2;
2480
-
2481
- var _this;
2482
-
2483
- _classCallCheck(this, SGisBrushFill);
2484
-
2485
- _this = _super.call(this, {
2486
- // @ts-ignore
2487
- strokeColor: getHexColor(getParameterValue((_originalSymbol$strok = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok.color)),
2488
- // @ts-ignore
2489
- strokeWidth: getParameterValue((_originalSymbol$strok2 = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok2.width),
2490
- lineDash: getLineDash(originalSymbol.stroke),
2491
- fillBackground: getHexColor( // @ts-ignore
2492
- getParameterValue((_originalSymbol$fill = originalSymbol.fill) == null ? void 0 : _originalSymbol$fill.color)),
2493
- fillForeground: isHatchBrush(originalSymbol.fill) ? // @ts-ignore
2494
- getHexColor(getParameterValue((_originalSymbol$fill2 = originalSymbol.fill) == null ? void 0 : _originalSymbol$fill2.hatchColor)) : void 0,
2495
- fillBrush: createSymbolFillBrush(originalSymbol.fill),
2496
- lineCap: 'square'
2497
- });
2498
- _this.originalSymbol = originalSymbol;
2499
- return _this;
2500
- }
2501
-
2502
- _createClass(SGisBrushFill, [{
2503
- key: "_updateBrush",
2504
- value: function _updateBrush() {
2505
- // @ts-ignore
2506
- if (!this._initialized) return;
2507
- const canvas = document.createElement('canvas');
2508
- const ctx = canvas.getContext('2d');
2509
-
2510
- if (!ctx) {
2511
- return;
2512
- }
2513
-
2514
- const brush = this.fillBrush;
2515
- const brushSize = brush.length;
2516
- const foreground = new color.Color(this.fillForeground);
2517
- const background = new color.Color(this.fillBackground);
2518
- canvas.height = brushSize;
2519
- canvas.width = brushSize;
2520
-
2521
- for (let i = 0; i < brushSize; i++) {
2522
- // eslint-disable-next-line id-length
2523
- for (let j = 0; j < brush[i].length; j++) {
2524
- const srcA = brush[i][j] * foreground.a / ALPHA_NORMALIZER;
2525
- const dstA = background.a / 255 * (1 - srcA);
2526
- const alpha = +Math.min(1, srcA + dstA).toFixed(2);
2527
- const red = Math.round(Math.min(255, background.r * dstA + foreground.r * srcA));
2528
- const green = Math.round(Math.min(255, background.g * dstA + foreground.g * srcA));
2529
- const blue = Math.round(Math.min(255, background.b * dstA + foreground.b * srcA));
2530
- ctx.fillStyle = "rgba(" + red + "," + green + "," + blue + "," + alpha + ")";
2531
- ctx.fillRect(j, i, 1, 1);
2532
- }
2533
- }
2534
-
2535
- this._brush = new Image();
2536
- this._brush.src = canvas.toDataURL();
2537
- }
2538
- }, {
2539
- key: "clone",
2540
- value: function clone() {
2541
- return new SGisBrushFill(this.originalSymbol);
2542
- }
2543
- }]);
2544
-
2545
- return SGisBrushFill;
2546
- }(BrushFill.BrushFill);
2547
-
2548
- let SGisImageFill = /*#__PURE__*/function (_sImageFill) {
2549
- _inherits(SGisImageFill, _sImageFill);
2550
-
2551
- var _super = /*#__PURE__*/_createSuper(SGisImageFill);
2552
-
2553
- function SGisImageFill(originalSymbol) {
2554
- var _originalSymbol$strok, _originalSymbol$strok2;
2555
-
2556
- var _this;
2557
-
2558
- _classCallCheck(this, SGisImageFill);
2559
-
2560
- _this = _super.call(this, {
2561
- // @ts-ignore
2562
- strokeColor: getHexColor(getParameterValue((_originalSymbol$strok = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok.color)),
2563
- // @ts-ignore
2564
- strokeWidth: getParameterValue((_originalSymbol$strok2 = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok2.width),
2565
- lineDash: getLineDash(originalSymbol.stroke),
2566
- src: "data:image/png;base64," + originalSymbol.fill.pattern,
2567
- lineCap: isDashedBrush(originalSymbol.stroke) ? 'square' : 'round'
2568
- });
2569
- _this.originalSymbol = originalSymbol;
2570
- return _this;
2571
- }
2572
-
2573
- _createClass(SGisImageFill, [{
2574
- key: "clone",
2575
- value: function clone() {
2576
- return new SGisImageFill(this.originalSymbol);
2577
- }
2578
- }]);
2579
-
2580
- return SGisImageFill;
2581
- }(ImageFill.ImageFill);
2582
-
2583
- let SGisPolygonSymbol = /*#__PURE__*/function (_sPolygonSymbol) {
2584
- _inherits(SGisPolygonSymbol, _sPolygonSymbol);
2585
-
2586
- var _super = /*#__PURE__*/_createSuper(SGisPolygonSymbol);
2587
-
2588
- function SGisPolygonSymbol(originalSymbol) {
2589
- var _originalSymbol$strok, _originalSymbol$strok2, _originalSymbol$fill;
2590
-
2591
- var _this;
2592
-
2593
- _classCallCheck(this, SGisPolygonSymbol);
2594
-
2595
- _this = _super.call(this, {
2596
- // @ts-ignore
2597
- strokeColor: getHexColor(getParameterValue((_originalSymbol$strok = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok.color)),
2598
- // @ts-ignore
2599
- strokeWidth: getParameterValue((_originalSymbol$strok2 = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok2.width),
2600
- lineDash: getLineDash(originalSymbol.stroke),
2601
- // @ts-ignore
2602
- fillColor: getHexColor(getParameterValue((_originalSymbol$fill = originalSymbol.fill) == null ? void 0 : _originalSymbol$fill.color)),
2603
- // TODO?: may be it should be defined by user
2604
- lineCap: isDashedBrush(originalSymbol.stroke) ? 'square' : 'round'
2605
- });
2606
- _this.originalSymbol = originalSymbol;
2607
- return _this;
2608
- }
2609
-
2610
- _createClass(SGisPolygonSymbol, [{
2611
- key: "clone",
2612
- value: function clone() {
2613
- return new SGisPolygonSymbol(this.originalSymbol);
2614
- }
2615
- }]);
2616
-
2617
- return SGisPolygonSymbol;
2618
- }(Simple.PolygonSymbol);
2619
-
2620
- const adaptMiterRings = (rings, resolution, fromCrs, toCrs) => {
2621
- const projected = geotools.projectRings(rings, fromCrs, toCrs);
2622
- return math.simplifyCoordinates(projected.map(ring => // @ts-ignore
2623
- ring.map((_ref) => {
2624
- let [x, y] = _ref;
2625
- return [x / resolution, y / -resolution];
2626
- })), 1);
2627
- };
2628
-
2629
- const miterSizeCalcs = {
2630
- ["small"
2631
- /* Small */
2632
- ]: strokeWidth => (strokeWidth + 1) * 3 + 1,
2633
- ["large"
2634
- /* Large */
2635
- ]: strokeWidth => (strokeWidth + 1) * 5 - 1
2636
- };
2637
- let LineMiterRender = /*#__PURE__*/function () {
2638
- function LineMiterRender(baseInfo) {
2639
- _classCallCheck(this, LineMiterRender);
2640
-
2641
- this.getAnchor = rings => {
2642
- if (this.position === 'right') {
2643
- const lastRing = rings[rings.length - 1];
2644
- return lastRing && lastRing[lastRing.length - 1] || null;
2645
- }
2646
-
2647
- const firstRing = rings[0];
2648
- return firstRing && firstRing[0] || null;
2649
- };
2650
-
2651
- Object.assign(this, baseInfo);
2652
- }
2653
-
2654
- _createClass(LineMiterRender, [{
2655
- key: "getRender",
2656
- value: function getRender(anchorRings, anchorCrs, resolution, currentCrs) {
2657
- const xMultiplier = this.position === 'right' ? 1 : -1;
2658
- const miterAnchor = this.getAnchor(anchorRings);
2659
- const miterRings = this.createRings(miterAnchor, xMultiplier);
2660
- const projectedMiterRings = adaptMiterRings(miterRings, resolution, anchorCrs, currentCrs);
2661
- return this.createRender(projectedMiterRings);
2662
- }
2663
- }, {
2664
- key: "miterSize",
2665
- get: function get() {
2666
- const calcMiterSize = miterSizeCalcs[this.size];
2667
- return calcMiterSize ? calcMiterSize(this.strokeWidth) : 1;
2668
- }
2669
- }]);
2670
-
2671
- return LineMiterRender;
2672
- }();
2673
-
2674
- let ArrowLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
2675
- _inherits(ArrowLineMiterRender, _LineMiterRender);
2676
-
2677
- var _super = /*#__PURE__*/_createSuper(ArrowLineMiterRender);
2678
-
2679
- function ArrowLineMiterRender() {
2680
- _classCallCheck(this, ArrowLineMiterRender);
2681
-
2682
- return _super.apply(this, arguments);
2683
- }
2684
-
2685
- _createClass(ArrowLineMiterRender, [{
2686
- key: "usageSize",
2687
- get: function get() {
2688
- return this.miterSize + this.strokeWidth;
2689
- }
2690
- }, {
2691
- key: "createRings",
2692
- value: function createRings(_ref, xMultiplier) {
2693
- let [x, y] = _ref;
2694
- return [[[x, y + this.miterSize / 2], [x + this.miterSize * xMultiplier, y], [x, y - this.miterSize / 2]]];
2695
- }
2696
- }, {
2697
- key: "createRender",
2698
- value: function createRender(miterRings) {
2699
- const isFilled = this.kind === api.LineEndingType.FilledArrow;
2700
- return new Poly.PolyRender(miterRings, {
2701
- enclosed: isFilled,
2702
- fillColor: isFilled ? this.color : void 0,
2703
- fillStyle: isFilled ? Poly.FillStyle.Color : Poly.FillStyle.None,
2704
- lineCap: 'square',
2705
- lineJoin: 'miter',
2706
- strokeColor: this.color,
2707
- strokeWidth: this.strokeWidth
2708
- });
2709
- }
2710
- }]);
2711
-
2712
- return ArrowLineMiterRender;
2713
- }(LineMiterRender);
2714
-
2715
- let CircleLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
2716
- _inherits(CircleLineMiterRender, _LineMiterRender);
2717
-
2718
- var _super = /*#__PURE__*/_createSuper(CircleLineMiterRender);
2719
-
2720
- function CircleLineMiterRender() {
2721
- _classCallCheck(this, CircleLineMiterRender);
2722
-
2723
- return _super.apply(this, arguments);
2724
- }
2725
-
2726
- _createClass(CircleLineMiterRender, [{
2727
- key: "usageSize",
2728
- get: function get() {
2729
- return this.miterSize + this.strokeWidth * 3;
2730
- }
2731
- }, {
2732
- key: "createRings",
2733
- value: function createRings(_ref, xMultiplier) {
2734
- let [x, y] = _ref;
2735
- return [[[x + (this.miterSize / 2 + this.strokeWidth) * xMultiplier, y]]];
2736
- }
2737
- }, {
2738
- key: "createRender",
2739
- value: function createRender(miterRings) {
2740
- const isFilled = this.kind === api.LineEndingType.FilledCircle;
2741
- return new Poly.PolyRender(polygonCircleFromPoint(miterRings[0][0], this.miterSize), {
2742
- fillColor: isFilled ? this.color : 'transparent',
2743
- strokeColor: this.color,
2744
- strokeWidth: this.strokeWidth,
2745
- enclosed: true
2746
- });
2747
- }
2748
- }]);
2749
-
2750
- return CircleLineMiterRender;
2751
- }(LineMiterRender);
2752
-
2753
- let SquareLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
2754
- _inherits(SquareLineMiterRender, _LineMiterRender);
2755
-
2756
- var _super = /*#__PURE__*/_createSuper(SquareLineMiterRender);
2757
-
2758
- function SquareLineMiterRender() {
2759
- _classCallCheck(this, SquareLineMiterRender);
2760
-
2761
- return _super.apply(this, arguments);
2762
- }
2763
-
2764
- _createClass(SquareLineMiterRender, [{
2765
- key: "usageSize",
2766
- get: function get() {
2767
- return this.miterSize + this.strokeWidth;
2768
- }
2769
- }, {
2770
- key: "createRings",
2771
- value: function createRings(_ref, xMultiplier) {
2772
- let [x, y] = _ref;
2773
- return [[[x, y + this.miterSize / 2], [x, y - this.miterSize / 2], [x + this.miterSize * xMultiplier, y - this.miterSize / 2], [x + this.miterSize * xMultiplier, y + this.miterSize / 2]]];
2774
- }
2775
- }, {
2776
- key: "createRender",
2777
- value: function createRender(miterRings) {
2778
- const isFilled = this.kind === api.LineEndingType.FilledSquare;
2779
- return new Poly.PolyRender(miterRings, {
2780
- enclosed: true,
2781
- fillColor: isFilled ? this.color : void 0,
2782
- fillStyle: isFilled ? Poly.FillStyle.Color : Poly.FillStyle.None,
2783
- lineCap: 'square',
2784
- lineJoin: 'miter',
2785
- strokeColor: this.color,
2786
- strokeWidth: this.strokeWidth
2787
- });
2788
- }
2789
- }]);
2790
-
2791
- return SquareLineMiterRender;
2792
- }(LineMiterRender);
2793
-
2794
- const getLineMiterRender = options => {
2795
- switch (options.kind) {
2796
- case api.LineEndingType.Arrow:
2797
- case api.LineEndingType.FilledArrow:
2798
- return new ArrowLineMiterRender(options);
2799
-
2800
- case api.LineEndingType.Square:
2801
- case api.LineEndingType.FilledSquare:
2802
- return new SquareLineMiterRender(options);
2803
-
2804
- case api.LineEndingType.Circle:
2805
- case api.LineEndingType.FilledCircle:
2806
- return new CircleLineMiterRender(options);
2807
-
2808
- default:
2809
- return null;
2810
- }
2811
- };
2812
-
2813
- const updateRingForRightMiter = (ring, miterSize, isLastRing) => {
2814
- const reversedRing = ring.slice().reverse();
2815
-
2816
- for (let i = 0; i < reversedRing.length; i++) {
2817
- const coordinates = reversedRing[i];
2818
-
2819
- if (isLastRing && i === 0) {
2820
- reversedRing[i] = [coordinates[0] - miterSize, coordinates[1]];
2821
- }
2822
-
2823
- const nextCoordinates = reversedRing[i - 1];
2824
-
2825
- if (nextCoordinates && nextCoordinates[0] < coordinates[0]) {
2826
- reversedRing[i] = [nextCoordinates[0] - Math.abs(nextCoordinates[0] - coordinates[0]), coordinates[1]];
2827
- }
2828
- }
2829
-
2830
- return reversedRing.reverse();
2831
- };
2832
-
2833
- const updateRingForLeftMiter = (ring, miterSize, isFirstRing) => {
2834
- const newRing = ring.slice();
2835
-
2836
- for (let i = 0; i < newRing.length; i++) {
2837
- const coordinates = newRing[i];
2838
-
2839
- if (i === 0 && isFirstRing) {
2840
- newRing[i] = [coordinates[0] + miterSize, coordinates[1]];
2841
- }
2842
-
2843
- const prevCoordinates = newRing[i - 1];
2844
-
2845
- if (prevCoordinates && prevCoordinates[0] > coordinates[0]) {
2846
- newRing[i] = [prevCoordinates[0] + Math.abs(coordinates[0] - prevCoordinates[0]), coordinates[1]];
2847
- }
2848
- }
2849
-
2850
- return newRing;
2851
- };
2852
-
2853
- const updateRingsForMiter = (rings, position, miterSize) => {
2854
- return rings.map((ring, ringIndex) => {
2855
- switch (position) {
2856
- case 'right':
2857
- return updateRingForRightMiter(ring, miterSize, ringIndex === rings.length - 1);
2858
-
2859
- default:
2860
- return updateRingForLeftMiter(ring, miterSize, ringIndex === 0);
2861
- }
2862
- });
2863
- };
2864
-
2865
- const copyRings = rings => rings.map(ring => ring.map(coordinates => coordinates.slice()));
2866
- let SGisPolylineSymbol = /*#__PURE__*/function (_sPolylineSymbol) {
2867
- _inherits(SGisPolylineSymbol, _sPolylineSymbol);
2868
-
2869
- var _super = /*#__PURE__*/_createSuper(SGisPolylineSymbol);
2870
-
2871
- function SGisPolylineSymbol(originalSymbol) {
2872
- var _originalSymbol$strok, _originalSymbol$strok2;
2873
-
2874
- var _this;
2875
-
2876
- _classCallCheck(this, SGisPolylineSymbol);
2877
-
2878
- _this = _super.call(this, {
2879
- // @ts-ignore
2880
- strokeColor: getHexColor(getParameterValue((_originalSymbol$strok = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok.color)),
2881
- strokeWidth: clamp( // @ts-ignore
2882
- getParameterValue((_originalSymbol$strok2 = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok2.width), PREVIEW_LIMITS.STROKE_WIDTH_MIN, PREVIEW_LIMITS.STROKE_WIDTH_MAX),
2883
- // @ts-ignore
2884
- lineDash: getLineDash(originalSymbol.stroke),
2885
- // @ts-ignore
2886
- lineCap: isDashedBrush(originalSymbol.stroke) ? 'square' : 'round'
2887
- });
2888
- _this.originalSymbol = originalSymbol;
2889
- return _this;
2890
- }
2891
-
2892
- _createClass(SGisPolylineSymbol, [{
2893
- key: "renderFunction",
2894
- value: function renderFunction(feature, resolution, crs) {
2895
- if (!isSimplePolylineSymbol(this.originalSymbol)) return _get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, feature, resolution, crs);
2896
- const {
2897
- ending,
2898
- beginning
2899
- } = this.originalSymbol;
2900
- const renders = [];
2901
- const featureCopy = feature.clone();
2902
- const beginningMiterRender = getLineMiterRender({
2903
- color: this.strokeColor,
2904
- // @ts-ignore
2905
- kind: beginning.type,
2906
- position: 'left',
2907
- // @ts-ignore
2908
- size: beginning.size,
2909
- strokeWidth: this.strokeWidth
2910
- });
2911
- const endingMiterRender = getLineMiterRender({
2912
- color: this.strokeColor,
2913
- // @ts-ignore
2914
- kind: ending.type,
2915
- position: 'right',
2916
- // @ts-ignore
2917
- size: ending.size,
2918
- strokeWidth: this.strokeWidth
2919
- });
2920
-
2921
- if (beginningMiterRender) {
2922
- const updatedRings = updateRingsForMiter(featureCopy.rings, 'left', beginningMiterRender.usageSize);
2923
- const render = beginningMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
2924
- featureCopy.rings = updatedRings;
2925
- renders.push(render);
2926
- }
2927
-
2928
- if (endingMiterRender) {
2929
- const updatedRings = updateRingsForMiter(featureCopy.rings, 'right', endingMiterRender.usageSize);
2930
- const render = endingMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
2931
- featureCopy.rings = updatedRings;
2932
- renders.push(render);
2933
- } // NOTE: линия должна быть в начале чтобы быть под митерами
2934
-
2935
-
2936
- renders.unshift(..._get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, featureCopy, resolution, crs));
2937
- return renders;
2938
- }
2939
- }, {
2940
- key: "clone",
2941
- value: function clone() {
2942
- return new SGisPolylineSymbol(this.originalSymbol);
2943
- }
2944
- }]);
2945
-
2946
- return SGisPolylineSymbol;
2947
- }(PolylineSymbol.PolylineSymbol);
2948
-
2949
- let ShadowedPointSymbol = /*#__PURE__*/function (_PointSymbol) {
2950
- _inherits(ShadowedPointSymbol, _PointSymbol);
2951
-
2952
- var _super = /*#__PURE__*/_createSuper(ShadowedPointSymbol);
2953
-
2954
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2955
- function ShadowedPointSymbol(options) {
2956
- _classCallCheck(this, ShadowedPointSymbol);
2957
-
2958
- return _super.call(this, options);
2959
- }
2960
-
2961
- _createClass(ShadowedPointSymbol, [{
2962
- key: "renderFunction",
2963
- value: function renderFunction(feature, resolution, crs) {
2964
- if (!(feature instanceof PointFeature.PointFeature)) return [];
2965
- const {
2966
- position
2967
- } = feature.projectTo(crs);
2968
- const pxPosition = [position[0] / resolution + (this.offset[0] || 0), -position[1] / resolution + (this.offset[1] || 0)];
2969
- const shadowRender = this.getShadow(pxPosition, feature, position);
2970
- const pointArc = this.getPoint(pxPosition, feature, position);
2971
- return shadowRender ? [shadowRender, pointArc] : [pointArc];
2972
- }
2973
- }, {
2974
- key: "getShadow",
2975
- value: function getShadow(position, _feature, mapCoordinates) {
2976
- return ShadowedPointSymbol.getShadowArc(position, this, mapCoordinates);
2977
- }
2978
- }, {
2979
- key: "getPoint",
2980
- value: function getPoint(position, _feature, mapCoordinates) {
2981
- return ShadowedPointSymbol.getPointArc(position, this, mapCoordinates);
2982
- }
2983
- }], [{
2984
- key: "getShadowArc",
2985
- value: function getShadowArc(position, _ref, mapCoordinates) {
2986
- let {
2987
- strokeWidth = 2,
2988
- shadowColor,
2989
- shadowSize,
2990
- size = 6
2991
- } = _ref;
2992
- return new Arc.Arc(position, {
2993
- fillColor: "transparent",
2994
- strokeColor: shadowColor,
2995
- strokeWidth: shadowSize,
2996
- radius: (size + strokeWidth + shadowSize) / 2,
2997
- mapCoordinates
2998
- });
2999
- }
3000
- }, {
3001
- key: "getPointArc",
3002
- value: function getPointArc(position, _ref2, mapCoordinates) {
3003
- let {
3004
- strokeWidth,
3005
- fillColor,
3006
- strokeColor,
3007
- size = 6
3008
- } = _ref2;
3009
- return new Arc.Arc(position, {
3010
- fillColor,
3011
- strokeColor,
3012
- strokeWidth,
3013
- radius: size / 2,
3014
- mapCoordinates
3015
- });
3016
- }
3017
- }]);
3018
-
3019
- return ShadowedPointSymbol;
3020
- }(Point.PointSymbol);
3021
-
3022
- const getSimplifiedPolygonCoordinates = function getSimplifiedPolygonCoordinates(feature, crs, tolerance) {
3023
- if (tolerance === void 0) {
3024
- tolerance = 1;
3025
- }
3026
-
3027
- const projected = feature.crs.equals(crs) ? feature.rings : feature.projectTo(crs).rings;
3028
- return math.simplifyCoordinates(projected, tolerance);
3029
- };
3030
- function createShadowRender(position, _ref) {
3031
- let {
3032
- strokeWidth = 1,
3033
- shadowColor,
3034
- shadowSize,
3035
- size = 3,
3036
- mapCoordinates
3037
- } = _ref;
3038
- const shadowRadius = (size + strokeWidth + shadowSize) / 2;
3039
- return new Arc.Arc(position, {
3040
- fillColor: "transparent",
3041
- strokeColor: shadowColor,
3042
- strokeWidth: shadowSize,
3043
- radius: shadowRadius,
3044
- mapCoordinates
3045
- });
3046
- }
3047
- function createPointRender(position, _ref2) {
3048
- let {
3049
- strokeColor,
3050
- strokeWidth,
3051
- fillColor,
3052
- size = 3,
3053
- mapCoordinates
3054
- } = _ref2;
3055
- const radius = size / 2;
3056
- return new Arc.Arc(position, {
3057
- fillColor,
3058
- strokeColor,
3059
- strokeWidth,
3060
- radius,
3061
- mapCoordinates
3062
- });
3063
- }
3064
- let ShadowedPolySymbol = /*#__PURE__*/function (_PolylineSymbol) {
3065
- _inherits(ShadowedPolySymbol, _PolylineSymbol);
3066
-
3067
- var _super = /*#__PURE__*/_createSuper(ShadowedPolySymbol);
3068
-
3069
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
3070
- function ShadowedPolySymbol(options) {
3071
- _classCallCheck(this, ShadowedPolySymbol);
3072
-
3073
- return _super.call(this, options);
3074
- }
3075
-
3076
- _createClass(ShadowedPolySymbol, [{
3077
- key: "renderFunction",
3078
- value: function renderFunction(feature, resolution, crs) {
3079
- if (!(feature instanceof Poly$1.Poly)) return [];
3080
-
3081
- const coordinates = _get(_getPrototypeOf(ShadowedPolySymbol.prototype), "getRenderedCoordinates", this).call(this, feature, resolution, crs);
3082
-
3083
- const simplifiedFeatureCoordinates = getSimplifiedPolygonCoordinates(feature, crs);
3084
- const polyRender = this.getPolyRender(coordinates, feature, simplifiedFeatureCoordinates);
3085
- const shadowRender = this.getShadow(coordinates, feature, simplifiedFeatureCoordinates);
3086
- const vertexRenders = this.getVertexRenders(coordinates, simplifiedFeatureCoordinates);
3087
- let renders = [polyRender];
3088
-
3089
- if (shadowRender) {
3090
- renders = [shadowRender, polyRender];
3091
- }
3092
-
3093
- if (vertexRenders) {
3094
- renders = renders.concat(vertexRenders);
3095
- }
3096
-
3097
- return renders;
3098
- }
3099
- }, {
3100
- key: "getShadow",
3101
- value: function getShadow(coordinates, _feature, mapCoordinates) {
3102
- return new Poly.PolyRender(coordinates, {
3103
- fillStyle: Poly.FillStyle.None,
3104
- enclosed: this.enclose,
3105
- strokeColor: this.shadowColor,
3106
- strokeWidth: this.shadowSize,
3107
- lineDash: this.lineDash,
3108
- mapCoordinates
3109
- });
3110
- }
3111
- }, {
3112
- key: "getPolyRender",
3113
- value: function getPolyRender(coordinates, _feature, mapCoordinates) {
3114
- return new Poly.PolyRender(coordinates, {
3115
- fillStyle: this.enclose ? Poly.FillStyle.Color : Poly.FillStyle.None,
3116
- enclosed: this.enclose,
3117
- fillColor: this.fillColor,
3118
- strokeColor: this.strokeColor,
3119
- strokeWidth: this.strokeWidth,
3120
- lineDash: this.lineDash,
3121
- mapCoordinates
3122
- });
3123
- }
3124
- }, {
3125
- key: "getVertexRenders",
3126
- value: function getVertexRenders(coordinates, mapCoordinates) {
3127
- if (!this.showVertex) return;
3128
- const pointRenderers = [];
3129
- const shadowRenderers = [];
3130
-
3131
- for (let i = 0; i < coordinates.length; i++) {
3132
- const ring = coordinates[i];
3133
-
3134
- for (let j = 0; j < ring.length; j++) {
3135
- const point = ring[j];
3136
- const featurePoint = mapCoordinates[i][j];
3137
- const shadowRender = createShadowRender(point, {
3138
- size: 6,
3139
- strokeWidth: 2,
3140
- shadowColor: this.shadowColor,
3141
- strokeColor: this.strokeColor,
3142
- shadowSize: this.vertexShadowSize !== undefined ? this.vertexShadowSize : 2,
3143
- fillColor: 'transparent',
3144
- mapCoordinates: featurePoint
3145
- });
3146
- const pointRender = createPointRender(point, {
3147
- size: 6,
3148
- strokeWidth: 2,
3149
- shadowColor: this.shadowColor,
3150
- strokeColor: this.strokeColor,
3151
- shadowSize: this.vertexShadowSize !== undefined ? this.vertexShadowSize : 2,
3152
- fillColor: '#ffffff',
3153
- mapCoordinates: featurePoint
3154
- });
3155
- shadowRenderers.push(shadowRender);
3156
- pointRenderers.push(pointRender);
3157
- }
3158
- }
3159
-
3160
- return [...pointRenderers, ...shadowRenderers];
3161
- }
3162
- }]);
3163
-
3164
- return ShadowedPolySymbol;
3165
- }(PolylineSymbol.PolylineSymbol);
3166
- const polySymbolParams = {
3167
- strokeWidth: 2,
3168
- strokeColor: '#e33600',
3169
- shadowSize: 8,
3170
- shadowColor: 'rgba(227, 54, 0, 0.3)'
3171
- };
3172
- const measureSymbolParams = {
3173
- strokeColor: '#ff6933',
3174
- shadowSize: 0,
3175
- vertexShadowSize: 0
3176
- };
3177
- const measureLengthSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
3178
- enclose: false,
3179
- showVertex: true
3180
- }));
3181
- const measureAreaSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
3182
- fillColor: 'rgba(255, 105, 51, 0.25)',
3183
- enclose: true,
3184
- showVertex: true
3185
- }));
3186
- const snapSymbolParams = {
3187
- size: 10,
3188
- strokeWidth: 2,
3189
- strokeColor: '#e33600',
3190
- fillColor: '#ffffff',
3191
- shadowColor: 'rgba(227, 54, 0, 0.3)',
3192
- shadowSize: 3
3193
- };
3194
- const measurePolygonSnapSymbol = /*#__PURE__*/new ShadowedPointSymbol( /*#__PURE__*/_extends({}, snapSymbolParams, {
3195
- strokeColor: '#ff6933',
3196
- shadowSize: 0
3197
- }));
3198
-
3199
- let SelectedPointSymbol = /*#__PURE__*/function (_ShadowedPointSymbol) {
3200
- _inherits(SelectedPointSymbol, _ShadowedPointSymbol);
3201
-
3202
- var _super = /*#__PURE__*/_createSuper(SelectedPointSymbol);
3203
-
3204
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
3205
- function SelectedPointSymbol(props) {
3206
- _classCallCheck(this, SelectedPointSymbol);
3207
-
3208
- return _super.call(this, props);
3209
- }
3210
-
3211
- _createClass(SelectedPointSymbol, [{
3212
- key: "getShadow",
3213
- value: function getShadow(position, feature, mapCoordinates) {
3214
- if (feature.isSelected) {
3215
- return _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getShadow", this).call(this, position, feature, mapCoordinates);
3216
- }
3217
- }
3218
- }, {
3219
- key: "getPoint",
3220
- value: function getPoint(position, feature, mapCoordinates) {
3221
- const pointRender = _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getPoint", this).call(this, position, feature, mapCoordinates);
3222
-
3223
- if (feature.isSelected) {
3224
- pointRender.strokeColor = this.selectedStrokeColor;
3225
- pointRender.fillColor = this.selectedFillColor;
3226
- }
3227
-
3228
- return pointRender;
3229
- }
3230
- }]);
3231
-
3232
- return SelectedPointSymbol;
3233
- }(ShadowedPointSymbol);
3234
-
3235
- let SelectedPolySymbol = /*#__PURE__*/function (_ShadowedPolySymbol) {
3236
- _inherits(SelectedPolySymbol, _ShadowedPolySymbol);
3237
-
3238
- var _super = /*#__PURE__*/_createSuper(SelectedPolySymbol);
3239
-
3240
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
3241
- function SelectedPolySymbol(props) {
3242
- _classCallCheck(this, SelectedPolySymbol);
3243
-
3244
- return _super.call(this, props);
3245
- }
3246
-
3247
- _createClass(SelectedPolySymbol, [{
3248
- key: "getShadow",
3249
- value: function getShadow(coordinates, feature, mapCoordinates) {
3250
- if (feature.isSelected) {
3251
- return _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getShadow", this).call(this, coordinates, feature, mapCoordinates);
3252
- }
3253
- }
3254
- }, {
3255
- key: "getPolyRender",
3256
- value: function getPolyRender(coordinates, feature, mapCoordinates) {
3257
- const polyRender = _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getPolyRender", this).call(this, coordinates, feature, mapCoordinates);
3258
-
3259
- if (feature.isSelected) {
3260
- polyRender.fillColor = this.selectedFillColor;
3261
- polyRender.strokeColor = this.selectedStrokeColor;
3262
-
3263
- if (this.selectedStrokeWidth !== void 0) {
3264
- polyRender.strokeWidth = this.selectedStrokeWidth;
3265
- }
3266
- }
3267
-
3268
- return polyRender;
3269
- }
3270
- }]);
3271
-
3272
- return SelectedPolySymbol;
3273
- }(ShadowedPolySymbol);
3274
-
3275
- const selectedPoint = /*#__PURE__*/new SelectedPointSymbol({
3276
- size: 8,
3277
- strokeWidth: 2,
3278
- strokeColor: 'rgba(255, 87, 34, 0.3)',
3279
- fillColor: 'rgba(255, 255, 255, 0.65)',
3280
- shadowColor: 'rgba(255, 87, 34, 0.3)',
3281
- shadowSize: 3,
3282
- selectedStrokeColor: '#ff5722',
3283
- selectedFillColor: 'rgba(255, 255, 255, 0.65)'
3284
- });
3285
- const selectedPolyline = /*#__PURE__*/new SelectedPolySymbol({
3286
- strokeWidth: 6,
3287
- strokeColor: 'rgba(255, 87, 34, 0.2)',
3288
- shadowSize: 8,
3289
- shadowColor: 'rgba(255, 87, 34, 0.3)',
3290
- selectedStrokeColor: '#ff5722',
3291
- selectedStrokeWidth: 2
3292
- });
3293
- const selectedPolygon = /*#__PURE__*/new SelectedPolySymbol({
3294
- strokeWidth: 2,
3295
- strokeColor: 'rgba(255, 87, 34, 0.3)',
3296
- shadowSize: 8,
3297
- shadowColor: 'rgba(255, 87, 34, 0.3)',
3298
- fillColor: 'rgba(255, 255, 255, 0.36)',
3299
- enclose: true,
3300
- selectedFillColor: 'rgba(255, 255, 255, 0.56)',
3301
- selectedStrokeColor: '#ff5722'
3302
- });
3303
-
3304
- const metersToPixels = (meters, _ref) => {
3305
- let {
3306
- painter,
3307
- crs = Crs.geo
3308
- } = _ref;
3309
- const {
3310
- width
3311
- } = painter;
3312
- const zeroPoint = painter.getPointFromPxPosition(0, 0).projectTo(crs);
3313
- const maxWidthPoint = painter.getPointFromPxPosition(width, 0).projectTo(crs);
3314
- const widthDistance = geotools.distance(zeroPoint, maxWidthPoint);
3315
- const pxK = width / (widthDistance || 1);
3316
- return Math.round(meters * pxK);
3317
- };
3318
-
3319
- const defaultPathStyles = {
3320
- strokeWidth: 2,
3321
- strokeColor: 'rgb(0, 163, 245)',
3322
- fillStyle: Poly.FillStyle.None
3323
- };
3324
- let SVGPoly = /*#__PURE__*/function (_Symbol) {
3325
- _inherits(SVGPoly, _Symbol);
3326
-
3327
- var _super = /*#__PURE__*/_createSuper(SVGPoly);
3328
-
3329
- function SVGPoly(_temp) {
3330
- var _this;
3331
-
3332
- let {
3333
- redrawFeatureNode,
3334
- pathStyles,
3335
- circle,
3336
- className,
3337
- appendToSvg
3338
- } = _temp === void 0 ? {} : _temp;
3339
-
3340
- _classCallCheck(this, SVGPoly);
3341
-
3342
- _this = _super.call(this);
3343
- _this.container = document.createElement('div');
3344
- _this.container.style.position = 'absolute';
3345
- _this.redrawFeatureNode = redrawFeatureNode;
3346
- _this.pathStyles = _extends({
3347
- center: [0, 0],
3348
- fillColor: 'none'
3349
- }, pathStyles);
3350
- _this.circle = circle;
3351
- _this.className = className;
3352
- _this.appendToSvg = appendToSvg;
3353
- return _this;
3354
- }
3355
-
3356
- _createClass(SVGPoly, [{
3357
- key: "renderFunction",
3358
- value: function renderFunction(feature, resolution, crs) {
3359
- const coordinates = feature instanceof Poly$1.Poly ? new PolylineSymbol.PolylineSymbol().getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
3360
- this.setCirclePxRaius(crs);
3361
- this.container.innerHTML = '';
3362
- const svg = this.setSvg(coordinates);
3363
- svg && this.container.append(svg);
3364
- feature.__dynamicSymbolRender = new Render.DynamicRender({
3365
- node: this.container,
3366
- update: (bbox, resolution) => this.update({
3367
- bbox,
3368
- resolution,
3369
- feature,
3370
- crs
3371
- }),
3372
- redraw: () => {
3373
- this.redrawFeatureNode && this.redrawFeatureNode(feature);
3374
- }
3375
- });
3376
-
3377
- this._setEventListeners(feature);
3378
-
3379
- return [feature.__dynamicSymbolRender];
3380
- }
3381
- }, {
3382
- key: "setCirclePxRaius",
3383
- value: function setCirclePxRaius(crs) {
3384
- if (this.circle && this.pathStyles) {
3385
- var _this$circle;
3386
-
3387
- this.pathStyles.radius = metersToPixels(this.circle.radius, {
3388
- painter: this.circle.painter,
3389
- crs
3390
- }) + (((_this$circle = this.circle) == null ? void 0 : _this$circle.pxOffset) || 0);
3391
- }
3392
- }
3393
- }, {
3394
- key: "update",
3395
- value: function update(_ref) {
3396
- var _this$pathStyles, _this$pathStyles2, _this$pathStyles3, _this$pathStyles4;
3397
-
3398
- let {
3399
- bbox,
3400
- resolution,
3401
- feature,
3402
- crs
3403
- } = _ref;
3404
- if (!feature) return;
3405
- if (!bbox) bbox = feature.__lastBbox;
3406
- if (!resolution) resolution = feature.__lastResolution;
3407
- if (!bbox || !resolution || !feature.crs.canProjectTo(bbox.crs)) return;
3408
-
3409
- if (feature.__lastResolution && resolution !== feature.__lastResolution) {
3410
- const newCoordinates = feature instanceof Poly$1.Poly ? new PolylineSymbol.PolylineSymbol().getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
3411
- this.setCirclePxRaius(crs);
3412
- this.container.innerHTML = '';
3413
- const svg = this.setSvg(newCoordinates);
3414
- svg && this.container.append(svg);
3415
- }
3416
-
3417
- const polygon = feature.projectTo(bbox.crs);
3418
- const radiusOffset = (_this$pathStyles = this.pathStyles) != null && _this$pathStyles.radius ? ((_this$pathStyles2 = this.pathStyles) == null ? void 0 : _this$pathStyles2.radius) + ((_this$pathStyles3 = this.pathStyles) != null && _this$pathStyles3.strokeWidth ? ((_this$pathStyles4 = this.pathStyles) == null ? void 0 : _this$pathStyles4.strokeWidth) / 2 : 0) : 0;
3419
- const dx = Math.round((polygon.bbox.xMin - bbox.xMin) / resolution) - radiusOffset;
3420
- const dy = Math.round((bbox.yMax - polygon.bbox.yMax) / resolution) - radiusOffset;
3421
- this.container.style.left = dx.toString() + "px";
3422
- this.container.style.top = dy.toString() + "px";
3423
- feature.__lastBbox = bbox;
3424
- feature.__lastResolution = resolution;
3425
- }
3426
- }, {
3427
- key: "setSvg",
3428
- value: function setSvg(coordinates) {
3429
- const {
3430
- lineCap,
3431
- lineJoin,
3432
- miterLimit,
3433
- lineDash,
3434
- dashOffset
3435
- } = this.pathStyles || {};
3436
- const svgRender = new SvgRender.SvgRender(_extends({
3437
- coordinates
3438
- }, defaultPathStyles, {
3439
- appendToSvg: this.appendToSvg
3440
- }, this.pathStyles));
3441
-
3442
- if (this.circle) {
3443
- svgRender._setArcNode();
3444
- } else {
3445
- svgRender._setPolyNode();
3446
- }
3447
-
3448
- let svgElement;
3449
- svgRender.getNode((_, svg) => {
3450
- svgElement = svg;
3451
- this.className && svgElement.classList.add(this.className);
3452
- const path = svgElement && svgElement.querySelector(this.circle ? 'circle' : 'path');
3453
-
3454
- if (path) {
3455
- path.setAttribute('stroke-linecap', lineCap || 'round');
3456
- path.setAttribute('stroke-linejoin', lineJoin || 'round');
3457
- path.setAttribute('stroke-miterlimit', (miterLimit || 10).toString());
3458
- path.setAttribute('stroke-dashoffset', (dashOffset || 0).toString());
3459
-
3460
- if (this.circle) {
3461
- path.setAttribute('stroke-dasharray', lineDash && lineDash.length > 0 ? lineDash.join(',') : '');
3462
- }
3463
- }
3464
- });
3465
- return svgElement;
3466
- }
3467
- }, {
3468
- key: "_setEventListeners",
3469
- value: function _setEventListeners(dynamicFeature) {
3470
- var _dynamicFeature$__dyn;
3471
-
3472
- if (dynamicFeature.eventFlags === EventHandler.MouseEventFlags.None) return;
3473
- const svgNode = dynamicFeature == null ? void 0 : (_dynamicFeature$__dyn = dynamicFeature.__dynamicSymbolRender) == null ? void 0 : _dynamicFeature$__dyn.node.querySelector(this.circle ? 'circle' : 'path');
3474
- Object.keys(EventHandler.mouseEvents).forEach(eventName => {
3475
- if (dynamicFeature.eventFlags & EventHandler.mouseEvents[eventName].flag) {
3476
- domEvent.listenDomEvent(svgNode, EventHandler.mouseEvents[eventName].type, event => {
3477
- dynamicFeature.fire(EventHandler.mouseEvents[eventName].type, {
3478
- node: svgNode,
3479
- browserEvent: event
3480
- });
3481
- });
3482
- }
3483
- });
3484
- }
3485
- }]);
3486
-
3487
- return SVGPoly;
3488
- }(_Symbol.Symbol);
3489
-
3490
- function isSGisPointSymbol(symbol) {
3491
- return symbol instanceof Point.PointSymbol || symbol instanceof StaticImageSymbol.StaticImageSymbol || symbol instanceof Square.SquareSymbol || symbol instanceof MaskedImage.MaskedImage;
3492
- }
3493
- function isSGisImageSymbol(symbol) {
3494
- return symbol instanceof StaticImageSymbol.StaticImageSymbol || symbol instanceof MaskedImage.MaskedImage;
3495
- }
3496
- function isSGisPolygonSymbol(symbol) {
3497
- return symbol instanceof Simple.PolygonSymbol || symbol instanceof BrushFill.BrushFill || symbol instanceof ImageFill.ImageFill;
3498
- }
3499
- function isSGisPolylineSymbol(symbol) {
3500
- return symbol instanceof PolylineSymbol.PolylineSymbol;
3501
- }
3502
- function isSGisH3Symbol(symbol) {
3503
- return symbol instanceof H3Symbol.H3Symbol;
3504
- }
3505
- function isSGisCombinedPolylineSymbol(symbol) {
3506
- return symbol instanceof CombinedPolylineSymbol.CombinedPolylineSymbol;
3507
- }
3508
- function isSGisClusterSymbol(symbol) {
3509
- return !!symbol.singleObjectSymbol;
3510
- }
3511
-
3512
- /**
3513
- * Моки фич для отображения превью символа
3514
- * http://cf.everpoint.ru/pages/viewpage.action?pageId=45024217
3515
- */
3516
-
3517
- const viewBoxSize = 100;
3518
- const pointFeature = /*#__PURE__*/new PointFeature.PointFeature([50, -50], {
3519
- crs: Crs.plain
3520
- });
3521
- const lineFeature = /*#__PURE__*/new Polyline.Polyline([[0, -57], [26, -57], [40, -35], [60, -65], [74, -43], [100, -43]], {
3522
- crs: Crs.plain
3523
- });
3524
- const combinedLineFeature = /*#__PURE__*/new CombinedPolyline.CombinedPolyline([[0, -57], [26, -57], [40, -35], [60, -65], [74, -43], [100, -43]], {
3525
- crs: Crs.plain
3526
- });
3527
- const polygonFeature = /*#__PURE__*/new Polygon.Polygon([[20, -20], [80, -20], [80, -80], [20, -80]], {
3528
- crs: Crs.plain
3529
- });
3530
- const h3gridFeature = /*#__PURE__*/new H3Feature.H3Feature([[50, -15], [80, -33], [80, -67], [50, -85], [20, -67], [20, -33], [50, -15]], {
3531
- crs: Crs.plain
3532
- });
3533
- const lineLegendFeature = /*#__PURE__*/new Polyline.Polyline([[0, -50], [100, -50]], {
3534
- crs: Crs.plain
3535
- });
3536
- const polygonLegendFeature = /*#__PURE__*/new Polygon.Polygon([[20, -20], [80, -20], [80, -80], [20, -80]], {
3537
- crs: Crs.plain
3538
- });
3539
- const polygonMapLegendFeature = /*#__PURE__*/new Polygon.Polygon([[50, 0], [100, -25], [100, -75], [50, -100], [0, -75], [0, -25]], {
3540
- crs: Crs.plain
3541
- });
3542
- const MAP_LEGEND_FEATURES = {
3543
- polygon: polygonMapLegendFeature
3544
- };
3545
- const LEGEND_FEATURES = {
3546
- point: pointFeature,
3547
- polyline: lineLegendFeature,
3548
- combinedPolyline: combinedLineFeature,
3549
- polygon: polygonLegendFeature,
3550
- h3grid: h3gridFeature
3551
- };
3552
- const MOCK_FEATURES = {
3553
- point: pointFeature,
3554
- polyline: lineFeature,
3555
- combinedPolyline: combinedLineFeature,
3556
- polygon: polygonFeature,
3557
- h3grid: h3gridFeature
3558
- };
3559
-
3560
- function getSymbolRenders(symbol, size, features) {
3561
- if (size === void 0) {
3562
- size = viewBoxSize;
3563
- }
3564
-
3565
- if (features === void 0) {
3566
- features = {};
3567
- }
3568
-
3569
- const resolution = viewBoxSize / size;
3570
-
3571
- const featuresToRender = _extends({}, MOCK_FEATURES, features);
3572
-
3573
- if (isSGisPolygonSymbol(symbol)) {
3574
- return symbol.renderFunctionAsync(featuresToRender.polygon, resolution, Crs.plain);
3575
- }
3576
-
3577
- if (isSGisPolylineSymbol(symbol)) {
3578
- return symbol.renderFunctionAsync(featuresToRender.polyline, resolution, Crs.plain);
3579
- }
3580
-
3581
- if (isSGisH3Symbol(symbol)) {
3582
- return symbol.renderFunctionAsync(featuresToRender.h3grid, resolution, Crs.plain);
3583
- }
3584
-
3585
- if (isSGisCombinedPolylineSymbol(symbol)) {
3586
- return symbol.renderFunctionAsync(featuresToRender.combinedPolyline, resolution, Crs.plain);
3587
- }
3588
-
3589
- return symbol.renderFunctionAsync(featuresToRender.point, resolution, Crs.plain);
3590
- }
3591
- const getMapLegendSymbolRenders = function getMapLegendSymbolRenders(symbol, size) {
3592
- if (size === void 0) {
3593
- size = viewBoxSize;
3594
- }
3595
-
3596
- return getSymbolRenders(symbol, size, MAP_LEGEND_FEATURES);
3597
- };
3598
- const getLegendSymbolRenders = function getLegendSymbolRenders(symbol, size) {
3599
- if (size === void 0) {
3600
- size = viewBoxSize;
3601
- }
3602
-
3603
- return getSymbolRenders(symbol, size, LEGEND_FEATURES);
3604
- };
3605
-
3606
- function renderSymbolToCanvas(renders, canvas) {
3607
- renders.forEach(render => {
3608
- canvas.draw(render);
3609
- });
3610
- }
3611
-
3612
- function deserializeSymbol(symbol) {
3613
- switch (symbol.type) {
3614
- case "h3grid":
3615
- return deserializeH3Symbol(symbol);
3616
-
3617
- case "svgPointSymbol":
3618
- return deserializeSvgPointSymbol(symbol);
3619
-
3620
- case 'circlePointSymbol':
3621
- return deserializePointSymbol(symbol);
3622
-
3623
- case 'squarePointSymbol':
3624
- return deserializeSquareSymbol(symbol);
3625
-
3626
- case 'maskedImagePointSymbol':
3627
- return deserializeMaskedImageSymbol(symbol);
3628
-
3629
- case 'imagePointSymbol':
3630
- return deserializeImagePointSymbol(symbol);
3631
-
3632
- case 'polygonSymbol':
3633
- return deserializePolygonSymbol(symbol);
3634
-
3635
- case 'simplePolylineSymbol':
3636
- return deserializePolylineSymbol(symbol);
3637
-
3638
- case "clusterSymbol":
3639
- return deserializeSymbol(symbol.singleObjectSymbol);
3640
-
3641
- default:
3642
- return null;
3643
- }
3644
- }
3645
-
3646
- function deserializeH3Symbol(symbol) {
3647
- var _symbol$stroke, _symbol$stroke2, _symbol$fill;
3648
-
3649
- return new H3Symbol.H3Symbol(_extends({}, symbol, {
3650
- cellSize: getParameterValue(symbol.cellSize),
3651
- strokeWidth: getParameterValue(symbol == null ? void 0 : (_symbol$stroke = symbol.stroke) == null ? void 0 : _symbol$stroke.width),
3652
- strokeColor: getParameterValue(symbol == null ? void 0 : (_symbol$stroke2 = symbol.stroke) == null ? void 0 : _symbol$stroke2.color),
3653
- fillColor: getParameterValue(symbol == null ? void 0 : (_symbol$fill = symbol.fill) == null ? void 0 : _symbol$fill.color)
3654
- }));
3655
- }
3656
-
3657
- function deserializePointSymbol(symbol) {
3658
- // @ts-ignore
3659
- return new Point.PointSymbol(deserializePointSymbolParams(symbol));
3660
- }
3661
-
3662
- const getOffsetParameterValue = offset => [getParameterValue(offset == null ? void 0 : offset[0]), getParameterValue(offset == null ? void 0 : offset[1])];
3663
-
3664
- function deserializeSvgPointSymbolParams(_ref) {
3665
- let {
3666
- type,
3667
- data,
3668
- size,
3669
- offset,
3670
- angle,
3671
- background,
3672
- figure
3673
- } = _ref;
3674
- return _extends({
3675
- type: getParameterValue(type),
3676
- data: getParameterValue(data),
3677
- size: getParameterValue(size),
3678
- offset: getOffsetParameterValue(offset),
3679
- angle: getParameterValue(angle)
3680
- }, background ? {
3681
- background: _extends({}, background, {
3682
- fillColor: deserializeColor(getParameterValue(background == null ? void 0 : background.fillColor)),
3683
- strokeColor: deserializeColor(getParameterValue(background == null ? void 0 : background.strokeColor)),
3684
- strokeWidth: getParameterValue(background == null ? void 0 : background.strokeWidth)
3685
- })
3686
- } : {}, figure ? {
3687
- figure: _extends({}, figure, {
3688
- strokeColor: deserializeColor(getParameterValue(figure == null ? void 0 : figure.strokeColor)),
3689
- strokeWidth: getParameterValue(figure == null ? void 0 : figure.strokeWidth),
3690
- fillColor: deserializeColor(getParameterValue(figure == null ? void 0 : figure.fillColor))
3691
- })
3692
- } : {});
3693
- }
3694
-
3695
- function deserializeSvgPointSymbol(symbol) {
3696
- return new Point.PointSymbol(deserializeSvgPointSymbolParams(symbol));
3697
- }
3698
-
3699
- function deserializeSquareSymbol(symbol) {
3700
- return new Square.SquareSymbol(_extends({}, deserializePointSymbolParams(symbol), {
3701
- // @ts-ignore
3702
- angle: getParameterValue(symbol.angle)
3703
- }));
3704
- }
3705
-
3706
- function deserializeMaskedImageSymbol(symbol) {
3707
- return new MaskedImage.MaskedImage(_extends({}, symbol, {
3708
- // @ts-ignore
3709
- angle: getParameterValue(symbol.angle),
3710
- // @ts-ignore
3711
- width: getParameterValue(symbol.width),
3712
- // @ts-ignore
3713
- height: getParameterValue(symbol.height),
3714
- // @ts-ignore
3715
- anchorPoint: deserializeAnchor(symbol.offset),
3716
- // @ts-ignore
3717
- imageSource: deserializeBase64(symbol.image),
3718
- // @ts-ignore
3719
- maskSource: deserializeBase64(symbol.imageMask),
3720
- // @ts-ignore
3721
- maskColor: deserializeColor(getParameterValue(symbol.maskedColor))
3722
- }));
3723
- }
3724
-
3725
- function deserializeImagePointSymbol(symbol) {
3726
- return new StaticImageSymbol.StaticImageSymbol(_extends({}, symbol, {
3727
- // @ts-ignore
3728
- angle: getParameterValue(symbol.angle),
3729
- // @ts-ignore
3730
- width: getParameterValue(symbol.width),
3731
- // @ts-ignore
3732
- height: getParameterValue(symbol.height),
3733
- // @ts-ignore
3734
- anchorPoint: deserializeAnchor(symbol.offset),
3735
- // @ts-ignore
3736
- source: deserializeBase64(symbol.image)
3737
- }));
3738
- }
3739
-
3740
- function deserializePolygonSymbol(symbol) {
3741
- if (isPolygonHasPatternBrush(symbol)) {
3742
- return new SGisImageFill(symbol);
3743
- }
3744
-
3745
- if (isPolygonHasHatchBrush(symbol)) {
3746
- return new SGisBrushFill(symbol);
3747
- }
3748
-
3749
- return new SGisPolygonSymbol(symbol);
3750
- }
3751
-
3752
- function deserializePolylineSymbol(symbol) {
3753
- return new SGisPolylineSymbol(symbol);
3754
- }
3755
-
3756
- function deserializePointSymbolParams(_ref2) {
3757
- let {
3758
- size,
3759
- offset,
3760
- strokeColor,
3761
- strokeWidth,
3762
- fillColor
3763
- } = _ref2;
3764
- return {
3765
- size: getParameterValue(size),
3766
- offset: deserializeAnchor(offset),
3767
- strokeWidth: getParameterValue(strokeWidth),
3768
- strokeColor: deserializeColor(getParameterValue(strokeColor)),
3769
- fillColor: deserializeColor(getParameterValue(fillColor))
3770
- };
3771
- }
3772
-
3773
- function deserializeBase64(base) {
3774
- return "data:image/png;base64," + base;
3775
- }
3776
-
3777
- function deserializeAnchor(offset) {
3778
- // @ts-ignore
3779
- return offset.map(getParameterValue);
3780
- }
3781
-
3782
- function deserializeColor(color$1) {
3783
- return color$1 ? new color.Color(color$1).toString() : null;
3784
- }
3785
-
3786
- const clampSymbol = (symbol, min, max) => {
3787
- if (isSGisImageSymbol(symbol)) {
3788
- symbol.width = clamp(symbol.width, min, max);
3789
- symbol.height = clamp(symbol.height, min, max);
3790
- } else if (isSGisPointSymbol(symbol)) {
3791
- symbol.size = clamp(symbol.size, min, max);
3792
- }
3793
-
3794
- return symbol;
3795
- };
3796
- function centerAlignSymbol(symbol) {
3797
- if (isSGisImageSymbol(symbol)) {
3798
- symbol.anchorPoint = [symbol.width / 2, symbol.height / 2];
3799
- } else if (isSGisPointSymbol(symbol)) {
3800
- symbol.offset = [0, 0];
3801
- }
3802
-
3803
- return symbol;
3804
- }
3805
- const adjustSymbol = (symbol, _ref) => {
3806
- let {
3807
- size
3808
- } = _ref;
3809
- return centerAlignSymbol(clampSymbol(symbol, 0, size));
3810
- };
3811
-
3812
- const useSvgSymbol = (symbol, skipOffset, isClassified) => {
3813
- const SVGWrapperRefElement = React.useRef(null);
3814
- const SVGContainer = React.useMemo(() => svg_js.SVG(), []);
3815
- const initSvg = React.useCallback(() => {
3816
- SVGContainer.addTo(SVGWrapperRefElement.current);
3817
- }, [SVGContainer]);
3818
- const getSvgData = React.useCallback(() => SVGContainer.svg(), [SVGContainer]);
3819
- const manipulateSvg = React.useCallback((_ref) => {
3820
- let {
3821
- svg,
3822
- bg,
3823
- newSymbol,
3824
- isClassified
3825
- } = _ref;
3826
- manipulateSvgSymbol({
3827
- SVGContainer,
3828
- symbol: newSymbol || symbol,
3829
- svg,
3830
- bg,
3831
- isClassified
3832
- });
3833
- }, [SVGContainer, symbol]);
3834
- const getUpdatedSvgSymbol = React.useCallback((field, value) => {
3835
- var _newSymbol$background;
3836
-
3837
- const {
3838
- data,
3839
- offset
3840
- } = symbol;
3841
- const newValue = value instanceof Color.Color ? value.toString('rgba') : value;
3842
-
3843
- const newSymbol = _extends({}, JSON.parse(JSON.stringify(symbol)), {
3844
- offset: skipOffset ? DEFAULT_SYMBOL_OFFSET : isSizeClassification(field) ? getOffsetParameterValue(offset) : offset
3845
- });
3846
-
3847
- if (field.indexOf('.') !== -1) {
3848
- var _newSymbol$parts$;
3849
-
3850
- const parts = field.split('.');
3851
-
3852
- if ((_newSymbol$parts$ = newSymbol[parts[0]]) != null && _newSymbol$parts$[parts[1]]) {
3853
- newSymbol[parts[0]][parts[1]] = newValue;
3854
- } else {
3855
- newSymbol[parts[0]] = _extends({}, newSymbol[parts[0]], {
3856
- [parts[1]]: newValue
3857
- }, parts[0] === 'background' ? {
3858
- type: newSymbol.background.type,
3859
- id: 'symbol-bg'
3860
- } : parts[0] === 'figure' ? {
3861
- id: 'symbol-figure'
3862
- } : {});
3863
- }
3864
- } else {
3865
- newSymbol[field] = newValue;
3866
- }
3867
-
3868
- manipulateSvg({
3869
- svg: getParameterValue(data),
3870
- newSymbol,
3871
- bg: (_newSymbol$background = newSymbol.background) == null ? void 0 : _newSymbol$background.type,
3872
- isClassified
3873
- });
3874
- return _extends({}, newSymbol, {
3875
- data: SVGContainer.svg()
3876
- });
3877
- }, [SVGContainer, manipulateSvg, skipOffset, symbol]);
3878
- return {
3879
- svgRef: SVGWrapperRefElement,
3880
- initSvg,
3881
- getSvgData,
3882
- manipulateSvg,
3883
- getUpdatedSvgSymbol
3884
- };
3885
- };
3886
-
3887
- var _templateObject$1, _templateObject2$1;
3888
- const SvgSymbolContainer = /*#__PURE__*/styled__default.div(_templateObject$1 || (_templateObject$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n"])));
3889
- const SvgSymbolLabel = /*#__PURE__*/styled__default.div(_templateObject2$1 || (_templateObject2$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n color: #fff;\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n line-height: 0;\n"])), (_ref) => {
3890
- let {
3891
- fontSettings
3892
- } = _ref;
3893
- return !!(fontSettings != null && fontSettings.fontFamily) && "font-family: " + fontSettings.fontFamily;
3894
- }, (_ref2) => {
3895
- let {
3896
- fontSettings
3897
- } = _ref2;
3898
- return !!(fontSettings != null && fontSettings.fontWeight) && "font-weight: " + fontSettings.fontWeight;
3899
- }, (_ref3) => {
3900
- let {
3901
- fontSettings
3902
- } = _ref3;
3903
- return !!(fontSettings != null && fontSettings.fontStyle) && "font-style: " + fontSettings.fontStyle;
3904
- }, (_ref4) => {
3905
- let {
3906
- fontSettings
3907
- } = _ref4;
3908
- return !!(fontSettings != null && fontSettings.fontColor) && "color: " + fontSettings.fontColor;
3909
- }, (_ref5) => {
3910
- let {
3911
- fontSettings
3912
- } = _ref5;
3913
- return !!(fontSettings != null && fontSettings.fontSize) && "font-size: " + (typeof fontSettings.fontSize === 'string' ? fontSettings.fontSize : fontSettings.fontSize + "px");
3914
- }, (_ref6) => {
3915
- let {
3916
- fontSettings
3917
- } = _ref6;
3918
- return !!(fontSettings != null && fontSettings.haloColor) && !!(fontSettings != null && fontSettings.haloWidth) && "-webkit-text-stroke: " + fontSettings.haloWidth + "px " + fontSettings.haloColor + ";";
3919
- });
3920
- const SvgSymbol = /*#__PURE__*/React.memo((_ref7) => {
3921
- let {
3922
- svg,
3923
- bg,
3924
- symbol,
3925
- title,
3926
- text,
3927
- fontSettings,
3928
- skipOffset,
3929
- isClassified,
3930
- onClick
3931
- } = _ref7;
3932
- const {
3933
- svgRef,
3934
- initSvg,
3935
- getSvgData,
3936
- manipulateSvg
3937
- } = useSvgSymbol(symbol, skipOffset, isClassified);
3938
- const onSelectSymbol = React.useCallback(() => {
3939
- onClick == null ? void 0 : onClick(getSvgData(), _extends({}, symbol, bg ? {
3940
- background: _extends({}, symbol.background, {
3941
- type: bg
3942
- })
3943
- } : {}));
3944
- }, [bg, getSvgData, onClick, symbol]);
3945
- const renderSymbol = React.useMemo(() => React__default.createElement(SymbolButton, {
3946
- ref: svgRef,
3947
- title: title,
3948
- onClick: onClick ? onSelectSymbol : undefined
3949
- }), [svgRef, title, onClick, onSelectSymbol]);
3950
- React.useEffect(() => {
3951
- initSvg();
3952
- }, [initSvg]);
3953
- React.useEffect(() => {
3954
- manipulateSvg({
3955
- svg,
3956
- bg,
3957
- newSymbol: symbol,
3958
- isClassified
3959
- });
3960
- }, [svg, symbol, bg, manipulateSvg, isClassified]);
3961
- return text ? React__default.createElement(SvgSymbolContainer, null, renderSymbol, React__default.createElement(SvgSymbolLabel, {
3962
- fontSettings: fontSettings
3963
- }, text), !!(fontSettings != null && fontSettings.haloColor) && !!(fontSettings != null && fontSettings.haloWidth) && React__default.createElement(SvgSymbolLabel, {
3964
- fontSettings: _extends({}, fontSettings, {
3965
- haloColor: undefined,
3966
- haloWidth: undefined
3967
- })
3968
- }, text)) : renderSymbol;
3969
- });
3970
-
3971
- const ClusterSymbolPreview = (_ref) => {
3972
- var _symbol$fillColor$val, _symbol$labelSymbol;
3973
-
3974
- let {
3975
- symbol,
3976
- index,
3977
- size = 56,
3978
- fontSize = '1.25rem'
3979
- } = _ref;
3980
- const isClassified = isParameterByAttribute(symbol.fillColor);
3981
- const isClassifiedValue = isClassified && index !== undefined;
3982
- const fillColor = isClassifiedValue ? ((_symbol$fillColor$val = symbol.fillColor.values[index]) == null ? void 0 : _symbol$fillColor$val.value) || symbol.fillColor.defaultValue : symbol.fillColor;
3983
- const strokeColor = isClassified ? fillColor : symbol.strokeColor;
3984
- const svgSymbol = {
3985
- type: 'svgPointSymbol',
3986
- size,
3987
- offset: [0, 0],
3988
- angle: 0,
3989
- background: {
3990
- id: 'symbol-bg',
3991
- fillColor,
3992
- strokeColor,
3993
- strokeWidth: 6,
3994
- type: 'circle'
3995
- }
3996
- };
3997
- return React__default.createElement(SvgSymbol, {
3998
- svg: DEFAULT_CLUSTER_SVG,
3999
- symbol: svgSymbol,
4000
- isClassified: isClassified,
4001
- text: '99',
4002
- fontSettings: _extends({}, symbol.labelSymbol, {
4003
- fontSize: fontSize || ((_symbol$labelSymbol = symbol.labelSymbol) == null ? void 0 : _symbol$labelSymbol.fontSize)
4004
- })
4005
- });
4006
- };
4007
-
4008
- const SymbolByType = (_ref) => {
4009
- let {
4010
- type,
4011
- symbol,
4012
- size,
4013
- svg,
4014
- skipOffset
4015
- } = _ref;
4016
- const defaultSymbol = React.useMemo(() => React__default.createElement(Symbol, {
4017
- symbol: symbol,
4018
- size: size
4019
- }), [symbol, size]);
4020
-
4021
- switch (type) {
4022
- case 'svgPointSymbol':
4023
- return svg ? React__default.createElement(SvgSymbol, {
4024
- svg: svg,
4025
- size: size,
4026
- skipOffset: skipOffset,
4027
- symbol: serializeSvgPointSymbol(symbol)
4028
- }) : defaultSymbol;
4029
-
4030
- default:
4031
- return defaultSymbol;
4032
- }
4033
- };
4034
-
4035
- const LegendSymbolRenderer = /*#__PURE__*/React.memo((_ref) => {
4036
- let {
4037
- symbol,
4038
- index
4039
- } = _ref;
4040
-
4041
- if (isClusterSymbol(symbol)) {
4042
- return React__default.createElement(ClusterLegendContainer, null, React__default.createElement(ClusterSymbolPreview, {
4043
- symbol: symbol,
4044
- index: index
4045
- }));
4046
- }
4047
-
4048
- return React__default.createElement(SymbolByType, {
4049
- symbol: deserializeSymbol(symbol),
4050
- size: getLegendSymbolSize(symbol) || DEFAULT_LEGEND_SYMBOL_SIZE,
4051
- type: symbol.type,
4052
- svg: getParameterValue(symbol.data),
4053
- skipOffset: true
4054
- });
4055
- });
4056
-
4057
- const LegendHeaderButtons = (_ref) => {
4058
- let {
4059
- layerName,
4060
- hasHiddenLegends,
4061
- isShared,
4062
- clearHiddenLegends,
4063
- goToClassification
4064
- } = _ref;
4065
- return React__default.createElement(React__default.Fragment, null, !!goToClassification && !isShared && React__default.createElement(LegendHeaderButton, null, React__default.createElement(icons.IconButton, {
4066
- onClick: goToClassification
4067
- }, React__default.createElement(icons.EverCloudClassificationIcon, null))), !!clearHiddenLegends && React__default.createElement(LegendHeaderButton, null, React__default.createElement(icons.IconButton, {
4068
- disabled: !hasHiddenLegends,
4069
- onClick: () => clearHiddenLegends == null ? void 0 : clearHiddenLegends(layerName)
4070
- }, React__default.createElement(icons.EverCloudRefreshIcon, null))));
4071
- };
4072
-
4073
- const getConditionAttribute = (attributes, condition) => {
4074
- if (!condition) return null;
4075
- const attributeName = getAttributeNameFromCondition(condition);
4076
- let attribute = attributes.find((_ref) => {
4077
- let {
4078
- name
4079
- } = _ref;
4080
- return name === attributeName;
4081
- });
4082
-
4083
- if (!attribute) {
4084
- if (attributeName === 'count') {
4085
- attribute = {
4086
- name: 'count',
4087
- alias: 'Количество',
4088
- type: api.AttributeType.Int32
4089
- };
4090
- } else {
4091
- return null;
4092
- }
4093
- }
4094
-
4095
- return attribute;
4096
- };
4097
-
4098
- const isHiddenLegend = (hiddenCondition, hiddenLegends) => !!(hiddenLegends != null && hiddenLegends.includes(hiddenCondition));
4099
-
4100
- const renderColumn = (column, index) => {
4101
- const dateTime = column.split(' ');
4102
- return React__default.createElement(React.Fragment, {
4103
- key: index
4104
- }, React__default.createElement(ItemText, {
4105
- title: column
4106
- }, dateTime[0], React__default.createElement(MapLegendDescription, null, dateTime[1])), index === 0 && React__default.createElement(ItemSeparator, null));
4107
- };
4108
-
4109
- const getLegendText = (_ref) => {
4110
- let {
4111
- title,
4112
- index,
4113
- isDate
4114
- } = _ref;
4115
-
4116
- if (!title) {
4117
- return React__default.createElement(ItemText, null, i18n.t("other", {
4118
- ns: "style"
4119
- }));
4120
- }
4121
-
4122
- const columns = title == null ? void 0 : title.split(' - ');
4123
- const isSingleColumn = (columns == null ? void 0 : columns.length) === 1;
4124
-
4125
- if (!isDate || index && isSingleColumn) {
4126
- return React__default.createElement(ItemText, {
4127
- title: title
4128
- }, title);
4129
- }
4130
-
4131
- if (!index && isSingleColumn) {
4132
- return React__default.createElement(React__default.Fragment, null, React__default.createElement(ItemText, {
4133
- title: "\u221E"
4134
- }, "\u221E"), React__default.createElement(ItemSeparator, null), renderColumn(title));
4135
- }
4136
-
4137
- return React__default.createElement(React__default.Fragment, null, columns.map(renderColumn));
4138
- };
4139
-
4140
- const getLayerAttributes = layerDefinition => {
4141
- const attributes = layerDefinition && layerDefinition.attributes || {};
4142
- return Object.entries(attributes).map((_ref) => {
4143
- let [name, definition] = _ref;
4144
- return _extends({
4145
- name
4146
- }, definition);
4147
- });
4148
- };
4149
-
4150
- const LegendChildren = (_ref) => {
4151
- var _layerInfo$style, _layerInfo$style$chil;
4152
-
4153
- let {
4154
- layerInfo,
4155
- hiddenLegends,
4156
- toggleHiddenLegend,
4157
- clearHiddenLegends,
4158
- formatValue
4159
- } = _ref;
4160
- if (!(layerInfo != null && (_layerInfo$style = layerInfo.style) != null && (_layerInfo$style$chil = _layerInfo$style.children) != null && _layerInfo$style$chil.length)) return null;
4161
- const attributes = getLayerAttributes(layerInfo.layerDefinition);
4162
- return React__default.createElement(MapLegendContainer, null, layerInfo.style.children.map((paramValue, index) => {
4163
- var _getConditionAttribut;
4164
-
4165
- const attribute = getConditionAttribute(attributes, paramValue.condition);
4166
- if (!attribute) return null;
4167
- const hiddenCondition = createHiddenCondition(attribute.name, attribute.type, getClassificationValue(paramValue.symbol, paramValue.title, new ClassificationCondition(paramValue.condition)));
4168
- const legendText = getLegendText({
4169
- title: isRangeCondition(paramValue.condition) ? createValueTitleFromCondition(paramValue, attribute, formatValue, index) : getTitleFromCondition({
4170
- condition: paramValue.condition,
4171
- attribute,
4172
- formatValue
4173
- }),
4174
- index,
4175
- isDate: ((_getConditionAttribut = getConditionAttribute(attributes, paramValue.condition)) == null ? void 0 : _getConditionAttribut.type) === 'DateTime'
4176
- });
4177
- return React__default.createElement(ClassifiedItem, {
4178
- key: index,
4179
- isHidden: isHiddenLegend(hiddenCondition, hiddenLegends == null ? void 0 : hiddenLegends[layerInfo.name]),
4180
- onClick: () => toggleHiddenLegend == null ? void 0 : toggleHiddenLegend(layerInfo.name, hiddenCondition)
4181
- }, React__default.createElement(SymbolContainer, null, React__default.createElement(LegendSymbolRenderer, {
4182
- symbol: paramValue.symbol
4183
- })), legendText, React__default.createElement(LegendHeaderButtons, {
4184
- layerName: layerInfo.name,
4185
- clearHiddenLegends: clearHiddenLegends
4186
- }));
4187
- }));
4188
- };
4189
-
4190
- const LegendParameterDescription = (_ref) => {
4191
- let {
4192
- parameter,
4193
- index
4194
- } = _ref;
4195
- const {
4196
- t
4197
- } = reactI18next.useTranslation("style");
4198
- const isSize = isParameterType("size", parameter);
4199
- const isStrokeWidth = isParameterType(["strokeWidth", "stroke.width"], parameter);
4200
- const isStrokeColor = isParameterType(["strokeColor", "stroke.color"], parameter);
4201
- return React__default.createElement(MapLegendDescriptionContainer, null, isStrokeWidth || isStrokeColor ? isStrokeWidth ? t("strokeWidth") : t("strokeColor") : isSize ? t("symbolSize") : t("symbolColor"), !!index && React__default.createElement(MapLegendBadge, null, index));
4202
- };
4203
-
4204
- const getValueFromLegendTitle = (title, minOrMax) => {
4205
- if (title.includes(" - ")) {
4206
- const result = title == null ? void 0 : title.split(" - ");
4207
- return minOrMax === "min" ? result == null ? void 0 : result[0] : result == null ? void 0 : result[1];
4208
- }
4209
-
4210
- if (title.includes(",")) {
4211
- const result = title == null ? void 0 : title.split(",");
4212
- return result.join(", ");
4213
- }
4214
-
4215
- return title.split(" ").find(isNumeric) || title || "";
4216
- };
4217
-
4218
- const MinimizedLegend = (_ref) => {
4219
- var _currentValues$, _currentValues, _currentValues$2, _currentValues2;
4220
-
4221
- let {
4222
- innerRef,
4223
- isShown,
4224
- values,
4225
- title,
4226
- parameter,
4227
- hiddenLegends
4228
- } = _ref;
4229
- const {
4230
- t
4231
- } = reactI18next.useTranslation("style");
4232
- const currentValues = [...values];
4233
- const other = currentValues.pop();
4234
- const isSize = isParameterType("size", parameter);
4235
- const isStrokeWidth = isParameterType(["strokeWidth", "stroke.width"], parameter);
4236
- const titleMax = getValueFromLegendTitle((_currentValues$ = currentValues[0]) == null ? void 0 : _currentValues$.title, "max");
4237
- const titleMin = getValueFromLegendTitle((_currentValues = currentValues[currentValues.length - 1]) == null ? void 0 : _currentValues.title, "min");
4238
- const checkIsHidden = React.useCallback(hiddenCondition => hiddenCondition ? hiddenLegends == null ? void 0 : hiddenLegends.some(condition => hiddenCondition.includes(condition)) : false, [hiddenLegends]);
4239
- return React__default.createElement(MinimizedLegendContainer, {
4240
- ref: innerRef,
4241
- isShown: isShown
4242
- }, !!title && React__default.createElement(MapLegendValueDescr, null, title), isSize ? React__default.createElement(React__default.Fragment, null, React__default.createElement(SizeMinimizedLegend, null, React__default.createElement(SizeMinimizedLegendSymbol, null, React__default.createElement(MapLegendItems, {
4243
- parameter: parameter,
4244
- isSize: true
4245
- }, currentValues.map((value, index) => React__default.createElement(MapLegendItem, {
4246
- key: "" + value.title + index,
4247
- title: value.title,
4248
- value: value.parameterValue,
4249
- parameter: parameter,
4250
- isHidden: checkIsHidden(value.hiddenCondition)
4251
- })))), React__default.createElement(SizeMinimizedLegendLabel, null, React__default.createElement(SizeMinimizedLegendDown, null, (_currentValues$2 = currentValues[0]) == null ? void 0 : _currentValues$2.title), React__default.createElement(SizeMinimizedLegendUp, null, (_currentValues2 = currentValues[currentValues.length - 1]) == null ? void 0 : _currentValues2.title))), React__default.createElement(SizeMinimizedLegend, null, React__default.createElement(SizeMinimizedLegendSymbol, null, React__default.createElement(MapLegendItems, {
4252
- parameter: parameter,
4253
- isSize: true
4254
- }, React__default.createElement(MapLegendOther, {
4255
- title: t("other"),
4256
- value: other == null ? void 0 : other.parameterValue,
4257
- parameter: parameter,
4258
- isHidden: checkIsHidden(other == null ? void 0 : other.hiddenCondition)
4259
- }))), React__default.createElement(SizeMinimizedLegendLabel, null, React__default.createElement(SizeMinimizedLegendUp, null, t("other"))))) : isStrokeWidth ? React__default.createElement(MapLegendItems, {
4260
- parameter: parameter,
4261
- isStrokeWidth: true
4262
- }, currentValues.map((value, index) => React__default.createElement(MapLegendItem, {
4263
- key: "" + value.title + index,
4264
- title: value.title,
4265
- value: value.parameterValue,
4266
- parameter: parameter,
4267
- isHidden: checkIsHidden(value.hiddenCondition)
4268
- }, (!index || index === currentValues.length - 1) && value.title)), React__default.createElement(MapLegendOther, {
4269
- title: t("other"),
4270
- value: other == null ? void 0 : other.parameterValue,
4271
- parameter: parameter,
4272
- isHidden: checkIsHidden(other == null ? void 0 : other.hiddenCondition)
4273
- }, t("other"))) : React__default.createElement(MapLegendItems, {
4274
- parameter: parameter
4275
- }, React__default.createElement(MapLegendItemsContainer, null, currentValues.map((value, index) => React__default.createElement(MapLegendItem, {
4276
- key: "" + value.title + index,
4277
- title: value.title,
4278
- value: value.parameterValue,
4279
- parameter: parameter,
4280
- isHidden: checkIsHidden(value.hiddenCondition)
4281
- }))), React__default.createElement(MapLegendOther, {
4282
- title: t("other"),
4283
- value: other == null ? void 0 : other.parameterValue,
4284
- parameter: parameter,
4285
- isHidden: checkIsHidden(other == null ? void 0 : other.hiddenCondition)
4286
- })), typeof (other == null ? void 0 : other.parameterValue) === "string" && (titleMax || titleMin) && React__default.createElement(MapLegendValues, null, React__default.createElement(MapLegendValuesRange, null, React__default.createElement("div", null, titleMax), React__default.createElement("div", null, titleMin)), React__default.createElement(MapLegendValuesOther, null, "-")));
4287
- };
4288
-
4289
- const MaximizedLegend = (_ref) => {
4290
- let {
4291
- innerRef,
4292
- isShown,
4293
- layerName,
4294
- symbol: sectionSymbol,
4295
- parameter,
4296
- values,
4297
- index: sectionIndex,
4298
- attributeType,
4299
- hiddenLegends,
4300
- toggleHiddenLegend
4301
- } = _ref;
4302
- const isDate = attributeType === 'DateTime';
4303
- const isSize = isParameterType('size', parameter);
4304
- const isStrokeWidth = isParameterType(['strokeWidth', 'stroke.width'], parameter);
4305
- const isStrokeColor = isParameterType(['strokeColor', 'stroke.color'], parameter);
4306
- const parameterValue = React.useMemo(() => get(sectionSymbol, parameter), [sectionSymbol, parameter]);
4307
- const renderLegend = React.useCallback((_ref2, index) => {
4308
- var _parameterValue$value;
4309
-
4310
- let {
4311
- symbol,
4312
- title,
4313
- hiddenCondition
4314
- } = _ref2;
4315
- if (!symbol) return null;
4316
- const isClusterFillColor$1 = isClusterFillColor(symbol, parameter);
4317
- const value = getParameterValue(parameterValue == null ? void 0 : (_parameterValue$value = parameterValue.values[index]) == null ? void 0 : _parameterValue$value.value) || (parameterValue == null ? void 0 : parameterValue.defaultValue);
4318
- return React__default.createElement(ClassifiedItem, {
4319
- key: sectionIndex + title + index,
4320
- isHidden: isHiddenLegend(hiddenCondition, hiddenLegends),
4321
- isClusterFillColor: isClusterFillColor$1,
4322
- onClick: () => toggleHiddenLegend == null ? void 0 : toggleHiddenLegend(layerName, hiddenCondition)
4323
- }, isSize || isStrokeWidth || isStrokeColor ? React__default.createElement(MapLegendItems, {
4324
- parameter: parameter,
4325
- isSize: isSize,
4326
- isStrokeWidth: isStrokeWidth,
4327
- isStrokeColor: isStrokeColor,
4328
- isSingle: true
4329
- }, React__default.createElement(MapLegendItem, {
4330
- key: "" + title + index,
4331
- title: title,
4332
- value: value,
4333
- parameter: parameter
4334
- })) : React__default.createElement(SymbolContainer, null, React__default.createElement(LegendSymbolRenderer, {
4335
- index: index,
4336
- symbol: isClusterFillColor$1 ? sectionSymbol : getExtractedSymbol(symbol, true)
4337
- })), getLegendText({
4338
- title,
4339
- index,
4340
- isDate
4341
- }));
4342
- }, [parameter, sectionIndex, hiddenLegends, isSize, isStrokeWidth, isStrokeColor, parameterValue, sectionSymbol, isDate, toggleHiddenLegend, layerName]);
4343
- return React__default.createElement(MaximizedLegendContainer, {
4344
- ref: innerRef,
4345
- isShown: isShown
4346
- }, values.map(renderLegend));
4347
- };
4348
-
4349
- function useCanvas() {
4350
- const canvas = React.useRef(null);
4351
- const ref = React.useCallback(node => {
4352
- if (node !== null) {
4353
- canvas.current = new Canvas.Canvas(node);
4354
- } else {
4355
- canvas.current = null;
4356
- }
4357
- }, []);
4358
- return {
4359
- canvas,
4360
- ref
4361
- };
4362
- }
4363
-
4364
- function useMount(_ref) {
4365
- let {
4366
- onMount,
4367
- onUnmount
4368
- } = _ref;
4369
- React.useEffect(() => {
4370
- onMount && onMount();
4371
- return onUnmount; // eslint-disable-next-line react-hooks/exhaustive-deps
4372
- }, []);
4373
- }
4374
-
4375
- function useNode() {
4376
- const [node, onSetNode] = React.useState(null);
4377
- const ref = React.useCallback(onSetNode, [onSetNode]);
4378
- return [ref, node];
4379
- }
4380
-
4381
- const DEFAULT_SYMBOL_SIZE$1 = 26;
4382
- function useSymbol(_ref, canvasRef) {
4383
- let {
4384
- symbol,
4385
- size = DEFAULT_SYMBOL_SIZE$1,
4386
- render = getSymbolRenders,
4387
- maxWidth
4388
- } = _ref;
4389
- React.useEffect(() => {
4390
- if (canvasRef.current !== null && symbol !== undefined) {
4391
- const canvas = canvasRef.current;
4392
- setCanvasSize(canvas, size, maxWidth);
4393
- render(symbol, size).then(renders => {
4394
- renderSymbolToCanvas(renders, canvas);
4395
- });
4396
- } // eslint-disable-next-line react-hooks/exhaustive-deps
4397
-
4398
- }, [symbol, size, maxWidth]);
4399
- }
4400
-
4401
- function setCanvasSize(canvas, size, maxWidth) {
4402
- canvas.node.height = size;
4403
- canvas.node.width = maxWidth ? Math.min(size, maxWidth) : size;
4404
- }
4405
-
4406
- const useToggle = initial => {
4407
- const [state, setState] = React.useState(initial !== undefined ? initial : false);
4408
- const toggle = React.useCallback(() => setState(!state), [state]);
4409
- return [state, toggle, setState];
4410
- };
4411
-
4412
- const LegendSection = (_ref) => {
4413
- var _hiddenLegends$layerN, _hiddenLegends$layerN2;
4414
-
4415
- let {
4416
- layerName,
4417
- symbol,
4418
- parameter,
4419
- parameters,
4420
- classified,
4421
- hiddenLegends,
4422
- toggleHiddenLegend,
4423
- clearHiddenLegends,
4424
- goToClassification,
4425
- attribute,
4426
- formatValue,
4427
- index,
4428
- count,
4429
- isShared
4430
- } = _ref;
4431
- const {
4432
- t
4433
- } = reactI18next.useTranslation("style");
4434
- const [isExpanded, toggleExpanded] = useToggle();
4435
- const [maxRef, maxNode] = useNode();
4436
- const [minRef, minNode] = useNode();
4437
- if (!layerName || !attribute) return null;
4438
- const currentSymbol = isCombinedPolylineSymbol(symbol) ? symbol.values[index] : symbol;
4439
- return React__default.createElement(MapLegendSectionContainer, {
4440
- hasHiddenLegends: !!(hiddenLegends != null && (_hiddenLegends$layerN = hiddenLegends[layerName]) != null && _hiddenLegends$layerN.length)
4441
- }, React__default.createElement(MapLegendHeader, null, attribute.alias || attribute.name, React__default.createElement(LegendHeaderButtons, {
4442
- layerName: layerName,
4443
- hasHiddenLegends: !!(hiddenLegends != null && (_hiddenLegends$layerN2 = hiddenLegends[layerName]) != null && _hiddenLegends$layerN2.length),
4444
- clearHiddenLegends: clearHiddenLegends,
4445
- goToClassification: goToClassification,
4446
- isShared: isShared
4447
- })), React__default.createElement(LegendParameterDescription, {
4448
- parameter: parameter,
4449
- index: count && index !== undefined ? count - index : 0
4450
- }), React__default.createElement(MapLegendSectionItems, {
4451
- minHeight: minNode == null ? void 0 : minNode.offsetHeight,
4452
- maxHeight: maxNode == null ? void 0 : maxNode.offsetHeight,
4453
- isExpanded: isExpanded
4454
- }, React__default.createElement(MaximizedLegend, {
4455
- innerRef: maxRef,
4456
- isShown: isExpanded,
4457
- layerName: layerName,
4458
- symbol: currentSymbol,
4459
- hiddenLegends: hiddenLegends == null ? void 0 : hiddenLegends[layerName],
4460
- toggleHiddenLegend: toggleHiddenLegend,
4461
- parameter: parameter,
4462
- attributeType: attribute.type,
4463
- index: index,
4464
- values: getMaximizedLegendValues(attribute, parameter, parameters, classified, currentSymbol, formatValue, index, t("other"))
4465
- }), React__default.createElement(MinimizedLegend, {
4466
- innerRef: minRef,
4467
- isShown: !isExpanded,
4468
- hiddenLegends: hiddenLegends == null ? void 0 : hiddenLegends[layerName],
4469
- parameter: parameter,
4470
- values: getMinimizedLegendValues(attribute, classified, formatValue, index, t("other"))
4471
- })), React__default.createElement(MapLegendExpandButton, {
4472
- onClick: toggleExpanded
4473
- }, isExpanded ? t('hide') : t('show')));
4474
- };
4475
-
4476
- const _excluded$1 = ["layerInfo", "formatValue", "hiddenLegends", "toggleHiddenLegend", "clearHiddenLegends", "goToClassification"];
4477
- const Legend = /*#__PURE__*/React.memo((_ref) => {
4478
- var _layerInfo$style, _layerInfo$style$chil;
4479
-
4480
- let {
4481
- layerInfo,
4482
- formatValue,
4483
- hiddenLegends,
4484
- toggleHiddenLegend,
4485
- clearHiddenLegends,
4486
- goToClassification
4487
- } = _ref,
4488
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
4489
-
4490
- if (!layerInfo) return null;
4491
-
4492
- if ((_layerInfo$style = layerInfo.style) != null && (_layerInfo$style$chil = _layerInfo$style.children) != null && _layerInfo$style$chil.length) {
4493
- return React__default.createElement(LegendChildren, {
4494
- layerInfo: layerInfo,
4495
- formatValue: formatValue,
4496
- hiddenLegends: hiddenLegends,
4497
- toggleHiddenLegend: toggleHiddenLegend,
4498
- clearHiddenLegends: clearHiddenLegends,
4499
- goToClassification: goToClassification
4500
- });
4501
- }
4502
-
4503
- const attributes = getLayerAttributes(layerInfo.layerDefinition);
4504
- const renderItems = React.useMemo(() => {
4505
- var _layerInfo$style2, _layerInfo$style3;
4506
-
4507
- const parameters = SYMBOL_CLASSIFICATION[layerInfo.geometryType];
4508
- const props = {
4509
- layerName: layerInfo.name,
4510
- symbol: (_layerInfo$style2 = layerInfo.style) == null ? void 0 : _layerInfo$style2.symbol,
4511
- parameters: parameters,
4512
- formatValue: formatValue,
4513
- hiddenLegends: hiddenLegends,
4514
- toggleHiddenLegend: toggleHiddenLegend,
4515
- clearHiddenLegends: clearHiddenLegends,
4516
- goToClassification: goToClassification
4517
- };
4518
-
4519
- if ((_layerInfo$style3 = layerInfo.style) != null && _layerInfo$style3.symbol && isCombinedPolylineSymbol(layerInfo.style.symbol)) {
4520
- var _layerInfo$style4, _layerInfo$style4$sym, _layerInfo$style4$sym2;
4521
-
4522
- const values = (_layerInfo$style4 = layerInfo.style) == null ? void 0 : (_layerInfo$style4$sym = _layerInfo$style4.symbol) == null ? void 0 : (_layerInfo$style4$sym2 = _layerInfo$style4$sym.values) == null ? void 0 : _layerInfo$style4$sym2.reduce((result, symbol, index) => {
4523
- return [classifyParamsReduce(symbol, parameters, index), ...result];
4524
- }, []);
4525
- return React__default.createElement(React__default.Fragment, null, values == null ? void 0 : values.map((value, index) => Object.keys(value).map((param, keyIndex) => {
4526
- var _item$values$;
4527
-
4528
- const item = value[param];
4529
- return React__default.createElement(LegendSection, Object.assign({
4530
- key: [keyIndex, index].join("-"),
4531
- index: item == null ? void 0 : item.index,
4532
- count: values == null ? void 0 : values.length,
4533
- attribute: getConditionAttribute(attributes, item == null ? void 0 : (_item$values$ = item.values[0]) == null ? void 0 : _item$values$.condition),
4534
- parameter: param,
4535
- classified: item
4536
- }, props, rest));
4537
- })));
4538
- }
4539
-
4540
- const classified = getClassified(layerInfo);
4541
- if (!classified) return null;
4542
- return React__default.createElement(React__default.Fragment, null, Object.keys(classified).map((param, keyIndex) => {
4543
- var _item$values$2;
4544
-
4545
- const item = classified[param];
4546
- return React__default.createElement(LegendSection, Object.assign({
4547
- key: [keyIndex, item.index].join("-"),
4548
- index: item.index,
4549
- attribute: getConditionAttribute(attributes, item == null ? void 0 : (_item$values$2 = item.values[0]) == null ? void 0 : _item$values$2.condition),
4550
- parameter: param,
4551
- classified: item
4552
- }, props, rest));
4553
- }));
4554
- }, [layerInfo, formatValue, hiddenLegends, toggleHiddenLegend, clearHiddenLegends, goToClassification]);
4555
- return React__default.createElement(MapLegendContainer, null, renderItems);
4556
- });
4557
-
4558
- const Symbol = (_ref) => {
4559
- let {
4560
- symbol,
4561
- size,
4562
- render
4563
- } = _ref;
4564
- const {
4565
- canvas,
4566
- ref
4567
- } = useCanvas();
4568
- useSymbol({
4569
- symbol,
4570
- size,
4571
- render
4572
- }, canvas);
4573
- return React__default.createElement("canvas", {
4574
- ref: ref
4575
- });
4576
- };
4577
-
4578
- var _templateObject$2, _templateObject2$2;
4579
- const CompoundIcon = /*#__PURE__*/styled__default.div(_templateObject$2 || (_templateObject$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background: ", ";\n height: 32px;\n width: 32px;\n"])), (_ref) => {
4580
- let {
4581
- geometryType,
4582
- icons
4583
- } = _ref;
4584
- return "url(" + icons[geometryType] + ") center center / " + (geometryType === api.GeometryType.Polyline ? '2rem 1.3rem' : 'auto 1rem') + " no-repeat";
4585
- });
4586
- const ClusterSymbol = /*#__PURE__*/styled__default.div(_templateObject2$2 || (_templateObject2$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n width: 32px;\n height: 32px;\n\n :before {\n content: \"\";\n position: absolute;\n top: 0;\n left: 0;\n width: inherit;\n height: inherit;\n background-color: ", ";\n border-radius: 50%;\n opacity: 0.28;\n }\n \n :after {\n content: \"99\";\n position: absolute;\n top: 4px;\n left: 4px;\n display: flex;\n justify-content: center;\n align-items: center;\n width: 24px;\n height: 24px;\n background-color: ", ";\n border-radius: 50%;\n color: white;\n font-size: 0.75rem;\n line-height: 1;\n }\n"])), (_ref2) => {
4587
- let {
4588
- color
4589
- } = _ref2;
4590
- return color;
4591
- }, (_ref3) => {
4592
- let {
4593
- color
4594
- } = _ref3;
4595
- return color;
4596
- });
4597
-
4598
- const MAX_SIZE = 32;
4599
- const StyleSymbol = (_ref) => {
4600
- let {
4601
- symbol,
4602
- size = MAX_SIZE,
4603
- children
4604
- } = _ref;
4605
-
4606
- if (children) {
4607
- return React__default.createElement(React__default.Fragment, null, children);
4608
- }
4609
-
4610
- let sGisSymbol = null;
4611
-
4612
- try {
4613
- sGisSymbol = deserializeSymbol(symbol);
4614
- } catch (e) {// TODO generate Error symbol
4615
- }
4616
-
4617
- if (!sGisSymbol) {
4618
- return null;
4619
- }
4620
-
4621
- if (isSGisClusterSymbol(symbol)) {
4622
- var _sGisSymbol$backgroun, _sGisSymbol$figure;
4623
-
4624
- const color = getParameterValue((_sGisSymbol$backgroun = sGisSymbol.background) == null ? void 0 : _sGisSymbol$backgroun.fillColor) || getParameterValue((_sGisSymbol$figure = sGisSymbol.figure) == null ? void 0 : _sGisSymbol$figure.fillColor) || "rgb(0, 170, 255)";
4625
- return React__default.createElement(ClusterSymbol, {
4626
- color: color
4627
- });
4628
- }
4629
-
4630
- return React__default.createElement(Symbol, {
4631
- symbol: adjustSymbol(sGisSymbol, {
4632
- size: size - 1
4633
- }),
4634
- size: size
4635
- });
4636
- };
4637
-
4638
- const LegendContext = /*#__PURE__*/React.createContext(null);
4639
- const LegendProvider = (_ref) => {
4640
- let {
4641
- symbol,
4642
- children
4643
- } = _ref;
4644
- return React__default.createElement(LegendContext.Provider, {
4645
- value: symbol || null
4646
- }, children);
4647
- };
4648
- const useLegendContext = () => React.useContext(LegendContext);
4649
-
4650
- const polygonCircleFromPoint = (center, diameter) => {
4651
- const coordinates = [];
4652
- const radius = diameter / 2;
4653
- const endAngle = Math.PI * 2;
4654
- const step = Math.max(Math.PI / 2 / radius, endAngle / 128);
4655
- let start = 0;
4656
- let end = endAngle;
4657
-
4658
- for (let ang = start; ang < end; ang += step) {
4659
- coordinates.push([Math.cos(ang) * radius + center[0], Math.sin(ang) * radius + center[1]]);
4660
- }
4661
-
4662
- return [coordinates];
4663
- };
4664
-
4665
- exports.ArrowLineMiterRender = ArrowLineMiterRender;
4666
- exports.BASE_OPERATORS = BASE_OPERATORS;
4667
- exports.BETWEEN_OPERATORS = BETWEEN_OPERATORS;
4668
- exports.CONTAINS_OPERATORS = CONTAINS_OPERATORS;
4669
- exports.CircleLineMiterRender = CircleLineMiterRender;
4670
- exports.ClassificationCondition = ClassificationCondition;
4671
- exports.ClassificationManager = ClassificationManager;
4672
- exports.ClassifiedItem = ClassifiedItem;
4673
- exports.ClusterLegendContainer = ClusterLegendContainer;
4674
- exports.ClusterSymbol = ClusterSymbol;
4675
- exports.ClusterSymbolPreview = ClusterSymbolPreview;
4676
- exports.CompoundIcon = CompoundIcon;
4677
- exports.DEFAULT_CLUSTER_SVG = DEFAULT_CLUSTER_SVG;
4678
- exports.DEFAULT_ID_ATTRIBUTE_NAME = DEFAULT_ID_ATTRIBUTE_NAME;
4679
- exports.DEFAULT_LEGEND_SIZES = DEFAULT_LEGEND_SIZES;
4680
- exports.DEFAULT_LEGEND_STYLES = DEFAULT_LEGEND_STYLES;
4681
- exports.DEFAULT_LEGEND_SYMBOL_SIZE = DEFAULT_LEGEND_SYMBOL_SIZE;
4682
- exports.DEFAULT_PARAMETER_INFO = DEFAULT_PARAMETER_INFO;
4683
- exports.DEFAULT_SYMBOL_FILL_COLOR = DEFAULT_SYMBOL_FILL_COLOR;
4684
- exports.DEFAULT_SYMBOL_OFFSET = DEFAULT_SYMBOL_OFFSET;
4685
- exports.DEFAULT_SYMBOL_SIZE = DEFAULT_SYMBOL_SIZE;
4686
- exports.DEFAULT_SYMBOL_STROKE_COLOR = DEFAULT_SYMBOL_STROKE_COLOR;
4687
- exports.DEFAULT_SYMBOL_WITH_BG_SIZE = DEFAULT_SYMBOL_WITH_BG_SIZE;
4688
- exports.ENDS_WITH_OPERATORS = ENDS_WITH_OPERATORS;
4689
- exports.EXTRA_BORDER_SIZE = EXTRA_BORDER_SIZE;
4690
- exports.EvergisStyle = EvergisStyle;
4691
- exports.FILLED_OPERATORS = FILLED_OPERATORS;
4692
- exports.GEOMETRY_ATTRIBUTE = GEOMETRY_ATTRIBUTE;
4693
- exports.ItemSeparator = ItemSeparator;
4694
- exports.ItemText = ItemText;
4695
- exports.Legend = Legend;
4696
- exports.LegendChildren = LegendChildren;
4697
- exports.LegendHeaderButton = LegendHeaderButton;
4698
- exports.LegendParameterDescription = LegendParameterDescription;
4699
- exports.LegendProvider = LegendProvider;
4700
- exports.LegendSection = LegendSection;
4701
- exports.LegendSymbolRenderer = LegendSymbolRenderer;
4702
- exports.LineMiterRender = LineMiterRender;
4703
- exports.MapLegendBadge = MapLegendBadge;
4704
- exports.MapLegendContainer = MapLegendContainer;
4705
- exports.MapLegendDescription = MapLegendDescription;
4706
- exports.MapLegendDescriptionContainer = MapLegendDescriptionContainer;
4707
- exports.MapLegendExpandButton = MapLegendExpandButton;
4708
- exports.MapLegendHeader = MapLegendHeader;
4709
- exports.MapLegendItem = MapLegendItem;
4710
- exports.MapLegendItems = MapLegendItems;
4711
- exports.MapLegendItemsContainer = MapLegendItemsContainer;
4712
- exports.MapLegendOther = MapLegendOther;
4713
- exports.MapLegendSectionContainer = MapLegendSectionContainer;
4714
- exports.MapLegendSectionItems = MapLegendSectionItems;
4715
- exports.MapLegendValueDescr = MapLegendValueDescr;
4716
- exports.MapLegendValues = MapLegendValues;
4717
- exports.MapLegendValuesOther = MapLegendValuesOther;
4718
- exports.MapLegendValuesRange = MapLegendValuesRange;
4719
- exports.MaximizedLegend = MaximizedLegend;
4720
- exports.MaximizedLegendContainer = MaximizedLegendContainer;
4721
- exports.MinimizedLegend = MinimizedLegend;
4722
- exports.MinimizedLegendContainer = MinimizedLegendContainer;
4723
55
  exports.NO_CONTENT_VALUE = NO_CONTENT_VALUE;
4724
- exports.OPERATOR_CONDITION_REMAP = OPERATOR_CONDITION_REMAP;
4725
- exports.PARAMETER_INFOS = PARAMETER_INFOS;
4726
- exports.PREVIEW_LIMITS = PREVIEW_LIMITS;
4727
- exports.RANGE_OPERATORS = RANGE_OPERATORS;
4728
- exports.SGisBrushFill = SGisBrushFill;
4729
- exports.SGisImageFill = SGisImageFill;
4730
- exports.SGisPolygonSymbol = SGisPolygonSymbol;
4731
- exports.SGisPolylineSymbol = SGisPolylineSymbol;
4732
- exports.SOLID_INTERVALS = SOLID_INTERVALS;
4733
- exports.STARTS_WITH_OPERATORS = STARTS_WITH_OPERATORS;
4734
- exports.SVGPoly = SVGPoly;
4735
- exports.SYMBOL_CLASSIFICATION = SYMBOL_CLASSIFICATION;
4736
- exports.SYMBOL_LIMITS = SYMBOL_LIMITS;
4737
- exports.SYMBOL_SIZE_PARAMETERS = SYMBOL_SIZE_PARAMETERS;
4738
- exports.SelectedPointSymbol = SelectedPointSymbol;
4739
- exports.SelectedPolySymbol = SelectedPolySymbol;
4740
- exports.ShadowedPointSymbol = ShadowedPointSymbol;
4741
- exports.ShadowedPolySymbol = ShadowedPolySymbol;
4742
- exports.SizeMinimizedLegend = SizeMinimizedLegend;
4743
- exports.SizeMinimizedLegendDown = SizeMinimizedLegendDown;
4744
- exports.SizeMinimizedLegendLabel = SizeMinimizedLegendLabel;
4745
- exports.SizeMinimizedLegendSymbol = SizeMinimizedLegendSymbol;
4746
- exports.SizeMinimizedLegendUp = SizeMinimizedLegendUp;
4747
- exports.SquareLineMiterRender = SquareLineMiterRender;
4748
- exports.StyleSymbol = StyleSymbol;
4749
- exports.SvgSymbol = SvgSymbol;
4750
- exports.Symbol = Symbol;
4751
- exports.SymbolButton = SymbolButton;
4752
- exports.SymbolByType = SymbolByType;
4753
- exports.SymbolContainer = SymbolContainer;
4754
- exports.adjustSymbol = adjustSymbol;
4755
- exports.applyParameterValue = applyParameterValue;
4756
- exports.checkLayerHasLegend = checkLayerHasLegend;
4757
- exports.clamp = clamp;
4758
- exports.classifyParamsReduce = classifyParamsReduce;
4759
- exports.convertSvgToBase64 = convertSvgToBase64;
4760
- exports.copyRings = copyRings;
4761
- exports.createCompositeSymbol = createCompositeSymbol;
4762
- exports.createHiddenCondition = createHiddenCondition;
4763
- exports.createLegendSymbol = createLegendSymbol;
4764
- exports.createOtherHiddenCondition = createOtherHiddenCondition;
4765
- exports.createPointRender = createPointRender;
4766
- exports.createShadowRender = createShadowRender;
4767
- exports.createSvgGradient = createSvgGradient;
4768
- exports.createValueTitle = createValueTitle;
4769
- exports.createValueTitleFromCondition = createValueTitleFromCondition;
4770
- exports.dateComparisonOperators = dateComparisonOperators;
4771
- exports.defineStrokeStylePreset = defineStrokeStylePreset;
4772
- exports.deserializeSymbol = deserializeSymbol;
4773
- exports.extractStyle = extractStyle;
4774
- exports.extractSymbol = extractSymbol;
4775
- exports.findChildFeatureStyle = findChildFeatureStyle;
4776
- exports.findChildFeatureSymbol = findChildFeatureSymbol;
4777
- exports.formatAttributeValue = formatAttributeValue;
4778
56
  exports.formatDate = formatDate;
4779
- exports.formatRangeClassValue = formatRangeClassValue;
4780
- exports.formatUniqueClassValue = formatUniqueClassValue;
4781
- exports.getAttributeFromCondition = getAttributeFromCondition;
4782
- exports.getAttributeNameFromClassified = getAttributeNameFromClassified;
4783
- exports.getAttributeNameFromCondition = getAttributeNameFromCondition;
4784
- exports.getChildSymbols = getChildSymbols;
4785
- exports.getClassificationValue = getClassificationValue;
4786
- exports.getClassified = getClassified;
4787
- exports.getDashStylePreset = getDashStylePreset;
4788
57
  exports.getDate = getDate;
4789
- exports.getDimensions = getDimensions;
4790
- exports.getExprFromCondition = getExprFromCondition;
4791
- exports.getExtractedSymbol = getExtractedSymbol;
4792
- exports.getFeatureSymbol = getFeatureSymbol;
4793
- exports.getHexColor = getHexColor;
4794
- exports.getLegendSymbolRenders = getLegendSymbolRenders;
4795
- exports.getLegendSymbolSize = getLegendSymbolSize;
4796
- exports.getLineDash = getLineDash;
4797
- exports.getMapLegendSymbolRenders = getMapLegendSymbolRenders;
4798
- exports.getMaximizedLegendValues = getMaximizedLegendValues;
4799
- exports.getMinimizedLegendValues = getMinimizedLegendValues;
4800
- exports.getOffsetParameterValue = getOffsetParameterValue;
4801
- exports.getParameterFromSymbol = getParameterFromSymbol;
4802
- exports.getParameterValue = getParameterValue;
4803
- exports.getRangeValues = getRangeValues$1;
4804
- exports.getServiceConfiguration = getServiceConfiguration;
4805
- exports.getSignFromConditionPart = getSignFromConditionPart;
4806
- exports.getSimplifiedPolygonCoordinates = getSimplifiedPolygonCoordinates;
4807
- exports.getSymbolParameterInfo = getSymbolParameterInfo;
4808
- exports.getSymbolRenders = getSymbolRenders;
4809
- exports.getSymbolStrokeWidth = getSymbolStrokeWidth;
4810
- exports.getTitleFromCondition = getTitleFromCondition;
4811
- exports.getValueFromConditionPart = getValueFromConditionPart;
4812
- exports.isArrowLineMiter = isArrowLineMiter;
4813
- exports.isCalculatedParameter = isCalculatedParameter;
4814
- exports.isCircleLineMiter = isCircleLineMiter;
4815
- exports.isClusterFillColor = isClusterFillColor;
4816
- exports.isClusterSymbol = isClusterSymbol;
4817
- exports.isCombinedPolylineSymbol = isCombinedPolylineSymbol;
4818
- exports.isCompositeSymbol = isCompositeSymbol;
4819
- exports.isDashedBrush = isDashedBrush;
4820
- exports.isFilledLineMitter = isFilledLineMitter;
4821
- exports.isH3GridSymbol = isH3GridSymbol;
4822
- exports.isHatchBrush = isHatchBrush;
4823
- exports.isImageSymbol = isImageSymbol;
4824
- exports.isLabelSymbol = isLabelSymbol;
4825
- exports.isLayerService = isLayerService;
4826
- exports.isMaskedImageSymbol = isMaskedImageSymbol;
4827
- exports.isMiterExist = isMiterExist;
4828
58
  exports.isNumeric = isNumeric;
4829
59
  exports.isObject = isObject;
4830
- exports.isParameterByAttribute = isParameterByAttribute;
4831
- exports.isParameterType = isParameterType;
4832
- exports.isParameterValueSimple = isParameterValueSimple;
4833
- exports.isParameterValueSymbol = isParameterValueSymbol;
4834
- exports.isPatternBrush = isPatternBrush;
4835
- exports.isPointLabelSymbol = isPointLabelSymbol;
4836
- exports.isPointSymbol = isPointSymbol;
4837
- exports.isPolygonHasHatchBrush = isPolygonHasHatchBrush;
4838
- exports.isPolygonHasPatternBrush = isPolygonHasPatternBrush;
4839
- exports.isPolygonLabelSymbol = isPolygonLabelSymbol;
4840
- exports.isPolygonSymbol = isPolygonSymbol;
4841
- exports.isPolylineLabelSymbol = isPolylineLabelSymbol;
4842
- exports.isPolylineSymbols = isPolylineSymbols;
4843
- exports.isRangeClass = isRangeClass;
4844
- exports.isRangeCondition = isRangeCondition;
4845
- exports.isRasterSymbol = isRasterSymbol;
4846
- exports.isRequisiteNumbers = isRequisiteNumbers;
4847
- exports.isSGisClusterSymbol = isSGisClusterSymbol;
4848
- exports.isSGisCombinedPolylineSymbol = isSGisCombinedPolylineSymbol;
4849
- exports.isSGisH3Symbol = isSGisH3Symbol;
4850
- exports.isSGisImageSymbol = isSGisImageSymbol;
4851
- exports.isSGisPointSymbol = isSGisPointSymbol;
4852
- exports.isSGisPolygonSymbol = isSGisPolygonSymbol;
4853
- exports.isSGisPolylineSymbol = isSGisPolylineSymbol;
4854
- exports.isScalablePolylineSymbol = isScalablePolylineSymbol;
4855
- exports.isSimpleOffset = isSimpleOffset;
4856
- exports.isSimplePolylineSymbol = isSimplePolylineSymbol;
4857
- exports.isSimpleSymbol = isSimpleSymbol;
4858
- exports.isSizableSymbol = isSizableSymbol;
4859
- exports.isSizeClassification = isSizeClassification;
4860
- exports.isSolidBrush = isSolidBrush;
4861
- exports.isSquareLineMiter = isSquareLineMiter;
4862
- exports.isSquareSymbol = isSquareSymbol;
4863
- exports.isStaticImageSymbol = isStaticImageSymbol;
4864
- exports.isStringAsInn = isStringAsInn;
4865
- exports.isStringAsKpp = isStringAsKpp;
4866
- exports.isStringAsMail = isStringAsMail;
4867
- exports.isStringAsOgrn = isStringAsOgrn;
4868
- exports.isStringAsPhone = isStringAsPhone;
4869
- exports.isStringAsUrl = isStringAsUrl;
4870
- exports.isStringContainsDate = isStringContainsDate;
4871
- exports.isStringParameterValue = isStringParameterValue;
4872
- exports.isStrokeStyledSymbol = isStrokeStyledSymbol;
4873
- exports.isStyle = isStyle;
4874
- exports.isSvgPointSymbol = isSvgPointSymbol;
4875
- exports.isSymbolWithOffset = isSymbolWithOffset;
4876
- exports.isTwoDimensionalSymbol = isTwoDimensionalSymbol;
4877
- exports.isUniqueClass = isUniqueClass;
4878
- exports.isValidParameter = isValidParameter;
4879
- exports.isValidUrl = isValidUrl;
4880
- exports.mailHref = mailHref;
4881
- exports.manipulateSvgSymbol = manipulateSvgSymbol;
4882
- exports.matchPhone = matchPhone;
4883
- exports.measureAreaSymbol = measureAreaSymbol;
4884
- exports.measureLengthSymbol = measureLengthSymbol;
4885
- exports.measurePolygonSnapSymbol = measurePolygonSnapSymbol;
4886
- exports.metersToPixels = metersToPixels;
4887
- exports.numberComparisonOperators = numberComparisonOperators;
4888
- exports.numberWithSpaces = numberWithSpaces;
4889
- exports.packStyle = packStyle;
4890
- exports.phoneHref = phoneHref;
4891
- exports.polygonCircleFromPoint = polygonCircleFromPoint;
4892
- exports.printRangeClass = printRangeClass;
4893
- exports.renderSymbolToCanvas = renderSymbolToCanvas;
4894
- exports.selectedPoint = selectedPoint;
4895
- exports.selectedPolygon = selectedPolygon;
4896
- exports.selectedPolyline = selectedPolyline;
4897
- exports.serializeSvgPointSymbol = serializeSvgPointSymbol;
4898
- exports.setDefaultParameterValue = setDefaultParameterValue;
4899
- exports.setParameterValue = setParameterValue;
4900
- exports.solidStrokeStylePreset = solidStrokeStylePreset;
4901
- exports.strokeStylePresets = strokeStylePresets;
4902
- exports.symbolParameterWalker = symbolParameterWalker;
4903
- exports.symbolTypeGuard = symbolTypeGuard;
4904
- exports.textComparisonOperators = textComparisonOperators;
4905
- exports.toIntervals = toIntervals;
4906
- exports.toLineDash = toLineDash;
4907
- exports.unClassify = unClassify;
4908
- exports.updateSymbolParameter = updateSymbolParameter;
4909
- exports.urlHref = urlHref;
4910
- exports.useCanvas = useCanvas;
4911
- exports.useLegendContext = useLegendContext;
4912
- exports.useMount = useMount;
4913
- exports.useNode = useNode;
4914
- exports.useSvgSymbol = useSvgSymbol;
4915
- exports.useSymbol = useSymbol;
4916
- exports.useToggle = useToggle;
4917
60
  //# sourceMappingURL=react.cjs.development.js.map