@evergis/react 2.0.111 → 2.0.113

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.
@@ -26,10 +26,6 @@ var PolylineSymbol = require('@evergis/sgis/es/symbols/PolylineSymbol');
26
26
  var Poly = require('@evergis/sgis/es/renders/Poly');
27
27
  var geotools = require('@evergis/sgis/es/geotools');
28
28
  var math = require('@evergis/sgis/es/utils/math');
29
- var PolylineControl = require('@evergis/sgis/es/controls/PolylineControl');
30
- var Label = require('@evergis/sgis/es/features/Label');
31
- var Control = require('@evergis/sgis/es/controls/Control');
32
- var PolyEditor = require('@evergis/sgis/es/controls/PolyEditor');
33
29
  var ReactDOM = _interopDefault(require('react-dom'));
34
30
  var _Symbol = require('@evergis/sgis/es/symbols/Symbol');
35
31
  var Poly$1 = require('@evergis/sgis/es/features/Poly');
@@ -42,6 +38,7 @@ var Square = require('@evergis/sgis/es/symbols/point/Square');
42
38
  var MaskedImage = require('@evergis/sgis/es/symbols/point/MaskedImage');
43
39
  var Canvas = require('@evergis/sgis/es/painters/DomPainter/Canvas');
44
40
  var commonEvents = require('@evergis/sgis/es/commonEvents');
41
+ var Label = require('@evergis/sgis/es/features/Label');
45
42
  var ClusterLayer$1 = require('@evergis/sgis/es/layers/ClusterLayer');
46
43
  var GridClusterProvider = require('@evergis/sgis/es/layers/clusterProviders/GridClusterProvider');
47
44
  var PointEditor = require('@evergis/sgis/es/controls/PointEditor');
@@ -51,6 +48,9 @@ var styled__default = _interopDefault(styled);
51
48
  var ui = require('@evergis/ui');
52
49
  var punycode = _interopDefault(require('punycode'));
53
50
  var TileLayer$1 = require('@evergis/sgis/es/layers/TileLayer');
51
+ var PolylineControl = require('@evergis/sgis/es/controls/PolylineControl');
52
+ var Control = require('@evergis/sgis/es/controls/Control');
53
+ var PolyEditor = require('@evergis/sgis/es/controls/PolyEditor');
54
54
 
55
55
  function _classCallCheck(instance, Constructor) {
56
56
  if (!(instance instanceof Constructor)) {
@@ -71,9 +71,6 @@ function _defineProperties(target, props) {
71
71
  function _createClass(Constructor, protoProps, staticProps) {
72
72
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
73
73
  if (staticProps) _defineProperties(Constructor, staticProps);
74
- Object.defineProperty(Constructor, "prototype", {
75
- writable: false
76
- });
77
74
  return Constructor;
78
75
  }
79
76
 
@@ -107,9 +104,6 @@ function _inherits(subClass, superClass) {
107
104
  configurable: true
108
105
  }
109
106
  });
110
- Object.defineProperty(subClass, "prototype", {
111
- writable: false
112
- });
113
107
  if (superClass) _setPrototypeOf(subClass, superClass);
114
108
  }
115
109
 
@@ -168,8 +162,6 @@ function _assertThisInitialized(self) {
168
162
  function _possibleConstructorReturn(self, call) {
169
163
  if (call && (typeof call === "object" || typeof call === "function")) {
170
164
  return call;
171
- } else if (call !== void 0) {
172
- throw new TypeError("Derived constructors may only return object or undefined");
173
165
  }
174
166
 
175
167
  return _assertThisInitialized(self);
@@ -203,7 +195,7 @@ function _superPropBase(object, property) {
203
195
  return object;
204
196
  }
205
197
 
206
- function _get() {
198
+ function _get(target, property, receiver) {
207
199
  if (typeof Reflect !== "undefined" && Reflect.get) {
208
200
  _get = Reflect.get;
209
201
  } else {
@@ -214,14 +206,14 @@ function _get() {
214
206
  var desc = Object.getOwnPropertyDescriptor(base, property);
215
207
 
216
208
  if (desc.get) {
217
- return desc.get.call(arguments.length < 3 ? target : receiver);
209
+ return desc.get.call(receiver);
218
210
  }
219
211
 
220
212
  return desc.value;
221
213
  };
222
214
  }
223
215
 
224
- return _get.apply(this, arguments);
216
+ return _get(target, property, receiver || target);
225
217
  }
226
218
 
227
219
  function _taggedTemplateLiteralLoose(strings, raw) {
@@ -250,7 +242,7 @@ const defaultApi = /*#__PURE__*/new api.Api({
250
242
  url: BASE_URL
251
243
  });
252
244
  const evergisContext = /*#__PURE__*/React.createContext(defaultApi);
253
- const EvergisProvider = _ref => {
245
+ const EvergisProvider = (_ref) => {
254
246
  let {
255
247
  api,
256
248
  children
@@ -268,7 +260,7 @@ const mapContext = /*#__PURE__*/React.createContext({
268
260
  map: defaultMap,
269
261
  painter: defaultPainter
270
262
  });
271
- const MapProvider = _ref => {
263
+ const MapProvider = (_ref) => {
272
264
  let {
273
265
  map,
274
266
  painter,
@@ -290,7 +282,7 @@ const tooltipContext = /*#__PURE__*/React.createContext({
290
282
  layer: defaultLayer,
291
283
  popupLayer: defaultPopupLayer
292
284
  });
293
- const TooltipProvider = _ref => {
285
+ const TooltipProvider = (_ref) => {
294
286
  let {
295
287
  layer,
296
288
  popupLayer,
@@ -307,7 +299,7 @@ const TooltipProvider = _ref => {
307
299
  const useTooltipContext = () => React.useContext(tooltipContext);
308
300
 
309
301
  const LegendContext = /*#__PURE__*/React.createContext(null);
310
- const LegendProvider = _ref => {
302
+ const LegendProvider = (_ref) => {
311
303
  let {
312
304
  symbol,
313
305
  children
@@ -319,7 +311,7 @@ const LegendProvider = _ref => {
319
311
  const useLegendContext = () => React.useContext(LegendContext);
320
312
 
321
313
  const evergisSelectContext = /*#__PURE__*/React.createContext([]);
322
- const EvergisSelectProvider = _ref => {
314
+ const EvergisSelectProvider = (_ref) => {
323
315
  let {
324
316
  layers,
325
317
  children
@@ -364,7 +356,7 @@ function useMapViewActions() {
364
356
  }, [map]);
365
357
  const zoomIn = React.useCallback(() => zoomTo(1), [zoomTo]);
366
358
  const zoomOut = React.useCallback(() => zoomTo(-1), [zoomTo]);
367
- const animateTo = React.useCallback(_ref => {
359
+ const animateTo = React.useCallback((_ref) => {
368
360
  let {
369
361
  position,
370
362
  resolution,
@@ -394,7 +386,7 @@ function useMapViewActions() {
394
386
  const {
395
387
  tileScheme
396
388
  } = map;
397
- let tileLevel = tileScheme.levels.find(_ref2 => {
389
+ let tileLevel = tileScheme.levels.find((_ref2) => {
398
390
  let {
399
391
  zIndex
400
392
  } = _ref2;
@@ -570,7 +562,7 @@ const formatStringAttribute = value => {
570
562
 
571
563
  const attributeValues = value.split(/[\s|]/).map(convertStringAttribute);
572
564
 
573
- if (attributeValues.every(_ref => {
565
+ if (attributeValues.every((_ref) => {
574
566
  let {
575
567
  type
576
568
  } = _ref;
@@ -578,7 +570,7 @@ const formatStringAttribute = value => {
578
570
  }
579
571
  /* String */
580
572
  )) {
581
- return [stringAttribute(attributeValues.map(_ref2 => {
573
+ return [stringAttribute(attributeValues.map((_ref2) => {
582
574
  let {
583
575
  value
584
576
  } = _ref2;
@@ -1055,7 +1047,7 @@ const getFeatureAttributeType = attributeValue => {
1055
1047
  };
1056
1048
  const getLayerAttributes = layerDefinition => {
1057
1049
  const attributes = layerDefinition && layerDefinition.attributes || {};
1058
- return Object.entries(attributes).map(_ref => {
1050
+ return Object.entries(attributes).map((_ref) => {
1059
1051
  let [name, definition] = _ref;
1060
1052
  return _extends({
1061
1053
  name
@@ -1063,7 +1055,7 @@ const getLayerAttributes = layerDefinition => {
1063
1055
  });
1064
1056
  };
1065
1057
  const getFeatureAttributes = attributes => {
1066
- return attributes ? Object.entries(attributes).map(_ref2 => {
1058
+ return attributes ? Object.entries(attributes).map((_ref2) => {
1067
1059
  let [name, value] = _ref2;
1068
1060
  return {
1069
1061
  name,
@@ -1081,7 +1073,7 @@ const getClassificationAttribute = (attributeName, attributes) => {
1081
1073
  return attribute ? _extends({}, attrNamePart, attribute) : attrNamePart;
1082
1074
  };
1083
1075
  const mergeAttributes = (attributes1, attributes2) => {
1084
- return attributes1.map(attribute => _extends({}, attribute, attributes2.find(_ref3 => {
1076
+ return attributes1.map(attribute => _extends({}, attribute, attributes2.find((_ref3) => {
1085
1077
  let {
1086
1078
  name
1087
1079
  } = _ref3;
@@ -1496,7 +1488,7 @@ let SGisPolygonSymbol = /*#__PURE__*/function (_sPolygonSymbol) {
1496
1488
  const adaptMiterRings = (rings, resolution, fromCrs, toCrs) => {
1497
1489
  const projected = geotools.projectRings(rings, fromCrs, toCrs);
1498
1490
  return math.simplifyCoordinates(projected.map(ring => // @ts-ignore
1499
- ring.map(_ref => {
1491
+ ring.map((_ref) => {
1500
1492
  let [x, y] = _ref;
1501
1493
  return [x / resolution, y / -resolution];
1502
1494
  })), 1);
@@ -1588,1503 +1580,1165 @@ let ArrowLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1588
1580
  return ArrowLineMiterRender;
1589
1581
  }(LineMiterRender);
1590
1582
 
1591
- const DEFAULT_FORMATTERS = {
1592
- polygon: formatPolygonMeasure,
1593
- length: formatLength
1594
- };
1595
-
1596
- const COORD_FRACTION = 6;
1597
- const DEFAULT_LABEL_POSITION = [Infinity, Infinity];
1598
- let BaseMeasureToolCreator = /*#__PURE__*/function (_PolylineControl) {
1599
- _inherits(BaseMeasureToolCreator, _PolylineControl);
1600
-
1601
- var _super = /*#__PURE__*/_createSuper(BaseMeasureToolCreator);
1583
+ let CircleLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1584
+ _inherits(CircleLineMiterRender, _LineMiterRender);
1602
1585
 
1603
- function BaseMeasureToolCreator(map, painter, params) {
1604
- var _this;
1586
+ var _super = /*#__PURE__*/_createSuper(CircleLineMiterRender);
1605
1587
 
1606
- _classCallCheck(this, BaseMeasureToolCreator);
1588
+ function CircleLineMiterRender() {
1589
+ _classCallCheck(this, CircleLineMiterRender);
1607
1590
 
1608
- _this = _super.call(this, map, params);
1591
+ return _super.apply(this, arguments);
1592
+ }
1609
1593
 
1610
- _this.cancel = () => {
1611
- _this.fire('cancel');
1612
- };
1594
+ _createClass(CircleLineMiterRender, [{
1595
+ key: "usageSize",
1596
+ get: function get() {
1597
+ return this.miterSize + this.strokeWidth * 3;
1598
+ }
1599
+ }, {
1600
+ key: "createRings",
1601
+ value: function createRings(_ref, xMultiplier) {
1602
+ let [x, y] = _ref;
1603
+ return [[[x + (this.miterSize / 2 + this.strokeWidth) * xMultiplier, y]]];
1604
+ }
1605
+ }, {
1606
+ key: "createRender",
1607
+ value: function createRender(miterRings) {
1608
+ const isFilled = this.kind === exports.LineMiterKind.FilledCircle;
1609
+ return new Poly.PolyRender(polygonCircleFromPoint(miterRings[0][0], this.miterSize), {
1610
+ fillColor: isFilled ? this.color : 'transparent',
1611
+ strokeColor: this.color,
1612
+ strokeWidth: this.strokeWidth,
1613
+ enclosed: true
1614
+ });
1615
+ }
1616
+ }]);
1613
1617
 
1614
- _this.painter = painter;
1615
- _this.renderLabelSymbol = params.renderLabelSymbol;
1616
- _this.formatters = params.formatters || DEFAULT_FORMATTERS;
1617
- _this.areaSymbol = params.areaSymbol;
1618
+ return CircleLineMiterRender;
1619
+ }(LineMiterRender);
1618
1620
 
1619
- _this.on('pointAdd', _this.handlePointAdd); // @ts-ignore
1621
+ let SquareLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1622
+ _inherits(SquareLineMiterRender, _LineMiterRender);
1620
1623
 
1624
+ var _super = /*#__PURE__*/_createSuper(SquareLineMiterRender);
1621
1625
 
1622
- _this.on('change', _this.updateDistance);
1626
+ function SquareLineMiterRender() {
1627
+ _classCallCheck(this, SquareLineMiterRender);
1623
1628
 
1624
- return _this;
1629
+ return _super.apply(this, arguments);
1625
1630
  }
1626
1631
 
1627
- _createClass(BaseMeasureToolCreator, [{
1628
- key: "_handleMousemove",
1629
- value: function _handleMousemove(event) {
1630
- _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_handleMousemove", this).call(this, event);
1631
-
1632
- this.drawPointOnMouseMove(event);
1632
+ _createClass(SquareLineMiterRender, [{
1633
+ key: "usageSize",
1634
+ get: function get() {
1635
+ return this.miterSize + this.strokeWidth;
1633
1636
  }
1634
1637
  }, {
1635
- key: "_activate",
1636
- value: function _activate() {
1637
- _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_activate", this).call(this);
1638
-
1639
- this.addTempLabel();
1640
- this.setCursor('pointer');
1638
+ key: "createRings",
1639
+ value: function createRings(_ref, xMultiplier) {
1640
+ let [x, y] = _ref;
1641
+ 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]]];
1641
1642
  }
1642
1643
  }, {
1643
- key: "_deactivate",
1644
- value: function _deactivate() {
1645
- _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_deactivate", this).call(this);
1644
+ key: "createRender",
1645
+ value: function createRender(miterRings) {
1646
+ const isFilled = this.kind === exports.LineMiterKind.FilledSquare;
1647
+ return new Poly.PolyRender(miterRings, {
1648
+ enclosed: true,
1649
+ fillColor: isFilled ? this.color : void 0,
1650
+ fillStyle: isFilled ? Poly.FillStyle.Color : Poly.FillStyle.None,
1651
+ lineCap: 'square',
1652
+ lineJoin: 'miter',
1653
+ strokeColor: this.color,
1654
+ strokeWidth: this.strokeWidth
1655
+ });
1656
+ }
1657
+ }]);
1646
1658
 
1647
- this.removeCoordLabel();
1648
- this.removeTempLabel();
1649
- this.removeMeasureLabel();
1650
- this.removeTempPolygon();
1651
- this.setCursor('default');
1659
+ return SquareLineMiterRender;
1660
+ }(LineMiterRender);
1661
+
1662
+ const getLineMiterRender = options => {
1663
+ switch (options.kind) {
1664
+ case exports.LineMiterKind.Arrow:
1665
+ case exports.LineMiterKind.FilledArrow:
1666
+ return new ArrowLineMiterRender(options);
1667
+
1668
+ case exports.LineMiterKind.Square:
1669
+ case exports.LineMiterKind.FilledSquare:
1670
+ return new SquareLineMiterRender(options);
1671
+
1672
+ case exports.LineMiterKind.Circle:
1673
+ case exports.LineMiterKind.FilledCircle:
1674
+ return new CircleLineMiterRender(options);
1675
+
1676
+ default:
1677
+ return null;
1678
+ }
1679
+ };
1680
+
1681
+ const updateRingForRightMiter = (ring, miterSize, isLastRing) => {
1682
+ const reversedRing = ring.slice().reverse();
1683
+
1684
+ for (let i = 0; i < reversedRing.length; i++) {
1685
+ const coordinates = reversedRing[i];
1686
+
1687
+ if (isLastRing && i === 0) {
1688
+ reversedRing[i] = [coordinates[0] - miterSize, coordinates[1]];
1652
1689
  }
1653
- }, {
1654
- key: "handlePointAdd",
1655
- value: function handlePointAdd() {
1656
- const feature = this.activeFeature;
1657
- if (!feature) return;
1658
- const {
1659
- rings,
1660
- crs
1661
- } = feature;
1662
1690
 
1663
- if (isPolylineLikePolygon(rings, this.map.resolution)) {
1664
- this.finishDrawing();
1665
- this.fire(new Control.DrawingFinishEvent(feature, new MouseEvent('mouseup')));
1666
- return;
1667
- }
1691
+ const nextCoordinates = reversedRing[i - 1];
1668
1692
 
1669
- if (rings[0].length === 2) {
1670
- const projection = crs.projectionTo(Crs.geo);
1671
- const point = rings[0][0];
1672
- if (!projection) return;
1673
- const [lat, long] = projection(point);
1674
- this.removeTempLabel();
1675
- this.addMeasureResultLabel();
1676
- this.addCoordLabel(lat.toFixed(COORD_FRACTION) + ", " + long.toFixed(COORD_FRACTION), point);
1677
- } else {
1678
- this.removeCoordLabel();
1679
- }
1693
+ if (nextCoordinates && nextCoordinates[0] < coordinates[0]) {
1694
+ reversedRing[i] = [nextCoordinates[0] - Math.abs(nextCoordinates[0] - coordinates[0]), coordinates[1]];
1680
1695
  }
1681
- }, {
1682
- key: "polygonPreview",
1683
- value: function polygonPreview() {
1684
- if (this.tempPolygon) {
1685
- this._tempLayer && this._tempLayer.remove(this.tempPolygon);
1686
- }
1696
+ }
1687
1697
 
1688
- const feature = this.activeFeature;
1689
- if (!feature) return;
1690
- const {
1691
- rings,
1692
- crs
1693
- } = feature;
1694
- const polygonRings = [...rings[0]];
1695
- polygonRings.shift();
1696
- this.tempPolygon = new Polygon.Polygon(polygonRings, {
1697
- crs
1698
- });
1699
- this.tempPolygon.symbol = this.areaSymbol || measureAreaSymbol;
1700
- this.activeFeature && this.activeFeature.hide();
1701
- this._tempLayer && this._tempLayer.add(this.tempPolygon);
1698
+ return reversedRing.reverse();
1699
+ };
1700
+
1701
+ const updateRingForLeftMiter = (ring, miterSize, isFirstRing) => {
1702
+ const newRing = ring.slice();
1703
+
1704
+ for (let i = 0; i < newRing.length; i++) {
1705
+ const coordinates = newRing[i];
1706
+
1707
+ if (i === 0 && isFirstRing) {
1708
+ newRing[i] = [coordinates[0] + miterSize, coordinates[1]];
1702
1709
  }
1703
- }, {
1704
- key: "removeTempPolygon",
1705
- value: function removeTempPolygon() {
1706
- if (this.tempPolygon) {
1707
- this._tempLayer && this._tempLayer.remove(this.tempPolygon);
1708
- delete this.tempPolygon;
1709
- }
1710
+
1711
+ const prevCoordinates = newRing[i - 1];
1712
+
1713
+ if (prevCoordinates && prevCoordinates[0] > coordinates[0]) {
1714
+ newRing[i] = [prevCoordinates[0] + Math.abs(coordinates[0] - prevCoordinates[0]), coordinates[1]];
1710
1715
  }
1711
- }, {
1712
- key: "updateDistance",
1713
- value: function updateDistance(event) {
1714
- const feature = this.activeFeature;
1715
- const {
1716
- ringIndex,
1717
- pointIndex
1718
- } = event;
1719
- if (!feature || ringIndex === null || pointIndex === null) return;
1720
- const {
1721
- rings,
1722
- crs
1723
- } = feature;
1724
- const position = rings[ringIndex][pointIndex];
1725
- const length = geotools.length(rings, crs);
1726
- let content = this.formatters.length(length);
1716
+ }
1727
1717
 
1728
- if (isPolylineLikePolygon(rings, this.map.resolution)) {
1729
- this.polygonPreview();
1730
- const area = geotools.area(rings, crs);
1731
- content = this.formatters.polygon(area, length);
1732
- } else if (this.tempPolygon) {
1733
- feature.show();
1734
- this.removeTempPolygon();
1735
- }
1718
+ return newRing;
1719
+ };
1736
1720
 
1737
- if (this.measureResultLabel) {
1738
- this.measureResultLabel.position = position;
1739
- this.measureResultLabel.content = content;
1740
- }
1721
+ const updateRingsForMiter = (rings, position, miterSize) => {
1722
+ return rings.map((ring, ringIndex) => {
1723
+ switch (position) {
1724
+ case 'right':
1725
+ return updateRingForRightMiter(ring, miterSize, ringIndex === rings.length - 1);
1726
+
1727
+ default:
1728
+ return updateRingForLeftMiter(ring, miterSize, ringIndex === 0);
1741
1729
  }
1742
- }, {
1743
- key: "addTempLabel",
1744
- value: function addTempLabel() {
1745
- this.tempLabel = new Label.LabelFeature(DEFAULT_LABEL_POSITION, {
1746
- content: 'Нажмите на карту, чтобы начать измерение',
1747
- crs: this.map.crs,
1748
- symbol: createLabelSymbol({
1749
- renderLabel: this.renderLabelSymbol
1750
- })
1751
- });
1752
- this._tempLayer && this._tempLayer.add(this.tempLabel);
1753
- }
1754
- }, {
1755
- key: "addCoordLabel",
1756
- value: function addCoordLabel(content, position) {
1757
- this.coordLabel = new Label.LabelFeature(position, {
1758
- content,
1759
- crs: this.map.crs,
1760
- symbol: createLabelSymbol({
1761
- renderLabel: this.renderLabelSymbol,
1762
- onClose: this.cancel
1763
- })
1730
+ });
1731
+ };
1732
+
1733
+ const copyRings = rings => rings.map(ring => ring.map(coordinates => coordinates.slice()));
1734
+ let SGisPolylineSymbol = /*#__PURE__*/function (_sPolylineSymbol) {
1735
+ _inherits(SGisPolylineSymbol, _sPolylineSymbol);
1736
+
1737
+ var _super = /*#__PURE__*/_createSuper(SGisPolylineSymbol);
1738
+
1739
+ function SGisPolylineSymbol(originalSymbol) {
1740
+ var _originalSymbol$strok, _originalSymbol$strok2;
1741
+
1742
+ var _this;
1743
+
1744
+ _classCallCheck(this, SGisPolylineSymbol);
1745
+
1746
+ _this = _super.call(this, {
1747
+ // @ts-ignore
1748
+ strokeColor: getHexColor(getParameterValue((_originalSymbol$strok = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok.color)),
1749
+ strokeWidth: clamp( // @ts-ignore
1750
+ getParameterValue((_originalSymbol$strok2 = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok2.width), PREVIEW_LIMITS.STROKE_WIDTH_MIN, PREVIEW_LIMITS.STROKE_WIDTH_MAX),
1751
+ // @ts-ignore
1752
+ lineDash: getLineDash(originalSymbol.stroke),
1753
+ // @ts-ignore
1754
+ lineCap: isDashedBrush(originalSymbol.stroke) ? 'square' : 'round'
1755
+ });
1756
+ _this.originalSymbol = originalSymbol;
1757
+ return _this;
1758
+ }
1759
+
1760
+ _createClass(SGisPolylineSymbol, [{
1761
+ key: "renderFunction",
1762
+ value: function renderFunction(feature, resolution, crs) {
1763
+ if (!isSimplePolylineSymbol(this.originalSymbol)) return _get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, feature, resolution, crs);
1764
+ const {
1765
+ ending,
1766
+ beginningSize,
1767
+ beginning,
1768
+ endingSize
1769
+ } = this.originalSymbol;
1770
+ const renders = [];
1771
+ const featureCopy = feature.clone();
1772
+ const beginningMiterRender = getLineMiterRender({
1773
+ color: this.strokeColor,
1774
+ // @ts-ignore
1775
+ kind: beginning,
1776
+ position: 'left',
1777
+ // @ts-ignore
1778
+ size: beginningSize,
1779
+ strokeWidth: this.strokeWidth
1764
1780
  });
1765
- this._tempLayer && this.coordLabel && this._tempLayer.add(this.coordLabel);
1766
- }
1767
- }, {
1768
- key: "addMeasureResultLabel",
1769
- value: function addMeasureResultLabel() {
1770
- this.measureResultLabel = new Label.LabelFeature(DEFAULT_LABEL_POSITION, {
1771
- crs: this.map.crs,
1772
- symbol: createLabelSymbol({
1773
- renderLabel: this.renderLabelSymbol
1774
- })
1781
+ const endingMiterRender = getLineMiterRender({
1782
+ color: this.strokeColor,
1783
+ // @ts-ignore
1784
+ kind: ending,
1785
+ position: 'right',
1786
+ // @ts-ignore
1787
+ size: endingSize,
1788
+ strokeWidth: this.strokeWidth
1775
1789
  });
1776
- this._tempLayer && this.measureResultLabel && this._tempLayer.add(this.measureResultLabel);
1777
- }
1778
- }, {
1779
- key: "removeTempLabel",
1780
- value: function removeTempLabel() {
1781
- if (this.tempLabel) {
1782
- this._tempLayer && this._tempLayer.remove(this.tempLabel);
1783
- delete this.tempLabel;
1784
- }
1785
- }
1786
- }, {
1787
- key: "removeCoordLabel",
1788
- value: function removeCoordLabel() {
1789
- if (this.coordLabel) {
1790
- this._tempLayer && this._tempLayer.remove(this.coordLabel);
1791
- delete this.coordLabel;
1792
- }
1793
- }
1794
- }, {
1795
- key: "removeMeasureLabel",
1796
- value: function removeMeasureLabel() {
1797
- if (this.measureResultLabel) {
1798
- this._tempLayer && this._tempLayer.remove(this.measureResultLabel);
1799
- delete this.measureResultLabel;
1800
- }
1801
- }
1802
- }, {
1803
- key: "drawPointOnMouseMove",
1804
- value: function drawPointOnMouseMove(event) {
1805
- if (this.tempLabel) {
1806
- this.tempLabel.position = event.point.position;
1790
+
1791
+ if (beginningMiterRender) {
1792
+ const updatedRings = updateRingsForMiter(featureCopy.rings, 'left', beginningMiterRender.usageSize);
1793
+ const render = beginningMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
1794
+ featureCopy.rings = updatedRings;
1795
+ renders.push(render);
1807
1796
  }
1797
+
1798
+ if (endingMiterRender) {
1799
+ const updatedRings = updateRingsForMiter(featureCopy.rings, 'right', endingMiterRender.usageSize);
1800
+ const render = endingMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
1801
+ featureCopy.rings = updatedRings;
1802
+ renders.push(render);
1803
+ } // NOTE: линия должна быть в начале чтобы быть под митерами
1804
+
1805
+
1806
+ renders.unshift(..._get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, featureCopy, resolution, crs));
1807
+ return renders;
1808
1808
  }
1809
1809
  }, {
1810
- key: "setCursor",
1811
- value: function setCursor(cursor) {
1812
- const {
1813
- wrapper
1814
- } = this.painter;
1815
-
1816
- if (wrapper && typeof wrapper !== 'string') {
1817
- wrapper.style.cursor = cursor;
1818
- }
1810
+ key: "clone",
1811
+ value: function clone() {
1812
+ return new SGisPolylineSymbol(this.originalSymbol);
1819
1813
  }
1820
1814
  }]);
1821
1815
 
1822
- return BaseMeasureToolCreator;
1823
- }(PolylineControl.PolylineControl);
1816
+ return SGisPolylineSymbol;
1817
+ }(PolylineSymbol.PolylineSymbol);
1824
1818
 
1825
- let BaseMeasureToolEditor = /*#__PURE__*/function (_PolyEditor) {
1826
- _inherits(BaseMeasureToolEditor, _PolyEditor);
1819
+ let LabelSymbol = /*#__PURE__*/function (_DynamicPointSymbol) {
1820
+ _inherits(LabelSymbol, _DynamicPointSymbol);
1827
1821
 
1828
- var _super = /*#__PURE__*/_createSuper(BaseMeasureToolEditor);
1822
+ var _super = /*#__PURE__*/_createSuper(LabelSymbol);
1829
1823
 
1830
- function BaseMeasureToolEditor(map, painter, params) {
1824
+ function LabelSymbol(_temp) {
1831
1825
  var _this;
1832
1826
 
1833
- _classCallCheck(this, BaseMeasureToolEditor);
1834
-
1835
- _this = _super.call(this, map, params);
1836
-
1837
- _this.measureResult = () => {
1838
- const feature = _this.activeFeature;
1839
- if (!feature) return null;
1840
- const {
1841
- rings,
1842
- isEnclosed,
1843
- crs
1844
- } = feature;
1845
- const pointsCount = rings[0].length;
1846
- const position = rings[0][pointsCount - 1];
1847
- const area = geotools.area(rings, crs);
1848
- const length = geotools.length(rings, crs, isEnclosed);
1849
- const content = isEnclosed ? _this.formatters.polygon(area, length) : _this.formatters.length(length);
1850
- return {
1851
- content,
1852
- position
1853
- };
1854
- };
1855
-
1856
- _this.removeFeature = () => {
1857
- _this.fire('remove');
1858
- };
1859
-
1860
- _this.painter = painter;
1861
- _this.renderLabelSymbol = params.renderLabelSymbol;
1862
- _this.formatters = params.formatters || DEFAULT_FORMATTERS;
1863
-
1864
- _this.on('change', _this.updateMeasureResult);
1827
+ let {
1828
+ component,
1829
+ offset
1830
+ } = _temp === void 0 ? {} : _temp;
1865
1831
 
1866
- _this.on('edit', _this.updateMeasureResult);
1832
+ _classCallCheck(this, LabelSymbol);
1867
1833
 
1834
+ _this = _super.call(this, {
1835
+ offset
1836
+ });
1837
+ _this.component = component;
1868
1838
  return _this;
1869
1839
  }
1870
1840
 
1871
- _createClass(BaseMeasureToolEditor, [{
1872
- key: "_activate",
1873
- value: function _activate() {
1874
- _get(_getPrototypeOf(BaseMeasureToolEditor.prototype), "_activate", this).call(this);
1875
-
1876
- this.addMeasureResultLabel();
1841
+ _createClass(LabelSymbol, [{
1842
+ key: "_getFeatureNode",
1843
+ value: function _getFeatureNode(feature) {
1844
+ const node = document.createElement('div');
1845
+ this.renderDom(feature.content, node);
1846
+ return node;
1877
1847
  }
1878
1848
  }, {
1879
- key: "addMeasureResultLabel",
1880
- value: function addMeasureResultLabel() {
1881
- const measureResult = this.measureResult();
1882
- if (measureResult === null) return;
1883
- const {
1884
- content,
1885
- position
1886
- } = measureResult;
1887
- this.measureResultLabel = new Label.LabelFeature(position, {
1888
- content,
1889
- crs: this.map.crs,
1890
- symbol: createLabelSymbol({
1891
- onClose: this.removeFeature,
1892
- renderLabel: this.renderLabelSymbol
1893
- })
1894
- });
1895
- this._tempLayer && this._tempLayer.add(this.measureResultLabel);
1849
+ key: "_updateFeatureNode",
1850
+ value: function _updateFeatureNode(feature) {
1851
+ this.renderDom(feature.content, this.getNode(feature));
1896
1852
  }
1897
1853
  }, {
1898
- key: "updateMeasureResult",
1899
- value: function updateMeasureResult() {
1900
- if (this.measureResultLabel) {
1901
- const measureResult = this.measureResult();
1902
- if (measureResult === null) return;
1903
- const {
1904
- content,
1905
- position
1906
- } = measureResult;
1907
- this.measureResultLabel.content = content;
1908
- this.measureResultLabel.position = position;
1854
+ key: "renderDom",
1855
+ value: function renderDom(content, node) {
1856
+ if (!node) {
1857
+ return;
1909
1858
  }
1910
- }
1911
- }]);
1912
1859
 
1913
- return BaseMeasureToolEditor;
1914
- }(PolyEditor.PolyEditor);
1860
+ const Component = this.component;
1915
1861
 
1916
- const metersToPixels = (meters, _ref) => {
1917
- let {
1918
- painter,
1919
- crs = Crs.geo
1920
- } = _ref;
1921
- const {
1922
- width
1923
- } = painter;
1924
- const zeroPoint = painter.getPointFromPxPosition(0, 0).projectTo(crs);
1925
- const maxWidthPoint = painter.getPointFromPxPosition(width, 0).projectTo(crs);
1926
- const widthDistance = geotools.distance(zeroPoint, maxWidthPoint);
1927
- const pxK = width / (widthDistance || 1);
1928
- return Math.round(meters * pxK);
1929
- };
1930
-
1931
- const polygonCircleFromPoint = (center, diameter) => {
1932
- const coordinates = [];
1933
- const radius = diameter / 2;
1934
- const endAngle = Math.PI * 2;
1935
- const step = Math.max(Math.PI / 2 / radius, endAngle / 128);
1936
- let start = 0;
1937
- let end = endAngle;
1862
+ if (Component) {
1863
+ ReactDOM.render(React__default.createElement(Component, {
1864
+ content: content
1865
+ }), node);
1866
+ } else {
1867
+ node.innerText = content;
1868
+ }
1869
+ }
1870
+ }]);
1938
1871
 
1939
- for (let ang = start; ang < end; ang += step) {
1940
- coordinates.push([Math.cos(ang) * radius + center[0], Math.sin(ang) * radius + center[1]]);
1941
- }
1872
+ return LabelSymbol;
1873
+ }(_Symbol.DynamicPointSymbol);
1942
1874
 
1943
- return [coordinates];
1875
+ const defaultOffset = [8, -16];
1876
+ const createLabelSymbol = props => {
1877
+ const {
1878
+ offset = defaultOffset,
1879
+ renderLabel = (_ref) => {
1880
+ let {
1881
+ content
1882
+ } = _ref;
1883
+ return React__default.createElement("div", null, content);
1884
+ },
1885
+ onClose = undefined
1886
+ } = props || {};
1887
+ return new LabelSymbol({
1888
+ offset,
1889
+ component: (_ref2) => {
1890
+ let {
1891
+ content
1892
+ } = _ref2;
1893
+ return renderLabel({
1894
+ content,
1895
+ onClose
1896
+ });
1897
+ }
1898
+ });
1944
1899
  };
1945
1900
 
1946
- let CircleLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1947
- _inherits(CircleLineMiterRender, _LineMiterRender);
1901
+ function createShadowRender(position, _ref) {
1902
+ let {
1903
+ strokeWidth = 2,
1904
+ shadowColor,
1905
+ shadowSize,
1906
+ size = 6
1907
+ } = _ref;
1908
+ const shadowDiameter = size + strokeWidth + shadowSize;
1909
+ return new Poly.PolyRender(polygonCircleFromPoint(position, shadowDiameter), {
1910
+ fillColor: 'transparent',
1911
+ strokeColor: shadowColor,
1912
+ strokeWidth: shadowSize,
1913
+ enclosed: true
1914
+ });
1915
+ }
1916
+ function getEditorPointRenderer(position, _ref2) {
1917
+ let {
1918
+ strokeColor,
1919
+ strokeWidth,
1920
+ shadowColor,
1921
+ fillColor,
1922
+ shadowSize,
1923
+ size = 0
1924
+ } = _ref2;
1925
+ return [createShadowRender(position, {
1926
+ strokeWidth,
1927
+ strokeColor,
1928
+ shadowSize,
1929
+ shadowColor,
1930
+ size
1931
+ }), new Poly.PolyRender(polygonCircleFromPoint(position, size), {
1932
+ fillColor,
1933
+ strokeColor,
1934
+ strokeWidth,
1935
+ enclosed: true
1936
+ })];
1937
+ }
1948
1938
 
1949
- var _super = /*#__PURE__*/_createSuper(CircleLineMiterRender);
1939
+ let ShadowedPointSymbol = /*#__PURE__*/function (_PointSymbol) {
1940
+ _inherits(ShadowedPointSymbol, _PointSymbol);
1950
1941
 
1951
- function CircleLineMiterRender() {
1952
- _classCallCheck(this, CircleLineMiterRender);
1942
+ var _super = /*#__PURE__*/_createSuper(ShadowedPointSymbol);
1953
1943
 
1954
- return _super.apply(this, arguments);
1944
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
1945
+ function ShadowedPointSymbol(options) {
1946
+ _classCallCheck(this, ShadowedPointSymbol);
1947
+
1948
+ return _super.call(this, options);
1955
1949
  }
1956
1950
 
1957
- _createClass(CircleLineMiterRender, [{
1958
- key: "usageSize",
1959
- get: function get() {
1960
- return this.miterSize + this.strokeWidth * 3;
1951
+ _createClass(ShadowedPointSymbol, [{
1952
+ key: "renderFunction",
1953
+ value: function renderFunction(feature, resolution, crs) {
1954
+ if (!(feature instanceof PointFeature.PointFeature)) return [];
1955
+ const {
1956
+ position
1957
+ } = feature.projectTo(crs);
1958
+ const pxPosition = [position[0] / resolution + (this.offset[0] || 0), -position[1] / resolution + (this.offset[1] || 0)];
1959
+ const shadowRender = this.getShadow(pxPosition, feature);
1960
+ const pointArc = this.getPoint(pxPosition, feature);
1961
+ return shadowRender ? [shadowRender, pointArc] : [pointArc];
1961
1962
  }
1962
1963
  }, {
1963
- key: "createRings",
1964
- value: function createRings(_ref, xMultiplier) {
1965
- let [x, y] = _ref;
1966
- return [[[x + (this.miterSize / 2 + this.strokeWidth) * xMultiplier, y]]];
1964
+ key: "getShadow",
1965
+ value: function getShadow(position, _feature) {
1966
+ return ShadowedPointSymbol.getShadowArc(position, this);
1967
1967
  }
1968
1968
  }, {
1969
- key: "createRender",
1970
- value: function createRender(miterRings) {
1971
- const isFilled = this.kind === exports.LineMiterKind.FilledCircle;
1972
- return new Poly.PolyRender(polygonCircleFromPoint(miterRings[0][0], this.miterSize), {
1973
- fillColor: isFilled ? this.color : 'transparent',
1974
- strokeColor: this.color,
1975
- strokeWidth: this.strokeWidth,
1969
+ key: "getPoint",
1970
+ value: function getPoint(position, _feature) {
1971
+ return ShadowedPointSymbol.getPointArc(position, this);
1972
+ }
1973
+ }], [{
1974
+ key: "getShadowArc",
1975
+ value: function getShadowArc(position, _ref) {
1976
+ let {
1977
+ strokeWidth = 2,
1978
+ shadowColor,
1979
+ shadowSize,
1980
+ size = 6
1981
+ } = _ref;
1982
+ return new Poly.PolyRender(polygonCircleFromPoint(position, size + strokeWidth + shadowSize), {
1983
+ fillColor: 'transparent',
1984
+ strokeColor: shadowColor,
1985
+ strokeWidth: shadowSize,
1976
1986
  enclosed: true
1977
1987
  });
1978
1988
  }
1979
- }]);
1980
-
1981
- return CircleLineMiterRender;
1982
- }(LineMiterRender);
1983
-
1984
- let SquareLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1985
- _inherits(SquareLineMiterRender, _LineMiterRender);
1986
-
1987
- var _super = /*#__PURE__*/_createSuper(SquareLineMiterRender);
1988
-
1989
- function SquareLineMiterRender() {
1990
- _classCallCheck(this, SquareLineMiterRender);
1991
-
1992
- return _super.apply(this, arguments);
1993
- }
1994
-
1995
- _createClass(SquareLineMiterRender, [{
1996
- key: "usageSize",
1997
- get: function get() {
1998
- return this.miterSize + this.strokeWidth;
1999
- }
2000
1989
  }, {
2001
- key: "createRings",
2002
- value: function createRings(_ref, xMultiplier) {
2003
- let [x, y] = _ref;
2004
- 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]]];
1990
+ key: "getPointArc",
1991
+ value: function getPointArc(position, _ref2) {
1992
+ let {
1993
+ strokeWidth,
1994
+ fillColor,
1995
+ strokeColor,
1996
+ size = 6
1997
+ } = _ref2;
1998
+ return new Poly.PolyRender(polygonCircleFromPoint(position, size), {
1999
+ fillColor,
2000
+ strokeColor,
2001
+ strokeWidth,
2002
+ enclosed: true
2003
+ });
2005
2004
  }
2006
2005
  }, {
2007
- key: "createRender",
2008
- value: function createRender(miterRings) {
2009
- const isFilled = this.kind === exports.LineMiterKind.FilledSquare;
2010
- return new Poly.PolyRender(miterRings, {
2011
- enclosed: true,
2012
- fillColor: isFilled ? this.color : void 0,
2013
- fillStyle: isFilled ? Poly.FillStyle.Color : Poly.FillStyle.None,
2014
- lineCap: 'square',
2015
- lineJoin: 'miter',
2016
- strokeColor: this.color,
2017
- strokeWidth: this.strokeWidth
2018
- });
2006
+ key: "getArcs",
2007
+ value: function getArcs(position, params) {
2008
+ const shadowRender = ShadowedPointSymbol.getShadowArc(position, params);
2009
+ const pointRender = ShadowedPointSymbol.getPointArc(position, params);
2010
+ return shadowRender ? [shadowRender, pointRender] : [pointRender];
2019
2011
  }
2020
2012
  }]);
2021
2013
 
2022
- return SquareLineMiterRender;
2023
- }(LineMiterRender);
2014
+ return ShadowedPointSymbol;
2015
+ }(Point.PointSymbol);
2024
2016
 
2025
- const getLineMiterRender = options => {
2026
- switch (options.kind) {
2027
- case exports.LineMiterKind.Arrow:
2028
- case exports.LineMiterKind.FilledArrow:
2029
- return new ArrowLineMiterRender(options);
2017
+ let ShadowedPolySymbol = /*#__PURE__*/function (_PolylineSymbol) {
2018
+ _inherits(ShadowedPolySymbol, _PolylineSymbol);
2030
2019
 
2031
- case exports.LineMiterKind.Square:
2032
- case exports.LineMiterKind.FilledSquare:
2033
- return new SquareLineMiterRender(options);
2020
+ var _super = /*#__PURE__*/_createSuper(ShadowedPolySymbol);
2034
2021
 
2035
- case exports.LineMiterKind.Circle:
2036
- case exports.LineMiterKind.FilledCircle:
2037
- return new CircleLineMiterRender(options);
2022
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2023
+ function ShadowedPolySymbol(options) {
2024
+ _classCallCheck(this, ShadowedPolySymbol);
2038
2025
 
2039
- default:
2040
- return null;
2026
+ return _super.call(this, options);
2041
2027
  }
2042
- };
2043
2028
 
2044
- const updateRingForRightMiter = (ring, miterSize, isLastRing) => {
2045
- const reversedRing = ring.slice().reverse();
2029
+ _createClass(ShadowedPolySymbol, [{
2030
+ key: "renderFunction",
2031
+ value: function renderFunction(feature, resolution, crs) {
2032
+ if (!(feature instanceof Poly$1.Poly)) return [];
2046
2033
 
2047
- for (let i = 0; i < reversedRing.length; i++) {
2048
- const coordinates = reversedRing[i];
2034
+ const coordinates = _get(_getPrototypeOf(ShadowedPolySymbol.prototype), "getRenderedCoordinates", this).call(this, feature, resolution, crs);
2049
2035
 
2050
- if (isLastRing && i === 0) {
2051
- reversedRing[i] = [coordinates[0] - miterSize, coordinates[1]];
2052
- }
2036
+ const polyRender = this.getPolyRender(coordinates, feature);
2037
+ const shadowRender = this.getShadow(coordinates, feature);
2038
+ const vertexRenders = this.getVertexRenders(coordinates);
2039
+ let renders = [polyRender];
2053
2040
 
2054
- const nextCoordinates = reversedRing[i - 1];
2041
+ if (shadowRender) {
2042
+ renders = [shadowRender, polyRender];
2043
+ }
2055
2044
 
2056
- if (nextCoordinates && nextCoordinates[0] < coordinates[0]) {
2057
- reversedRing[i] = [nextCoordinates[0] - Math.abs(nextCoordinates[0] - coordinates[0]), coordinates[1]];
2058
- }
2059
- }
2060
-
2061
- return reversedRing.reverse();
2062
- };
2063
-
2064
- const updateRingForLeftMiter = (ring, miterSize, isFirstRing) => {
2065
- const newRing = ring.slice();
2066
-
2067
- for (let i = 0; i < newRing.length; i++) {
2068
- const coordinates = newRing[i];
2045
+ if (vertexRenders) {
2046
+ renders = renders.concat(vertexRenders);
2047
+ }
2069
2048
 
2070
- if (i === 0 && isFirstRing) {
2071
- newRing[i] = [coordinates[0] + miterSize, coordinates[1]];
2049
+ return renders;
2072
2050
  }
2073
-
2074
- const prevCoordinates = newRing[i - 1];
2075
-
2076
- if (prevCoordinates && prevCoordinates[0] > coordinates[0]) {
2077
- newRing[i] = [prevCoordinates[0] + Math.abs(coordinates[0] - prevCoordinates[0]), coordinates[1]];
2051
+ }, {
2052
+ key: "getShadow",
2053
+ value: function getShadow(coordinates, _feature) {
2054
+ return new Poly.PolyRender(coordinates, {
2055
+ fillStyle: Poly.FillStyle.None,
2056
+ enclosed: this.enclose,
2057
+ strokeColor: this.shadowColor,
2058
+ strokeWidth: this.shadowSize,
2059
+ lineDash: this.lineDash
2060
+ });
2078
2061
  }
2079
- }
2062
+ }, {
2063
+ key: "getPolyRender",
2064
+ value: function getPolyRender(coordinates, _feature) {
2065
+ return new Poly.PolyRender(coordinates, {
2066
+ fillStyle: this.enclose ? Poly.FillStyle.Color : Poly.FillStyle.None,
2067
+ enclosed: this.enclose,
2068
+ fillColor: this.fillColor,
2069
+ strokeColor: this.strokeColor,
2070
+ strokeWidth: this.strokeWidth,
2071
+ lineDash: this.lineDash
2072
+ });
2073
+ }
2074
+ }, {
2075
+ key: "getVertexRenders",
2076
+ value: function getVertexRenders(coordinates) {
2077
+ if (!this.showVertex) return;
2078
+ const vertexCoordinates = coordinates.reduce((acc, curr) => {
2079
+ return acc.concat(curr);
2080
+ }, []);
2081
+ return vertexCoordinates.map(coord => getEditorPointRenderer(coord, {
2082
+ size: 6,
2083
+ strokeWidth: 2,
2084
+ shadowColor: this.shadowColor,
2085
+ strokeColor: this.strokeColor,
2086
+ shadowSize: this.vertexShadowSize !== undefined ? this.vertexShadowSize : 2,
2087
+ fillColor: '#ffffff'
2088
+ })).reduce((acc, curr) => acc.concat(curr), []);
2089
+ }
2090
+ }]);
2080
2091
 
2081
- return newRing;
2092
+ return ShadowedPolySymbol;
2093
+ }(PolylineSymbol.PolylineSymbol);
2094
+ const polySymbolParams = {
2095
+ strokeWidth: 2,
2096
+ strokeColor: '#e33600',
2097
+ shadowSize: 8,
2098
+ shadowColor: 'rgba(227, 54, 0, 0.3)'
2082
2099
  };
2083
-
2084
- const updateRingsForMiter = (rings, position, miterSize) => {
2085
- return rings.map((ring, ringIndex) => {
2086
- switch (position) {
2087
- case 'right':
2088
- return updateRingForRightMiter(ring, miterSize, ringIndex === rings.length - 1);
2089
-
2090
- default:
2091
- return updateRingForLeftMiter(ring, miterSize, ringIndex === 0);
2092
- }
2093
- });
2100
+ const measureSymbolParams = {
2101
+ strokeColor: '#ff6933',
2102
+ shadowSize: 0,
2103
+ vertexShadowSize: 0
2094
2104
  };
2105
+ const measureLengthSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
2106
+ enclose: false,
2107
+ showVertex: true
2108
+ }));
2109
+ const measureAreaSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
2110
+ fillColor: 'rgba(255, 105, 51, 0.25)',
2111
+ enclose: true,
2112
+ showVertex: true
2113
+ }));
2114
+ const snapSymbolParams = {
2115
+ size: 10,
2116
+ strokeWidth: 2,
2117
+ strokeColor: '#e33600',
2118
+ fillColor: '#ffffff',
2119
+ shadowColor: 'rgba(227, 54, 0, 0.3)',
2120
+ shadowSize: 3
2121
+ };
2122
+ const measurePolygonSnapSymbol = /*#__PURE__*/new ShadowedPointSymbol( /*#__PURE__*/_extends({}, snapSymbolParams, {
2123
+ strokeColor: '#ff6933',
2124
+ shadowSize: 0
2125
+ }));
2095
2126
 
2096
- const copyRings = rings => rings.map(ring => ring.map(coordinates => coordinates.slice()));
2097
- let SGisPolylineSymbol = /*#__PURE__*/function (_sPolylineSymbol) {
2098
- _inherits(SGisPolylineSymbol, _sPolylineSymbol);
2099
-
2100
- var _super = /*#__PURE__*/_createSuper(SGisPolylineSymbol);
2101
-
2102
- function SGisPolylineSymbol(originalSymbol) {
2103
- var _originalSymbol$strok, _originalSymbol$strok2;
2127
+ let SelectedPointSymbol = /*#__PURE__*/function (_ShadowedPointSymbol) {
2128
+ _inherits(SelectedPointSymbol, _ShadowedPointSymbol);
2104
2129
 
2105
- var _this;
2130
+ var _super = /*#__PURE__*/_createSuper(SelectedPointSymbol);
2106
2131
 
2107
- _classCallCheck(this, SGisPolylineSymbol);
2132
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2133
+ function SelectedPointSymbol(props) {
2134
+ _classCallCheck(this, SelectedPointSymbol);
2108
2135
 
2109
- _this = _super.call(this, {
2110
- // @ts-ignore
2111
- strokeColor: getHexColor(getParameterValue((_originalSymbol$strok = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok.color)),
2112
- strokeWidth: clamp( // @ts-ignore
2113
- getParameterValue((_originalSymbol$strok2 = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok2.width), PREVIEW_LIMITS.STROKE_WIDTH_MIN, PREVIEW_LIMITS.STROKE_WIDTH_MAX),
2114
- // @ts-ignore
2115
- lineDash: getLineDash(originalSymbol.stroke),
2116
- // @ts-ignore
2117
- lineCap: isDashedBrush(originalSymbol.stroke) ? 'square' : 'round'
2118
- });
2119
- _this.originalSymbol = originalSymbol;
2120
- return _this;
2136
+ return _super.call(this, props);
2121
2137
  }
2122
2138
 
2123
- _createClass(SGisPolylineSymbol, [{
2124
- key: "renderFunction",
2125
- value: function renderFunction(feature, resolution, crs) {
2126
- if (!isSimplePolylineSymbol(this.originalSymbol)) return _get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, feature, resolution, crs);
2127
- const {
2128
- ending,
2129
- beginningSize,
2130
- beginning,
2131
- endingSize
2132
- } = this.originalSymbol;
2133
- const renders = [];
2134
- const featureCopy = feature.clone();
2135
- const beginningMiterRender = getLineMiterRender({
2136
- color: this.strokeColor,
2137
- // @ts-ignore
2138
- kind: beginning,
2139
- position: 'left',
2140
- // @ts-ignore
2141
- size: beginningSize,
2142
- strokeWidth: this.strokeWidth
2143
- });
2144
- const endingMiterRender = getLineMiterRender({
2145
- color: this.strokeColor,
2146
- // @ts-ignore
2147
- kind: ending,
2148
- position: 'right',
2149
- // @ts-ignore
2150
- size: endingSize,
2151
- strokeWidth: this.strokeWidth
2152
- });
2153
-
2154
- if (beginningMiterRender) {
2155
- const updatedRings = updateRingsForMiter(featureCopy.rings, 'left', beginningMiterRender.usageSize);
2156
- const render = beginningMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
2157
- featureCopy.rings = updatedRings;
2158
- renders.push(render);
2139
+ _createClass(SelectedPointSymbol, [{
2140
+ key: "getShadow",
2141
+ value: function getShadow(position, feature) {
2142
+ if (feature.isSelected) {
2143
+ return _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getShadow", this).call(this, position, feature);
2159
2144
  }
2160
-
2161
- if (endingMiterRender) {
2162
- const updatedRings = updateRingsForMiter(featureCopy.rings, 'right', endingMiterRender.usageSize);
2163
- const render = endingMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
2164
- featureCopy.rings = updatedRings;
2165
- renders.push(render);
2166
- } // NOTE: линия должна быть в начале чтобы быть под митерами
2167
-
2168
-
2169
- renders.unshift(..._get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, featureCopy, resolution, crs));
2170
- return renders;
2171
2145
  }
2172
2146
  }, {
2173
- key: "clone",
2174
- value: function clone() {
2175
- return new SGisPolylineSymbol(this.originalSymbol);
2176
- }
2177
- }]);
2147
+ key: "getPoint",
2148
+ value: function getPoint(position, feature) {
2149
+ const pointRender = _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getPoint", this).call(this, position, feature);
2178
2150
 
2179
- return SGisPolylineSymbol;
2180
- }(PolylineSymbol.PolylineSymbol);
2151
+ if (feature.isSelected) {
2152
+ pointRender.strokeColor = this.selectedStrokeColor;
2153
+ pointRender.fillColor = this.selectedFillColor;
2154
+ }
2181
2155
 
2182
- let LabelSymbol = /*#__PURE__*/function (_DynamicPointSymbol) {
2183
- _inherits(LabelSymbol, _DynamicPointSymbol);
2156
+ return pointRender;
2157
+ }
2158
+ }]);
2184
2159
 
2185
- var _super = /*#__PURE__*/_createSuper(LabelSymbol);
2160
+ return SelectedPointSymbol;
2161
+ }(ShadowedPointSymbol);
2186
2162
 
2187
- function LabelSymbol(_temp) {
2188
- var _this;
2163
+ let SelectedPolySymbol = /*#__PURE__*/function (_ShadowedPolySymbol) {
2164
+ _inherits(SelectedPolySymbol, _ShadowedPolySymbol);
2189
2165
 
2190
- let {
2191
- component,
2192
- offset
2193
- } = _temp === void 0 ? {} : _temp;
2166
+ var _super = /*#__PURE__*/_createSuper(SelectedPolySymbol);
2194
2167
 
2195
- _classCallCheck(this, LabelSymbol);
2168
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2169
+ function SelectedPolySymbol(props) {
2170
+ _classCallCheck(this, SelectedPolySymbol);
2196
2171
 
2197
- _this = _super.call(this, {
2198
- offset
2199
- });
2200
- _this.component = component;
2201
- return _this;
2172
+ return _super.call(this, props);
2202
2173
  }
2203
2174
 
2204
- _createClass(LabelSymbol, [{
2205
- key: "_getFeatureNode",
2206
- value: function _getFeatureNode(feature) {
2207
- const node = document.createElement('div');
2208
- this.renderDom(feature.content, node);
2209
- return node;
2210
- }
2211
- }, {
2212
- key: "_updateFeatureNode",
2213
- value: function _updateFeatureNode(feature) {
2214
- this.renderDom(feature.content, this.getNode(feature));
2175
+ _createClass(SelectedPolySymbol, [{
2176
+ key: "getShadow",
2177
+ value: function getShadow(coordinates, feature) {
2178
+ if (feature.isSelected) {
2179
+ return _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getShadow", this).call(this, coordinates, feature);
2180
+ }
2215
2181
  }
2216
2182
  }, {
2217
- key: "renderDom",
2218
- value: function renderDom(content, node) {
2219
- if (!node) {
2220
- return;
2221
- }
2183
+ key: "getPolyRender",
2184
+ value: function getPolyRender(coordinates, feature) {
2185
+ const polyRender = _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getPolyRender", this).call(this, coordinates, feature);
2222
2186
 
2223
- const Component = this.component;
2187
+ if (feature.isSelected) {
2188
+ polyRender.fillColor = this.selectedFillColor;
2189
+ polyRender.strokeColor = this.selectedStrokeColor;
2224
2190
 
2225
- if (Component) {
2226
- ReactDOM.render(React__default.createElement(Component, {
2227
- content: content
2228
- }), node);
2229
- } else {
2230
- node.innerText = content;
2191
+ if (this.selectedStrokeWidth !== void 0) {
2192
+ polyRender.strokeWidth = this.selectedStrokeWidth;
2193
+ }
2231
2194
  }
2195
+
2196
+ return polyRender;
2232
2197
  }
2233
2198
  }]);
2234
2199
 
2235
- return LabelSymbol;
2236
- }(_Symbol.DynamicPointSymbol);
2200
+ return SelectedPolySymbol;
2201
+ }(ShadowedPolySymbol);
2237
2202
 
2238
- const defaultOffset = [8, -16];
2239
- const createLabelSymbol = props => {
2240
- const {
2241
- offset = defaultOffset,
2242
- renderLabel = _ref => {
2243
- let {
2244
- content
2245
- } = _ref;
2246
- return React__default.createElement("div", null, content);
2247
- },
2248
- onClose = undefined
2249
- } = props || {};
2250
- return new LabelSymbol({
2251
- offset,
2252
- component: _ref2 => {
2253
- let {
2254
- content
2255
- } = _ref2;
2256
- return renderLabel({
2257
- content,
2258
- onClose
2259
- });
2260
- }
2261
- });
2262
- };
2203
+ const selectedPoint = /*#__PURE__*/new SelectedPointSymbol({
2204
+ size: 8,
2205
+ strokeWidth: 2,
2206
+ strokeColor: 'rgba(255, 87, 34, 0.3)',
2207
+ fillColor: 'rgba(255, 255, 255, 0.65)',
2208
+ shadowColor: 'rgba(255, 87, 34, 0.3)',
2209
+ shadowSize: 3,
2210
+ selectedStrokeColor: '#ff5722',
2211
+ selectedFillColor: 'rgba(255, 255, 255, 0.65)'
2212
+ });
2213
+ const selectedPolyline = /*#__PURE__*/new SelectedPolySymbol({
2214
+ strokeWidth: 6,
2215
+ strokeColor: 'rgba(255, 87, 34, 0.2)',
2216
+ shadowSize: 8,
2217
+ shadowColor: 'rgba(255, 87, 34, 0.3)',
2218
+ selectedStrokeColor: '#ff5722',
2219
+ selectedStrokeWidth: 2
2220
+ });
2221
+ const selectedPolygon = /*#__PURE__*/new SelectedPolySymbol({
2222
+ strokeWidth: 2,
2223
+ strokeColor: 'rgba(255, 87, 34, 0.3)',
2224
+ shadowSize: 8,
2225
+ shadowColor: 'rgba(255, 87, 34, 0.3)',
2226
+ fillColor: 'rgba(255, 255, 255, 0.36)',
2227
+ enclose: true,
2228
+ selectedFillColor: 'rgba(255, 255, 255, 0.56)',
2229
+ selectedStrokeColor: '#ff5722'
2230
+ });
2263
2231
 
2264
- function createShadowRender(position, _ref) {
2232
+ const metersToPixels = (meters, _ref) => {
2265
2233
  let {
2266
- strokeWidth = 2,
2267
- shadowColor,
2268
- shadowSize,
2269
- size = 6
2234
+ painter,
2235
+ crs = Crs.geo
2270
2236
  } = _ref;
2271
- const shadowDiameter = size + strokeWidth + shadowSize;
2272
- return new Poly.PolyRender(polygonCircleFromPoint(position, shadowDiameter), {
2273
- fillColor: 'transparent',
2274
- strokeColor: shadowColor,
2275
- strokeWidth: shadowSize,
2276
- enclosed: true
2277
- });
2278
- }
2279
- function getEditorPointRenderer(position, _ref2) {
2280
- let {
2281
- strokeColor,
2282
- strokeWidth,
2283
- shadowColor,
2284
- fillColor,
2285
- shadowSize,
2286
- size = 0
2287
- } = _ref2;
2288
- return [createShadowRender(position, {
2289
- strokeWidth,
2290
- strokeColor,
2291
- shadowSize,
2292
- shadowColor,
2293
- size
2294
- }), new Poly.PolyRender(polygonCircleFromPoint(position, size), {
2295
- fillColor,
2296
- strokeColor,
2297
- strokeWidth,
2298
- enclosed: true
2299
- })];
2300
- }
2237
+ const {
2238
+ width
2239
+ } = painter;
2240
+ const zeroPoint = painter.getPointFromPxPosition(0, 0).projectTo(crs);
2241
+ const maxWidthPoint = painter.getPointFromPxPosition(width, 0).projectTo(crs);
2242
+ const widthDistance = geotools.distance(zeroPoint, maxWidthPoint);
2243
+ const pxK = width / (widthDistance || 1);
2244
+ return Math.round(meters * pxK);
2245
+ };
2301
2246
 
2302
- let ShadowedPointSymbol = /*#__PURE__*/function (_PointSymbol) {
2303
- _inherits(ShadowedPointSymbol, _PointSymbol);
2247
+ const defaultPathStyles = {
2248
+ strokeWidth: 2,
2249
+ strokeColor: 'rgb(0, 163, 245)',
2250
+ fillStyle: Poly.FillStyle.None
2251
+ };
2252
+ let SVGPoly = /*#__PURE__*/function (_Symbol) {
2253
+ _inherits(SVGPoly, _Symbol);
2304
2254
 
2305
- var _super = /*#__PURE__*/_createSuper(ShadowedPointSymbol);
2255
+ var _super = /*#__PURE__*/_createSuper(SVGPoly);
2306
2256
 
2307
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2308
- function ShadowedPointSymbol(options) {
2309
- _classCallCheck(this, ShadowedPointSymbol);
2257
+ function SVGPoly(_temp) {
2258
+ var _this;
2310
2259
 
2311
- return _super.call(this, options);
2260
+ let {
2261
+ redrawFeatureNode,
2262
+ pathStyles,
2263
+ circle,
2264
+ className,
2265
+ appendToSvg
2266
+ } = _temp === void 0 ? {} : _temp;
2267
+
2268
+ _classCallCheck(this, SVGPoly);
2269
+
2270
+ _this = _super.call(this);
2271
+ _this.container = document.createElement('div');
2272
+ _this.container.style.position = 'absolute';
2273
+ _this.redrawFeatureNode = redrawFeatureNode;
2274
+ _this.pathStyles = _extends({
2275
+ center: [0, 0],
2276
+ fillColor: 'none'
2277
+ }, pathStyles);
2278
+ _this.circle = circle;
2279
+ _this.className = className;
2280
+ _this.appendToSvg = appendToSvg;
2281
+ return _this;
2312
2282
  }
2313
2283
 
2314
- _createClass(ShadowedPointSymbol, [{
2284
+ _createClass(SVGPoly, [{
2315
2285
  key: "renderFunction",
2316
2286
  value: function renderFunction(feature, resolution, crs) {
2317
- if (!(feature instanceof PointFeature.PointFeature)) return [];
2318
- const {
2319
- position
2320
- } = feature.projectTo(crs);
2321
- const pxPosition = [position[0] / resolution + (this.offset[0] || 0), -position[1] / resolution + (this.offset[1] || 0)];
2322
- const shadowRender = this.getShadow(pxPosition, feature);
2323
- const pointArc = this.getPoint(pxPosition, feature);
2324
- return shadowRender ? [shadowRender, pointArc] : [pointArc];
2287
+ const coordinates = feature instanceof Poly$1.Poly ? new PolylineSymbol.PolylineSymbol().getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
2288
+ this.setCirclePxRaius(crs);
2289
+ this.container.innerHTML = '';
2290
+ const svg = this.setSvg(coordinates);
2291
+ svg && this.container.append(svg);
2292
+ feature.__dynamicSymbolRender = new Render.DynamicRender({
2293
+ node: this.container,
2294
+ update: (bbox, resolution) => this.update({
2295
+ bbox,
2296
+ resolution,
2297
+ feature,
2298
+ crs
2299
+ }),
2300
+ redraw: () => {
2301
+ this.redrawFeatureNode && this.redrawFeatureNode(feature);
2302
+ }
2303
+ });
2304
+
2305
+ this._setEventListeners(feature);
2306
+
2307
+ return [feature.__dynamicSymbolRender];
2325
2308
  }
2326
2309
  }, {
2327
- key: "getShadow",
2328
- value: function getShadow(position, _feature) {
2329
- return ShadowedPointSymbol.getShadowArc(position, this);
2310
+ key: "setCirclePxRaius",
2311
+ value: function setCirclePxRaius(crs) {
2312
+ if (this.circle && this.pathStyles) {
2313
+ var _this$circle;
2314
+
2315
+ this.pathStyles.radius = metersToPixels(this.circle.radius, {
2316
+ painter: this.circle.painter,
2317
+ crs
2318
+ }) + (((_this$circle = this.circle) == null ? void 0 : _this$circle.pxOffset) || 0);
2319
+ }
2330
2320
  }
2331
2321
  }, {
2332
- key: "getPoint",
2333
- value: function getPoint(position, _feature) {
2334
- return ShadowedPointSymbol.getPointArc(position, this);
2335
- }
2336
- }], [{
2337
- key: "getShadowArc",
2338
- value: function getShadowArc(position, _ref) {
2322
+ key: "update",
2323
+ value: function update(_ref) {
2324
+ var _this$pathStyles, _this$pathStyles2, _this$pathStyles3, _this$pathStyles4;
2325
+
2339
2326
  let {
2340
- strokeWidth = 2,
2341
- shadowColor,
2342
- shadowSize,
2343
- size = 6
2327
+ bbox,
2328
+ resolution,
2329
+ feature,
2330
+ crs
2344
2331
  } = _ref;
2345
- return new Poly.PolyRender(polygonCircleFromPoint(position, size + strokeWidth + shadowSize), {
2346
- fillColor: 'transparent',
2347
- strokeColor: shadowColor,
2348
- strokeWidth: shadowSize,
2349
- enclosed: true
2350
- });
2332
+ if (!feature) return;
2333
+ if (!bbox) bbox = feature.__lastBbox;
2334
+ if (!resolution) resolution = feature.__lastResolution;
2335
+ if (!bbox || !resolution || !feature.crs.canProjectTo(bbox.crs)) return;
2336
+
2337
+ if (feature.__lastResolution && resolution !== feature.__lastResolution) {
2338
+ const newCoordinates = feature instanceof Poly$1.Poly ? new PolylineSymbol.PolylineSymbol().getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
2339
+ this.setCirclePxRaius(crs);
2340
+ this.container.innerHTML = '';
2341
+ const svg = this.setSvg(newCoordinates);
2342
+ svg && this.container.append(svg);
2343
+ }
2344
+
2345
+ const polygon = feature.projectTo(bbox.crs);
2346
+ 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;
2347
+ const dx = Math.round((polygon.bbox.xMin - bbox.xMin) / resolution) - radiusOffset;
2348
+ const dy = Math.round((bbox.yMax - polygon.bbox.yMax) / resolution) - radiusOffset;
2349
+ this.container.style.left = dx.toString() + "px";
2350
+ this.container.style.top = dy.toString() + "px";
2351
+ feature.__lastBbox = bbox;
2352
+ feature.__lastResolution = resolution;
2351
2353
  }
2352
2354
  }, {
2353
- key: "getPointArc",
2354
- value: function getPointArc(position, _ref2) {
2355
- let {
2356
- strokeWidth,
2357
- fillColor,
2358
- strokeColor,
2359
- size = 6
2360
- } = _ref2;
2361
- return new Poly.PolyRender(polygonCircleFromPoint(position, size), {
2362
- fillColor,
2363
- strokeColor,
2364
- strokeWidth,
2365
- enclosed: true
2366
- });
2367
- }
2368
- }, {
2369
- key: "getArcs",
2370
- value: function getArcs(position, params) {
2371
- const shadowRender = ShadowedPointSymbol.getShadowArc(position, params);
2372
- const pointRender = ShadowedPointSymbol.getPointArc(position, params);
2373
- return shadowRender ? [shadowRender, pointRender] : [pointRender];
2374
- }
2375
- }]);
2376
-
2377
- return ShadowedPointSymbol;
2378
- }(Point.PointSymbol);
2379
-
2380
- let ShadowedPolySymbol = /*#__PURE__*/function (_PolylineSymbol) {
2381
- _inherits(ShadowedPolySymbol, _PolylineSymbol);
2382
-
2383
- var _super = /*#__PURE__*/_createSuper(ShadowedPolySymbol);
2384
-
2385
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2386
- function ShadowedPolySymbol(options) {
2387
- _classCallCheck(this, ShadowedPolySymbol);
2388
-
2389
- return _super.call(this, options);
2390
- }
2391
-
2392
- _createClass(ShadowedPolySymbol, [{
2393
- key: "renderFunction",
2394
- value: function renderFunction(feature, resolution, crs) {
2395
- if (!(feature instanceof Poly$1.Poly)) return [];
2396
- const coordinates = PolylineSymbol.PolylineSymbol.getRenderedCoordinates(feature, resolution, crs);
2397
- const polyRender = this.getPolyRender(coordinates, feature);
2398
- const shadowRender = this.getShadow(coordinates, feature);
2399
- const vertexRenders = this.getVertexRenders(coordinates);
2400
- let renders = [polyRender];
2355
+ key: "setSvg",
2356
+ value: function setSvg(coordinates) {
2357
+ const {
2358
+ lineCap,
2359
+ lineJoin,
2360
+ miterLimit,
2361
+ lineDash,
2362
+ dashOffset
2363
+ } = this.pathStyles || {};
2364
+ const svgRender = new SvgRender.SvgRender(_extends({
2365
+ coordinates
2366
+ }, defaultPathStyles, {
2367
+ appendToSvg: this.appendToSvg
2368
+ }, this.pathStyles));
2401
2369
 
2402
- if (shadowRender) {
2403
- renders = [shadowRender, polyRender];
2370
+ if (this.circle) {
2371
+ svgRender._setArcNode();
2372
+ } else {
2373
+ svgRender._setPolyNode();
2404
2374
  }
2405
2375
 
2406
- if (vertexRenders) {
2407
- renders = renders.concat(vertexRenders);
2408
- }
2376
+ let svgElement;
2377
+ svgRender.getNode((_, svg) => {
2378
+ svgElement = svg;
2379
+ this.className && svgElement.classList.add(this.className);
2380
+ const path = svgElement && svgElement.querySelector(this.circle ? 'circle' : 'path');
2409
2381
 
2410
- return renders;
2411
- }
2412
- }, {
2413
- key: "getShadow",
2414
- value: function getShadow(coordinates, _feature) {
2415
- return new Poly.PolyRender(coordinates, {
2416
- fillStyle: Poly.FillStyle.None,
2417
- enclosed: this.enclose,
2418
- strokeColor: this.shadowColor,
2419
- strokeWidth: this.shadowSize,
2420
- lineDash: this.lineDash
2382
+ if (path) {
2383
+ path.setAttribute('stroke-linecap', lineCap || 'round');
2384
+ path.setAttribute('stroke-linejoin', lineJoin || 'round');
2385
+ path.setAttribute('stroke-miterlimit', (miterLimit || 10).toString());
2386
+ path.setAttribute('stroke-dashoffset', (dashOffset || 0).toString());
2387
+
2388
+ if (this.circle) {
2389
+ path.setAttribute('stroke-dasharray', lineDash && lineDash.length > 0 ? lineDash.join(',') : '');
2390
+ }
2391
+ }
2421
2392
  });
2393
+ return svgElement;
2422
2394
  }
2423
2395
  }, {
2424
- key: "getPolyRender",
2425
- value: function getPolyRender(coordinates, _feature) {
2426
- return new Poly.PolyRender(coordinates, {
2427
- fillStyle: this.enclose ? Poly.FillStyle.Color : Poly.FillStyle.None,
2428
- enclosed: this.enclose,
2429
- fillColor: this.fillColor,
2430
- strokeColor: this.strokeColor,
2431
- strokeWidth: this.strokeWidth,
2432
- lineDash: this.lineDash
2396
+ key: "_setEventListeners",
2397
+ value: function _setEventListeners(dynamicFeature) {
2398
+ var _dynamicFeature$__dyn;
2399
+
2400
+ if (dynamicFeature.eventFlags === EventHandler.MouseEventFlags.None) return;
2401
+ const svgNode = dynamicFeature == null ? void 0 : (_dynamicFeature$__dyn = dynamicFeature.__dynamicSymbolRender) == null ? void 0 : _dynamicFeature$__dyn.node.querySelector(this.circle ? 'circle' : 'path');
2402
+ Object.keys(EventHandler.mouseEvents).forEach(eventName => {
2403
+ if (dynamicFeature.eventFlags & EventHandler.mouseEvents[eventName].flag) {
2404
+ domEvent.listenDomEvent(svgNode, EventHandler.mouseEvents[eventName].type, event => {
2405
+ dynamicFeature.fire(EventHandler.mouseEvents[eventName].type, {
2406
+ node: svgNode,
2407
+ browserEvent: event
2408
+ });
2409
+ });
2410
+ }
2433
2411
  });
2434
2412
  }
2435
- }, {
2436
- key: "getVertexRenders",
2437
- value: function getVertexRenders(coordinates) {
2438
- if (!this.showVertex) return;
2439
- const vertexCoordinates = coordinates.reduce((acc, curr) => {
2440
- return acc.concat(curr);
2441
- }, []);
2442
- return vertexCoordinates.map(coord => getEditorPointRenderer(coord, {
2443
- size: 6,
2444
- strokeWidth: 2,
2445
- shadowColor: this.shadowColor,
2446
- strokeColor: this.strokeColor,
2447
- shadowSize: this.vertexShadowSize !== undefined ? this.vertexShadowSize : 2,
2448
- fillColor: '#ffffff'
2449
- })).reduce((acc, curr) => acc.concat(curr), []);
2450
- }
2451
2413
  }]);
2452
2414
 
2453
- return ShadowedPolySymbol;
2454
- }(PolylineSymbol.PolylineSymbol);
2455
- const polySymbolParams = {
2456
- strokeWidth: 2,
2457
- strokeColor: '#e33600',
2458
- shadowSize: 8,
2459
- shadowColor: 'rgba(227, 54, 0, 0.3)'
2415
+ return SVGPoly;
2416
+ }(_Symbol.Symbol);
2417
+
2418
+ function isSGisPointSymbol(symbol) {
2419
+ return symbol instanceof Point.PointSymbol || symbol instanceof StaticImageSymbol.StaticImageSymbol || symbol instanceof Square.SquareSymbol || symbol instanceof MaskedImage.MaskedImage;
2420
+ }
2421
+ function isSGisImageSymbol(symbol) {
2422
+ return symbol instanceof StaticImageSymbol.StaticImageSymbol || symbol instanceof MaskedImage.MaskedImage;
2423
+ }
2424
+ function isSGisPolygonSymbol(symbol) {
2425
+ return symbol instanceof Simple.PolygonSymbol || symbol instanceof BrushFill.BrushFill || symbol instanceof ImageFill.ImageFill;
2426
+ }
2427
+ function isSGisPolylineSymbol(symbol) {
2428
+ return symbol instanceof PolylineSymbol.PolylineSymbol;
2429
+ }
2430
+
2431
+ /**
2432
+ * Моки фич для отображения превью символа
2433
+ * http://cf.everpoint.ru/pages/viewpage.action?pageId=45024217
2434
+ */
2435
+
2436
+ const viewBoxSize = 100;
2437
+ const pointFeature = /*#__PURE__*/new PointFeature.PointFeature([50, -50], {
2438
+ crs: Crs.plain
2439
+ });
2440
+ const lineFeature = /*#__PURE__*/new Polyline.Polyline([[0, -57], [26, -57], [40, -35], [60, -65], [74, -43], [100, -43]], {
2441
+ crs: Crs.plain
2442
+ });
2443
+ const polygonFeature = /*#__PURE__*/new Polygon.Polygon([[50, -15], [80, -33], [80, -67], [50, -85], [20, -67], [20, -33], [50, -15]], {
2444
+ crs: Crs.plain
2445
+ });
2446
+ const lineLegendFeature = /*#__PURE__*/new Polyline.Polyline([[0, -50], [100, -50]], {
2447
+ crs: Crs.plain
2448
+ });
2449
+ const polygonLegendFeature = /*#__PURE__*/new Polygon.Polygon([[0, 0], [100, 0], [100, -100], [0, -100]], {
2450
+ crs: Crs.plain
2451
+ });
2452
+ const polygonMapLegendFeature = /*#__PURE__*/new Polygon.Polygon([[50, 0], [100, -25], [100, -75], [50, -100], [0, -75], [0, -25]], {
2453
+ crs: Crs.plain
2454
+ });
2455
+ const MAP_LEGEND_FEATURES = {
2456
+ polygon: polygonMapLegendFeature
2460
2457
  };
2461
- const measureSymbolParams = {
2462
- strokeColor: '#ff6933',
2463
- shadowSize: 0,
2464
- vertexShadowSize: 0
2458
+ const LEGEND_FEATURES = {
2459
+ polyline: lineLegendFeature,
2460
+ polygon: polygonLegendFeature
2465
2461
  };
2466
- const measureLengthSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
2467
- enclose: false,
2468
- showVertex: true
2469
- }));
2470
- const measureAreaSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
2471
- fillColor: 'rgba(255, 105, 51, 0.25)',
2472
- enclose: true,
2473
- showVertex: true
2474
- }));
2475
- const snapSymbolParams = {
2476
- size: 10,
2477
- strokeWidth: 2,
2478
- strokeColor: '#e33600',
2479
- fillColor: '#ffffff',
2480
- shadowColor: 'rgba(227, 54, 0, 0.3)',
2481
- shadowSize: 3
2462
+ const MOCK_FEATURES = {
2463
+ point: pointFeature,
2464
+ polyline: lineFeature,
2465
+ polygon: polygonFeature
2482
2466
  };
2483
- const measurePolygonSnapSymbol = /*#__PURE__*/new ShadowedPointSymbol( /*#__PURE__*/_extends({}, snapSymbolParams, {
2484
- strokeColor: '#ff6933',
2485
- shadowSize: 0
2486
- }));
2487
-
2488
- let SelectedPointSymbol = /*#__PURE__*/function (_ShadowedPointSymbol) {
2489
- _inherits(SelectedPointSymbol, _ShadowedPointSymbol);
2490
-
2491
- var _super = /*#__PURE__*/_createSuper(SelectedPointSymbol);
2492
2467
 
2493
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2494
- function SelectedPointSymbol(props) {
2495
- _classCallCheck(this, SelectedPointSymbol);
2468
+ function getSymbolRenders(symbol, size, features) {
2469
+ if (size === void 0) {
2470
+ size = viewBoxSize;
2471
+ }
2496
2472
 
2497
- return _super.call(this, props);
2473
+ if (features === void 0) {
2474
+ features = {};
2498
2475
  }
2499
2476
 
2500
- _createClass(SelectedPointSymbol, [{
2501
- key: "getShadow",
2502
- value: function getShadow(position, feature) {
2503
- if (feature.isSelected) {
2504
- return _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getShadow", this).call(this, position, feature);
2505
- }
2506
- }
2507
- }, {
2508
- key: "getPoint",
2509
- value: function getPoint(position, feature) {
2510
- const pointRender = _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getPoint", this).call(this, position, feature);
2477
+ const resolution = viewBoxSize / size;
2511
2478
 
2512
- if (feature.isSelected) {
2513
- pointRender.strokeColor = this.selectedStrokeColor;
2514
- pointRender.fillColor = this.selectedFillColor;
2515
- }
2479
+ const featuresToRender = _extends({}, MOCK_FEATURES, features);
2516
2480
 
2517
- return pointRender;
2518
- }
2519
- }]);
2481
+ if (isSGisPolygonSymbol(symbol)) {
2482
+ return symbol.renderFunctionAsync(featuresToRender.polygon, resolution, Crs.plain);
2483
+ }
2520
2484
 
2521
- return SelectedPointSymbol;
2522
- }(ShadowedPointSymbol);
2485
+ if (isSGisPolylineSymbol(symbol)) {
2486
+ return symbol.renderFunctionAsync(featuresToRender.polyline, resolution, Crs.plain);
2487
+ }
2523
2488
 
2524
- let SelectedPolySymbol = /*#__PURE__*/function (_ShadowedPolySymbol) {
2525
- _inherits(SelectedPolySymbol, _ShadowedPolySymbol);
2489
+ return symbol.renderFunctionAsync(featuresToRender.point, resolution, Crs.plain);
2490
+ }
2491
+ const getMapLegendSymbolRenders = function getMapLegendSymbolRenders(symbol, size) {
2492
+ if (size === void 0) {
2493
+ size = viewBoxSize;
2494
+ }
2526
2495
 
2527
- var _super = /*#__PURE__*/_createSuper(SelectedPolySymbol);
2496
+ return getSymbolRenders(symbol, size, MAP_LEGEND_FEATURES);
2497
+ };
2498
+ const getLegendSymbolRenders = function getLegendSymbolRenders(symbol, size) {
2499
+ if (size === void 0) {
2500
+ size = viewBoxSize;
2501
+ }
2528
2502
 
2529
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2530
- function SelectedPolySymbol(props) {
2531
- _classCallCheck(this, SelectedPolySymbol);
2503
+ return getSymbolRenders(symbol, size, LEGEND_FEATURES);
2504
+ };
2532
2505
 
2533
- return _super.call(this, props);
2534
- }
2506
+ function renderSymbolToCanvas(renders, canvas) {
2507
+ renders.forEach(render => {
2508
+ canvas.draw(render);
2509
+ });
2510
+ }
2535
2511
 
2536
- _createClass(SelectedPolySymbol, [{
2537
- key: "getShadow",
2538
- value: function getShadow(coordinates, feature) {
2539
- if (feature.isSelected) {
2540
- return _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getShadow", this).call(this, coordinates, feature);
2541
- }
2542
- }
2543
- }, {
2544
- key: "getPolyRender",
2545
- value: function getPolyRender(coordinates, feature) {
2546
- const polyRender = _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getPolyRender", this).call(this, coordinates, feature);
2512
+ function deserializeSymbol(symbol) {
2513
+ switch (symbol.type) {
2514
+ case 'circlePointSymbol':
2515
+ return deserializePointSymbol(symbol);
2547
2516
 
2548
- if (feature.isSelected) {
2549
- polyRender.fillColor = this.selectedFillColor;
2550
- polyRender.strokeColor = this.selectedStrokeColor;
2517
+ case 'squarePointSymbol':
2518
+ return deserializeSquareSymbol(symbol);
2551
2519
 
2552
- if (this.selectedStrokeWidth !== void 0) {
2553
- polyRender.strokeWidth = this.selectedStrokeWidth;
2554
- }
2555
- }
2520
+ case 'maskedImagePointSymbol':
2521
+ return deserializeMaskedImageSymbol(symbol);
2556
2522
 
2557
- return polyRender;
2558
- }
2559
- }]);
2523
+ case 'imagePointSymbol':
2524
+ return deserializeImagePointSymbol(symbol);
2560
2525
 
2561
- return SelectedPolySymbol;
2562
- }(ShadowedPolySymbol);
2526
+ case 'polygonSymbol':
2527
+ return deserializePolygonSymbol(symbol);
2563
2528
 
2564
- const selectedPoint = /*#__PURE__*/new SelectedPointSymbol({
2565
- size: 8,
2566
- strokeWidth: 2,
2567
- strokeColor: 'rgba(255, 87, 34, 0.3)',
2568
- fillColor: 'rgba(255, 255, 255, 0.65)',
2569
- shadowColor: 'rgba(255, 87, 34, 0.3)',
2570
- shadowSize: 3,
2571
- selectedStrokeColor: '#ff5722',
2572
- selectedFillColor: 'rgba(255, 255, 255, 0.65)'
2573
- });
2574
- const selectedPolyline = /*#__PURE__*/new SelectedPolySymbol({
2575
- strokeWidth: 6,
2576
- strokeColor: 'rgba(255, 87, 34, 0.2)',
2577
- shadowSize: 8,
2578
- shadowColor: 'rgba(255, 87, 34, 0.3)',
2579
- selectedStrokeColor: '#ff5722',
2580
- selectedStrokeWidth: 2
2581
- });
2582
- const selectedPolygon = /*#__PURE__*/new SelectedPolySymbol({
2583
- strokeWidth: 2,
2584
- strokeColor: 'rgba(255, 87, 34, 0.3)',
2585
- shadowSize: 8,
2586
- shadowColor: 'rgba(255, 87, 34, 0.3)',
2587
- fillColor: 'rgba(255, 255, 255, 0.36)',
2588
- enclose: true,
2589
- selectedFillColor: 'rgba(255, 255, 255, 0.56)',
2590
- selectedStrokeColor: '#ff5722'
2591
- });
2529
+ case 'simplePolylineSymbol':
2530
+ case 'polylineSymbol':
2531
+ return deserializePolylineSymbol(symbol);
2592
2532
 
2593
- const defaultPathStyles = {
2594
- strokeWidth: 2,
2595
- strokeColor: 'rgb(0, 163, 245)',
2596
- fillStyle: Poly.FillStyle.None
2597
- };
2598
- let SVGPoly = /*#__PURE__*/function (_Symbol) {
2599
- _inherits(SVGPoly, _Symbol);
2533
+ default:
2534
+ return null;
2535
+ }
2536
+ }
2600
2537
 
2601
- var _super = /*#__PURE__*/_createSuper(SVGPoly);
2538
+ function deserializePointSymbol(symbol) {
2539
+ // @ts-ignore
2540
+ return new Point.PointSymbol(deserializePointSymbolParams(symbol));
2541
+ }
2602
2542
 
2603
- function SVGPoly(_temp) {
2604
- var _this;
2543
+ function deserializeSquareSymbol(symbol) {
2544
+ return new Square.SquareSymbol(_extends({}, deserializePointSymbolParams(symbol), {
2545
+ // @ts-ignore
2546
+ angle: getParameterValue(symbol.angle)
2547
+ }));
2548
+ }
2605
2549
 
2606
- let {
2607
- redrawFeatureNode,
2608
- pathStyles,
2609
- circle,
2610
- className,
2611
- appendToSvg
2612
- } = _temp === void 0 ? {} : _temp;
2550
+ function deserializeMaskedImageSymbol(symbol) {
2551
+ return new MaskedImage.MaskedImage(_extends({}, symbol, {
2552
+ // @ts-ignore
2553
+ angle: getParameterValue(symbol.angle),
2554
+ // @ts-ignore
2555
+ width: getParameterValue(symbol.width),
2556
+ // @ts-ignore
2557
+ height: getParameterValue(symbol.height),
2558
+ // @ts-ignore
2559
+ anchorPoint: deserializeAnchor(symbol.offset),
2560
+ // @ts-ignore
2561
+ imageSource: deserializeBase64(symbol.image),
2562
+ // @ts-ignore
2563
+ maskSource: deserializeBase64(symbol.imageMask),
2564
+ // @ts-ignore
2565
+ maskColor: deserializeColor(getParameterValue(symbol.maskedColor))
2566
+ }));
2567
+ }
2613
2568
 
2614
- _classCallCheck(this, SVGPoly);
2569
+ function deserializeImagePointSymbol(symbol) {
2570
+ return new StaticImageSymbol.StaticImageSymbol(_extends({}, symbol, {
2571
+ // @ts-ignore
2572
+ angle: getParameterValue(symbol.angle),
2573
+ // @ts-ignore
2574
+ width: getParameterValue(symbol.width),
2575
+ // @ts-ignore
2576
+ height: getParameterValue(symbol.height),
2577
+ // @ts-ignore
2578
+ anchorPoint: deserializeAnchor(symbol.offset),
2579
+ // @ts-ignore
2580
+ source: deserializeBase64(symbol.image)
2581
+ }));
2582
+ }
2615
2583
 
2616
- _this = _super.call(this);
2617
- _this.container = document.createElement('div');
2618
- _this.container.style.position = 'absolute';
2619
- _this.redrawFeatureNode = redrawFeatureNode;
2620
- _this.pathStyles = _extends({
2621
- center: [0, 0],
2622
- fillColor: 'none'
2623
- }, pathStyles);
2624
- _this.circle = circle;
2625
- _this.className = className;
2626
- _this.appendToSvg = appendToSvg;
2627
- return _this;
2584
+ function deserializePolygonSymbol(symbol) {
2585
+ if (isPolygonHasPatternBrush(symbol)) {
2586
+ return new SGisImageFill(symbol);
2628
2587
  }
2629
2588
 
2630
- _createClass(SVGPoly, [{
2631
- key: "renderFunction",
2632
- value: function renderFunction(feature, resolution, crs) {
2633
- const coordinates = feature instanceof Poly$1.Poly ? PolylineSymbol.PolylineSymbol.getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
2634
- this.setCirclePxRaius(crs);
2635
- this.container.innerHTML = '';
2636
- const svg = this.setSvg(coordinates);
2637
- svg && this.container.append(svg);
2638
- feature.__dynamicSymbolRender = new Render.DynamicRender({
2639
- node: this.container,
2640
- update: (bbox, resolution) => this.update({
2641
- bbox,
2642
- resolution,
2643
- feature,
2644
- crs
2645
- }),
2646
- redraw: () => {
2647
- this.redrawFeatureNode && this.redrawFeatureNode(feature);
2648
- }
2649
- });
2589
+ if (isPolygonHasHatchBrush(symbol)) {
2590
+ return new SGisBrushFill(symbol);
2591
+ }
2650
2592
 
2651
- this._setEventListeners(feature);
2593
+ return new SGisPolygonSymbol(symbol);
2594
+ }
2652
2595
 
2653
- return [feature.__dynamicSymbolRender];
2654
- }
2655
- }, {
2656
- key: "setCirclePxRaius",
2657
- value: function setCirclePxRaius(crs) {
2658
- if (this.circle && this.pathStyles) {
2659
- var _this$circle;
2596
+ function deserializePolylineSymbol(symbol) {
2597
+ return new SGisPolylineSymbol(symbol);
2598
+ }
2660
2599
 
2661
- this.pathStyles.radius = metersToPixels(this.circle.radius, {
2662
- painter: this.circle.painter,
2663
- crs
2664
- }) + (((_this$circle = this.circle) == null ? void 0 : _this$circle.pxOffset) || 0);
2665
- }
2666
- }
2667
- }, {
2668
- key: "update",
2669
- value: function update(_ref) {
2670
- var _this$pathStyles, _this$pathStyles2, _this$pathStyles3, _this$pathStyles4;
2600
+ function deserializePointSymbolParams(_ref) {
2601
+ let {
2602
+ size,
2603
+ offset,
2604
+ strokeColor,
2605
+ strokeWidth,
2606
+ fillColor
2607
+ } = _ref;
2608
+ return {
2609
+ size: getParameterValue(size),
2610
+ offset: deserializeAnchor(offset),
2611
+ strokeWidth: getParameterValue(strokeWidth),
2612
+ strokeColor: deserializeColor(getParameterValue(strokeColor)),
2613
+ fillColor: deserializeColor(getParameterValue(fillColor))
2614
+ };
2615
+ }
2671
2616
 
2672
- let {
2673
- bbox,
2674
- resolution,
2675
- feature,
2676
- crs
2677
- } = _ref;
2678
- if (!feature) return;
2679
- if (!bbox) bbox = feature.__lastBbox;
2680
- if (!resolution) resolution = feature.__lastResolution;
2681
- if (!bbox || !resolution || !feature.crs.canProjectTo(bbox.crs)) return;
2617
+ function deserializeBase64(base) {
2618
+ return "data:image/png;base64," + base;
2619
+ }
2682
2620
 
2683
- if (feature.__lastResolution && resolution !== feature.__lastResolution) {
2684
- const newCoordinates = feature instanceof Poly$1.Poly ? PolylineSymbol.PolylineSymbol.getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
2685
- this.setCirclePxRaius(crs);
2686
- this.container.innerHTML = '';
2687
- const svg = this.setSvg(newCoordinates);
2688
- svg && this.container.append(svg);
2689
- }
2621
+ function deserializeAnchor(offset) {
2622
+ // @ts-ignore
2623
+ return offset.map(getParameterValue);
2624
+ }
2690
2625
 
2691
- const polygon = feature.projectTo(bbox.crs);
2692
- 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;
2693
- const dx = Math.round((polygon.bbox.xMin - bbox.xMin) / resolution) - radiusOffset;
2694
- const dy = Math.round((bbox.yMax - polygon.bbox.yMax) / resolution) - radiusOffset;
2695
- this.container.style.left = dx.toString() + "px";
2696
- this.container.style.top = dy.toString() + "px";
2697
- feature.__lastBbox = bbox;
2698
- feature.__lastResolution = resolution;
2699
- }
2700
- }, {
2701
- key: "setSvg",
2702
- value: function setSvg(coordinates) {
2703
- const {
2704
- lineCap,
2705
- lineJoin,
2706
- miterLimit,
2707
- lineDash,
2708
- dashOffset
2709
- } = this.pathStyles || {};
2710
- const svgRender = new SvgRender.SvgRender(_extends({
2711
- coordinates
2712
- }, defaultPathStyles, {
2713
- appendToSvg: this.appendToSvg
2714
- }, this.pathStyles));
2715
-
2716
- if (this.circle) {
2717
- svgRender._setArcNode();
2718
- } else {
2719
- svgRender._setPolyNode();
2720
- }
2721
-
2722
- let svgElement;
2723
- svgRender.getNode((_, svg) => {
2724
- svgElement = svg;
2725
- this.className && svgElement.classList.add(this.className);
2726
- const path = svgElement && svgElement.querySelector(this.circle ? 'circle' : 'path');
2727
-
2728
- if (path) {
2729
- path.setAttribute('stroke-linecap', lineCap || 'round');
2730
- path.setAttribute('stroke-linejoin', lineJoin || 'round');
2731
- path.setAttribute('stroke-miterlimit', (miterLimit || 10).toString());
2732
- path.setAttribute('stroke-dashoffset', (dashOffset || 0).toString());
2733
-
2734
- if (this.circle) {
2735
- path.setAttribute('stroke-dasharray', lineDash && lineDash.length > 0 ? lineDash.join(',') : '');
2736
- }
2737
- }
2738
- });
2739
- return svgElement;
2740
- }
2741
- }, {
2742
- key: "_setEventListeners",
2743
- value: function _setEventListeners(dynamicFeature) {
2744
- var _dynamicFeature$__dyn;
2745
-
2746
- if (dynamicFeature.eventFlags === EventHandler.MouseEventFlags.None) return;
2747
- const svgNode = dynamicFeature == null ? void 0 : (_dynamicFeature$__dyn = dynamicFeature.__dynamicSymbolRender) == null ? void 0 : _dynamicFeature$__dyn.node.querySelector(this.circle ? 'circle' : 'path');
2748
- Object.keys(EventHandler.mouseEvents).forEach(eventName => {
2749
- if (dynamicFeature.eventFlags & EventHandler.mouseEvents[eventName].flag) {
2750
- domEvent.listenDomEvent(svgNode, EventHandler.mouseEvents[eventName].type, event => {
2751
- dynamicFeature.fire(EventHandler.mouseEvents[eventName].type, {
2752
- node: svgNode,
2753
- browserEvent: event
2754
- });
2755
- });
2756
- }
2757
- });
2758
- }
2759
- }]);
2760
-
2761
- return SVGPoly;
2762
- }(_Symbol.Symbol);
2763
-
2764
- function isSGisPointSymbol(symbol) {
2765
- return symbol instanceof Point.PointSymbol || symbol instanceof StaticImageSymbol.StaticImageSymbol || symbol instanceof Square.SquareSymbol || symbol instanceof MaskedImage.MaskedImage;
2766
- }
2767
- function isSGisImageSymbol(symbol) {
2768
- return symbol instanceof StaticImageSymbol.StaticImageSymbol || symbol instanceof MaskedImage.MaskedImage;
2769
- }
2770
- function isSGisPolygonSymbol(symbol) {
2771
- return symbol instanceof Simple.PolygonSymbol || symbol instanceof BrushFill.BrushFill || symbol instanceof ImageFill.ImageFill;
2772
- }
2773
- function isSGisPolylineSymbol(symbol) {
2774
- return symbol instanceof PolylineSymbol.PolylineSymbol;
2626
+ function deserializeColor(color$1) {
2627
+ return color$1 ? new color.Color(color$1).toString() : null;
2775
2628
  }
2776
2629
 
2777
- /**
2778
- * Моки фич для отображения превью символа
2779
- * http://cf.everpoint.ru/pages/viewpage.action?pageId=45024217
2780
- */
2781
-
2782
- const viewBoxSize = 100;
2783
- const pointFeature = /*#__PURE__*/new PointFeature.PointFeature([50, -50], {
2784
- crs: Crs.plain
2785
- });
2786
- const lineFeature = /*#__PURE__*/new Polyline.Polyline([[0, -57], [26, -57], [40, -35], [60, -65], [74, -43], [100, -43]], {
2787
- crs: Crs.plain
2788
- });
2789
- const polygonFeature = /*#__PURE__*/new Polygon.Polygon([[50, -15], [80, -33], [80, -67], [50, -85], [20, -67], [20, -33], [50, -15]], {
2790
- crs: Crs.plain
2791
- });
2792
- const lineLegendFeature = /*#__PURE__*/new Polyline.Polyline([[0, -50], [100, -50]], {
2793
- crs: Crs.plain
2794
- });
2795
- const polygonLegendFeature = /*#__PURE__*/new Polygon.Polygon([[0, 0], [100, 0], [100, -100], [0, -100]], {
2796
- crs: Crs.plain
2797
- });
2798
- const polygonMapLegendFeature = /*#__PURE__*/new Polygon.Polygon([[50, 0], [100, -25], [100, -75], [50, -100], [0, -75], [0, -25]], {
2799
- crs: Crs.plain
2800
- });
2801
- const MAP_LEGEND_FEATURES = {
2802
- polygon: polygonMapLegendFeature
2803
- };
2804
- const LEGEND_FEATURES = {
2805
- polyline: lineLegendFeature,
2806
- polygon: polygonLegendFeature
2807
- };
2808
- const MOCK_FEATURES = {
2809
- point: pointFeature,
2810
- polyline: lineFeature,
2811
- polygon: polygonFeature
2812
- };
2813
-
2814
- function getSymbolRenders(symbol, size, features) {
2815
- if (size === void 0) {
2816
- size = viewBoxSize;
2630
+ const clampSymbol = (symbol, min, max) => {
2631
+ if (isSGisImageSymbol(symbol)) {
2632
+ symbol.width = clamp(symbol.width, min, max);
2633
+ symbol.height = clamp(symbol.height, min, max);
2634
+ } else if (isSGisPointSymbol(symbol)) {
2635
+ symbol.size = clamp(symbol.size, min, max);
2817
2636
  }
2818
2637
 
2819
- if (features === void 0) {
2820
- features = {};
2638
+ return symbol;
2639
+ };
2640
+ function centerAlignSymbol(symbol) {
2641
+ if (isSGisImageSymbol(symbol)) {
2642
+ symbol.anchorPoint = [symbol.width / 2, symbol.height / 2];
2643
+ } else if (isSGisPointSymbol(symbol)) {
2644
+ symbol.offset = [0, 0];
2821
2645
  }
2822
2646
 
2823
- const resolution = viewBoxSize / size;
2647
+ return symbol;
2648
+ }
2649
+ const adjustSymbol = (symbol, _ref) => {
2650
+ let {
2651
+ size
2652
+ } = _ref;
2653
+ return centerAlignSymbol(clampSymbol(symbol, 0, size));
2654
+ };
2824
2655
 
2825
- const featuresToRender = _extends({}, MOCK_FEATURES, features);
2656
+ let EvergisFeature = /*#__PURE__*/function () {
2657
+ function EvergisFeature(feature) {
2658
+ _classCallCheck(this, EvergisFeature);
2826
2659
 
2827
- if (isSGisPolygonSymbol(symbol)) {
2828
- return symbol.renderFunctionAsync(featuresToRender.polygon, resolution, Crs.plain);
2660
+ this.id = null;
2661
+ this.displayName = null;
2662
+ this.geometry = null;
2663
+ this.layerName = null;
2664
+ this.layerAlias = null;
2665
+ this.attributes = null;
2666
+ this.symbol = null;
2667
+ this.id = feature.id;
2668
+ this.displayName = feature.id;
2669
+ this.geometry = feature.geometry;
2670
+ this.layerName = feature.layer;
2671
+ this.layerAlias = feature.layer;
2672
+ this.attributes = getFeatureAttributes(feature.attributes);
2829
2673
  }
2830
2674
 
2831
- if (isSGisPolylineSymbol(symbol)) {
2832
- return symbol.renderFunctionAsync(featuresToRender.polyline, resolution, Crs.plain);
2833
- }
2675
+ _createClass(EvergisFeature, [{
2676
+ key: "sGisFeature",
2677
+ value: function sGisFeature() {
2678
+ if (!this.geometry || !this.symbol) {
2679
+ return null;
2680
+ } // @ts-ignore
2834
2681
 
2835
- return symbol.renderFunctionAsync(featuresToRender.point, resolution, Crs.plain);
2836
- }
2837
- const getMapLegendSymbolRenders = function getMapLegendSymbolRenders(symbol, size) {
2838
- if (size === void 0) {
2839
- size = viewBoxSize;
2840
- }
2841
2682
 
2842
- return getSymbolRenders(symbol, size, MAP_LEGEND_FEATURES);
2843
- };
2844
- const getLegendSymbolRenders = function getLegendSymbolRenders(symbol, size) {
2845
- if (size === void 0) {
2846
- size = viewBoxSize;
2847
- }
2683
+ const {
2684
+ type,
2685
+ coordinates,
2686
+ sr
2687
+ } = this.geometry;
2688
+ const crs = CRS_MAP[sr];
2848
2689
 
2849
- return getSymbolRenders(symbol, size, LEGEND_FEATURES);
2850
- };
2690
+ if (!crs) {
2691
+ return null;
2692
+ }
2851
2693
 
2852
- function renderSymbolToCanvas(renders, canvas) {
2853
- renders.forEach(render => {
2854
- canvas.draw(render);
2855
- });
2856
- }
2694
+ switch (type) {
2695
+ case api.GeometryType.Point:
2696
+ return new PointFeature.PointFeature(coordinates, {
2697
+ symbol: selectedPoint,
2698
+ crs
2699
+ });
2857
2700
 
2858
- function deserializeSymbol(symbol) {
2859
- switch (symbol.type) {
2860
- case 'circlePointSymbol':
2861
- return deserializePointSymbol(symbol);
2701
+ case api.GeometryType.Multipoint:
2702
+ return new MultiPoint.MultiPoint(coordinates, {
2703
+ symbol: selectedPoint,
2704
+ crs
2705
+ });
2862
2706
 
2863
- case 'squarePointSymbol':
2864
- return deserializeSquareSymbol(symbol);
2707
+ case api.GeometryType.Polyline:
2708
+ return new Polyline.Polyline(coordinates, {
2709
+ symbol: selectedPolyline,
2710
+ crs
2711
+ });
2865
2712
 
2866
- case 'maskedImagePointSymbol':
2867
- return deserializeMaskedImageSymbol(symbol);
2713
+ case api.GeometryType.Polygon:
2714
+ return new Polygon.Polygon(coordinates, {
2715
+ symbol: selectedPolygon,
2716
+ crs
2717
+ });
2868
2718
 
2869
- case 'imagePointSymbol':
2870
- return deserializeImagePointSymbol(symbol);
2719
+ default:
2720
+ return null;
2721
+ }
2722
+ }
2723
+ }, {
2724
+ key: "extent",
2725
+ value: function extent() {
2726
+ const feature = this.sGisFeature();
2727
+ return feature && feature.bbox;
2728
+ }
2729
+ }]);
2871
2730
 
2872
- case 'polygonSymbol':
2873
- return deserializePolygonSymbol(symbol);
2731
+ return EvergisFeature;
2732
+ }();
2874
2733
 
2875
- case 'simplePolylineSymbol':
2876
- case 'polylineSymbol':
2877
- return deserializePolylineSymbol(symbol);
2734
+ function evaluateCondition(condition$1, attributes) {
2735
+ try {
2736
+ const evaluator = new condition.ConditionEvaluator(attributes);
2737
+ const result = evaluator.evaluate(condition$1);
2878
2738
 
2879
- default:
2739
+ if (result instanceof Error) {
2880
2740
  return null;
2881
- }
2882
- }
2883
-
2884
- function deserializePointSymbol(symbol) {
2885
- // @ts-ignore
2886
- return new Point.PointSymbol(deserializePointSymbolParams(symbol));
2887
- }
2888
-
2889
- function deserializeSquareSymbol(symbol) {
2890
- return new Square.SquareSymbol(_extends({}, deserializePointSymbolParams(symbol), {
2891
- // @ts-ignore
2892
- angle: getParameterValue(symbol.angle)
2893
- }));
2894
- }
2895
-
2896
- function deserializeMaskedImageSymbol(symbol) {
2897
- return new MaskedImage.MaskedImage(_extends({}, symbol, {
2898
- // @ts-ignore
2899
- angle: getParameterValue(symbol.angle),
2900
- // @ts-ignore
2901
- width: getParameterValue(symbol.width),
2902
- // @ts-ignore
2903
- height: getParameterValue(symbol.height),
2904
- // @ts-ignore
2905
- anchorPoint: deserializeAnchor(symbol.offset),
2906
- // @ts-ignore
2907
- imageSource: deserializeBase64(symbol.image),
2908
- // @ts-ignore
2909
- maskSource: deserializeBase64(symbol.imageMask),
2910
- // @ts-ignore
2911
- maskColor: deserializeColor(getParameterValue(symbol.maskedColor))
2912
- }));
2913
- }
2914
-
2915
- function deserializeImagePointSymbol(symbol) {
2916
- return new StaticImageSymbol.StaticImageSymbol(_extends({}, symbol, {
2917
- // @ts-ignore
2918
- angle: getParameterValue(symbol.angle),
2919
- // @ts-ignore
2920
- width: getParameterValue(symbol.width),
2921
- // @ts-ignore
2922
- height: getParameterValue(symbol.height),
2923
- // @ts-ignore
2924
- anchorPoint: deserializeAnchor(symbol.offset),
2925
- // @ts-ignore
2926
- source: deserializeBase64(symbol.image)
2927
- }));
2928
- }
2929
-
2930
- function deserializePolygonSymbol(symbol) {
2931
- if (isPolygonHasPatternBrush(symbol)) {
2932
- return new SGisImageFill(symbol);
2933
- }
2934
-
2935
- if (isPolygonHasHatchBrush(symbol)) {
2936
- return new SGisBrushFill(symbol);
2937
- }
2938
-
2939
- return new SGisPolygonSymbol(symbol);
2940
- }
2941
-
2942
- function deserializePolylineSymbol(symbol) {
2943
- return new SGisPolylineSymbol(symbol);
2944
- }
2945
-
2946
- function deserializePointSymbolParams(_ref) {
2947
- let {
2948
- size,
2949
- offset,
2950
- strokeColor,
2951
- strokeWidth,
2952
- fillColor
2953
- } = _ref;
2954
- return {
2955
- size: getParameterValue(size),
2956
- offset: deserializeAnchor(offset),
2957
- strokeWidth: getParameterValue(strokeWidth),
2958
- strokeColor: deserializeColor(getParameterValue(strokeColor)),
2959
- fillColor: deserializeColor(getParameterValue(fillColor))
2960
- };
2961
- }
2962
-
2963
- function deserializeBase64(base) {
2964
- return "data:image/png;base64," + base;
2965
- }
2966
-
2967
- function deserializeAnchor(offset) {
2968
- // @ts-ignore
2969
- return offset.map(getParameterValue);
2970
- }
2971
-
2972
- function deserializeColor(color$1) {
2973
- return color$1 ? new color.Color(color$1).toString() : null;
2974
- }
2975
-
2976
- const clampSymbol = (symbol, min, max) => {
2977
- if (isSGisImageSymbol(symbol)) {
2978
- symbol.width = clamp(symbol.width, min, max);
2979
- symbol.height = clamp(symbol.height, min, max);
2980
- } else if (isSGisPointSymbol(symbol)) {
2981
- symbol.size = clamp(symbol.size, min, max);
2982
- }
2983
-
2984
- return symbol;
2985
- };
2986
- function centerAlignSymbol(symbol) {
2987
- if (isSGisImageSymbol(symbol)) {
2988
- symbol.anchorPoint = [symbol.width / 2, symbol.height / 2];
2989
- } else if (isSGisPointSymbol(symbol)) {
2990
- symbol.offset = [0, 0];
2991
- }
2992
-
2993
- return symbol;
2994
- }
2995
- const adjustSymbol = (symbol, _ref) => {
2996
- let {
2997
- size
2998
- } = _ref;
2999
- return centerAlignSymbol(clampSymbol(symbol, 0, size));
3000
- };
3001
-
3002
- let EvergisFeature = /*#__PURE__*/function () {
3003
- function EvergisFeature(feature) {
3004
- _classCallCheck(this, EvergisFeature);
3005
-
3006
- this.id = null;
3007
- this.displayName = null;
3008
- this.geometry = null;
3009
- this.layerName = null;
3010
- this.layerAlias = null;
3011
- this.attributes = null;
3012
- this.symbol = null;
3013
- this.id = feature.id;
3014
- this.displayName = feature.id;
3015
- this.geometry = feature.geometry;
3016
- this.layerName = feature.layer;
3017
- this.layerAlias = feature.layer;
3018
- this.attributes = getFeatureAttributes(feature.attributes);
3019
- }
3020
-
3021
- _createClass(EvergisFeature, [{
3022
- key: "sGisFeature",
3023
- value: function sGisFeature() {
3024
- if (!this.geometry || !this.symbol) {
3025
- return null;
3026
- } // @ts-ignore
3027
-
3028
-
3029
- const {
3030
- type,
3031
- coordinates,
3032
- sr
3033
- } = this.geometry;
3034
- const crs = CRS_MAP[sr];
3035
-
3036
- if (!crs) {
3037
- return null;
3038
- }
3039
-
3040
- switch (type) {
3041
- case api.GeometryType.Point:
3042
- return new PointFeature.PointFeature(coordinates, {
3043
- symbol: selectedPoint,
3044
- crs
3045
- });
3046
-
3047
- case api.GeometryType.Multipoint:
3048
- return new MultiPoint.MultiPoint(coordinates, {
3049
- symbol: selectedPoint,
3050
- crs
3051
- });
3052
-
3053
- case api.GeometryType.Polyline:
3054
- return new Polyline.Polyline(coordinates, {
3055
- symbol: selectedPolyline,
3056
- crs
3057
- });
3058
-
3059
- case api.GeometryType.Polygon:
3060
- return new Polygon.Polygon(coordinates, {
3061
- symbol: selectedPolygon,
3062
- crs
3063
- });
3064
-
3065
- default:
3066
- return null;
3067
- }
3068
- }
3069
- }, {
3070
- key: "extent",
3071
- value: function extent() {
3072
- const feature = this.sGisFeature();
3073
- return feature && feature.bbox;
3074
- }
3075
- }]);
3076
-
3077
- return EvergisFeature;
3078
- }();
3079
-
3080
- function evaluateCondition(condition$1, attributes) {
3081
- try {
3082
- const evaluator = new condition.ConditionEvaluator(attributes);
3083
- const result = evaluator.evaluate(condition$1);
3084
-
3085
- if (result instanceof Error) {
3086
- return null;
3087
- }
2741
+ }
3088
2742
 
3089
2743
  return result;
3090
2744
  } catch (_unused) {
@@ -3093,7 +2747,7 @@ function evaluateCondition(condition$1, attributes) {
3093
2747
  }
3094
2748
 
3095
2749
  function getAttributeValue(attributes, attributeName) {
3096
- const attributeMeta = attributes.find(_ref => {
2750
+ const attributeMeta = attributes.find((_ref) => {
3097
2751
  let {
3098
2752
  name
3099
2753
  } = _ref;
@@ -3107,7 +2761,7 @@ const getAttributeNameFromClassified = values => values.length > 0 ? getAttribut
3107
2761
 
3108
2762
  function findFeatureValue(parameterValues, _ref2) {
3109
2763
  let [name, value] = _ref2;
3110
- return value !== null ? parameterValues.find(_ref3 => {
2764
+ return value !== null ? parameterValues.find((_ref3) => {
3111
2765
  let {
3112
2766
  condition
3113
2767
  } = _ref3;
@@ -3147,7 +2801,7 @@ function evaluateFeatureSymbol(attributes) {
3147
2801
  }
3148
2802
 
3149
2803
  function findChildFeatureStyle(childStyles, attributes) {
3150
- return (childStyles || []).find(_ref5 => {
2804
+ return (childStyles || []).find((_ref5) => {
3151
2805
  let {
3152
2806
  condition
3153
2807
  } = _ref5;
@@ -3208,7 +2862,7 @@ let EvergisLayer = /*#__PURE__*/function () {
3208
2862
  feature.attributes = mergeAttributes(feature.attributes || [], this.attributes || []);
3209
2863
  feature.symbol = this.style && getFeatureSymbol(this.style, feature.attributes);
3210
2864
  feature.layerAlias = this.alias;
3211
- const titleAttribute = (feature.attributes || []).find(_ref => {
2865
+ const titleAttribute = (feature.attributes || []).find((_ref) => {
3212
2866
  let {
3213
2867
  name
3214
2868
  } = _ref;
@@ -3231,7 +2885,7 @@ const evaluateFeature = layers => feature => {
3231
2885
  };
3232
2886
 
3233
2887
  const OTHERS_TITLE = 'Другое';
3234
- const createLegendItem = _ref => {
2888
+ const createLegendItem = (_ref) => {
3235
2889
  let {
3236
2890
  attributes,
3237
2891
  renderTitle,
@@ -3273,7 +2927,7 @@ function createStyleLegend(style, config) {
3273
2927
  classificationManager,
3274
2928
  symbol
3275
2929
  } = style;
3276
- const items = classificationManager.filter(_ref => {
2930
+ const items = classificationManager.filter((_ref) => {
3277
2931
  let {
3278
2932
  parameter
3279
2933
  } = _ref;
@@ -3390,7 +3044,7 @@ const useMapLegend = (layer, config) => {
3390
3044
  };
3391
3045
 
3392
3046
  const LEGEND_SYMBOL_MAX_SIZE = 32;
3393
- const useLegendValueSymbol = _ref => {
3047
+ const useLegendValueSymbol = (_ref) => {
3394
3048
  let {
3395
3049
  parameter,
3396
3050
  parameterValue
@@ -3792,7 +3446,7 @@ function useMapWrapper() {
3792
3446
  return wrapperRef;
3793
3447
  }
3794
3448
 
3795
- const byScale = scale => _ref => {
3449
+ const byScale = scale => (_ref) => {
3796
3450
  let {
3797
3451
  zIndex
3798
3452
  } = _ref;
@@ -3991,7 +3645,7 @@ const useTooltip = function useTooltip(zIndex) {
3991
3645
 
3992
3646
  return reset;
3993
3647
  }, [reset, map, layer, zIndex]);
3994
- const onSetLabelFeature = React.useCallback(_ref => {
3648
+ const onSetLabelFeature = React.useCallback((_ref) => {
3995
3649
  let {
3996
3650
  point,
3997
3651
  position,
@@ -4155,7 +3809,7 @@ function useClusterLayer(_ref) {
4155
3809
  }
4156
3810
 
4157
3811
  const INIT_FEATURES = [];
4158
- const useEvergisSelect = _ref => {
3812
+ const useEvergisSelect = (_ref) => {
4159
3813
  let {
4160
3814
  onPick,
4161
3815
  onFeatures
@@ -4188,7 +3842,7 @@ function none() {
4188
3842
  return;
4189
3843
  }
4190
3844
 
4191
- const useDraggableMarker = _ref => {
3845
+ const useDraggableMarker = (_ref) => {
4192
3846
  let {
4193
3847
  position,
4194
3848
  onChange,
@@ -4304,7 +3958,7 @@ const useDebouncedCallback = interval => {
4304
3958
  }, interval), [interval]);
4305
3959
  };
4306
3960
 
4307
- const Symbol = _ref => {
3961
+ const Symbol = (_ref) => {
4308
3962
  let {
4309
3963
  symbol,
4310
3964
  size,
@@ -4325,7 +3979,7 @@ const Symbol = _ref => {
4325
3979
  };
4326
3980
 
4327
3981
  var _templateObject;
4328
- const CompoundIcon = /*#__PURE__*/styled__default.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background: ", ";\n height: 32px;\n width: 32px;\n"])), _ref => {
3982
+ const CompoundIcon = /*#__PURE__*/styled__default.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background: ", ";\n height: 32px;\n width: 32px;\n"])), (_ref) => {
4329
3983
  let {
4330
3984
  geometryType,
4331
3985
  icons
@@ -4334,7 +3988,7 @@ const CompoundIcon = /*#__PURE__*/styled__default.div(_templateObject || (_templ
4334
3988
  });
4335
3989
 
4336
3990
  const MAX_SIZE = 32;
4337
- const StyleSymbol = _ref => {
3991
+ const StyleSymbol = (_ref) => {
4338
3992
  let {
4339
3993
  symbol,
4340
3994
  size = MAX_SIZE,
@@ -4379,7 +4033,7 @@ const CloseIcon = /*#__PURE__*/styled__default(ui.Icon)(_templateObject20 || (_t
4379
4033
  const PrevIcon = /*#__PURE__*/styled__default(ui.Icon)(_templateObject21 || (_templateObject21 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), featureCardIconMixin);
4380
4034
  const NextIcon = /*#__PURE__*/styled__default(ui.Icon)(_templateObject22 || (_templateObject22 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), featureCardIconMixin);
4381
4035
 
4382
- const MailValue = _ref => {
4036
+ const MailValue = (_ref) => {
4383
4037
  let {
4384
4038
  mail
4385
4039
  } = _ref;
@@ -4390,7 +4044,7 @@ const MailValue = _ref => {
4390
4044
  }, mail);
4391
4045
  };
4392
4046
 
4393
- const PhoneValue = _ref => {
4047
+ const PhoneValue = (_ref) => {
4394
4048
  let {
4395
4049
  phone
4396
4050
  } = _ref;
@@ -4401,7 +4055,7 @@ const PhoneValue = _ref => {
4401
4055
  }, phone);
4402
4056
  };
4403
4057
 
4404
- const UrlValue = _ref => {
4058
+ const UrlValue = (_ref) => {
4405
4059
  let {
4406
4060
  url
4407
4061
  } = _ref;
@@ -4412,7 +4066,7 @@ const UrlValue = _ref => {
4412
4066
  }, url);
4413
4067
  };
4414
4068
 
4415
- const AttributeValue = _ref => {
4069
+ const AttributeValue = (_ref) => {
4416
4070
  let {
4417
4071
  attribute
4418
4072
  } = _ref;
@@ -4426,29 +4080,29 @@ const AttributeValue = _ref => {
4426
4080
  if (attributeValue.type === 2
4427
4081
  /* Url */
4428
4082
  ) {
4429
- return React__default.createElement(UrlValue, {
4430
- key: key,
4431
- url: punycodeDecode(value)
4432
- });
4433
- }
4083
+ return React__default.createElement(UrlValue, {
4084
+ key: key,
4085
+ url: punycodeDecode(value)
4086
+ });
4087
+ }
4434
4088
 
4435
4089
  if (attributeValue.type === 3
4436
4090
  /* Mail */
4437
4091
  ) {
4438
- return React__default.createElement(MailValue, {
4439
- key: key,
4440
- mail: value
4441
- });
4442
- }
4092
+ return React__default.createElement(MailValue, {
4093
+ key: key,
4094
+ mail: value
4095
+ });
4096
+ }
4443
4097
 
4444
4098
  if (attributeValue.type === 1
4445
4099
  /* Phone */
4446
4100
  ) {
4447
- return React__default.createElement(PhoneValue, {
4448
- key: key,
4449
- phone: value
4450
- });
4451
- }
4101
+ return React__default.createElement(PhoneValue, {
4102
+ key: key,
4103
+ phone: value
4104
+ });
4105
+ }
4452
4106
 
4453
4107
  return React__default.createElement(SimpleAttribute, {
4454
4108
  key: value
@@ -4464,7 +4118,7 @@ function punycodeDecode(domains) {
4464
4118
  }
4465
4119
  }
4466
4120
 
4467
- const EvergisCardAttribute = _ref => {
4121
+ const EvergisCardAttribute = (_ref) => {
4468
4122
  let {
4469
4123
  attribute,
4470
4124
  className
@@ -4476,7 +4130,7 @@ const EvergisCardAttribute = _ref => {
4476
4130
  }));
4477
4131
  };
4478
4132
 
4479
- const StyledCard = _ref => {
4133
+ const StyledCard = (_ref) => {
4480
4134
  let {
4481
4135
  features = [],
4482
4136
  className,
@@ -4527,7 +4181,7 @@ const StyledCard = _ref => {
4527
4181
  };
4528
4182
 
4529
4183
  const _excluded$1 = ["renderCard", "className", "children"];
4530
- const EvergisCard = _ref => {
4184
+ const EvergisCard = (_ref) => {
4531
4185
  let {
4532
4186
  renderCard,
4533
4187
  className,
@@ -4579,7 +4233,7 @@ const toSgis = feature => feature.sGisFeature(); // TODO inner hooks???
4579
4233
 
4580
4234
  const useSGisFeatures = (features, currentIndex) => React.useMemo(() => features.map(toSgis).filter(truthly).map(setSelected(currentIndex)), [features, currentIndex]);
4581
4235
 
4582
- const EvergisSelectLayer = _ref => {
4236
+ const EvergisSelectLayer = (_ref) => {
4583
4237
  let {
4584
4238
  features,
4585
4239
  zIndex,
@@ -4624,7 +4278,7 @@ const TileLayer = props => {
4624
4278
  };
4625
4279
 
4626
4280
  const defaultZIndex = 200;
4627
- const EvergisSelect = _ref => {
4281
+ const EvergisSelect = (_ref) => {
4628
4282
  let {
4629
4283
  onPick,
4630
4284
  className,
@@ -4659,7 +4313,7 @@ const LegendSymbolTitle = /*#__PURE__*/styled__default.p(_templateObject3$1 || (
4659
4313
  const LegendValueContainer = /*#__PURE__*/styled__default.div(_templateObject4$1 || (_templateObject4$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n font-size: 0.625rem;\n padding: 0.125rem 0;\n\n ", " {\n padding-left: 0.5rem;\n }\n"])), LegendSymbolTitle);
4660
4314
  const LegendSectionHeader = /*#__PURE__*/styled__default.div(_templateObject5$1 || (_templateObject5$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-top: 0.5rem;\n font-size: 0.75rem;\n"])));
4661
4315
 
4662
- const LegendSection = _ref => {
4316
+ const LegendSection = (_ref) => {
4663
4317
  let {
4664
4318
  item,
4665
4319
  renderLegendTitle,
@@ -4676,7 +4330,7 @@ SearchPrefix.defaultProps = {
4676
4330
  kind: "search"
4677
4331
  };
4678
4332
 
4679
- const SearchInput = _ref => {
4333
+ const SearchInput = (_ref) => {
4680
4334
  let {
4681
4335
  onChange
4682
4336
  } = _ref;
@@ -4685,7 +4339,7 @@ const SearchInput = _ref => {
4685
4339
  }));
4686
4340
  };
4687
4341
 
4688
- const LegendSymbol = _ref => {
4342
+ const LegendSymbol = (_ref) => {
4689
4343
  let {
4690
4344
  parameter,
4691
4345
  parameterValue,
@@ -4703,7 +4357,7 @@ const LegendSymbol = _ref => {
4703
4357
  return React__default.createElement(React__default.Fragment, null, children(symbol));
4704
4358
  };
4705
4359
 
4706
- const LegendValue = _ref => {
4360
+ const LegendValue = (_ref) => {
4707
4361
  let {
4708
4362
  value,
4709
4363
  parameter,
@@ -4725,7 +4379,7 @@ const getNumberParam = (parameterValue, param) => {
4725
4379
  return typeof parameterValue === 'object' && param in parameterValue && typeof parameterValue[param] === 'number' ? parameterValue[param] : null;
4726
4380
  };
4727
4381
 
4728
- const getSymbolSize = _ref => {
4382
+ const getSymbolSize = (_ref) => {
4729
4383
  let {
4730
4384
  parameterValue,
4731
4385
  maxSize
@@ -4750,7 +4404,7 @@ const getSymbolSize = _ref => {
4750
4404
  }
4751
4405
  };
4752
4406
 
4753
- const Legend = _ref => {
4407
+ const Legend = (_ref) => {
4754
4408
  let {
4755
4409
  layer,
4756
4410
  children,
@@ -4793,7 +4447,7 @@ const Legend = _ref => {
4793
4447
  })))));
4794
4448
  };
4795
4449
 
4796
- const Map = _ref => {
4450
+ const Map = (_ref) => {
4797
4451
  let {
4798
4452
  className,
4799
4453
  position,
@@ -4815,163 +4469,488 @@ const Map = _ref => {
4815
4469
  })) {
4816
4470
  onBboxChange(state);
4817
4471
  }
4818
- }, [map, onBboxChange, position, resolution]);
4819
- useUpdateMapView({
4820
- position,
4821
- resolution
4822
- });
4823
- useMaxMinScale(minScale, maxScale, position, resolution);
4824
- useMapBboxChange(handleBboxChange);
4825
- return React__default.createElement("div", {
4826
- className: className,
4827
- ref: wrapperRef,
4828
- style: style
4829
- }, children);
4830
- };
4831
-
4832
- var _templateObject$4, _templateObject2$3, _templateObject3$3, _templateObject4$2, _templateObject5$2;
4833
-
4834
- const topLeft = distance => styled.css(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteralLoose(["\n top: ", ";\n left: ", ";\n"])), distance, distance);
4472
+ }, [map, onBboxChange, position, resolution]);
4473
+ useUpdateMapView({
4474
+ position,
4475
+ resolution
4476
+ });
4477
+ useMaxMinScale(minScale, maxScale, position, resolution);
4478
+ useMapBboxChange(handleBboxChange);
4479
+ return React__default.createElement("div", {
4480
+ className: className,
4481
+ ref: wrapperRef,
4482
+ style: style
4483
+ }, children);
4484
+ };
4485
+
4486
+ var _templateObject$4, _templateObject2$3, _templateObject3$3, _templateObject4$2, _templateObject5$2;
4487
+
4488
+ const topLeft = distance => styled.css(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteralLoose(["\n top: ", ";\n left: ", ";\n"])), distance, distance);
4489
+
4490
+ const topRight = distance => styled.css(_templateObject2$3 || (_templateObject2$3 = _taggedTemplateLiteralLoose(["\n top: ", ";\n right: ", ";\n"])), distance, distance);
4491
+
4492
+ const bottomLeft = distance => styled.css(_templateObject3$3 || (_templateObject3$3 = _taggedTemplateLiteralLoose(["\n bottom: ", ";\n left: ", ";\n"])), distance, distance);
4493
+
4494
+ const bottomRight = distance => styled.css(_templateObject4$2 || (_templateObject4$2 = _taggedTemplateLiteralLoose(["\n bottom: ", ";\n right: ", ";\n"])), distance, distance);
4495
+
4496
+ const placementMixin = function placementMixin(placement, distance) {
4497
+ if (placement === void 0) {
4498
+ placement = 'bottom-left';
4499
+ }
4500
+
4501
+ if (distance === void 0) {
4502
+ distance = '1rem';
4503
+ }
4504
+
4505
+ return styled.css(_templateObject5$2 || (_templateObject5$2 = _taggedTemplateLiteralLoose(["\n ", "\n ", "\n ", "\n ", "\n"])), placement === 'top-left' && topLeft(distance), placement === 'top-right' && topRight(distance), placement === 'bottom-left' && bottomLeft(distance), placement === 'bottom-right' && bottomRight(distance));
4506
+ };
4507
+
4508
+ var _templateObject$5, _templateObject2$4, _templateObject3$4, _templateObject4$3, _templateObject5$3, _templateObject6$1, _templateObject7$1, _templateObject8$1;
4509
+ const mapControlBtnMixin = /*#__PURE__*/styled.css(_templateObject$5 || (_templateObject$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 2rem;\n height: 2rem;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n color: #fff;\n"])));
4510
+ const ZoomInBtn = /*#__PURE__*/styled__default(ui.Icon)(_templateObject2$4 || (_templateObject2$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4511
+ ZoomInBtn.defaultProps = {
4512
+ kind: "plus"
4513
+ };
4514
+ const ZoomOutBtn = /*#__PURE__*/styled__default(ui.Icon)(_templateObject3$4 || (_templateObject3$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4515
+ ZoomOutBtn.defaultProps = {
4516
+ kind: "minus"
4517
+ };
4518
+ const SearchBtn = /*#__PURE__*/styled__default(ui.Icon)(_templateObject4$3 || (_templateObject4$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4519
+ SearchBtn.defaultProps = {
4520
+ kind: "search"
4521
+ }; // TODO not exists in fonts
4522
+
4523
+ const FullscreenBtn = /*#__PURE__*/styled__default(ui.Icon)(_templateObject5$3 || (_templateObject5$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4524
+ FullscreenBtn.defaultProps = {
4525
+ kind: "maximize"
4526
+ };
4527
+ const MeasureBtn = /*#__PURE__*/styled__default(ui.Icon)(_templateObject6$1 || (_templateObject6$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4528
+ MeasureBtn.defaultProps = {
4529
+ kind: "measure_length"
4530
+ };
4531
+ 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"])));
4532
+ 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) => {
4533
+ let {
4534
+ vertical
4535
+ } = _ref;
4536
+ return vertical ? 'column' : 'row';
4537
+ }, (_ref2) => {
4538
+ let {
4539
+ placement
4540
+ } = _ref2;
4541
+ return placementMixin(placement);
4542
+ }, MapControl, (_ref3) => {
4543
+ let {
4544
+ vertical
4545
+ } = _ref3;
4546
+ return vertical ? '0.5rem' : '0';
4547
+ }, (_ref4) => {
4548
+ let {
4549
+ vertical
4550
+ } = _ref4;
4551
+ return vertical ? '0' : '0.5rem';
4552
+ }, (_ref5) => {
4553
+ let {
4554
+ vertical
4555
+ } = _ref5;
4556
+ return vertical ? 'column' : 'row';
4557
+ });
4558
+
4559
+ const Measure = () => {
4560
+ return React__default.createElement(MapControl, null, React__default.createElement(MeasureBtn, {
4561
+ onClick: () => {}
4562
+ }));
4563
+ };
4564
+
4565
+ const Search = () => {
4566
+ return React__default.createElement(MapControl, null, React__default.createElement(SearchBtn, {
4567
+ onClick: () => {}
4568
+ }));
4569
+ };
4570
+
4571
+ const Fullscreen = () => {
4572
+ return React__default.createElement(MapControl, null, React__default.createElement(FullscreenBtn, {
4573
+ onClick: () => {}
4574
+ }));
4575
+ };
4576
+
4577
+ var _templateObject$6, _templateObject2$5, _templateObject3$5, _templateObject4$4, _templateObject5$4;
4578
+ const MapLegendControl = /*#__PURE__*/styled__default(MapControl)(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n cursor: default;\n"])));
4579
+ const MapLegendContainer = /*#__PURE__*/styled__default.div(_templateObject2$5 || (_templateObject2$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n width: 16.5rem;\n height: 3.875rem;\n align-items: center;\n padding: 0.5rem;\n box-sizing: border-box;\n\n canvas {\n height: 1rem;\n width: 0.835rem;\n }\n"])));
4580
+ const MapLegendHeader = /*#__PURE__*/styled__default(LegendSectionHeader)(_templateObject3$5 || (_templateObject3$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0;\n"])));
4581
+ const MapLegendSection = /*#__PURE__*/styled__default.div(_templateObject4$4 || (_templateObject4$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n"])));
4582
+ const MapLegendValueDescr = /*#__PURE__*/styled__default.div(_templateObject5$4 || (_templateObject5$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0.5rem;\n font-size: 0.625rem;\n opacity: 0.65;\n"])));
4583
+
4584
+ const MAX_SIZE$2 = 100;
4585
+ const MapLegendSymbol = (_ref) => {
4586
+ let {
4587
+ value,
4588
+ parameter
4589
+ } = _ref;
4590
+ return React__default.createElement(LegendSymbol, {
4591
+ key: value.title,
4592
+ parameter: parameter,
4593
+ parameterValue: value.parameterValue
4594
+ }, symbol => React__default.createElement(Symbol, {
4595
+ render: getMapLegendSymbolRenders,
4596
+ symbol: symbol,
4597
+ size: MAX_SIZE$2
4598
+ }));
4599
+ };
4600
+
4601
+ const DEFAULT_FROM_TO = ['Выше', 'Ниже'];
4602
+ const MapLegend = (_ref) => {
4603
+ let {
4604
+ layer,
4605
+ config,
4606
+ fromToTitle = DEFAULT_FROM_TO,
4607
+ className
4608
+ } = _ref;
4609
+ const legend = useMapLegend(layer, config);
4610
+
4611
+ if (!legend) {
4612
+ return null;
4613
+ }
4614
+
4615
+ const {
4616
+ symbol,
4617
+ item
4618
+ } = legend;
4619
+ return React__default.createElement(LegendProvider, {
4620
+ symbol: symbol
4621
+ }, React__default.createElement(MapLegendControl, {
4622
+ className: className
4623
+ }, React__default.createElement(MapLegendContainer, null, React__default.createElement(MapLegendHeader, null, item.title), React__default.createElement(MapLegendSection, null, React__default.createElement(MapLegendValueDescr, null, fromToTitle[0]), item.values.map(value => React__default.createElement(MapLegendSymbol, {
4624
+ key: value.title,
4625
+ value: value,
4626
+ parameter: item.parameter
4627
+ })), React__default.createElement(MapLegendValueDescr, null, fromToTitle[1])))));
4628
+ };
4629
+
4630
+ const DEFAULT_FORMATTERS = {
4631
+ polygon: formatPolygonMeasure,
4632
+ length: formatLength
4633
+ };
4634
+
4635
+ const COORD_FRACTION = 6;
4636
+ const DEFAULT_LABEL_POSITION = [Infinity, Infinity];
4637
+ let BaseMeasureToolCreator = /*#__PURE__*/function (_PolylineControl) {
4638
+ _inherits(BaseMeasureToolCreator, _PolylineControl);
4639
+
4640
+ var _super = /*#__PURE__*/_createSuper(BaseMeasureToolCreator);
4641
+
4642
+ function BaseMeasureToolCreator(map, painter, params) {
4643
+ var _this;
4644
+
4645
+ _classCallCheck(this, BaseMeasureToolCreator);
4646
+
4647
+ _this = _super.call(this, map, params);
4648
+
4649
+ _this.cancel = () => {
4650
+ _this.fire('cancel');
4651
+ };
4652
+
4653
+ _this.painter = painter;
4654
+ _this.renderLabelSymbol = params.renderLabelSymbol;
4655
+ _this.formatters = params.formatters || DEFAULT_FORMATTERS;
4656
+ _this.areaSymbol = params.areaSymbol;
4657
+
4658
+ _this.on('pointAdd', _this.handlePointAdd); // @ts-ignore
4659
+
4660
+
4661
+ _this.on('change', _this.updateDistance);
4662
+
4663
+ return _this;
4664
+ }
4665
+
4666
+ _createClass(BaseMeasureToolCreator, [{
4667
+ key: "_handleMousemove",
4668
+ value: function _handleMousemove(event) {
4669
+ _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_handleMousemove", this).call(this, event);
4670
+
4671
+ this.drawPointOnMouseMove(event);
4672
+ }
4673
+ }, {
4674
+ key: "_activate",
4675
+ value: function _activate() {
4676
+ _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_activate", this).call(this);
4677
+
4678
+ this.addTempLabel();
4679
+ this.setCursor('pointer');
4680
+ }
4681
+ }, {
4682
+ key: "_deactivate",
4683
+ value: function _deactivate() {
4684
+ _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_deactivate", this).call(this);
4685
+
4686
+ this.removeCoordLabel();
4687
+ this.removeTempLabel();
4688
+ this.removeMeasureLabel();
4689
+ this.removeTempPolygon();
4690
+ this.setCursor('default');
4691
+ }
4692
+ }, {
4693
+ key: "handlePointAdd",
4694
+ value: function handlePointAdd() {
4695
+ const feature = this.activeFeature;
4696
+ if (!feature) return;
4697
+ const {
4698
+ rings,
4699
+ crs
4700
+ } = feature;
4701
+
4702
+ if (isPolylineLikePolygon(rings, this.map.resolution)) {
4703
+ this.finishDrawing();
4704
+ this.fire(new Control.DrawingFinishEvent(feature, new MouseEvent('mouseup')));
4705
+ return;
4706
+ }
4707
+
4708
+ if (rings[0].length === 2) {
4709
+ const projection = crs.projectionTo(Crs.geo);
4710
+ const point = rings[0][0];
4711
+ if (!projection) return;
4712
+ const [lat, long] = projection(point);
4713
+ this.removeTempLabel();
4714
+ this.addMeasureResultLabel();
4715
+ this.addCoordLabel(lat.toFixed(COORD_FRACTION) + ", " + long.toFixed(COORD_FRACTION), point);
4716
+ } else {
4717
+ this.removeCoordLabel();
4718
+ }
4719
+ }
4720
+ }, {
4721
+ key: "polygonPreview",
4722
+ value: function polygonPreview() {
4723
+ if (this.tempPolygon) {
4724
+ this._tempLayer && this._tempLayer.remove(this.tempPolygon);
4725
+ }
4726
+
4727
+ const feature = this.activeFeature;
4728
+ if (!feature) return;
4729
+ const {
4730
+ rings,
4731
+ crs
4732
+ } = feature;
4733
+ const polygonRings = [...rings[0]];
4734
+ polygonRings.shift();
4735
+ this.tempPolygon = new Polygon.Polygon(polygonRings, {
4736
+ crs
4737
+ });
4738
+ this.tempPolygon.symbol = this.areaSymbol || measureAreaSymbol;
4739
+ this.activeFeature && this.activeFeature.hide();
4740
+ this._tempLayer && this._tempLayer.add(this.tempPolygon);
4741
+ }
4742
+ }, {
4743
+ key: "removeTempPolygon",
4744
+ value: function removeTempPolygon() {
4745
+ if (this.tempPolygon) {
4746
+ this._tempLayer && this._tempLayer.remove(this.tempPolygon);
4747
+ delete this.tempPolygon;
4748
+ }
4749
+ }
4750
+ }, {
4751
+ key: "updateDistance",
4752
+ value: function updateDistance(event) {
4753
+ const feature = this.activeFeature;
4754
+ const {
4755
+ ringIndex,
4756
+ pointIndex
4757
+ } = event;
4758
+ if (!feature || ringIndex === null || pointIndex === null) return;
4759
+ const {
4760
+ rings,
4761
+ crs
4762
+ } = feature;
4763
+ const position = rings[ringIndex][pointIndex];
4764
+ const length = geotools.length(rings, crs);
4765
+ let content = this.formatters.length(length);
4766
+
4767
+ if (isPolylineLikePolygon(rings, this.map.resolution)) {
4768
+ this.polygonPreview();
4769
+ const area = geotools.area(rings, crs);
4770
+ content = this.formatters.polygon(area, length);
4771
+ } else if (this.tempPolygon) {
4772
+ feature.show();
4773
+ this.removeTempPolygon();
4774
+ }
4775
+
4776
+ if (this.measureResultLabel) {
4777
+ this.measureResultLabel.position = position;
4778
+ this.measureResultLabel.content = content;
4779
+ }
4780
+ }
4781
+ }, {
4782
+ key: "addTempLabel",
4783
+ value: function addTempLabel() {
4784
+ this.tempLabel = new Label.LabelFeature(DEFAULT_LABEL_POSITION, {
4785
+ content: 'Нажмите на карту, чтобы начать измерение',
4786
+ crs: this.map.crs,
4787
+ symbol: createLabelSymbol({
4788
+ renderLabel: this.renderLabelSymbol
4789
+ })
4790
+ });
4791
+ this._tempLayer && this._tempLayer.add(this.tempLabel);
4792
+ }
4793
+ }, {
4794
+ key: "addCoordLabel",
4795
+ value: function addCoordLabel(content, position) {
4796
+ this.coordLabel = new Label.LabelFeature(position, {
4797
+ content,
4798
+ crs: this.map.crs,
4799
+ symbol: createLabelSymbol({
4800
+ renderLabel: this.renderLabelSymbol,
4801
+ onClose: this.cancel
4802
+ })
4803
+ });
4804
+ this._tempLayer && this.coordLabel && this._tempLayer.add(this.coordLabel);
4805
+ }
4806
+ }, {
4807
+ key: "addMeasureResultLabel",
4808
+ value: function addMeasureResultLabel() {
4809
+ this.measureResultLabel = new Label.LabelFeature(DEFAULT_LABEL_POSITION, {
4810
+ crs: this.map.crs,
4811
+ symbol: createLabelSymbol({
4812
+ renderLabel: this.renderLabelSymbol
4813
+ })
4814
+ });
4815
+ this._tempLayer && this.measureResultLabel && this._tempLayer.add(this.measureResultLabel);
4816
+ }
4817
+ }, {
4818
+ key: "removeTempLabel",
4819
+ value: function removeTempLabel() {
4820
+ if (this.tempLabel) {
4821
+ this._tempLayer && this._tempLayer.remove(this.tempLabel);
4822
+ delete this.tempLabel;
4823
+ }
4824
+ }
4825
+ }, {
4826
+ key: "removeCoordLabel",
4827
+ value: function removeCoordLabel() {
4828
+ if (this.coordLabel) {
4829
+ this._tempLayer && this._tempLayer.remove(this.coordLabel);
4830
+ delete this.coordLabel;
4831
+ }
4832
+ }
4833
+ }, {
4834
+ key: "removeMeasureLabel",
4835
+ value: function removeMeasureLabel() {
4836
+ if (this.measureResultLabel) {
4837
+ this._tempLayer && this._tempLayer.remove(this.measureResultLabel);
4838
+ delete this.measureResultLabel;
4839
+ }
4840
+ }
4841
+ }, {
4842
+ key: "drawPointOnMouseMove",
4843
+ value: function drawPointOnMouseMove(event) {
4844
+ if (this.tempLabel) {
4845
+ this.tempLabel.position = event.point.position;
4846
+ }
4847
+ }
4848
+ }, {
4849
+ key: "setCursor",
4850
+ value: function setCursor(cursor) {
4851
+ const {
4852
+ wrapper
4853
+ } = this.painter;
4835
4854
 
4836
- const topRight = distance => styled.css(_templateObject2$3 || (_templateObject2$3 = _taggedTemplateLiteralLoose(["\n top: ", ";\n right: ", ";\n"])), distance, distance);
4855
+ if (wrapper && typeof wrapper !== 'string') {
4856
+ wrapper.style.cursor = cursor;
4857
+ }
4858
+ }
4859
+ }]);
4837
4860
 
4838
- const bottomLeft = distance => styled.css(_templateObject3$3 || (_templateObject3$3 = _taggedTemplateLiteralLoose(["\n bottom: ", ";\n left: ", ";\n"])), distance, distance);
4861
+ return BaseMeasureToolCreator;
4862
+ }(PolylineControl.PolylineControl);
4839
4863
 
4840
- const bottomRight = distance => styled.css(_templateObject4$2 || (_templateObject4$2 = _taggedTemplateLiteralLoose(["\n bottom: ", ";\n right: ", ";\n"])), distance, distance);
4864
+ let BaseMeasureToolEditor = /*#__PURE__*/function (_PolyEditor) {
4865
+ _inherits(BaseMeasureToolEditor, _PolyEditor);
4841
4866
 
4842
- const placementMixin = function placementMixin(placement, distance) {
4843
- if (placement === void 0) {
4844
- placement = 'bottom-left';
4845
- }
4867
+ var _super = /*#__PURE__*/_createSuper(BaseMeasureToolEditor);
4846
4868
 
4847
- if (distance === void 0) {
4848
- distance = '1rem';
4849
- }
4869
+ function BaseMeasureToolEditor(map, painter, params) {
4870
+ var _this;
4850
4871
 
4851
- return styled.css(_templateObject5$2 || (_templateObject5$2 = _taggedTemplateLiteralLoose(["\n ", "\n ", "\n ", "\n ", "\n"])), placement === 'top-left' && topLeft(distance), placement === 'top-right' && topRight(distance), placement === 'bottom-left' && bottomLeft(distance), placement === 'bottom-right' && bottomRight(distance));
4852
- };
4872
+ _classCallCheck(this, BaseMeasureToolEditor);
4853
4873
 
4854
- var _templateObject$5, _templateObject2$4, _templateObject3$4, _templateObject4$3, _templateObject5$3, _templateObject6$1, _templateObject7$1, _templateObject8$1;
4855
- const mapControlBtnMixin = /*#__PURE__*/styled.css(_templateObject$5 || (_templateObject$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 2rem;\n height: 2rem;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n color: #fff;\n"])));
4856
- const ZoomInBtn = /*#__PURE__*/styled__default(ui.Icon)(_templateObject2$4 || (_templateObject2$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4857
- ZoomInBtn.defaultProps = {
4858
- kind: "plus"
4859
- };
4860
- const ZoomOutBtn = /*#__PURE__*/styled__default(ui.Icon)(_templateObject3$4 || (_templateObject3$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4861
- ZoomOutBtn.defaultProps = {
4862
- kind: "minus"
4863
- };
4864
- const SearchBtn = /*#__PURE__*/styled__default(ui.Icon)(_templateObject4$3 || (_templateObject4$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4865
- SearchBtn.defaultProps = {
4866
- kind: "search"
4867
- }; // TODO not exists in fonts
4874
+ _this = _super.call(this, map, params);
4868
4875
 
4869
- const FullscreenBtn = /*#__PURE__*/styled__default(ui.Icon)(_templateObject5$3 || (_templateObject5$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4870
- FullscreenBtn.defaultProps = {
4871
- kind: "maximize"
4872
- };
4873
- const MeasureBtn = /*#__PURE__*/styled__default(ui.Icon)(_templateObject6$1 || (_templateObject6$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4874
- MeasureBtn.defaultProps = {
4875
- kind: "measure_length"
4876
- };
4877
- 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"])));
4878
- 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 => {
4879
- let {
4880
- vertical
4881
- } = _ref;
4882
- return vertical ? 'column' : 'row';
4883
- }, _ref2 => {
4884
- let {
4885
- placement
4886
- } = _ref2;
4887
- return placementMixin(placement);
4888
- }, MapControl, _ref3 => {
4889
- let {
4890
- vertical
4891
- } = _ref3;
4892
- return vertical ? '0.5rem' : '0';
4893
- }, _ref4 => {
4894
- let {
4895
- vertical
4896
- } = _ref4;
4897
- return vertical ? '0' : '0.5rem';
4898
- }, _ref5 => {
4899
- let {
4900
- vertical
4901
- } = _ref5;
4902
- return vertical ? 'column' : 'row';
4903
- });
4876
+ _this.measureResult = () => {
4877
+ const feature = _this.activeFeature;
4878
+ if (!feature) return null;
4879
+ const {
4880
+ rings,
4881
+ isEnclosed,
4882
+ crs
4883
+ } = feature;
4884
+ const pointsCount = rings[0].length;
4885
+ const position = rings[0][pointsCount - 1];
4886
+ const area = geotools.area(rings, crs);
4887
+ const length = geotools.length(rings, crs, isEnclosed);
4888
+ const content = isEnclosed ? _this.formatters.polygon(area, length) : _this.formatters.length(length);
4889
+ return {
4890
+ content,
4891
+ position
4892
+ };
4893
+ };
4904
4894
 
4905
- const Measure = () => {
4906
- return React__default.createElement(MapControl, null, React__default.createElement(MeasureBtn, {
4907
- onClick: () => {}
4908
- }));
4909
- };
4895
+ _this.removeFeature = () => {
4896
+ _this.fire('remove');
4897
+ };
4910
4898
 
4911
- const Search = () => {
4912
- return React__default.createElement(MapControl, null, React__default.createElement(SearchBtn, {
4913
- onClick: () => {}
4914
- }));
4915
- };
4899
+ _this.painter = painter;
4900
+ _this.renderLabelSymbol = params.renderLabelSymbol;
4901
+ _this.formatters = params.formatters || DEFAULT_FORMATTERS;
4916
4902
 
4917
- const Fullscreen = () => {
4918
- return React__default.createElement(MapControl, null, React__default.createElement(FullscreenBtn, {
4919
- onClick: () => {}
4920
- }));
4921
- };
4903
+ _this.on('change', _this.updateMeasureResult);
4922
4904
 
4923
- var _templateObject$6, _templateObject2$5, _templateObject3$5, _templateObject4$4, _templateObject5$4;
4924
- const MapLegendControl = /*#__PURE__*/styled__default(MapControl)(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n cursor: default;\n"])));
4925
- const MapLegendContainer = /*#__PURE__*/styled__default.div(_templateObject2$5 || (_templateObject2$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n width: 16.5rem;\n height: 3.875rem;\n align-items: center;\n padding: 0.5rem;\n box-sizing: border-box;\n\n canvas {\n height: 1rem;\n width: 0.835rem;\n }\n"])));
4926
- const MapLegendHeader = /*#__PURE__*/styled__default(LegendSectionHeader)(_templateObject3$5 || (_templateObject3$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0;\n"])));
4927
- const MapLegendSection = /*#__PURE__*/styled__default.div(_templateObject4$4 || (_templateObject4$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n"])));
4928
- const MapLegendValueDescr = /*#__PURE__*/styled__default.div(_templateObject5$4 || (_templateObject5$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0.5rem;\n font-size: 0.625rem;\n opacity: 0.65;\n"])));
4905
+ _this.on('edit', _this.updateMeasureResult);
4929
4906
 
4930
- const MAX_SIZE$2 = 100;
4931
- const MapLegendSymbol = _ref => {
4932
- let {
4933
- value,
4934
- parameter
4935
- } = _ref;
4936
- return React__default.createElement(LegendSymbol, {
4937
- key: value.title,
4938
- parameter: parameter,
4939
- parameterValue: value.parameterValue
4940
- }, symbol => React__default.createElement(Symbol, {
4941
- render: getMapLegendSymbolRenders,
4942
- symbol: symbol,
4943
- size: MAX_SIZE$2
4944
- }));
4945
- };
4907
+ return _this;
4908
+ }
4946
4909
 
4947
- const DEFAULT_FROM_TO = ['Выше', 'Ниже'];
4948
- const MapLegend = _ref => {
4949
- let {
4950
- layer,
4951
- config,
4952
- fromToTitle = DEFAULT_FROM_TO,
4953
- className
4954
- } = _ref;
4955
- const legend = useMapLegend(layer, config);
4910
+ _createClass(BaseMeasureToolEditor, [{
4911
+ key: "_activate",
4912
+ value: function _activate() {
4913
+ _get(_getPrototypeOf(BaseMeasureToolEditor.prototype), "_activate", this).call(this);
4956
4914
 
4957
- if (!legend) {
4958
- return null;
4959
- }
4915
+ this.addMeasureResultLabel();
4916
+ }
4917
+ }, {
4918
+ key: "addMeasureResultLabel",
4919
+ value: function addMeasureResultLabel() {
4920
+ const measureResult = this.measureResult();
4921
+ if (measureResult === null) return;
4922
+ const {
4923
+ content,
4924
+ position
4925
+ } = measureResult;
4926
+ this.measureResultLabel = new Label.LabelFeature(position, {
4927
+ content,
4928
+ crs: this.map.crs,
4929
+ symbol: createLabelSymbol({
4930
+ onClose: this.removeFeature,
4931
+ renderLabel: this.renderLabelSymbol
4932
+ })
4933
+ });
4934
+ this._tempLayer && this._tempLayer.add(this.measureResultLabel);
4935
+ }
4936
+ }, {
4937
+ key: "updateMeasureResult",
4938
+ value: function updateMeasureResult() {
4939
+ if (this.measureResultLabel) {
4940
+ const measureResult = this.measureResult();
4941
+ if (measureResult === null) return;
4942
+ const {
4943
+ content,
4944
+ position
4945
+ } = measureResult;
4946
+ this.measureResultLabel.content = content;
4947
+ this.measureResultLabel.position = position;
4948
+ }
4949
+ }
4950
+ }]);
4960
4951
 
4961
- const {
4962
- symbol,
4963
- item
4964
- } = legend;
4965
- return React__default.createElement(LegendProvider, {
4966
- symbol: symbol
4967
- }, React__default.createElement(MapLegendControl, {
4968
- className: className
4969
- }, React__default.createElement(MapLegendContainer, null, React__default.createElement(MapLegendHeader, null, item.title), React__default.createElement(MapLegendSection, null, React__default.createElement(MapLegendValueDescr, null, fromToTitle[0]), item.values.map(value => React__default.createElement(MapLegendSymbol, {
4970
- key: value.title,
4971
- value: value,
4972
- parameter: item.parameter
4973
- })), React__default.createElement(MapLegendValueDescr, null, fromToTitle[1])))));
4974
- };
4952
+ return BaseMeasureToolEditor;
4953
+ }(PolyEditor.PolyEditor);
4975
4954
 
4976
4955
  let MeasureTool = /*#__PURE__*/function (_React$Component) {
4977
4956
  _inherits(MeasureTool, _React$Component);
@@ -5073,7 +5052,7 @@ let MeasureTool = /*#__PURE__*/function (_React$Component) {
5073
5052
  snappingSymbol: snapSymbol || measurePolygonSnapSymbol,
5074
5053
  symbol: lengthSymbol || measureLengthSymbol,
5075
5054
  renderLabelSymbol,
5076
- formatters: formatters
5055
+ formatters
5077
5056
  });
5078
5057
  this.editorControl.featureDragAllowed = false;
5079
5058
  this.editorControl.on('remove', this.removeFeature);
@@ -5161,7 +5140,7 @@ let MeasureTool = /*#__PURE__*/function (_React$Component) {
5161
5140
  }(React__default.Component);
5162
5141
 
5163
5142
  const _excluded$3 = ["isActive"];
5164
- const Measurer = _ref => {
5143
+ const Measurer = (_ref) => {
5165
5144
  let {
5166
5145
  isActive
5167
5146
  } = _ref,
@@ -5179,18 +5158,18 @@ const Measurer = _ref => {
5179
5158
 
5180
5159
  var _templateObject$7, _templateObject2$6, _templateObject3$6;
5181
5160
  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"])));
5182
- const ScaleRulerBlock = /*#__PURE__*/styled__default.div(_templateObject2$6 || (_templateObject2$6 = /*#__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 => {
5161
+ const ScaleRulerBlock = /*#__PURE__*/styled__default.div(_templateObject2$6 || (_templateObject2$6 = /*#__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) => {
5183
5162
  let {
5184
5163
  width
5185
5164
  } = _ref;
5186
5165
  return width + "px";
5187
5166
  });
5188
- const TextContainer = /*#__PURE__*/styled__default.div(_templateObject3$6 || (_templateObject3$6 = /*#__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 => {
5167
+ const TextContainer = /*#__PURE__*/styled__default.div(_templateObject3$6 || (_templateObject3$6 = /*#__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) => {
5189
5168
  let {
5190
5169
  alignEnd
5191
5170
  } = _ref2;
5192
5171
  return alignEnd ? 'flex-end' : 'center';
5193
- }, _ref3 => {
5172
+ }, (_ref3) => {
5194
5173
  let {
5195
5174
  width
5196
5175
  } = _ref3;
@@ -5215,7 +5194,7 @@ const ScaleRuler = () => {
5215
5194
  }, currentScale >= 1000 ? currentScale / 1000 + "km" : currentScale + "m")));
5216
5195
  };
5217
5196
 
5218
- const Zoom = _ref => {
5197
+ const Zoom = (_ref) => {
5219
5198
  let {
5220
5199
  children
5221
5200
  } = _ref;
@@ -5264,7 +5243,7 @@ const placementMixin$1 = function placementMixin(placement, distance, cornerSize
5264
5243
  return styled.css(_templateObject9$1 || (_templateObject9$1 = _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));
5265
5244
  };
5266
5245
  const corner = /*#__PURE__*/styled.css(_templateObject10$1 || (_templateObject10$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n &:before {\n content: '';\n width: 0;\n height: 0;\n position: absolute;\n }\n"])));
5267
- const TooltipComponent = /*#__PURE__*/styled__default.div(_templateObject11$1 || (_templateObject11$1 = /*#__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 => {
5246
+ const TooltipComponent = /*#__PURE__*/styled__default.div(_templateObject11$1 || (_templateObject11$1 = /*#__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) => {
5268
5247
  let {
5269
5248
  placement,
5270
5249
  distance = '0.5rem',
@@ -5272,7 +5251,7 @@ const TooltipComponent = /*#__PURE__*/styled__default.div(_templateObject11$1 ||
5272
5251
  cornerSize = '0.25rem'
5273
5252
  } = _ref;
5274
5253
  return placementMixin$1(placement, distance, withArrow ? cornerSize : null);
5275
- }, _ref2 => {
5254
+ }, (_ref2) => {
5276
5255
  let {
5277
5256
  withArrow
5278
5257
  } = _ref2;
@@ -5286,7 +5265,7 @@ const {
5286
5265
  Consumer
5287
5266
  } = /*#__PURE__*/React.createContext([]); // TODO I just cant read that
5288
5267
 
5289
- const Tooltip = _ref => {
5268
+ const Tooltip = (_ref) => {
5290
5269
  let {
5291
5270
  features = [],
5292
5271
  map,
@@ -5325,7 +5304,7 @@ const Noop = () => React__default.createElement("div", {
5325
5304
  }
5326
5305
  });
5327
5306
 
5328
- const DraggableMarker = _ref => {
5307
+ const DraggableMarker = (_ref) => {
5329
5308
  let {
5330
5309
  position,
5331
5310
  onChange,
@@ -5339,6 +5318,21 @@ const DraggableMarker = _ref => {
5339
5318
  return React__default.createElement(React.Fragment, null);
5340
5319
  };
5341
5320
 
5321
+ const polygonCircleFromPoint = (center, diameter) => {
5322
+ const coordinates = [];
5323
+ const radius = diameter / 2;
5324
+ const endAngle = Math.PI * 2;
5325
+ const step = Math.max(Math.PI / 2 / radius, endAngle / 128);
5326
+ let start = 0;
5327
+ let end = endAngle;
5328
+
5329
+ for (let ang = start; ang < end; ang += step) {
5330
+ coordinates.push([Math.cos(ang) * radius + center[0], Math.sin(ang) * radius + center[1]]);
5331
+ }
5332
+
5333
+ return [coordinates];
5334
+ };
5335
+
5342
5336
  exports.ArrowLineMiterRender = ArrowLineMiterRender;
5343
5337
  exports.BaseMeasureToolCreator = BaseMeasureToolCreator;
5344
5338
  exports.BaseMeasureToolEditor = BaseMeasureToolEditor;