@evergis/react 2.0.146 → 2.0.148

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.
@@ -27,10 +27,6 @@ var PolylineSymbol = require('@evergis/sgis/es/symbols/PolylineSymbol');
27
27
  var Poly = require('@evergis/sgis/es/renders/Poly');
28
28
  var geotools = require('@evergis/sgis/es/geotools');
29
29
  var math = require('@evergis/sgis/es/utils/math');
30
- var PolylineControl = require('@evergis/sgis/es/controls/PolylineControl');
31
- var Label = require('@evergis/sgis/es/features/Label');
32
- var Control = require('@evergis/sgis/es/controls/Control');
33
- var PolyEditor = require('@evergis/sgis/es/controls/PolyEditor');
34
30
  var ReactDOM = _interopDefault(require('react-dom'));
35
31
  var _Symbol = require('@evergis/sgis/es/symbols/Symbol');
36
32
  var Poly$1 = require('@evergis/sgis/es/features/Poly');
@@ -45,6 +41,7 @@ var H3Symbol = require('@evergis/sgis/es/symbols/H3Symbol');
45
41
  var H3Feature = require('@evergis/sgis/es/features/H3Feature');
46
42
  var Canvas = require('@evergis/sgis/es/painters/DomPainter/Canvas');
47
43
  var commonEvents = require('@evergis/sgis/es/commonEvents');
44
+ var Label = require('@evergis/sgis/es/features/Label');
48
45
  var ClusterLayer$1 = require('@evergis/sgis/es/layers/ClusterLayer');
49
46
  var GridClusterProvider = require('@evergis/sgis/es/layers/clusterProviders/GridClusterProvider');
50
47
  var PointEditor = require('@evergis/sgis/es/controls/PointEditor');
@@ -53,6 +50,9 @@ var styled = require('styled-components');
53
50
  var styled__default = _interopDefault(styled);
54
51
  var punycode = _interopDefault(require('punycode'));
55
52
  var TileLayer$1 = require('@evergis/sgis/es/layers/TileLayer');
53
+ var PolylineControl = require('@evergis/sgis/es/controls/PolylineControl');
54
+ var Control = require('@evergis/sgis/es/controls/Control');
55
+ var PolyEditor = require('@evergis/sgis/es/controls/PolyEditor');
56
56
 
57
57
  function _classCallCheck(instance, Constructor) {
58
58
  if (!(instance instanceof Constructor)) {
@@ -73,9 +73,6 @@ function _defineProperties(target, props) {
73
73
  function _createClass(Constructor, protoProps, staticProps) {
74
74
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
75
75
  if (staticProps) _defineProperties(Constructor, staticProps);
76
- Object.defineProperty(Constructor, "prototype", {
77
- writable: false
78
- });
79
76
  return Constructor;
80
77
  }
81
78
 
@@ -109,9 +106,6 @@ function _inherits(subClass, superClass) {
109
106
  configurable: true
110
107
  }
111
108
  });
112
- Object.defineProperty(subClass, "prototype", {
113
- writable: false
114
- });
115
109
  if (superClass) _setPrototypeOf(subClass, superClass);
116
110
  }
117
111
 
@@ -170,8 +164,6 @@ function _assertThisInitialized(self) {
170
164
  function _possibleConstructorReturn(self, call) {
171
165
  if (call && (typeof call === "object" || typeof call === "function")) {
172
166
  return call;
173
- } else if (call !== void 0) {
174
- throw new TypeError("Derived constructors may only return object or undefined");
175
167
  }
176
168
 
177
169
  return _assertThisInitialized(self);
@@ -205,7 +197,7 @@ function _superPropBase(object, property) {
205
197
  return object;
206
198
  }
207
199
 
208
- function _get() {
200
+ function _get(target, property, receiver) {
209
201
  if (typeof Reflect !== "undefined" && Reflect.get) {
210
202
  _get = Reflect.get;
211
203
  } else {
@@ -216,14 +208,14 @@ function _get() {
216
208
  var desc = Object.getOwnPropertyDescriptor(base, property);
217
209
 
218
210
  if (desc.get) {
219
- return desc.get.call(arguments.length < 3 ? target : receiver);
211
+ return desc.get.call(receiver);
220
212
  }
221
213
 
222
214
  return desc.value;
223
215
  };
224
216
  }
225
217
 
226
- return _get.apply(this, arguments);
218
+ return _get(target, property, receiver || target);
227
219
  }
228
220
 
229
221
  function _taggedTemplateLiteralLoose(strings, raw) {
@@ -252,7 +244,7 @@ const defaultApi = /*#__PURE__*/new api.Api({
252
244
  url: BASE_URL
253
245
  });
254
246
  const evergisContext = /*#__PURE__*/React.createContext(defaultApi);
255
- const EvergisProvider = _ref => {
247
+ const EvergisProvider = (_ref) => {
256
248
  let {
257
249
  api,
258
250
  children
@@ -270,7 +262,7 @@ const mapContext = /*#__PURE__*/React.createContext({
270
262
  map: defaultMap,
271
263
  painter: defaultPainter
272
264
  });
273
- const MapProvider = _ref => {
265
+ const MapProvider = (_ref) => {
274
266
  let {
275
267
  map,
276
268
  painter,
@@ -292,7 +284,7 @@ const tooltipContext = /*#__PURE__*/React.createContext({
292
284
  layer: defaultLayer,
293
285
  popupLayer: defaultPopupLayer
294
286
  });
295
- const TooltipProvider = _ref => {
287
+ const TooltipProvider = (_ref) => {
296
288
  let {
297
289
  layer,
298
290
  popupLayer,
@@ -309,7 +301,7 @@ const TooltipProvider = _ref => {
309
301
  const useTooltipContext = () => React.useContext(tooltipContext);
310
302
 
311
303
  const LegendContext = /*#__PURE__*/React.createContext(null);
312
- const LegendProvider = _ref => {
304
+ const LegendProvider = (_ref) => {
313
305
  let {
314
306
  symbol,
315
307
  children
@@ -321,7 +313,7 @@ const LegendProvider = _ref => {
321
313
  const useLegendContext = () => React.useContext(LegendContext);
322
314
 
323
315
  const evergisSelectContext = /*#__PURE__*/React.createContext([]);
324
- const EvergisSelectProvider = _ref => {
316
+ const EvergisSelectProvider = (_ref) => {
325
317
  let {
326
318
  layers,
327
319
  children
@@ -366,7 +358,7 @@ function useMapViewActions() {
366
358
  }, [map]);
367
359
  const zoomIn = React.useCallback(() => zoomTo(1), [zoomTo]);
368
360
  const zoomOut = React.useCallback(() => zoomTo(-1), [zoomTo]);
369
- const animateTo = React.useCallback(_ref => {
361
+ const animateTo = React.useCallback((_ref) => {
370
362
  let {
371
363
  position,
372
364
  resolution,
@@ -396,7 +388,7 @@ function useMapViewActions() {
396
388
  const {
397
389
  tileScheme
398
390
  } = map;
399
- let tileLevel = tileScheme.levels.find(_ref2 => {
391
+ let tileLevel = tileScheme.levels.find((_ref2) => {
400
392
  let {
401
393
  zIndex
402
394
  } = _ref2;
@@ -572,7 +564,7 @@ const formatStringAttribute = value => {
572
564
 
573
565
  const attributeValues = value.split(/[\s|]/).map(convertStringAttribute);
574
566
 
575
- if (attributeValues.every(_ref => {
567
+ if (attributeValues.every((_ref) => {
576
568
  let {
577
569
  type
578
570
  } = _ref;
@@ -580,7 +572,7 @@ const formatStringAttribute = value => {
580
572
  }
581
573
  /* String */
582
574
  )) {
583
- return [stringAttribute(attributeValues.map(_ref2 => {
575
+ return [stringAttribute(attributeValues.map((_ref2) => {
584
576
  let {
585
577
  value
586
578
  } = _ref2;
@@ -1057,7 +1049,7 @@ const getFeatureAttributeType = attributeValue => {
1057
1049
  };
1058
1050
  const getLayerAttributes = layerDefinition => {
1059
1051
  const attributes = layerDefinition && layerDefinition.attributes || {};
1060
- return Object.entries(attributes).map(_ref => {
1052
+ return Object.entries(attributes).map((_ref) => {
1061
1053
  let [name, definition] = _ref;
1062
1054
  return _extends({
1063
1055
  name
@@ -1065,7 +1057,7 @@ const getLayerAttributes = layerDefinition => {
1065
1057
  });
1066
1058
  };
1067
1059
  const getFeatureAttributes = attributes => {
1068
- return attributes ? Object.entries(attributes).map(_ref2 => {
1060
+ return attributes ? Object.entries(attributes).map((_ref2) => {
1069
1061
  let [name, value] = _ref2;
1070
1062
  return {
1071
1063
  name,
@@ -1083,7 +1075,7 @@ const getClassificationAttribute = (attributeName, attributes) => {
1083
1075
  return attribute ? _extends({}, attrNamePart, attribute) : attrNamePart;
1084
1076
  };
1085
1077
  const mergeAttributes = (attributes1, attributes2) => {
1086
- return attributes1.map(attribute => _extends({}, attribute, attributes2.find(_ref3 => {
1078
+ return attributes1.map(attribute => _extends({}, attribute, attributes2.find((_ref3) => {
1087
1079
  let {
1088
1080
  name
1089
1081
  } = _ref3;
@@ -1498,7 +1490,7 @@ let SGisPolygonSymbol = /*#__PURE__*/function (_sPolygonSymbol) {
1498
1490
  const adaptMiterRings = (rings, resolution, fromCrs, toCrs) => {
1499
1491
  const projected = geotools.projectRings(rings, fromCrs, toCrs);
1500
1492
  return math.simplifyCoordinates(projected.map(ring => // @ts-ignore
1501
- ring.map(_ref => {
1493
+ ring.map((_ref) => {
1502
1494
  let [x, y] = _ref;
1503
1495
  return [x / resolution, y / -resolution];
1504
1496
  })), 1);
@@ -1590,1675 +1582,1333 @@ let ArrowLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1590
1582
  return ArrowLineMiterRender;
1591
1583
  }(LineMiterRender);
1592
1584
 
1593
- const DEFAULT_FORMATTERS = {
1594
- polygon: formatPolygonMeasure,
1595
- length: formatLength
1596
- };
1597
-
1598
- const COORD_FRACTION = 6;
1599
- const DEFAULT_LABEL_POSITION = [Infinity, Infinity];
1600
- let BaseMeasureToolCreator = /*#__PURE__*/function (_PolylineControl) {
1601
- _inherits(BaseMeasureToolCreator, _PolylineControl);
1602
-
1603
- var _super = /*#__PURE__*/_createSuper(BaseMeasureToolCreator);
1585
+ let CircleLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1586
+ _inherits(CircleLineMiterRender, _LineMiterRender);
1604
1587
 
1605
- function BaseMeasureToolCreator(map, painter, params) {
1606
- var _this;
1588
+ var _super = /*#__PURE__*/_createSuper(CircleLineMiterRender);
1607
1589
 
1608
- _classCallCheck(this, BaseMeasureToolCreator);
1590
+ function CircleLineMiterRender() {
1591
+ _classCallCheck(this, CircleLineMiterRender);
1609
1592
 
1610
- _this = _super.call(this, map, params);
1593
+ return _super.apply(this, arguments);
1594
+ }
1611
1595
 
1612
- _this.cancel = () => {
1613
- _this.fire('cancel');
1614
- };
1596
+ _createClass(CircleLineMiterRender, [{
1597
+ key: "usageSize",
1598
+ get: function get() {
1599
+ return this.miterSize + this.strokeWidth * 3;
1600
+ }
1601
+ }, {
1602
+ key: "createRings",
1603
+ value: function createRings(_ref, xMultiplier) {
1604
+ let [x, y] = _ref;
1605
+ return [[[x + (this.miterSize / 2 + this.strokeWidth) * xMultiplier, y]]];
1606
+ }
1607
+ }, {
1608
+ key: "createRender",
1609
+ value: function createRender(miterRings) {
1610
+ const isFilled = this.kind === exports.LineMiterKind.FilledCircle;
1611
+ return new Poly.PolyRender(polygonCircleFromPoint(miterRings[0][0], this.miterSize), {
1612
+ fillColor: isFilled ? this.color : 'transparent',
1613
+ strokeColor: this.color,
1614
+ strokeWidth: this.strokeWidth,
1615
+ enclosed: true
1616
+ });
1617
+ }
1618
+ }]);
1615
1619
 
1616
- _this.painter = painter;
1617
- _this.renderLabelSymbol = params.renderLabelSymbol;
1618
- _this.formatters = params.formatters || DEFAULT_FORMATTERS;
1619
- _this.areaSymbol = params.areaSymbol;
1620
+ return CircleLineMiterRender;
1621
+ }(LineMiterRender);
1620
1622
 
1621
- _this.on('pointAdd', _this.handlePointAdd); // @ts-ignore
1623
+ let SquareLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1624
+ _inherits(SquareLineMiterRender, _LineMiterRender);
1622
1625
 
1626
+ var _super = /*#__PURE__*/_createSuper(SquareLineMiterRender);
1623
1627
 
1624
- _this.on('change', _this.updateDistance);
1628
+ function SquareLineMiterRender() {
1629
+ _classCallCheck(this, SquareLineMiterRender);
1625
1630
 
1626
- return _this;
1631
+ return _super.apply(this, arguments);
1627
1632
  }
1628
1633
 
1629
- _createClass(BaseMeasureToolCreator, [{
1630
- key: "_handleMousemove",
1631
- value: function _handleMousemove(event) {
1632
- _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_handleMousemove", this).call(this, event);
1633
-
1634
- this.drawPointOnMouseMove(event);
1634
+ _createClass(SquareLineMiterRender, [{
1635
+ key: "usageSize",
1636
+ get: function get() {
1637
+ return this.miterSize + this.strokeWidth;
1635
1638
  }
1636
1639
  }, {
1637
- key: "_activate",
1638
- value: function _activate() {
1639
- _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_activate", this).call(this);
1640
-
1641
- this.addTempLabel();
1642
- this.setCursor('pointer');
1640
+ key: "createRings",
1641
+ value: function createRings(_ref, xMultiplier) {
1642
+ let [x, y] = _ref;
1643
+ 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]]];
1643
1644
  }
1644
1645
  }, {
1645
- key: "_deactivate",
1646
- value: function _deactivate() {
1647
- _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_deactivate", this).call(this);
1646
+ key: "createRender",
1647
+ value: function createRender(miterRings) {
1648
+ const isFilled = this.kind === exports.LineMiterKind.FilledSquare;
1649
+ return new Poly.PolyRender(miterRings, {
1650
+ enclosed: true,
1651
+ fillColor: isFilled ? this.color : void 0,
1652
+ fillStyle: isFilled ? Poly.FillStyle.Color : Poly.FillStyle.None,
1653
+ lineCap: 'square',
1654
+ lineJoin: 'miter',
1655
+ strokeColor: this.color,
1656
+ strokeWidth: this.strokeWidth
1657
+ });
1658
+ }
1659
+ }]);
1648
1660
 
1649
- this.removeCoordLabel();
1650
- this.removeTempLabel();
1651
- this.removeMeasureLabel();
1652
- this.removeTempPolygon();
1653
- this.setCursor('default');
1661
+ return SquareLineMiterRender;
1662
+ }(LineMiterRender);
1663
+
1664
+ const getLineMiterRender = options => {
1665
+ switch (options.kind) {
1666
+ case exports.LineMiterKind.Arrow:
1667
+ case exports.LineMiterKind.FilledArrow:
1668
+ return new ArrowLineMiterRender(options);
1669
+
1670
+ case exports.LineMiterKind.Square:
1671
+ case exports.LineMiterKind.FilledSquare:
1672
+ return new SquareLineMiterRender(options);
1673
+
1674
+ case exports.LineMiterKind.Circle:
1675
+ case exports.LineMiterKind.FilledCircle:
1676
+ return new CircleLineMiterRender(options);
1677
+
1678
+ default:
1679
+ return null;
1680
+ }
1681
+ };
1682
+
1683
+ const updateRingForRightMiter = (ring, miterSize, isLastRing) => {
1684
+ const reversedRing = ring.slice().reverse();
1685
+
1686
+ for (let i = 0; i < reversedRing.length; i++) {
1687
+ const coordinates = reversedRing[i];
1688
+
1689
+ if (isLastRing && i === 0) {
1690
+ reversedRing[i] = [coordinates[0] - miterSize, coordinates[1]];
1654
1691
  }
1655
- }, {
1656
- key: "handlePointAdd",
1657
- value: function handlePointAdd() {
1658
- const feature = this.activeFeature;
1659
- if (!feature) return;
1660
- const {
1661
- rings,
1662
- crs
1663
- } = feature;
1664
1692
 
1665
- if (isPolylineLikePolygon(rings, this.map.resolution)) {
1666
- this.finishDrawing();
1667
- this.fire(new Control.DrawingFinishEvent(feature, new MouseEvent('mouseup')));
1668
- return;
1669
- }
1693
+ const nextCoordinates = reversedRing[i - 1];
1670
1694
 
1671
- if (rings[0].length === 2) {
1672
- const projection = crs.projectionTo(Crs.geo);
1673
- const point = rings[0][0];
1674
- if (!projection) return;
1675
- const [lat, long] = projection(point);
1676
- this.removeTempLabel();
1677
- this.addMeasureResultLabel();
1678
- this.addCoordLabel(lat.toFixed(COORD_FRACTION) + ", " + long.toFixed(COORD_FRACTION), point);
1679
- } else {
1680
- this.removeCoordLabel();
1681
- }
1695
+ if (nextCoordinates && nextCoordinates[0] < coordinates[0]) {
1696
+ reversedRing[i] = [nextCoordinates[0] - Math.abs(nextCoordinates[0] - coordinates[0]), coordinates[1]];
1682
1697
  }
1683
- }, {
1684
- key: "polygonPreview",
1685
- value: function polygonPreview() {
1686
- if (this.tempPolygon) {
1687
- this._tempLayer && this._tempLayer.remove(this.tempPolygon);
1688
- }
1698
+ }
1689
1699
 
1690
- const feature = this.activeFeature;
1691
- if (!feature) return;
1692
- const {
1693
- rings,
1694
- crs
1695
- } = feature;
1696
- const polygonRings = [...rings[0]];
1697
- polygonRings.shift();
1698
- this.tempPolygon = new Polygon.Polygon(polygonRings, {
1699
- crs
1700
- });
1701
- this.tempPolygon.symbol = this.areaSymbol || measureAreaSymbol;
1702
- this.activeFeature && this.activeFeature.hide();
1703
- this._tempLayer && this._tempLayer.add(this.tempPolygon);
1700
+ return reversedRing.reverse();
1701
+ };
1702
+
1703
+ const updateRingForLeftMiter = (ring, miterSize, isFirstRing) => {
1704
+ const newRing = ring.slice();
1705
+
1706
+ for (let i = 0; i < newRing.length; i++) {
1707
+ const coordinates = newRing[i];
1708
+
1709
+ if (i === 0 && isFirstRing) {
1710
+ newRing[i] = [coordinates[0] + miterSize, coordinates[1]];
1704
1711
  }
1705
- }, {
1706
- key: "removeTempPolygon",
1707
- value: function removeTempPolygon() {
1708
- if (this.tempPolygon) {
1709
- this._tempLayer && this._tempLayer.remove(this.tempPolygon);
1710
- delete this.tempPolygon;
1711
- }
1712
+
1713
+ const prevCoordinates = newRing[i - 1];
1714
+
1715
+ if (prevCoordinates && prevCoordinates[0] > coordinates[0]) {
1716
+ newRing[i] = [prevCoordinates[0] + Math.abs(coordinates[0] - prevCoordinates[0]), coordinates[1]];
1712
1717
  }
1713
- }, {
1714
- key: "updateDistance",
1715
- value: function updateDistance(event) {
1716
- const feature = this.activeFeature;
1717
- const {
1718
- ringIndex,
1719
- pointIndex
1720
- } = event;
1721
- if (!feature || ringIndex === null || pointIndex === null) return;
1722
- const {
1723
- rings,
1724
- crs
1725
- } = feature;
1726
- const position = rings[ringIndex][pointIndex];
1727
- const length = geotools.length(rings, crs);
1728
- let content = this.formatters.length(length);
1718
+ }
1729
1719
 
1730
- if (isPolylineLikePolygon(rings, this.map.resolution)) {
1731
- this.polygonPreview();
1732
- const area = geotools.area(rings, crs);
1733
- content = this.formatters.polygon(area, length);
1734
- } else if (this.tempPolygon) {
1735
- feature.show();
1736
- this.removeTempPolygon();
1737
- }
1720
+ return newRing;
1721
+ };
1738
1722
 
1739
- if (this.measureResultLabel) {
1740
- this.measureResultLabel.position = position;
1741
- this.measureResultLabel.content = content;
1742
- }
1723
+ const updateRingsForMiter = (rings, position, miterSize) => {
1724
+ return rings.map((ring, ringIndex) => {
1725
+ switch (position) {
1726
+ case 'right':
1727
+ return updateRingForRightMiter(ring, miterSize, ringIndex === rings.length - 1);
1728
+
1729
+ default:
1730
+ return updateRingForLeftMiter(ring, miterSize, ringIndex === 0);
1743
1731
  }
1744
- }, {
1745
- key: "addTempLabel",
1746
- value: function addTempLabel() {
1747
- this.tempLabel = new Label.LabelFeature(DEFAULT_LABEL_POSITION, {
1748
- content: 'Нажмите на карту, чтобы начать измерение',
1749
- crs: this.map.crs,
1750
- symbol: createLabelSymbol({
1751
- renderLabel: this.renderLabelSymbol
1752
- })
1753
- });
1754
- this._tempLayer && this._tempLayer.add(this.tempLabel);
1755
- }
1756
- }, {
1757
- key: "addCoordLabel",
1758
- value: function addCoordLabel(content, position) {
1759
- this.coordLabel = new Label.LabelFeature(position, {
1760
- content,
1761
- crs: this.map.crs,
1762
- symbol: createLabelSymbol({
1763
- renderLabel: this.renderLabelSymbol,
1764
- onClose: this.cancel
1765
- })
1732
+ });
1733
+ };
1734
+
1735
+ const copyRings = rings => rings.map(ring => ring.map(coordinates => coordinates.slice()));
1736
+ let SGisPolylineSymbol = /*#__PURE__*/function (_sPolylineSymbol) {
1737
+ _inherits(SGisPolylineSymbol, _sPolylineSymbol);
1738
+
1739
+ var _super = /*#__PURE__*/_createSuper(SGisPolylineSymbol);
1740
+
1741
+ function SGisPolylineSymbol(originalSymbol) {
1742
+ var _originalSymbol$strok, _originalSymbol$strok2;
1743
+
1744
+ var _this;
1745
+
1746
+ _classCallCheck(this, SGisPolylineSymbol);
1747
+
1748
+ _this = _super.call(this, {
1749
+ // @ts-ignore
1750
+ strokeColor: getHexColor(getParameterValue((_originalSymbol$strok = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok.color)),
1751
+ strokeWidth: clamp( // @ts-ignore
1752
+ getParameterValue((_originalSymbol$strok2 = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok2.width), PREVIEW_LIMITS.STROKE_WIDTH_MIN, PREVIEW_LIMITS.STROKE_WIDTH_MAX),
1753
+ // @ts-ignore
1754
+ lineDash: getLineDash(originalSymbol.stroke),
1755
+ // @ts-ignore
1756
+ lineCap: isDashedBrush(originalSymbol.stroke) ? 'square' : 'round'
1757
+ });
1758
+ _this.originalSymbol = originalSymbol;
1759
+ return _this;
1760
+ }
1761
+
1762
+ _createClass(SGisPolylineSymbol, [{
1763
+ key: "renderFunction",
1764
+ value: function renderFunction(feature, resolution, crs) {
1765
+ if (!isSimplePolylineSymbol(this.originalSymbol)) return _get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, feature, resolution, crs);
1766
+ const {
1767
+ ending,
1768
+ beginningSize,
1769
+ beginning,
1770
+ endingSize
1771
+ } = this.originalSymbol;
1772
+ const renders = [];
1773
+ const featureCopy = feature.clone();
1774
+ const beginningMiterRender = getLineMiterRender({
1775
+ color: this.strokeColor,
1776
+ // @ts-ignore
1777
+ kind: beginning,
1778
+ position: 'left',
1779
+ // @ts-ignore
1780
+ size: beginningSize,
1781
+ strokeWidth: this.strokeWidth
1766
1782
  });
1767
- this._tempLayer && this.coordLabel && this._tempLayer.add(this.coordLabel);
1768
- }
1769
- }, {
1770
- key: "addMeasureResultLabel",
1771
- value: function addMeasureResultLabel() {
1772
- this.measureResultLabel = new Label.LabelFeature(DEFAULT_LABEL_POSITION, {
1773
- crs: this.map.crs,
1774
- symbol: createLabelSymbol({
1775
- renderLabel: this.renderLabelSymbol
1776
- })
1783
+ const endingMiterRender = getLineMiterRender({
1784
+ color: this.strokeColor,
1785
+ // @ts-ignore
1786
+ kind: ending,
1787
+ position: 'right',
1788
+ // @ts-ignore
1789
+ size: endingSize,
1790
+ strokeWidth: this.strokeWidth
1777
1791
  });
1778
- this._tempLayer && this.measureResultLabel && this._tempLayer.add(this.measureResultLabel);
1779
- }
1780
- }, {
1781
- key: "removeTempLabel",
1782
- value: function removeTempLabel() {
1783
- if (this.tempLabel) {
1784
- this._tempLayer && this._tempLayer.remove(this.tempLabel);
1785
- delete this.tempLabel;
1786
- }
1787
- }
1788
- }, {
1789
- key: "removeCoordLabel",
1790
- value: function removeCoordLabel() {
1791
- if (this.coordLabel) {
1792
- this._tempLayer && this._tempLayer.remove(this.coordLabel);
1793
- delete this.coordLabel;
1794
- }
1795
- }
1796
- }, {
1797
- key: "removeMeasureLabel",
1798
- value: function removeMeasureLabel() {
1799
- if (this.measureResultLabel) {
1800
- this._tempLayer && this._tempLayer.remove(this.measureResultLabel);
1801
- delete this.measureResultLabel;
1802
- }
1803
- }
1804
- }, {
1805
- key: "drawPointOnMouseMove",
1806
- value: function drawPointOnMouseMove(event) {
1807
- if (this.tempLabel) {
1808
- this.tempLabel.position = event.point.position;
1792
+
1793
+ if (beginningMiterRender) {
1794
+ const updatedRings = updateRingsForMiter(featureCopy.rings, 'left', beginningMiterRender.usageSize);
1795
+ const render = beginningMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
1796
+ featureCopy.rings = updatedRings;
1797
+ renders.push(render);
1809
1798
  }
1799
+
1800
+ if (endingMiterRender) {
1801
+ const updatedRings = updateRingsForMiter(featureCopy.rings, 'right', endingMiterRender.usageSize);
1802
+ const render = endingMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
1803
+ featureCopy.rings = updatedRings;
1804
+ renders.push(render);
1805
+ } // NOTE: линия должна быть в начале чтобы быть под митерами
1806
+
1807
+
1808
+ renders.unshift(..._get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, featureCopy, resolution, crs));
1809
+ return renders;
1810
1810
  }
1811
1811
  }, {
1812
- key: "setCursor",
1813
- value: function setCursor(cursor) {
1814
- const {
1815
- wrapper
1816
- } = this.painter;
1817
-
1818
- if (wrapper && typeof wrapper !== 'string') {
1819
- wrapper.style.cursor = cursor;
1820
- }
1812
+ key: "clone",
1813
+ value: function clone() {
1814
+ return new SGisPolylineSymbol(this.originalSymbol);
1821
1815
  }
1822
1816
  }]);
1823
1817
 
1824
- return BaseMeasureToolCreator;
1825
- }(PolylineControl.PolylineControl);
1818
+ return SGisPolylineSymbol;
1819
+ }(PolylineSymbol.PolylineSymbol);
1826
1820
 
1827
- let BaseMeasureToolEditor = /*#__PURE__*/function (_PolyEditor) {
1828
- _inherits(BaseMeasureToolEditor, _PolyEditor);
1821
+ let LabelSymbol = /*#__PURE__*/function (_DynamicPointSymbol) {
1822
+ _inherits(LabelSymbol, _DynamicPointSymbol);
1829
1823
 
1830
- var _super = /*#__PURE__*/_createSuper(BaseMeasureToolEditor);
1824
+ var _super = /*#__PURE__*/_createSuper(LabelSymbol);
1831
1825
 
1832
- function BaseMeasureToolEditor(map, painter, params) {
1826
+ function LabelSymbol(_temp) {
1833
1827
  var _this;
1834
1828
 
1835
- _classCallCheck(this, BaseMeasureToolEditor);
1836
-
1837
- _this = _super.call(this, map, params);
1838
-
1839
- _this.measureResult = () => {
1840
- const feature = _this.activeFeature;
1841
- if (!feature) return null;
1842
- const {
1843
- rings,
1844
- isEnclosed,
1845
- crs
1846
- } = feature;
1847
- const pointsCount = rings[0].length;
1848
- const position = rings[0][pointsCount - 1];
1849
- const area = geotools.area(rings, crs);
1850
- const length = geotools.length(rings, crs, isEnclosed);
1851
- const content = isEnclosed ? _this.formatters.polygon(area, length) : _this.formatters.length(length);
1852
- return {
1853
- content,
1854
- position
1855
- };
1856
- };
1857
-
1858
- _this.removeFeature = () => {
1859
- _this.fire('remove');
1860
- };
1861
-
1862
- _this.painter = painter;
1863
- _this.renderLabelSymbol = params.renderLabelSymbol;
1864
- _this.formatters = params.formatters || DEFAULT_FORMATTERS;
1865
-
1866
- _this.on('change', _this.updateMeasureResult);
1829
+ let {
1830
+ component,
1831
+ offset
1832
+ } = _temp === void 0 ? {} : _temp;
1867
1833
 
1868
- _this.on('edit', _this.updateMeasureResult);
1834
+ _classCallCheck(this, LabelSymbol);
1869
1835
 
1836
+ _this = _super.call(this, {
1837
+ offset
1838
+ });
1839
+ _this.component = component;
1870
1840
  return _this;
1871
1841
  }
1872
1842
 
1873
- _createClass(BaseMeasureToolEditor, [{
1874
- key: "_activate",
1875
- value: function _activate() {
1876
- _get(_getPrototypeOf(BaseMeasureToolEditor.prototype), "_activate", this).call(this);
1877
-
1878
- this.addMeasureResultLabel();
1843
+ _createClass(LabelSymbol, [{
1844
+ key: "_getFeatureNode",
1845
+ value: function _getFeatureNode(feature) {
1846
+ const node = document.createElement('div');
1847
+ this.renderDom(feature.content, node);
1848
+ return node;
1879
1849
  }
1880
1850
  }, {
1881
- key: "addMeasureResultLabel",
1882
- value: function addMeasureResultLabel() {
1883
- const measureResult = this.measureResult();
1884
- if (measureResult === null) return;
1885
- const {
1886
- content,
1887
- position
1888
- } = measureResult;
1889
- this.measureResultLabel = new Label.LabelFeature(position, {
1890
- content,
1891
- crs: this.map.crs,
1892
- symbol: createLabelSymbol({
1893
- onClose: this.removeFeature,
1894
- renderLabel: this.renderLabelSymbol
1895
- })
1896
- });
1897
- this._tempLayer && this._tempLayer.add(this.measureResultLabel);
1851
+ key: "_updateFeatureNode",
1852
+ value: function _updateFeatureNode(feature) {
1853
+ this.renderDom(feature.content, this.getNode(feature));
1898
1854
  }
1899
1855
  }, {
1900
- key: "updateMeasureResult",
1901
- value: function updateMeasureResult() {
1902
- if (this.measureResultLabel) {
1903
- const measureResult = this.measureResult();
1904
- if (measureResult === null) return;
1905
- const {
1906
- content,
1907
- position
1908
- } = measureResult;
1909
- this.measureResultLabel.content = content;
1910
- this.measureResultLabel.position = position;
1856
+ key: "renderDom",
1857
+ value: function renderDom(content, node) {
1858
+ if (!node) {
1859
+ return;
1911
1860
  }
1912
- }
1913
- }]);
1914
1861
 
1915
- return BaseMeasureToolEditor;
1916
- }(PolyEditor.PolyEditor);
1862
+ const Component = this.component;
1917
1863
 
1918
- const metersToPixels = (meters, _ref) => {
1919
- let {
1920
- painter,
1921
- crs = Crs.geo
1922
- } = _ref;
1923
- const {
1924
- width
1925
- } = painter;
1926
- const zeroPoint = painter.getPointFromPxPosition(0, 0).projectTo(crs);
1927
- const maxWidthPoint = painter.getPointFromPxPosition(width, 0).projectTo(crs);
1928
- const widthDistance = geotools.distance(zeroPoint, maxWidthPoint);
1929
- const pxK = width / (widthDistance || 1);
1930
- return Math.round(meters * pxK);
1931
- };
1932
-
1933
- const polygonCircleFromPoint = (center, diameter) => {
1934
- const coordinates = [];
1935
- const radius = diameter / 2;
1936
- const endAngle = Math.PI * 2;
1937
- const step = Math.max(Math.PI / 2 / radius, endAngle / 128);
1938
- let start = 0;
1939
- let end = endAngle;
1864
+ if (Component) {
1865
+ ReactDOM.render(React__default.createElement(Component, {
1866
+ content: content
1867
+ }), node);
1868
+ } else {
1869
+ node.innerText = content;
1870
+ }
1871
+ }
1872
+ }]);
1940
1873
 
1941
- for (let ang = start; ang < end; ang += step) {
1942
- coordinates.push([Math.cos(ang) * radius + center[0], Math.sin(ang) * radius + center[1]]);
1943
- }
1874
+ return LabelSymbol;
1875
+ }(_Symbol.DynamicPointSymbol);
1944
1876
 
1945
- return [coordinates];
1877
+ const defaultOffset = [8, -16];
1878
+ const createLabelSymbol = props => {
1879
+ const {
1880
+ offset = defaultOffset,
1881
+ renderLabel = (_ref) => {
1882
+ let {
1883
+ content
1884
+ } = _ref;
1885
+ return React__default.createElement("div", null, content);
1886
+ },
1887
+ onClose = undefined
1888
+ } = props || {};
1889
+ return new LabelSymbol({
1890
+ offset,
1891
+ component: (_ref2) => {
1892
+ let {
1893
+ content
1894
+ } = _ref2;
1895
+ return renderLabel({
1896
+ content,
1897
+ onClose
1898
+ });
1899
+ }
1900
+ });
1946
1901
  };
1947
1902
 
1948
- const isNumeric = number => !isNaN(parseFloat(number)) && isFinite(number);
1903
+ function createShadowRender(position, _ref) {
1904
+ let {
1905
+ strokeWidth = 2,
1906
+ shadowColor,
1907
+ shadowSize,
1908
+ size = 6
1909
+ } = _ref;
1910
+ const shadowDiameter = size + strokeWidth + shadowSize;
1911
+ return new Poly.PolyRender(polygonCircleFromPoint(position, shadowDiameter), {
1912
+ fillColor: 'transparent',
1913
+ strokeColor: shadowColor,
1914
+ strokeWidth: shadowSize,
1915
+ enclosed: true
1916
+ });
1917
+ }
1918
+ function getEditorPointRenderer(position, _ref2) {
1919
+ let {
1920
+ strokeColor,
1921
+ strokeWidth,
1922
+ shadowColor,
1923
+ fillColor,
1924
+ shadowSize,
1925
+ size = 0
1926
+ } = _ref2;
1927
+ return [createShadowRender(position, {
1928
+ strokeWidth,
1929
+ strokeColor,
1930
+ shadowSize,
1931
+ shadowColor,
1932
+ size
1933
+ }), new Poly.PolyRender(polygonCircleFromPoint(position, size), {
1934
+ fillColor,
1935
+ strokeColor,
1936
+ strokeWidth,
1937
+ enclosed: true
1938
+ })];
1939
+ }
1949
1940
 
1950
- let CircleLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1951
- _inherits(CircleLineMiterRender, _LineMiterRender);
1941
+ let ShadowedPointSymbol = /*#__PURE__*/function (_PointSymbol) {
1942
+ _inherits(ShadowedPointSymbol, _PointSymbol);
1952
1943
 
1953
- var _super = /*#__PURE__*/_createSuper(CircleLineMiterRender);
1944
+ var _super = /*#__PURE__*/_createSuper(ShadowedPointSymbol);
1954
1945
 
1955
- function CircleLineMiterRender() {
1956
- _classCallCheck(this, CircleLineMiterRender);
1946
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
1947
+ function ShadowedPointSymbol(options) {
1948
+ _classCallCheck(this, ShadowedPointSymbol);
1957
1949
 
1958
- return _super.apply(this, arguments);
1950
+ return _super.call(this, options);
1959
1951
  }
1960
1952
 
1961
- _createClass(CircleLineMiterRender, [{
1962
- key: "usageSize",
1963
- get: function get() {
1964
- return this.miterSize + this.strokeWidth * 3;
1953
+ _createClass(ShadowedPointSymbol, [{
1954
+ key: "renderFunction",
1955
+ value: function renderFunction(feature, resolution, crs) {
1956
+ if (!(feature instanceof PointFeature.PointFeature)) return [];
1957
+ const {
1958
+ position
1959
+ } = feature.projectTo(crs);
1960
+ const pxPosition = [position[0] / resolution + (this.offset[0] || 0), -position[1] / resolution + (this.offset[1] || 0)];
1961
+ const shadowRender = this.getShadow(pxPosition, feature);
1962
+ const pointArc = this.getPoint(pxPosition, feature);
1963
+ return shadowRender ? [shadowRender, pointArc] : [pointArc];
1965
1964
  }
1966
1965
  }, {
1967
- key: "createRings",
1968
- value: function createRings(_ref, xMultiplier) {
1969
- let [x, y] = _ref;
1970
- return [[[x + (this.miterSize / 2 + this.strokeWidth) * xMultiplier, y]]];
1966
+ key: "getShadow",
1967
+ value: function getShadow(position, _feature) {
1968
+ return ShadowedPointSymbol.getShadowArc(position, this);
1971
1969
  }
1972
1970
  }, {
1973
- key: "createRender",
1974
- value: function createRender(miterRings) {
1975
- const isFilled = this.kind === exports.LineMiterKind.FilledCircle;
1976
- return new Poly.PolyRender(polygonCircleFromPoint(miterRings[0][0], this.miterSize), {
1977
- fillColor: isFilled ? this.color : 'transparent',
1978
- strokeColor: this.color,
1979
- strokeWidth: this.strokeWidth,
1971
+ key: "getPoint",
1972
+ value: function getPoint(position, _feature) {
1973
+ return ShadowedPointSymbol.getPointArc(position, this);
1974
+ }
1975
+ }], [{
1976
+ key: "getShadowArc",
1977
+ value: function getShadowArc(position, _ref) {
1978
+ let {
1979
+ strokeWidth = 2,
1980
+ shadowColor,
1981
+ shadowSize,
1982
+ size = 6
1983
+ } = _ref;
1984
+ return new Poly.PolyRender(polygonCircleFromPoint(position, size + strokeWidth + shadowSize), {
1985
+ fillColor: 'transparent',
1986
+ strokeColor: shadowColor,
1987
+ strokeWidth: shadowSize,
1980
1988
  enclosed: true
1981
1989
  });
1982
1990
  }
1983
- }]);
1984
-
1985
- return CircleLineMiterRender;
1986
- }(LineMiterRender);
1987
-
1988
- let SquareLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1989
- _inherits(SquareLineMiterRender, _LineMiterRender);
1990
-
1991
- var _super = /*#__PURE__*/_createSuper(SquareLineMiterRender);
1992
-
1993
- function SquareLineMiterRender() {
1994
- _classCallCheck(this, SquareLineMiterRender);
1995
-
1996
- return _super.apply(this, arguments);
1997
- }
1998
-
1999
- _createClass(SquareLineMiterRender, [{
2000
- key: "usageSize",
2001
- get: function get() {
2002
- return this.miterSize + this.strokeWidth;
2003
- }
2004
1991
  }, {
2005
- key: "createRings",
2006
- value: function createRings(_ref, xMultiplier) {
2007
- let [x, y] = _ref;
2008
- 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]]];
1992
+ key: "getPointArc",
1993
+ value: function getPointArc(position, _ref2) {
1994
+ let {
1995
+ strokeWidth,
1996
+ fillColor,
1997
+ strokeColor,
1998
+ size = 6
1999
+ } = _ref2;
2000
+ return new Poly.PolyRender(polygonCircleFromPoint(position, size), {
2001
+ fillColor,
2002
+ strokeColor,
2003
+ strokeWidth,
2004
+ enclosed: true
2005
+ });
2009
2006
  }
2010
2007
  }, {
2011
- key: "createRender",
2012
- value: function createRender(miterRings) {
2013
- const isFilled = this.kind === exports.LineMiterKind.FilledSquare;
2014
- return new Poly.PolyRender(miterRings, {
2015
- enclosed: true,
2016
- fillColor: isFilled ? this.color : void 0,
2017
- fillStyle: isFilled ? Poly.FillStyle.Color : Poly.FillStyle.None,
2018
- lineCap: 'square',
2019
- lineJoin: 'miter',
2020
- strokeColor: this.color,
2021
- strokeWidth: this.strokeWidth
2022
- });
2008
+ key: "getArcs",
2009
+ value: function getArcs(position, params) {
2010
+ const shadowRender = ShadowedPointSymbol.getShadowArc(position, params);
2011
+ const pointRender = ShadowedPointSymbol.getPointArc(position, params);
2012
+ return shadowRender ? [shadowRender, pointRender] : [pointRender];
2023
2013
  }
2024
2014
  }]);
2025
2015
 
2026
- return SquareLineMiterRender;
2027
- }(LineMiterRender);
2016
+ return ShadowedPointSymbol;
2017
+ }(Point.PointSymbol);
2028
2018
 
2029
- const getLineMiterRender = options => {
2030
- switch (options.kind) {
2031
- case exports.LineMiterKind.Arrow:
2032
- case exports.LineMiterKind.FilledArrow:
2033
- return new ArrowLineMiterRender(options);
2019
+ let ShadowedPolySymbol = /*#__PURE__*/function (_PolylineSymbol) {
2020
+ _inherits(ShadowedPolySymbol, _PolylineSymbol);
2034
2021
 
2035
- case exports.LineMiterKind.Square:
2036
- case exports.LineMiterKind.FilledSquare:
2037
- return new SquareLineMiterRender(options);
2022
+ var _super = /*#__PURE__*/_createSuper(ShadowedPolySymbol);
2038
2023
 
2039
- case exports.LineMiterKind.Circle:
2040
- case exports.LineMiterKind.FilledCircle:
2041
- return new CircleLineMiterRender(options);
2024
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2025
+ function ShadowedPolySymbol(options) {
2026
+ _classCallCheck(this, ShadowedPolySymbol);
2042
2027
 
2043
- default:
2044
- return null;
2028
+ return _super.call(this, options);
2045
2029
  }
2046
- };
2047
-
2048
- const updateRingForRightMiter = (ring, miterSize, isLastRing) => {
2049
- const reversedRing = ring.slice().reverse();
2050
2030
 
2051
- for (let i = 0; i < reversedRing.length; i++) {
2052
- const coordinates = reversedRing[i];
2031
+ _createClass(ShadowedPolySymbol, [{
2032
+ key: "renderFunction",
2033
+ value: function renderFunction(feature, resolution, crs) {
2034
+ if (!(feature instanceof Poly$1.Poly)) return [];
2053
2035
 
2054
- if (isLastRing && i === 0) {
2055
- reversedRing[i] = [coordinates[0] - miterSize, coordinates[1]];
2056
- }
2036
+ const coordinates = _get(_getPrototypeOf(ShadowedPolySymbol.prototype), "getRenderedCoordinates", this).call(this, feature, resolution, crs);
2057
2037
 
2058
- const nextCoordinates = reversedRing[i - 1];
2038
+ const polyRender = this.getPolyRender(coordinates, feature);
2039
+ const shadowRender = this.getShadow(coordinates, feature);
2040
+ const vertexRenders = this.getVertexRenders(coordinates);
2041
+ let renders = [polyRender];
2059
2042
 
2060
- if (nextCoordinates && nextCoordinates[0] < coordinates[0]) {
2061
- reversedRing[i] = [nextCoordinates[0] - Math.abs(nextCoordinates[0] - coordinates[0]), coordinates[1]];
2062
- }
2063
- }
2064
-
2065
- return reversedRing.reverse();
2066
- };
2067
-
2068
- const updateRingForLeftMiter = (ring, miterSize, isFirstRing) => {
2069
- const newRing = ring.slice();
2043
+ if (shadowRender) {
2044
+ renders = [shadowRender, polyRender];
2045
+ }
2070
2046
 
2071
- for (let i = 0; i < newRing.length; i++) {
2072
- const coordinates = newRing[i];
2047
+ if (vertexRenders) {
2048
+ renders = renders.concat(vertexRenders);
2049
+ }
2073
2050
 
2074
- if (i === 0 && isFirstRing) {
2075
- newRing[i] = [coordinates[0] + miterSize, coordinates[1]];
2051
+ return renders;
2076
2052
  }
2077
-
2078
- const prevCoordinates = newRing[i - 1];
2079
-
2080
- if (prevCoordinates && prevCoordinates[0] > coordinates[0]) {
2081
- newRing[i] = [prevCoordinates[0] + Math.abs(coordinates[0] - prevCoordinates[0]), coordinates[1]];
2053
+ }, {
2054
+ key: "getShadow",
2055
+ value: function getShadow(coordinates, _feature) {
2056
+ return new Poly.PolyRender(coordinates, {
2057
+ fillStyle: Poly.FillStyle.None,
2058
+ enclosed: this.enclose,
2059
+ strokeColor: this.shadowColor,
2060
+ strokeWidth: this.shadowSize,
2061
+ lineDash: this.lineDash
2062
+ });
2082
2063
  }
2083
- }
2064
+ }, {
2065
+ key: "getPolyRender",
2066
+ value: function getPolyRender(coordinates, _feature) {
2067
+ return new Poly.PolyRender(coordinates, {
2068
+ fillStyle: this.enclose ? Poly.FillStyle.Color : Poly.FillStyle.None,
2069
+ enclosed: this.enclose,
2070
+ fillColor: this.fillColor,
2071
+ strokeColor: this.strokeColor,
2072
+ strokeWidth: this.strokeWidth,
2073
+ lineDash: this.lineDash
2074
+ });
2075
+ }
2076
+ }, {
2077
+ key: "getVertexRenders",
2078
+ value: function getVertexRenders(coordinates) {
2079
+ if (!this.showVertex) return;
2080
+ const vertexCoordinates = coordinates.reduce((acc, curr) => {
2081
+ return acc.concat(curr);
2082
+ }, []);
2083
+ return vertexCoordinates.map(coord => getEditorPointRenderer(coord, {
2084
+ size: 6,
2085
+ strokeWidth: 2,
2086
+ shadowColor: this.shadowColor,
2087
+ strokeColor: this.strokeColor,
2088
+ shadowSize: this.vertexShadowSize !== undefined ? this.vertexShadowSize : 2,
2089
+ fillColor: '#ffffff'
2090
+ })).reduce((acc, curr) => acc.concat(curr), []);
2091
+ }
2092
+ }]);
2084
2093
 
2085
- return newRing;
2094
+ return ShadowedPolySymbol;
2095
+ }(PolylineSymbol.PolylineSymbol);
2096
+ const polySymbolParams = {
2097
+ strokeWidth: 2,
2098
+ strokeColor: '#e33600',
2099
+ shadowSize: 8,
2100
+ shadowColor: 'rgba(227, 54, 0, 0.3)'
2086
2101
  };
2087
-
2088
- const updateRingsForMiter = (rings, position, miterSize) => {
2089
- return rings.map((ring, ringIndex) => {
2090
- switch (position) {
2091
- case 'right':
2092
- return updateRingForRightMiter(ring, miterSize, ringIndex === rings.length - 1);
2093
-
2094
- default:
2095
- return updateRingForLeftMiter(ring, miterSize, ringIndex === 0);
2096
- }
2097
- });
2102
+ const measureSymbolParams = {
2103
+ strokeColor: '#ff6933',
2104
+ shadowSize: 0,
2105
+ vertexShadowSize: 0
2098
2106
  };
2107
+ const measureLengthSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
2108
+ enclose: false,
2109
+ showVertex: true
2110
+ }));
2111
+ const measureAreaSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
2112
+ fillColor: 'rgba(255, 105, 51, 0.25)',
2113
+ enclose: true,
2114
+ showVertex: true
2115
+ }));
2116
+ const snapSymbolParams = {
2117
+ size: 10,
2118
+ strokeWidth: 2,
2119
+ strokeColor: '#e33600',
2120
+ fillColor: '#ffffff',
2121
+ shadowColor: 'rgba(227, 54, 0, 0.3)',
2122
+ shadowSize: 3
2123
+ };
2124
+ const measurePolygonSnapSymbol = /*#__PURE__*/new ShadowedPointSymbol( /*#__PURE__*/_extends({}, snapSymbolParams, {
2125
+ strokeColor: '#ff6933',
2126
+ shadowSize: 0
2127
+ }));
2099
2128
 
2100
- const copyRings = rings => rings.map(ring => ring.map(coordinates => coordinates.slice()));
2101
- let SGisPolylineSymbol = /*#__PURE__*/function (_sPolylineSymbol) {
2102
- _inherits(SGisPolylineSymbol, _sPolylineSymbol);
2103
-
2104
- var _super = /*#__PURE__*/_createSuper(SGisPolylineSymbol);
2105
-
2106
- function SGisPolylineSymbol(originalSymbol) {
2107
- var _originalSymbol$strok, _originalSymbol$strok2;
2129
+ let SelectedPointSymbol = /*#__PURE__*/function (_ShadowedPointSymbol) {
2130
+ _inherits(SelectedPointSymbol, _ShadowedPointSymbol);
2108
2131
 
2109
- var _this;
2132
+ var _super = /*#__PURE__*/_createSuper(SelectedPointSymbol);
2110
2133
 
2111
- _classCallCheck(this, SGisPolylineSymbol);
2134
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2135
+ function SelectedPointSymbol(props) {
2136
+ _classCallCheck(this, SelectedPointSymbol);
2112
2137
 
2113
- _this = _super.call(this, {
2114
- // @ts-ignore
2115
- strokeColor: getHexColor(getParameterValue((_originalSymbol$strok = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok.color)),
2116
- strokeWidth: clamp( // @ts-ignore
2117
- getParameterValue((_originalSymbol$strok2 = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok2.width), PREVIEW_LIMITS.STROKE_WIDTH_MIN, PREVIEW_LIMITS.STROKE_WIDTH_MAX),
2118
- // @ts-ignore
2119
- lineDash: getLineDash(originalSymbol.stroke),
2120
- // @ts-ignore
2121
- lineCap: isDashedBrush(originalSymbol.stroke) ? 'square' : 'round'
2122
- });
2123
- _this.originalSymbol = originalSymbol;
2124
- return _this;
2138
+ return _super.call(this, props);
2125
2139
  }
2126
2140
 
2127
- _createClass(SGisPolylineSymbol, [{
2128
- key: "renderFunction",
2129
- value: function renderFunction(feature, resolution, crs) {
2130
- if (!isSimplePolylineSymbol(this.originalSymbol)) return _get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, feature, resolution, crs);
2131
- const {
2132
- ending,
2133
- beginningSize,
2134
- beginning,
2135
- endingSize
2136
- } = this.originalSymbol;
2137
- const renders = [];
2138
- const featureCopy = feature.clone();
2139
- const beginningMiterRender = getLineMiterRender({
2140
- color: this.strokeColor,
2141
- // @ts-ignore
2142
- kind: beginning,
2143
- position: 'left',
2144
- // @ts-ignore
2145
- size: beginningSize,
2146
- strokeWidth: this.strokeWidth
2147
- });
2148
- const endingMiterRender = getLineMiterRender({
2149
- color: this.strokeColor,
2150
- // @ts-ignore
2151
- kind: ending,
2152
- position: 'right',
2153
- // @ts-ignore
2154
- size: endingSize,
2155
- strokeWidth: this.strokeWidth
2156
- });
2157
-
2158
- if (beginningMiterRender) {
2159
- const updatedRings = updateRingsForMiter(featureCopy.rings, 'left', beginningMiterRender.usageSize);
2160
- const render = beginningMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
2161
- featureCopy.rings = updatedRings;
2162
- renders.push(render);
2141
+ _createClass(SelectedPointSymbol, [{
2142
+ key: "getShadow",
2143
+ value: function getShadow(position, feature) {
2144
+ if (feature.isSelected) {
2145
+ return _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getShadow", this).call(this, position, feature);
2163
2146
  }
2164
-
2165
- if (endingMiterRender) {
2166
- const updatedRings = updateRingsForMiter(featureCopy.rings, 'right', endingMiterRender.usageSize);
2167
- const render = endingMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
2168
- featureCopy.rings = updatedRings;
2169
- renders.push(render);
2170
- } // NOTE: линия должна быть в начале чтобы быть под митерами
2171
-
2172
-
2173
- renders.unshift(..._get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, featureCopy, resolution, crs));
2174
- return renders;
2175
2147
  }
2176
2148
  }, {
2177
- key: "clone",
2178
- value: function clone() {
2179
- return new SGisPolylineSymbol(this.originalSymbol);
2180
- }
2181
- }]);
2149
+ key: "getPoint",
2150
+ value: function getPoint(position, feature) {
2151
+ const pointRender = _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getPoint", this).call(this, position, feature);
2182
2152
 
2183
- return SGisPolylineSymbol;
2184
- }(PolylineSymbol.PolylineSymbol);
2153
+ if (feature.isSelected) {
2154
+ pointRender.strokeColor = this.selectedStrokeColor;
2155
+ pointRender.fillColor = this.selectedFillColor;
2156
+ }
2185
2157
 
2186
- let LabelSymbol = /*#__PURE__*/function (_DynamicPointSymbol) {
2187
- _inherits(LabelSymbol, _DynamicPointSymbol);
2158
+ return pointRender;
2159
+ }
2160
+ }]);
2188
2161
 
2189
- var _super = /*#__PURE__*/_createSuper(LabelSymbol);
2162
+ return SelectedPointSymbol;
2163
+ }(ShadowedPointSymbol);
2190
2164
 
2191
- function LabelSymbol(_temp) {
2192
- var _this;
2165
+ let SelectedPolySymbol = /*#__PURE__*/function (_ShadowedPolySymbol) {
2166
+ _inherits(SelectedPolySymbol, _ShadowedPolySymbol);
2193
2167
 
2194
- let {
2195
- component,
2196
- offset
2197
- } = _temp === void 0 ? {} : _temp;
2168
+ var _super = /*#__PURE__*/_createSuper(SelectedPolySymbol);
2198
2169
 
2199
- _classCallCheck(this, LabelSymbol);
2170
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2171
+ function SelectedPolySymbol(props) {
2172
+ _classCallCheck(this, SelectedPolySymbol);
2200
2173
 
2201
- _this = _super.call(this, {
2202
- offset
2203
- });
2204
- _this.component = component;
2205
- return _this;
2174
+ return _super.call(this, props);
2206
2175
  }
2207
2176
 
2208
- _createClass(LabelSymbol, [{
2209
- key: "_getFeatureNode",
2210
- value: function _getFeatureNode(feature) {
2211
- const node = document.createElement('div');
2212
- this.renderDom(feature.content, node);
2213
- return node;
2214
- }
2215
- }, {
2216
- key: "_updateFeatureNode",
2217
- value: function _updateFeatureNode(feature) {
2218
- this.renderDom(feature.content, this.getNode(feature));
2177
+ _createClass(SelectedPolySymbol, [{
2178
+ key: "getShadow",
2179
+ value: function getShadow(coordinates, feature) {
2180
+ if (feature.isSelected) {
2181
+ return _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getShadow", this).call(this, coordinates, feature);
2182
+ }
2219
2183
  }
2220
2184
  }, {
2221
- key: "renderDom",
2222
- value: function renderDom(content, node) {
2223
- if (!node) {
2224
- return;
2225
- }
2185
+ key: "getPolyRender",
2186
+ value: function getPolyRender(coordinates, feature) {
2187
+ const polyRender = _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getPolyRender", this).call(this, coordinates, feature);
2226
2188
 
2227
- const Component = this.component;
2189
+ if (feature.isSelected) {
2190
+ polyRender.fillColor = this.selectedFillColor;
2191
+ polyRender.strokeColor = this.selectedStrokeColor;
2228
2192
 
2229
- if (Component) {
2230
- ReactDOM.render(React__default.createElement(Component, {
2231
- content: content
2232
- }), node);
2233
- } else {
2234
- node.innerText = content;
2193
+ if (this.selectedStrokeWidth !== void 0) {
2194
+ polyRender.strokeWidth = this.selectedStrokeWidth;
2195
+ }
2235
2196
  }
2197
+
2198
+ return polyRender;
2236
2199
  }
2237
2200
  }]);
2238
2201
 
2239
- return LabelSymbol;
2240
- }(_Symbol.DynamicPointSymbol);
2202
+ return SelectedPolySymbol;
2203
+ }(ShadowedPolySymbol);
2241
2204
 
2242
- const defaultOffset = [8, -16];
2243
- const createLabelSymbol = props => {
2244
- const {
2245
- offset = defaultOffset,
2246
- renderLabel = _ref => {
2247
- let {
2248
- content
2249
- } = _ref;
2250
- return React__default.createElement("div", null, content);
2251
- },
2252
- onClose = undefined
2253
- } = props || {};
2254
- return new LabelSymbol({
2255
- offset,
2256
- component: _ref2 => {
2257
- let {
2258
- content
2259
- } = _ref2;
2260
- return renderLabel({
2261
- content,
2262
- onClose
2263
- });
2264
- }
2265
- });
2266
- };
2205
+ const selectedPoint = /*#__PURE__*/new SelectedPointSymbol({
2206
+ size: 8,
2207
+ strokeWidth: 2,
2208
+ strokeColor: 'rgba(255, 87, 34, 0.3)',
2209
+ fillColor: 'rgba(255, 255, 255, 0.65)',
2210
+ shadowColor: 'rgba(255, 87, 34, 0.3)',
2211
+ shadowSize: 3,
2212
+ selectedStrokeColor: '#ff5722',
2213
+ selectedFillColor: 'rgba(255, 255, 255, 0.65)'
2214
+ });
2215
+ const selectedPolyline = /*#__PURE__*/new SelectedPolySymbol({
2216
+ strokeWidth: 6,
2217
+ strokeColor: 'rgba(255, 87, 34, 0.2)',
2218
+ shadowSize: 8,
2219
+ shadowColor: 'rgba(255, 87, 34, 0.3)',
2220
+ selectedStrokeColor: '#ff5722',
2221
+ selectedStrokeWidth: 2
2222
+ });
2223
+ const selectedPolygon = /*#__PURE__*/new SelectedPolySymbol({
2224
+ strokeWidth: 2,
2225
+ strokeColor: 'rgba(255, 87, 34, 0.3)',
2226
+ shadowSize: 8,
2227
+ shadowColor: 'rgba(255, 87, 34, 0.3)',
2228
+ fillColor: 'rgba(255, 255, 255, 0.36)',
2229
+ enclose: true,
2230
+ selectedFillColor: 'rgba(255, 255, 255, 0.56)',
2231
+ selectedStrokeColor: '#ff5722'
2232
+ });
2267
2233
 
2268
- function createShadowRender(position, _ref) {
2234
+ const metersToPixels = (meters, _ref) => {
2269
2235
  let {
2270
- strokeWidth = 2,
2271
- shadowColor,
2272
- shadowSize,
2273
- size = 6
2236
+ painter,
2237
+ crs = Crs.geo
2274
2238
  } = _ref;
2275
- const shadowDiameter = size + strokeWidth + shadowSize;
2276
- return new Poly.PolyRender(polygonCircleFromPoint(position, shadowDiameter), {
2277
- fillColor: 'transparent',
2278
- strokeColor: shadowColor,
2279
- strokeWidth: shadowSize,
2280
- enclosed: true
2281
- });
2282
- }
2283
- function getEditorPointRenderer(position, _ref2) {
2284
- let {
2285
- strokeColor,
2286
- strokeWidth,
2287
- shadowColor,
2288
- fillColor,
2289
- shadowSize,
2290
- size = 0
2291
- } = _ref2;
2292
- return [createShadowRender(position, {
2293
- strokeWidth,
2294
- strokeColor,
2295
- shadowSize,
2296
- shadowColor,
2297
- size
2298
- }), new Poly.PolyRender(polygonCircleFromPoint(position, size), {
2299
- fillColor,
2300
- strokeColor,
2301
- strokeWidth,
2302
- enclosed: true
2303
- })];
2304
- }
2239
+ const {
2240
+ width
2241
+ } = painter;
2242
+ const zeroPoint = painter.getPointFromPxPosition(0, 0).projectTo(crs);
2243
+ const maxWidthPoint = painter.getPointFromPxPosition(width, 0).projectTo(crs);
2244
+ const widthDistance = geotools.distance(zeroPoint, maxWidthPoint);
2245
+ const pxK = width / (widthDistance || 1);
2246
+ return Math.round(meters * pxK);
2247
+ };
2305
2248
 
2306
- let ShadowedPointSymbol = /*#__PURE__*/function (_PointSymbol) {
2307
- _inherits(ShadowedPointSymbol, _PointSymbol);
2249
+ const defaultPathStyles = {
2250
+ strokeWidth: 2,
2251
+ strokeColor: 'rgb(0, 163, 245)',
2252
+ fillStyle: Poly.FillStyle.None
2253
+ };
2254
+ let SVGPoly = /*#__PURE__*/function (_Symbol) {
2255
+ _inherits(SVGPoly, _Symbol);
2308
2256
 
2309
- var _super = /*#__PURE__*/_createSuper(ShadowedPointSymbol);
2257
+ var _super = /*#__PURE__*/_createSuper(SVGPoly);
2310
2258
 
2311
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2312
- function ShadowedPointSymbol(options) {
2313
- _classCallCheck(this, ShadowedPointSymbol);
2259
+ function SVGPoly(_temp) {
2260
+ var _this;
2314
2261
 
2315
- return _super.call(this, options);
2262
+ let {
2263
+ redrawFeatureNode,
2264
+ pathStyles,
2265
+ circle,
2266
+ className,
2267
+ appendToSvg
2268
+ } = _temp === void 0 ? {} : _temp;
2269
+
2270
+ _classCallCheck(this, SVGPoly);
2271
+
2272
+ _this = _super.call(this);
2273
+ _this.container = document.createElement('div');
2274
+ _this.container.style.position = 'absolute';
2275
+ _this.redrawFeatureNode = redrawFeatureNode;
2276
+ _this.pathStyles = _extends({
2277
+ center: [0, 0],
2278
+ fillColor: 'none'
2279
+ }, pathStyles);
2280
+ _this.circle = circle;
2281
+ _this.className = className;
2282
+ _this.appendToSvg = appendToSvg;
2283
+ return _this;
2316
2284
  }
2317
2285
 
2318
- _createClass(ShadowedPointSymbol, [{
2286
+ _createClass(SVGPoly, [{
2319
2287
  key: "renderFunction",
2320
2288
  value: function renderFunction(feature, resolution, crs) {
2321
- if (!(feature instanceof PointFeature.PointFeature)) return [];
2322
- const {
2323
- position
2324
- } = feature.projectTo(crs);
2325
- const pxPosition = [position[0] / resolution + (this.offset[0] || 0), -position[1] / resolution + (this.offset[1] || 0)];
2326
- const shadowRender = this.getShadow(pxPosition, feature);
2327
- const pointArc = this.getPoint(pxPosition, feature);
2328
- return shadowRender ? [shadowRender, pointArc] : [pointArc];
2289
+ const coordinates = feature instanceof Poly$1.Poly ? new PolylineSymbol.PolylineSymbol().getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
2290
+ this.setCirclePxRaius(crs);
2291
+ this.container.innerHTML = '';
2292
+ const svg = this.setSvg(coordinates);
2293
+ svg && this.container.append(svg);
2294
+ feature.__dynamicSymbolRender = new Render.DynamicRender({
2295
+ node: this.container,
2296
+ update: (bbox, resolution) => this.update({
2297
+ bbox,
2298
+ resolution,
2299
+ feature,
2300
+ crs
2301
+ }),
2302
+ redraw: () => {
2303
+ this.redrawFeatureNode && this.redrawFeatureNode(feature);
2304
+ }
2305
+ });
2306
+
2307
+ this._setEventListeners(feature);
2308
+
2309
+ return [feature.__dynamicSymbolRender];
2329
2310
  }
2330
2311
  }, {
2331
- key: "getShadow",
2332
- value: function getShadow(position, _feature) {
2333
- return ShadowedPointSymbol.getShadowArc(position, this);
2312
+ key: "setCirclePxRaius",
2313
+ value: function setCirclePxRaius(crs) {
2314
+ if (this.circle && this.pathStyles) {
2315
+ var _this$circle;
2316
+
2317
+ this.pathStyles.radius = metersToPixels(this.circle.radius, {
2318
+ painter: this.circle.painter,
2319
+ crs
2320
+ }) + (((_this$circle = this.circle) == null ? void 0 : _this$circle.pxOffset) || 0);
2321
+ }
2334
2322
  }
2335
2323
  }, {
2336
- key: "getPoint",
2337
- value: function getPoint(position, _feature) {
2338
- return ShadowedPointSymbol.getPointArc(position, this);
2339
- }
2340
- }], [{
2341
- key: "getShadowArc",
2342
- value: function getShadowArc(position, _ref) {
2324
+ key: "update",
2325
+ value: function update(_ref) {
2326
+ var _this$pathStyles, _this$pathStyles2, _this$pathStyles3, _this$pathStyles4;
2327
+
2343
2328
  let {
2344
- strokeWidth = 2,
2345
- shadowColor,
2346
- shadowSize,
2347
- size = 6
2329
+ bbox,
2330
+ resolution,
2331
+ feature,
2332
+ crs
2348
2333
  } = _ref;
2349
- return new Poly.PolyRender(polygonCircleFromPoint(position, size + strokeWidth + shadowSize), {
2350
- fillColor: 'transparent',
2351
- strokeColor: shadowColor,
2352
- strokeWidth: shadowSize,
2353
- enclosed: true
2354
- });
2334
+ if (!feature) return;
2335
+ if (!bbox) bbox = feature.__lastBbox;
2336
+ if (!resolution) resolution = feature.__lastResolution;
2337
+ if (!bbox || !resolution || !feature.crs.canProjectTo(bbox.crs)) return;
2338
+
2339
+ if (feature.__lastResolution && resolution !== feature.__lastResolution) {
2340
+ const newCoordinates = feature instanceof Poly$1.Poly ? new PolylineSymbol.PolylineSymbol().getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
2341
+ this.setCirclePxRaius(crs);
2342
+ this.container.innerHTML = '';
2343
+ const svg = this.setSvg(newCoordinates);
2344
+ svg && this.container.append(svg);
2345
+ }
2346
+
2347
+ const polygon = feature.projectTo(bbox.crs);
2348
+ 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;
2349
+ const dx = Math.round((polygon.bbox.xMin - bbox.xMin) / resolution) - radiusOffset;
2350
+ const dy = Math.round((bbox.yMax - polygon.bbox.yMax) / resolution) - radiusOffset;
2351
+ this.container.style.left = dx.toString() + "px";
2352
+ this.container.style.top = dy.toString() + "px";
2353
+ feature.__lastBbox = bbox;
2354
+ feature.__lastResolution = resolution;
2355
2355
  }
2356
2356
  }, {
2357
- key: "getPointArc",
2358
- value: function getPointArc(position, _ref2) {
2359
- let {
2360
- strokeWidth,
2361
- fillColor,
2362
- strokeColor,
2363
- size = 6
2364
- } = _ref2;
2365
- return new Poly.PolyRender(polygonCircleFromPoint(position, size), {
2366
- fillColor,
2367
- strokeColor,
2368
- strokeWidth,
2369
- enclosed: true
2370
- });
2371
- }
2372
- }, {
2373
- key: "getArcs",
2374
- value: function getArcs(position, params) {
2375
- const shadowRender = ShadowedPointSymbol.getShadowArc(position, params);
2376
- const pointRender = ShadowedPointSymbol.getPointArc(position, params);
2377
- return shadowRender ? [shadowRender, pointRender] : [pointRender];
2378
- }
2379
- }]);
2380
-
2381
- return ShadowedPointSymbol;
2382
- }(Point.PointSymbol);
2383
-
2384
- let ShadowedPolySymbol = /*#__PURE__*/function (_PolylineSymbol) {
2385
- _inherits(ShadowedPolySymbol, _PolylineSymbol);
2386
-
2387
- var _super = /*#__PURE__*/_createSuper(ShadowedPolySymbol);
2388
-
2389
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2390
- function ShadowedPolySymbol(options) {
2391
- _classCallCheck(this, ShadowedPolySymbol);
2392
-
2393
- return _super.call(this, options);
2394
- }
2395
-
2396
- _createClass(ShadowedPolySymbol, [{
2397
- key: "renderFunction",
2398
- value: function renderFunction(feature, resolution, crs) {
2399
- if (!(feature instanceof Poly$1.Poly)) return [];
2400
-
2401
- const coordinates = _get(_getPrototypeOf(ShadowedPolySymbol.prototype), "getRenderedCoordinates", this).call(this, feature, resolution, crs);
2402
-
2403
- const polyRender = this.getPolyRender(coordinates, feature);
2404
- const shadowRender = this.getShadow(coordinates, feature);
2405
- const vertexRenders = this.getVertexRenders(coordinates);
2406
- let renders = [polyRender];
2357
+ key: "setSvg",
2358
+ value: function setSvg(coordinates) {
2359
+ const {
2360
+ lineCap,
2361
+ lineJoin,
2362
+ miterLimit,
2363
+ lineDash,
2364
+ dashOffset
2365
+ } = this.pathStyles || {};
2366
+ const svgRender = new SvgRender.SvgRender(_extends({
2367
+ coordinates
2368
+ }, defaultPathStyles, {
2369
+ appendToSvg: this.appendToSvg
2370
+ }, this.pathStyles));
2407
2371
 
2408
- if (shadowRender) {
2409
- renders = [shadowRender, polyRender];
2372
+ if (this.circle) {
2373
+ svgRender._setArcNode();
2374
+ } else {
2375
+ svgRender._setPolyNode();
2410
2376
  }
2411
2377
 
2412
- if (vertexRenders) {
2413
- renders = renders.concat(vertexRenders);
2414
- }
2378
+ let svgElement;
2379
+ svgRender.getNode((_, svg) => {
2380
+ svgElement = svg;
2381
+ this.className && svgElement.classList.add(this.className);
2382
+ const path = svgElement && svgElement.querySelector(this.circle ? 'circle' : 'path');
2415
2383
 
2416
- return renders;
2417
- }
2418
- }, {
2419
- key: "getShadow",
2420
- value: function getShadow(coordinates, _feature) {
2421
- return new Poly.PolyRender(coordinates, {
2422
- fillStyle: Poly.FillStyle.None,
2423
- enclosed: this.enclose,
2424
- strokeColor: this.shadowColor,
2425
- strokeWidth: this.shadowSize,
2426
- lineDash: this.lineDash
2384
+ if (path) {
2385
+ path.setAttribute('stroke-linecap', lineCap || 'round');
2386
+ path.setAttribute('stroke-linejoin', lineJoin || 'round');
2387
+ path.setAttribute('stroke-miterlimit', (miterLimit || 10).toString());
2388
+ path.setAttribute('stroke-dashoffset', (dashOffset || 0).toString());
2389
+
2390
+ if (this.circle) {
2391
+ path.setAttribute('stroke-dasharray', lineDash && lineDash.length > 0 ? lineDash.join(',') : '');
2392
+ }
2393
+ }
2427
2394
  });
2395
+ return svgElement;
2428
2396
  }
2429
2397
  }, {
2430
- key: "getPolyRender",
2431
- value: function getPolyRender(coordinates, _feature) {
2432
- return new Poly.PolyRender(coordinates, {
2433
- fillStyle: this.enclose ? Poly.FillStyle.Color : Poly.FillStyle.None,
2434
- enclosed: this.enclose,
2435
- fillColor: this.fillColor,
2436
- strokeColor: this.strokeColor,
2437
- strokeWidth: this.strokeWidth,
2438
- lineDash: this.lineDash
2398
+ key: "_setEventListeners",
2399
+ value: function _setEventListeners(dynamicFeature) {
2400
+ var _dynamicFeature$__dyn;
2401
+
2402
+ if (dynamicFeature.eventFlags === EventHandler.MouseEventFlags.None) return;
2403
+ const svgNode = dynamicFeature == null ? void 0 : (_dynamicFeature$__dyn = dynamicFeature.__dynamicSymbolRender) == null ? void 0 : _dynamicFeature$__dyn.node.querySelector(this.circle ? 'circle' : 'path');
2404
+ Object.keys(EventHandler.mouseEvents).forEach(eventName => {
2405
+ if (dynamicFeature.eventFlags & EventHandler.mouseEvents[eventName].flag) {
2406
+ domEvent.listenDomEvent(svgNode, EventHandler.mouseEvents[eventName].type, event => {
2407
+ dynamicFeature.fire(EventHandler.mouseEvents[eventName].type, {
2408
+ node: svgNode,
2409
+ browserEvent: event
2410
+ });
2411
+ });
2412
+ }
2439
2413
  });
2440
2414
  }
2441
- }, {
2442
- key: "getVertexRenders",
2443
- value: function getVertexRenders(coordinates) {
2444
- if (!this.showVertex) return;
2445
- const vertexCoordinates = coordinates.reduce((acc, curr) => {
2446
- return acc.concat(curr);
2447
- }, []);
2448
- return vertexCoordinates.map(coord => getEditorPointRenderer(coord, {
2449
- size: 6,
2450
- strokeWidth: 2,
2451
- shadowColor: this.shadowColor,
2452
- strokeColor: this.strokeColor,
2453
- shadowSize: this.vertexShadowSize !== undefined ? this.vertexShadowSize : 2,
2454
- fillColor: '#ffffff'
2455
- })).reduce((acc, curr) => acc.concat(curr), []);
2456
- }
2457
2415
  }]);
2458
2416
 
2459
- return ShadowedPolySymbol;
2460
- }(PolylineSymbol.PolylineSymbol);
2461
- const polySymbolParams = {
2462
- strokeWidth: 2,
2463
- strokeColor: '#e33600',
2464
- shadowSize: 8,
2465
- shadowColor: 'rgba(227, 54, 0, 0.3)'
2417
+ return SVGPoly;
2418
+ }(_Symbol.Symbol);
2419
+
2420
+ function isSGisPointSymbol(symbol) {
2421
+ return symbol instanceof Point.PointSymbol || symbol instanceof StaticImageSymbol.StaticImageSymbol || symbol instanceof Square.SquareSymbol || symbol instanceof MaskedImage.MaskedImage;
2422
+ }
2423
+ function isSGisImageSymbol(symbol) {
2424
+ return symbol instanceof StaticImageSymbol.StaticImageSymbol || symbol instanceof MaskedImage.MaskedImage;
2425
+ }
2426
+ function isSGisPolygonSymbol(symbol) {
2427
+ return symbol instanceof Simple.PolygonSymbol || symbol instanceof BrushFill.BrushFill || symbol instanceof ImageFill.ImageFill;
2428
+ }
2429
+ function isSGisPolylineSymbol(symbol) {
2430
+ return symbol instanceof PolylineSymbol.PolylineSymbol;
2431
+ }
2432
+ function isSGisH3Symbol(symbol) {
2433
+ return symbol instanceof H3Symbol.H3Symbol;
2434
+ }
2435
+ function isSGisClusterSymbol(symbol) {
2436
+ return !!symbol.singleObjectSymbol;
2437
+ }
2438
+
2439
+ /**
2440
+ * Моки фич для отображения превью символа
2441
+ * http://cf.everpoint.ru/pages/viewpage.action?pageId=45024217
2442
+ */
2443
+
2444
+ const viewBoxSize = 100;
2445
+ const pointFeature = /*#__PURE__*/new PointFeature.PointFeature([50, -50], {
2446
+ crs: Crs.plain
2447
+ });
2448
+ const lineFeature = /*#__PURE__*/new Polyline.Polyline([[0, -57], [26, -57], [40, -35], [60, -65], [74, -43], [100, -43]], {
2449
+ crs: Crs.plain
2450
+ });
2451
+ const polygonFeature = /*#__PURE__*/new Polygon.Polygon([[20, -20], [80, -20], [80, -80], [20, -80]], {
2452
+ crs: Crs.plain
2453
+ });
2454
+ const h3gridFeature = /*#__PURE__*/new H3Feature.H3Feature([[50, -15], [80, -33], [80, -67], [50, -85], [20, -67], [20, -33], [50, -15]], {
2455
+ crs: Crs.plain
2456
+ });
2457
+ const lineLegendFeature = /*#__PURE__*/new Polyline.Polyline([[0, -50], [100, -50]], {
2458
+ crs: Crs.plain
2459
+ });
2460
+ const polygonLegendFeature = /*#__PURE__*/new Polygon.Polygon([[20, -20], [80, -20], [80, -80], [20, -80]], {
2461
+ crs: Crs.plain
2462
+ });
2463
+ const polygonMapLegendFeature = /*#__PURE__*/new Polygon.Polygon([[50, 0], [100, -25], [100, -75], [50, -100], [0, -75], [0, -25]], {
2464
+ crs: Crs.plain
2465
+ });
2466
+ const MAP_LEGEND_FEATURES = {
2467
+ polygon: polygonMapLegendFeature
2466
2468
  };
2467
- const measureSymbolParams = {
2468
- strokeColor: '#ff6933',
2469
- shadowSize: 0,
2470
- vertexShadowSize: 0
2469
+ const LEGEND_FEATURES = {
2470
+ point: pointFeature,
2471
+ polyline: lineLegendFeature,
2472
+ polygon: polygonLegendFeature,
2473
+ h3grid: h3gridFeature
2471
2474
  };
2472
- const measureLengthSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
2473
- enclose: false,
2474
- showVertex: true
2475
- }));
2476
- const measureAreaSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
2477
- fillColor: 'rgba(255, 105, 51, 0.25)',
2478
- enclose: true,
2479
- showVertex: true
2480
- }));
2481
- const snapSymbolParams = {
2482
- size: 10,
2483
- strokeWidth: 2,
2484
- strokeColor: '#e33600',
2485
- fillColor: '#ffffff',
2486
- shadowColor: 'rgba(227, 54, 0, 0.3)',
2487
- shadowSize: 3
2475
+ const MOCK_FEATURES = {
2476
+ point: pointFeature,
2477
+ polyline: lineFeature,
2478
+ polygon: polygonFeature,
2479
+ h3grid: h3gridFeature
2488
2480
  };
2489
- const measurePolygonSnapSymbol = /*#__PURE__*/new ShadowedPointSymbol( /*#__PURE__*/_extends({}, snapSymbolParams, {
2490
- strokeColor: '#ff6933',
2491
- shadowSize: 0
2492
- }));
2493
2481
 
2494
- let SelectedPointSymbol = /*#__PURE__*/function (_ShadowedPointSymbol) {
2495
- _inherits(SelectedPointSymbol, _ShadowedPointSymbol);
2482
+ function getSymbolRenders(symbol, size, features) {
2483
+ if (size === void 0) {
2484
+ size = viewBoxSize;
2485
+ }
2496
2486
 
2497
- var _super = /*#__PURE__*/_createSuper(SelectedPointSymbol);
2487
+ if (features === void 0) {
2488
+ features = {};
2489
+ }
2498
2490
 
2499
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2500
- function SelectedPointSymbol(props) {
2501
- _classCallCheck(this, SelectedPointSymbol);
2491
+ const resolution = viewBoxSize / size;
2502
2492
 
2503
- return _super.call(this, props);
2493
+ const featuresToRender = _extends({}, MOCK_FEATURES, features);
2494
+
2495
+ if (isSGisPolygonSymbol(symbol)) {
2496
+ return symbol.renderFunctionAsync(featuresToRender.polygon, resolution, Crs.plain);
2504
2497
  }
2505
2498
 
2506
- _createClass(SelectedPointSymbol, [{
2507
- key: "getShadow",
2508
- value: function getShadow(position, feature) {
2509
- if (feature.isSelected) {
2510
- return _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getShadow", this).call(this, position, feature);
2511
- }
2512
- }
2513
- }, {
2514
- key: "getPoint",
2515
- value: function getPoint(position, feature) {
2516
- const pointRender = _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getPoint", this).call(this, position, feature);
2499
+ if (isSGisPolylineSymbol(symbol)) {
2500
+ return symbol.renderFunctionAsync(featuresToRender.polyline, resolution, Crs.plain);
2501
+ }
2517
2502
 
2518
- if (feature.isSelected) {
2519
- pointRender.strokeColor = this.selectedStrokeColor;
2520
- pointRender.fillColor = this.selectedFillColor;
2521
- }
2522
-
2523
- return pointRender;
2524
- }
2525
- }]);
2526
-
2527
- return SelectedPointSymbol;
2528
- }(ShadowedPointSymbol);
2529
-
2530
- let SelectedPolySymbol = /*#__PURE__*/function (_ShadowedPolySymbol) {
2531
- _inherits(SelectedPolySymbol, _ShadowedPolySymbol);
2532
-
2533
- var _super = /*#__PURE__*/_createSuper(SelectedPolySymbol);
2503
+ if (isSGisH3Symbol(symbol)) {
2504
+ return symbol.renderFunctionAsync(featuresToRender.h3grid, resolution, Crs.plain);
2505
+ }
2534
2506
 
2535
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2536
- function SelectedPolySymbol(props) {
2537
- _classCallCheck(this, SelectedPolySymbol);
2507
+ return symbol.renderFunctionAsync(featuresToRender.point, resolution, Crs.plain);
2508
+ }
2509
+ const getMapLegendSymbolRenders = function getMapLegendSymbolRenders(symbol, size) {
2510
+ if (size === void 0) {
2511
+ size = viewBoxSize;
2512
+ }
2538
2513
 
2539
- return _super.call(this, props);
2514
+ return getSymbolRenders(symbol, size, MAP_LEGEND_FEATURES);
2515
+ };
2516
+ const getLegendSymbolRenders = function getLegendSymbolRenders(symbol, size) {
2517
+ if (size === void 0) {
2518
+ size = viewBoxSize;
2540
2519
  }
2541
2520
 
2542
- _createClass(SelectedPolySymbol, [{
2543
- key: "getShadow",
2544
- value: function getShadow(coordinates, feature) {
2545
- if (feature.isSelected) {
2546
- return _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getShadow", this).call(this, coordinates, feature);
2547
- }
2548
- }
2549
- }, {
2550
- key: "getPolyRender",
2551
- value: function getPolyRender(coordinates, feature) {
2552
- const polyRender = _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getPolyRender", this).call(this, coordinates, feature);
2521
+ return getSymbolRenders(symbol, size, LEGEND_FEATURES);
2522
+ };
2553
2523
 
2554
- if (feature.isSelected) {
2555
- polyRender.fillColor = this.selectedFillColor;
2556
- polyRender.strokeColor = this.selectedStrokeColor;
2524
+ function renderSymbolToCanvas(renders, canvas) {
2525
+ renders.forEach(render => {
2526
+ canvas.draw(render);
2527
+ });
2528
+ }
2557
2529
 
2558
- if (this.selectedStrokeWidth !== void 0) {
2559
- polyRender.strokeWidth = this.selectedStrokeWidth;
2560
- }
2561
- }
2530
+ function deserializeSymbol(symbol) {
2531
+ switch (symbol.type) {
2532
+ case "h3grid":
2533
+ return deserializeH3Symbol(symbol);
2562
2534
 
2563
- return polyRender;
2564
- }
2565
- }]);
2535
+ case "svgPointSymbol":
2536
+ return deserializeSvgPointSymbol(symbol);
2566
2537
 
2567
- return SelectedPolySymbol;
2568
- }(ShadowedPolySymbol);
2538
+ case 'circlePointSymbol':
2539
+ return deserializePointSymbol(symbol);
2569
2540
 
2570
- const selectedPoint = /*#__PURE__*/new SelectedPointSymbol({
2571
- size: 8,
2572
- strokeWidth: 2,
2573
- strokeColor: 'rgba(255, 87, 34, 0.3)',
2574
- fillColor: 'rgba(255, 255, 255, 0.65)',
2575
- shadowColor: 'rgba(255, 87, 34, 0.3)',
2576
- shadowSize: 3,
2577
- selectedStrokeColor: '#ff5722',
2578
- selectedFillColor: 'rgba(255, 255, 255, 0.65)'
2579
- });
2580
- const selectedPolyline = /*#__PURE__*/new SelectedPolySymbol({
2581
- strokeWidth: 6,
2582
- strokeColor: 'rgba(255, 87, 34, 0.2)',
2583
- shadowSize: 8,
2584
- shadowColor: 'rgba(255, 87, 34, 0.3)',
2585
- selectedStrokeColor: '#ff5722',
2586
- selectedStrokeWidth: 2
2587
- });
2588
- const selectedPolygon = /*#__PURE__*/new SelectedPolySymbol({
2589
- strokeWidth: 2,
2590
- strokeColor: 'rgba(255, 87, 34, 0.3)',
2591
- shadowSize: 8,
2592
- shadowColor: 'rgba(255, 87, 34, 0.3)',
2593
- fillColor: 'rgba(255, 255, 255, 0.36)',
2594
- enclose: true,
2595
- selectedFillColor: 'rgba(255, 255, 255, 0.56)',
2596
- selectedStrokeColor: '#ff5722'
2597
- });
2541
+ case 'squarePointSymbol':
2542
+ return deserializeSquareSymbol(symbol);
2598
2543
 
2599
- const defaultPathStyles = {
2600
- strokeWidth: 2,
2601
- strokeColor: 'rgb(0, 163, 245)',
2602
- fillStyle: Poly.FillStyle.None
2603
- };
2604
- let SVGPoly = /*#__PURE__*/function (_Symbol) {
2605
- _inherits(SVGPoly, _Symbol);
2544
+ case 'maskedImagePointSymbol':
2545
+ return deserializeMaskedImageSymbol(symbol);
2606
2546
 
2607
- var _super = /*#__PURE__*/_createSuper(SVGPoly);
2547
+ case 'imagePointSymbol':
2548
+ return deserializeImagePointSymbol(symbol);
2608
2549
 
2609
- function SVGPoly(_temp) {
2610
- var _this;
2550
+ case 'polygonSymbol':
2551
+ return deserializePolygonSymbol(symbol);
2611
2552
 
2612
- let {
2613
- redrawFeatureNode,
2614
- pathStyles,
2615
- circle,
2616
- className,
2617
- appendToSvg
2618
- } = _temp === void 0 ? {} : _temp;
2553
+ case 'simplePolylineSymbol':
2554
+ case 'polylineSymbol':
2555
+ return deserializePolylineSymbol(symbol);
2619
2556
 
2620
- _classCallCheck(this, SVGPoly);
2557
+ case "clusterSymbol":
2558
+ return deserializeSymbol(symbol.singleObjectSymbol);
2621
2559
 
2622
- _this = _super.call(this);
2623
- _this.container = document.createElement('div');
2624
- _this.container.style.position = 'absolute';
2625
- _this.redrawFeatureNode = redrawFeatureNode;
2626
- _this.pathStyles = _extends({
2627
- center: [0, 0],
2628
- fillColor: 'none'
2629
- }, pathStyles);
2630
- _this.circle = circle;
2631
- _this.className = className;
2632
- _this.appendToSvg = appendToSvg;
2633
- return _this;
2560
+ default:
2561
+ return null;
2634
2562
  }
2563
+ }
2635
2564
 
2636
- _createClass(SVGPoly, [{
2637
- key: "renderFunction",
2638
- value: function renderFunction(feature, resolution, crs) {
2639
- const coordinates = feature instanceof Poly$1.Poly ? new PolylineSymbol.PolylineSymbol().getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
2640
- this.setCirclePxRaius(crs);
2641
- this.container.innerHTML = '';
2642
- const svg = this.setSvg(coordinates);
2643
- svg && this.container.append(svg);
2644
- feature.__dynamicSymbolRender = new Render.DynamicRender({
2645
- node: this.container,
2646
- update: (bbox, resolution) => this.update({
2647
- bbox,
2648
- resolution,
2649
- feature,
2650
- crs
2651
- }),
2652
- redraw: () => {
2653
- this.redrawFeatureNode && this.redrawFeatureNode(feature);
2654
- }
2655
- });
2565
+ function deserializeH3Symbol(symbol) {
2566
+ var _symbol$stroke, _symbol$stroke2, _symbol$fill;
2656
2567
 
2657
- this._setEventListeners(feature);
2568
+ return new H3Symbol.H3Symbol(_extends({}, symbol, {
2569
+ cellSize: getParameterValue(symbol.cellSize),
2570
+ strokeWidth: getParameterValue(symbol == null ? void 0 : (_symbol$stroke = symbol.stroke) == null ? void 0 : _symbol$stroke.width),
2571
+ strokeColor: getParameterValue(symbol == null ? void 0 : (_symbol$stroke2 = symbol.stroke) == null ? void 0 : _symbol$stroke2.color),
2572
+ fillColor: getParameterValue(symbol == null ? void 0 : (_symbol$fill = symbol.fill) == null ? void 0 : _symbol$fill.color)
2573
+ }));
2574
+ }
2658
2575
 
2659
- return [feature.__dynamicSymbolRender];
2660
- }
2661
- }, {
2662
- key: "setCirclePxRaius",
2663
- value: function setCirclePxRaius(crs) {
2664
- if (this.circle && this.pathStyles) {
2665
- var _this$circle;
2576
+ function deserializePointSymbol(symbol) {
2577
+ // @ts-ignore
2578
+ return new Point.PointSymbol(deserializePointSymbolParams(symbol));
2579
+ }
2666
2580
 
2667
- this.pathStyles.radius = metersToPixels(this.circle.radius, {
2668
- painter: this.circle.painter,
2669
- crs
2670
- }) + (((_this$circle = this.circle) == null ? void 0 : _this$circle.pxOffset) || 0);
2671
- }
2672
- }
2673
- }, {
2674
- key: "update",
2675
- value: function update(_ref) {
2676
- var _this$pathStyles, _this$pathStyles2, _this$pathStyles3, _this$pathStyles4;
2581
+ const getOffsetParameterValue = offset => [getParameterValue(offset == null ? void 0 : offset[0]), getParameterValue(offset == null ? void 0 : offset[1])];
2677
2582
 
2678
- let {
2679
- bbox,
2680
- resolution,
2681
- feature,
2682
- crs
2683
- } = _ref;
2684
- if (!feature) return;
2685
- if (!bbox) bbox = feature.__lastBbox;
2686
- if (!resolution) resolution = feature.__lastResolution;
2687
- if (!bbox || !resolution || !feature.crs.canProjectTo(bbox.crs)) return;
2583
+ function deserializeSvgPointSymbolParams(_ref) {
2584
+ let {
2585
+ type,
2586
+ data,
2587
+ size,
2588
+ offset,
2589
+ angle,
2590
+ background,
2591
+ figure
2592
+ } = _ref;
2593
+ return _extends({
2594
+ type: getParameterValue(type),
2595
+ data: getParameterValue(data),
2596
+ size: getParameterValue(size),
2597
+ offset: getOffsetParameterValue(offset),
2598
+ angle: getParameterValue(angle)
2599
+ }, background ? {
2600
+ background: _extends({}, background, {
2601
+ fillColor: deserializeColor(getParameterValue(background == null ? void 0 : background.fillColor)),
2602
+ strokeColor: deserializeColor(getParameterValue(background == null ? void 0 : background.strokeColor)),
2603
+ strokeWidth: getParameterValue(background == null ? void 0 : background.strokeWidth)
2604
+ })
2605
+ } : {}, figure ? {
2606
+ figure: _extends({}, figure, {
2607
+ fillColor: deserializeColor(getParameterValue(figure == null ? void 0 : figure.fillColor))
2608
+ })
2609
+ } : {});
2610
+ }
2688
2611
 
2689
- if (feature.__lastResolution && resolution !== feature.__lastResolution) {
2690
- const newCoordinates = feature instanceof Poly$1.Poly ? new PolylineSymbol.PolylineSymbol().getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
2691
- this.setCirclePxRaius(crs);
2692
- this.container.innerHTML = '';
2693
- const svg = this.setSvg(newCoordinates);
2694
- svg && this.container.append(svg);
2695
- }
2612
+ function deserializeSvgPointSymbol(symbol) {
2613
+ return new Point.PointSymbol(deserializeSvgPointSymbolParams(symbol));
2614
+ }
2696
2615
 
2697
- const polygon = feature.projectTo(bbox.crs);
2698
- 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;
2699
- const dx = Math.round((polygon.bbox.xMin - bbox.xMin) / resolution) - radiusOffset;
2700
- const dy = Math.round((bbox.yMax - polygon.bbox.yMax) / resolution) - radiusOffset;
2701
- this.container.style.left = dx.toString() + "px";
2702
- this.container.style.top = dy.toString() + "px";
2703
- feature.__lastBbox = bbox;
2704
- feature.__lastResolution = resolution;
2705
- }
2706
- }, {
2707
- key: "setSvg",
2708
- value: function setSvg(coordinates) {
2709
- const {
2710
- lineCap,
2711
- lineJoin,
2712
- miterLimit,
2713
- lineDash,
2714
- dashOffset
2715
- } = this.pathStyles || {};
2716
- const svgRender = new SvgRender.SvgRender(_extends({
2717
- coordinates
2718
- }, defaultPathStyles, {
2719
- appendToSvg: this.appendToSvg
2720
- }, this.pathStyles));
2721
-
2722
- if (this.circle) {
2723
- svgRender._setArcNode();
2724
- } else {
2725
- svgRender._setPolyNode();
2726
- }
2727
-
2728
- let svgElement;
2729
- svgRender.getNode((_, svg) => {
2730
- svgElement = svg;
2731
- this.className && svgElement.classList.add(this.className);
2732
- const path = svgElement && svgElement.querySelector(this.circle ? 'circle' : 'path');
2616
+ function deserializeSquareSymbol(symbol) {
2617
+ return new Square.SquareSymbol(_extends({}, deserializePointSymbolParams(symbol), {
2618
+ // @ts-ignore
2619
+ angle: getParameterValue(symbol.angle)
2620
+ }));
2621
+ }
2733
2622
 
2734
- if (path) {
2735
- path.setAttribute('stroke-linecap', lineCap || 'round');
2736
- path.setAttribute('stroke-linejoin', lineJoin || 'round');
2737
- path.setAttribute('stroke-miterlimit', (miterLimit || 10).toString());
2738
- path.setAttribute('stroke-dashoffset', (dashOffset || 0).toString());
2623
+ function deserializeMaskedImageSymbol(symbol) {
2624
+ return new MaskedImage.MaskedImage(_extends({}, symbol, {
2625
+ // @ts-ignore
2626
+ angle: getParameterValue(symbol.angle),
2627
+ // @ts-ignore
2628
+ width: getParameterValue(symbol.width),
2629
+ // @ts-ignore
2630
+ height: getParameterValue(symbol.height),
2631
+ // @ts-ignore
2632
+ anchorPoint: deserializeAnchor(symbol.offset),
2633
+ // @ts-ignore
2634
+ imageSource: deserializeBase64(symbol.image),
2635
+ // @ts-ignore
2636
+ maskSource: deserializeBase64(symbol.imageMask),
2637
+ // @ts-ignore
2638
+ maskColor: deserializeColor(getParameterValue(symbol.maskedColor))
2639
+ }));
2640
+ }
2739
2641
 
2740
- if (this.circle) {
2741
- path.setAttribute('stroke-dasharray', lineDash && lineDash.length > 0 ? lineDash.join(',') : '');
2742
- }
2743
- }
2744
- });
2745
- return svgElement;
2746
- }
2747
- }, {
2748
- key: "_setEventListeners",
2749
- value: function _setEventListeners(dynamicFeature) {
2750
- var _dynamicFeature$__dyn;
2642
+ function deserializeImagePointSymbol(symbol) {
2643
+ return new StaticImageSymbol.StaticImageSymbol(_extends({}, symbol, {
2644
+ // @ts-ignore
2645
+ angle: getParameterValue(symbol.angle),
2646
+ // @ts-ignore
2647
+ width: getParameterValue(symbol.width),
2648
+ // @ts-ignore
2649
+ height: getParameterValue(symbol.height),
2650
+ // @ts-ignore
2651
+ anchorPoint: deserializeAnchor(symbol.offset),
2652
+ // @ts-ignore
2653
+ source: deserializeBase64(symbol.image)
2654
+ }));
2655
+ }
2751
2656
 
2752
- if (dynamicFeature.eventFlags === EventHandler.MouseEventFlags.None) return;
2753
- const svgNode = dynamicFeature == null ? void 0 : (_dynamicFeature$__dyn = dynamicFeature.__dynamicSymbolRender) == null ? void 0 : _dynamicFeature$__dyn.node.querySelector(this.circle ? 'circle' : 'path');
2754
- Object.keys(EventHandler.mouseEvents).forEach(eventName => {
2755
- if (dynamicFeature.eventFlags & EventHandler.mouseEvents[eventName].flag) {
2756
- domEvent.listenDomEvent(svgNode, EventHandler.mouseEvents[eventName].type, event => {
2757
- dynamicFeature.fire(EventHandler.mouseEvents[eventName].type, {
2758
- node: svgNode,
2759
- browserEvent: event
2760
- });
2761
- });
2762
- }
2763
- });
2764
- }
2765
- }]);
2657
+ function deserializePolygonSymbol(symbol) {
2658
+ if (isPolygonHasPatternBrush(symbol)) {
2659
+ return new SGisImageFill(symbol);
2660
+ }
2766
2661
 
2767
- return SVGPoly;
2768
- }(_Symbol.Symbol);
2662
+ if (isPolygonHasHatchBrush(symbol)) {
2663
+ return new SGisBrushFill(symbol);
2664
+ }
2769
2665
 
2770
- function isSGisPointSymbol(symbol) {
2771
- return symbol instanceof Point.PointSymbol || symbol instanceof StaticImageSymbol.StaticImageSymbol || symbol instanceof Square.SquareSymbol || symbol instanceof MaskedImage.MaskedImage;
2666
+ return new SGisPolygonSymbol(symbol);
2772
2667
  }
2773
- function isSGisImageSymbol(symbol) {
2774
- return symbol instanceof StaticImageSymbol.StaticImageSymbol || symbol instanceof MaskedImage.MaskedImage;
2668
+
2669
+ function deserializePolylineSymbol(symbol) {
2670
+ return new SGisPolylineSymbol(symbol);
2775
2671
  }
2776
- function isSGisPolygonSymbol(symbol) {
2777
- return symbol instanceof Simple.PolygonSymbol || symbol instanceof BrushFill.BrushFill || symbol instanceof ImageFill.ImageFill;
2672
+
2673
+ function deserializePointSymbolParams(_ref2) {
2674
+ let {
2675
+ size,
2676
+ offset,
2677
+ strokeColor,
2678
+ strokeWidth,
2679
+ fillColor
2680
+ } = _ref2;
2681
+ return {
2682
+ size: getParameterValue(size),
2683
+ offset: deserializeAnchor(offset),
2684
+ strokeWidth: getParameterValue(strokeWidth),
2685
+ strokeColor: deserializeColor(getParameterValue(strokeColor)),
2686
+ fillColor: deserializeColor(getParameterValue(fillColor))
2687
+ };
2778
2688
  }
2779
- function isSGisPolylineSymbol(symbol) {
2780
- return symbol instanceof PolylineSymbol.PolylineSymbol;
2689
+
2690
+ function deserializeBase64(base) {
2691
+ return "data:image/png;base64," + base;
2781
2692
  }
2782
- function isSGisH3Symbol(symbol) {
2783
- return symbol instanceof H3Symbol.H3Symbol;
2693
+
2694
+ function deserializeAnchor(offset) {
2695
+ // @ts-ignore
2696
+ return offset.map(getParameterValue);
2784
2697
  }
2785
- function isSGisClusterSymbol(symbol) {
2786
- return !!symbol.singleObjectSymbol;
2698
+
2699
+ function deserializeColor(color$1) {
2700
+ return color$1 ? new color.Color(color$1).toString() : null;
2787
2701
  }
2788
2702
 
2789
- /**
2790
- * Моки фич для отображения превью символа
2791
- * http://cf.everpoint.ru/pages/viewpage.action?pageId=45024217
2792
- */
2703
+ const clampSymbol = (symbol, min, max) => {
2704
+ if (isSGisImageSymbol(symbol)) {
2705
+ symbol.width = clamp(symbol.width, min, max);
2706
+ symbol.height = clamp(symbol.height, min, max);
2707
+ } else if (isSGisPointSymbol(symbol)) {
2708
+ symbol.size = clamp(symbol.size, min, max);
2709
+ }
2793
2710
 
2794
- const viewBoxSize = 100;
2795
- const pointFeature = /*#__PURE__*/new PointFeature.PointFeature([50, -50], {
2796
- crs: Crs.plain
2797
- });
2798
- const lineFeature = /*#__PURE__*/new Polyline.Polyline([[0, -57], [26, -57], [40, -35], [60, -65], [74, -43], [100, -43]], {
2799
- crs: Crs.plain
2800
- });
2801
- const polygonFeature = /*#__PURE__*/new Polygon.Polygon([[20, -20], [80, -20], [80, -80], [20, -80]], {
2802
- crs: Crs.plain
2803
- });
2804
- const h3gridFeature = /*#__PURE__*/new H3Feature.H3Feature([[50, -15], [80, -33], [80, -67], [50, -85], [20, -67], [20, -33], [50, -15]], {
2805
- crs: Crs.plain
2806
- });
2807
- const lineLegendFeature = /*#__PURE__*/new Polyline.Polyline([[0, -50], [100, -50]], {
2808
- crs: Crs.plain
2809
- });
2810
- const polygonLegendFeature = /*#__PURE__*/new Polygon.Polygon([[20, -20], [80, -20], [80, -80], [20, -80]], {
2811
- crs: Crs.plain
2812
- });
2813
- const polygonMapLegendFeature = /*#__PURE__*/new Polygon.Polygon([[50, 0], [100, -25], [100, -75], [50, -100], [0, -75], [0, -25]], {
2814
- crs: Crs.plain
2815
- });
2816
- const MAP_LEGEND_FEATURES = {
2817
- polygon: polygonMapLegendFeature
2818
- };
2819
- const LEGEND_FEATURES = {
2820
- point: pointFeature,
2821
- polyline: lineLegendFeature,
2822
- polygon: polygonLegendFeature,
2823
- h3grid: h3gridFeature
2711
+ return symbol;
2824
2712
  };
2825
- const MOCK_FEATURES = {
2826
- point: pointFeature,
2827
- polyline: lineFeature,
2828
- polygon: polygonFeature,
2829
- h3grid: h3gridFeature
2713
+ function centerAlignSymbol(symbol) {
2714
+ if (isSGisImageSymbol(symbol)) {
2715
+ symbol.anchorPoint = [symbol.width / 2, symbol.height / 2];
2716
+ } else if (isSGisPointSymbol(symbol)) {
2717
+ symbol.offset = [0, 0];
2718
+ }
2719
+
2720
+ return symbol;
2721
+ }
2722
+ const adjustSymbol = (symbol, _ref) => {
2723
+ let {
2724
+ size
2725
+ } = _ref;
2726
+ return centerAlignSymbol(clampSymbol(symbol, 0, size));
2830
2727
  };
2831
2728
 
2832
- function getSymbolRenders(symbol, size, features) {
2833
- if (size === void 0) {
2834
- size = viewBoxSize;
2835
- }
2729
+ let EvergisFeature = /*#__PURE__*/function () {
2730
+ function EvergisFeature(feature) {
2731
+ _classCallCheck(this, EvergisFeature);
2836
2732
 
2837
- if (features === void 0) {
2838
- features = {};
2733
+ this.id = null;
2734
+ this.displayName = null;
2735
+ this.geometry = null;
2736
+ this.layerName = null;
2737
+ this.layerAlias = null;
2738
+ this.attributes = null;
2739
+ this.symbol = null;
2740
+ this.id = feature.id;
2741
+ this.displayName = feature.id;
2742
+ this.geometry = feature.geometry;
2743
+ this.layerName = feature.layer;
2744
+ this.layerAlias = feature.layer;
2745
+ this.attributes = getFeatureAttributes(feature.attributes);
2839
2746
  }
2840
2747
 
2841
- const resolution = viewBoxSize / size;
2842
-
2843
- const featuresToRender = _extends({}, MOCK_FEATURES, features);
2748
+ _createClass(EvergisFeature, [{
2749
+ key: "sGisFeature",
2750
+ value: function sGisFeature() {
2751
+ if (!this.geometry || !this.symbol) {
2752
+ return null;
2753
+ } // @ts-ignore
2844
2754
 
2845
- if (isSGisPolygonSymbol(symbol)) {
2846
- return symbol.renderFunctionAsync(featuresToRender.polygon, resolution, Crs.plain);
2847
- }
2848
2755
 
2849
- if (isSGisPolylineSymbol(symbol)) {
2850
- return symbol.renderFunctionAsync(featuresToRender.polyline, resolution, Crs.plain);
2851
- }
2756
+ const {
2757
+ type,
2758
+ coordinates,
2759
+ sr
2760
+ } = this.geometry;
2761
+ const crs = CRS_MAP[sr];
2852
2762
 
2853
- if (isSGisH3Symbol(symbol)) {
2854
- return symbol.renderFunctionAsync(featuresToRender.h3grid, resolution, Crs.plain);
2855
- }
2763
+ if (!crs) {
2764
+ return null;
2765
+ }
2856
2766
 
2857
- return symbol.renderFunctionAsync(featuresToRender.point, resolution, Crs.plain);
2858
- }
2859
- const getMapLegendSymbolRenders = function getMapLegendSymbolRenders(symbol, size) {
2860
- if (size === void 0) {
2861
- size = viewBoxSize;
2862
- }
2863
-
2864
- return getSymbolRenders(symbol, size, MAP_LEGEND_FEATURES);
2865
- };
2866
- const getLegendSymbolRenders = function getLegendSymbolRenders(symbol, size) {
2867
- if (size === void 0) {
2868
- size = viewBoxSize;
2869
- }
2870
-
2871
- return getSymbolRenders(symbol, size, LEGEND_FEATURES);
2872
- };
2767
+ switch (type) {
2768
+ case api.GeometryType.Point:
2769
+ return new PointFeature.PointFeature(coordinates, {
2770
+ symbol: selectedPoint,
2771
+ crs
2772
+ });
2873
2773
 
2874
- function renderSymbolToCanvas(renders, canvas) {
2875
- renders.forEach(render => {
2876
- canvas.draw(render);
2877
- });
2878
- }
2774
+ case api.GeometryType.Multipoint:
2775
+ return new MultiPoint.MultiPoint(coordinates, {
2776
+ symbol: selectedPoint,
2777
+ crs
2778
+ });
2879
2779
 
2880
- function deserializeSymbol(symbol) {
2881
- switch (symbol.type) {
2882
- case "h3grid":
2883
- return deserializeH3Symbol(symbol);
2780
+ case api.GeometryType.Polyline:
2781
+ return new Polyline.Polyline(coordinates, {
2782
+ symbol: selectedPolyline,
2783
+ crs
2784
+ });
2884
2785
 
2885
- case "svgPointSymbol":
2886
- return deserializeSvgPointSymbol(symbol);
2786
+ case api.GeometryType.Polygon:
2787
+ return new Polygon.Polygon(coordinates, {
2788
+ symbol: selectedPolygon,
2789
+ crs
2790
+ });
2887
2791
 
2888
- case 'circlePointSymbol':
2889
- return deserializePointSymbol(symbol);
2792
+ default:
2793
+ return null;
2794
+ }
2795
+ }
2796
+ }, {
2797
+ key: "extent",
2798
+ value: function extent() {
2799
+ const feature = this.sGisFeature();
2800
+ return feature && feature.bbox;
2801
+ }
2802
+ }]);
2890
2803
 
2891
- case 'squarePointSymbol':
2892
- return deserializeSquareSymbol(symbol);
2804
+ return EvergisFeature;
2805
+ }();
2893
2806
 
2894
- case 'maskedImagePointSymbol':
2895
- return deserializeMaskedImageSymbol(symbol);
2807
+ function evaluateCondition(condition$1, attributes) {
2808
+ try {
2809
+ const evaluator = new condition.ConditionEvaluator(attributes);
2810
+ const result = evaluator.evaluate(condition$1);
2896
2811
 
2897
- case 'imagePointSymbol':
2898
- return deserializeImagePointSymbol(symbol);
2812
+ if (result instanceof Error) {
2813
+ return null;
2814
+ }
2899
2815
 
2900
- case 'polygonSymbol':
2901
- return deserializePolygonSymbol(symbol);
2816
+ return result;
2817
+ } catch (_unused) {
2818
+ return null;
2819
+ }
2820
+ }
2902
2821
 
2903
- case 'simplePolylineSymbol':
2904
- case 'polylineSymbol':
2905
- return deserializePolylineSymbol(symbol);
2822
+ function getAttributeValue(attributes, attributeName) {
2823
+ const attributeMeta = attributes.find((_ref) => {
2824
+ let {
2825
+ name
2826
+ } = _ref;
2827
+ return name === attributeName;
2828
+ });
2829
+ return attributeMeta ? attributeMeta.value : null;
2830
+ }
2906
2831
 
2907
- case "clusterSymbol":
2908
- return deserializeSymbol(symbol.singleObjectSymbol);
2832
+ const getAttributeNameFromCondition = condition => new ClassificationCondition(condition).attributeName;
2833
+ const getAttributeNameFromClassified = values => values.length > 0 ? getAttributeNameFromCondition(values[0].condition) : null;
2909
2834
 
2910
- default:
2911
- return null;
2912
- }
2835
+ function findFeatureValue(parameterValues, _ref2) {
2836
+ let [name, value] = _ref2;
2837
+ return value !== null ? parameterValues.find((_ref3) => {
2838
+ let {
2839
+ condition
2840
+ } = _ref3;
2841
+ return value !== undefined && evaluateCondition(condition, {
2842
+ [name]: value
2843
+ });
2844
+ }) : null;
2913
2845
  }
2914
2846
 
2915
- function deserializeH3Symbol(symbol) {
2916
- var _symbol$stroke, _symbol$stroke2, _symbol$fill;
2917
-
2918
- return new H3Symbol.H3Symbol(_extends({}, symbol, {
2919
- cellSize: getParameterValue(symbol.cellSize),
2920
- strokeWidth: getParameterValue(symbol == null ? void 0 : (_symbol$stroke = symbol.stroke) == null ? void 0 : _symbol$stroke.width),
2921
- strokeColor: getParameterValue(symbol == null ? void 0 : (_symbol$stroke2 = symbol.stroke) == null ? void 0 : _symbol$stroke2.color),
2922
- fillColor: getParameterValue(symbol == null ? void 0 : (_symbol$fill = symbol.fill) == null ? void 0 : _symbol$fill.color)
2923
- }));
2847
+ function extractValuesAttribute(parameterValues, attributes) {
2848
+ const name = getAttributeNameFromClassified(parameterValues) || '';
2849
+ const value = name && getAttributeValue(attributes, name);
2850
+ return [name, value];
2924
2851
  }
2925
2852
 
2926
- function deserializePointSymbol(symbol) {
2853
+ function evaluateFeatureSymbol(attributes) {
2927
2854
  // @ts-ignore
2928
- return new Point.PointSymbol(deserializePointSymbolParams(symbol));
2929
- }
2855
+ function calc(result, _ref4) {
2856
+ let [parameterName, parameterValue] = _ref4;
2857
+ let newParameterValue;
2930
2858
 
2931
- const getOffsetParameterValue = offset => [getParameterValue(offset == null ? void 0 : offset[0]), getParameterValue(offset == null ? void 0 : offset[1])];
2859
+ if (isParameterByAttribute(parameterValue)) {
2860
+ const [attributeName, attributeValue] = extractValuesAttribute(parameterValue.values, attributes);
2861
+ const featureValue = findFeatureValue(parameterValue.values, [attributeName, attributeValue]);
2862
+ newParameterValue = featureValue ? featureValue.value : parameterValue.defaultValue;
2863
+ } else if (isObject(parameterValue)) {
2864
+ // @ts-ignore
2865
+ newParameterValue = Object.entries(parameterValue).reduce(calc, parameterValue);
2866
+ }
2932
2867
 
2933
- function deserializeSvgPointSymbolParams(_ref) {
2934
- let {
2935
- type,
2936
- data,
2937
- size,
2938
- offset,
2939
- angle,
2940
- background,
2941
- figure
2942
- } = _ref;
2943
- return _extends({
2944
- type: getParameterValue(type),
2945
- data: getParameterValue(data),
2946
- size: getParameterValue(size),
2947
- offset: getOffsetParameterValue(offset),
2948
- angle: getParameterValue(angle)
2949
- }, background ? {
2950
- background: _extends({}, background, {
2951
- fillColor: deserializeColor(getParameterValue(background == null ? void 0 : background.fillColor)),
2952
- strokeColor: deserializeColor(getParameterValue(background == null ? void 0 : background.strokeColor)),
2953
- strokeWidth: getParameterValue(background == null ? void 0 : background.strokeWidth)
2954
- })
2955
- } : {}, figure ? {
2956
- figure: _extends({}, figure, {
2957
- fillColor: deserializeColor(getParameterValue(figure == null ? void 0 : figure.fillColor))
2958
- })
2959
- } : {});
2960
- }
2868
+ return newParameterValue !== undefined ? _extends({}, result, {
2869
+ [parameterName]: newParameterValue
2870
+ }) : result;
2871
+ }
2961
2872
 
2962
- function deserializeSvgPointSymbol(symbol) {
2963
- return new Point.PointSymbol(deserializeSvgPointSymbolParams(symbol));
2873
+ return calc;
2964
2874
  }
2965
2875
 
2966
- function deserializeSquareSymbol(symbol) {
2967
- return new Square.SquareSymbol(_extends({}, deserializePointSymbolParams(symbol), {
2968
- // @ts-ignore
2969
- angle: getParameterValue(symbol.angle)
2970
- }));
2971
- }
2876
+ function findChildFeatureStyle(childStyles, attributes) {
2877
+ return (childStyles || []).find((_ref5) => {
2878
+ let {
2879
+ condition
2880
+ } = _ref5;
2881
+ const attributeName = condition && getAttributeNameFromCondition(condition);
2882
+ const attributeValue = attributeName && getAttributeValue(attributes, attributeName);
2972
2883
 
2973
- function deserializeMaskedImageSymbol(symbol) {
2974
- return new MaskedImage.MaskedImage(_extends({}, symbol, {
2975
- // @ts-ignore
2976
- angle: getParameterValue(symbol.angle),
2977
- // @ts-ignore
2978
- width: getParameterValue(symbol.width),
2979
- // @ts-ignore
2980
- height: getParameterValue(symbol.height),
2981
- // @ts-ignore
2982
- anchorPoint: deserializeAnchor(symbol.offset),
2983
- // @ts-ignore
2984
- imageSource: deserializeBase64(symbol.image),
2985
- // @ts-ignore
2986
- maskSource: deserializeBase64(symbol.imageMask),
2987
- // @ts-ignore
2988
- maskColor: deserializeColor(getParameterValue(symbol.maskedColor))
2989
- }));
2990
- }
2884
+ if (condition && attributeName && attributeValue !== undefined) {
2885
+ return evaluateCondition(condition, {
2886
+ [attributeName]: attributeValue
2887
+ });
2888
+ }
2991
2889
 
2992
- function deserializeImagePointSymbol(symbol) {
2993
- return new StaticImageSymbol.StaticImageSymbol(_extends({}, symbol, {
2994
- // @ts-ignore
2995
- angle: getParameterValue(symbol.angle),
2996
- // @ts-ignore
2997
- width: getParameterValue(symbol.width),
2998
- // @ts-ignore
2999
- height: getParameterValue(symbol.height),
3000
- // @ts-ignore
3001
- anchorPoint: deserializeAnchor(symbol.offset),
3002
- // @ts-ignore
3003
- source: deserializeBase64(symbol.image)
3004
- }));
2890
+ return false;
2891
+ }) || null;
3005
2892
  }
3006
-
3007
- function deserializePolygonSymbol(symbol) {
3008
- if (isPolygonHasPatternBrush(symbol)) {
3009
- return new SGisImageFill(symbol);
2893
+ function findChildFeatureSymbol(childStyles, attributes) {
2894
+ const featureStyle = findChildFeatureStyle(childStyles, attributes);
2895
+ return featureStyle ? featureStyle.symbol : null;
2896
+ }
2897
+ function getFeatureSymbol(style, attributes) {
2898
+ if (!style || !style.symbol) {
2899
+ return null;
3010
2900
  }
3011
2901
 
3012
- if (isPolygonHasHatchBrush(symbol)) {
3013
- return new SGisBrushFill(symbol);
2902
+ if (style.children !== null) {
2903
+ return findChildFeatureSymbol(style.children, attributes) || style.symbol;
3014
2904
  }
3015
2905
 
3016
- return new SGisPolygonSymbol(symbol);
2906
+ return Object.entries(style.symbol).reduce(evaluateFeatureSymbol(attributes), style.symbol);
3017
2907
  }
3018
2908
 
3019
- function deserializePolylineSymbol(symbol) {
3020
- return new SGisPolylineSymbol(symbol);
3021
- }
3022
-
3023
- function deserializePointSymbolParams(_ref2) {
3024
- let {
3025
- size,
3026
- offset,
3027
- strokeColor,
3028
- strokeWidth,
3029
- fillColor
3030
- } = _ref2;
3031
- return {
3032
- size: getParameterValue(size),
3033
- offset: deserializeAnchor(offset),
3034
- strokeWidth: getParameterValue(strokeWidth),
3035
- strokeColor: deserializeColor(getParameterValue(strokeColor)),
3036
- fillColor: deserializeColor(getParameterValue(fillColor))
3037
- };
3038
- }
3039
-
3040
- function deserializeBase64(base) {
3041
- return "data:image/png;base64," + base;
3042
- }
3043
-
3044
- function deserializeAnchor(offset) {
3045
- // @ts-ignore
3046
- return offset.map(getParameterValue);
3047
- }
3048
-
3049
- function deserializeColor(color$1) {
3050
- return color$1 ? new color.Color(color$1).toString() : null;
3051
- }
3052
-
3053
- const clampSymbol = (symbol, min, max) => {
3054
- if (isSGisImageSymbol(symbol)) {
3055
- symbol.width = clamp(symbol.width, min, max);
3056
- symbol.height = clamp(symbol.height, min, max);
3057
- } else if (isSGisPointSymbol(symbol)) {
3058
- symbol.size = clamp(symbol.size, min, max);
3059
- }
3060
-
3061
- return symbol;
3062
- };
3063
- function centerAlignSymbol(symbol) {
3064
- if (isSGisImageSymbol(symbol)) {
3065
- symbol.anchorPoint = [symbol.width / 2, symbol.height / 2];
3066
- } else if (isSGisPointSymbol(symbol)) {
3067
- symbol.offset = [0, 0];
3068
- }
3069
-
3070
- return symbol;
3071
- }
3072
- const adjustSymbol = (symbol, _ref) => {
3073
- let {
3074
- size
3075
- } = _ref;
3076
- return centerAlignSymbol(clampSymbol(symbol, 0, size));
3077
- };
3078
-
3079
- let EvergisFeature = /*#__PURE__*/function () {
3080
- function EvergisFeature(feature) {
3081
- _classCallCheck(this, EvergisFeature);
3082
-
3083
- this.id = null;
3084
- this.displayName = null;
3085
- this.geometry = null;
3086
- this.layerName = null;
3087
- this.layerAlias = null;
3088
- this.attributes = null;
3089
- this.symbol = null;
3090
- this.id = feature.id;
3091
- this.displayName = feature.id;
3092
- this.geometry = feature.geometry;
3093
- this.layerName = feature.layer;
3094
- this.layerAlias = feature.layer;
3095
- this.attributes = getFeatureAttributes(feature.attributes);
3096
- }
3097
-
3098
- _createClass(EvergisFeature, [{
3099
- key: "sGisFeature",
3100
- value: function sGisFeature() {
3101
- if (!this.geometry || !this.symbol) {
3102
- return null;
3103
- } // @ts-ignore
3104
-
3105
-
3106
- const {
3107
- type,
3108
- coordinates,
3109
- sr
3110
- } = this.geometry;
3111
- const crs = CRS_MAP[sr];
3112
-
3113
- if (!crs) {
3114
- return null;
3115
- }
3116
-
3117
- switch (type) {
3118
- case api.GeometryType.Point:
3119
- return new PointFeature.PointFeature(coordinates, {
3120
- symbol: selectedPoint,
3121
- crs
3122
- });
3123
-
3124
- case api.GeometryType.Multipoint:
3125
- return new MultiPoint.MultiPoint(coordinates, {
3126
- symbol: selectedPoint,
3127
- crs
3128
- });
3129
-
3130
- case api.GeometryType.Polyline:
3131
- return new Polyline.Polyline(coordinates, {
3132
- symbol: selectedPolyline,
3133
- crs
3134
- });
3135
-
3136
- case api.GeometryType.Polygon:
3137
- return new Polygon.Polygon(coordinates, {
3138
- symbol: selectedPolygon,
3139
- crs
3140
- });
3141
-
3142
- default:
3143
- return null;
3144
- }
3145
- }
3146
- }, {
3147
- key: "extent",
3148
- value: function extent() {
3149
- const feature = this.sGisFeature();
3150
- return feature && feature.bbox;
3151
- }
3152
- }]);
3153
-
3154
- return EvergisFeature;
3155
- }();
3156
-
3157
- function evaluateCondition(condition$1, attributes) {
3158
- try {
3159
- const evaluator = new condition.ConditionEvaluator(attributes);
3160
- const result = evaluator.evaluate(condition$1);
3161
-
3162
- if (result instanceof Error) {
3163
- return null;
3164
- }
3165
-
3166
- return result;
3167
- } catch (_unused) {
3168
- return null;
3169
- }
3170
- }
3171
-
3172
- function getAttributeValue(attributes, attributeName) {
3173
- const attributeMeta = attributes.find(_ref => {
3174
- let {
3175
- name
3176
- } = _ref;
3177
- return name === attributeName;
3178
- });
3179
- return attributeMeta ? attributeMeta.value : null;
3180
- }
3181
-
3182
- const getAttributeNameFromCondition = condition => new ClassificationCondition(condition).attributeName;
3183
- const getAttributeNameFromClassified = values => values.length > 0 ? getAttributeNameFromCondition(values[0].condition) : null;
3184
-
3185
- function findFeatureValue(parameterValues, _ref2) {
3186
- let [name, value] = _ref2;
3187
- return value !== null ? parameterValues.find(_ref3 => {
3188
- let {
3189
- condition
3190
- } = _ref3;
3191
- return value !== undefined && evaluateCondition(condition, {
3192
- [name]: value
3193
- });
3194
- }) : null;
3195
- }
3196
-
3197
- function extractValuesAttribute(parameterValues, attributes) {
3198
- const name = getAttributeNameFromClassified(parameterValues) || '';
3199
- const value = name && getAttributeValue(attributes, name);
3200
- return [name, value];
3201
- }
3202
-
3203
- function evaluateFeatureSymbol(attributes) {
3204
- // @ts-ignore
3205
- function calc(result, _ref4) {
3206
- let [parameterName, parameterValue] = _ref4;
3207
- let newParameterValue;
3208
-
3209
- if (isParameterByAttribute(parameterValue)) {
3210
- const [attributeName, attributeValue] = extractValuesAttribute(parameterValue.values, attributes);
3211
- const featureValue = findFeatureValue(parameterValue.values, [attributeName, attributeValue]);
3212
- newParameterValue = featureValue ? featureValue.value : parameterValue.defaultValue;
3213
- } else if (isObject(parameterValue)) {
3214
- // @ts-ignore
3215
- newParameterValue = Object.entries(parameterValue).reduce(calc, parameterValue);
3216
- }
3217
-
3218
- return newParameterValue !== undefined ? _extends({}, result, {
3219
- [parameterName]: newParameterValue
3220
- }) : result;
3221
- }
3222
-
3223
- return calc;
3224
- }
3225
-
3226
- function findChildFeatureStyle(childStyles, attributes) {
3227
- return (childStyles || []).find(_ref5 => {
3228
- let {
3229
- condition
3230
- } = _ref5;
3231
- const attributeName = condition && getAttributeNameFromCondition(condition);
3232
- const attributeValue = attributeName && getAttributeValue(attributes, attributeName);
3233
-
3234
- if (condition && attributeName && attributeValue !== undefined) {
3235
- return evaluateCondition(condition, {
3236
- [attributeName]: attributeValue
3237
- });
3238
- }
3239
-
3240
- return false;
3241
- }) || null;
3242
- }
3243
- function findChildFeatureSymbol(childStyles, attributes) {
3244
- const featureStyle = findChildFeatureStyle(childStyles, attributes);
3245
- return featureStyle ? featureStyle.symbol : null;
3246
- }
3247
- function getFeatureSymbol(style, attributes) {
3248
- if (!style || !style.symbol) {
3249
- return null;
3250
- }
3251
-
3252
- if (style.children !== null) {
3253
- return findChildFeatureSymbol(style.children, attributes) || style.symbol;
3254
- }
3255
-
3256
- return Object.entries(style.symbol).reduce(evaluateFeatureSymbol(attributes), style.symbol);
3257
- }
3258
-
3259
- let EvergisLayer = /*#__PURE__*/function () {
3260
- function EvergisLayer(service) {
3261
- _classCallCheck(this, EvergisLayer);
2909
+ let EvergisLayer = /*#__PURE__*/function () {
2910
+ function EvergisLayer(service) {
2911
+ _classCallCheck(this, EvergisLayer);
3262
2912
 
3263
2913
  this.name = null;
3264
2914
  this.titleAttribute = null;
@@ -3285,7 +2935,7 @@ let EvergisLayer = /*#__PURE__*/function () {
3285
2935
  feature.attributes = mergeAttributes(feature.attributes || [], this.attributes || []);
3286
2936
  feature.symbol = this.style && getFeatureSymbol(this.style, feature.attributes);
3287
2937
  feature.layerAlias = this.alias;
3288
- const titleAttribute = (feature.attributes || []).find(_ref => {
2938
+ const titleAttribute = (feature.attributes || []).find((_ref) => {
3289
2939
  let {
3290
2940
  name
3291
2941
  } = _ref;
@@ -3308,7 +2958,7 @@ const evaluateFeature = layers => feature => {
3308
2958
  };
3309
2959
 
3310
2960
  const OTHERS_TITLE = 'Другое';
3311
- const createLegendItem = _ref => {
2961
+ const createLegendItem = (_ref) => {
3312
2962
  let {
3313
2963
  attributes,
3314
2964
  renderTitle,
@@ -3354,7 +3004,7 @@ function createStyleLegend(style, config) {
3354
3004
  classificationManager,
3355
3005
  symbol
3356
3006
  } = style;
3357
- const items = classificationManager.filter(_ref => {
3007
+ const items = classificationManager.filter((_ref) => {
3358
3008
  let {
3359
3009
  parameter
3360
3010
  } = _ref;
@@ -3470,7 +3120,7 @@ const useMapLegend = (layer, config) => {
3470
3120
  };
3471
3121
 
3472
3122
  const LEGEND_SYMBOL_MAX_SIZE = 32;
3473
- const useLegendValueSymbol = _ref => {
3123
+ const useLegendValueSymbol = (_ref) => {
3474
3124
  let {
3475
3125
  parameter,
3476
3126
  parameterValue
@@ -3704,23 +3354,26 @@ function useFeatureLayer(_ref) {
3704
3354
  let {
3705
3355
  zIndex,
3706
3356
  isDisplayed = true,
3707
- features
3357
+ features,
3358
+ opacity
3708
3359
  } = _ref;
3709
3360
  const {
3710
3361
  map
3711
3362
  } = useMapContext();
3712
3363
  const layer = useProperty({
3713
3364
  factory: () => new FeatureLayer$1.FeatureLayer({
3714
- features
3365
+ features,
3366
+ opacity
3715
3367
  }),
3716
3368
  destructor: layer => map.indexOf(layer) !== -1 && map.removeLayer(layer),
3717
3369
  update: (layer, _ref2) => {
3718
3370
  let [features] = _ref2;
3719
3371
  layer.features = features;
3720
3372
  }
3721
- }, [features]);
3373
+ }, [features, opacity]);
3722
3374
  useLayerOrder(layer, zIndex);
3723
3375
  useLayerVisibility(layer, isDisplayed);
3376
+ useLayerOpacity(layer, opacity);
3724
3377
  return layer;
3725
3378
  }
3726
3379
 
@@ -3874,7 +3527,7 @@ function useMapWrapper() {
3874
3527
  return wrapperRef;
3875
3528
  }
3876
3529
 
3877
- const byScale = scale => _ref => {
3530
+ const byScale = scale => (_ref) => {
3878
3531
  let {
3879
3532
  zIndex
3880
3533
  } = _ref;
@@ -4073,7 +3726,7 @@ const useTooltip = function useTooltip(zIndex) {
4073
3726
 
4074
3727
  return reset;
4075
3728
  }, [reset, map, layer, zIndex]);
4076
- const onSetLabelFeature = React.useCallback(_ref => {
3729
+ const onSetLabelFeature = React.useCallback((_ref) => {
4077
3730
  let {
4078
3731
  point,
4079
3732
  position,
@@ -4237,7 +3890,7 @@ function useClusterLayer(_ref) {
4237
3890
  }
4238
3891
 
4239
3892
  const INIT_FEATURES = [];
4240
- const useEvergisSelect = _ref => {
3893
+ const useEvergisSelect = (_ref) => {
4241
3894
  let {
4242
3895
  onPick,
4243
3896
  onFeatures
@@ -4270,7 +3923,7 @@ function none() {
4270
3923
  return;
4271
3924
  }
4272
3925
 
4273
- const useDraggableMarker = _ref => {
3926
+ const useDraggableMarker = (_ref) => {
4274
3927
  let {
4275
3928
  position,
4276
3929
  onChange,
@@ -4392,7 +4045,7 @@ const useToggle = initial => {
4392
4045
  return [state, toggle, setState];
4393
4046
  };
4394
4047
 
4395
- const Symbol = _ref => {
4048
+ const Symbol = (_ref) => {
4396
4049
  let {
4397
4050
  symbol,
4398
4051
  size,
@@ -4413,19 +4066,19 @@ const Symbol = _ref => {
4413
4066
  };
4414
4067
 
4415
4068
  var _templateObject, _templateObject2;
4416
- const CompoundIcon = /*#__PURE__*/styled__default.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background: ", ";\n height: 32px;\n width: 32px;\n"])), _ref => {
4069
+ const CompoundIcon = /*#__PURE__*/styled__default.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background: ", ";\n height: 32px;\n width: 32px;\n"])), (_ref) => {
4417
4070
  let {
4418
4071
  geometryType,
4419
4072
  icons
4420
4073
  } = _ref;
4421
4074
  return "url(" + icons[geometryType] + ") center center / " + (geometryType === api.GeometryType.Polyline ? '2rem 1.3rem' : 'auto 1rem') + " no-repeat";
4422
4075
  });
4423
- const ClusterSymbol = /*#__PURE__*/styled__default.div(_templateObject2 || (_templateObject2 = /*#__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 => {
4076
+ const ClusterSymbol = /*#__PURE__*/styled__default.div(_templateObject2 || (_templateObject2 = /*#__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) => {
4424
4077
  let {
4425
4078
  color
4426
4079
  } = _ref2;
4427
4080
  return color;
4428
- }, _ref3 => {
4081
+ }, (_ref3) => {
4429
4082
  let {
4430
4083
  color
4431
4084
  } = _ref3;
@@ -4433,7 +4086,7 @@ const ClusterSymbol = /*#__PURE__*/styled__default.div(_templateObject2 || (_tem
4433
4086
  });
4434
4087
 
4435
4088
  const MAX_SIZE = 32;
4436
- const StyleSymbol = _ref => {
4089
+ const StyleSymbol = (_ref) => {
4437
4090
  let {
4438
4091
  symbol,
4439
4092
  size = MAX_SIZE,
@@ -4490,7 +4143,7 @@ const AttributeValueContainer = /*#__PURE__*/styled__default.div(_templateObject
4490
4143
  const SimpleAttribute = /*#__PURE__*/styled__default.div(_templateObject15 || (_templateObject15 = /*#__PURE__*/_taggedTemplateLiteralLoose([""])));
4491
4144
  const ValueLink = /*#__PURE__*/styled__default.a(_templateObject16 || (_templateObject16 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 0 0.25rem;\n color: #1fb3aa;\n text-decoration: none;\n"])));
4492
4145
 
4493
- const MailValue = _ref => {
4146
+ const MailValue = (_ref) => {
4494
4147
  let {
4495
4148
  mail
4496
4149
  } = _ref;
@@ -4501,7 +4154,7 @@ const MailValue = _ref => {
4501
4154
  }, mail);
4502
4155
  };
4503
4156
 
4504
- const PhoneValue = _ref => {
4157
+ const PhoneValue = (_ref) => {
4505
4158
  let {
4506
4159
  phone
4507
4160
  } = _ref;
@@ -4512,7 +4165,7 @@ const PhoneValue = _ref => {
4512
4165
  }, phone);
4513
4166
  };
4514
4167
 
4515
- const UrlValue = _ref => {
4168
+ const UrlValue = (_ref) => {
4516
4169
  let {
4517
4170
  url
4518
4171
  } = _ref;
@@ -4523,7 +4176,7 @@ const UrlValue = _ref => {
4523
4176
  }, url);
4524
4177
  };
4525
4178
 
4526
- const AttributeValue = _ref => {
4179
+ const AttributeValue = (_ref) => {
4527
4180
  let {
4528
4181
  attribute
4529
4182
  } = _ref;
@@ -4537,29 +4190,29 @@ const AttributeValue = _ref => {
4537
4190
  if (attributeValue.type === 2
4538
4191
  /* Url */
4539
4192
  ) {
4540
- return React__default.createElement(UrlValue, {
4541
- key: key,
4542
- url: punycodeDecode(value)
4543
- });
4544
- }
4193
+ return React__default.createElement(UrlValue, {
4194
+ key: key,
4195
+ url: punycodeDecode(value)
4196
+ });
4197
+ }
4545
4198
 
4546
4199
  if (attributeValue.type === 3
4547
4200
  /* Mail */
4548
4201
  ) {
4549
- return React__default.createElement(MailValue, {
4550
- key: key,
4551
- mail: value
4552
- });
4553
- }
4202
+ return React__default.createElement(MailValue, {
4203
+ key: key,
4204
+ mail: value
4205
+ });
4206
+ }
4554
4207
 
4555
4208
  if (attributeValue.type === 1
4556
4209
  /* Phone */
4557
4210
  ) {
4558
- return React__default.createElement(PhoneValue, {
4559
- key: key,
4560
- phone: value
4561
- });
4562
- }
4211
+ return React__default.createElement(PhoneValue, {
4212
+ key: key,
4213
+ phone: value
4214
+ });
4215
+ }
4563
4216
 
4564
4217
  return React__default.createElement(SimpleAttribute, {
4565
4218
  key: value
@@ -4575,7 +4228,7 @@ function punycodeDecode(domains) {
4575
4228
  }
4576
4229
  }
4577
4230
 
4578
- const EvergisCardAttribute = _ref => {
4231
+ const EvergisCardAttribute = (_ref) => {
4579
4232
  let {
4580
4233
  attribute,
4581
4234
  className
@@ -4587,7 +4240,7 @@ const EvergisCardAttribute = _ref => {
4587
4240
  }));
4588
4241
  };
4589
4242
 
4590
- const StyledCard = _ref => {
4243
+ const StyledCard = (_ref) => {
4591
4244
  let {
4592
4245
  features = [],
4593
4246
  className,
@@ -4633,7 +4286,7 @@ const StyledCard = _ref => {
4633
4286
  };
4634
4287
 
4635
4288
  const _excluded$1 = ["renderCard", "className", "children"];
4636
- const EvergisCard = _ref => {
4289
+ const EvergisCard = (_ref) => {
4637
4290
  let {
4638
4291
  renderCard,
4639
4292
  className,
@@ -4685,7 +4338,7 @@ const toSgis = feature => feature.sGisFeature(); // TODO inner hooks???
4685
4338
 
4686
4339
  const useSGisFeatures = (features, currentIndex) => React.useMemo(() => features.map(toSgis).filter(truthly).map(setSelected(currentIndex)), [features, currentIndex]);
4687
4340
 
4688
- const EvergisSelectLayer = _ref => {
4341
+ const EvergisSelectLayer = (_ref) => {
4689
4342
  let {
4690
4343
  features,
4691
4344
  zIndex,
@@ -4730,7 +4383,7 @@ const TileLayer = props => {
4730
4383
  };
4731
4384
 
4732
4385
  const defaultZIndex = 200;
4733
- const EvergisSelect = _ref => {
4386
+ const EvergisSelect = (_ref) => {
4734
4387
  let {
4735
4388
  onPick,
4736
4389
  className,
@@ -4765,7 +4418,7 @@ const LegendSymbolTitle = /*#__PURE__*/styled__default.p(_templateObject3$1 || (
4765
4418
  const LegendValueContainer = /*#__PURE__*/styled__default.div(_templateObject4$1 || (_templateObject4$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n font-size: 0.75rem;\n\n ", " {\n padding-left: 0.5rem;\n }\n"])), LegendSymbolTitle);
4766
4419
  const LegendSectionHeader = /*#__PURE__*/styled__default.div(_templateObject5$1 || (_templateObject5$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 0.75rem;\n font-weight: 600;\n line-height: 1rem;\n"])));
4767
4420
 
4768
- const LegendSection = _ref => {
4421
+ const LegendSection = (_ref) => {
4769
4422
  let {
4770
4423
  item,
4771
4424
  renderLegendTitle,
@@ -4779,7 +4432,7 @@ var _templateObject$3, _templateObject2$3;
4779
4432
  const InputContainer = /*#__PURE__*/styled__default.div(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n border-radius: 0.125rem;\n box-sizing: border-box;\n border: 0.0625rem solid rgba(48, 69, 79, 0.12);\n margin-bottom: 0.5rem;\n \n i {\n color: rgba(48, 69, 79, 0.54);\n padding: 0.25rem;\n\n &:hover {\n cursor: pointer;\n color: rgba(48, 69, 79, 0.87);\n }\n }\n"])));
4780
4433
  const InputField = /*#__PURE__*/styled__default.input(_templateObject2$3 || (_templateObject2$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 100%;\n border: none;\n outline: none;\n font-size: 1rem;\n line-height: 1.1875rem;\n padding: 0 0.5rem;\n background-color: transparent;\n color: rgba(48, 69, 79, 0.87);\n"])));
4781
4434
 
4782
- const SearchInput = _ref => {
4435
+ const SearchInput = (_ref) => {
4783
4436
  let {
4784
4437
  onChange
4785
4438
  } = _ref;
@@ -4788,7 +4441,7 @@ const SearchInput = _ref => {
4788
4441
  }));
4789
4442
  };
4790
4443
 
4791
- const LegendSymbol = _ref => {
4444
+ const LegendSymbol = (_ref) => {
4792
4445
  let {
4793
4446
  parameter,
4794
4447
  parameterValue,
@@ -4806,7 +4459,7 @@ const LegendSymbol = _ref => {
4806
4459
  return React__default.createElement(React__default.Fragment, null, children(symbol));
4807
4460
  };
4808
4461
 
4809
- const LegendValue = _ref => {
4462
+ const LegendValue = (_ref) => {
4810
4463
  let {
4811
4464
  value,
4812
4465
  parameter,
@@ -4828,7 +4481,7 @@ const getNumberParam = (parameterValue, param) => {
4828
4481
  return typeof parameterValue === 'object' && param in parameterValue && typeof parameterValue[param] === 'number' ? parameterValue[param] : null;
4829
4482
  };
4830
4483
 
4831
- const getSymbolSize = _ref => {
4484
+ const getSymbolSize = (_ref) => {
4832
4485
  let {
4833
4486
  parameterValue,
4834
4487
  maxSize
@@ -4853,7 +4506,7 @@ const getSymbolSize = _ref => {
4853
4506
  }
4854
4507
  };
4855
4508
 
4856
- const Legend = _ref => {
4509
+ const Legend = (_ref) => {
4857
4510
  let {
4858
4511
  layer,
4859
4512
  children,
@@ -4897,7 +4550,7 @@ const Legend = _ref => {
4897
4550
  })))));
4898
4551
  };
4899
4552
 
4900
- const Map = _ref => {
4553
+ const Map = (_ref) => {
4901
4554
  let {
4902
4555
  className,
4903
4556
  position,
@@ -4969,27 +4622,27 @@ const FullscreenBtn = /*#__PURE__*/styled__default(icons.Icon)(_templateObject5$
4969
4622
  const MeasureBtn = /*#__PURE__*/styled__default(icons.Icon)(_templateObject6$1 || (_templateObject6$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin); // MeasureBtn.defaultProps = { kind: "measure_length" };
4970
4623
 
4971
4624
  const MapControl = /*#__PURE__*/styled__default.div(_templateObject7$1 || (_templateObject7$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border-radius: 0.15rem;\n background: rgba(28, 33, 48, 0.8);\n display: flex;\n align-items: center;\n justify-content: center;\n color: #fff;\n font-size: 1.5rem;\n cursor: pointer;\n height: auto;\n width: auto;\n padding: 0.25rem;\n"])));
4972
- const MapControls = /*#__PURE__*/styled__default.div(_templateObject8$1 || (_templateObject8$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n display: flex;\n flex-direction: ", ";\n\n ", "\n\n ", " {\n margin-bottom: ", ";\n margin-right: ", ";\n flex-direction: ", ";\n }\n"])), _ref => {
4625
+ const MapControls = /*#__PURE__*/styled__default.div(_templateObject8$1 || (_templateObject8$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n display: flex;\n flex-direction: ", ";\n\n ", "\n\n ", " {\n margin-bottom: ", ";\n margin-right: ", ";\n flex-direction: ", ";\n }\n"])), (_ref) => {
4973
4626
  let {
4974
4627
  vertical
4975
4628
  } = _ref;
4976
4629
  return vertical ? 'column' : 'row';
4977
- }, _ref2 => {
4630
+ }, (_ref2) => {
4978
4631
  let {
4979
4632
  placement
4980
4633
  } = _ref2;
4981
4634
  return placementMixin(placement);
4982
- }, MapControl, _ref3 => {
4635
+ }, MapControl, (_ref3) => {
4983
4636
  let {
4984
4637
  vertical
4985
4638
  } = _ref3;
4986
4639
  return vertical ? '0.5rem' : '0';
4987
- }, _ref4 => {
4640
+ }, (_ref4) => {
4988
4641
  let {
4989
4642
  vertical
4990
4643
  } = _ref4;
4991
4644
  return vertical ? '0' : '0.5rem';
4992
- }, _ref5 => {
4645
+ }, (_ref5) => {
4993
4646
  let {
4994
4647
  vertical
4995
4648
  } = _ref5;
@@ -5002,148 +4655,475 @@ const Measure = () => {
5002
4655
  }));
5003
4656
  };
5004
4657
 
5005
- const Search = () => {
5006
- return React__default.createElement(MapControl, null, React__default.createElement(SearchBtn, {
5007
- onClick: () => {}
5008
- }));
5009
- };
4658
+ const Search = () => {
4659
+ return React__default.createElement(MapControl, null, React__default.createElement(SearchBtn, {
4660
+ onClick: () => {}
4661
+ }));
4662
+ };
4663
+
4664
+ const Fullscreen = () => {
4665
+ return React__default.createElement(MapControl, null, React__default.createElement(FullscreenBtn, {
4666
+ onClick: () => {}
4667
+ }));
4668
+ };
4669
+
4670
+ var _templateObject$6, _templateObject2$6, _templateObject3$4, _templateObject4$4, _templateObject5$4, _templateObject6$2, _templateObject7$2, _templateObject8$2, _templateObject9$1, _templateObject10$1, _templateObject11$1, _templateObject12$1, _templateObject13$1;
4671
+ const MapLegendControl = /*#__PURE__*/styled__default(MapControl)(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n cursor: default;\n"])));
4672
+ const MapLegendContainer = /*#__PURE__*/styled__default.div(_templateObject2$6 || (_templateObject2$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n width: 12.5rem;\n box-sizing: border-box;\n\n canvas {\n height: 1.625rem;\n width: 1.625rem;\n }\n"])));
4673
+ const MapLegendHeader = /*#__PURE__*/styled__default(LegendSectionHeader)(_templateObject3$4 || (_templateObject3$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n max-width: 15rem;\n margin-bottom: 0.25rem;\n font-weight: 500;\n"])));
4674
+ const MapLegendValueDescr = /*#__PURE__*/styled__default.div(_templateObject4$4 || (_templateObject4$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-bottom: 0.25rem;\n font-size: 0.75rem;\n font-weight: 600;\n line-height: 1rem;\n"])));
4675
+ const MapLegendItem = /*#__PURE__*/styled__default.div(_templateObject5$4 || (_templateObject5$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex: 1;\n height: 1rem;\n background: ", ";\n border: 1px rgba(48, 69, 79, 0.1) solid;\n margin-right: -1px;\n \n ", "\n"])), (_ref) => {
4676
+ let {
4677
+ value
4678
+ } = _ref;
4679
+ return typeof value === "number" ? "none" : value;
4680
+ }, (_ref2) => {
4681
+ let {
4682
+ value
4683
+ } = _ref2;
4684
+ return !!value && typeof value === "number" && SizeLegendMixin(value);
4685
+ });
4686
+ const MapLegendOther = /*#__PURE__*/styled__default(MapLegendItem)(_templateObject6$2 || (_templateObject6$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex: none;\n width: 1rem;\n margin-left: 0.25rem;\n border-radius: 0.125rem;\n"])));
4687
+ const SizeOverlayLegendMixin = /*#__PURE__*/styled.css(_templateObject7$2 || (_templateObject7$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n width: 2rem;\n height: 2rem;\n \n ", ", ", " {\n flex: none;\n position: absolute;\n top: 0;\n left: 50%;\n width: inherit;\n height: inherit;\n margin-left: -1rem;\n \n :after {\n top: 0;\n margin-top: 0;\n }\n }\n"])), MapLegendItem, MapLegendOther);
4688
+ const MapLegendItems = /*#__PURE__*/styled__default.div(_templateObject8$2 || (_templateObject8$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n width: 100%;\n border-radius: 0.125rem;\n\n ", ";\n"])), (_ref3) => {
4689
+ let {
4690
+ overlay
4691
+ } = _ref3;
4692
+ return overlay && SizeOverlayLegendMixin;
4693
+ });
4694
+
4695
+ const SizeLegendMixin = function SizeLegendMixin(value) {
4696
+ if (value === void 0) {
4697
+ value = 0;
4698
+ }
4699
+
4700
+ return styled.css(_templateObject9$1 || (_templateObject9$1 = _taggedTemplateLiteralLoose(["\n position: relative;\n height: 2rem;\n background: none;\n border: none;\n margin-right: 0;\n \n :after {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 50%;\n border: 1px rgba(48, 69, 79, 0.28) solid;\n border-radius: 50%;\n margin: -", "px 0 0 -", "px;\n width: ", "px;\n height: ", "px;\n }\n"])), value / 2, value / 2, value, value);
4701
+ };
4702
+
4703
+ const MapLegendValues = /*#__PURE__*/styled__default.div(_templateObject10$1 || (_templateObject10$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n width: 100%;\n font-size: 0.75rem;\n color: rgba(48, 69, 79, 0.65);\n"])));
4704
+ const MapLegendValuesRange = /*#__PURE__*/styled__default.div(_templateObject11$1 || (_templateObject11$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n"])));
4705
+ const MapLegendValuesOther = /*#__PURE__*/styled__default(MapLegendOther)(_templateObject12$1 || (_templateObject12$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 0;\n text-align: center;\n overflow: visible;\n"])));
4706
+ const MapLegendExpandButton = /*#__PURE__*/styled__default.div(_templateObject13$1 || (_templateObject13$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n cursor: pointer;\n margin: 0.1rem 0 0.5rem;\n font-size: 0.625rem;\n color: #1FB3AA;\n"])));
4707
+
4708
+ const isNumeric = number => !isNaN(parseFloat(number)) && isFinite(number);
4709
+
4710
+ const getValueFromLegendTitle = (title, minOrMax) => {
4711
+ var _title$split;
4712
+
4713
+ if (title.includes(" - ")) {
4714
+ const result = title == null ? void 0 : title.split(" - ");
4715
+ return minOrMax === "min" ? result == null ? void 0 : result[0] : result == null ? void 0 : result[1];
4716
+ }
4717
+
4718
+ return (title == null ? void 0 : (_title$split = title.split(" ")) == null ? void 0 : _title$split.find(isNumeric)) || "";
4719
+ };
4720
+
4721
+ const MinimizedLegend = (_ref) => {
4722
+ var _currentValues$, _currentValues;
4723
+
4724
+ let {
4725
+ values,
4726
+ title,
4727
+ overlay
4728
+ } = _ref;
4729
+ const currentValues = [...values];
4730
+ const other = currentValues.pop();
4731
+ return React__default.createElement(React__default.Fragment, null, !!title && React__default.createElement(MapLegendValueDescr, null, title), React__default.createElement(MapLegendItems, {
4732
+ overlay: overlay
4733
+ }, currentValues.map(value => React__default.createElement(MapLegendItem, {
4734
+ key: value.title,
4735
+ title: value.title,
4736
+ value: value.parameterValue
4737
+ })), React__default.createElement(MapLegendOther, {
4738
+ title: "\u0414\u0440\u0443\u0433\u043E\u0435",
4739
+ value: other == null ? void 0 : other.parameterValue
4740
+ })), typeof (other == null ? void 0 : other.parameterValue) === "string" && React__default.createElement(MapLegendValues, null, React__default.createElement(MapLegendValuesRange, null, React__default.createElement("div", null, getValueFromLegendTitle((_currentValues$ = currentValues[0]) == null ? void 0 : _currentValues$.title, "max")), React__default.createElement("div", null, getValueFromLegendTitle((_currentValues = currentValues[currentValues.length - 1]) == null ? void 0 : _currentValues.title, "min"))), React__default.createElement(MapLegendValuesOther, null, "-")));
4741
+ };
4742
+
4743
+ const MapLegend = (_ref) => {
4744
+ let {
4745
+ layer,
4746
+ config,
4747
+ className
4748
+ } = _ref;
4749
+ const legend = useMapLegend(layer, config);
4750
+ const [isExpanded, toggleExpanded] = useToggle();
4751
+
4752
+ if (!legend) {
4753
+ return null;
4754
+ }
4755
+
4756
+ const {
4757
+ symbol,
4758
+ items
4759
+ } = legend;
4760
+ return React__default.createElement(LegendProvider, {
4761
+ symbol: symbol
4762
+ }, React__default.createElement(MapLegendControl, {
4763
+ className: className
4764
+ }, React__default.createElement(MapLegendHeader, null, layer == null ? void 0 : layer.alias), !!items.length && React__default.createElement(MapLegendContainer, null, isExpanded ? React__default.createElement(Legend, {
4765
+ layer: layer,
4766
+ config: config
4767
+ }) : React__default.createElement(React__default.Fragment, null, items.map(item => {
4768
+ var _symbol$fill, _item$parameter, _symbol$fill2;
4769
+
4770
+ return React__default.createElement(React.Fragment, {
4771
+ key: item.title
4772
+ }, React__default.createElement(MinimizedLegend, {
4773
+ values: item.values,
4774
+ defaultValue: (_symbol$fill = symbol.fill) == null ? void 0 : _symbol$fill.color,
4775
+ title: item.title !== (layer == null ? void 0 : layer.alias) ? item.title : ""
4776
+ }), ((_item$parameter = item.parameter) == null ? void 0 : _item$parameter.includes("size")) && React__default.createElement(MinimizedLegend, {
4777
+ values: item.values,
4778
+ defaultValue: (_symbol$fill2 = symbol.fill) == null ? void 0 : _symbol$fill2.color,
4779
+ overlay: true
4780
+ }));
4781
+ })), React__default.createElement(MapLegendExpandButton, {
4782
+ onClick: toggleExpanded
4783
+ }, isExpanded ? "Свернуть" : "Развернуть"))));
4784
+ };
4785
+
4786
+ const MAX_SIZE$2 = 100;
4787
+ const MapLegendSymbol = (_ref) => {
4788
+ let {
4789
+ value,
4790
+ parameter
4791
+ } = _ref;
4792
+ return React__default.createElement(LegendSymbol, {
4793
+ key: value.title,
4794
+ parameter: parameter,
4795
+ parameterValue: value.parameterValue
4796
+ }, symbol => React__default.createElement(Symbol, {
4797
+ render: getMapLegendSymbolRenders,
4798
+ symbol: symbol,
4799
+ size: MAX_SIZE$2
4800
+ }));
4801
+ };
4802
+
4803
+ const DEFAULT_FORMATTERS = {
4804
+ polygon: formatPolygonMeasure,
4805
+ length: formatLength
4806
+ };
4807
+
4808
+ const COORD_FRACTION = 6;
4809
+ const DEFAULT_LABEL_POSITION = [Infinity, Infinity];
4810
+ let BaseMeasureToolCreator = /*#__PURE__*/function (_PolylineControl) {
4811
+ _inherits(BaseMeasureToolCreator, _PolylineControl);
4812
+
4813
+ var _super = /*#__PURE__*/_createSuper(BaseMeasureToolCreator);
4814
+
4815
+ function BaseMeasureToolCreator(map, painter, params) {
4816
+ var _this;
4817
+
4818
+ _classCallCheck(this, BaseMeasureToolCreator);
4819
+
4820
+ _this = _super.call(this, map, params);
4821
+
4822
+ _this.cancel = () => {
4823
+ _this.fire('cancel');
4824
+ };
4825
+
4826
+ _this.painter = painter;
4827
+ _this.renderLabelSymbol = params.renderLabelSymbol;
4828
+ _this.formatters = params.formatters || DEFAULT_FORMATTERS;
4829
+ _this.areaSymbol = params.areaSymbol;
4830
+
4831
+ _this.on('pointAdd', _this.handlePointAdd); // @ts-ignore
4832
+
4833
+
4834
+ _this.on('change', _this.updateDistance);
4835
+
4836
+ return _this;
4837
+ }
4838
+
4839
+ _createClass(BaseMeasureToolCreator, [{
4840
+ key: "_handleMousemove",
4841
+ value: function _handleMousemove(event) {
4842
+ _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_handleMousemove", this).call(this, event);
4843
+
4844
+ this.drawPointOnMouseMove(event);
4845
+ }
4846
+ }, {
4847
+ key: "_activate",
4848
+ value: function _activate() {
4849
+ _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_activate", this).call(this);
4850
+
4851
+ this.addTempLabel();
4852
+ this.setCursor('pointer');
4853
+ }
4854
+ }, {
4855
+ key: "_deactivate",
4856
+ value: function _deactivate() {
4857
+ _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_deactivate", this).call(this);
4858
+
4859
+ this.removeCoordLabel();
4860
+ this.removeTempLabel();
4861
+ this.removeMeasureLabel();
4862
+ this.removeTempPolygon();
4863
+ this.setCursor('default');
4864
+ }
4865
+ }, {
4866
+ key: "handlePointAdd",
4867
+ value: function handlePointAdd() {
4868
+ const feature = this.activeFeature;
4869
+ if (!feature) return;
4870
+ const {
4871
+ rings,
4872
+ crs
4873
+ } = feature;
4874
+
4875
+ if (isPolylineLikePolygon(rings, this.map.resolution)) {
4876
+ this.finishDrawing();
4877
+ this.fire(new Control.DrawingFinishEvent(feature, new MouseEvent('mouseup')));
4878
+ return;
4879
+ }
4880
+
4881
+ if (rings[0].length === 2) {
4882
+ const projection = crs.projectionTo(Crs.geo);
4883
+ const point = rings[0][0];
4884
+ if (!projection) return;
4885
+ const [lat, long] = projection(point);
4886
+ this.removeTempLabel();
4887
+ this.addMeasureResultLabel();
4888
+ this.addCoordLabel(lat.toFixed(COORD_FRACTION) + ", " + long.toFixed(COORD_FRACTION), point);
4889
+ } else {
4890
+ this.removeCoordLabel();
4891
+ }
4892
+ }
4893
+ }, {
4894
+ key: "polygonPreview",
4895
+ value: function polygonPreview() {
4896
+ if (this.tempPolygon) {
4897
+ this._tempLayer && this._tempLayer.remove(this.tempPolygon);
4898
+ }
4899
+
4900
+ const feature = this.activeFeature;
4901
+ if (!feature) return;
4902
+ const {
4903
+ rings,
4904
+ crs
4905
+ } = feature;
4906
+ const polygonRings = [...rings[0]];
4907
+ polygonRings.shift();
4908
+ this.tempPolygon = new Polygon.Polygon(polygonRings, {
4909
+ crs
4910
+ });
4911
+ this.tempPolygon.symbol = this.areaSymbol || measureAreaSymbol;
4912
+ this.activeFeature && this.activeFeature.hide();
4913
+ this._tempLayer && this._tempLayer.add(this.tempPolygon);
4914
+ }
4915
+ }, {
4916
+ key: "removeTempPolygon",
4917
+ value: function removeTempPolygon() {
4918
+ if (this.tempPolygon) {
4919
+ this._tempLayer && this._tempLayer.remove(this.tempPolygon);
4920
+ delete this.tempPolygon;
4921
+ }
4922
+ }
4923
+ }, {
4924
+ key: "updateDistance",
4925
+ value: function updateDistance(event) {
4926
+ const feature = this.activeFeature;
4927
+ const {
4928
+ ringIndex,
4929
+ pointIndex
4930
+ } = event;
4931
+ if (!feature || ringIndex === null || pointIndex === null) return;
4932
+ const {
4933
+ rings,
4934
+ crs
4935
+ } = feature;
4936
+ const position = rings[ringIndex][pointIndex];
4937
+ const length = geotools.length(rings, crs);
4938
+ let content = this.formatters.length(length);
4939
+
4940
+ if (isPolylineLikePolygon(rings, this.map.resolution)) {
4941
+ this.polygonPreview();
4942
+ const area = geotools.area(rings, crs);
4943
+ content = this.formatters.polygon(area, length);
4944
+ } else if (this.tempPolygon) {
4945
+ feature.show();
4946
+ this.removeTempPolygon();
4947
+ }
4948
+
4949
+ if (this.measureResultLabel) {
4950
+ this.measureResultLabel.position = position;
4951
+ this.measureResultLabel.content = content;
4952
+ }
4953
+ }
4954
+ }, {
4955
+ key: "addTempLabel",
4956
+ value: function addTempLabel() {
4957
+ this.tempLabel = new Label.LabelFeature(DEFAULT_LABEL_POSITION, {
4958
+ content: 'Нажмите на карту, чтобы начать измерение',
4959
+ crs: this.map.crs,
4960
+ symbol: createLabelSymbol({
4961
+ renderLabel: this.renderLabelSymbol
4962
+ })
4963
+ });
4964
+ this._tempLayer && this._tempLayer.add(this.tempLabel);
4965
+ }
4966
+ }, {
4967
+ key: "addCoordLabel",
4968
+ value: function addCoordLabel(content, position) {
4969
+ this.coordLabel = new Label.LabelFeature(position, {
4970
+ content,
4971
+ crs: this.map.crs,
4972
+ symbol: createLabelSymbol({
4973
+ renderLabel: this.renderLabelSymbol,
4974
+ onClose: this.cancel
4975
+ })
4976
+ });
4977
+ this._tempLayer && this.coordLabel && this._tempLayer.add(this.coordLabel);
4978
+ }
4979
+ }, {
4980
+ key: "addMeasureResultLabel",
4981
+ value: function addMeasureResultLabel() {
4982
+ this.measureResultLabel = new Label.LabelFeature(DEFAULT_LABEL_POSITION, {
4983
+ crs: this.map.crs,
4984
+ symbol: createLabelSymbol({
4985
+ renderLabel: this.renderLabelSymbol
4986
+ })
4987
+ });
4988
+ this._tempLayer && this.measureResultLabel && this._tempLayer.add(this.measureResultLabel);
4989
+ }
4990
+ }, {
4991
+ key: "removeTempLabel",
4992
+ value: function removeTempLabel() {
4993
+ if (this.tempLabel) {
4994
+ this._tempLayer && this._tempLayer.remove(this.tempLabel);
4995
+ delete this.tempLabel;
4996
+ }
4997
+ }
4998
+ }, {
4999
+ key: "removeCoordLabel",
5000
+ value: function removeCoordLabel() {
5001
+ if (this.coordLabel) {
5002
+ this._tempLayer && this._tempLayer.remove(this.coordLabel);
5003
+ delete this.coordLabel;
5004
+ }
5005
+ }
5006
+ }, {
5007
+ key: "removeMeasureLabel",
5008
+ value: function removeMeasureLabel() {
5009
+ if (this.measureResultLabel) {
5010
+ this._tempLayer && this._tempLayer.remove(this.measureResultLabel);
5011
+ delete this.measureResultLabel;
5012
+ }
5013
+ }
5014
+ }, {
5015
+ key: "drawPointOnMouseMove",
5016
+ value: function drawPointOnMouseMove(event) {
5017
+ if (this.tempLabel) {
5018
+ this.tempLabel.position = event.point.position;
5019
+ }
5020
+ }
5021
+ }, {
5022
+ key: "setCursor",
5023
+ value: function setCursor(cursor) {
5024
+ const {
5025
+ wrapper
5026
+ } = this.painter;
5027
+
5028
+ if (wrapper && typeof wrapper !== 'string') {
5029
+ wrapper.style.cursor = cursor;
5030
+ }
5031
+ }
5032
+ }]);
5010
5033
 
5011
- const Fullscreen = () => {
5012
- return React__default.createElement(MapControl, null, React__default.createElement(FullscreenBtn, {
5013
- onClick: () => {}
5014
- }));
5015
- };
5034
+ return BaseMeasureToolCreator;
5035
+ }(PolylineControl.PolylineControl);
5016
5036
 
5017
- var _templateObject$6, _templateObject2$6, _templateObject3$4, _templateObject4$4, _templateObject5$4, _templateObject6$2, _templateObject7$2, _templateObject8$2, _templateObject9$1, _templateObject10$1, _templateObject11$1, _templateObject12$1, _templateObject13$1;
5018
- const MapLegendControl = /*#__PURE__*/styled__default(MapControl)(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n cursor: default;\n"])));
5019
- const MapLegendContainer = /*#__PURE__*/styled__default.div(_templateObject2$6 || (_templateObject2$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n width: 12.5rem;\n box-sizing: border-box;\n\n canvas {\n height: 1.625rem;\n width: 1.625rem;\n }\n"])));
5020
- const MapLegendHeader = /*#__PURE__*/styled__default(LegendSectionHeader)(_templateObject3$4 || (_templateObject3$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n max-width: 15rem;\n margin-bottom: 0.25rem;\n font-weight: 500;\n"])));
5021
- const MapLegendValueDescr = /*#__PURE__*/styled__default.div(_templateObject4$4 || (_templateObject4$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-bottom: 0.25rem;\n font-size: 0.75rem;\n font-weight: 600;\n line-height: 1rem;\n"])));
5022
- const MapLegendItem = /*#__PURE__*/styled__default.div(_templateObject5$4 || (_templateObject5$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex: 1;\n height: 1rem;\n background: ", ";\n border: 1px rgba(48, 69, 79, 0.1) solid;\n margin-right: -1px;\n \n ", "\n"])), _ref => {
5023
- let {
5024
- value
5025
- } = _ref;
5026
- return typeof value === "number" ? "none" : value;
5027
- }, _ref2 => {
5028
- let {
5029
- value
5030
- } = _ref2;
5031
- return !!value && typeof value === "number" && SizeLegendMixin(value);
5032
- });
5033
- const MapLegendOther = /*#__PURE__*/styled__default(MapLegendItem)(_templateObject6$2 || (_templateObject6$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex: none;\n width: 1rem;\n margin-left: 0.25rem;\n border-radius: 0.125rem;\n"])));
5034
- const SizeOverlayLegendMixin = /*#__PURE__*/styled.css(_templateObject7$2 || (_templateObject7$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n width: 2rem;\n height: 2rem;\n \n ", ", ", " {\n flex: none;\n position: absolute;\n top: 0;\n left: 50%;\n width: inherit;\n height: inherit;\n margin-left: -1rem;\n \n :after {\n top: 0;\n margin-top: 0;\n }\n }\n"])), MapLegendItem, MapLegendOther);
5035
- const MapLegendItems = /*#__PURE__*/styled__default.div(_templateObject8$2 || (_templateObject8$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n width: 100%;\n border-radius: 0.125rem;\n\n ", ";\n"])), _ref3 => {
5036
- let {
5037
- overlay
5038
- } = _ref3;
5039
- return overlay && SizeOverlayLegendMixin;
5040
- });
5037
+ let BaseMeasureToolEditor = /*#__PURE__*/function (_PolyEditor) {
5038
+ _inherits(BaseMeasureToolEditor, _PolyEditor);
5041
5039
 
5042
- const SizeLegendMixin = function SizeLegendMixin(value) {
5043
- if (value === void 0) {
5044
- value = 0;
5045
- }
5040
+ var _super = /*#__PURE__*/_createSuper(BaseMeasureToolEditor);
5046
5041
 
5047
- return styled.css(_templateObject9$1 || (_templateObject9$1 = _taggedTemplateLiteralLoose(["\n position: relative;\n height: 2rem;\n background: none;\n border: none;\n margin-right: 0;\n \n :after {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 50%;\n border: 1px rgba(48, 69, 79, 0.28) solid;\n border-radius: 50%;\n margin: -", "px 0 0 -", "px;\n width: ", "px;\n height: ", "px;\n }\n"])), value / 2, value / 2, value, value);
5048
- };
5042
+ function BaseMeasureToolEditor(map, painter, params) {
5043
+ var _this;
5049
5044
 
5050
- const MapLegendValues = /*#__PURE__*/styled__default.div(_templateObject10$1 || (_templateObject10$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n width: 100%;\n font-size: 0.75rem;\n color: rgba(48, 69, 79, 0.65);\n"])));
5051
- const MapLegendValuesRange = /*#__PURE__*/styled__default.div(_templateObject11$1 || (_templateObject11$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: space-between;\n width: 100%;\n"])));
5052
- const MapLegendValuesOther = /*#__PURE__*/styled__default(MapLegendOther)(_templateObject12$1 || (_templateObject12$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 0;\n text-align: center;\n overflow: visible;\n"])));
5053
- const MapLegendExpandButton = /*#__PURE__*/styled__default.div(_templateObject13$1 || (_templateObject13$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n cursor: pointer;\n margin: 0.1rem 0 0.5rem;\n font-size: 0.625rem;\n color: #1FB3AA;\n"])));
5045
+ _classCallCheck(this, BaseMeasureToolEditor);
5054
5046
 
5055
- const getValueFromLegendTitle = (title, minOrMax) => {
5056
- var _title$split;
5047
+ _this = _super.call(this, map, params);
5057
5048
 
5058
- if (title.includes(" - ")) {
5059
- const result = title == null ? void 0 : title.split(" - ");
5060
- return minOrMax === "min" ? result == null ? void 0 : result[0] : result == null ? void 0 : result[1];
5061
- }
5049
+ _this.measureResult = () => {
5050
+ const feature = _this.activeFeature;
5051
+ if (!feature) return null;
5052
+ const {
5053
+ rings,
5054
+ isEnclosed,
5055
+ crs
5056
+ } = feature;
5057
+ const pointsCount = rings[0].length;
5058
+ const position = rings[0][pointsCount - 1];
5059
+ const area = geotools.area(rings, crs);
5060
+ const length = geotools.length(rings, crs, isEnclosed);
5061
+ const content = isEnclosed ? _this.formatters.polygon(area, length) : _this.formatters.length(length);
5062
+ return {
5063
+ content,
5064
+ position
5065
+ };
5066
+ };
5062
5067
 
5063
- return (title == null ? void 0 : (_title$split = title.split(" ")) == null ? void 0 : _title$split.find(isNumeric)) || "";
5064
- };
5068
+ _this.removeFeature = () => {
5069
+ _this.fire('remove');
5070
+ };
5065
5071
 
5066
- const MinimizedLegend = _ref => {
5067
- var _currentValues$, _currentValues;
5072
+ _this.painter = painter;
5073
+ _this.renderLabelSymbol = params.renderLabelSymbol;
5074
+ _this.formatters = params.formatters || DEFAULT_FORMATTERS;
5068
5075
 
5069
- let {
5070
- values,
5071
- title,
5072
- overlay
5073
- } = _ref;
5074
- const currentValues = [...values];
5075
- const other = currentValues.pop();
5076
- return React__default.createElement(React__default.Fragment, null, !!title && React__default.createElement(MapLegendValueDescr, null, title), React__default.createElement(MapLegendItems, {
5077
- overlay: overlay
5078
- }, currentValues.map(value => React__default.createElement(MapLegendItem, {
5079
- key: value.title,
5080
- title: value.title,
5081
- value: value.parameterValue
5082
- })), React__default.createElement(MapLegendOther, {
5083
- title: "\u0414\u0440\u0443\u0433\u043E\u0435",
5084
- value: other == null ? void 0 : other.parameterValue
5085
- })), typeof (other == null ? void 0 : other.parameterValue) === "string" && React__default.createElement(MapLegendValues, null, React__default.createElement(MapLegendValuesRange, null, React__default.createElement("div", null, getValueFromLegendTitle((_currentValues$ = currentValues[0]) == null ? void 0 : _currentValues$.title, "max")), React__default.createElement("div", null, getValueFromLegendTitle((_currentValues = currentValues[currentValues.length - 1]) == null ? void 0 : _currentValues.title, "min"))), React__default.createElement(MapLegendValuesOther, null, "-")));
5086
- };
5076
+ _this.on('change', _this.updateMeasureResult);
5087
5077
 
5088
- const MapLegend = _ref => {
5089
- let {
5090
- layer,
5091
- config,
5092
- className
5093
- } = _ref;
5094
- const legend = useMapLegend(layer, config);
5095
- const [isExpanded, toggleExpanded] = useToggle();
5078
+ _this.on('edit', _this.updateMeasureResult);
5096
5079
 
5097
- if (!legend) {
5098
- return null;
5080
+ return _this;
5099
5081
  }
5100
5082
 
5101
- const {
5102
- symbol,
5103
- items
5104
- } = legend;
5105
- return React__default.createElement(LegendProvider, {
5106
- symbol: symbol
5107
- }, React__default.createElement(MapLegendControl, {
5108
- className: className
5109
- }, React__default.createElement(MapLegendHeader, null, layer == null ? void 0 : layer.alias), !!items.length && React__default.createElement(MapLegendContainer, null, isExpanded ? React__default.createElement(Legend, {
5110
- layer: layer,
5111
- config: config
5112
- }) : React__default.createElement(React__default.Fragment, null, items.map(item => {
5113
- var _symbol$fill, _item$parameter, _symbol$fill2;
5083
+ _createClass(BaseMeasureToolEditor, [{
5084
+ key: "_activate",
5085
+ value: function _activate() {
5086
+ _get(_getPrototypeOf(BaseMeasureToolEditor.prototype), "_activate", this).call(this);
5114
5087
 
5115
- return React__default.createElement(React.Fragment, {
5116
- key: item.title
5117
- }, React__default.createElement(MinimizedLegend, {
5118
- values: item.values,
5119
- defaultValue: (_symbol$fill = symbol.fill) == null ? void 0 : _symbol$fill.color,
5120
- title: item.title !== (layer == null ? void 0 : layer.alias) ? item.title : ""
5121
- }), ((_item$parameter = item.parameter) == null ? void 0 : _item$parameter.includes("size")) && React__default.createElement(MinimizedLegend, {
5122
- values: item.values,
5123
- defaultValue: (_symbol$fill2 = symbol.fill) == null ? void 0 : _symbol$fill2.color,
5124
- overlay: true
5125
- }));
5126
- })), React__default.createElement(MapLegendExpandButton, {
5127
- onClick: toggleExpanded
5128
- }, isExpanded ? "Свернуть" : "Развернуть"))));
5129
- };
5088
+ this.addMeasureResultLabel();
5089
+ }
5090
+ }, {
5091
+ key: "addMeasureResultLabel",
5092
+ value: function addMeasureResultLabel() {
5093
+ const measureResult = this.measureResult();
5094
+ if (measureResult === null) return;
5095
+ const {
5096
+ content,
5097
+ position
5098
+ } = measureResult;
5099
+ this.measureResultLabel = new Label.LabelFeature(position, {
5100
+ content,
5101
+ crs: this.map.crs,
5102
+ symbol: createLabelSymbol({
5103
+ onClose: this.removeFeature,
5104
+ renderLabel: this.renderLabelSymbol
5105
+ })
5106
+ });
5107
+ this._tempLayer && this._tempLayer.add(this.measureResultLabel);
5108
+ }
5109
+ }, {
5110
+ key: "updateMeasureResult",
5111
+ value: function updateMeasureResult() {
5112
+ if (this.measureResultLabel) {
5113
+ const measureResult = this.measureResult();
5114
+ if (measureResult === null) return;
5115
+ const {
5116
+ content,
5117
+ position
5118
+ } = measureResult;
5119
+ this.measureResultLabel.content = content;
5120
+ this.measureResultLabel.position = position;
5121
+ }
5122
+ }
5123
+ }]);
5130
5124
 
5131
- const MAX_SIZE$2 = 100;
5132
- const MapLegendSymbol = _ref => {
5133
- let {
5134
- value,
5135
- parameter
5136
- } = _ref;
5137
- return React__default.createElement(LegendSymbol, {
5138
- key: value.title,
5139
- parameter: parameter,
5140
- parameterValue: value.parameterValue
5141
- }, symbol => React__default.createElement(Symbol, {
5142
- render: getMapLegendSymbolRenders,
5143
- symbol: symbol,
5144
- size: MAX_SIZE$2
5145
- }));
5146
- };
5125
+ return BaseMeasureToolEditor;
5126
+ }(PolyEditor.PolyEditor);
5147
5127
 
5148
5128
  let MeasureTool = /*#__PURE__*/function (_React$Component) {
5149
5129
  _inherits(MeasureTool, _React$Component);
@@ -5333,7 +5313,7 @@ let MeasureTool = /*#__PURE__*/function (_React$Component) {
5333
5313
  }(React__default.Component);
5334
5314
 
5335
5315
  const _excluded$3 = ["isActive"];
5336
- const Measurer = _ref => {
5316
+ const Measurer = (_ref) => {
5337
5317
  let {
5338
5318
  isActive
5339
5319
  } = _ref,
@@ -5351,18 +5331,18 @@ const Measurer = _ref => {
5351
5331
 
5352
5332
  var _templateObject$7, _templateObject2$7, _templateObject3$5;
5353
5333
  const ScaleRulerContainer = /*#__PURE__*/styled__default.div(_templateObject$7 || (_templateObject$7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 2rem;\n cursor: default;\n display: flex;\n align-items: flex-end;\n padding: 0 0.5rem 0.5rem;\n box-sizing: border-box;\n"])));
5354
- const ScaleRulerBlock = /*#__PURE__*/styled__default.div(_templateObject2$7 || (_templateObject2$7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: flex-end;\n justify-content: center;\n width: ", ";\n height: 0.25rem;\n border: 0.0625rem solid white;\n border-top: 0;\n"])), _ref => {
5334
+ const ScaleRulerBlock = /*#__PURE__*/styled__default.div(_templateObject2$7 || (_templateObject2$7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: flex-end;\n justify-content: center;\n width: ", ";\n height: 0.25rem;\n border: 0.0625rem solid white;\n border-top: 0;\n"])), (_ref) => {
5355
5335
  let {
5356
5336
  width
5357
5337
  } = _ref;
5358
5338
  return width + "px";
5359
5339
  });
5360
- const TextContainer = /*#__PURE__*/styled__default.div(_templateObject3$5 || (_templateObject3$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 2rem;\n display: flex;\n justify-content: center;\n align-items: ", ";\n width: ", ";\n color: #fff;\n font-size: 1rem;\n cursor: default;\n padding: 0 0.5rem;\n"])), _ref2 => {
5340
+ const TextContainer = /*#__PURE__*/styled__default.div(_templateObject3$5 || (_templateObject3$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 2rem;\n display: flex;\n justify-content: center;\n align-items: ", ";\n width: ", ";\n color: #fff;\n font-size: 1rem;\n cursor: default;\n padding: 0 0.5rem;\n"])), (_ref2) => {
5361
5341
  let {
5362
5342
  alignEnd
5363
5343
  } = _ref2;
5364
5344
  return alignEnd ? 'flex-end' : 'center';
5365
- }, _ref3 => {
5345
+ }, (_ref3) => {
5366
5346
  let {
5367
5347
  width
5368
5348
  } = _ref3;
@@ -5387,7 +5367,7 @@ const ScaleRuler = () => {
5387
5367
  }, currentScale >= 1000 ? currentScale / 1000 + "km" : currentScale + "m")));
5388
5368
  };
5389
5369
 
5390
- const Zoom = _ref => {
5370
+ const Zoom = (_ref) => {
5391
5371
  let {
5392
5372
  children
5393
5373
  } = _ref;
@@ -5436,7 +5416,7 @@ const placementMixin$1 = function placementMixin(placement, distance, cornerSize
5436
5416
  return styled.css(_templateObject9$2 || (_templateObject9$2 = _taggedTemplateLiteralLoose(["\n ", "\n ", "\n ", "\n ", "\n"])), placement === 'top' && top(distance, cornerSize), placement === 'right' && right(distance, cornerSize), placement === 'left' && left(distance, cornerSize), placement === 'bottom' && bottom(distance, cornerSize));
5437
5417
  };
5438
5418
  const corner = /*#__PURE__*/styled.css(_templateObject10$2 || (_templateObject10$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n &:before {\n content: '';\n width: 0;\n height: 0;\n position: absolute;\n }\n"])));
5439
- const TooltipComponent = /*#__PURE__*/styled__default.div(_templateObject11$2 || (_templateObject11$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n z-index: 999;\n display: flex;\n font-size: 0.625rem;\n color: #fff;\n background-color: rgba(28, 33, 48, 0.8);\n padding: 0.4em 0.6em;\n border-radius: 2px;\n user-select: none;\n box-sizing: border-box;\n white-space: pre;\n ", "\n ", "\n"])), _ref => {
5419
+ const TooltipComponent = /*#__PURE__*/styled__default.div(_templateObject11$2 || (_templateObject11$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n z-index: 999;\n display: flex;\n font-size: 0.625rem;\n color: #fff;\n background-color: rgba(28, 33, 48, 0.8);\n padding: 0.4em 0.6em;\n border-radius: 2px;\n user-select: none;\n box-sizing: border-box;\n white-space: pre;\n ", "\n ", "\n"])), (_ref) => {
5440
5420
  let {
5441
5421
  placement,
5442
5422
  distance = '0.5rem',
@@ -5444,7 +5424,7 @@ const TooltipComponent = /*#__PURE__*/styled__default.div(_templateObject11$2 ||
5444
5424
  cornerSize = '0.25rem'
5445
5425
  } = _ref;
5446
5426
  return placementMixin$1(placement, distance, withArrow ? cornerSize : null);
5447
- }, _ref2 => {
5427
+ }, (_ref2) => {
5448
5428
  let {
5449
5429
  withArrow
5450
5430
  } = _ref2;
@@ -5458,7 +5438,7 @@ const {
5458
5438
  Consumer
5459
5439
  } = /*#__PURE__*/React.createContext([]); // TODO I just cant read that
5460
5440
 
5461
- const Tooltip = _ref => {
5441
+ const Tooltip = (_ref) => {
5462
5442
  let {
5463
5443
  features = [],
5464
5444
  map,
@@ -5497,7 +5477,7 @@ const Noop = () => React__default.createElement("div", {
5497
5477
  }
5498
5478
  });
5499
5479
 
5500
- const DraggableMarker = _ref => {
5480
+ const DraggableMarker = (_ref) => {
5501
5481
  let {
5502
5482
  position,
5503
5483
  onChange,
@@ -5511,6 +5491,21 @@ const DraggableMarker = _ref => {
5511
5491
  return React__default.createElement(React.Fragment, null);
5512
5492
  };
5513
5493
 
5494
+ const polygonCircleFromPoint = (center, diameter) => {
5495
+ const coordinates = [];
5496
+ const radius = diameter / 2;
5497
+ const endAngle = Math.PI * 2;
5498
+ const step = Math.max(Math.PI / 2 / radius, endAngle / 128);
5499
+ let start = 0;
5500
+ let end = endAngle;
5501
+
5502
+ for (let ang = start; ang < end; ang += step) {
5503
+ coordinates.push([Math.cos(ang) * radius + center[0], Math.sin(ang) * radius + center[1]]);
5504
+ }
5505
+
5506
+ return [coordinates];
5507
+ };
5508
+
5514
5509
  exports.ArrowLineMiterRender = ArrowLineMiterRender;
5515
5510
  exports.BaseMeasureToolCreator = BaseMeasureToolCreator;
5516
5511
  exports.BaseMeasureToolEditor = BaseMeasureToolEditor;