@evergis/react 2.0.71 → 2.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.esm.js CHANGED
@@ -17,12 +17,8 @@ import { ImageFill } from '@evergis/sgis/es/symbols/polygon/ImageFill';
17
17
  import { PolygonSymbol } from '@evergis/sgis/es/symbols/polygon/Simple';
18
18
  import { PolylineSymbol } from '@evergis/sgis/es/symbols/PolylineSymbol';
19
19
  import { PolyRender, FillStyle } from '@evergis/sgis/es/renders/Poly';
20
- import { projectRings, length, area, distance } from '@evergis/sgis/es/geotools';
20
+ import { projectRings, distance, length, area } from '@evergis/sgis/es/geotools';
21
21
  import { simplifyCoordinates, softEquals } from '@evergis/sgis/es/utils/math';
22
- import { PolylineControl } from '@evergis/sgis/es/controls/PolylineControl';
23
- import { LabelFeature } from '@evergis/sgis/es/features/Label';
24
- import { DrawingFinishEvent } from '@evergis/sgis/es/controls/Control';
25
- import { PolyEditor } from '@evergis/sgis/es/controls/PolyEditor';
26
22
  import ReactDOM from 'react-dom';
27
23
  import { DynamicPointSymbol, Symbol as Symbol$1 } from '@evergis/sgis/es/symbols/Symbol';
28
24
  import { Poly } from '@evergis/sgis/es/features/Poly';
@@ -35,6 +31,7 @@ import { SquareSymbol } from '@evergis/sgis/es/symbols/point/Square';
35
31
  import { MaskedImage } from '@evergis/sgis/es/symbols/point/MaskedImage';
36
32
  import { Canvas } from '@evergis/sgis/es/painters/DomPainter/Canvas';
37
33
  import { sGisClickEvent } from '@evergis/sgis/es/commonEvents';
34
+ import { LabelFeature } from '@evergis/sgis/es/features/Label';
38
35
  import { ClusterLayer as ClusterLayer$1 } from '@evergis/sgis/es/layers/ClusterLayer';
39
36
  import { GridClusterProvider } from '@evergis/sgis/es/layers/clusterProviders/GridClusterProvider';
40
37
  import { PointEditor } from '@evergis/sgis/es/controls/PointEditor';
@@ -43,6 +40,9 @@ import styled, { css } from 'styled-components';
43
40
  import { Icon } from '@evergis/ui';
44
41
  import punycode from 'punycode';
45
42
  import { TileLayer as TileLayer$1 } from '@evergis/sgis/es/layers/TileLayer';
43
+ import { PolylineControl } from '@evergis/sgis/es/controls/PolylineControl';
44
+ import { DrawingFinishEvent } from '@evergis/sgis/es/controls/Control';
45
+ import { PolyEditor } from '@evergis/sgis/es/controls/PolyEditor';
46
46
 
47
47
  function _classCallCheck(instance, Constructor) {
48
48
  if (!(instance instanceof Constructor)) {
@@ -63,9 +63,6 @@ function _defineProperties(target, props) {
63
63
  function _createClass(Constructor, protoProps, staticProps) {
64
64
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
65
65
  if (staticProps) _defineProperties(Constructor, staticProps);
66
- Object.defineProperty(Constructor, "prototype", {
67
- writable: false
68
- });
69
66
  return Constructor;
70
67
  }
71
68
 
@@ -99,9 +96,6 @@ function _inherits(subClass, superClass) {
99
96
  configurable: true
100
97
  }
101
98
  });
102
- Object.defineProperty(subClass, "prototype", {
103
- writable: false
104
- });
105
99
  if (superClass) _setPrototypeOf(subClass, superClass);
106
100
  }
107
101
 
@@ -160,8 +154,6 @@ function _assertThisInitialized(self) {
160
154
  function _possibleConstructorReturn(self, call) {
161
155
  if (call && (typeof call === "object" || typeof call === "function")) {
162
156
  return call;
163
- } else if (call !== void 0) {
164
- throw new TypeError("Derived constructors may only return object or undefined");
165
157
  }
166
158
 
167
159
  return _assertThisInitialized(self);
@@ -195,7 +187,7 @@ function _superPropBase(object, property) {
195
187
  return object;
196
188
  }
197
189
 
198
- function _get() {
190
+ function _get(target, property, receiver) {
199
191
  if (typeof Reflect !== "undefined" && Reflect.get) {
200
192
  _get = Reflect.get;
201
193
  } else {
@@ -206,14 +198,14 @@ function _get() {
206
198
  var desc = Object.getOwnPropertyDescriptor(base, property);
207
199
 
208
200
  if (desc.get) {
209
- return desc.get.call(arguments.length < 3 ? target : receiver);
201
+ return desc.get.call(receiver);
210
202
  }
211
203
 
212
204
  return desc.value;
213
205
  };
214
206
  }
215
207
 
216
- return _get.apply(this, arguments);
208
+ return _get(target, property, receiver || target);
217
209
  }
218
210
 
219
211
  function _taggedTemplateLiteralLoose(strings, raw) {
@@ -242,7 +234,7 @@ const defaultApi = /*#__PURE__*/new Api({
242
234
  url: BASE_URL
243
235
  });
244
236
  const evergisContext = /*#__PURE__*/createContext(defaultApi);
245
- const EvergisProvider = _ref => {
237
+ const EvergisProvider = (_ref) => {
246
238
  let {
247
239
  api,
248
240
  children
@@ -260,7 +252,7 @@ const mapContext = /*#__PURE__*/createContext({
260
252
  map: defaultMap,
261
253
  painter: defaultPainter
262
254
  });
263
- const MapProvider = _ref => {
255
+ const MapProvider = (_ref) => {
264
256
  let {
265
257
  map,
266
258
  painter,
@@ -282,7 +274,7 @@ const tooltipContext = /*#__PURE__*/createContext({
282
274
  layer: defaultLayer,
283
275
  popupLayer: defaultPopupLayer
284
276
  });
285
- const TooltipProvider = _ref => {
277
+ const TooltipProvider = (_ref) => {
286
278
  let {
287
279
  layer,
288
280
  popupLayer,
@@ -299,7 +291,7 @@ const TooltipProvider = _ref => {
299
291
  const useTooltipContext = () => useContext(tooltipContext);
300
292
 
301
293
  const LegendContext = /*#__PURE__*/createContext(null);
302
- const LegendProvider = _ref => {
294
+ const LegendProvider = (_ref) => {
303
295
  let {
304
296
  symbol,
305
297
  children
@@ -311,7 +303,7 @@ const LegendProvider = _ref => {
311
303
  const useLegendContext = () => useContext(LegendContext);
312
304
 
313
305
  const evergisSelectContext = /*#__PURE__*/createContext([]);
314
- const EvergisSelectProvider = _ref => {
306
+ const EvergisSelectProvider = (_ref) => {
315
307
  let {
316
308
  layers,
317
309
  children
@@ -356,7 +348,7 @@ function useMapViewActions() {
356
348
  }, [map]);
357
349
  const zoomIn = useCallback(() => zoomTo(1), [zoomTo]);
358
350
  const zoomOut = useCallback(() => zoomTo(-1), [zoomTo]);
359
- const animateTo = useCallback(_ref => {
351
+ const animateTo = useCallback((_ref) => {
360
352
  let {
361
353
  position,
362
354
  resolution,
@@ -548,7 +540,7 @@ const formatStringAttribute = value => {
548
540
 
549
541
  const attributeValues = value.split(/[\s|]/).map(convertStringAttribute);
550
542
 
551
- if (attributeValues.every(_ref => {
543
+ if (attributeValues.every((_ref) => {
552
544
  let {
553
545
  type
554
546
  } = _ref;
@@ -556,7 +548,7 @@ const formatStringAttribute = value => {
556
548
  }
557
549
  /* String */
558
550
  )) {
559
- return [stringAttribute(attributeValues.map(_ref2 => {
551
+ return [stringAttribute(attributeValues.map((_ref2) => {
560
552
  let {
561
553
  value
562
554
  } = _ref2;
@@ -963,30 +955,33 @@ const unClassify = symbol => Object.entries(symbol).reduce((flatSymbol, _ref) =>
963
955
  }, {});
964
956
 
965
957
  const printRangeClass = (value, index) => {
966
- const isDouble = Boolean(value.attribute && value.attribute.type === 'Double');
958
+ var _value$attribute, _value$attribute2;
959
+
960
+ const isDouble = Boolean(((_value$attribute = value.attribute) == null ? void 0 : _value$attribute.type) === 'Double');
961
+ const isDate = Boolean(((_value$attribute2 = value.attribute) == null ? void 0 : _value$attribute2.type) === 'DateTime');
967
962
  const {
968
963
  from,
969
964
  to
970
- } = getRangeValues(value, isDouble, index);
965
+ } = getRangeValues(value, isDouble, isDate, index);
971
966
 
972
967
  if (from === null) {
973
- return to + " \u0438 \u043C\u0435\u043D\u0435\u0435";
968
+ return to + " " + (isDate ? 'и до' : 'и менее');
974
969
  }
975
970
 
976
971
  if (to === null) {
977
- return "\u0431\u043E\u043B\u0435\u0435 " + from;
972
+ return (isDate ? 'после' : 'более') + " " + from;
978
973
  }
979
974
 
980
975
  return from === to ? "" + from : from + " - " + to;
981
976
  };
982
977
 
983
- function getRangeValues(_ref, isDouble, index) {
978
+ function getRangeValues(_ref, isDouble, isDate, index) {
984
979
  let {
985
980
  from,
986
981
  to
987
982
  } = _ref;
988
983
  return {
989
- from: from !== null && index !== 0 ? isDouble ? +from : +from + 1 : from,
984
+ from: from !== null && index !== 0 ? isDate ? from : isDouble ? +from : +from + 1 : from,
990
985
  to
991
986
  };
992
987
  }
@@ -1036,7 +1031,7 @@ const getFeatureAttributeType = attributeValue => {
1036
1031
  };
1037
1032
  const getLayerAttributes = layerDefinition => {
1038
1033
  const attributes = layerDefinition && layerDefinition.attributes || {};
1039
- return Object.entries(attributes).map(_ref => {
1034
+ return Object.entries(attributes).map((_ref) => {
1040
1035
  let [name, definition] = _ref;
1041
1036
  return _extends({
1042
1037
  name
@@ -1044,7 +1039,7 @@ const getLayerAttributes = layerDefinition => {
1044
1039
  });
1045
1040
  };
1046
1041
  const getFeatureAttributes = attributes => {
1047
- return attributes ? Object.entries(attributes).map(_ref2 => {
1042
+ return attributes ? Object.entries(attributes).map((_ref2) => {
1048
1043
  let [name, value] = _ref2;
1049
1044
  return {
1050
1045
  name,
@@ -1062,7 +1057,7 @@ const getClassificationAttribute = (attributeName, attributes) => {
1062
1057
  return attribute ? _extends({}, attrNamePart, attribute) : attrNamePart;
1063
1058
  };
1064
1059
  const mergeAttributes = (attributes1, attributes2) => {
1065
- return attributes1.map(attribute => _extends({}, attribute, attributes2.find(_ref3 => {
1060
+ return attributes1.map(attribute => _extends({}, attribute, attributes2.find((_ref3) => {
1066
1061
  let {
1067
1062
  name
1068
1063
  } = _ref3;
@@ -1477,7 +1472,7 @@ let SGisPolygonSymbol = /*#__PURE__*/function (_sPolygonSymbol) {
1477
1472
  const adaptMiterRings = (rings, resolution, fromCrs, toCrs) => {
1478
1473
  const projected = projectRings(rings, fromCrs, toCrs);
1479
1474
  return simplifyCoordinates(projected.map(ring => // @ts-ignore
1480
- ring.map(_ref => {
1475
+ ring.map((_ref) => {
1481
1476
  let [x, y] = _ref;
1482
1477
  return [x / resolution, y / -resolution];
1483
1478
  })), 1);
@@ -1569,1965 +1564,1625 @@ let ArrowLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1569
1564
  return ArrowLineMiterRender;
1570
1565
  }(LineMiterRender);
1571
1566
 
1572
- const DEFAULT_FORMATTERS = {
1573
- polygon: formatPolygonMeasure,
1574
- length: formatLength
1575
- };
1576
-
1577
- const COORD_FRACTION = 6;
1578
- const DEFAULT_LABEL_POSITION = [Infinity, Infinity];
1579
- let BaseMeasureToolCreator = /*#__PURE__*/function (_PolylineControl) {
1580
- _inherits(BaseMeasureToolCreator, _PolylineControl);
1581
-
1582
- var _super = /*#__PURE__*/_createSuper(BaseMeasureToolCreator);
1567
+ let CircleLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1568
+ _inherits(CircleLineMiterRender, _LineMiterRender);
1583
1569
 
1584
- function BaseMeasureToolCreator(map, painter, params) {
1585
- var _this;
1570
+ var _super = /*#__PURE__*/_createSuper(CircleLineMiterRender);
1586
1571
 
1587
- _classCallCheck(this, BaseMeasureToolCreator);
1572
+ function CircleLineMiterRender() {
1573
+ _classCallCheck(this, CircleLineMiterRender);
1588
1574
 
1589
- _this = _super.call(this, map, params);
1575
+ return _super.apply(this, arguments);
1576
+ }
1590
1577
 
1591
- _this.cancel = () => {
1592
- _this.fire('cancel');
1593
- };
1578
+ _createClass(CircleLineMiterRender, [{
1579
+ key: "usageSize",
1580
+ get: function get() {
1581
+ return this.miterSize + this.strokeWidth * 3;
1582
+ }
1583
+ }, {
1584
+ key: "createRings",
1585
+ value: function createRings(_ref, xMultiplier) {
1586
+ let [x, y] = _ref;
1587
+ return [[[x + (this.miterSize / 2 + this.strokeWidth) * xMultiplier, y]]];
1588
+ }
1589
+ }, {
1590
+ key: "createRender",
1591
+ value: function createRender(miterRings) {
1592
+ const isFilled = this.kind === LineMiterKind.FilledCircle;
1593
+ return new PolyRender(polygonCircleFromPoint(miterRings[0][0], this.miterSize), {
1594
+ fillColor: isFilled ? this.color : 'transparent',
1595
+ strokeColor: this.color,
1596
+ strokeWidth: this.strokeWidth,
1597
+ enclosed: true
1598
+ });
1599
+ }
1600
+ }]);
1594
1601
 
1595
- _this.painter = painter;
1596
- _this.renderLabelSymbol = params.renderLabelSymbol;
1597
- _this.formatters = params.formatters || DEFAULT_FORMATTERS;
1598
- _this.areaSymbol = params.areaSymbol;
1602
+ return CircleLineMiterRender;
1603
+ }(LineMiterRender);
1599
1604
 
1600
- _this.on('pointAdd', _this.handlePointAdd); // @ts-ignore
1605
+ let SquareLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1606
+ _inherits(SquareLineMiterRender, _LineMiterRender);
1601
1607
 
1608
+ var _super = /*#__PURE__*/_createSuper(SquareLineMiterRender);
1602
1609
 
1603
- _this.on('change', _this.updateDistance);
1610
+ function SquareLineMiterRender() {
1611
+ _classCallCheck(this, SquareLineMiterRender);
1604
1612
 
1605
- return _this;
1613
+ return _super.apply(this, arguments);
1606
1614
  }
1607
1615
 
1608
- _createClass(BaseMeasureToolCreator, [{
1609
- key: "_handleMousemove",
1610
- value: function _handleMousemove(event) {
1611
- _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_handleMousemove", this).call(this, event);
1612
-
1613
- this.drawPointOnMouseMove(event);
1616
+ _createClass(SquareLineMiterRender, [{
1617
+ key: "usageSize",
1618
+ get: function get() {
1619
+ return this.miterSize + this.strokeWidth;
1614
1620
  }
1615
1621
  }, {
1616
- key: "_activate",
1617
- value: function _activate() {
1618
- _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_activate", this).call(this);
1619
-
1620
- this.addTempLabel();
1621
- this.setCursor('pointer');
1622
+ key: "createRings",
1623
+ value: function createRings(_ref, xMultiplier) {
1624
+ let [x, y] = _ref;
1625
+ 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]]];
1622
1626
  }
1623
1627
  }, {
1624
- key: "_deactivate",
1625
- value: function _deactivate() {
1626
- _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_deactivate", this).call(this);
1627
-
1628
- this.removeCoordLabel();
1629
- this.removeTempLabel();
1630
- this.removeMeasureLabel();
1631
- this.removeTempPolygon();
1632
- this.setCursor('default');
1628
+ key: "createRender",
1629
+ value: function createRender(miterRings) {
1630
+ const isFilled = this.kind === LineMiterKind.FilledSquare;
1631
+ return new PolyRender(miterRings, {
1632
+ enclosed: true,
1633
+ fillColor: isFilled ? this.color : void 0,
1634
+ fillStyle: isFilled ? FillStyle.Color : FillStyle.None,
1635
+ lineCap: 'square',
1636
+ lineJoin: 'miter',
1637
+ strokeColor: this.color,
1638
+ strokeWidth: this.strokeWidth
1639
+ });
1633
1640
  }
1634
- }, {
1635
- key: "handlePointAdd",
1636
- value: function handlePointAdd() {
1637
- const feature = this.activeFeature;
1638
- if (!feature) return;
1639
- const {
1640
- rings,
1641
- crs
1642
- } = feature;
1641
+ }]);
1643
1642
 
1644
- if (isPolylineLikePolygon(rings, this.map.resolution)) {
1645
- this.finishDrawing();
1646
- this.fire(new DrawingFinishEvent(feature, new MouseEvent('mouseup')));
1647
- return;
1648
- }
1643
+ return SquareLineMiterRender;
1644
+ }(LineMiterRender);
1649
1645
 
1650
- if (rings[0].length === 2) {
1651
- const projection = crs.projectionTo(geo);
1652
- const point = rings[0][0];
1653
- if (!projection) return;
1654
- const [lat, long] = projection(point);
1655
- this.removeTempLabel();
1656
- this.addMeasureResultLabel();
1657
- this.addCoordLabel(lat.toFixed(COORD_FRACTION) + ", " + long.toFixed(COORD_FRACTION), point);
1658
- } else {
1659
- this.removeCoordLabel();
1660
- }
1646
+ const getLineMiterRender = options => {
1647
+ switch (options.kind) {
1648
+ case LineMiterKind.Arrow:
1649
+ case LineMiterKind.FilledArrow:
1650
+ return new ArrowLineMiterRender(options);
1651
+
1652
+ case LineMiterKind.Square:
1653
+ case LineMiterKind.FilledSquare:
1654
+ return new SquareLineMiterRender(options);
1655
+
1656
+ case LineMiterKind.Circle:
1657
+ case LineMiterKind.FilledCircle:
1658
+ return new CircleLineMiterRender(options);
1659
+
1660
+ default:
1661
+ return null;
1662
+ }
1663
+ };
1664
+
1665
+ const updateRingForRightMiter = (ring, miterSize, isLastRing) => {
1666
+ const reversedRing = ring.slice().reverse();
1667
+
1668
+ for (let i = 0; i < reversedRing.length; i++) {
1669
+ const coordinates = reversedRing[i];
1670
+
1671
+ if (isLastRing && i === 0) {
1672
+ reversedRing[i] = [coordinates[0] - miterSize, coordinates[1]];
1661
1673
  }
1662
- }, {
1663
- key: "polygonPreview",
1664
- value: function polygonPreview() {
1665
- if (this.tempPolygon) {
1666
- this._tempLayer && this._tempLayer.remove(this.tempPolygon);
1667
- }
1668
1674
 
1669
- const feature = this.activeFeature;
1670
- if (!feature) return;
1671
- const {
1672
- rings,
1673
- crs
1674
- } = feature;
1675
- const polygonRings = [...rings[0]];
1676
- polygonRings.shift();
1677
- this.tempPolygon = new Polygon(polygonRings, {
1678
- crs
1679
- });
1680
- this.tempPolygon.symbol = this.areaSymbol || measureAreaSymbol;
1681
- this.activeFeature && this.activeFeature.hide();
1682
- this._tempLayer && this._tempLayer.add(this.tempPolygon);
1675
+ const nextCoordinates = reversedRing[i - 1];
1676
+
1677
+ if (nextCoordinates && nextCoordinates[0] < coordinates[0]) {
1678
+ reversedRing[i] = [nextCoordinates[0] - Math.abs(nextCoordinates[0] - coordinates[0]), coordinates[1]];
1683
1679
  }
1684
- }, {
1685
- key: "removeTempPolygon",
1686
- value: function removeTempPolygon() {
1687
- if (this.tempPolygon) {
1688
- this._tempLayer && this._tempLayer.remove(this.tempPolygon);
1689
- delete this.tempPolygon;
1690
- }
1680
+ }
1681
+
1682
+ return reversedRing.reverse();
1683
+ };
1684
+
1685
+ const updateRingForLeftMiter = (ring, miterSize, isFirstRing) => {
1686
+ const newRing = ring.slice();
1687
+
1688
+ for (let i = 0; i < newRing.length; i++) {
1689
+ const coordinates = newRing[i];
1690
+
1691
+ if (i === 0 && isFirstRing) {
1692
+ newRing[i] = [coordinates[0] + miterSize, coordinates[1]];
1691
1693
  }
1692
- }, {
1693
- key: "updateDistance",
1694
- value: function updateDistance(event) {
1695
- const feature = this.activeFeature;
1696
- const {
1697
- ringIndex,
1698
- pointIndex
1699
- } = event;
1700
- if (!feature || ringIndex === null || pointIndex === null) return;
1701
- const {
1702
- rings,
1703
- crs
1704
- } = feature;
1705
- const position = rings[ringIndex][pointIndex];
1706
- const length$1 = length(rings, crs);
1707
- let content = this.formatters.length(length$1);
1708
1694
 
1709
- if (isPolylineLikePolygon(rings, this.map.resolution)) {
1710
- this.polygonPreview();
1711
- const area$1 = area(rings, crs);
1712
- content = this.formatters.polygon(area$1, length$1);
1713
- } else if (this.tempPolygon) {
1714
- feature.show();
1715
- this.removeTempPolygon();
1716
- }
1695
+ const prevCoordinates = newRing[i - 1];
1717
1696
 
1718
- if (this.measureResultLabel) {
1719
- this.measureResultLabel.position = position;
1720
- this.measureResultLabel.content = content;
1721
- }
1697
+ if (prevCoordinates && prevCoordinates[0] > coordinates[0]) {
1698
+ newRing[i] = [prevCoordinates[0] + Math.abs(coordinates[0] - prevCoordinates[0]), coordinates[1]];
1722
1699
  }
1723
- }, {
1724
- key: "addTempLabel",
1725
- value: function addTempLabel() {
1726
- this.tempLabel = new LabelFeature(DEFAULT_LABEL_POSITION, {
1727
- content: 'Нажмите на карту, чтобы начать измерение',
1728
- crs: this.map.crs,
1729
- symbol: createLabelSymbol({
1730
- renderLabel: this.renderLabelSymbol
1731
- })
1732
- });
1733
- this._tempLayer && this._tempLayer.add(this.tempLabel);
1734
- }
1735
- }, {
1736
- key: "addCoordLabel",
1737
- value: function addCoordLabel(content, position) {
1738
- this.coordLabel = new LabelFeature(position, {
1739
- content,
1740
- crs: this.map.crs,
1741
- symbol: createLabelSymbol({
1742
- renderLabel: this.renderLabelSymbol,
1743
- onClose: this.cancel
1744
- })
1745
- });
1746
- this._tempLayer && this.coordLabel && this._tempLayer.add(this.coordLabel);
1747
- }
1748
- }, {
1749
- key: "addMeasureResultLabel",
1750
- value: function addMeasureResultLabel() {
1751
- this.measureResultLabel = new LabelFeature(DEFAULT_LABEL_POSITION, {
1752
- crs: this.map.crs,
1753
- symbol: createLabelSymbol({
1754
- renderLabel: this.renderLabelSymbol
1755
- })
1756
- });
1757
- this._tempLayer && this.measureResultLabel && this._tempLayer.add(this.measureResultLabel);
1758
- }
1759
- }, {
1760
- key: "removeTempLabel",
1761
- value: function removeTempLabel() {
1762
- if (this.tempLabel) {
1763
- this._tempLayer && this._tempLayer.remove(this.tempLabel);
1764
- delete this.tempLabel;
1765
- }
1766
- }
1767
- }, {
1768
- key: "removeCoordLabel",
1769
- value: function removeCoordLabel() {
1770
- if (this.coordLabel) {
1771
- this._tempLayer && this._tempLayer.remove(this.coordLabel);
1772
- delete this.coordLabel;
1773
- }
1774
- }
1775
- }, {
1776
- key: "removeMeasureLabel",
1777
- value: function removeMeasureLabel() {
1778
- if (this.measureResultLabel) {
1779
- this._tempLayer && this._tempLayer.remove(this.measureResultLabel);
1780
- delete this.measureResultLabel;
1781
- }
1782
- }
1783
- }, {
1784
- key: "drawPointOnMouseMove",
1785
- value: function drawPointOnMouseMove(event) {
1786
- if (this.tempLabel) {
1787
- this.tempLabel.position = event.point.position;
1788
- }
1789
- }
1790
- }, {
1791
- key: "setCursor",
1792
- value: function setCursor(cursor) {
1793
- const {
1794
- wrapper
1795
- } = this.painter;
1700
+ }
1796
1701
 
1797
- if (wrapper && typeof wrapper !== 'string') {
1798
- wrapper.style.cursor = cursor;
1799
- }
1702
+ return newRing;
1703
+ };
1704
+
1705
+ const updateRingsForMiter = (rings, position, miterSize) => {
1706
+ return rings.map((ring, ringIndex) => {
1707
+ switch (position) {
1708
+ case 'right':
1709
+ return updateRingForRightMiter(ring, miterSize, ringIndex === rings.length - 1);
1710
+
1711
+ default:
1712
+ return updateRingForLeftMiter(ring, miterSize, ringIndex === 0);
1800
1713
  }
1801
- }]);
1714
+ });
1715
+ };
1802
1716
 
1803
- return BaseMeasureToolCreator;
1804
- }(PolylineControl);
1717
+ const copyRings = rings => rings.map(ring => ring.map(coordinates => coordinates.slice()));
1718
+ let SGisPolylineSymbol = /*#__PURE__*/function (_sPolylineSymbol) {
1719
+ _inherits(SGisPolylineSymbol, _sPolylineSymbol);
1805
1720
 
1806
- let BaseMeasureToolEditor = /*#__PURE__*/function (_PolyEditor) {
1807
- _inherits(BaseMeasureToolEditor, _PolyEditor);
1721
+ var _super = /*#__PURE__*/_createSuper(SGisPolylineSymbol);
1808
1722
 
1809
- var _super = /*#__PURE__*/_createSuper(BaseMeasureToolEditor);
1723
+ function SGisPolylineSymbol(originalSymbol) {
1724
+ var _originalSymbol$strok, _originalSymbol$strok2;
1810
1725
 
1811
- function BaseMeasureToolEditor(map, painter, params) {
1812
1726
  var _this;
1813
1727
 
1814
- _classCallCheck(this, BaseMeasureToolEditor);
1728
+ _classCallCheck(this, SGisPolylineSymbol);
1815
1729
 
1816
- _this = _super.call(this, map, params);
1730
+ _this = _super.call(this, {
1731
+ // @ts-ignore
1732
+ strokeColor: getHexColor(getParameterValue((_originalSymbol$strok = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok.color)),
1733
+ strokeWidth: clamp( // @ts-ignore
1734
+ getParameterValue((_originalSymbol$strok2 = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok2.width), PREVIEW_LIMITS.STROKE_WIDTH_MIN, PREVIEW_LIMITS.STROKE_WIDTH_MAX),
1735
+ // @ts-ignore
1736
+ lineDash: getLineDash(originalSymbol.stroke),
1737
+ // @ts-ignore
1738
+ lineCap: isDashedBrush(originalSymbol.stroke) ? 'square' : 'round'
1739
+ });
1740
+ _this.originalSymbol = originalSymbol;
1741
+ return _this;
1742
+ }
1817
1743
 
1818
- _this.measureResult = () => {
1819
- const feature = _this.activeFeature;
1820
- if (!feature) return null;
1744
+ _createClass(SGisPolylineSymbol, [{
1745
+ key: "renderFunction",
1746
+ value: function renderFunction(feature, resolution, crs) {
1747
+ if (!isSimplePolylineSymbol(this.originalSymbol)) return _get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, feature, resolution, crs);
1821
1748
  const {
1822
- rings,
1823
- isEnclosed,
1824
- crs
1825
- } = feature;
1826
- const pointsCount = rings[0].length;
1827
- const position = rings[0][pointsCount - 1];
1828
- const area$1 = area(rings, crs);
1829
- const length$1 = length(rings, crs, isEnclosed);
1830
- const content = isEnclosed ? _this.formatters.polygon(area$1, length$1) : _this.formatters.length(length$1);
1831
- return {
1832
- content,
1833
- position
1834
- };
1835
- };
1749
+ ending,
1750
+ beginningSize,
1751
+ beginning,
1752
+ endingSize
1753
+ } = this.originalSymbol;
1754
+ const renders = [];
1755
+ const featureCopy = feature.clone();
1756
+ const beginningMiterRender = getLineMiterRender({
1757
+ color: this.strokeColor,
1758
+ // @ts-ignore
1759
+ kind: beginning,
1760
+ position: 'left',
1761
+ // @ts-ignore
1762
+ size: beginningSize,
1763
+ strokeWidth: this.strokeWidth
1764
+ });
1765
+ const endingMiterRender = getLineMiterRender({
1766
+ color: this.strokeColor,
1767
+ // @ts-ignore
1768
+ kind: ending,
1769
+ position: 'right',
1770
+ // @ts-ignore
1771
+ size: endingSize,
1772
+ strokeWidth: this.strokeWidth
1773
+ });
1836
1774
 
1837
- _this.removeFeature = () => {
1838
- _this.fire('remove');
1839
- };
1775
+ if (beginningMiterRender) {
1776
+ const updatedRings = updateRingsForMiter(featureCopy.rings, 'left', beginningMiterRender.usageSize);
1777
+ const render = beginningMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
1778
+ featureCopy.rings = updatedRings;
1779
+ renders.push(render);
1780
+ }
1840
1781
 
1841
- _this.painter = painter;
1842
- _this.renderLabelSymbol = params.renderLabelSymbol;
1843
- _this.formatters = params.formatters || DEFAULT_FORMATTERS;
1782
+ if (endingMiterRender) {
1783
+ const updatedRings = updateRingsForMiter(featureCopy.rings, 'right', endingMiterRender.usageSize);
1784
+ const render = endingMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
1785
+ featureCopy.rings = updatedRings;
1786
+ renders.push(render);
1787
+ } // NOTE: линия должна быть в начале чтобы быть под митерами
1844
1788
 
1845
- _this.on('change', _this.updateMeasureResult);
1846
1789
 
1847
- _this.on('edit', _this.updateMeasureResult);
1790
+ renders.unshift(..._get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, featureCopy, resolution, crs));
1791
+ return renders;
1792
+ }
1793
+ }, {
1794
+ key: "clone",
1795
+ value: function clone() {
1796
+ return new SGisPolylineSymbol(this.originalSymbol);
1797
+ }
1798
+ }]);
1799
+
1800
+ return SGisPolylineSymbol;
1801
+ }(PolylineSymbol);
1802
+
1803
+ let LabelSymbol = /*#__PURE__*/function (_DynamicPointSymbol) {
1804
+ _inherits(LabelSymbol, _DynamicPointSymbol);
1805
+
1806
+ var _super = /*#__PURE__*/_createSuper(LabelSymbol);
1807
+
1808
+ function LabelSymbol(_temp) {
1809
+ var _this;
1810
+
1811
+ let {
1812
+ component,
1813
+ offset
1814
+ } = _temp === void 0 ? {} : _temp;
1815
+
1816
+ _classCallCheck(this, LabelSymbol);
1848
1817
 
1818
+ _this = _super.call(this, {
1819
+ offset
1820
+ });
1821
+ _this.component = component;
1849
1822
  return _this;
1850
1823
  }
1851
1824
 
1852
- _createClass(BaseMeasureToolEditor, [{
1853
- key: "_activate",
1854
- value: function _activate() {
1855
- _get(_getPrototypeOf(BaseMeasureToolEditor.prototype), "_activate", this).call(this);
1856
-
1857
- this.addMeasureResultLabel();
1825
+ _createClass(LabelSymbol, [{
1826
+ key: "_getFeatureNode",
1827
+ value: function _getFeatureNode(feature) {
1828
+ const node = document.createElement('div');
1829
+ this.renderDom(feature.content, node);
1830
+ return node;
1858
1831
  }
1859
1832
  }, {
1860
- key: "addMeasureResultLabel",
1861
- value: function addMeasureResultLabel() {
1862
- const measureResult = this.measureResult();
1863
- if (measureResult === null) return;
1864
- const {
1865
- content,
1866
- position
1867
- } = measureResult;
1868
- this.measureResultLabel = new LabelFeature(position, {
1869
- content,
1870
- crs: this.map.crs,
1871
- symbol: createLabelSymbol({
1872
- onClose: this.removeFeature,
1873
- renderLabel: this.renderLabelSymbol
1874
- })
1875
- });
1876
- this._tempLayer && this._tempLayer.add(this.measureResultLabel);
1833
+ key: "_updateFeatureNode",
1834
+ value: function _updateFeatureNode(feature) {
1835
+ this.renderDom(feature.content, this.getNode(feature));
1877
1836
  }
1878
1837
  }, {
1879
- key: "updateMeasureResult",
1880
- value: function updateMeasureResult() {
1881
- if (this.measureResultLabel) {
1882
- const measureResult = this.measureResult();
1883
- if (measureResult === null) return;
1884
- const {
1885
- content,
1886
- position
1887
- } = measureResult;
1888
- this.measureResultLabel.content = content;
1889
- this.measureResultLabel.position = position;
1838
+ key: "renderDom",
1839
+ value: function renderDom(content, node) {
1840
+ if (!node) {
1841
+ return;
1890
1842
  }
1891
- }
1892
- }]);
1893
1843
 
1894
- return BaseMeasureToolEditor;
1895
- }(PolyEditor);
1896
-
1897
- const metersToPixels = (meters, _ref) => {
1898
- let {
1899
- painter,
1900
- crs = geo
1901
- } = _ref;
1902
- const {
1903
- width
1904
- } = painter;
1905
- const zeroPoint = painter.getPointFromPxPosition(0, 0).projectTo(crs);
1906
- const maxWidthPoint = painter.getPointFromPxPosition(width, 0).projectTo(crs);
1907
- const widthDistance = distance(zeroPoint, maxWidthPoint);
1908
- const pxK = width / (widthDistance || 1);
1909
- return Math.round(meters * pxK);
1910
- };
1844
+ const Component = this.component;
1911
1845
 
1912
- const polygonCircleFromPoint = (center, diameter) => {
1913
- const coordinates = [];
1914
- const radius = diameter / 2;
1915
- const endAngle = Math.PI * 2;
1916
- const step = Math.max(Math.PI / 2 / radius, endAngle / 128);
1917
- let start = 0;
1918
- let end = endAngle;
1846
+ if (Component) {
1847
+ ReactDOM.render(React.createElement(Component, {
1848
+ content: content
1849
+ }), node);
1850
+ } else {
1851
+ node.innerText = content;
1852
+ }
1853
+ }
1854
+ }]);
1919
1855
 
1920
- for (let ang = start; ang < end; ang += step) {
1921
- coordinates.push([Math.cos(ang) * radius + center[0], Math.sin(ang) * radius + center[1]]);
1922
- }
1856
+ return LabelSymbol;
1857
+ }(DynamicPointSymbol);
1923
1858
 
1924
- return [coordinates];
1859
+ const defaultOffset = [8, -16];
1860
+ const createLabelSymbol = props => {
1861
+ const {
1862
+ offset = defaultOffset,
1863
+ renderLabel = (_ref) => {
1864
+ let {
1865
+ content
1866
+ } = _ref;
1867
+ return React.createElement("div", null, content);
1868
+ },
1869
+ onClose = undefined
1870
+ } = props || {};
1871
+ return new LabelSymbol({
1872
+ offset,
1873
+ component: (_ref2) => {
1874
+ let {
1875
+ content
1876
+ } = _ref2;
1877
+ return renderLabel({
1878
+ content,
1879
+ onClose
1880
+ });
1881
+ }
1882
+ });
1925
1883
  };
1926
1884
 
1927
- let CircleLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1928
- _inherits(CircleLineMiterRender, _LineMiterRender);
1885
+ function createShadowRender(position, _ref) {
1886
+ let {
1887
+ strokeWidth = 2,
1888
+ shadowColor,
1889
+ shadowSize,
1890
+ size = 6
1891
+ } = _ref;
1892
+ const shadowDiameter = size + strokeWidth + shadowSize;
1893
+ return new PolyRender(polygonCircleFromPoint(position, shadowDiameter), {
1894
+ fillColor: 'transparent',
1895
+ strokeColor: shadowColor,
1896
+ strokeWidth: shadowSize,
1897
+ enclosed: true
1898
+ });
1899
+ }
1900
+ function getEditorPointRenderer(position, _ref2) {
1901
+ let {
1902
+ strokeColor,
1903
+ strokeWidth,
1904
+ shadowColor,
1905
+ fillColor,
1906
+ shadowSize,
1907
+ size = 0
1908
+ } = _ref2;
1909
+ return [createShadowRender(position, {
1910
+ strokeWidth,
1911
+ strokeColor,
1912
+ shadowSize,
1913
+ shadowColor,
1914
+ size
1915
+ }), new PolyRender(polygonCircleFromPoint(position, size), {
1916
+ fillColor,
1917
+ strokeColor,
1918
+ strokeWidth,
1919
+ enclosed: true
1920
+ })];
1921
+ }
1929
1922
 
1930
- var _super = /*#__PURE__*/_createSuper(CircleLineMiterRender);
1923
+ let ShadowedPointSymbol = /*#__PURE__*/function (_PointSymbol) {
1924
+ _inherits(ShadowedPointSymbol, _PointSymbol);
1931
1925
 
1932
- function CircleLineMiterRender() {
1933
- _classCallCheck(this, CircleLineMiterRender);
1926
+ var _super = /*#__PURE__*/_createSuper(ShadowedPointSymbol);
1934
1927
 
1935
- return _super.apply(this, arguments);
1928
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
1929
+ function ShadowedPointSymbol(options) {
1930
+ _classCallCheck(this, ShadowedPointSymbol);
1931
+
1932
+ return _super.call(this, options);
1936
1933
  }
1937
1934
 
1938
- _createClass(CircleLineMiterRender, [{
1939
- key: "usageSize",
1940
- get: function get() {
1941
- return this.miterSize + this.strokeWidth * 3;
1935
+ _createClass(ShadowedPointSymbol, [{
1936
+ key: "renderFunction",
1937
+ value: function renderFunction(feature, resolution, crs) {
1938
+ if (!(feature instanceof PointFeature)) return [];
1939
+ const {
1940
+ position
1941
+ } = feature.projectTo(crs);
1942
+ const pxPosition = [position[0] / resolution + (this.offset[0] || 0), -position[1] / resolution + (this.offset[1] || 0)];
1943
+ const shadowRender = this.getShadow(pxPosition, feature);
1944
+ const pointArc = this.getPoint(pxPosition, feature);
1945
+ return shadowRender ? [shadowRender, pointArc] : [pointArc];
1942
1946
  }
1943
1947
  }, {
1944
- key: "createRings",
1945
- value: function createRings(_ref, xMultiplier) {
1946
- let [x, y] = _ref;
1947
- return [[[x + (this.miterSize / 2 + this.strokeWidth) * xMultiplier, y]]];
1948
+ key: "getShadow",
1949
+ value: function getShadow(position, _feature) {
1950
+ return ShadowedPointSymbol.getShadowArc(position, this);
1948
1951
  }
1949
1952
  }, {
1950
- key: "createRender",
1951
- value: function createRender(miterRings) {
1952
- const isFilled = this.kind === LineMiterKind.FilledCircle;
1953
- return new PolyRender(polygonCircleFromPoint(miterRings[0][0], this.miterSize), {
1954
- fillColor: isFilled ? this.color : 'transparent',
1955
- strokeColor: this.color,
1956
- strokeWidth: this.strokeWidth,
1953
+ key: "getPoint",
1954
+ value: function getPoint(position, _feature) {
1955
+ return ShadowedPointSymbol.getPointArc(position, this);
1956
+ }
1957
+ }], [{
1958
+ key: "getShadowArc",
1959
+ value: function getShadowArc(position, _ref) {
1960
+ let {
1961
+ strokeWidth = 2,
1962
+ shadowColor,
1963
+ shadowSize,
1964
+ size = 6
1965
+ } = _ref;
1966
+ return new PolyRender(polygonCircleFromPoint(position, size + strokeWidth + shadowSize), {
1967
+ fillColor: 'transparent',
1968
+ strokeColor: shadowColor,
1969
+ strokeWidth: shadowSize,
1957
1970
  enclosed: true
1958
1971
  });
1959
1972
  }
1960
- }]);
1961
-
1962
- return CircleLineMiterRender;
1963
- }(LineMiterRender);
1964
-
1965
- let SquareLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
1966
- _inherits(SquareLineMiterRender, _LineMiterRender);
1967
-
1968
- var _super = /*#__PURE__*/_createSuper(SquareLineMiterRender);
1969
-
1970
- function SquareLineMiterRender() {
1971
- _classCallCheck(this, SquareLineMiterRender);
1972
-
1973
- return _super.apply(this, arguments);
1974
- }
1975
-
1976
- _createClass(SquareLineMiterRender, [{
1977
- key: "usageSize",
1978
- get: function get() {
1979
- return this.miterSize + this.strokeWidth;
1980
- }
1981
1973
  }, {
1982
- key: "createRings",
1983
- value: function createRings(_ref, xMultiplier) {
1984
- let [x, y] = _ref;
1985
- 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]]];
1974
+ key: "getPointArc",
1975
+ value: function getPointArc(position, _ref2) {
1976
+ let {
1977
+ strokeWidth,
1978
+ fillColor,
1979
+ strokeColor,
1980
+ size = 6
1981
+ } = _ref2;
1982
+ return new PolyRender(polygonCircleFromPoint(position, size), {
1983
+ fillColor,
1984
+ strokeColor,
1985
+ strokeWidth,
1986
+ enclosed: true
1987
+ });
1986
1988
  }
1987
1989
  }, {
1988
- key: "createRender",
1989
- value: function createRender(miterRings) {
1990
- const isFilled = this.kind === LineMiterKind.FilledSquare;
1991
- return new PolyRender(miterRings, {
1992
- enclosed: true,
1993
- fillColor: isFilled ? this.color : void 0,
1994
- fillStyle: isFilled ? FillStyle.Color : FillStyle.None,
1995
- lineCap: 'square',
1996
- lineJoin: 'miter',
1997
- strokeColor: this.color,
1998
- strokeWidth: this.strokeWidth
1999
- });
1990
+ key: "getArcs",
1991
+ value: function getArcs(position, params) {
1992
+ const shadowRender = ShadowedPointSymbol.getShadowArc(position, params);
1993
+ const pointRender = ShadowedPointSymbol.getPointArc(position, params);
1994
+ return shadowRender ? [shadowRender, pointRender] : [pointRender];
2000
1995
  }
2001
1996
  }]);
2002
1997
 
2003
- return SquareLineMiterRender;
2004
- }(LineMiterRender);
1998
+ return ShadowedPointSymbol;
1999
+ }(PointSymbol);
2005
2000
 
2006
- const getLineMiterRender = options => {
2007
- switch (options.kind) {
2008
- case LineMiterKind.Arrow:
2009
- case LineMiterKind.FilledArrow:
2010
- return new ArrowLineMiterRender(options);
2001
+ let ShadowedPolySymbol = /*#__PURE__*/function (_PolylineSymbol) {
2002
+ _inherits(ShadowedPolySymbol, _PolylineSymbol);
2011
2003
 
2012
- case LineMiterKind.Square:
2013
- case LineMiterKind.FilledSquare:
2014
- return new SquareLineMiterRender(options);
2004
+ var _super = /*#__PURE__*/_createSuper(ShadowedPolySymbol);
2015
2005
 
2016
- case LineMiterKind.Circle:
2017
- case LineMiterKind.FilledCircle:
2018
- return new CircleLineMiterRender(options);
2006
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2007
+ function ShadowedPolySymbol(options) {
2008
+ _classCallCheck(this, ShadowedPolySymbol);
2019
2009
 
2020
- default:
2021
- return null;
2010
+ return _super.call(this, options);
2022
2011
  }
2023
- };
2024
2012
 
2025
- const updateRingForRightMiter = (ring, miterSize, isLastRing) => {
2026
- const reversedRing = ring.slice().reverse();
2013
+ _createClass(ShadowedPolySymbol, [{
2014
+ key: "renderFunction",
2015
+ value: function renderFunction(feature, resolution, crs) {
2016
+ if (!(feature instanceof Poly)) return [];
2017
+ const coordinates = PolylineSymbol.getRenderedCoordinates(feature, resolution, crs);
2018
+ const polyRender = this.getPolyRender(coordinates, feature);
2019
+ const shadowRender = this.getShadow(coordinates, feature);
2020
+ const vertexRenders = this.getVertexRenders(coordinates);
2021
+ let renders = [polyRender];
2027
2022
 
2028
- for (let i = 0; i < reversedRing.length; i++) {
2029
- const coordinates = reversedRing[i];
2023
+ if (shadowRender) {
2024
+ renders = [shadowRender, polyRender];
2025
+ }
2030
2026
 
2031
- if (isLastRing && i === 0) {
2032
- reversedRing[i] = [coordinates[0] - miterSize, coordinates[1]];
2033
- }
2034
-
2035
- const nextCoordinates = reversedRing[i - 1];
2027
+ if (vertexRenders) {
2028
+ renders = renders.concat(vertexRenders);
2029
+ }
2036
2030
 
2037
- if (nextCoordinates && nextCoordinates[0] < coordinates[0]) {
2038
- reversedRing[i] = [nextCoordinates[0] - Math.abs(nextCoordinates[0] - coordinates[0]), coordinates[1]];
2031
+ return renders;
2039
2032
  }
2040
- }
2033
+ }, {
2034
+ key: "getShadow",
2035
+ value: function getShadow(coordinates, _feature) {
2036
+ return new PolyRender(coordinates, {
2037
+ fillStyle: FillStyle.None,
2038
+ enclosed: this.enclose,
2039
+ strokeColor: this.shadowColor,
2040
+ strokeWidth: this.shadowSize,
2041
+ lineDash: this.lineDash
2042
+ });
2043
+ }
2044
+ }, {
2045
+ key: "getPolyRender",
2046
+ value: function getPolyRender(coordinates, _feature) {
2047
+ return new PolyRender(coordinates, {
2048
+ fillStyle: this.enclose ? FillStyle.Color : FillStyle.None,
2049
+ enclosed: this.enclose,
2050
+ fillColor: this.fillColor,
2051
+ strokeColor: this.strokeColor,
2052
+ strokeWidth: this.strokeWidth,
2053
+ lineDash: this.lineDash
2054
+ });
2055
+ }
2056
+ }, {
2057
+ key: "getVertexRenders",
2058
+ value: function getVertexRenders(coordinates) {
2059
+ if (!this.showVertex) return;
2060
+ const vertexCoordinates = coordinates.reduce((acc, curr) => {
2061
+ return acc.concat(curr);
2062
+ }, []);
2063
+ return vertexCoordinates.map(coord => getEditorPointRenderer(coord, {
2064
+ size: 6,
2065
+ strokeWidth: 2,
2066
+ shadowColor: this.shadowColor,
2067
+ strokeColor: this.strokeColor,
2068
+ shadowSize: this.vertexShadowSize !== undefined ? this.vertexShadowSize : 2,
2069
+ fillColor: '#ffffff'
2070
+ })).reduce((acc, curr) => acc.concat(curr), []);
2071
+ }
2072
+ }]);
2041
2073
 
2042
- return reversedRing.reverse();
2074
+ return ShadowedPolySymbol;
2075
+ }(PolylineSymbol);
2076
+ const polySymbolParams = {
2077
+ strokeWidth: 2,
2078
+ strokeColor: '#e33600',
2079
+ shadowSize: 8,
2080
+ shadowColor: 'rgba(227, 54, 0, 0.3)'
2043
2081
  };
2082
+ const measureSymbolParams = {
2083
+ strokeColor: '#ff6933',
2084
+ shadowSize: 0,
2085
+ vertexShadowSize: 0
2086
+ };
2087
+ const measureLengthSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
2088
+ enclose: false,
2089
+ showVertex: true
2090
+ }));
2091
+ const measureAreaSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
2092
+ fillColor: 'rgba(255, 105, 51, 0.25)',
2093
+ enclose: true,
2094
+ showVertex: true
2095
+ }));
2096
+ const snapSymbolParams = {
2097
+ size: 10,
2098
+ strokeWidth: 2,
2099
+ strokeColor: '#e33600',
2100
+ fillColor: '#ffffff',
2101
+ shadowColor: 'rgba(227, 54, 0, 0.3)',
2102
+ shadowSize: 3
2103
+ };
2104
+ const measurePolygonSnapSymbol = /*#__PURE__*/new ShadowedPointSymbol( /*#__PURE__*/_extends({}, snapSymbolParams, {
2105
+ strokeColor: '#ff6933',
2106
+ shadowSize: 0
2107
+ }));
2044
2108
 
2045
- const updateRingForLeftMiter = (ring, miterSize, isFirstRing) => {
2046
- const newRing = ring.slice();
2047
-
2048
- for (let i = 0; i < newRing.length; i++) {
2049
- const coordinates = newRing[i];
2109
+ let SelectedPointSymbol = /*#__PURE__*/function (_ShadowedPointSymbol) {
2110
+ _inherits(SelectedPointSymbol, _ShadowedPointSymbol);
2050
2111
 
2051
- if (i === 0 && isFirstRing) {
2052
- newRing[i] = [coordinates[0] + miterSize, coordinates[1]];
2053
- }
2112
+ var _super = /*#__PURE__*/_createSuper(SelectedPointSymbol);
2054
2113
 
2055
- const prevCoordinates = newRing[i - 1];
2114
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2115
+ function SelectedPointSymbol(props) {
2116
+ _classCallCheck(this, SelectedPointSymbol);
2056
2117
 
2057
- if (prevCoordinates && prevCoordinates[0] > coordinates[0]) {
2058
- newRing[i] = [prevCoordinates[0] + Math.abs(coordinates[0] - prevCoordinates[0]), coordinates[1]];
2059
- }
2118
+ return _super.call(this, props);
2060
2119
  }
2061
2120
 
2062
- return newRing;
2063
- };
2121
+ _createClass(SelectedPointSymbol, [{
2122
+ key: "getShadow",
2123
+ value: function getShadow(position, feature) {
2124
+ if (feature.isSelected) {
2125
+ return _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getShadow", this).call(this, position, feature);
2126
+ }
2127
+ }
2128
+ }, {
2129
+ key: "getPoint",
2130
+ value: function getPoint(position, feature) {
2131
+ const pointRender = _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getPoint", this).call(this, position, feature);
2064
2132
 
2065
- const updateRingsForMiter = (rings, position, miterSize) => {
2066
- return rings.map((ring, ringIndex) => {
2067
- switch (position) {
2068
- case 'right':
2069
- return updateRingForRightMiter(ring, miterSize, ringIndex === rings.length - 1);
2133
+ if (feature.isSelected) {
2134
+ pointRender.strokeColor = this.selectedStrokeColor;
2135
+ pointRender.fillColor = this.selectedFillColor;
2136
+ }
2070
2137
 
2071
- default:
2072
- return updateRingForLeftMiter(ring, miterSize, ringIndex === 0);
2138
+ return pointRender;
2073
2139
  }
2074
- });
2075
- };
2076
-
2077
- const copyRings = rings => rings.map(ring => ring.map(coordinates => coordinates.slice()));
2078
- let SGisPolylineSymbol = /*#__PURE__*/function (_sPolylineSymbol) {
2079
- _inherits(SGisPolylineSymbol, _sPolylineSymbol);
2140
+ }]);
2080
2141
 
2081
- var _super = /*#__PURE__*/_createSuper(SGisPolylineSymbol);
2142
+ return SelectedPointSymbol;
2143
+ }(ShadowedPointSymbol);
2082
2144
 
2083
- function SGisPolylineSymbol(originalSymbol) {
2084
- var _originalSymbol$strok, _originalSymbol$strok2;
2145
+ let SelectedPolySymbol = /*#__PURE__*/function (_ShadowedPolySymbol) {
2146
+ _inherits(SelectedPolySymbol, _ShadowedPolySymbol);
2085
2147
 
2086
- var _this;
2148
+ var _super = /*#__PURE__*/_createSuper(SelectedPolySymbol);
2087
2149
 
2088
- _classCallCheck(this, SGisPolylineSymbol);
2150
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2151
+ function SelectedPolySymbol(props) {
2152
+ _classCallCheck(this, SelectedPolySymbol);
2089
2153
 
2090
- _this = _super.call(this, {
2091
- // @ts-ignore
2092
- strokeColor: getHexColor(getParameterValue((_originalSymbol$strok = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok.color)),
2093
- strokeWidth: clamp( // @ts-ignore
2094
- getParameterValue((_originalSymbol$strok2 = originalSymbol.stroke) == null ? void 0 : _originalSymbol$strok2.width), PREVIEW_LIMITS.STROKE_WIDTH_MIN, PREVIEW_LIMITS.STROKE_WIDTH_MAX),
2095
- // @ts-ignore
2096
- lineDash: getLineDash(originalSymbol.stroke),
2097
- // @ts-ignore
2098
- lineCap: isDashedBrush(originalSymbol.stroke) ? 'square' : 'round'
2099
- });
2100
- _this.originalSymbol = originalSymbol;
2101
- return _this;
2154
+ return _super.call(this, props);
2102
2155
  }
2103
2156
 
2104
- _createClass(SGisPolylineSymbol, [{
2105
- key: "renderFunction",
2106
- value: function renderFunction(feature, resolution, crs) {
2107
- if (!isSimplePolylineSymbol(this.originalSymbol)) return _get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, feature, resolution, crs);
2108
- const {
2109
- ending,
2110
- beginningSize,
2111
- beginning,
2112
- endingSize
2113
- } = this.originalSymbol;
2114
- const renders = [];
2115
- const featureCopy = feature.clone();
2116
- const beginningMiterRender = getLineMiterRender({
2117
- color: this.strokeColor,
2118
- // @ts-ignore
2119
- kind: beginning,
2120
- position: 'left',
2121
- // @ts-ignore
2122
- size: beginningSize,
2123
- strokeWidth: this.strokeWidth
2124
- });
2125
- const endingMiterRender = getLineMiterRender({
2126
- color: this.strokeColor,
2127
- // @ts-ignore
2128
- kind: ending,
2129
- position: 'right',
2130
- // @ts-ignore
2131
- size: endingSize,
2132
- strokeWidth: this.strokeWidth
2133
- });
2134
-
2135
- if (beginningMiterRender) {
2136
- const updatedRings = updateRingsForMiter(featureCopy.rings, 'left', beginningMiterRender.usageSize);
2137
- const render = beginningMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
2138
- featureCopy.rings = updatedRings;
2139
- renders.push(render);
2157
+ _createClass(SelectedPolySymbol, [{
2158
+ key: "getShadow",
2159
+ value: function getShadow(coordinates, feature) {
2160
+ if (feature.isSelected) {
2161
+ return _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getShadow", this).call(this, coordinates, feature);
2140
2162
  }
2141
-
2142
- if (endingMiterRender) {
2143
- const updatedRings = updateRingsForMiter(featureCopy.rings, 'right', endingMiterRender.usageSize);
2144
- const render = endingMiterRender.getRender(updatedRings, feature.crs, resolution, crs);
2145
- featureCopy.rings = updatedRings;
2146
- renders.push(render);
2147
- } // NOTE: линия должна быть в начале чтобы быть под митерами
2148
-
2149
-
2150
- renders.unshift(..._get(_getPrototypeOf(SGisPolylineSymbol.prototype), "renderFunction", this).call(this, featureCopy, resolution, crs));
2151
- return renders;
2152
2163
  }
2153
2164
  }, {
2154
- key: "clone",
2155
- value: function clone() {
2156
- return new SGisPolylineSymbol(this.originalSymbol);
2157
- }
2158
- }]);
2159
-
2160
- return SGisPolylineSymbol;
2161
- }(PolylineSymbol);
2162
-
2163
- let LabelSymbol = /*#__PURE__*/function (_DynamicPointSymbol) {
2164
- _inherits(LabelSymbol, _DynamicPointSymbol);
2165
-
2166
- var _super = /*#__PURE__*/_createSuper(LabelSymbol);
2165
+ key: "getPolyRender",
2166
+ value: function getPolyRender(coordinates, feature) {
2167
+ const polyRender = _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getPolyRender", this).call(this, coordinates, feature);
2167
2168
 
2168
- function LabelSymbol(_temp) {
2169
- var _this;
2169
+ if (feature.isSelected) {
2170
+ polyRender.fillColor = this.selectedFillColor;
2171
+ polyRender.strokeColor = this.selectedStrokeColor;
2170
2172
 
2171
- let {
2172
- component,
2173
- offset
2174
- } = _temp === void 0 ? {} : _temp;
2173
+ if (this.selectedStrokeWidth !== void 0) {
2174
+ polyRender.strokeWidth = this.selectedStrokeWidth;
2175
+ }
2176
+ }
2175
2177
 
2176
- _classCallCheck(this, LabelSymbol);
2178
+ return polyRender;
2179
+ }
2180
+ }]);
2177
2181
 
2178
- _this = _super.call(this, {
2179
- offset
2180
- });
2181
- _this.component = component;
2182
- return _this;
2183
- }
2182
+ return SelectedPolySymbol;
2183
+ }(ShadowedPolySymbol);
2184
2184
 
2185
- _createClass(LabelSymbol, [{
2186
- key: "_getFeatureNode",
2187
- value: function _getFeatureNode(feature) {
2188
- const node = document.createElement('div');
2189
- this.renderDom(feature.content, node);
2190
- return node;
2191
- }
2192
- }, {
2193
- key: "_updateFeatureNode",
2194
- value: function _updateFeatureNode(feature) {
2195
- this.renderDom(feature.content, this.getNode(feature));
2196
- }
2197
- }, {
2198
- key: "renderDom",
2199
- value: function renderDom(content, node) {
2200
- if (!node) {
2201
- return;
2202
- }
2203
-
2204
- const Component = this.component;
2205
-
2206
- if (Component) {
2207
- ReactDOM.render(React.createElement(Component, {
2208
- content: content
2209
- }), node);
2210
- } else {
2211
- node.innerText = content;
2212
- }
2213
- }
2214
- }]);
2215
-
2216
- return LabelSymbol;
2217
- }(DynamicPointSymbol);
2185
+ const selectedPoint = /*#__PURE__*/new SelectedPointSymbol({
2186
+ size: 8,
2187
+ strokeWidth: 2,
2188
+ strokeColor: 'rgba(255, 87, 34, 0.3)',
2189
+ fillColor: 'rgba(255, 255, 255, 0.65)',
2190
+ shadowColor: 'rgba(255, 87, 34, 0.3)',
2191
+ shadowSize: 3,
2192
+ selectedStrokeColor: '#ff5722',
2193
+ selectedFillColor: 'rgba(255, 255, 255, 0.65)'
2194
+ });
2195
+ const selectedPolyline = /*#__PURE__*/new SelectedPolySymbol({
2196
+ strokeWidth: 6,
2197
+ strokeColor: 'rgba(255, 87, 34, 0.2)',
2198
+ shadowSize: 8,
2199
+ shadowColor: 'rgba(255, 87, 34, 0.3)',
2200
+ selectedStrokeColor: '#ff5722',
2201
+ selectedStrokeWidth: 2
2202
+ });
2203
+ const selectedPolygon = /*#__PURE__*/new SelectedPolySymbol({
2204
+ strokeWidth: 2,
2205
+ strokeColor: 'rgba(255, 87, 34, 0.3)',
2206
+ shadowSize: 8,
2207
+ shadowColor: 'rgba(255, 87, 34, 0.3)',
2208
+ fillColor: 'rgba(255, 255, 255, 0.36)',
2209
+ enclose: true,
2210
+ selectedFillColor: 'rgba(255, 255, 255, 0.56)',
2211
+ selectedStrokeColor: '#ff5722'
2212
+ });
2218
2213
 
2219
- const defaultOffset = [8, -16];
2220
- const createLabelSymbol = props => {
2214
+ const metersToPixels = (meters, _ref) => {
2215
+ let {
2216
+ painter,
2217
+ crs = geo
2218
+ } = _ref;
2221
2219
  const {
2222
- offset = defaultOffset,
2223
- renderLabel = _ref => {
2224
- let {
2225
- content
2226
- } = _ref;
2227
- return React.createElement("div", null, content);
2228
- },
2229
- onClose = undefined
2230
- } = props || {};
2231
- return new LabelSymbol({
2232
- offset,
2233
- component: _ref2 => {
2234
- let {
2235
- content
2236
- } = _ref2;
2237
- return renderLabel({
2238
- content,
2239
- onClose
2240
- });
2241
- }
2242
- });
2220
+ width
2221
+ } = painter;
2222
+ const zeroPoint = painter.getPointFromPxPosition(0, 0).projectTo(crs);
2223
+ const maxWidthPoint = painter.getPointFromPxPosition(width, 0).projectTo(crs);
2224
+ const widthDistance = distance(zeroPoint, maxWidthPoint);
2225
+ const pxK = width / (widthDistance || 1);
2226
+ return Math.round(meters * pxK);
2243
2227
  };
2244
2228
 
2245
- function createShadowRender(position, _ref) {
2246
- let {
2247
- strokeWidth = 2,
2248
- shadowColor,
2249
- shadowSize,
2250
- size = 6
2251
- } = _ref;
2252
- const shadowDiameter = size + strokeWidth + shadowSize;
2253
- return new PolyRender(polygonCircleFromPoint(position, shadowDiameter), {
2254
- fillColor: 'transparent',
2255
- strokeColor: shadowColor,
2256
- strokeWidth: shadowSize,
2257
- enclosed: true
2258
- });
2259
- }
2260
- function getEditorPointRenderer(position, _ref2) {
2261
- let {
2262
- strokeColor,
2263
- strokeWidth,
2264
- shadowColor,
2265
- fillColor,
2266
- shadowSize,
2267
- size = 0
2268
- } = _ref2;
2269
- return [createShadowRender(position, {
2270
- strokeWidth,
2271
- strokeColor,
2272
- shadowSize,
2273
- shadowColor,
2274
- size
2275
- }), new PolyRender(polygonCircleFromPoint(position, size), {
2276
- fillColor,
2277
- strokeColor,
2278
- strokeWidth,
2279
- enclosed: true
2280
- })];
2281
- }
2229
+ const defaultPathStyles = {
2230
+ strokeWidth: 2,
2231
+ strokeColor: 'rgb(0, 163, 245)',
2232
+ fillStyle: FillStyle.None
2233
+ };
2234
+ let SVGPoly = /*#__PURE__*/function (_Symbol) {
2235
+ _inherits(SVGPoly, _Symbol);
2282
2236
 
2283
- let ShadowedPointSymbol = /*#__PURE__*/function (_PointSymbol) {
2284
- _inherits(ShadowedPointSymbol, _PointSymbol);
2237
+ var _super = /*#__PURE__*/_createSuper(SVGPoly);
2285
2238
 
2286
- var _super = /*#__PURE__*/_createSuper(ShadowedPointSymbol);
2239
+ function SVGPoly(_temp) {
2240
+ var _this;
2287
2241
 
2288
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2289
- function ShadowedPointSymbol(options) {
2290
- _classCallCheck(this, ShadowedPointSymbol);
2242
+ let {
2243
+ redrawFeatureNode,
2244
+ pathStyles,
2245
+ circle,
2246
+ className,
2247
+ appendToSvg
2248
+ } = _temp === void 0 ? {} : _temp;
2291
2249
 
2292
- return _super.call(this, options);
2250
+ _classCallCheck(this, SVGPoly);
2251
+
2252
+ _this = _super.call(this);
2253
+ _this.container = document.createElement('div');
2254
+ _this.container.style.position = 'absolute';
2255
+ _this.redrawFeatureNode = redrawFeatureNode;
2256
+ _this.pathStyles = _extends({
2257
+ center: [0, 0],
2258
+ fillColor: 'none'
2259
+ }, pathStyles);
2260
+ _this.circle = circle;
2261
+ _this.className = className;
2262
+ _this.appendToSvg = appendToSvg;
2263
+ return _this;
2293
2264
  }
2294
2265
 
2295
- _createClass(ShadowedPointSymbol, [{
2266
+ _createClass(SVGPoly, [{
2296
2267
  key: "renderFunction",
2297
2268
  value: function renderFunction(feature, resolution, crs) {
2298
- if (!(feature instanceof PointFeature)) return [];
2299
- const {
2300
- position
2301
- } = feature.projectTo(crs);
2302
- const pxPosition = [position[0] / resolution + (this.offset[0] || 0), -position[1] / resolution + (this.offset[1] || 0)];
2303
- const shadowRender = this.getShadow(pxPosition, feature);
2304
- const pointArc = this.getPoint(pxPosition, feature);
2305
- return shadowRender ? [shadowRender, pointArc] : [pointArc];
2306
- }
2307
- }, {
2308
- key: "getShadow",
2309
- value: function getShadow(position, _feature) {
2310
- return ShadowedPointSymbol.getShadowArc(position, this);
2311
- }
2312
- }, {
2313
- key: "getPoint",
2314
- value: function getPoint(position, _feature) {
2315
- return ShadowedPointSymbol.getPointArc(position, this);
2316
- }
2317
- }], [{
2318
- key: "getShadowArc",
2319
- value: function getShadowArc(position, _ref) {
2320
- let {
2321
- strokeWidth = 2,
2322
- shadowColor,
2323
- shadowSize,
2324
- size = 6
2325
- } = _ref;
2326
- return new PolyRender(polygonCircleFromPoint(position, size + strokeWidth + shadowSize), {
2327
- fillColor: 'transparent',
2328
- strokeColor: shadowColor,
2329
- strokeWidth: shadowSize,
2330
- enclosed: true
2269
+ const coordinates = feature instanceof Poly ? PolylineSymbol.getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
2270
+ this.setCirclePxRaius(crs);
2271
+ this.container.innerHTML = '';
2272
+ const svg = this.setSvg(coordinates);
2273
+ svg && this.container.append(svg);
2274
+ feature.__dynamicSymbolRender = new DynamicRender({
2275
+ node: this.container,
2276
+ update: (bbox, resolution) => this.update({
2277
+ bbox,
2278
+ resolution,
2279
+ feature,
2280
+ crs
2281
+ }),
2282
+ redraw: () => {
2283
+ this.redrawFeatureNode && this.redrawFeatureNode(feature);
2284
+ }
2331
2285
  });
2286
+
2287
+ this._setEventListeners(feature);
2288
+
2289
+ return [feature.__dynamicSymbolRender];
2332
2290
  }
2333
2291
  }, {
2334
- key: "getPointArc",
2335
- value: function getPointArc(position, _ref2) {
2336
- let {
2337
- strokeWidth,
2338
- fillColor,
2339
- strokeColor,
2340
- size = 6
2341
- } = _ref2;
2342
- return new PolyRender(polygonCircleFromPoint(position, size), {
2343
- fillColor,
2344
- strokeColor,
2345
- strokeWidth,
2346
- enclosed: true
2347
- });
2292
+ key: "setCirclePxRaius",
2293
+ value: function setCirclePxRaius(crs) {
2294
+ if (this.circle && this.pathStyles) {
2295
+ var _this$circle;
2296
+
2297
+ this.pathStyles.radius = metersToPixels(this.circle.radius, {
2298
+ painter: this.circle.painter,
2299
+ crs
2300
+ }) + (((_this$circle = this.circle) == null ? void 0 : _this$circle.pxOffset) || 0);
2301
+ }
2348
2302
  }
2349
2303
  }, {
2350
- key: "getArcs",
2351
- value: function getArcs(position, params) {
2352
- const shadowRender = ShadowedPointSymbol.getShadowArc(position, params);
2353
- const pointRender = ShadowedPointSymbol.getPointArc(position, params);
2354
- return shadowRender ? [shadowRender, pointRender] : [pointRender];
2355
- }
2356
- }]);
2304
+ key: "update",
2305
+ value: function update(_ref) {
2306
+ var _this$pathStyles, _this$pathStyles2, _this$pathStyles3, _this$pathStyles4;
2357
2307
 
2358
- return ShadowedPointSymbol;
2359
- }(PointSymbol);
2360
-
2361
- let ShadowedPolySymbol = /*#__PURE__*/function (_PolylineSymbol) {
2362
- _inherits(ShadowedPolySymbol, _PolylineSymbol);
2363
-
2364
- var _super = /*#__PURE__*/_createSuper(ShadowedPolySymbol);
2365
-
2366
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2367
- function ShadowedPolySymbol(options) {
2368
- _classCallCheck(this, ShadowedPolySymbol);
2308
+ let {
2309
+ bbox,
2310
+ resolution,
2311
+ feature,
2312
+ crs
2313
+ } = _ref;
2314
+ if (!feature) return;
2315
+ if (!bbox) bbox = feature.__lastBbox;
2316
+ if (!resolution) resolution = feature.__lastResolution;
2317
+ if (!bbox || !resolution || !feature.crs.canProjectTo(bbox.crs)) return;
2369
2318
 
2370
- return _super.call(this, options);
2371
- }
2319
+ if (feature.__lastResolution && resolution !== feature.__lastResolution) {
2320
+ const newCoordinates = feature instanceof Poly ? PolylineSymbol.getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
2321
+ this.setCirclePxRaius(crs);
2322
+ this.container.innerHTML = '';
2323
+ const svg = this.setSvg(newCoordinates);
2324
+ svg && this.container.append(svg);
2325
+ }
2372
2326
 
2373
- _createClass(ShadowedPolySymbol, [{
2374
- key: "renderFunction",
2375
- value: function renderFunction(feature, resolution, crs) {
2376
- if (!(feature instanceof Poly)) return [];
2377
- const coordinates = PolylineSymbol.getRenderedCoordinates(feature, resolution, crs);
2378
- const polyRender = this.getPolyRender(coordinates, feature);
2379
- const shadowRender = this.getShadow(coordinates, feature);
2380
- const vertexRenders = this.getVertexRenders(coordinates);
2381
- let renders = [polyRender];
2327
+ const polygon = feature.projectTo(bbox.crs);
2328
+ 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;
2329
+ const dx = Math.round((polygon.bbox.xMin - bbox.xMin) / resolution) - radiusOffset;
2330
+ const dy = Math.round((bbox.yMax - polygon.bbox.yMax) / resolution) - radiusOffset;
2331
+ this.container.style.left = dx.toString() + "px";
2332
+ this.container.style.top = dy.toString() + "px";
2333
+ feature.__lastBbox = bbox;
2334
+ feature.__lastResolution = resolution;
2335
+ }
2336
+ }, {
2337
+ key: "setSvg",
2338
+ value: function setSvg(coordinates) {
2339
+ const {
2340
+ lineCap,
2341
+ lineJoin,
2342
+ miterLimit,
2343
+ lineDash,
2344
+ dashOffset
2345
+ } = this.pathStyles || {};
2346
+ const svgRender = new SvgRender(_extends({
2347
+ coordinates
2348
+ }, defaultPathStyles, {
2349
+ appendToSvg: this.appendToSvg
2350
+ }, this.pathStyles));
2382
2351
 
2383
- if (shadowRender) {
2384
- renders = [shadowRender, polyRender];
2352
+ if (this.circle) {
2353
+ svgRender._setArcNode();
2354
+ } else {
2355
+ svgRender._setPolyNode();
2385
2356
  }
2386
2357
 
2387
- if (vertexRenders) {
2388
- renders = renders.concat(vertexRenders);
2389
- }
2358
+ let svgElement;
2359
+ svgRender.getNode((_, svg) => {
2360
+ svgElement = svg;
2361
+ this.className && svgElement.classList.add(this.className);
2362
+ const path = svgElement && svgElement.querySelector(this.circle ? 'circle' : 'path');
2390
2363
 
2391
- return renders;
2392
- }
2393
- }, {
2394
- key: "getShadow",
2395
- value: function getShadow(coordinates, _feature) {
2396
- return new PolyRender(coordinates, {
2397
- fillStyle: FillStyle.None,
2398
- enclosed: this.enclose,
2399
- strokeColor: this.shadowColor,
2400
- strokeWidth: this.shadowSize,
2401
- lineDash: this.lineDash
2364
+ if (path) {
2365
+ path.setAttribute('stroke-linecap', lineCap || 'round');
2366
+ path.setAttribute('stroke-linejoin', lineJoin || 'round');
2367
+ path.setAttribute('stroke-miterlimit', (miterLimit || 10).toString());
2368
+ path.setAttribute('stroke-dashoffset', (dashOffset || 0).toString());
2369
+
2370
+ if (this.circle) {
2371
+ path.setAttribute('stroke-dasharray', lineDash && lineDash.length > 0 ? lineDash.join(',') : '');
2372
+ }
2373
+ }
2402
2374
  });
2375
+ return svgElement;
2403
2376
  }
2404
2377
  }, {
2405
- key: "getPolyRender",
2406
- value: function getPolyRender(coordinates, _feature) {
2407
- return new PolyRender(coordinates, {
2408
- fillStyle: this.enclose ? FillStyle.Color : FillStyle.None,
2409
- enclosed: this.enclose,
2410
- fillColor: this.fillColor,
2411
- strokeColor: this.strokeColor,
2412
- strokeWidth: this.strokeWidth,
2413
- lineDash: this.lineDash
2378
+ key: "_setEventListeners",
2379
+ value: function _setEventListeners(dynamicFeature) {
2380
+ var _dynamicFeature$__dyn;
2381
+
2382
+ if (dynamicFeature.eventFlags === MouseEventFlags.None) return;
2383
+ const svgNode = dynamicFeature == null ? void 0 : (_dynamicFeature$__dyn = dynamicFeature.__dynamicSymbolRender) == null ? void 0 : _dynamicFeature$__dyn.node.querySelector(this.circle ? 'circle' : 'path');
2384
+ Object.keys(mouseEvents).forEach(eventName => {
2385
+ if (dynamicFeature.eventFlags & mouseEvents[eventName].flag) {
2386
+ listenDomEvent(svgNode, mouseEvents[eventName].type, event => {
2387
+ dynamicFeature.fire(mouseEvents[eventName].type, {
2388
+ node: svgNode,
2389
+ browserEvent: event
2390
+ });
2391
+ });
2392
+ }
2414
2393
  });
2415
2394
  }
2416
- }, {
2417
- key: "getVertexRenders",
2418
- value: function getVertexRenders(coordinates) {
2419
- if (!this.showVertex) return;
2420
- const vertexCoordinates = coordinates.reduce((acc, curr) => {
2421
- return acc.concat(curr);
2422
- }, []);
2423
- return vertexCoordinates.map(coord => getEditorPointRenderer(coord, {
2424
- size: 6,
2425
- strokeWidth: 2,
2426
- shadowColor: this.shadowColor,
2427
- strokeColor: this.strokeColor,
2428
- shadowSize: this.vertexShadowSize !== undefined ? this.vertexShadowSize : 2,
2429
- fillColor: '#ffffff'
2430
- })).reduce((acc, curr) => acc.concat(curr), []);
2431
- }
2432
2395
  }]);
2433
2396
 
2434
- return ShadowedPolySymbol;
2435
- }(PolylineSymbol);
2436
- const polySymbolParams = {
2437
- strokeWidth: 2,
2438
- strokeColor: '#e33600',
2439
- shadowSize: 8,
2440
- shadowColor: 'rgba(227, 54, 0, 0.3)'
2397
+ return SVGPoly;
2398
+ }(Symbol$1);
2399
+
2400
+ function isSGisPointSymbol(symbol) {
2401
+ return symbol instanceof PointSymbol || symbol instanceof StaticImageSymbol || symbol instanceof SquareSymbol || symbol instanceof MaskedImage;
2402
+ }
2403
+ function isSGisImageSymbol(symbol) {
2404
+ return symbol instanceof StaticImageSymbol || symbol instanceof MaskedImage;
2405
+ }
2406
+ function isSGisPolygonSymbol(symbol) {
2407
+ return symbol instanceof PolygonSymbol || symbol instanceof BrushFill || symbol instanceof ImageFill;
2408
+ }
2409
+ function isSGisPolylineSymbol(symbol) {
2410
+ return symbol instanceof PolylineSymbol;
2411
+ }
2412
+
2413
+ /**
2414
+ * Моки фич для отображения превью символа
2415
+ * http://cf.everpoint.ru/pages/viewpage.action?pageId=45024217
2416
+ */
2417
+
2418
+ const viewBoxSize = 100;
2419
+ const pointFeature = /*#__PURE__*/new PointFeature([50, -50], {
2420
+ crs: plain
2421
+ });
2422
+ const lineFeature = /*#__PURE__*/new Polyline([[0, -57], [26, -57], [40, -35], [60, -65], [74, -43], [100, -43]], {
2423
+ crs: plain
2424
+ });
2425
+ const polygonFeature = /*#__PURE__*/new Polygon([[50, -15], [80, -33], [80, -67], [50, -85], [20, -67], [20, -33], [50, -15]], {
2426
+ crs: plain
2427
+ });
2428
+ const lineLegendFeature = /*#__PURE__*/new Polyline([[0, -50], [100, -50]], {
2429
+ crs: plain
2430
+ });
2431
+ const polygonLegendFeature = /*#__PURE__*/new Polygon([[0, 0], [100, 0], [100, -100], [0, -100]], {
2432
+ crs: plain
2433
+ });
2434
+ const polygonMapLegendFeature = /*#__PURE__*/new Polygon([[50, 0], [100, -25], [100, -75], [50, -100], [0, -75], [0, -25]], {
2435
+ crs: plain
2436
+ });
2437
+ const MAP_LEGEND_FEATURES = {
2438
+ polygon: polygonMapLegendFeature
2441
2439
  };
2442
- const measureSymbolParams = {
2443
- strokeColor: '#ff6933',
2444
- shadowSize: 0,
2445
- vertexShadowSize: 0
2440
+ const LEGEND_FEATURES = {
2441
+ polyline: lineLegendFeature,
2442
+ polygon: polygonLegendFeature
2446
2443
  };
2447
- const measureLengthSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
2448
- enclose: false,
2449
- showVertex: true
2450
- }));
2451
- const measureAreaSymbol = /*#__PURE__*/new ShadowedPolySymbol( /*#__PURE__*/_extends({}, polySymbolParams, measureSymbolParams, {
2452
- fillColor: 'rgba(255, 105, 51, 0.25)',
2453
- enclose: true,
2454
- showVertex: true
2455
- }));
2456
- const snapSymbolParams = {
2457
- size: 10,
2458
- strokeWidth: 2,
2459
- strokeColor: '#e33600',
2460
- fillColor: '#ffffff',
2461
- shadowColor: 'rgba(227, 54, 0, 0.3)',
2462
- shadowSize: 3
2444
+ const MOCK_FEATURES = {
2445
+ point: pointFeature,
2446
+ polyline: lineFeature,
2447
+ polygon: polygonFeature
2463
2448
  };
2464
- const measurePolygonSnapSymbol = /*#__PURE__*/new ShadowedPointSymbol( /*#__PURE__*/_extends({}, snapSymbolParams, {
2465
- strokeColor: '#ff6933',
2466
- shadowSize: 0
2467
- }));
2468
2449
 
2469
- let SelectedPointSymbol = /*#__PURE__*/function (_ShadowedPointSymbol) {
2470
- _inherits(SelectedPointSymbol, _ShadowedPointSymbol);
2450
+ function getSymbolRenders(symbol, size, features) {
2451
+ if (size === void 0) {
2452
+ size = viewBoxSize;
2453
+ }
2471
2454
 
2472
- var _super = /*#__PURE__*/_createSuper(SelectedPointSymbol);
2455
+ if (features === void 0) {
2456
+ features = {};
2457
+ }
2473
2458
 
2474
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2475
- function SelectedPointSymbol(props) {
2476
- _classCallCheck(this, SelectedPointSymbol);
2459
+ const resolution = viewBoxSize / size;
2477
2460
 
2478
- return _super.call(this, props);
2461
+ const featuresToRender = _extends({}, MOCK_FEATURES, features);
2462
+
2463
+ if (isSGisPolygonSymbol(symbol)) {
2464
+ return symbol.renderFunctionAsync(featuresToRender.polygon, resolution, plain);
2479
2465
  }
2480
2466
 
2481
- _createClass(SelectedPointSymbol, [{
2482
- key: "getShadow",
2483
- value: function getShadow(position, feature) {
2484
- if (feature.isSelected) {
2485
- return _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getShadow", this).call(this, position, feature);
2486
- }
2487
- }
2488
- }, {
2489
- key: "getPoint",
2490
- value: function getPoint(position, feature) {
2491
- const pointRender = _get(_getPrototypeOf(SelectedPointSymbol.prototype), "getPoint", this).call(this, position, feature);
2467
+ if (isSGisPolylineSymbol(symbol)) {
2468
+ return symbol.renderFunctionAsync(featuresToRender.polyline, resolution, plain);
2469
+ }
2492
2470
 
2493
- if (feature.isSelected) {
2494
- pointRender.strokeColor = this.selectedStrokeColor;
2495
- pointRender.fillColor = this.selectedFillColor;
2496
- }
2471
+ return symbol.renderFunctionAsync(featuresToRender.point, resolution, plain);
2472
+ }
2473
+ const getMapLegendSymbolRenders = function getMapLegendSymbolRenders(symbol, size) {
2474
+ if (size === void 0) {
2475
+ size = viewBoxSize;
2476
+ }
2497
2477
 
2498
- return pointRender;
2499
- }
2500
- }]);
2478
+ return getSymbolRenders(symbol, size, MAP_LEGEND_FEATURES);
2479
+ };
2480
+ const getLegendSymbolRenders = function getLegendSymbolRenders(symbol, size) {
2481
+ if (size === void 0) {
2482
+ size = viewBoxSize;
2483
+ }
2501
2484
 
2502
- return SelectedPointSymbol;
2503
- }(ShadowedPointSymbol);
2485
+ return getSymbolRenders(symbol, size, LEGEND_FEATURES);
2486
+ };
2504
2487
 
2505
- let SelectedPolySymbol = /*#__PURE__*/function (_ShadowedPolySymbol) {
2506
- _inherits(SelectedPolySymbol, _ShadowedPolySymbol);
2488
+ function renderSymbolToCanvas(renders, canvas) {
2489
+ renders.forEach(render => {
2490
+ canvas.draw(render);
2491
+ });
2492
+ }
2507
2493
 
2508
- var _super = /*#__PURE__*/_createSuper(SelectedPolySymbol);
2494
+ function deserializeSymbol(symbol) {
2495
+ switch (symbol.type) {
2496
+ case 'circlePointSymbol':
2497
+ return deserializePointSymbol(symbol);
2509
2498
 
2510
- // eslint-disable-next-line @typescript-eslint/no-useless-constructor
2511
- function SelectedPolySymbol(props) {
2512
- _classCallCheck(this, SelectedPolySymbol);
2499
+ case 'squarePointSymbol':
2500
+ return deserializeSquareSymbol(symbol);
2513
2501
 
2514
- return _super.call(this, props);
2515
- }
2502
+ case 'maskedImagePointSymbol':
2503
+ return deserializeMaskedImageSymbol(symbol);
2516
2504
 
2517
- _createClass(SelectedPolySymbol, [{
2518
- key: "getShadow",
2519
- value: function getShadow(coordinates, feature) {
2520
- if (feature.isSelected) {
2521
- return _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getShadow", this).call(this, coordinates, feature);
2522
- }
2523
- }
2524
- }, {
2525
- key: "getPolyRender",
2526
- value: function getPolyRender(coordinates, feature) {
2527
- const polyRender = _get(_getPrototypeOf(SelectedPolySymbol.prototype), "getPolyRender", this).call(this, coordinates, feature);
2505
+ case 'imagePointSymbol':
2506
+ return deserializeImagePointSymbol(symbol);
2528
2507
 
2529
- if (feature.isSelected) {
2530
- polyRender.fillColor = this.selectedFillColor;
2531
- polyRender.strokeColor = this.selectedStrokeColor;
2508
+ case 'polygonSymbol':
2509
+ return deserializePolygonSymbol(symbol);
2532
2510
 
2533
- if (this.selectedStrokeWidth !== void 0) {
2534
- polyRender.strokeWidth = this.selectedStrokeWidth;
2535
- }
2536
- }
2511
+ case 'simplePolylineSymbol':
2512
+ case 'polylineSymbol':
2513
+ return deserializePolylineSymbol(symbol);
2537
2514
 
2538
- return polyRender;
2539
- }
2540
- }]);
2515
+ default:
2516
+ return null;
2517
+ }
2518
+ }
2541
2519
 
2542
- return SelectedPolySymbol;
2543
- }(ShadowedPolySymbol);
2520
+ function deserializePointSymbol(symbol) {
2521
+ // @ts-ignore
2522
+ return new PointSymbol(deserializePointSymbolParams(symbol));
2523
+ }
2544
2524
 
2545
- const selectedPoint = /*#__PURE__*/new SelectedPointSymbol({
2546
- size: 8,
2547
- strokeWidth: 2,
2548
- strokeColor: 'rgba(255, 87, 34, 0.3)',
2549
- fillColor: 'rgba(255, 255, 255, 0.65)',
2550
- shadowColor: 'rgba(255, 87, 34, 0.3)',
2551
- shadowSize: 3,
2552
- selectedStrokeColor: '#ff5722',
2553
- selectedFillColor: 'rgba(255, 255, 255, 0.65)'
2554
- });
2555
- const selectedPolyline = /*#__PURE__*/new SelectedPolySymbol({
2556
- strokeWidth: 6,
2557
- strokeColor: 'rgba(255, 87, 34, 0.2)',
2558
- shadowSize: 8,
2559
- shadowColor: 'rgba(255, 87, 34, 0.3)',
2560
- selectedStrokeColor: '#ff5722',
2561
- selectedStrokeWidth: 2
2562
- });
2563
- const selectedPolygon = /*#__PURE__*/new SelectedPolySymbol({
2564
- strokeWidth: 2,
2565
- strokeColor: 'rgba(255, 87, 34, 0.3)',
2566
- shadowSize: 8,
2567
- shadowColor: 'rgba(255, 87, 34, 0.3)',
2568
- fillColor: 'rgba(255, 255, 255, 0.36)',
2569
- enclose: true,
2570
- selectedFillColor: 'rgba(255, 255, 255, 0.56)',
2571
- selectedStrokeColor: '#ff5722'
2572
- });
2525
+ function deserializeSquareSymbol(symbol) {
2526
+ return new SquareSymbol(_extends({}, deserializePointSymbolParams(symbol), {
2527
+ // @ts-ignore
2528
+ angle: getParameterValue(symbol.angle)
2529
+ }));
2530
+ }
2573
2531
 
2574
- const defaultPathStyles = {
2575
- strokeWidth: 2,
2576
- strokeColor: 'rgb(0, 163, 245)',
2577
- fillStyle: FillStyle.None
2578
- };
2579
- let SVGPoly = /*#__PURE__*/function (_Symbol) {
2580
- _inherits(SVGPoly, _Symbol);
2532
+ function deserializeMaskedImageSymbol(symbol) {
2533
+ return new MaskedImage(_extends({}, symbol, {
2534
+ // @ts-ignore
2535
+ angle: getParameterValue(symbol.angle),
2536
+ // @ts-ignore
2537
+ width: getParameterValue(symbol.width),
2538
+ // @ts-ignore
2539
+ height: getParameterValue(symbol.height),
2540
+ // @ts-ignore
2541
+ anchorPoint: deserializeAnchor(symbol.offset),
2542
+ // @ts-ignore
2543
+ imageSource: deserializeBase64(symbol.image),
2544
+ // @ts-ignore
2545
+ maskSource: deserializeBase64(symbol.imageMask),
2546
+ // @ts-ignore
2547
+ maskColor: deserializeColor(getParameterValue(symbol.maskedColor))
2548
+ }));
2549
+ }
2581
2550
 
2582
- var _super = /*#__PURE__*/_createSuper(SVGPoly);
2551
+ function deserializeImagePointSymbol(symbol) {
2552
+ return new StaticImageSymbol(_extends({}, symbol, {
2553
+ // @ts-ignore
2554
+ angle: getParameterValue(symbol.angle),
2555
+ // @ts-ignore
2556
+ width: getParameterValue(symbol.width),
2557
+ // @ts-ignore
2558
+ height: getParameterValue(symbol.height),
2559
+ // @ts-ignore
2560
+ anchorPoint: deserializeAnchor(symbol.offset),
2561
+ // @ts-ignore
2562
+ source: deserializeBase64(symbol.image)
2563
+ }));
2564
+ }
2583
2565
 
2584
- function SVGPoly(_temp) {
2585
- var _this;
2566
+ function deserializePolygonSymbol(symbol) {
2567
+ if (isPolygonHasPatternBrush(symbol)) {
2568
+ return new SGisImageFill(symbol);
2569
+ }
2586
2570
 
2587
- let {
2588
- redrawFeatureNode,
2589
- pathStyles,
2590
- circle,
2591
- className,
2592
- appendToSvg
2593
- } = _temp === void 0 ? {} : _temp;
2571
+ if (isPolygonHasHatchBrush(symbol)) {
2572
+ return new SGisBrushFill(symbol);
2573
+ }
2594
2574
 
2595
- _classCallCheck(this, SVGPoly);
2575
+ return new SGisPolygonSymbol(symbol);
2576
+ }
2596
2577
 
2597
- _this = _super.call(this);
2598
- _this.container = document.createElement('div');
2599
- _this.container.style.position = 'absolute';
2600
- _this.redrawFeatureNode = redrawFeatureNode;
2601
- _this.pathStyles = _extends({
2602
- center: [0, 0],
2603
- fillColor: 'none'
2604
- }, pathStyles);
2605
- _this.circle = circle;
2606
- _this.className = className;
2607
- _this.appendToSvg = appendToSvg;
2608
- return _this;
2609
- }
2578
+ function deserializePolylineSymbol(symbol) {
2579
+ return new SGisPolylineSymbol(symbol);
2580
+ }
2610
2581
 
2611
- _createClass(SVGPoly, [{
2612
- key: "renderFunction",
2613
- value: function renderFunction(feature, resolution, crs) {
2614
- const coordinates = feature instanceof Poly ? PolylineSymbol.getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
2615
- this.setCirclePxRaius(crs);
2616
- this.container.innerHTML = '';
2617
- const svg = this.setSvg(coordinates);
2618
- svg && this.container.append(svg);
2619
- feature.__dynamicSymbolRender = new DynamicRender({
2620
- node: this.container,
2621
- update: (bbox, resolution) => this.update({
2622
- bbox,
2623
- resolution,
2624
- feature,
2625
- crs
2626
- }),
2627
- redraw: () => {
2628
- this.redrawFeatureNode && this.redrawFeatureNode(feature);
2629
- }
2630
- });
2582
+ function deserializePointSymbolParams(_ref) {
2583
+ let {
2584
+ size,
2585
+ offset,
2586
+ strokeColor,
2587
+ strokeWidth,
2588
+ fillColor
2589
+ } = _ref;
2590
+ return {
2591
+ size: getParameterValue(size),
2592
+ offset: deserializeAnchor(offset),
2593
+ strokeWidth: getParameterValue(strokeWidth),
2594
+ strokeColor: deserializeColor(getParameterValue(strokeColor)),
2595
+ fillColor: deserializeColor(getParameterValue(fillColor))
2596
+ };
2597
+ }
2631
2598
 
2632
- this._setEventListeners(feature);
2599
+ function deserializeBase64(base) {
2600
+ return "data:image/png;base64," + base;
2601
+ }
2633
2602
 
2634
- return [feature.__dynamicSymbolRender];
2635
- }
2636
- }, {
2637
- key: "setCirclePxRaius",
2638
- value: function setCirclePxRaius(crs) {
2639
- if (this.circle && this.pathStyles) {
2640
- var _this$circle;
2603
+ function deserializeAnchor(offset) {
2604
+ // @ts-ignore
2605
+ return offset.map(getParameterValue);
2606
+ }
2641
2607
 
2642
- this.pathStyles.radius = metersToPixels(this.circle.radius, {
2643
- painter: this.circle.painter,
2644
- crs
2645
- }) + (((_this$circle = this.circle) == null ? void 0 : _this$circle.pxOffset) || 0);
2646
- }
2647
- }
2648
- }, {
2649
- key: "update",
2650
- value: function update(_ref) {
2651
- var _this$pathStyles, _this$pathStyles2, _this$pathStyles3, _this$pathStyles4;
2608
+ function deserializeColor(color) {
2609
+ return color ? new Color(color).toString() : null;
2610
+ }
2652
2611
 
2653
- let {
2654
- bbox,
2655
- resolution,
2656
- feature,
2657
- crs
2658
- } = _ref;
2659
- if (!feature) return;
2660
- if (!bbox) bbox = feature.__lastBbox;
2661
- if (!resolution) resolution = feature.__lastResolution;
2662
- if (!bbox || !resolution || !feature.crs.canProjectTo(bbox.crs)) return;
2612
+ const clampSymbol = (symbol, min, max) => {
2613
+ if (isSGisImageSymbol(symbol)) {
2614
+ symbol.width = clamp(symbol.width, min, max);
2615
+ symbol.height = clamp(symbol.height, min, max);
2616
+ } else if (isSGisPointSymbol(symbol)) {
2617
+ symbol.size = clamp(symbol.size, min, max);
2618
+ }
2663
2619
 
2664
- if (feature.__lastResolution && resolution !== feature.__lastResolution) {
2665
- const newCoordinates = feature instanceof Poly ? PolylineSymbol.getRenderedCoordinates(feature, resolution, crs) : feature.centroid;
2666
- this.setCirclePxRaius(crs);
2667
- this.container.innerHTML = '';
2668
- const svg = this.setSvg(newCoordinates);
2669
- svg && this.container.append(svg);
2670
- }
2620
+ return symbol;
2621
+ };
2622
+ function centerAlignSymbol(symbol) {
2623
+ if (isSGisImageSymbol(symbol)) {
2624
+ symbol.anchorPoint = [symbol.width / 2, symbol.height / 2];
2625
+ } else if (isSGisPointSymbol(symbol)) {
2626
+ symbol.offset = [0, 0];
2627
+ }
2671
2628
 
2672
- const polygon = feature.projectTo(bbox.crs);
2673
- 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;
2674
- const dx = Math.round((polygon.bbox.xMin - bbox.xMin) / resolution) - radiusOffset;
2675
- const dy = Math.round((bbox.yMax - polygon.bbox.yMax) / resolution) - radiusOffset;
2676
- this.container.style.left = dx.toString() + "px";
2677
- this.container.style.top = dy.toString() + "px";
2678
- feature.__lastBbox = bbox;
2679
- feature.__lastResolution = resolution;
2680
- }
2681
- }, {
2682
- key: "setSvg",
2683
- value: function setSvg(coordinates) {
2684
- const {
2685
- lineCap,
2686
- lineJoin,
2687
- miterLimit,
2688
- lineDash,
2689
- dashOffset
2690
- } = this.pathStyles || {};
2691
- const svgRender = new SvgRender(_extends({
2692
- coordinates
2693
- }, defaultPathStyles, {
2694
- appendToSvg: this.appendToSvg
2695
- }, this.pathStyles));
2629
+ return symbol;
2630
+ }
2631
+ const adjustSymbol = (symbol, _ref) => {
2632
+ let {
2633
+ size
2634
+ } = _ref;
2635
+ return centerAlignSymbol(clampSymbol(symbol, 0, size));
2636
+ };
2696
2637
 
2697
- if (this.circle) {
2698
- svgRender._setArcNode();
2699
- } else {
2700
- svgRender._setPolyNode();
2701
- }
2638
+ let EvergisFeature = /*#__PURE__*/function () {
2639
+ function EvergisFeature(feature) {
2640
+ _classCallCheck(this, EvergisFeature);
2702
2641
 
2703
- let svgElement;
2704
- svgRender.getNode((_, svg) => {
2705
- svgElement = svg;
2706
- this.className && svgElement.classList.add(this.className);
2707
- const path = svgElement && svgElement.querySelector(this.circle ? 'circle' : 'path');
2642
+ this.id = null;
2643
+ this.displayName = null;
2644
+ this.geometry = null;
2645
+ this.layerName = null;
2646
+ this.layerAlias = null;
2647
+ this.attributes = null;
2648
+ this.symbol = null;
2649
+ this.id = feature.id;
2650
+ this.displayName = feature.id;
2651
+ this.geometry = feature.geometry;
2652
+ this.layerName = feature.layer;
2653
+ this.layerAlias = feature.layer;
2654
+ this.attributes = getFeatureAttributes(feature.attributes);
2655
+ }
2708
2656
 
2709
- if (path) {
2710
- path.setAttribute('stroke-linecap', lineCap || 'round');
2711
- path.setAttribute('stroke-linejoin', lineJoin || 'round');
2712
- path.setAttribute('stroke-miterlimit', (miterLimit || 10).toString());
2713
- path.setAttribute('stroke-dashoffset', (dashOffset || 0).toString());
2657
+ _createClass(EvergisFeature, [{
2658
+ key: "sGisFeature",
2659
+ value: function sGisFeature() {
2660
+ if (!this.geometry || !this.symbol) {
2661
+ return null;
2662
+ } // @ts-ignore
2714
2663
 
2715
- if (this.circle) {
2716
- path.setAttribute('stroke-dasharray', lineDash && lineDash.length > 0 ? lineDash.join(',') : '');
2717
- }
2718
- }
2719
- });
2720
- return svgElement;
2721
- }
2722
- }, {
2723
- key: "_setEventListeners",
2724
- value: function _setEventListeners(dynamicFeature) {
2725
- var _dynamicFeature$__dyn;
2726
2664
 
2727
- if (dynamicFeature.eventFlags === MouseEventFlags.None) return;
2728
- const svgNode = dynamicFeature == null ? void 0 : (_dynamicFeature$__dyn = dynamicFeature.__dynamicSymbolRender) == null ? void 0 : _dynamicFeature$__dyn.node.querySelector(this.circle ? 'circle' : 'path');
2729
- Object.keys(mouseEvents).forEach(eventName => {
2730
- if (dynamicFeature.eventFlags & mouseEvents[eventName].flag) {
2731
- listenDomEvent(svgNode, mouseEvents[eventName].type, event => {
2732
- dynamicFeature.fire(mouseEvents[eventName].type, {
2733
- node: svgNode,
2734
- browserEvent: event
2735
- });
2736
- });
2737
- }
2738
- });
2739
- }
2740
- }]);
2665
+ const {
2666
+ type,
2667
+ coordinates,
2668
+ sr
2669
+ } = this.geometry;
2670
+ const crs = CRS_MAP[sr];
2741
2671
 
2742
- return SVGPoly;
2743
- }(Symbol$1);
2672
+ if (!crs) {
2673
+ return null;
2674
+ }
2744
2675
 
2745
- function isSGisPointSymbol(symbol) {
2746
- return symbol instanceof PointSymbol || symbol instanceof StaticImageSymbol || symbol instanceof SquareSymbol || symbol instanceof MaskedImage;
2747
- }
2748
- function isSGisImageSymbol(symbol) {
2749
- return symbol instanceof StaticImageSymbol || symbol instanceof MaskedImage;
2750
- }
2751
- function isSGisPolygonSymbol(symbol) {
2752
- return symbol instanceof PolygonSymbol || symbol instanceof BrushFill || symbol instanceof ImageFill;
2753
- }
2754
- function isSGisPolylineSymbol(symbol) {
2755
- return symbol instanceof PolylineSymbol;
2756
- }
2676
+ switch (type) {
2677
+ case GeometryType.Point:
2678
+ return new PointFeature(coordinates, {
2679
+ symbol: selectedPoint,
2680
+ crs
2681
+ });
2757
2682
 
2758
- /**
2759
- * Моки фич для отображения превью символа
2760
- * http://cf.everpoint.ru/pages/viewpage.action?pageId=45024217
2761
- */
2683
+ case GeometryType.Multipoint:
2684
+ return new MultiPoint(coordinates, {
2685
+ symbol: selectedPoint,
2686
+ crs
2687
+ });
2762
2688
 
2763
- const viewBoxSize = 100;
2764
- const pointFeature = /*#__PURE__*/new PointFeature([50, -50], {
2765
- crs: plain
2766
- });
2767
- const lineFeature = /*#__PURE__*/new Polyline([[0, -57], [26, -57], [40, -35], [60, -65], [74, -43], [100, -43]], {
2768
- crs: plain
2769
- });
2770
- const polygonFeature = /*#__PURE__*/new Polygon([[50, -15], [80, -33], [80, -67], [50, -85], [20, -67], [20, -33], [50, -15]], {
2771
- crs: plain
2772
- });
2773
- const lineLegendFeature = /*#__PURE__*/new Polyline([[0, -50], [100, -50]], {
2774
- crs: plain
2775
- });
2776
- const polygonLegendFeature = /*#__PURE__*/new Polygon([[0, 0], [100, 0], [100, -100], [0, -100]], {
2777
- crs: plain
2778
- });
2779
- const polygonMapLegendFeature = /*#__PURE__*/new Polygon([[50, 0], [100, -25], [100, -75], [50, -100], [0, -75], [0, -25]], {
2780
- crs: plain
2781
- });
2782
- const MAP_LEGEND_FEATURES = {
2783
- polygon: polygonMapLegendFeature
2784
- };
2785
- const LEGEND_FEATURES = {
2786
- polyline: lineLegendFeature,
2787
- polygon: polygonLegendFeature
2788
- };
2789
- const MOCK_FEATURES = {
2790
- point: pointFeature,
2791
- polyline: lineFeature,
2792
- polygon: polygonFeature
2793
- };
2689
+ case GeometryType.Polyline:
2690
+ return new Polyline(coordinates, {
2691
+ symbol: selectedPolyline,
2692
+ crs
2693
+ });
2794
2694
 
2795
- function getSymbolRenders(symbol, size, features) {
2796
- if (size === void 0) {
2797
- size = viewBoxSize;
2798
- }
2695
+ case GeometryType.Polygon:
2696
+ return new Polygon(coordinates, {
2697
+ symbol: selectedPolygon,
2698
+ crs
2699
+ });
2799
2700
 
2800
- if (features === void 0) {
2801
- features = {};
2802
- }
2701
+ default:
2702
+ return null;
2703
+ }
2704
+ }
2705
+ }, {
2706
+ key: "extent",
2707
+ value: function extent() {
2708
+ const feature = this.sGisFeature();
2709
+ return feature && feature.bbox;
2710
+ }
2711
+ }]);
2803
2712
 
2804
- const resolution = viewBoxSize / size;
2713
+ return EvergisFeature;
2714
+ }();
2805
2715
 
2806
- const featuresToRender = _extends({}, MOCK_FEATURES, features);
2716
+ function evaluateCondition(condition, attributes) {
2717
+ try {
2718
+ const evaluator = new ConditionEvaluator(attributes);
2719
+ const result = evaluator.evaluate(condition);
2807
2720
 
2808
- if (isSGisPolygonSymbol(symbol)) {
2809
- return symbol.renderFunctionAsync(featuresToRender.polygon, resolution, plain);
2810
- }
2721
+ if (result instanceof Error) {
2722
+ return null;
2723
+ }
2811
2724
 
2812
- if (isSGisPolylineSymbol(symbol)) {
2813
- return symbol.renderFunctionAsync(featuresToRender.polyline, resolution, plain);
2725
+ return result;
2726
+ } catch (_unused) {
2727
+ return null;
2814
2728
  }
2729
+ }
2815
2730
 
2816
- return symbol.renderFunctionAsync(featuresToRender.point, resolution, plain);
2731
+ function getAttributeValue(attributes, attributeName) {
2732
+ const attributeMeta = attributes.find((_ref) => {
2733
+ let {
2734
+ name
2735
+ } = _ref;
2736
+ return name === attributeName;
2737
+ });
2738
+ return attributeMeta ? attributeMeta.value : null;
2817
2739
  }
2818
- const getMapLegendSymbolRenders = function getMapLegendSymbolRenders(symbol, size) {
2819
- if (size === void 0) {
2820
- size = viewBoxSize;
2821
- }
2822
2740
 
2823
- return getSymbolRenders(symbol, size, MAP_LEGEND_FEATURES);
2824
- };
2825
- const getLegendSymbolRenders = function getLegendSymbolRenders(symbol, size) {
2826
- if (size === void 0) {
2827
- size = viewBoxSize;
2828
- }
2741
+ const getAttributeNameFromCondition = condition => new ClassificationCondition(condition).attributeName;
2742
+ const getAttributeNameFromClassified = values => values.length > 0 ? getAttributeNameFromCondition(values[0].condition) : null;
2829
2743
 
2830
- return getSymbolRenders(symbol, size, LEGEND_FEATURES);
2831
- };
2744
+ function findFeatureValue(parameterValues, _ref2) {
2745
+ let [name, value] = _ref2;
2746
+ return value !== null ? parameterValues.find((_ref3) => {
2747
+ let {
2748
+ condition
2749
+ } = _ref3;
2750
+ return value !== undefined && evaluateCondition(condition, {
2751
+ [name]: value
2752
+ });
2753
+ }) : null;
2754
+ }
2832
2755
 
2833
- function renderSymbolToCanvas(renders, canvas) {
2834
- renders.forEach(render => {
2835
- canvas.draw(render);
2836
- });
2756
+ function extractValuesAttribute(parameterValues, attributes) {
2757
+ const name = getAttributeNameFromClassified(parameterValues) || '';
2758
+ const value = name && getAttributeValue(attributes, name);
2759
+ return [name, value];
2837
2760
  }
2838
2761
 
2839
- function deserializeSymbol(symbol) {
2840
- switch (symbol.type) {
2841
- case 'circlePointSymbol':
2842
- return deserializePointSymbol(symbol);
2762
+ function evaluateFeatureSymbol(attributes) {
2763
+ // @ts-ignore
2764
+ function calc(result, _ref4) {
2765
+ let [parameterName, parameterValue] = _ref4;
2766
+ let newParameterValue;
2843
2767
 
2844
- case 'squarePointSymbol':
2845
- return deserializeSquareSymbol(symbol);
2768
+ if (isParameterByAttribute(parameterValue)) {
2769
+ const [attributeName, attributeValue] = extractValuesAttribute(parameterValue.values, attributes);
2770
+ const featureValue = findFeatureValue(parameterValue.values, [attributeName, attributeValue]);
2771
+ newParameterValue = featureValue ? featureValue.value : parameterValue.defaultValue;
2772
+ } else if (isObject(parameterValue)) {
2773
+ // @ts-ignore
2774
+ newParameterValue = Object.entries(parameterValue).reduce(calc, parameterValue);
2775
+ }
2846
2776
 
2847
- case 'maskedImagePointSymbol':
2848
- return deserializeMaskedImageSymbol(symbol);
2777
+ return newParameterValue !== undefined ? _extends({}, result, {
2778
+ [parameterName]: newParameterValue
2779
+ }) : result;
2780
+ }
2849
2781
 
2850
- case 'imagePointSymbol':
2851
- return deserializeImagePointSymbol(symbol);
2782
+ return calc;
2783
+ }
2852
2784
 
2853
- case 'polygonSymbol':
2854
- return deserializePolygonSymbol(symbol);
2785
+ function findChildFeatureStyle(childStyles, attributes) {
2786
+ return (childStyles || []).find((_ref5) => {
2787
+ let {
2788
+ condition
2789
+ } = _ref5;
2790
+ const attributeName = condition && getAttributeNameFromCondition(condition);
2791
+ const attributeValue = attributeName && getAttributeValue(attributes, attributeName);
2855
2792
 
2856
- case 'simplePolylineSymbol':
2857
- case 'polylineSymbol':
2858
- return deserializePolylineSymbol(symbol);
2793
+ if (condition && attributeName && attributeValue !== undefined) {
2794
+ return evaluateCondition(condition, {
2795
+ [attributeName]: attributeValue
2796
+ });
2797
+ }
2859
2798
 
2860
- default:
2861
- return null;
2862
- }
2799
+ return false;
2800
+ }) || null;
2863
2801
  }
2864
-
2865
- function deserializePointSymbol(symbol) {
2866
- // @ts-ignore
2867
- return new PointSymbol(deserializePointSymbolParams(symbol));
2802
+ function findChildFeatureSymbol(childStyles, attributes) {
2803
+ const featureStyle = findChildFeatureStyle(childStyles, attributes);
2804
+ return featureStyle ? featureStyle.symbol : null;
2868
2805
  }
2806
+ function getFeatureSymbol(style, attributes) {
2807
+ if (!style || !style.symbol) {
2808
+ return null;
2809
+ }
2869
2810
 
2870
- function deserializeSquareSymbol(symbol) {
2871
- return new SquareSymbol(_extends({}, deserializePointSymbolParams(symbol), {
2872
- // @ts-ignore
2873
- angle: getParameterValue(symbol.angle)
2874
- }));
2875
- }
2811
+ if (style.children !== null) {
2812
+ return findChildFeatureSymbol(style.children, attributes) || style.symbol;
2813
+ }
2876
2814
 
2877
- function deserializeMaskedImageSymbol(symbol) {
2878
- return new MaskedImage(_extends({}, symbol, {
2879
- // @ts-ignore
2880
- angle: getParameterValue(symbol.angle),
2881
- // @ts-ignore
2882
- width: getParameterValue(symbol.width),
2883
- // @ts-ignore
2884
- height: getParameterValue(symbol.height),
2885
- // @ts-ignore
2886
- anchorPoint: deserializeAnchor(symbol.offset),
2887
- // @ts-ignore
2888
- imageSource: deserializeBase64(symbol.image),
2889
- // @ts-ignore
2890
- maskSource: deserializeBase64(symbol.imageMask),
2891
- // @ts-ignore
2892
- maskColor: deserializeColor(getParameterValue(symbol.maskedColor))
2893
- }));
2815
+ return Object.entries(style.symbol).reduce(evaluateFeatureSymbol(attributes), style.symbol);
2894
2816
  }
2895
2817
 
2896
- function deserializeImagePointSymbol(symbol) {
2897
- return new StaticImageSymbol(_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
- source: deserializeBase64(symbol.image)
2908
- }));
2909
- }
2818
+ let EvergisLayer = /*#__PURE__*/function () {
2819
+ function EvergisLayer(service) {
2820
+ _classCallCheck(this, EvergisLayer);
2910
2821
 
2911
- function deserializePolygonSymbol(symbol) {
2912
- if (isPolygonHasPatternBrush(symbol)) {
2913
- return new SGisImageFill(symbol);
2822
+ this.name = null;
2823
+ this.titleAttribute = null;
2824
+ this.alias = null;
2825
+ this.attributes = null;
2826
+ this.style = null;
2827
+ const evergisService = service;
2828
+ const {
2829
+ name,
2830
+ alias,
2831
+ style,
2832
+ layerDefinition
2833
+ } = evergisService;
2834
+ this.name = name;
2835
+ this.alias = alias || name;
2836
+ this.attributes = getLayerAttributes(layerDefinition);
2837
+ this.style = style && new EvergisStyle(style) || null;
2838
+ this.titleAttribute = layerDefinition && layerDefinition.titleAttribute || null;
2914
2839
  }
2915
2840
 
2916
- if (isPolygonHasHatchBrush(symbol)) {
2917
- return new SGisBrushFill(symbol);
2918
- }
2841
+ _createClass(EvergisLayer, [{
2842
+ key: "evaluateFeature",
2843
+ value: function evaluateFeature(feature) {
2844
+ feature.attributes = mergeAttributes(feature.attributes || [], this.attributes || []);
2845
+ feature.symbol = this.style && getFeatureSymbol(this.style, feature.attributes);
2846
+ feature.layerAlias = this.alias;
2847
+ const titleAttribute = (feature.attributes || []).find((_ref) => {
2848
+ let {
2849
+ name
2850
+ } = _ref;
2851
+ return name === this.titleAttribute;
2852
+ });
2853
+ const displayName = titleAttribute && formatAttributeValue(titleAttribute)[0].value || feature.id;
2854
+ feature.displayName = displayName ? "" + displayName : feature.id;
2855
+ return feature;
2856
+ }
2857
+ }]);
2919
2858
 
2920
- return new SGisPolygonSymbol(symbol);
2921
- }
2859
+ return EvergisLayer;
2860
+ }();
2922
2861
 
2923
- function deserializePolylineSymbol(symbol) {
2924
- return new SGisPolylineSymbol(symbol);
2925
- }
2862
+ const findFeatureLayer = feature => layer => layer.name === feature.layerName;
2926
2863
 
2927
- function deserializePointSymbolParams(_ref) {
2864
+ const evaluateFeature = layers => feature => {
2865
+ const featureLayer = layers.find(findFeatureLayer(feature));
2866
+ return featureLayer ? featureLayer.evaluateFeature(feature) : feature;
2867
+ };
2868
+
2869
+ const OTHERS_TITLE = 'Другое';
2870
+ const createLegendItem = (_ref) => {
2928
2871
  let {
2929
- size,
2930
- offset,
2931
- strokeColor,
2932
- strokeWidth,
2933
- fillColor
2872
+ attributes,
2873
+ renderTitle,
2874
+ skipDefaultValue,
2875
+ reverse
2934
2876
  } = _ref;
2935
- return {
2936
- size: getParameterValue(size),
2937
- offset: deserializeAnchor(offset),
2938
- strokeWidth: getParameterValue(strokeWidth),
2939
- strokeColor: deserializeColor(getParameterValue(strokeColor)),
2940
- fillColor: deserializeColor(getParameterValue(fillColor))
2877
+ return classification => {
2878
+ const {
2879
+ defaultTitle,
2880
+ defaultValue,
2881
+ values,
2882
+ attribute: attributeName,
2883
+ parameter
2884
+ } = classification;
2885
+ const attribute = attributeName && attributes ? getClassificationAttribute(attributeName, attributes) : undefined;
2886
+ const defaultLegendValue = {
2887
+ title: defaultTitle || OTHERS_TITLE,
2888
+ parameterValue: defaultValue
2889
+ };
2890
+ const legendValues = values.map((value, index) => ({
2891
+ title: renderTitle && renderTitle(_extends({}, value, {
2892
+ attribute
2893
+ }), index),
2894
+ parameterValue: value.parameterValue
2895
+ }));
2896
+ const withDefault = skipDefaultValue ? legendValues : [...legendValues, defaultLegendValue];
2897
+ const reversedValues = reverse ? [...withDefault].reverse() : withDefault;
2898
+ return {
2899
+ title: attribute && attribute.alias || attributeName,
2900
+ attribute,
2901
+ parameter,
2902
+ values: reversedValues
2903
+ };
2941
2904
  };
2942
- }
2905
+ };
2943
2906
 
2944
- function deserializeBase64(base) {
2945
- return "data:image/png;base64," + base;
2946
- }
2907
+ function createStyleLegend(style, config) {
2908
+ const {
2909
+ classificationManager,
2910
+ symbol
2911
+ } = style;
2912
+ const items = classificationManager.filter((_ref) => {
2913
+ let {
2914
+ parameter
2915
+ } = _ref;
2916
+ return config.parameters && parameter ? config.parameters.includes(parameter) : true;
2917
+ });
2947
2918
 
2948
- function deserializeAnchor(offset) {
2949
- // @ts-ignore
2950
- return offset.map(getParameterValue);
2951
- }
2919
+ if (items.length === 0) {
2920
+ return null;
2921
+ }
2952
2922
 
2953
- function deserializeColor(color) {
2954
- return color ? new Color(color).toString() : null;
2923
+ return {
2924
+ symbol: unClassify(symbol),
2925
+ items: items.map(createLegendItem(config))
2926
+ };
2955
2927
  }
2956
2928
 
2957
- const clampSymbol = (symbol, min, max) => {
2958
- if (isSGisImageSymbol(symbol)) {
2959
- symbol.width = clamp(symbol.width, min, max);
2960
- symbol.height = clamp(symbol.height, min, max);
2961
- } else if (isSGisPointSymbol(symbol)) {
2962
- symbol.size = clamp(symbol.size, min, max);
2963
- }
2929
+ function createValueTitle(value, index) {
2930
+ if (value.title) return value.title;
2931
+ if (isRangeClass(value)) return printRangeClass(value, index);
2932
+ if (isUniqueClass(value)) return value.uniqueValue;
2933
+ return '';
2934
+ }
2964
2935
 
2965
- return symbol;
2966
- };
2967
- function centerAlignSymbol(symbol) {
2968
- if (isSGisImageSymbol(symbol)) {
2969
- symbol.anchorPoint = [symbol.width / 2, symbol.height / 2];
2970
- } else if (isSGisPointSymbol(symbol)) {
2971
- symbol.offset = [0, 0];
2936
+ function formatArea(num) {
2937
+ let result = num;
2938
+ let measure = 'м²';
2939
+
2940
+ if (num >= 10000000) {
2941
+ result = num / 1000000;
2942
+ measure = 'км²';
2943
+ } else if (num >= 10000) {
2944
+ result = num / 10000;
2945
+ measure = 'га';
2972
2946
  }
2973
2947
 
2974
- return symbol;
2948
+ return numberWithSpaces(result) + " " + measure;
2975
2949
  }
2976
- const adjustSymbol = (symbol, _ref) => {
2977
- let {
2978
- size
2979
- } = _ref;
2980
- return centerAlignSymbol(clampSymbol(symbol, 0, size));
2981
- };
2950
+ function formatLength(num) {
2951
+ let result = num;
2952
+ let measure = 'м';
2982
2953
 
2983
- let EvergisFeature = /*#__PURE__*/function () {
2984
- function EvergisFeature(feature) {
2985
- _classCallCheck(this, EvergisFeature);
2954
+ if (num > 10000) {
2955
+ result = num / 1000;
2956
+ measure = 'км';
2957
+ }
2986
2958
 
2987
- this.id = null;
2988
- this.displayName = null;
2989
- this.geometry = null;
2990
- this.layerName = null;
2991
- this.layerAlias = null;
2992
- this.attributes = null;
2993
- this.symbol = null;
2994
- this.id = feature.id;
2995
- this.displayName = feature.id;
2996
- this.geometry = feature.geometry;
2997
- this.layerName = feature.layer;
2998
- this.layerAlias = feature.layer;
2999
- this.attributes = getFeatureAttributes(feature.attributes);
2959
+ return numberWithSpaces(result) + " " + measure;
2960
+ }
2961
+ function formatPolygonMeasure(area, perimiter) {
2962
+ return "S : " + formatArea(area) + " P : " + formatLength(perimiter);
2963
+ }
2964
+ function isPolylineLikePolygon(rings, resolution) {
2965
+ if (rings[0].length <= 3) {
2966
+ return false;
3000
2967
  }
3001
2968
 
3002
- _createClass(EvergisFeature, [{
3003
- key: "sGisFeature",
3004
- value: function sGisFeature() {
3005
- if (!this.geometry || !this.symbol) {
3006
- return null;
3007
- } // @ts-ignore
2969
+ const coords = rings[0];
2970
+ const firstPoint = coords[0];
2971
+ const lastPoint = coords[coords.length - 1];
2972
+ const distance = resolution * 2;
2973
+ return softEquals(firstPoint[0], lastPoint[0], distance) && softEquals(firstPoint[1], lastPoint[1], distance);
2974
+ }
3008
2975
 
2976
+ function getScale(scale) {
2977
+ const scales = [1, 2, 5];
3009
2978
 
3010
- const {
3011
- type,
3012
- coordinates,
3013
- sr
3014
- } = this.geometry;
3015
- const crs = CRS_MAP[sr];
2979
+ for (let x = 0; x < 21; x++) {
2980
+ for (let y = 0; y < scales.length; y++) {
2981
+ const result = Math.pow(10, x) * scales[y];
3016
2982
 
3017
- if (!crs) {
3018
- return null;
2983
+ if (result > scale) {
2984
+ return result;
3019
2985
  }
2986
+ }
2987
+ }
3020
2988
 
3021
- switch (type) {
3022
- case GeometryType.Point:
3023
- return new PointFeature(coordinates, {
3024
- symbol: selectedPoint,
3025
- crs
3026
- });
2989
+ return 1;
2990
+ }
3027
2991
 
3028
- case GeometryType.Multipoint:
3029
- return new MultiPoint(coordinates, {
3030
- symbol: selectedPoint,
3031
- crs
3032
- });
2992
+ const useLegend = (style, config) => useMemo(() => {
2993
+ if (!style || !(config && config.attributes)) return null;
2994
+ return createStyleLegend(style, config);
2995
+ }, [style, config]);
3033
2996
 
3034
- case GeometryType.Polyline:
3035
- return new Polyline(coordinates, {
3036
- symbol: selectedPolyline,
3037
- crs
3038
- });
2997
+ const DEFAULT_LEGEND_CONFIG = {
2998
+ renderTitle: createValueTitle
2999
+ };
3000
+ const useLayerLegend = (layer, config) => {
3001
+ const {
3002
+ style,
3003
+ layerDefinition
3004
+ } = layer || {};
3005
+ const {
3006
+ attributes
3007
+ } = layerDefinition || {};
3008
+ const styleProxy = style && new EvergisStyle(style);
3009
+ return useLegend(styleProxy, _extends({
3010
+ attributes: attributes
3011
+ }, DEFAULT_LEGEND_CONFIG, config));
3012
+ };
3039
3013
 
3040
- case GeometryType.Polygon:
3041
- return new Polygon(coordinates, {
3042
- symbol: selectedPolygon,
3043
- crs
3044
- });
3014
+ const useMapLegend = (layer, config) => {
3015
+ const legend = useLayerLegend(layer, config);
3045
3016
 
3046
- default:
3047
- return null;
3048
- }
3049
- }
3050
- }, {
3051
- key: "extent",
3052
- value: function extent() {
3053
- const feature = this.sGisFeature();
3054
- return feature && feature.bbox;
3055
- }
3056
- }]);
3017
+ if (!legend) {
3018
+ return null;
3019
+ }
3057
3020
 
3058
- return EvergisFeature;
3059
- }();
3021
+ const firstLegend = legend.items[0];
3022
+ return {
3023
+ symbol: legend.symbol,
3024
+ item: firstLegend
3025
+ };
3026
+ };
3027
+
3028
+ const LEGEND_SYMBOL_MAX_SIZE = 32;
3029
+ const useLegendValueSymbol = (_ref) => {
3030
+ let {
3031
+ parameter,
3032
+ parameterValue
3033
+ } = _ref;
3034
+ const symbol = useLegendContext();
3035
+ const valueSymbol = // @ts-ignore
3036
+ symbol && applyParameterValue(symbol, parameter, parameterValue);
3037
+ let sGisSymbol = null;
3060
3038
 
3061
- function evaluateCondition(condition, attributes) {
3062
3039
  try {
3063
- const evaluator = new ConditionEvaluator(attributes);
3064
- const result = evaluator.evaluate(condition);
3040
+ sGisSymbol = valueSymbol && deserializeSymbol(valueSymbol);
3041
+ } catch (e) {}
3065
3042
 
3066
- if (result instanceof Error) {
3067
- return null;
3068
- }
3043
+ return sGisSymbol && adjustSymbol(sGisSymbol, {
3044
+ size: LEGEND_SYMBOL_MAX_SIZE - 1
3045
+ });
3046
+ };
3069
3047
 
3070
- return result;
3071
- } catch (_unused) {
3072
- return null;
3073
- }
3074
- }
3048
+ const DEFAULT_SYMBOL_SIZE = 16;
3049
+ function useSymbol(_ref, canvasRef) {
3050
+ let {
3051
+ symbol,
3052
+ size = DEFAULT_SYMBOL_SIZE,
3053
+ render = getSymbolRenders,
3054
+ maxWidth
3055
+ } = _ref;
3056
+ useEffect(() => {
3057
+ if (canvasRef.current !== null && symbol !== undefined) {
3058
+ const canvas = canvasRef.current;
3059
+ setCanvasSize(canvas, size, maxWidth);
3060
+ render(symbol, size).then(renders => {
3061
+ renderSymbolToCanvas(renders, canvas);
3062
+ });
3063
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
3075
3064
 
3076
- function getAttributeValue(attributes, attributeName) {
3077
- const attributeMeta = attributes.find(_ref => {
3078
- let {
3079
- name
3080
- } = _ref;
3081
- return name === attributeName;
3082
- });
3083
- return attributeMeta ? attributeMeta.value : null;
3065
+ }, [symbol, size, maxWidth]);
3084
3066
  }
3085
3067
 
3086
- const getAttributeNameFromCondition = condition => new ClassificationCondition(condition).attributeName;
3087
- const getAttributeNameFromClassified = values => values.length > 0 ? getAttributeNameFromCondition(values[0].condition) : null;
3068
+ function setCanvasSize(canvas, size, maxWidth) {
3069
+ canvas.node.height = size;
3070
+ canvas.node.width = maxWidth ? Math.min(size, maxWidth) : size;
3071
+ }
3088
3072
 
3089
- function findFeatureValue(parameterValues, _ref2) {
3090
- let [name, value] = _ref2;
3091
- return value !== null ? parameterValues.find(_ref3 => {
3092
- let {
3093
- condition
3094
- } = _ref3;
3095
- return value !== undefined && evaluateCondition(condition, {
3096
- [name]: value
3097
- });
3098
- }) : null;
3073
+ function useCanvas() {
3074
+ const canvas = useRef(null);
3075
+ const ref = useCallback(node => {
3076
+ if (node !== null) {
3077
+ canvas.current = new Canvas(node);
3078
+ } else {
3079
+ canvas.current = null;
3080
+ }
3081
+ }, []);
3082
+ return {
3083
+ canvas,
3084
+ ref
3085
+ };
3099
3086
  }
3100
3087
 
3101
- function extractValuesAttribute(parameterValues, attributes) {
3102
- const name = getAttributeNameFromClassified(parameterValues) || '';
3103
- const value = name && getAttributeValue(attributes, name);
3104
- return [name, value];
3088
+ function useMount(_ref) {
3089
+ let {
3090
+ onMount,
3091
+ onUnmount
3092
+ } = _ref;
3093
+ useEffect(() => {
3094
+ onMount && onMount();
3095
+ return onUnmount; // eslint-disable-next-line react-hooks/exhaustive-deps
3096
+ }, []);
3105
3097
  }
3106
3098
 
3107
- function evaluateFeatureSymbol(attributes) {
3108
- // @ts-ignore
3109
- function calc(result, _ref4) {
3110
- let [parameterName, parameterValue] = _ref4;
3111
- let newParameterValue;
3112
-
3113
- if (isParameterByAttribute(parameterValue)) {
3114
- const [attributeName, attributeValue] = extractValuesAttribute(parameterValue.values, attributes);
3115
- const featureValue = findFeatureValue(parameterValue.values, [attributeName, attributeValue]);
3116
- newParameterValue = featureValue ? featureValue.value : parameterValue.defaultValue;
3117
- } else if (isObject(parameterValue)) {
3118
- // @ts-ignore
3119
- newParameterValue = Object.entries(parameterValue).reduce(calc, parameterValue);
3120
- }
3099
+ function useProperty(_ref, deps) {
3100
+ let {
3101
+ factory,
3102
+ destructor,
3103
+ update
3104
+ } = _ref;
3121
3105
 
3122
- return newParameterValue !== undefined ? _extends({}, result, {
3123
- [parameterName]: newParameterValue
3124
- }) : result;
3106
+ if (deps === void 0) {
3107
+ deps = [];
3125
3108
  }
3126
3109
 
3127
- return calc;
3128
- }
3129
-
3130
- function findChildFeatureStyle(childStyles, attributes) {
3131
- return (childStyles || []).find(_ref5 => {
3132
- let {
3133
- condition
3134
- } = _ref5;
3135
- const attributeName = condition && getAttributeNameFromCondition(condition);
3136
- const attributeValue = attributeName && getAttributeValue(attributes, attributeName);
3137
-
3138
- if (condition && attributeName && attributeValue !== undefined) {
3139
- return evaluateCondition(condition, {
3140
- [attributeName]: attributeValue
3141
- });
3110
+ const propRef = useRef();
3111
+ useMount({
3112
+ onUnmount() {
3113
+ if (propRef.current && destructor) {
3114
+ destructor(propRef.current);
3115
+ }
3142
3116
  }
3143
3117
 
3144
- return false;
3145
- }) || null;
3146
- }
3147
- function findChildFeatureSymbol(childStyles, attributes) {
3148
- const featureStyle = findChildFeatureStyle(childStyles, attributes);
3149
- return featureStyle ? featureStyle.symbol : null;
3150
- }
3151
- function getFeatureSymbol(style, attributes) {
3152
- if (!style || !style.symbol) {
3153
- return null;
3154
- }
3155
-
3156
- if (style.children !== null) {
3157
- return findChildFeatureSymbol(style.children, attributes) || style.symbol;
3158
- }
3159
-
3160
- return Object.entries(style.symbol).reduce(evaluateFeatureSymbol(attributes), style.symbol);
3161
- }
3162
-
3163
- let EvergisLayer = /*#__PURE__*/function () {
3164
- function EvergisLayer(service) {
3165
- _classCallCheck(this, EvergisLayer);
3166
-
3167
- this.name = null;
3168
- this.titleAttribute = null;
3169
- this.alias = null;
3170
- this.attributes = null;
3171
- this.style = null;
3172
- const evergisService = service;
3173
- const {
3174
- name,
3175
- alias,
3176
- style,
3177
- layerDefinition
3178
- } = evergisService;
3179
- this.name = name;
3180
- this.alias = alias || name;
3181
- this.attributes = getLayerAttributes(layerDefinition);
3182
- this.style = style && new EvergisStyle(style) || null;
3183
- this.titleAttribute = layerDefinition && layerDefinition.titleAttribute || null;
3184
- }
3185
-
3186
- _createClass(EvergisLayer, [{
3187
- key: "evaluateFeature",
3188
- value: function evaluateFeature(feature) {
3189
- feature.attributes = mergeAttributes(feature.attributes || [], this.attributes || []);
3190
- feature.symbol = this.style && getFeatureSymbol(this.style, feature.attributes);
3191
- feature.layerAlias = this.alias;
3192
- const titleAttribute = (feature.attributes || []).find(_ref => {
3193
- let {
3194
- name
3195
- } = _ref;
3196
- return name === this.titleAttribute;
3197
- });
3198
- const displayName = titleAttribute && formatAttributeValue(titleAttribute)[0].value || feature.id;
3199
- feature.displayName = displayName ? "" + displayName : feature.id;
3200
- return feature;
3118
+ });
3119
+ return useMemo(() => {
3120
+ if (propRef.current) {
3121
+ if (update) {
3122
+ const newProp = update(propRef.current, deps, {
3123
+ factory,
3124
+ destructor
3125
+ });
3126
+ if (newProp) propRef.current = newProp;
3127
+ } else if (destructor) {
3128
+ destructor(propRef.current);
3129
+ }
3130
+ } else {
3131
+ if (!update || !propRef.current) {
3132
+ propRef.current = factory(deps);
3133
+ }
3201
3134
  }
3202
- }]);
3203
-
3204
- return EvergisLayer;
3205
- }();
3206
-
3207
- const findFeatureLayer = feature => layer => layer.name === feature.layerName;
3208
3135
 
3209
- const evaluateFeature = layers => feature => {
3210
- const featureLayer = layers.find(findFeatureLayer(feature));
3211
- return featureLayer ? featureLayer.evaluateFeature(feature) : feature;
3212
- };
3136
+ return propRef.current; // eslint-disable-next-line react-hooks/exhaustive-deps
3137
+ }, deps);
3138
+ }
3213
3139
 
3214
- const OTHERS_TITLE = 'Другое';
3215
- const createLegendItem = _ref => {
3140
+ function useUpdate(_ref) {
3216
3141
  let {
3217
- attributes,
3218
- renderTitle,
3219
- skipDefaultValue,
3220
- reverse
3142
+ onUpdate,
3143
+ shouldUpdate,
3144
+ deps
3221
3145
  } = _ref;
3222
- return classification => {
3223
- const {
3224
- defaultTitle,
3225
- defaultValue,
3226
- values,
3227
- attribute: attributeName,
3228
- parameter
3229
- } = classification;
3230
- const attribute = attributeName && attributes ? getClassificationAttribute(attributeName, attributes) : undefined;
3231
- const defaultLegendValue = {
3232
- title: defaultTitle || OTHERS_TITLE,
3233
- parameterValue: defaultValue
3234
- };
3235
- const legendValues = values.map((value, index) => ({
3236
- title: renderTitle && renderTitle(_extends({}, value, {
3237
- attribute
3238
- }), index),
3239
- parameterValue: value.parameterValue
3240
- }));
3241
- const withDefault = skipDefaultValue ? legendValues : [...legendValues, defaultLegendValue];
3242
- const reversedValues = reverse ? [...withDefault].reverse() : withDefault;
3243
- return {
3244
- title: attribute && attribute.alias || attributeName,
3245
- attribute,
3246
- parameter,
3247
- values: reversedValues
3248
- };
3249
- };
3250
- };
3251
-
3252
- function createStyleLegend(style, config) {
3253
- const {
3254
- classificationManager,
3255
- symbol
3256
- } = style;
3257
- const items = classificationManager.filter(_ref => {
3258
- let {
3259
- parameter
3260
- } = _ref;
3261
- return config.parameters && parameter ? config.parameters.includes(parameter) : true;
3262
- });
3263
-
3264
- if (items.length === 0) {
3265
- return null;
3266
- }
3146
+ useEffect(() => {
3147
+ if (!shouldUpdate || shouldUpdate()) {
3148
+ onUpdate();
3149
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
3267
3150
 
3268
- return {
3269
- symbol: unClassify(symbol),
3270
- items: items.map(createLegendItem(config))
3271
- };
3151
+ }, deps);
3272
3152
  }
3273
3153
 
3274
- function createValueTitle(value, index) {
3275
- if (value.title) return value.title;
3276
- if (isRangeClass(value)) return printRangeClass(value, index);
3277
- if (isUniqueClass(value)) return value.uniqueValue;
3278
- return '';
3154
+ function useLayerOrder(layer, zIndex) {
3155
+ const {
3156
+ map
3157
+ } = useMapContext();
3158
+ useUpdate({
3159
+ onUpdate: () => map.insertLayer(layer, zIndex),
3160
+ deps: [zIndex, layer]
3161
+ });
3279
3162
  }
3280
3163
 
3281
- function formatArea(num) {
3282
- let result = num;
3283
- let measure = 'м²';
3284
-
3285
- if (num >= 10000000) {
3286
- result = num / 1000000;
3287
- measure = 'км²';
3288
- } else if (num >= 10000) {
3289
- result = num / 10000;
3290
- measure = 'га';
3164
+ function useLayerVisibility(layer, isDisplayed) {
3165
+ if (isDisplayed === void 0) {
3166
+ isDisplayed = true;
3291
3167
  }
3292
3168
 
3293
- return numberWithSpaces(result) + " " + measure;
3169
+ useUpdate({
3170
+ shouldUpdate: () => layer.isDisplayed !== isDisplayed,
3171
+ onUpdate: () => layer.isDisplayed = isDisplayed,
3172
+ deps: [isDisplayed, layer]
3173
+ });
3294
3174
  }
3295
- function formatLength(num) {
3296
- let result = num;
3297
- let measure = 'м';
3298
3175
 
3299
- if (num > 10000) {
3300
- result = num / 1000;
3301
- measure = 'км';
3302
- }
3303
-
3304
- return numberWithSpaces(result) + " " + measure;
3305
- }
3306
- function formatPolygonMeasure(area, perimiter) {
3307
- return "S : " + formatArea(area) + " P : " + formatLength(perimiter);
3308
- }
3309
- function isPolylineLikePolygon(rings, resolution) {
3310
- if (rings[0].length <= 3) {
3311
- return false;
3176
+ function useLayerOpacity(layer, opacity) {
3177
+ if (opacity === void 0) {
3178
+ opacity = 1;
3312
3179
  }
3313
3180
 
3314
- const coords = rings[0];
3315
- const firstPoint = coords[0];
3316
- const lastPoint = coords[coords.length - 1];
3317
- const distance = resolution * 2;
3318
- return softEquals(firstPoint[0], lastPoint[0], distance) && softEquals(firstPoint[1], lastPoint[1], distance);
3319
- }
3320
-
3321
- function getScale(scale) {
3322
- const scales = [1, 2, 5];
3323
-
3324
- for (let x = 0; x < 21; x++) {
3325
- for (let y = 0; y < scales.length; y++) {
3326
- const result = Math.pow(10, x) * scales[y];
3327
-
3328
- if (result > scale) {
3329
- return result;
3330
- }
3331
- }
3332
- }
3333
-
3334
- return 1;
3335
- }
3336
-
3337
- const useLegend = (style, config) => useMemo(() => {
3338
- if (!style || !(config && config.attributes)) return null;
3339
- return createStyleLegend(style, config);
3340
- }, [style, config]);
3341
-
3342
- const DEFAULT_LEGEND_CONFIG = {
3343
- renderTitle: createValueTitle
3344
- };
3345
- const useLayerLegend = (layer, config) => {
3346
- const {
3347
- style,
3348
- layerDefinition
3349
- } = layer || {};
3350
- const {
3351
- attributes
3352
- } = layerDefinition || {};
3353
- const styleProxy = style && new EvergisStyle(style);
3354
- return useLegend(styleProxy, _extends({
3355
- attributes: attributes
3356
- }, DEFAULT_LEGEND_CONFIG, config));
3357
- };
3358
-
3359
- const useMapLegend = (layer, config) => {
3360
- const legend = useLayerLegend(layer, config);
3361
-
3362
- if (!legend) {
3363
- return null;
3364
- }
3365
-
3366
- const firstLegend = legend.items[0];
3367
- return {
3368
- symbol: legend.symbol,
3369
- item: firstLegend
3370
- };
3371
- };
3372
-
3373
- const LEGEND_SYMBOL_MAX_SIZE = 32;
3374
- const useLegendValueSymbol = _ref => {
3375
- let {
3376
- parameter,
3377
- parameterValue
3378
- } = _ref;
3379
- const symbol = useLegendContext();
3380
- const valueSymbol = // @ts-ignore
3381
- symbol && applyParameterValue(symbol, parameter, parameterValue);
3382
- let sGisSymbol = null;
3383
-
3384
- try {
3385
- sGisSymbol = valueSymbol && deserializeSymbol(valueSymbol);
3386
- } catch (e) {}
3387
-
3388
- return sGisSymbol && adjustSymbol(sGisSymbol, {
3389
- size: LEGEND_SYMBOL_MAX_SIZE - 1
3390
- });
3391
- };
3392
-
3393
- const DEFAULT_SYMBOL_SIZE = 16;
3394
- function useSymbol(_ref, canvasRef) {
3395
- let {
3396
- symbol,
3397
- size = DEFAULT_SYMBOL_SIZE,
3398
- render = getSymbolRenders,
3399
- maxWidth
3400
- } = _ref;
3401
- useEffect(() => {
3402
- if (canvasRef.current !== null && symbol !== undefined) {
3403
- const canvas = canvasRef.current;
3404
- setCanvasSize(canvas, size, maxWidth);
3405
- render(symbol, size).then(renders => {
3406
- renderSymbolToCanvas(renders, canvas);
3407
- });
3408
- } // eslint-disable-next-line react-hooks/exhaustive-deps
3409
-
3410
- }, [symbol, size, maxWidth]);
3411
- }
3412
-
3413
- function setCanvasSize(canvas, size, maxWidth) {
3414
- canvas.node.height = size;
3415
- canvas.node.width = maxWidth ? Math.min(size, maxWidth) : size;
3416
- }
3417
-
3418
- function useCanvas() {
3419
- const canvas = useRef(null);
3420
- const ref = useCallback(node => {
3421
- if (node !== null) {
3422
- canvas.current = new Canvas(node);
3423
- } else {
3424
- canvas.current = null;
3425
- }
3426
- }, []);
3427
- return {
3428
- canvas,
3429
- ref
3430
- };
3431
- }
3432
-
3433
- function useMount(_ref) {
3434
- let {
3435
- onMount,
3436
- onUnmount
3437
- } = _ref;
3438
- useEffect(() => {
3439
- onMount && onMount();
3440
- return onUnmount; // eslint-disable-next-line react-hooks/exhaustive-deps
3441
- }, []);
3442
- }
3443
-
3444
- function useProperty(_ref, deps) {
3445
- let {
3446
- factory,
3447
- destructor,
3448
- update
3449
- } = _ref;
3450
-
3451
- if (deps === void 0) {
3452
- deps = [];
3453
- }
3454
-
3455
- const propRef = useRef();
3456
- useMount({
3457
- onUnmount() {
3458
- if (propRef.current && destructor) {
3459
- destructor(propRef.current);
3460
- }
3461
- }
3462
-
3463
- });
3464
- return useMemo(() => {
3465
- if (propRef.current) {
3466
- if (update) {
3467
- const newProp = update(propRef.current, deps, {
3468
- factory,
3469
- destructor
3470
- });
3471
- if (newProp) propRef.current = newProp;
3472
- } else if (destructor) {
3473
- destructor(propRef.current);
3474
- }
3475
- } else {
3476
- if (!update || !propRef.current) {
3477
- propRef.current = factory(deps);
3478
- }
3479
- }
3480
-
3481
- return propRef.current; // eslint-disable-next-line react-hooks/exhaustive-deps
3482
- }, deps);
3483
- }
3484
-
3485
- function useUpdate(_ref) {
3486
- let {
3487
- onUpdate,
3488
- shouldUpdate,
3489
- deps
3490
- } = _ref;
3491
- useEffect(() => {
3492
- if (!shouldUpdate || shouldUpdate()) {
3493
- onUpdate();
3494
- } // eslint-disable-next-line react-hooks/exhaustive-deps
3495
-
3496
- }, deps);
3497
- }
3498
-
3499
- function useLayerOrder(layer, zIndex) {
3500
- const {
3501
- map
3502
- } = useMapContext();
3503
- useUpdate({
3504
- onUpdate: () => map.insertLayer(layer, zIndex),
3505
- deps: [zIndex, layer]
3506
- });
3507
- }
3508
-
3509
- function useLayerVisibility(layer, isDisplayed) {
3510
- if (isDisplayed === void 0) {
3511
- isDisplayed = true;
3512
- }
3513
-
3514
- useUpdate({
3515
- shouldUpdate: () => layer.isDisplayed !== isDisplayed,
3516
- onUpdate: () => layer.isDisplayed = isDisplayed,
3517
- deps: [isDisplayed, layer]
3518
- });
3519
- }
3520
-
3521
- function useLayerOpacity(layer, opacity) {
3522
- if (opacity === void 0) {
3523
- opacity = 1;
3524
- }
3525
-
3526
- useUpdate({
3527
- shouldUpdate: () => layer.opacity !== opacity,
3528
- onUpdate: () => layer.opacity = opacity,
3529
- deps: [opacity, layer]
3530
- });
3181
+ useUpdate({
3182
+ shouldUpdate: () => layer.opacity !== opacity,
3183
+ onUpdate: () => layer.opacity = opacity,
3184
+ deps: [opacity, layer]
3185
+ });
3531
3186
  }
3532
3187
 
3533
3188
  function useEvergisDynamicLayer(_ref) {
@@ -3749,7 +3404,7 @@ function useMapWrapper() {
3749
3404
  return wrapperRef;
3750
3405
  }
3751
3406
 
3752
- const byScale = scale => _ref => {
3407
+ const byScale = scale => (_ref) => {
3753
3408
  let {
3754
3409
  zIndex
3755
3410
  } = _ref;
@@ -3948,7 +3603,7 @@ const useTooltip = function useTooltip(zIndex) {
3948
3603
 
3949
3604
  return reset;
3950
3605
  }, [reset, map, layer, zIndex]);
3951
- const onSetLabelFeature = useCallback(_ref => {
3606
+ const onSetLabelFeature = useCallback((_ref) => {
3952
3607
  let {
3953
3608
  point,
3954
3609
  position,
@@ -4112,7 +3767,7 @@ function useClusterLayer(_ref) {
4112
3767
  }
4113
3768
 
4114
3769
  const INIT_FEATURES = [];
4115
- const useEvergisSelect = _ref => {
3770
+ const useEvergisSelect = (_ref) => {
4116
3771
  let {
4117
3772
  onPick,
4118
3773
  onFeatures
@@ -4145,7 +3800,7 @@ function none() {
4145
3800
  return;
4146
3801
  }
4147
3802
 
4148
- const useDraggableMarker = _ref => {
3803
+ const useDraggableMarker = (_ref) => {
4149
3804
  let {
4150
3805
  position,
4151
3806
  onChange,
@@ -4261,7 +3916,7 @@ const useDebouncedCallback = interval => {
4261
3916
  }, interval), [interval]);
4262
3917
  };
4263
3918
 
4264
- const Symbol = _ref => {
3919
+ const Symbol = (_ref) => {
4265
3920
  let {
4266
3921
  symbol,
4267
3922
  size,
@@ -4282,7 +3937,7 @@ const Symbol = _ref => {
4282
3937
  };
4283
3938
 
4284
3939
  var _templateObject;
4285
- const CompoundIcon = /*#__PURE__*/styled.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background: ", ";\n height: 32px;\n width: 32px;\n"])), _ref => {
3940
+ const CompoundIcon = /*#__PURE__*/styled.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background: ", ";\n height: 32px;\n width: 32px;\n"])), (_ref) => {
4286
3941
  let {
4287
3942
  geometryType,
4288
3943
  icons
@@ -4291,7 +3946,7 @@ const CompoundIcon = /*#__PURE__*/styled.div(_templateObject || (_templateObject
4291
3946
  });
4292
3947
 
4293
3948
  const MAX_SIZE = 32;
4294
- const StyleSymbol = _ref => {
3949
+ const StyleSymbol = (_ref) => {
4295
3950
  let {
4296
3951
  symbol,
4297
3952
  size = MAX_SIZE,
@@ -4336,7 +3991,7 @@ const CloseIcon = /*#__PURE__*/styled(Icon)(_templateObject20 || (_templateObjec
4336
3991
  const PrevIcon = /*#__PURE__*/styled(Icon)(_templateObject21 || (_templateObject21 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), featureCardIconMixin);
4337
3992
  const NextIcon = /*#__PURE__*/styled(Icon)(_templateObject22 || (_templateObject22 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), featureCardIconMixin);
4338
3993
 
4339
- const MailValue = _ref => {
3994
+ const MailValue = (_ref) => {
4340
3995
  let {
4341
3996
  mail
4342
3997
  } = _ref;
@@ -4347,7 +4002,7 @@ const MailValue = _ref => {
4347
4002
  }, mail);
4348
4003
  };
4349
4004
 
4350
- const PhoneValue = _ref => {
4005
+ const PhoneValue = (_ref) => {
4351
4006
  let {
4352
4007
  phone
4353
4008
  } = _ref;
@@ -4358,7 +4013,7 @@ const PhoneValue = _ref => {
4358
4013
  }, phone);
4359
4014
  };
4360
4015
 
4361
- const UrlValue = _ref => {
4016
+ const UrlValue = (_ref) => {
4362
4017
  let {
4363
4018
  url
4364
4019
  } = _ref;
@@ -4369,7 +4024,7 @@ const UrlValue = _ref => {
4369
4024
  }, url);
4370
4025
  };
4371
4026
 
4372
- const AttributeValue = _ref => {
4027
+ const AttributeValue = (_ref) => {
4373
4028
  let {
4374
4029
  attribute
4375
4030
  } = _ref;
@@ -4383,29 +4038,29 @@ const AttributeValue = _ref => {
4383
4038
  if (attributeValue.type === 2
4384
4039
  /* Url */
4385
4040
  ) {
4386
- return React.createElement(UrlValue, {
4387
- key: key,
4388
- url: punycodeDecode(value)
4389
- });
4390
- }
4041
+ return React.createElement(UrlValue, {
4042
+ key: key,
4043
+ url: punycodeDecode(value)
4044
+ });
4045
+ }
4391
4046
 
4392
4047
  if (attributeValue.type === 3
4393
4048
  /* Mail */
4394
4049
  ) {
4395
- return React.createElement(MailValue, {
4396
- key: key,
4397
- mail: value
4398
- });
4399
- }
4050
+ return React.createElement(MailValue, {
4051
+ key: key,
4052
+ mail: value
4053
+ });
4054
+ }
4400
4055
 
4401
4056
  if (attributeValue.type === 1
4402
4057
  /* Phone */
4403
4058
  ) {
4404
- return React.createElement(PhoneValue, {
4405
- key: key,
4406
- phone: value
4407
- });
4408
- }
4059
+ return React.createElement(PhoneValue, {
4060
+ key: key,
4061
+ phone: value
4062
+ });
4063
+ }
4409
4064
 
4410
4065
  return React.createElement(SimpleAttribute, {
4411
4066
  key: value
@@ -4421,7 +4076,7 @@ function punycodeDecode(domains) {
4421
4076
  }
4422
4077
  }
4423
4078
 
4424
- const EvergisCardAttribute = _ref => {
4079
+ const EvergisCardAttribute = (_ref) => {
4425
4080
  let {
4426
4081
  attribute,
4427
4082
  className
@@ -4433,7 +4088,7 @@ const EvergisCardAttribute = _ref => {
4433
4088
  }));
4434
4089
  };
4435
4090
 
4436
- const StyledCard = _ref => {
4091
+ const StyledCard = (_ref) => {
4437
4092
  let {
4438
4093
  features = [],
4439
4094
  className,
@@ -4484,7 +4139,7 @@ const StyledCard = _ref => {
4484
4139
  };
4485
4140
 
4486
4141
  const _excluded$1 = ["renderCard", "className", "children"];
4487
- const EvergisCard = _ref => {
4142
+ const EvergisCard = (_ref) => {
4488
4143
  let {
4489
4144
  renderCard,
4490
4145
  className,
@@ -4536,7 +4191,7 @@ const toSgis = feature => feature.sGisFeature(); // TODO inner hooks???
4536
4191
 
4537
4192
  const useSGisFeatures = (features, currentIndex) => useMemo(() => features.map(toSgis).filter(truthly).map(setSelected(currentIndex)), [features, currentIndex]);
4538
4193
 
4539
- const EvergisSelectLayer = _ref => {
4194
+ const EvergisSelectLayer = (_ref) => {
4540
4195
  let {
4541
4196
  features,
4542
4197
  zIndex,
@@ -4581,7 +4236,7 @@ const TileLayer = props => {
4581
4236
  };
4582
4237
 
4583
4238
  const defaultZIndex = 200;
4584
- const EvergisSelect = _ref => {
4239
+ const EvergisSelect = (_ref) => {
4585
4240
  let {
4586
4241
  onPick,
4587
4242
  className,
@@ -4616,7 +4271,7 @@ const LegendSymbolTitle = /*#__PURE__*/styled.p(_templateObject3$1 || (_template
4616
4271
  const LegendValueContainer = /*#__PURE__*/styled.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);
4617
4272
  const LegendSectionHeader = /*#__PURE__*/styled.div(_templateObject5$1 || (_templateObject5$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-top: 0.5rem;\n font-size: 0.75rem;\n"])));
4618
4273
 
4619
- const LegendSection = _ref => {
4274
+ const LegendSection = (_ref) => {
4620
4275
  let {
4621
4276
  item,
4622
4277
  renderLegendTitle,
@@ -4633,7 +4288,7 @@ SearchPrefix.defaultProps = {
4633
4288
  kind: "search"
4634
4289
  };
4635
4290
 
4636
- const SearchInput = _ref => {
4291
+ const SearchInput = (_ref) => {
4637
4292
  let {
4638
4293
  onChange
4639
4294
  } = _ref;
@@ -4642,7 +4297,7 @@ const SearchInput = _ref => {
4642
4297
  }));
4643
4298
  };
4644
4299
 
4645
- const LegendSymbol = _ref => {
4300
+ const LegendSymbol = (_ref) => {
4646
4301
  let {
4647
4302
  parameter,
4648
4303
  parameterValue,
@@ -4660,7 +4315,7 @@ const LegendSymbol = _ref => {
4660
4315
  return React.createElement(React.Fragment, null, children(symbol));
4661
4316
  };
4662
4317
 
4663
- const LegendValue = _ref => {
4318
+ const LegendValue = (_ref) => {
4664
4319
  let {
4665
4320
  value,
4666
4321
  parameter,
@@ -4682,7 +4337,7 @@ const getNumberParam = (parameterValue, param) => {
4682
4337
  return typeof parameterValue === 'object' && param in parameterValue && typeof parameterValue[param] === 'number' ? parameterValue[param] : null;
4683
4338
  };
4684
4339
 
4685
- const getSymbolSize = _ref => {
4340
+ const getSymbolSize = (_ref) => {
4686
4341
  let {
4687
4342
  parameterValue,
4688
4343
  maxSize
@@ -4707,7 +4362,7 @@ const getSymbolSize = _ref => {
4707
4362
  }
4708
4363
  };
4709
4364
 
4710
- const Legend = _ref => {
4365
+ const Legend = (_ref) => {
4711
4366
  let {
4712
4367
  layer,
4713
4368
  children,
@@ -4750,7 +4405,7 @@ const Legend = _ref => {
4750
4405
  })))));
4751
4406
  };
4752
4407
 
4753
- const Map = _ref => {
4408
+ const Map = (_ref) => {
4754
4409
  let {
4755
4410
  className,
4756
4411
  position,
@@ -4772,163 +4427,488 @@ const Map = _ref => {
4772
4427
  })) {
4773
4428
  onBboxChange(state);
4774
4429
  }
4775
- }, [map, onBboxChange, position, resolution]);
4776
- useUpdateMapView({
4777
- position,
4778
- resolution
4779
- });
4780
- useMaxMinScale(minScale, maxScale, position, resolution);
4781
- useMapBboxChange(handleBboxChange);
4782
- return React.createElement("div", {
4783
- className: className,
4784
- ref: wrapperRef,
4785
- style: style
4786
- }, children);
4787
- };
4788
-
4789
- var _templateObject$4, _templateObject2$3, _templateObject3$3, _templateObject4$2, _templateObject5$2;
4790
-
4791
- const topLeft = distance => css(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteralLoose(["\n top: ", ";\n left: ", ";\n"])), distance, distance);
4430
+ }, [map, onBboxChange, position, resolution]);
4431
+ useUpdateMapView({
4432
+ position,
4433
+ resolution
4434
+ });
4435
+ useMaxMinScale(minScale, maxScale, position, resolution);
4436
+ useMapBboxChange(handleBboxChange);
4437
+ return React.createElement("div", {
4438
+ className: className,
4439
+ ref: wrapperRef,
4440
+ style: style
4441
+ }, children);
4442
+ };
4443
+
4444
+ var _templateObject$4, _templateObject2$3, _templateObject3$3, _templateObject4$2, _templateObject5$2;
4445
+
4446
+ const topLeft = distance => css(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteralLoose(["\n top: ", ";\n left: ", ";\n"])), distance, distance);
4447
+
4448
+ const topRight = distance => css(_templateObject2$3 || (_templateObject2$3 = _taggedTemplateLiteralLoose(["\n top: ", ";\n right: ", ";\n"])), distance, distance);
4449
+
4450
+ const bottomLeft = distance => css(_templateObject3$3 || (_templateObject3$3 = _taggedTemplateLiteralLoose(["\n bottom: ", ";\n left: ", ";\n"])), distance, distance);
4451
+
4452
+ const bottomRight = distance => css(_templateObject4$2 || (_templateObject4$2 = _taggedTemplateLiteralLoose(["\n bottom: ", ";\n right: ", ";\n"])), distance, distance);
4453
+
4454
+ const placementMixin = function placementMixin(placement, distance) {
4455
+ if (placement === void 0) {
4456
+ placement = 'bottom-left';
4457
+ }
4458
+
4459
+ if (distance === void 0) {
4460
+ distance = '1rem';
4461
+ }
4462
+
4463
+ return 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));
4464
+ };
4465
+
4466
+ var _templateObject$5, _templateObject2$4, _templateObject3$4, _templateObject4$3, _templateObject5$3, _templateObject6$1, _templateObject7$1, _templateObject8$1;
4467
+ const mapControlBtnMixin = /*#__PURE__*/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"])));
4468
+ const ZoomInBtn = /*#__PURE__*/styled(Icon)(_templateObject2$4 || (_templateObject2$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4469
+ ZoomInBtn.defaultProps = {
4470
+ kind: "plus"
4471
+ };
4472
+ const ZoomOutBtn = /*#__PURE__*/styled(Icon)(_templateObject3$4 || (_templateObject3$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4473
+ ZoomOutBtn.defaultProps = {
4474
+ kind: "minus"
4475
+ };
4476
+ const SearchBtn = /*#__PURE__*/styled(Icon)(_templateObject4$3 || (_templateObject4$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4477
+ SearchBtn.defaultProps = {
4478
+ kind: "search"
4479
+ }; // TODO not exists in fonts
4480
+
4481
+ const FullscreenBtn = /*#__PURE__*/styled(Icon)(_templateObject5$3 || (_templateObject5$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4482
+ FullscreenBtn.defaultProps = {
4483
+ kind: "maximize"
4484
+ };
4485
+ const MeasureBtn = /*#__PURE__*/styled(Icon)(_templateObject6$1 || (_templateObject6$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4486
+ MeasureBtn.defaultProps = {
4487
+ kind: "measure_length"
4488
+ };
4489
+ const MapControl = /*#__PURE__*/styled.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"])));
4490
+ const MapControls = /*#__PURE__*/styled.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) => {
4491
+ let {
4492
+ vertical
4493
+ } = _ref;
4494
+ return vertical ? 'column' : 'row';
4495
+ }, (_ref2) => {
4496
+ let {
4497
+ placement
4498
+ } = _ref2;
4499
+ return placementMixin(placement);
4500
+ }, MapControl, (_ref3) => {
4501
+ let {
4502
+ vertical
4503
+ } = _ref3;
4504
+ return vertical ? '0.5rem' : '0';
4505
+ }, (_ref4) => {
4506
+ let {
4507
+ vertical
4508
+ } = _ref4;
4509
+ return vertical ? '0' : '0.5rem';
4510
+ }, (_ref5) => {
4511
+ let {
4512
+ vertical
4513
+ } = _ref5;
4514
+ return vertical ? 'column' : 'row';
4515
+ });
4516
+
4517
+ const Measure = () => {
4518
+ return React.createElement(MapControl, null, React.createElement(MeasureBtn, {
4519
+ onClick: () => {}
4520
+ }));
4521
+ };
4522
+
4523
+ const Search = () => {
4524
+ return React.createElement(MapControl, null, React.createElement(SearchBtn, {
4525
+ onClick: () => {}
4526
+ }));
4527
+ };
4528
+
4529
+ const Fullscreen = () => {
4530
+ return React.createElement(MapControl, null, React.createElement(FullscreenBtn, {
4531
+ onClick: () => {}
4532
+ }));
4533
+ };
4534
+
4535
+ var _templateObject$6, _templateObject2$5, _templateObject3$5, _templateObject4$4, _templateObject5$4;
4536
+ const MapLegendControl = /*#__PURE__*/styled(MapControl)(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n cursor: default;\n"])));
4537
+ const MapLegendContainer = /*#__PURE__*/styled.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"])));
4538
+ const MapLegendHeader = /*#__PURE__*/styled(LegendSectionHeader)(_templateObject3$5 || (_templateObject3$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0;\n"])));
4539
+ const MapLegendSection = /*#__PURE__*/styled.div(_templateObject4$4 || (_templateObject4$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n"])));
4540
+ const MapLegendValueDescr = /*#__PURE__*/styled.div(_templateObject5$4 || (_templateObject5$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0.5rem;\n font-size: 0.625rem;\n opacity: 0.65;\n"])));
4541
+
4542
+ const MAX_SIZE$2 = 100;
4543
+ const MapLegendSymbol = (_ref) => {
4544
+ let {
4545
+ value,
4546
+ parameter
4547
+ } = _ref;
4548
+ return React.createElement(LegendSymbol, {
4549
+ key: value.title,
4550
+ parameter: parameter,
4551
+ parameterValue: value.parameterValue
4552
+ }, symbol => React.createElement(Symbol, {
4553
+ render: getMapLegendSymbolRenders,
4554
+ symbol: symbol,
4555
+ size: MAX_SIZE$2
4556
+ }));
4557
+ };
4558
+
4559
+ const DEFAULT_FROM_TO = ['Выше', 'Ниже'];
4560
+ const MapLegend = (_ref) => {
4561
+ let {
4562
+ layer,
4563
+ config,
4564
+ fromToTitle = DEFAULT_FROM_TO,
4565
+ className
4566
+ } = _ref;
4567
+ const legend = useMapLegend(layer, config);
4568
+
4569
+ if (!legend) {
4570
+ return null;
4571
+ }
4572
+
4573
+ const {
4574
+ symbol,
4575
+ item
4576
+ } = legend;
4577
+ return React.createElement(LegendProvider, {
4578
+ symbol: symbol
4579
+ }, React.createElement(MapLegendControl, {
4580
+ className: className
4581
+ }, React.createElement(MapLegendContainer, null, React.createElement(MapLegendHeader, null, item.title), React.createElement(MapLegendSection, null, React.createElement(MapLegendValueDescr, null, fromToTitle[0]), item.values.map(value => React.createElement(MapLegendSymbol, {
4582
+ key: value.title,
4583
+ value: value,
4584
+ parameter: item.parameter
4585
+ })), React.createElement(MapLegendValueDescr, null, fromToTitle[1])))));
4586
+ };
4587
+
4588
+ const DEFAULT_FORMATTERS = {
4589
+ polygon: formatPolygonMeasure,
4590
+ length: formatLength
4591
+ };
4592
+
4593
+ const COORD_FRACTION = 6;
4594
+ const DEFAULT_LABEL_POSITION = [Infinity, Infinity];
4595
+ let BaseMeasureToolCreator = /*#__PURE__*/function (_PolylineControl) {
4596
+ _inherits(BaseMeasureToolCreator, _PolylineControl);
4597
+
4598
+ var _super = /*#__PURE__*/_createSuper(BaseMeasureToolCreator);
4599
+
4600
+ function BaseMeasureToolCreator(map, painter, params) {
4601
+ var _this;
4602
+
4603
+ _classCallCheck(this, BaseMeasureToolCreator);
4604
+
4605
+ _this = _super.call(this, map, params);
4606
+
4607
+ _this.cancel = () => {
4608
+ _this.fire('cancel');
4609
+ };
4610
+
4611
+ _this.painter = painter;
4612
+ _this.renderLabelSymbol = params.renderLabelSymbol;
4613
+ _this.formatters = params.formatters || DEFAULT_FORMATTERS;
4614
+ _this.areaSymbol = params.areaSymbol;
4615
+
4616
+ _this.on('pointAdd', _this.handlePointAdd); // @ts-ignore
4617
+
4618
+
4619
+ _this.on('change', _this.updateDistance);
4620
+
4621
+ return _this;
4622
+ }
4623
+
4624
+ _createClass(BaseMeasureToolCreator, [{
4625
+ key: "_handleMousemove",
4626
+ value: function _handleMousemove(event) {
4627
+ _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_handleMousemove", this).call(this, event);
4628
+
4629
+ this.drawPointOnMouseMove(event);
4630
+ }
4631
+ }, {
4632
+ key: "_activate",
4633
+ value: function _activate() {
4634
+ _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_activate", this).call(this);
4635
+
4636
+ this.addTempLabel();
4637
+ this.setCursor('pointer');
4638
+ }
4639
+ }, {
4640
+ key: "_deactivate",
4641
+ value: function _deactivate() {
4642
+ _get(_getPrototypeOf(BaseMeasureToolCreator.prototype), "_deactivate", this).call(this);
4643
+
4644
+ this.removeCoordLabel();
4645
+ this.removeTempLabel();
4646
+ this.removeMeasureLabel();
4647
+ this.removeTempPolygon();
4648
+ this.setCursor('default');
4649
+ }
4650
+ }, {
4651
+ key: "handlePointAdd",
4652
+ value: function handlePointAdd() {
4653
+ const feature = this.activeFeature;
4654
+ if (!feature) return;
4655
+ const {
4656
+ rings,
4657
+ crs
4658
+ } = feature;
4659
+
4660
+ if (isPolylineLikePolygon(rings, this.map.resolution)) {
4661
+ this.finishDrawing();
4662
+ this.fire(new DrawingFinishEvent(feature, new MouseEvent('mouseup')));
4663
+ return;
4664
+ }
4665
+
4666
+ if (rings[0].length === 2) {
4667
+ const projection = crs.projectionTo(geo);
4668
+ const point = rings[0][0];
4669
+ if (!projection) return;
4670
+ const [lat, long] = projection(point);
4671
+ this.removeTempLabel();
4672
+ this.addMeasureResultLabel();
4673
+ this.addCoordLabel(lat.toFixed(COORD_FRACTION) + ", " + long.toFixed(COORD_FRACTION), point);
4674
+ } else {
4675
+ this.removeCoordLabel();
4676
+ }
4677
+ }
4678
+ }, {
4679
+ key: "polygonPreview",
4680
+ value: function polygonPreview() {
4681
+ if (this.tempPolygon) {
4682
+ this._tempLayer && this._tempLayer.remove(this.tempPolygon);
4683
+ }
4684
+
4685
+ const feature = this.activeFeature;
4686
+ if (!feature) return;
4687
+ const {
4688
+ rings,
4689
+ crs
4690
+ } = feature;
4691
+ const polygonRings = [...rings[0]];
4692
+ polygonRings.shift();
4693
+ this.tempPolygon = new Polygon(polygonRings, {
4694
+ crs
4695
+ });
4696
+ this.tempPolygon.symbol = this.areaSymbol || measureAreaSymbol;
4697
+ this.activeFeature && this.activeFeature.hide();
4698
+ this._tempLayer && this._tempLayer.add(this.tempPolygon);
4699
+ }
4700
+ }, {
4701
+ key: "removeTempPolygon",
4702
+ value: function removeTempPolygon() {
4703
+ if (this.tempPolygon) {
4704
+ this._tempLayer && this._tempLayer.remove(this.tempPolygon);
4705
+ delete this.tempPolygon;
4706
+ }
4707
+ }
4708
+ }, {
4709
+ key: "updateDistance",
4710
+ value: function updateDistance(event) {
4711
+ const feature = this.activeFeature;
4712
+ const {
4713
+ ringIndex,
4714
+ pointIndex
4715
+ } = event;
4716
+ if (!feature || ringIndex === null || pointIndex === null) return;
4717
+ const {
4718
+ rings,
4719
+ crs
4720
+ } = feature;
4721
+ const position = rings[ringIndex][pointIndex];
4722
+ const length$1 = length(rings, crs);
4723
+ let content = this.formatters.length(length$1);
4724
+
4725
+ if (isPolylineLikePolygon(rings, this.map.resolution)) {
4726
+ this.polygonPreview();
4727
+ const area$1 = area(rings, crs);
4728
+ content = this.formatters.polygon(area$1, length$1);
4729
+ } else if (this.tempPolygon) {
4730
+ feature.show();
4731
+ this.removeTempPolygon();
4732
+ }
4733
+
4734
+ if (this.measureResultLabel) {
4735
+ this.measureResultLabel.position = position;
4736
+ this.measureResultLabel.content = content;
4737
+ }
4738
+ }
4739
+ }, {
4740
+ key: "addTempLabel",
4741
+ value: function addTempLabel() {
4742
+ this.tempLabel = new LabelFeature(DEFAULT_LABEL_POSITION, {
4743
+ content: 'Нажмите на карту, чтобы начать измерение',
4744
+ crs: this.map.crs,
4745
+ symbol: createLabelSymbol({
4746
+ renderLabel: this.renderLabelSymbol
4747
+ })
4748
+ });
4749
+ this._tempLayer && this._tempLayer.add(this.tempLabel);
4750
+ }
4751
+ }, {
4752
+ key: "addCoordLabel",
4753
+ value: function addCoordLabel(content, position) {
4754
+ this.coordLabel = new LabelFeature(position, {
4755
+ content,
4756
+ crs: this.map.crs,
4757
+ symbol: createLabelSymbol({
4758
+ renderLabel: this.renderLabelSymbol,
4759
+ onClose: this.cancel
4760
+ })
4761
+ });
4762
+ this._tempLayer && this.coordLabel && this._tempLayer.add(this.coordLabel);
4763
+ }
4764
+ }, {
4765
+ key: "addMeasureResultLabel",
4766
+ value: function addMeasureResultLabel() {
4767
+ this.measureResultLabel = new LabelFeature(DEFAULT_LABEL_POSITION, {
4768
+ crs: this.map.crs,
4769
+ symbol: createLabelSymbol({
4770
+ renderLabel: this.renderLabelSymbol
4771
+ })
4772
+ });
4773
+ this._tempLayer && this.measureResultLabel && this._tempLayer.add(this.measureResultLabel);
4774
+ }
4775
+ }, {
4776
+ key: "removeTempLabel",
4777
+ value: function removeTempLabel() {
4778
+ if (this.tempLabel) {
4779
+ this._tempLayer && this._tempLayer.remove(this.tempLabel);
4780
+ delete this.tempLabel;
4781
+ }
4782
+ }
4783
+ }, {
4784
+ key: "removeCoordLabel",
4785
+ value: function removeCoordLabel() {
4786
+ if (this.coordLabel) {
4787
+ this._tempLayer && this._tempLayer.remove(this.coordLabel);
4788
+ delete this.coordLabel;
4789
+ }
4790
+ }
4791
+ }, {
4792
+ key: "removeMeasureLabel",
4793
+ value: function removeMeasureLabel() {
4794
+ if (this.measureResultLabel) {
4795
+ this._tempLayer && this._tempLayer.remove(this.measureResultLabel);
4796
+ delete this.measureResultLabel;
4797
+ }
4798
+ }
4799
+ }, {
4800
+ key: "drawPointOnMouseMove",
4801
+ value: function drawPointOnMouseMove(event) {
4802
+ if (this.tempLabel) {
4803
+ this.tempLabel.position = event.point.position;
4804
+ }
4805
+ }
4806
+ }, {
4807
+ key: "setCursor",
4808
+ value: function setCursor(cursor) {
4809
+ const {
4810
+ wrapper
4811
+ } = this.painter;
4792
4812
 
4793
- const topRight = distance => css(_templateObject2$3 || (_templateObject2$3 = _taggedTemplateLiteralLoose(["\n top: ", ";\n right: ", ";\n"])), distance, distance);
4813
+ if (wrapper && typeof wrapper !== 'string') {
4814
+ wrapper.style.cursor = cursor;
4815
+ }
4816
+ }
4817
+ }]);
4794
4818
 
4795
- const bottomLeft = distance => css(_templateObject3$3 || (_templateObject3$3 = _taggedTemplateLiteralLoose(["\n bottom: ", ";\n left: ", ";\n"])), distance, distance);
4819
+ return BaseMeasureToolCreator;
4820
+ }(PolylineControl);
4796
4821
 
4797
- const bottomRight = distance => css(_templateObject4$2 || (_templateObject4$2 = _taggedTemplateLiteralLoose(["\n bottom: ", ";\n right: ", ";\n"])), distance, distance);
4822
+ let BaseMeasureToolEditor = /*#__PURE__*/function (_PolyEditor) {
4823
+ _inherits(BaseMeasureToolEditor, _PolyEditor);
4798
4824
 
4799
- const placementMixin = function placementMixin(placement, distance) {
4800
- if (placement === void 0) {
4801
- placement = 'bottom-left';
4802
- }
4825
+ var _super = /*#__PURE__*/_createSuper(BaseMeasureToolEditor);
4803
4826
 
4804
- if (distance === void 0) {
4805
- distance = '1rem';
4806
- }
4827
+ function BaseMeasureToolEditor(map, painter, params) {
4828
+ var _this;
4807
4829
 
4808
- return 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));
4809
- };
4830
+ _classCallCheck(this, BaseMeasureToolEditor);
4810
4831
 
4811
- var _templateObject$5, _templateObject2$4, _templateObject3$4, _templateObject4$3, _templateObject5$3, _templateObject6$1, _templateObject7$1, _templateObject8$1;
4812
- const mapControlBtnMixin = /*#__PURE__*/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"])));
4813
- const ZoomInBtn = /*#__PURE__*/styled(Icon)(_templateObject2$4 || (_templateObject2$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4814
- ZoomInBtn.defaultProps = {
4815
- kind: "plus"
4816
- };
4817
- const ZoomOutBtn = /*#__PURE__*/styled(Icon)(_templateObject3$4 || (_templateObject3$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4818
- ZoomOutBtn.defaultProps = {
4819
- kind: "minus"
4820
- };
4821
- const SearchBtn = /*#__PURE__*/styled(Icon)(_templateObject4$3 || (_templateObject4$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4822
- SearchBtn.defaultProps = {
4823
- kind: "search"
4824
- }; // TODO not exists in fonts
4832
+ _this = _super.call(this, map, params);
4825
4833
 
4826
- const FullscreenBtn = /*#__PURE__*/styled(Icon)(_templateObject5$3 || (_templateObject5$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4827
- FullscreenBtn.defaultProps = {
4828
- kind: "maximize"
4829
- };
4830
- const MeasureBtn = /*#__PURE__*/styled(Icon)(_templateObject6$1 || (_templateObject6$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n ", "\n"])), mapControlBtnMixin);
4831
- MeasureBtn.defaultProps = {
4832
- kind: "measure_length"
4833
- };
4834
- const MapControl = /*#__PURE__*/styled.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"])));
4835
- const MapControls = /*#__PURE__*/styled.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 => {
4836
- let {
4837
- vertical
4838
- } = _ref;
4839
- return vertical ? 'column' : 'row';
4840
- }, _ref2 => {
4841
- let {
4842
- placement
4843
- } = _ref2;
4844
- return placementMixin(placement);
4845
- }, MapControl, _ref3 => {
4846
- let {
4847
- vertical
4848
- } = _ref3;
4849
- return vertical ? '0.5rem' : '0';
4850
- }, _ref4 => {
4851
- let {
4852
- vertical
4853
- } = _ref4;
4854
- return vertical ? '0' : '0.5rem';
4855
- }, _ref5 => {
4856
- let {
4857
- vertical
4858
- } = _ref5;
4859
- return vertical ? 'column' : 'row';
4860
- });
4834
+ _this.measureResult = () => {
4835
+ const feature = _this.activeFeature;
4836
+ if (!feature) return null;
4837
+ const {
4838
+ rings,
4839
+ isEnclosed,
4840
+ crs
4841
+ } = feature;
4842
+ const pointsCount = rings[0].length;
4843
+ const position = rings[0][pointsCount - 1];
4844
+ const area$1 = area(rings, crs);
4845
+ const length$1 = length(rings, crs, isEnclosed);
4846
+ const content = isEnclosed ? _this.formatters.polygon(area$1, length$1) : _this.formatters.length(length$1);
4847
+ return {
4848
+ content,
4849
+ position
4850
+ };
4851
+ };
4861
4852
 
4862
- const Measure = () => {
4863
- return React.createElement(MapControl, null, React.createElement(MeasureBtn, {
4864
- onClick: () => {}
4865
- }));
4866
- };
4853
+ _this.removeFeature = () => {
4854
+ _this.fire('remove');
4855
+ };
4867
4856
 
4868
- const Search = () => {
4869
- return React.createElement(MapControl, null, React.createElement(SearchBtn, {
4870
- onClick: () => {}
4871
- }));
4872
- };
4857
+ _this.painter = painter;
4858
+ _this.renderLabelSymbol = params.renderLabelSymbol;
4859
+ _this.formatters = params.formatters || DEFAULT_FORMATTERS;
4873
4860
 
4874
- const Fullscreen = () => {
4875
- return React.createElement(MapControl, null, React.createElement(FullscreenBtn, {
4876
- onClick: () => {}
4877
- }));
4878
- };
4861
+ _this.on('change', _this.updateMeasureResult);
4879
4862
 
4880
- var _templateObject$6, _templateObject2$5, _templateObject3$5, _templateObject4$4, _templateObject5$4;
4881
- const MapLegendControl = /*#__PURE__*/styled(MapControl)(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n cursor: default;\n"])));
4882
- const MapLegendContainer = /*#__PURE__*/styled.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"])));
4883
- const MapLegendHeader = /*#__PURE__*/styled(LegendSectionHeader)(_templateObject3$5 || (_templateObject3$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0;\n"])));
4884
- const MapLegendSection = /*#__PURE__*/styled.div(_templateObject4$4 || (_templateObject4$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n"])));
4885
- const MapLegendValueDescr = /*#__PURE__*/styled.div(_templateObject5$4 || (_templateObject5$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0.5rem;\n font-size: 0.625rem;\n opacity: 0.65;\n"])));
4863
+ _this.on('edit', _this.updateMeasureResult);
4886
4864
 
4887
- const MAX_SIZE$2 = 100;
4888
- const MapLegendSymbol = _ref => {
4889
- let {
4890
- value,
4891
- parameter
4892
- } = _ref;
4893
- return React.createElement(LegendSymbol, {
4894
- key: value.title,
4895
- parameter: parameter,
4896
- parameterValue: value.parameterValue
4897
- }, symbol => React.createElement(Symbol, {
4898
- render: getMapLegendSymbolRenders,
4899
- symbol: symbol,
4900
- size: MAX_SIZE$2
4901
- }));
4902
- };
4865
+ return _this;
4866
+ }
4903
4867
 
4904
- const DEFAULT_FROM_TO = ['Выше', 'Ниже'];
4905
- const MapLegend = _ref => {
4906
- let {
4907
- layer,
4908
- config,
4909
- fromToTitle = DEFAULT_FROM_TO,
4910
- className
4911
- } = _ref;
4912
- const legend = useMapLegend(layer, config);
4868
+ _createClass(BaseMeasureToolEditor, [{
4869
+ key: "_activate",
4870
+ value: function _activate() {
4871
+ _get(_getPrototypeOf(BaseMeasureToolEditor.prototype), "_activate", this).call(this);
4913
4872
 
4914
- if (!legend) {
4915
- return null;
4916
- }
4873
+ this.addMeasureResultLabel();
4874
+ }
4875
+ }, {
4876
+ key: "addMeasureResultLabel",
4877
+ value: function addMeasureResultLabel() {
4878
+ const measureResult = this.measureResult();
4879
+ if (measureResult === null) return;
4880
+ const {
4881
+ content,
4882
+ position
4883
+ } = measureResult;
4884
+ this.measureResultLabel = new LabelFeature(position, {
4885
+ content,
4886
+ crs: this.map.crs,
4887
+ symbol: createLabelSymbol({
4888
+ onClose: this.removeFeature,
4889
+ renderLabel: this.renderLabelSymbol
4890
+ })
4891
+ });
4892
+ this._tempLayer && this._tempLayer.add(this.measureResultLabel);
4893
+ }
4894
+ }, {
4895
+ key: "updateMeasureResult",
4896
+ value: function updateMeasureResult() {
4897
+ if (this.measureResultLabel) {
4898
+ const measureResult = this.measureResult();
4899
+ if (measureResult === null) return;
4900
+ const {
4901
+ content,
4902
+ position
4903
+ } = measureResult;
4904
+ this.measureResultLabel.content = content;
4905
+ this.measureResultLabel.position = position;
4906
+ }
4907
+ }
4908
+ }]);
4917
4909
 
4918
- const {
4919
- symbol,
4920
- item
4921
- } = legend;
4922
- return React.createElement(LegendProvider, {
4923
- symbol: symbol
4924
- }, React.createElement(MapLegendControl, {
4925
- className: className
4926
- }, React.createElement(MapLegendContainer, null, React.createElement(MapLegendHeader, null, item.title), React.createElement(MapLegendSection, null, React.createElement(MapLegendValueDescr, null, fromToTitle[0]), item.values.map(value => React.createElement(MapLegendSymbol, {
4927
- key: value.title,
4928
- value: value,
4929
- parameter: item.parameter
4930
- })), React.createElement(MapLegendValueDescr, null, fromToTitle[1])))));
4931
- };
4910
+ return BaseMeasureToolEditor;
4911
+ }(PolyEditor);
4932
4912
 
4933
4913
  let MeasureTool = /*#__PURE__*/function (_React$Component) {
4934
4914
  _inherits(MeasureTool, _React$Component);
@@ -5118,7 +5098,7 @@ let MeasureTool = /*#__PURE__*/function (_React$Component) {
5118
5098
  }(React.Component);
5119
5099
 
5120
5100
  const _excluded$3 = ["isActive"];
5121
- const Measurer = _ref => {
5101
+ const Measurer = (_ref) => {
5122
5102
  let {
5123
5103
  isActive
5124
5104
  } = _ref,
@@ -5136,18 +5116,18 @@ const Measurer = _ref => {
5136
5116
 
5137
5117
  var _templateObject$7, _templateObject2$6, _templateObject3$6;
5138
5118
  const ScaleRulerContainer = /*#__PURE__*/styled.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"])));
5139
- const ScaleRulerBlock = /*#__PURE__*/styled.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 => {
5119
+ const ScaleRulerBlock = /*#__PURE__*/styled.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) => {
5140
5120
  let {
5141
5121
  width
5142
5122
  } = _ref;
5143
5123
  return width + "px";
5144
5124
  });
5145
- const TextContainer = /*#__PURE__*/styled.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 => {
5125
+ const TextContainer = /*#__PURE__*/styled.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) => {
5146
5126
  let {
5147
5127
  alignEnd
5148
5128
  } = _ref2;
5149
5129
  return alignEnd ? 'flex-end' : 'center';
5150
- }, _ref3 => {
5130
+ }, (_ref3) => {
5151
5131
  let {
5152
5132
  width
5153
5133
  } = _ref3;
@@ -5172,7 +5152,7 @@ const ScaleRuler = () => {
5172
5152
  }, currentScale >= 1000 ? currentScale / 1000 + "km" : currentScale + "m")));
5173
5153
  };
5174
5154
 
5175
- const Zoom = _ref => {
5155
+ const Zoom = (_ref) => {
5176
5156
  let {
5177
5157
  children
5178
5158
  } = _ref;
@@ -5221,7 +5201,7 @@ const placementMixin$1 = function placementMixin(placement, distance, cornerSize
5221
5201
  return 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));
5222
5202
  };
5223
5203
  const corner = /*#__PURE__*/css(_templateObject10$1 || (_templateObject10$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n &:before {\n content: '';\n width: 0;\n height: 0;\n position: absolute;\n }\n"])));
5224
- const TooltipComponent = /*#__PURE__*/styled.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 => {
5204
+ const TooltipComponent = /*#__PURE__*/styled.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) => {
5225
5205
  let {
5226
5206
  placement,
5227
5207
  distance = '0.5rem',
@@ -5229,7 +5209,7 @@ const TooltipComponent = /*#__PURE__*/styled.div(_templateObject11$1 || (_templa
5229
5209
  cornerSize = '0.25rem'
5230
5210
  } = _ref;
5231
5211
  return placementMixin$1(placement, distance, withArrow ? cornerSize : null);
5232
- }, _ref2 => {
5212
+ }, (_ref2) => {
5233
5213
  let {
5234
5214
  withArrow
5235
5215
  } = _ref2;
@@ -5243,7 +5223,7 @@ const {
5243
5223
  Consumer
5244
5224
  } = /*#__PURE__*/createContext([]); // TODO I just cant read that
5245
5225
 
5246
- const Tooltip = _ref => {
5226
+ const Tooltip = (_ref) => {
5247
5227
  let {
5248
5228
  features = [],
5249
5229
  map,
@@ -5282,7 +5262,7 @@ const Noop = () => React.createElement("div", {
5282
5262
  }
5283
5263
  });
5284
5264
 
5285
- const DraggableMarker = _ref => {
5265
+ const DraggableMarker = (_ref) => {
5286
5266
  let {
5287
5267
  position,
5288
5268
  onChange,
@@ -5296,5 +5276,20 @@ const DraggableMarker = _ref => {
5296
5276
  return React.createElement(Fragment, null);
5297
5277
  };
5298
5278
 
5279
+ const polygonCircleFromPoint = (center, diameter) => {
5280
+ const coordinates = [];
5281
+ const radius = diameter / 2;
5282
+ const endAngle = Math.PI * 2;
5283
+ const step = Math.max(Math.PI / 2 / radius, endAngle / 128);
5284
+ let start = 0;
5285
+ let end = endAngle;
5286
+
5287
+ for (let ang = start; ang < end; ang += step) {
5288
+ coordinates.push([Math.cos(ang) * radius + center[0], Math.sin(ang) * radius + center[1]]);
5289
+ }
5290
+
5291
+ return [coordinates];
5292
+ };
5293
+
5299
5294
  export { ArrowLineMiterRender, BaseMeasureToolCreator, BaseMeasureToolEditor, CRS_MAP, CardAttributes, CardHeader, CircleLineMiterRender, ClassificationCondition, ClassificationManager, ClusterLayer, CompoundIcon, DEFAULT_CRS, DEFAULT_SRID, DEFAULT_SYMBOL_SIZE, DraggableMarker, EvergisCard, EvergisCardAttribute, AttributeContainer as EvergisCardAttributeContainer, AttributeTitle as EvergisCardAttributeTitle, AttributeValueContainer as EvergisCardAttributeValueContainer, CardControls as EvergisCardCardControls, CardTitle as EvergisCardCardTitle, CloseIcon as EvergisCardCloseIcon, EvergisCardContainer, CurrentFeatureIndex as EvergisCardCurrentFeatureIndex, FeatureName as EvergisCardFeatureName, LayerName as EvergisCardLayerName, NextIcon as EvergisCardNextIcon, CardPagination as EvergisCardPagination, PaginationDescription as EvergisCardPaginationDescription, PrevIcon as EvergisCardPrevIcon, SimpleAttribute as EvergisCardSimpleValue, StickyHeader as EvergisCardStickyHeader, ValueLink as EvergisCardValueLink, ZoomIcon as EvergisCardZoomIcon, EvergisDynamicLayer, EvergisFeature, EvergisLayer, EvergisProvider, EvergisSelect, EvergisSelectLayer, EvergisSelectProvider, EvergisStyle, EvergisTileLayer, FeatureLayer, Fullscreen, LabelSymbol, Legend, LegendContainer, LegendProvider, LegendSection, LegendSectionContainer, LegendSymbol, LegendValue, LegendValueContainer, LineMiterKind, LineMiterRender, Map, MapControl, MapControls, MapLegend, MapLegendContainer, MapLegendHeader, MapLegendSection, MapLegendSymbol, MapProvider, Measure, MeasureTool, Measurer, NO_CONTENT_VALUE, Noop, PREVIEW_LIMITS, SGisBrushFill, SGisImageFill, SGisPolygonSymbol, SGisPolylineSymbol, SOLID_INTERVALS, SVGPoly, ScaleRuler, ScaleRulerBlock, ScaleRulerContainer, Search, SelectedPointSymbol, SelectedPolySymbol, ShadowedPointSymbol, ShadowedPolySymbol, SquareLineMiterRender, SrId, StyleSymbol, Symbol, TextContainer, TileLayer, Tooltip, TooltipComponent, TooltipProvider, Zoom, ZoomLevel, adjustSymbol, applyParameterValue, clamp, copyRings, createCompositeSymbol, createLabelSymbol, createStyleLegend, createValueTitle, defaultOffset, defineStrokeStylePreset, deserializeSymbol, evaluateFeature, extractStyle, extractSymbol, findChildFeatureStyle, findChildFeatureSymbol, formatArea, formatAttributeValue, formatLength, formatPolygonMeasure, getAttributeNameFromClassified, getAttributeNameFromCondition, getChildSymbols, getCrs, getDashStylePreset, getFeatureSymbol, getLegendSymbolRenders, getLineDash, getLineMiterRender, getMapLegendSymbolRenders, getMapState, getParameterValue, getScale, getSymbolRenders, isArrowLineMiter, isCalculatedParameter, isCircleLineMiter, isCompositeSymbol, isDashedBrush, isFilledLineMitter, isHatchBrush, isImageSymbol, isLabelSymbol, isMaskedImageSymbol, isMiterExist, isParameterByAttribute, isParameterValueSimple, isParameterValueSymbol, isPatternBrush, isPointLabelSymbol, isPointSymbol, isPolygonHasHatchBrush, isPolygonHasPatternBrush, isPolygonLabelSymbol, isPolygonSymbol, isPolylineLabelSymbol, isPolylineLikePolygon, isPolylineSymbol, isPolylineSymbols, isRangeClass, isRasterSymbol, isSGisImageSymbol, isSGisPointSymbol, isSGisPolygonSymbol, isSGisPolylineSymbol, isScalablePolylineSymbol, isSimpleOffset, isSimplePolylineSymbol, isSimpleSymbol, isSizableSymbol, isSolidBrush, isSquareLineMiter, isSquareSymbol, isStaticImageSymbol, isStringParameterValue, isStrokeStyledSymbol, isStyle, isSymbolWithOffset, isTwoDimensionalSymbol, isUniqueClass, measureAreaSymbol, measureLengthSymbol, measurePolygonSnapSymbol, metersToPixels, numberWithSpaces, packStyle, polygonCircleFromPoint, printRangeClass, renderSymbolToCanvas, selectedPoint, selectedPolygon, selectedPolyline, setDefaultParameterValue, setParameterValue, shouldUpdateMapState, solidStrokeStylePreset, strokeStylePresets, symbolParameterWalker, symbolTypeGuard, toIntervals, toLineDash, unClassify, updateMapResolution, useCanvas, useClusterLayer, useCrs, useDebouncedCallback, useDraggableMarker, useEventPoint, useEvergisContext, useEvergisDynamicLayer, useEvergisSelect, useEvergisSelectContext, useEvergisTileLayer, useFeatureLayer, useLayerLegend, useLayerOrder, useLayerVisibility, useLegend, useLegendContext, useLegendValueSymbol, useMapBboxChange, useMapContext, useMapLegend, useMapLevel, useMapPick, useMapState, useMapView, useMapViewActions, useMapWrapper, useMaxMinScale, useMetersToPixels, useMetersToPixelsCb, useMount, useProperty, useScale, useSymbol, useTooltip, useTooltipContext, useUpdate, useUpdateMapView };
5300
5295
  //# sourceMappingURL=react.esm.js.map