@evergis/react 2.0.72 → 2.0.75
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/LICENSE +20 -20
- package/README.md +29 -29
- package/dist/components/EvergisCard/MailValue.d.ts +1 -0
- package/dist/components/EvergisCard/PhoneValue.d.ts +1 -0
- package/dist/components/EvergisCard/UrlValue.d.ts +1 -0
- package/dist/components/MapControls/Fullscreen.d.ts +1 -0
- package/dist/components/MapControls/Measure.d.ts +1 -0
- package/dist/components/MapControls/Search.d.ts +1 -0
- package/dist/components/Noop/index.d.ts +1 -0
- package/dist/core/classification/types.d.ts +2 -2
- package/dist/react.cjs.development.js +1900 -1905
- package/dist/react.cjs.development.js.map +1 -1
- package/dist/react.cjs.production.min.js +1 -1
- package/dist/react.cjs.production.min.js.map +1 -1
- package/dist/react.esm.js +1901 -1906
- package/dist/react.esm.js.map +1 -1
- package/package.json +10 -10
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
|
|
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(
|
|
201
|
+
return desc.get.call(receiver);
|
|
210
202
|
}
|
|
211
203
|
|
|
212
204
|
return desc.value;
|
|
213
205
|
};
|
|
214
206
|
}
|
|
215
207
|
|
|
216
|
-
return _get
|
|
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
|
-
|
|
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 + "
|
|
968
|
+
return to + " " + (isDate ? 'и до' : 'и менее');
|
|
974
969
|
}
|
|
975
970
|
|
|
976
971
|
if (to === null) {
|
|
977
|
-
return "
|
|
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
|
-
|
|
1573
|
-
|
|
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
|
-
|
|
1585
|
-
var _this;
|
|
1570
|
+
var _super = /*#__PURE__*/_createSuper(CircleLineMiterRender);
|
|
1586
1571
|
|
|
1587
|
-
|
|
1572
|
+
function CircleLineMiterRender() {
|
|
1573
|
+
_classCallCheck(this, CircleLineMiterRender);
|
|
1588
1574
|
|
|
1589
|
-
|
|
1575
|
+
return _super.apply(this, arguments);
|
|
1576
|
+
}
|
|
1590
1577
|
|
|
1591
|
-
|
|
1592
|
-
|
|
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
|
-
|
|
1596
|
-
|
|
1597
|
-
_this.formatters = params.formatters || DEFAULT_FORMATTERS;
|
|
1598
|
-
_this.areaSymbol = params.areaSymbol;
|
|
1602
|
+
return CircleLineMiterRender;
|
|
1603
|
+
}(LineMiterRender);
|
|
1599
1604
|
|
|
1600
|
-
|
|
1605
|
+
let SquareLineMiterRender = /*#__PURE__*/function (_LineMiterRender) {
|
|
1606
|
+
_inherits(SquareLineMiterRender, _LineMiterRender);
|
|
1601
1607
|
|
|
1608
|
+
var _super = /*#__PURE__*/_createSuper(SquareLineMiterRender);
|
|
1602
1609
|
|
|
1603
|
-
|
|
1610
|
+
function SquareLineMiterRender() {
|
|
1611
|
+
_classCallCheck(this, SquareLineMiterRender);
|
|
1604
1612
|
|
|
1605
|
-
return
|
|
1613
|
+
return _super.apply(this, arguments);
|
|
1606
1614
|
}
|
|
1607
1615
|
|
|
1608
|
-
_createClass(
|
|
1609
|
-
key: "
|
|
1610
|
-
|
|
1611
|
-
|
|
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: "
|
|
1617
|
-
value: function
|
|
1618
|
-
|
|
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: "
|
|
1625
|
-
value: function
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
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
|
-
|
|
1645
|
-
|
|
1646
|
-
this.fire(new DrawingFinishEvent(feature, new MouseEvent('mouseup')));
|
|
1647
|
-
return;
|
|
1648
|
-
}
|
|
1643
|
+
return SquareLineMiterRender;
|
|
1644
|
+
}(LineMiterRender);
|
|
1649
1645
|
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
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
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
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
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1719
|
-
|
|
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
|
-
|
|
1798
|
-
|
|
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
|
-
|
|
1804
|
-
|
|
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
|
-
|
|
1807
|
-
_inherits(BaseMeasureToolEditor, _PolyEditor);
|
|
1721
|
+
var _super = /*#__PURE__*/_createSuper(SGisPolylineSymbol);
|
|
1808
1722
|
|
|
1809
|
-
|
|
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,
|
|
1728
|
+
_classCallCheck(this, SGisPolylineSymbol);
|
|
1815
1729
|
|
|
1816
|
-
_this = _super.call(this,
|
|
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
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
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
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
const
|
|
1828
|
-
const
|
|
1829
|
-
const
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
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
|
-
|
|
1838
|
-
|
|
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
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
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
|
-
|
|
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(
|
|
1853
|
-
key: "
|
|
1854
|
-
value: function
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
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: "
|
|
1861
|
-
value: function
|
|
1862
|
-
|
|
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: "
|
|
1880
|
-
value: function
|
|
1881
|
-
if (
|
|
1882
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
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
|
-
|
|
1921
|
-
|
|
1922
|
-
}
|
|
1856
|
+
return LabelSymbol;
|
|
1857
|
+
}(DynamicPointSymbol);
|
|
1923
1858
|
|
|
1924
|
-
|
|
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
|
-
|
|
1928
|
-
|
|
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
|
-
|
|
1923
|
+
let ShadowedPointSymbol = /*#__PURE__*/function (_PointSymbol) {
|
|
1924
|
+
_inherits(ShadowedPointSymbol, _PointSymbol);
|
|
1931
1925
|
|
|
1932
|
-
|
|
1933
|
-
_classCallCheck(this, CircleLineMiterRender);
|
|
1926
|
+
var _super = /*#__PURE__*/_createSuper(ShadowedPointSymbol);
|
|
1934
1927
|
|
|
1935
|
-
|
|
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(
|
|
1939
|
-
key: "
|
|
1940
|
-
|
|
1941
|
-
|
|
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: "
|
|
1945
|
-
value: function
|
|
1946
|
-
|
|
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: "
|
|
1951
|
-
value: function
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
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: "
|
|
1983
|
-
value: function
|
|
1984
|
-
let
|
|
1985
|
-
|
|
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: "
|
|
1989
|
-
value: function
|
|
1990
|
-
const
|
|
1991
|
-
|
|
1992
|
-
|
|
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
|
|
2004
|
-
}(
|
|
1998
|
+
return ShadowedPointSymbol;
|
|
1999
|
+
}(PointSymbol);
|
|
2005
2000
|
|
|
2006
|
-
|
|
2007
|
-
|
|
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
|
-
|
|
2013
|
-
case LineMiterKind.FilledSquare:
|
|
2014
|
-
return new SquareLineMiterRender(options);
|
|
2004
|
+
var _super = /*#__PURE__*/_createSuper(ShadowedPolySymbol);
|
|
2015
2005
|
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2006
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
2007
|
+
function ShadowedPolySymbol(options) {
|
|
2008
|
+
_classCallCheck(this, ShadowedPolySymbol);
|
|
2019
2009
|
|
|
2020
|
-
|
|
2021
|
-
return null;
|
|
2010
|
+
return _super.call(this, options);
|
|
2022
2011
|
}
|
|
2023
|
-
};
|
|
2024
2012
|
|
|
2025
|
-
|
|
2026
|
-
|
|
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
|
-
|
|
2029
|
-
|
|
2023
|
+
if (shadowRender) {
|
|
2024
|
+
renders = [shadowRender, polyRender];
|
|
2025
|
+
}
|
|
2030
2026
|
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
const nextCoordinates = reversedRing[i - 1];
|
|
2027
|
+
if (vertexRenders) {
|
|
2028
|
+
renders = renders.concat(vertexRenders);
|
|
2029
|
+
}
|
|
2036
2030
|
|
|
2037
|
-
|
|
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
|
|
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
|
-
|
|
2046
|
-
|
|
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
|
-
|
|
2052
|
-
newRing[i] = [coordinates[0] + miterSize, coordinates[1]];
|
|
2053
|
-
}
|
|
2112
|
+
var _super = /*#__PURE__*/_createSuper(SelectedPointSymbol);
|
|
2054
2113
|
|
|
2055
|
-
|
|
2114
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
2115
|
+
function SelectedPointSymbol(props) {
|
|
2116
|
+
_classCallCheck(this, SelectedPointSymbol);
|
|
2056
2117
|
|
|
2057
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2142
|
+
return SelectedPointSymbol;
|
|
2143
|
+
}(ShadowedPointSymbol);
|
|
2082
2144
|
|
|
2083
|
-
|
|
2084
|
-
|
|
2145
|
+
let SelectedPolySymbol = /*#__PURE__*/function (_ShadowedPolySymbol) {
|
|
2146
|
+
_inherits(SelectedPolySymbol, _ShadowedPolySymbol);
|
|
2085
2147
|
|
|
2086
|
-
|
|
2148
|
+
var _super = /*#__PURE__*/_createSuper(SelectedPolySymbol);
|
|
2087
2149
|
|
|
2088
|
-
|
|
2150
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
2151
|
+
function SelectedPolySymbol(props) {
|
|
2152
|
+
_classCallCheck(this, SelectedPolySymbol);
|
|
2089
2153
|
|
|
2090
|
-
|
|
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(
|
|
2105
|
-
key: "
|
|
2106
|
-
value: function
|
|
2107
|
-
if (
|
|
2108
|
-
|
|
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: "
|
|
2155
|
-
value: function
|
|
2156
|
-
|
|
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
|
-
|
|
2169
|
-
|
|
2169
|
+
if (feature.isSelected) {
|
|
2170
|
+
polyRender.fillColor = this.selectedFillColor;
|
|
2171
|
+
polyRender.strokeColor = this.selectedStrokeColor;
|
|
2170
2172
|
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2173
|
+
if (this.selectedStrokeWidth !== void 0) {
|
|
2174
|
+
polyRender.strokeWidth = this.selectedStrokeWidth;
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2175
2177
|
|
|
2176
|
-
|
|
2178
|
+
return polyRender;
|
|
2179
|
+
}
|
|
2180
|
+
}]);
|
|
2177
2181
|
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
});
|
|
2181
|
-
_this.component = component;
|
|
2182
|
-
return _this;
|
|
2183
|
-
}
|
|
2182
|
+
return SelectedPolySymbol;
|
|
2183
|
+
}(ShadowedPolySymbol);
|
|
2184
2184
|
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
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
|
|
2220
|
-
|
|
2214
|
+
const metersToPixels = (meters, _ref) => {
|
|
2215
|
+
let {
|
|
2216
|
+
painter,
|
|
2217
|
+
crs = geo
|
|
2218
|
+
} = _ref;
|
|
2221
2219
|
const {
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
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
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
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
|
-
|
|
2284
|
-
_inherits(ShadowedPointSymbol, _PointSymbol);
|
|
2237
|
+
var _super = /*#__PURE__*/_createSuper(SVGPoly);
|
|
2285
2238
|
|
|
2286
|
-
|
|
2239
|
+
function SVGPoly(_temp) {
|
|
2240
|
+
var _this;
|
|
2287
2241
|
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2242
|
+
let {
|
|
2243
|
+
redrawFeatureNode,
|
|
2244
|
+
pathStyles,
|
|
2245
|
+
circle,
|
|
2246
|
+
className,
|
|
2247
|
+
appendToSvg
|
|
2248
|
+
} = _temp === void 0 ? {} : _temp;
|
|
2291
2249
|
|
|
2292
|
-
|
|
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(
|
|
2266
|
+
_createClass(SVGPoly, [{
|
|
2296
2267
|
key: "renderFunction",
|
|
2297
2268
|
value: function renderFunction(feature, resolution, crs) {
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
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: "
|
|
2335
|
-
value: function
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
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: "
|
|
2351
|
-
value: function
|
|
2352
|
-
|
|
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
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
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 (
|
|
2384
|
-
|
|
2352
|
+
if (this.circle) {
|
|
2353
|
+
svgRender._setArcNode();
|
|
2354
|
+
} else {
|
|
2355
|
+
svgRender._setPolyNode();
|
|
2385
2356
|
}
|
|
2386
2357
|
|
|
2387
|
-
|
|
2388
|
-
|
|
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
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
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: "
|
|
2406
|
-
value: function
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
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
|
|
2435
|
-
}(
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
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
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
vertexShadowSize: 0
|
|
2440
|
+
const LEGEND_FEATURES = {
|
|
2441
|
+
polyline: lineLegendFeature,
|
|
2442
|
+
polygon: polygonLegendFeature
|
|
2446
2443
|
};
|
|
2447
|
-
const
|
|
2448
|
-
|
|
2449
|
-
|
|
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
|
-
|
|
2470
|
-
|
|
2450
|
+
function getSymbolRenders(symbol, size, features) {
|
|
2451
|
+
if (size === void 0) {
|
|
2452
|
+
size = viewBoxSize;
|
|
2453
|
+
}
|
|
2471
2454
|
|
|
2472
|
-
|
|
2455
|
+
if (features === void 0) {
|
|
2456
|
+
features = {};
|
|
2457
|
+
}
|
|
2473
2458
|
|
|
2474
|
-
|
|
2475
|
-
function SelectedPointSymbol(props) {
|
|
2476
|
-
_classCallCheck(this, SelectedPointSymbol);
|
|
2459
|
+
const resolution = viewBoxSize / size;
|
|
2477
2460
|
|
|
2478
|
-
|
|
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
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
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
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
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
|
-
|
|
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
|
|
2503
|
-
}
|
|
2485
|
+
return getSymbolRenders(symbol, size, LEGEND_FEATURES);
|
|
2486
|
+
};
|
|
2504
2487
|
|
|
2505
|
-
|
|
2506
|
-
|
|
2488
|
+
function renderSymbolToCanvas(renders, canvas) {
|
|
2489
|
+
renders.forEach(render => {
|
|
2490
|
+
canvas.draw(render);
|
|
2491
|
+
});
|
|
2492
|
+
}
|
|
2507
2493
|
|
|
2508
|
-
|
|
2494
|
+
function deserializeSymbol(symbol) {
|
|
2495
|
+
switch (symbol.type) {
|
|
2496
|
+
case 'circlePointSymbol':
|
|
2497
|
+
return deserializePointSymbol(symbol);
|
|
2509
2498
|
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
_classCallCheck(this, SelectedPolySymbol);
|
|
2499
|
+
case 'squarePointSymbol':
|
|
2500
|
+
return deserializeSquareSymbol(symbol);
|
|
2513
2501
|
|
|
2514
|
-
|
|
2515
|
-
|
|
2502
|
+
case 'maskedImagePointSymbol':
|
|
2503
|
+
return deserializeMaskedImageSymbol(symbol);
|
|
2516
2504
|
|
|
2517
|
-
|
|
2518
|
-
|
|
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
|
-
|
|
2530
|
-
|
|
2531
|
-
polyRender.strokeColor = this.selectedStrokeColor;
|
|
2508
|
+
case 'polygonSymbol':
|
|
2509
|
+
return deserializePolygonSymbol(symbol);
|
|
2532
2510
|
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
}
|
|
2511
|
+
case 'simplePolylineSymbol':
|
|
2512
|
+
case 'polylineSymbol':
|
|
2513
|
+
return deserializePolylineSymbol(symbol);
|
|
2537
2514
|
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
}
|
|
2515
|
+
default:
|
|
2516
|
+
return null;
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2541
2519
|
|
|
2542
|
-
|
|
2543
|
-
|
|
2520
|
+
function deserializePointSymbol(symbol) {
|
|
2521
|
+
// @ts-ignore
|
|
2522
|
+
return new PointSymbol(deserializePointSymbolParams(symbol));
|
|
2523
|
+
}
|
|
2544
2524
|
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
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
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2585
|
-
|
|
2566
|
+
function deserializePolygonSymbol(symbol) {
|
|
2567
|
+
if (isPolygonHasPatternBrush(symbol)) {
|
|
2568
|
+
return new SGisImageFill(symbol);
|
|
2569
|
+
}
|
|
2586
2570
|
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
circle,
|
|
2591
|
-
className,
|
|
2592
|
-
appendToSvg
|
|
2593
|
-
} = _temp === void 0 ? {} : _temp;
|
|
2571
|
+
if (isPolygonHasHatchBrush(symbol)) {
|
|
2572
|
+
return new SGisBrushFill(symbol);
|
|
2573
|
+
}
|
|
2594
2574
|
|
|
2595
|
-
|
|
2575
|
+
return new SGisPolygonSymbol(symbol);
|
|
2576
|
+
}
|
|
2596
2577
|
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
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
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
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
|
-
|
|
2599
|
+
function deserializeBase64(base) {
|
|
2600
|
+
return "data:image/png;base64," + base;
|
|
2601
|
+
}
|
|
2633
2602
|
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
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
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
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
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
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
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
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
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
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
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
svgRender._setPolyNode();
|
|
2701
|
-
}
|
|
2638
|
+
let EvergisFeature = /*#__PURE__*/function () {
|
|
2639
|
+
function EvergisFeature(feature) {
|
|
2640
|
+
_classCallCheck(this, EvergisFeature);
|
|
2702
2641
|
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
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
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
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
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
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
|
-
|
|
2743
|
-
|
|
2672
|
+
if (!crs) {
|
|
2673
|
+
return null;
|
|
2674
|
+
}
|
|
2744
2675
|
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
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
|
-
|
|
2761
|
-
|
|
2683
|
+
case GeometryType.Multipoint:
|
|
2684
|
+
return new MultiPoint(coordinates, {
|
|
2685
|
+
symbol: selectedPoint,
|
|
2686
|
+
crs
|
|
2687
|
+
});
|
|
2762
2688
|
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
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
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2695
|
+
case GeometryType.Polygon:
|
|
2696
|
+
return new Polygon(coordinates, {
|
|
2697
|
+
symbol: selectedPolygon,
|
|
2698
|
+
crs
|
|
2699
|
+
});
|
|
2799
2700
|
|
|
2800
|
-
|
|
2801
|
-
|
|
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
|
-
|
|
2713
|
+
return EvergisFeature;
|
|
2714
|
+
}();
|
|
2805
2715
|
|
|
2806
|
-
|
|
2716
|
+
function evaluateCondition(condition, attributes) {
|
|
2717
|
+
try {
|
|
2718
|
+
const evaluator = new ConditionEvaluator(attributes);
|
|
2719
|
+
const result = evaluator.evaluate(condition);
|
|
2807
2720
|
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2721
|
+
if (result instanceof Error) {
|
|
2722
|
+
return null;
|
|
2723
|
+
}
|
|
2811
2724
|
|
|
2812
|
-
|
|
2813
|
-
|
|
2725
|
+
return result;
|
|
2726
|
+
} catch (_unused) {
|
|
2727
|
+
return null;
|
|
2814
2728
|
}
|
|
2729
|
+
}
|
|
2815
2730
|
|
|
2816
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
2834
|
-
|
|
2835
|
-
|
|
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
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2762
|
+
function evaluateFeatureSymbol(attributes) {
|
|
2763
|
+
// @ts-ignore
|
|
2764
|
+
function calc(result, _ref4) {
|
|
2765
|
+
let [parameterName, parameterValue] = _ref4;
|
|
2766
|
+
let newParameterValue;
|
|
2843
2767
|
|
|
2844
|
-
|
|
2845
|
-
|
|
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
|
-
|
|
2848
|
-
|
|
2777
|
+
return newParameterValue !== undefined ? _extends({}, result, {
|
|
2778
|
+
[parameterName]: newParameterValue
|
|
2779
|
+
}) : result;
|
|
2780
|
+
}
|
|
2849
2781
|
|
|
2850
|
-
|
|
2851
|
-
|
|
2782
|
+
return calc;
|
|
2783
|
+
}
|
|
2852
2784
|
|
|
2853
|
-
|
|
2854
|
-
|
|
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
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2793
|
+
if (condition && attributeName && attributeValue !== undefined) {
|
|
2794
|
+
return evaluateCondition(condition, {
|
|
2795
|
+
[attributeName]: attributeValue
|
|
2796
|
+
});
|
|
2797
|
+
}
|
|
2859
2798
|
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
}
|
|
2799
|
+
return false;
|
|
2800
|
+
}) || null;
|
|
2863
2801
|
}
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
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
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
angle: getParameterValue(symbol.angle)
|
|
2874
|
-
}));
|
|
2875
|
-
}
|
|
2811
|
+
if (style.children !== null) {
|
|
2812
|
+
return findChildFeatureSymbol(style.children, attributes) || style.symbol;
|
|
2813
|
+
}
|
|
2876
2814
|
|
|
2877
|
-
|
|
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
|
|
2897
|
-
|
|
2898
|
-
|
|
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
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
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
|
-
|
|
2917
|
-
|
|
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
|
|
2921
|
-
}
|
|
2859
|
+
return EvergisLayer;
|
|
2860
|
+
}();
|
|
2922
2861
|
|
|
2923
|
-
|
|
2924
|
-
return new SGisPolylineSymbol(symbol);
|
|
2925
|
-
}
|
|
2862
|
+
const findFeatureLayer = feature => layer => layer.name === feature.layerName;
|
|
2926
2863
|
|
|
2927
|
-
|
|
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
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
fillColor
|
|
2872
|
+
attributes,
|
|
2873
|
+
renderTitle,
|
|
2874
|
+
skipDefaultValue,
|
|
2875
|
+
reverse
|
|
2934
2876
|
} = _ref;
|
|
2935
|
-
return {
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
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
|
|
2945
|
-
|
|
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
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
}
|
|
2919
|
+
if (items.length === 0) {
|
|
2920
|
+
return null;
|
|
2921
|
+
}
|
|
2952
2922
|
|
|
2953
|
-
|
|
2954
|
-
|
|
2923
|
+
return {
|
|
2924
|
+
symbol: unClassify(symbol),
|
|
2925
|
+
items: items.map(createLegendItem(config))
|
|
2926
|
+
};
|
|
2955
2927
|
}
|
|
2956
2928
|
|
|
2957
|
-
|
|
2958
|
-
if (
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
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
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
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
|
|
2948
|
+
return numberWithSpaces(result) + " " + measure;
|
|
2975
2949
|
}
|
|
2976
|
-
|
|
2977
|
-
let
|
|
2978
|
-
|
|
2979
|
-
} = _ref;
|
|
2980
|
-
return centerAlignSymbol(clampSymbol(symbol, 0, size));
|
|
2981
|
-
};
|
|
2950
|
+
function formatLength(num) {
|
|
2951
|
+
let result = num;
|
|
2952
|
+
let measure = 'м';
|
|
2982
2953
|
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2954
|
+
if (num > 10000) {
|
|
2955
|
+
result = num / 1000;
|
|
2956
|
+
measure = 'км';
|
|
2957
|
+
}
|
|
2986
2958
|
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
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
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
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
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
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 (
|
|
3018
|
-
return
|
|
2983
|
+
if (result > scale) {
|
|
2984
|
+
return result;
|
|
3019
2985
|
}
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
3020
2988
|
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
return new PointFeature(coordinates, {
|
|
3024
|
-
symbol: selectedPoint,
|
|
3025
|
-
crs
|
|
3026
|
-
});
|
|
2989
|
+
return 1;
|
|
2990
|
+
}
|
|
3027
2991
|
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
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
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
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
|
-
|
|
3041
|
-
|
|
3042
|
-
symbol: selectedPolygon,
|
|
3043
|
-
crs
|
|
3044
|
-
});
|
|
3014
|
+
const useMapLegend = (layer, config) => {
|
|
3015
|
+
const legend = useLayerLegend(layer, config);
|
|
3045
3016
|
|
|
3046
|
-
|
|
3047
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3064
|
-
|
|
3040
|
+
sGisSymbol = valueSymbol && deserializeSymbol(valueSymbol);
|
|
3041
|
+
} catch (e) {}
|
|
3065
3042
|
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3043
|
+
return sGisSymbol && adjustSymbol(sGisSymbol, {
|
|
3044
|
+
size: LEGEND_SYMBOL_MAX_SIZE - 1
|
|
3045
|
+
});
|
|
3046
|
+
};
|
|
3069
3047
|
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3087
|
-
|
|
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
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
}
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
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
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
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
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
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
|
-
|
|
3123
|
-
|
|
3124
|
-
}) : result;
|
|
3106
|
+
if (deps === void 0) {
|
|
3107
|
+
deps = [];
|
|
3125
3108
|
}
|
|
3126
3109
|
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
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
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
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
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
};
|
|
3136
|
+
return propRef.current; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3137
|
+
}, deps);
|
|
3138
|
+
}
|
|
3213
3139
|
|
|
3214
|
-
|
|
3215
|
-
const createLegendItem = _ref => {
|
|
3140
|
+
function useUpdate(_ref) {
|
|
3216
3141
|
let {
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
reverse
|
|
3142
|
+
onUpdate,
|
|
3143
|
+
shouldUpdate,
|
|
3144
|
+
deps
|
|
3221
3145
|
} = _ref;
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
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
|
-
|
|
3269
|
-
symbol: unClassify(symbol),
|
|
3270
|
-
items: items.map(createLegendItem(config))
|
|
3271
|
-
};
|
|
3151
|
+
}, deps);
|
|
3272
3152
|
}
|
|
3273
3153
|
|
|
3274
|
-
function
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
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
|
|
3282
|
-
|
|
3283
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
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
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
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
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
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
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
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
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
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
|
-
|
|
4813
|
+
if (wrapper && typeof wrapper !== 'string') {
|
|
4814
|
+
wrapper.style.cursor = cursor;
|
|
4815
|
+
}
|
|
4816
|
+
}
|
|
4817
|
+
}]);
|
|
4794
4818
|
|
|
4795
|
-
|
|
4819
|
+
return BaseMeasureToolCreator;
|
|
4820
|
+
}(PolylineControl);
|
|
4796
4821
|
|
|
4797
|
-
|
|
4822
|
+
let BaseMeasureToolEditor = /*#__PURE__*/function (_PolyEditor) {
|
|
4823
|
+
_inherits(BaseMeasureToolEditor, _PolyEditor);
|
|
4798
4824
|
|
|
4799
|
-
|
|
4800
|
-
if (placement === void 0) {
|
|
4801
|
-
placement = 'bottom-left';
|
|
4802
|
-
}
|
|
4825
|
+
var _super = /*#__PURE__*/_createSuper(BaseMeasureToolEditor);
|
|
4803
4826
|
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
}
|
|
4827
|
+
function BaseMeasureToolEditor(map, painter, params) {
|
|
4828
|
+
var _this;
|
|
4807
4829
|
|
|
4808
|
-
|
|
4809
|
-
};
|
|
4830
|
+
_classCallCheck(this, BaseMeasureToolEditor);
|
|
4810
4831
|
|
|
4811
|
-
|
|
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
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
};
|
|
4834
|
-
const
|
|
4835
|
-
const
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
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
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
}));
|
|
4866
|
-
};
|
|
4853
|
+
_this.removeFeature = () => {
|
|
4854
|
+
_this.fire('remove');
|
|
4855
|
+
};
|
|
4867
4856
|
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
}));
|
|
4872
|
-
};
|
|
4857
|
+
_this.painter = painter;
|
|
4858
|
+
_this.renderLabelSymbol = params.renderLabelSymbol;
|
|
4859
|
+
_this.formatters = params.formatters || DEFAULT_FORMATTERS;
|
|
4873
4860
|
|
|
4874
|
-
|
|
4875
|
-
return React.createElement(MapControl, null, React.createElement(FullscreenBtn, {
|
|
4876
|
-
onClick: () => {}
|
|
4877
|
-
}));
|
|
4878
|
-
};
|
|
4861
|
+
_this.on('change', _this.updateMeasureResult);
|
|
4879
4862
|
|
|
4880
|
-
|
|
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
|
-
|
|
4888
|
-
|
|
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
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
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
|
-
|
|
4915
|
-
|
|
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
|
-
|
|
4919
|
-
|
|
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
|