qwc2 2025.10.9 → 2025.10.14
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/actions/display.js +30 -1
- package/actions/editing.js +22 -1
- package/actions/layerinfo.js +13 -1
- package/actions/layers.js +213 -3
- package/actions/localConfig.js +58 -1
- package/actions/locale.js +21 -1
- package/actions/locate.js +26 -1
- package/actions/logging.js +10 -1
- package/actions/map.js +105 -2
- package/actions/measurement.js +12 -1
- package/actions/processNotifications.js +37 -1
- package/actions/redlining.js +18 -1
- package/actions/redliningPick.js +12 -1
- package/actions/search.js +12 -1
- package/actions/serviceinfo.js +12 -1
- package/actions/task.js +55 -3
- package/actions/theme.js +339 -19
- package/actions/windows.js +164 -5
- package/components/AppMenu.js +435 -3
- package/components/AttributeForm.js +928 -32
- package/components/AttributeTableWidget.js +1105 -13
- package/components/AutoEditForm.js +189 -3
- package/components/CoordinateDisplayer.js +78 -2
- package/components/EditComboField.js +190 -6
- package/components/EditUploadField.js +315 -3
- package/components/ExportSelection.js +203 -2
- package/components/FullscreenSwitcher.js +90 -3
- package/components/Icon.js +81 -2
- package/components/IdentifyViewer.js +1161 -6
- package/components/ImportLayer.js +718 -20
- package/components/LayerInfoWindow.js +145 -2
- package/components/LinkFeatureForm.js +246 -5
- package/components/MapButton.js +88 -2
- package/components/MapSelection.js +287 -8
- package/components/MessageBar.js +68 -2
- package/components/NumericInputWindow.js +359 -2
- package/components/PickFeature.js +266 -2
- package/components/PluginsContainer.js +227 -8
- package/components/PrintSelection.js +620 -49
- package/components/ProcessNotifications.js +104 -2
- package/components/QtDesignerForm.js +1137 -18
- package/components/ResizeableWindow.js +591 -8
- package/components/SearchBox.js +1307 -20
- package/components/ServiceInfoWindow.js +107 -2
- package/components/SideBar.js +204 -4
- package/components/StandardApp.js +381 -20
- package/components/Swipeable.js +15 -1
- package/components/TaskBar.js +85 -2
- package/components/ThemeLayersListWindow.js +216 -4
- package/components/ThemeList.js +381 -7
- package/components/Toolbar.js +106 -2
- package/components/WindowManager.js +178 -2
- package/components/map/OlLayer.js +257 -6
- package/components/map/OlMap.js +405 -5
- package/components/map/layers/BingLayer.js +31 -2
- package/components/map/layers/GoogleLayer.js +222 -19
- package/components/map/layers/GraticuleLayer.js +21 -1
- package/components/map/layers/ImageLayer.js +15 -1
- package/components/map/layers/MVTLayer.js +52 -2
- package/components/map/layers/OSMLayer.js +24 -2
- package/components/map/layers/OverlayLayer.js +55 -3
- package/components/map/layers/VectorLayer.js +173 -8
- package/components/map/layers/WFSLayer.js +220 -6
- package/components/map/layers/WMSLayer.js +180 -6
- package/components/map/layers/WMTSLayer.js +67 -3
- package/components/map/layers/XYZLayer.js +24 -2
- package/components/map/layers/index.js +28 -1
- package/components/map3d/EditDataset3D.js +190 -3
- package/components/map3d/HeightProfile3D.js +402 -3
- package/components/map3d/ImportObjects3D.js +162 -2
- package/components/map3d/Map3D.js +1304 -38
- package/components/map3d/MapControls3D.js +392 -7
- package/components/map3d/SearchField3D.js +183 -11
- package/components/map3d/View3DSwitcher.js +98 -2
- package/components/map3d/drawtool/CreateTool3D.js +174 -4
- package/components/map3d/drawtool/EditTool3D.js +590 -6
- package/components/map3d/drawtool/NumericInput3D.js +336 -4
- package/components/map3d/layers/GeoTIFFLayer3D.js +15 -1
- package/components/map3d/layers/VectorLayer3D.js +53 -2
- package/components/map3d/layers/WFSLayer3D.js +109 -3
- package/components/map3d/layers/WMSLayer3D.js +70 -2
- package/components/map3d/layers/WMTSLayer3D.js +27 -3
- package/components/map3d/layers/index.js +14 -1
- package/components/map3d/utils/FirstPersonControls3D.js +423 -16
- package/components/map3d/utils/MiscUtils3D.js +221 -13
- package/components/map3d/utils/OrbitControls3D.js +176 -5
- package/components/map3d/utils/Tiles3DStyle.js +238 -9
- package/components/share/ShareLink.js +54 -2
- package/components/share/ShareQRCode.js +62 -2
- package/components/share/ShareSocials.js +125 -3
- package/components/timeline/FixedTimeline.js +236 -5
- package/components/timeline/InfiniteTimeline.js +347 -8
- package/components/timeline/TimelineFeaturesSlider.js +439 -5
- package/components/widgets/AccordeonWidget.js +96 -2
- package/components/widgets/ButtonBar.js +124 -2
- package/components/widgets/ColorButton.js +201 -3
- package/components/widgets/ComboBox.js +166 -2
- package/components/widgets/CopyButton.js +110 -2
- package/components/widgets/DateTimeInput.js +100 -3
- package/components/widgets/EditableSelect.js +230 -3
- package/components/widgets/FileSelector.js +128 -4
- package/components/widgets/Input.js +124 -2
- package/components/widgets/InputContainer.js +96 -2
- package/components/widgets/LayerCatalogWidget.js +219 -3
- package/components/widgets/MenuButton.js +157 -1
- package/components/widgets/ModalDialog.js +64 -2
- package/components/widgets/NavBar.js +119 -2
- package/components/widgets/NumberInput.js +226 -4
- package/components/widgets/PopupMenu.js +72 -1
- package/components/widgets/Primitives.js +6 -1
- package/components/widgets/ReCaptchaWidget.js +55 -1
- package/components/widgets/SearchWidget.js +255 -2
- package/components/widgets/Spinner.js +44 -2
- package/components/widgets/SuggestionInput.js +77 -2
- package/components/widgets/TextInput.js +308 -2
- package/components/widgets/ToggleSwitch.js +85 -2
- package/components/widgets/VectorLayerPicker.js +85 -3
- package/libs/openlayers.js +225 -5
- package/package.json +1 -1
- package/plugins/API.js +358 -15
- package/plugins/AttributeTable.js +109 -3
- package/plugins/Authentication.js +130 -5
- package/plugins/BackgroundSwitcher.js +218 -4
- package/plugins/Bookmark.js +289 -3
- package/plugins/BottomBar.js +298 -4
- package/plugins/CookiePopup.js +67 -3
- package/plugins/Cyclomedia.js +442 -5
- package/plugins/Editing.js +497 -9
- package/plugins/FeatureForm.js +366 -4
- package/plugins/FeatureSearch.js +458 -3
- package/plugins/GeometryDigitizer.js +664 -7
- package/plugins/HeightProfile.js +763 -15
- package/plugins/Help.js +102 -3
- package/plugins/HomeButton.js +80 -3
- package/plugins/Identify.js +543 -5
- package/plugins/LayerCatalog.js +215 -4
- package/plugins/LayerTree.js +1194 -6
- package/plugins/LocateButton.js +94 -3
- package/plugins/Map.js +320 -16
- package/plugins/MapCompare.js +94 -3
- package/plugins/MapCopyright.js +127 -5
- package/plugins/MapExport.js +613 -20
- package/plugins/MapFilter.js +868 -12
- package/plugins/MapInfoTooltip.js +277 -3
- package/plugins/MapLegend.js +253 -4
- package/plugins/MapTip.js +290 -4
- package/plugins/Measure.js +220 -4
- package/plugins/NewsPopup.js +137 -3
- package/plugins/OverviewMap.js +167 -7
- package/plugins/Panoramax.js +340 -2
- package/plugins/Portal.js +199 -4
- package/plugins/Print.js +1231 -15
- package/plugins/Redlining.js +750 -6
- package/plugins/Reports.js +332 -3
- package/plugins/Routing.js +1278 -15
- package/plugins/ScratchDrawing.js +173 -5
- package/plugins/Settings.js +241 -4
- package/plugins/Share.js +198 -3
- package/plugins/StartupMarker.js +84 -4
- package/plugins/TaskButton.js +88 -3
- package/plugins/ThemeSwitcher.js +164 -4
- package/plugins/TimeManager.js +971 -10
- package/plugins/TopBar.js +300 -7
- package/plugins/TourGuide.js +213 -2
- package/plugins/ValueTool.js +419 -4
- package/plugins/View3D.js +519 -14
- package/plugins/ZoomButtons.js +165 -3
- package/plugins/map/EditingSupport.js +199 -7
- package/plugins/map/LocateSupport.js +260 -4
- package/plugins/map/MeasurementSupport.js +216 -8
- package/plugins/map/RedliningPickSupport.js +201 -7
- package/plugins/map/RedliningSupport.js +726 -17
- package/plugins/map/SnapInteraction.js +101 -1
- package/plugins/map/SnapSupport.js +210 -2
- package/plugins/map/SnappingSupport.js +356 -17
- package/plugins/map3d/BackgroundSwitcher3D.js +44 -3
- package/plugins/map3d/BottomBar3D.js +118 -3
- package/plugins/map3d/Compare3D.js +422 -8
- package/plugins/map3d/Draw3D.js +353 -6
- package/plugins/map3d/ExportObjects3D.js +393 -18
- package/plugins/map3d/HideObjects3D.js +313 -12
- package/plugins/map3d/Identify3D.js +283 -12
- package/plugins/map3d/LayerTree3D.js +323 -3
- package/plugins/map3d/MapCopyright3D.js +128 -5
- package/plugins/map3d/MapExport3D.js +590 -10
- package/plugins/map3d/MapLight3D.js +553 -6
- package/plugins/map3d/Measure3D.js +571 -20
- package/plugins/map3d/OverviewMap3D.js +169 -3
- package/plugins/map3d/Settings3D.js +73 -3
- package/plugins/map3d/TopBar3D.js +207 -9
- package/plugins/redlining/RedliningBufferSupport.js +206 -3
- package/reducers/display.js +34 -2
- package/reducers/editing.js +68 -3
- package/reducers/index.js +9 -1
- package/reducers/layerinfo.js +26 -2
- package/reducers/layers.js +456 -9
- package/reducers/localConfig.js +122 -2
- package/reducers/locale.js +38 -2
- package/reducers/locate.js +40 -2
- package/reducers/map.js +176 -5
- package/reducers/measurement.js +42 -2
- package/reducers/processNotifications.js +49 -2
- package/reducers/redlining.js +50 -2
- package/reducers/redliningPick.js +27 -2
- package/reducers/search.js +20 -1
- package/reducers/serviceinfo.js +25 -2
- package/reducers/task.js +45 -2
- package/reducers/theme.js +51 -2
- package/reducers/windows.js +203 -2
- package/scripts/dist.sh +1 -1
- package/scripts/gen-plugin-docs.js +152 -2
- package/scripts/makeIconkit.js +85 -6
- package/scripts/themesConfig.js +742 -40
- package/scripts/updateTranslations.js +251 -10
- package/selectors/searchproviders.js +44 -2
- package/stores/StandardStore.js +42 -2
- package/utils/ConfigUtils.js +84 -3
- package/utils/CoordinatesUtils.js +234 -23
- package/utils/DxfUtils.js +237 -11
- package/utils/EditingInterface.js +421 -87
- package/utils/EditingUtils.js +357 -13
- package/utils/ElevationInterface.js +83 -22
- package/utils/FeatureStyles.js +429 -5
- package/utils/IdentifyUtils.js +443 -7
- package/utils/ImageEditor.js +79 -9
- package/utils/LayerUtils.js +1516 -50
- package/utils/LocaleUtils.js +117 -7
- package/utils/MapUtils.js +241 -59
- package/utils/MeasureUtils.js +323 -2
- package/utils/MiscUtils.js +189 -11
- package/utils/PermaLinkUtils.js +429 -6
- package/utils/PluginStore.js +27 -1
- package/utils/ResourceRegistry.js +15 -1
- package/utils/RoutingInterface.js +307 -7
- package/utils/SearchProviders.js +722 -19
- package/utils/ServiceLayerUtils.js +669 -14
- package/utils/Signal.js +32 -2
- package/utils/ThemeUtils.js +341 -7
- package/utils/VectorLayerUtils.js +589 -15
- package/utils/expr_grammar/grammar.js +2239 -2
- package/utils/expr_grammar/test.js +65 -3
|
@@ -1,23 +1,732 @@
|
|
|
1
|
-
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
5
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
6
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
7
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
8
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
9
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
10
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
11
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
13
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
14
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
15
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
16
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
17
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
18
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
22
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
|
+
/**
|
|
2
24
|
* Copyright 2017-2024 Sourcepole AG
|
|
3
25
|
* All rights reserved.
|
|
4
26
|
*
|
|
5
27
|
* This source code is licensed under the BSD-style license found in the
|
|
6
28
|
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import React from 'react';
|
|
32
|
+
import { connect } from 'react-redux';
|
|
33
|
+
import Mousetrap from 'mousetrap';
|
|
34
|
+
import ol from 'openlayers';
|
|
35
|
+
import PropTypes from 'prop-types';
|
|
36
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
37
|
+
import { LayerRole, addLayerFeatures, removeLayerFeatures } from '../../actions/layers';
|
|
38
|
+
import { changeRedliningState } from '../../actions/redlining';
|
|
39
|
+
import NumericInputWindow from '../../components/NumericInputWindow';
|
|
40
|
+
import { OlLayerAdded, OlLayerUpdated } from '../../components/map/OlLayer';
|
|
41
|
+
import FeatureStyles from '../../utils/FeatureStyles';
|
|
42
|
+
import MapUtils from '../../utils/MapUtils';
|
|
43
|
+
import MeasureUtils from '../../utils/MeasureUtils';
|
|
44
|
+
import VectorLayerUtils from '../../utils/VectorLayerUtils';
|
|
45
|
+
var GeomTypeConfig = {
|
|
46
|
+
Text: {
|
|
47
|
+
drawInteraction: function drawInteraction(opts) {
|
|
48
|
+
return new ol.interaction.Draw(_objectSpread(_objectSpread({}, opts), {}, {
|
|
49
|
+
type: "Point"
|
|
50
|
+
}));
|
|
51
|
+
},
|
|
52
|
+
editTool: 'Pick',
|
|
53
|
+
drawNodes: true
|
|
54
|
+
},
|
|
55
|
+
Point: {
|
|
56
|
+
drawInteraction: function drawInteraction(opts) {
|
|
57
|
+
return new ol.interaction.Draw(_objectSpread(_objectSpread({}, opts), {}, {
|
|
58
|
+
type: "Point"
|
|
59
|
+
}));
|
|
60
|
+
},
|
|
61
|
+
editTool: 'Pick',
|
|
62
|
+
drawNodes: true
|
|
63
|
+
},
|
|
64
|
+
LineString: {
|
|
65
|
+
drawInteraction: function drawInteraction(opts) {
|
|
66
|
+
return new ol.interaction.Draw(_objectSpread(_objectSpread({}, opts), {}, {
|
|
67
|
+
type: "LineString"
|
|
68
|
+
}));
|
|
69
|
+
},
|
|
70
|
+
editTool: 'Pick',
|
|
71
|
+
drawNodes: true
|
|
72
|
+
},
|
|
73
|
+
Polygon: {
|
|
74
|
+
drawInteraction: function drawInteraction(opts) {
|
|
75
|
+
return new ol.interaction.Draw(_objectSpread(_objectSpread({}, opts), {}, {
|
|
76
|
+
type: "Polygon"
|
|
77
|
+
}));
|
|
78
|
+
},
|
|
79
|
+
editTool: 'Pick',
|
|
80
|
+
drawNodes: true
|
|
81
|
+
},
|
|
82
|
+
Circle: {
|
|
83
|
+
drawInteraction: function drawInteraction(opts) {
|
|
84
|
+
return new ol.interaction.Draw(_objectSpread(_objectSpread({}, opts), {}, {
|
|
85
|
+
type: "Circle"
|
|
86
|
+
}));
|
|
87
|
+
},
|
|
88
|
+
editTool: 'Pick',
|
|
89
|
+
drawNodes: true,
|
|
90
|
+
regular: true
|
|
91
|
+
},
|
|
92
|
+
Ellipse: {
|
|
93
|
+
drawInteraction: function drawInteraction(opts) {
|
|
94
|
+
return new ol.interaction.DrawRegular(_objectSpread(_objectSpread({}, opts), {}, {
|
|
95
|
+
sides: 0
|
|
96
|
+
}));
|
|
97
|
+
},
|
|
98
|
+
editTool: 'Transform',
|
|
99
|
+
drawNodes: false
|
|
100
|
+
},
|
|
101
|
+
Box: {
|
|
102
|
+
drawInteraction: function drawInteraction(opts) {
|
|
103
|
+
return new ol.interaction.Draw(_objectSpread(_objectSpread({}, opts), {}, {
|
|
104
|
+
type: "Circle",
|
|
105
|
+
geometryFunction: ol.interaction.createBox()
|
|
106
|
+
}));
|
|
107
|
+
},
|
|
108
|
+
editTool: 'Transform',
|
|
109
|
+
drawNodes: true
|
|
110
|
+
},
|
|
111
|
+
Square: {
|
|
112
|
+
drawInteraction: function drawInteraction(opts) {
|
|
113
|
+
return new ol.interaction.DrawRegular(_objectSpread(_objectSpread({}, opts), {}, {
|
|
114
|
+
sides: 4,
|
|
115
|
+
squareCondition: function squareCondition() {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
}));
|
|
119
|
+
},
|
|
120
|
+
editTool: 'Transform',
|
|
121
|
+
regular: true
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
8
126
|
* Redlining support for the map component.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
_this
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
127
|
+
*/
|
|
128
|
+
var RedliningSupport = /*#__PURE__*/function (_React$Component) {
|
|
129
|
+
function RedliningSupport(props) {
|
|
130
|
+
var _this;
|
|
131
|
+
_classCallCheck(this, RedliningSupport);
|
|
132
|
+
_this = _callSuper(this, RedliningSupport, [props]);
|
|
133
|
+
_defineProperty(_this, "updateCurrentFeature", function (feature) {
|
|
134
|
+
if (_this.currentFeature && _this.props.redlining.selectedFeature) {
|
|
135
|
+
if (feature.circleParams) {
|
|
136
|
+
var circleParams = feature.circleParams;
|
|
137
|
+
_this.currentFeature.setGeometry(new ol.geom.Circle(circleParams.center, circleParams.radius));
|
|
138
|
+
} else {
|
|
139
|
+
_this.currentFeature.getGeometry().setCoordinates(feature.geometry.coordinates);
|
|
140
|
+
}
|
|
141
|
+
_this.props.changeRedliningState({
|
|
142
|
+
selectedFeature: feature,
|
|
143
|
+
geomType: feature.shape
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
_defineProperty(_this, "styleOptions", function (styleProps, isText) {
|
|
148
|
+
return {
|
|
149
|
+
strokeColor: isText ? styleProps.textOutlineColor : styleProps.borderColor,
|
|
150
|
+
strokeWidth: 1 + 0.5 * styleProps.size,
|
|
151
|
+
strokeDash: styleProps.strokeDash,
|
|
152
|
+
fillColor: isText ? styleProps.textFillColor : styleProps.fillColor,
|
|
153
|
+
circleRadius: 5 + styleProps.size,
|
|
154
|
+
headmarker: styleProps.headmarker,
|
|
155
|
+
tailmarker: styleProps.tailmarker
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
_defineProperty(_this, "styleProps", function (feature) {
|
|
159
|
+
var styleOptions = feature.get('styleOptions');
|
|
160
|
+
var label = feature.get("label") || "";
|
|
161
|
+
var isText = feature.get("shape") === "Text";
|
|
162
|
+
return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, isText ? "textOutlineColor" : "borderColor", styleOptions.strokeColor), "strokeDash", styleOptions.strokeDash), "size", (styleOptions.strokeWidth - 1) * 2), isText ? "textFillColor" : "fillColor", styleOptions.fillColor), "text", label), "headmarker", styleOptions.headmarker), "tailmarker", styleOptions.tailmarker);
|
|
163
|
+
});
|
|
164
|
+
_defineProperty(_this, "updateFeatureStyle", function (styleProps) {
|
|
165
|
+
var isText = _this.currentFeature.get("shape") === "Text";
|
|
166
|
+
var styleName = isText ? "text" : "default";
|
|
167
|
+
var opts = _this.styleOptions(styleProps, isText);
|
|
168
|
+
_this.blockOnChange = true;
|
|
169
|
+
_this.currentFeature.set('label', styleProps.text);
|
|
170
|
+
_this.currentFeature.set('styleName', styleName);
|
|
171
|
+
_this.currentFeature.set('styleOptions', opts);
|
|
172
|
+
_this.blockOnChange = false;
|
|
173
|
+
});
|
|
174
|
+
_defineProperty(_this, "styleFunction", function (feature) {
|
|
175
|
+
var styleOptions = feature.get("styleOptions");
|
|
176
|
+
var styleName = feature.get("styleName");
|
|
177
|
+
var styles = [];
|
|
178
|
+
if (styleName === "text") {
|
|
179
|
+
styles.push(_this.selectedTextStyle(feature, styleOptions));
|
|
180
|
+
}
|
|
181
|
+
styles.push.apply(styles, _toConsumableArray(FeatureStyles[styleName](feature, styleOptions)));
|
|
182
|
+
var shape = feature.get('shape');
|
|
183
|
+
var geomTypeConfig = GeomTypeConfig[shape];
|
|
184
|
+
if ((geomTypeConfig || {}).drawNodes !== false) {
|
|
185
|
+
styles.push(_this.selectedStyle);
|
|
186
|
+
}
|
|
187
|
+
return styles;
|
|
188
|
+
});
|
|
189
|
+
_defineProperty(_this, "setCurrentFeature", function (feature) {
|
|
190
|
+
var _featureObj$shape;
|
|
191
|
+
_this.currentFeature = feature;
|
|
192
|
+
_this.currentFeature.setStyle(_this.styleFunction);
|
|
193
|
+
var circleParams = _this.currentFeature.get('circleParams');
|
|
194
|
+
if (circleParams) {
|
|
195
|
+
_this.currentFeature.setGeometry(new ol.geom.Circle(circleParams.center, circleParams.radius));
|
|
196
|
+
}
|
|
197
|
+
var measurements = _this.currentFeature.get('measurements');
|
|
198
|
+
var featureObj = _this.currentFeatureObject();
|
|
199
|
+
var newRedliningState = {
|
|
200
|
+
style: _this.styleProps(_this.currentFeature),
|
|
201
|
+
measurements: !!_this.currentFeature.get('measurements'),
|
|
202
|
+
selectedFeature: featureObj,
|
|
203
|
+
geomType: (_featureObj$shape = featureObj === null || featureObj === void 0 ? void 0 : featureObj.shape) !== null && _featureObj$shape !== void 0 ? _featureObj$shape : _this.props.redlining.geomType
|
|
204
|
+
};
|
|
205
|
+
if (measurements) {
|
|
206
|
+
newRedliningState.lenUnit = measurements.lenUnit;
|
|
207
|
+
newRedliningState.areaUnit = measurements.areaUnit;
|
|
208
|
+
}
|
|
209
|
+
_this.props.changeRedliningState(newRedliningState);
|
|
210
|
+
_this.currentFeature.on('change', _this.updateMeasurements);
|
|
211
|
+
});
|
|
212
|
+
_defineProperty(_this, "addDrawInteraction", function () {
|
|
213
|
+
var geomTypeConfig = GeomTypeConfig[_this.props.redlining.geomType];
|
|
214
|
+
if (!geomTypeConfig) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
var isFreeHand = _this.props.redlining.freehand;
|
|
218
|
+
var drawInteraction = geomTypeConfig.drawInteraction({
|
|
219
|
+
stopClick: true,
|
|
220
|
+
condition: function condition(event) {
|
|
221
|
+
return event.originalEvent.buttons === 1;
|
|
222
|
+
},
|
|
223
|
+
style: function style() {
|
|
224
|
+
return _this.picking ? [] : FeatureStyles.sketchInteraction();
|
|
225
|
+
},
|
|
226
|
+
freehand: isFreeHand
|
|
227
|
+
});
|
|
228
|
+
drawInteraction.on('drawstart', function (evt) {
|
|
229
|
+
if (_this.picking && _this.props.redlining.drawMultiple === false) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
_this.leaveTemporaryEditMode();
|
|
233
|
+
_this.currentFeature = evt.feature;
|
|
234
|
+
_this.currentFeature.setId(uuidv4());
|
|
235
|
+
_this.currentFeature.set('shape', _this.props.redlining.geomType);
|
|
236
|
+
_this.currentFeature.setStyle(_this.styleFunction);
|
|
237
|
+
_this.updateFeatureStyle(_this.props.redlining.style);
|
|
238
|
+
_this.currentFeature.on('change', _this.updateMeasurements);
|
|
239
|
+
}, _this);
|
|
240
|
+
drawInteraction.on('drawend', function () {
|
|
241
|
+
var featureId = _this.currentFeature.getId();
|
|
242
|
+
_this.commitCurrentFeature(_this.props.redlining, true);
|
|
243
|
+
_this.enterTemporaryEditMode(featureId, _this.props.redlining.layer, geomTypeConfig.editTool);
|
|
244
|
+
}, _this);
|
|
245
|
+
_this.props.map.addInteraction(drawInteraction);
|
|
246
|
+
_this.interactions.push(drawInteraction);
|
|
247
|
+
});
|
|
248
|
+
_defineProperty(_this, "updateMeasurements", function () {
|
|
249
|
+
if (_this.blockOnChange || !_this.currentFeature) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
var feature = _this.currentFeature;
|
|
253
|
+
var hadMeasurements = !!feature.get('measurements');
|
|
254
|
+
if (_this.props.redlining.measurements) {
|
|
255
|
+
var settings = {
|
|
256
|
+
displayCrs: _this.props.displayCrs,
|
|
257
|
+
lenUnit: _this.props.redlining.lenUnit,
|
|
258
|
+
areaUnit: _this.props.redlining.areaUnit
|
|
259
|
+
};
|
|
260
|
+
MeasureUtils.updateFeatureMeasurements(feature, feature.get('shape'), _this.props.mapCrs, settings);
|
|
261
|
+
} else if (hadMeasurements) {
|
|
262
|
+
feature.set('measurements', undefined);
|
|
263
|
+
feature.set('segment_labels', undefined);
|
|
264
|
+
feature.set('label', '');
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
_defineProperty(_this, "waitForFeatureAndLayer", function (layerId, featureId, callback) {
|
|
268
|
+
var redliningLayer = _this.searchRedliningLayer(layerId);
|
|
269
|
+
if (!redliningLayer) {
|
|
270
|
+
OlLayerAdded.connect(function (layer) {
|
|
271
|
+
if (layer.get("id") === layerId) {
|
|
272
|
+
var feature = featureId ? layer.getSource().getFeatureById(featureId) : null;
|
|
273
|
+
callback(layer, feature);
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
return false;
|
|
277
|
+
});
|
|
278
|
+
} else if (featureId) {
|
|
279
|
+
var feature = redliningLayer.getSource().getFeatureById(featureId);
|
|
280
|
+
if (feature) {
|
|
281
|
+
callback(redliningLayer, feature);
|
|
282
|
+
} else {
|
|
283
|
+
OlLayerUpdated.connect(function (layer) {
|
|
284
|
+
if (layer.get("id") === layerId) {
|
|
285
|
+
var feat = layer.getSource().getFeatureById(featureId);
|
|
286
|
+
if (feat) {
|
|
287
|
+
callback(layer, feat);
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return false;
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
} else {
|
|
295
|
+
callback(redliningLayer, null);
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
_defineProperty(_this, "enterTemporaryEditMode", function (featureId, layerId, editTool) {
|
|
299
|
+
_this.waitForFeatureAndLayer(layerId, featureId, function (redliningLayer, feature) {
|
|
300
|
+
if (!feature) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
_this.setCurrentFeature(feature);
|
|
304
|
+
if (editTool === 'Transform') {
|
|
305
|
+
_this.setupTransformInteraction([_this.currentFeature]);
|
|
306
|
+
} else {
|
|
307
|
+
_this.setupModifyInteraction([_this.currentFeature]);
|
|
308
|
+
}
|
|
309
|
+
_this.picking = true;
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
_defineProperty(_this, "leaveTemporaryEditMode", function () {
|
|
313
|
+
if (_this.currentFeature) {
|
|
314
|
+
_this.commitCurrentFeature(_this.props.redlining);
|
|
315
|
+
}
|
|
316
|
+
if (_this.picking) {
|
|
317
|
+
// Remove modify interactions
|
|
318
|
+
_this.props.map.removeInteraction(_this.interactions.pop());
|
|
319
|
+
_this.picking = false;
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
_defineProperty(_this, "addPickInteraction", function () {
|
|
323
|
+
var redliningLayer = _this.searchRedliningLayer(_this.props.redlining.layer);
|
|
324
|
+
if (!redliningLayer) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
var selectInteraction = new ol.interaction.Select({
|
|
328
|
+
layers: [redliningLayer],
|
|
329
|
+
hitTolerance: 5
|
|
330
|
+
});
|
|
331
|
+
var currentEditInteraction = null;
|
|
332
|
+
selectInteraction.on('select', function (evt) {
|
|
333
|
+
if (evt.selected.length === 1 && evt.selected[0] === _this.currentFeature) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (_this.currentFeature) {
|
|
337
|
+
_this.commitCurrentFeature(_this.props.redlining);
|
|
338
|
+
}
|
|
339
|
+
if (currentEditInteraction) {
|
|
340
|
+
_this.props.map.removeInteraction(currentEditInteraction);
|
|
341
|
+
_this.interactions = _this.interactions.filter(function (i) {
|
|
342
|
+
return i !== currentEditInteraction;
|
|
343
|
+
});
|
|
344
|
+
currentEditInteraction = null;
|
|
345
|
+
}
|
|
346
|
+
if (evt.selected.length === 1) {
|
|
347
|
+
_this.setCurrentFeature(evt.selected[0]);
|
|
348
|
+
var geomTypeConfig = GeomTypeConfig[_this.currentFeature.get('shape')];
|
|
349
|
+
if (geomTypeConfig && geomTypeConfig.editTool === 'Transform') {
|
|
350
|
+
currentEditInteraction = _this.setupTransformInteraction([_this.currentFeature]);
|
|
351
|
+
currentEditInteraction.on('select', function (ev) {
|
|
352
|
+
// Clear selection when selecting a different feature, and let the parent select interaction deal with the new feature
|
|
353
|
+
if (_this.currentFeature && ev.feature !== _this.currentFeature) {
|
|
354
|
+
_this.commitCurrentFeature(_this.props.redlining);
|
|
355
|
+
currentEditInteraction.setSelection(new ol.Collection());
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
} else {
|
|
359
|
+
currentEditInteraction = _this.setupModifyInteraction(selectInteraction.getFeatures().getArray());
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}, _this);
|
|
363
|
+
if (_this.props.redlining.action === 'PickDraw') {
|
|
364
|
+
_this.props.map.on('click', _this.maybeEnterTemporaryDrawMode);
|
|
365
|
+
}
|
|
366
|
+
_this.props.map.addInteraction(selectInteraction);
|
|
367
|
+
_this.interactions.push(selectInteraction);
|
|
368
|
+
_this.picking = true;
|
|
369
|
+
});
|
|
370
|
+
_defineProperty(_this, "addTransformInteraction", function () {
|
|
371
|
+
var redliningLayer = _this.searchRedliningLayer(_this.props.redlining.layer);
|
|
372
|
+
if (!redliningLayer) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
var transformInteraction = _this.setupTransformInteraction();
|
|
376
|
+
transformInteraction.on('select', function (evt) {
|
|
377
|
+
if (evt.feature === _this.currentFeature) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
if (_this.currentFeature) {
|
|
381
|
+
_this.commitCurrentFeature(_this.props.redlining);
|
|
382
|
+
}
|
|
383
|
+
if (evt.feature) {
|
|
384
|
+
_this.setCurrentFeature(evt.feature);
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
_this.picking = true;
|
|
388
|
+
});
|
|
389
|
+
_defineProperty(_this, "addPickDrawInteraction", function () {
|
|
390
|
+
_this.waitForFeatureAndLayer(_this.props.redlining.layer, null, function () {
|
|
391
|
+
return _this.addPickInteraction();
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
_defineProperty(_this, "maybeEnterTemporaryDrawMode", function (ev) {
|
|
395
|
+
var redliningLayer = _this.searchRedliningLayer(_this.props.redlining.layer);
|
|
396
|
+
if (_this.currentFeature || !_this.props.redlining.drawMultiple && redliningLayer.getSource().getFeatures().length > 0) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
var featureHit = false;
|
|
400
|
+
_this.props.map.forEachFeatureAtPixel(ev.pixel, function (feature, layer) {
|
|
401
|
+
featureHit |= layer === redliningLayer;
|
|
402
|
+
}, {
|
|
403
|
+
hitTolerance: 5
|
|
404
|
+
});
|
|
405
|
+
if (!redliningLayer || featureHit) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
_this.reset(_this.props.redlining);
|
|
409
|
+
_this.props.map.un('click', _this.maybeEnterTemporaryDrawMode);
|
|
410
|
+
var geomTypeConfig = GeomTypeConfig[_this.props.redlining.geomType];
|
|
411
|
+
if (!geomTypeConfig) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
var isFreeHand = _this.props.redlining.freehand;
|
|
415
|
+
var drawInteraction = geomTypeConfig.drawInteraction({
|
|
416
|
+
stopClick: true,
|
|
417
|
+
condition: function condition(event) {
|
|
418
|
+
return event.originalEvent.buttons === 1;
|
|
419
|
+
},
|
|
420
|
+
style: function style() {
|
|
421
|
+
return _this.picking ? [] : FeatureStyles.sketchInteraction();
|
|
422
|
+
},
|
|
423
|
+
freehand: isFreeHand
|
|
424
|
+
});
|
|
425
|
+
drawInteraction.on('drawstart', function (evt) {
|
|
426
|
+
_this.currentFeature = evt.feature;
|
|
427
|
+
_this.currentFeature.setId(uuidv4());
|
|
428
|
+
_this.currentFeature.set('shape', _this.props.redlining.geomType);
|
|
429
|
+
_this.currentFeature.setStyle(_this.styleFunction);
|
|
430
|
+
_this.updateFeatureStyle(_this.props.redlining.style);
|
|
431
|
+
_this.currentFeature.on('change', _this.updateMeasurements);
|
|
432
|
+
}, _this);
|
|
433
|
+
drawInteraction.on('drawend', function () {
|
|
434
|
+
// Draw end
|
|
435
|
+
_this.commitCurrentFeature(_this.props.redlining, true);
|
|
436
|
+
_this.reset(_this.props.redlining);
|
|
437
|
+
// Ughh... Apparently we need to wait 250ms for the 'singleclick' event processing to finish to avoid pick interactions picking up the current event
|
|
438
|
+
setTimeout(function () {
|
|
439
|
+
return _this.addPickInteraction(true);
|
|
440
|
+
}, 300);
|
|
441
|
+
}, _this);
|
|
442
|
+
_this.props.map.addInteraction(drawInteraction);
|
|
443
|
+
_this.interactions.push(drawInteraction);
|
|
444
|
+
_this.picking = false;
|
|
445
|
+
var clickCoord = MapUtils.getHook(MapUtils.GET_SNAPPED_COORDINATES_FROM_PIXEL_HOOK)(ev.pixel);
|
|
446
|
+
drawInteraction.appendCoordinates([clickCoord]);
|
|
447
|
+
if (_this.props.redlining.geomType === 'Point') {
|
|
448
|
+
drawInteraction.finishDrawing();
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
_defineProperty(_this, "setupModifyInteraction", function () {
|
|
452
|
+
var selectedFeatures = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
453
|
+
var modifyInteraction = new ol.interaction.Modify({
|
|
454
|
+
features: new ol.Collection(selectedFeatures),
|
|
455
|
+
condition: function condition(event) {
|
|
456
|
+
return event.originalEvent.buttons === 1;
|
|
457
|
+
},
|
|
458
|
+
deleteCondition: function deleteCondition(event) {
|
|
459
|
+
// delete vertices on SHIFT + click
|
|
460
|
+
if (event.type === "pointerdown" && ol.events.condition.shiftKeyOnly(event)) {
|
|
461
|
+
_this.props.map.setIgnoreNextClick(true);
|
|
462
|
+
}
|
|
463
|
+
return ol.events.condition.shiftKeyOnly(event) && ol.events.condition.singleClick(event);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
modifyInteraction.on('modifyend', _this.updateSelectedFeature);
|
|
467
|
+
_this.props.map.addInteraction(modifyInteraction);
|
|
468
|
+
_this.interactions.push(modifyInteraction);
|
|
469
|
+
return modifyInteraction;
|
|
470
|
+
});
|
|
471
|
+
_defineProperty(_this, "setupTransformInteraction", function () {
|
|
472
|
+
var selectedFeatures = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
473
|
+
var transformInteraction = new ol.interaction.Transform({
|
|
474
|
+
stretch: false,
|
|
475
|
+
keepAspectRatio: function keepAspectRatio(ev) {
|
|
476
|
+
return _this.currentFeature ? GeomTypeConfig[_this.currentFeature.get('shape')].regular || ol.events.condition.shiftKeyOnly(ev) : false;
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
transformInteraction.on('rotating', function (e) {
|
|
480
|
+
if (_this.currentFeature.get('shape') === 'Text') {
|
|
481
|
+
_this.currentFeature.set('rotation', -e.angle);
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
transformInteraction.on('rotateend', _this.updateSelectedFeature);
|
|
485
|
+
transformInteraction.on('translateend', _this.updateSelectedFeature);
|
|
486
|
+
transformInteraction.on('scaleend', _this.updateSelectedFeature);
|
|
487
|
+
_this.props.map.addInteraction(transformInteraction);
|
|
488
|
+
_this.interactions.push(transformInteraction);
|
|
489
|
+
transformInteraction.setSelection(new ol.Collection(selectedFeatures));
|
|
490
|
+
return transformInteraction;
|
|
491
|
+
});
|
|
492
|
+
_defineProperty(_this, "updateSelectedFeature", function () {
|
|
493
|
+
var _featureObj$shape2;
|
|
494
|
+
var featureObj = _this.currentFeatureObject();
|
|
495
|
+
_this.props.changeRedliningState({
|
|
496
|
+
selectedFeature: featureObj,
|
|
497
|
+
geomType: (_featureObj$shape2 = featureObj === null || featureObj === void 0 ? void 0 : featureObj.shape) !== null && _featureObj$shape2 !== void 0 ? _featureObj$shape2 : _this.props.redlining.geomType
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
_defineProperty(_this, "triggerDelete", function () {
|
|
501
|
+
_this.props.changeRedliningState({
|
|
502
|
+
action: "Delete"
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
_defineProperty(_this, "deleteCurrentFeature", function () {
|
|
506
|
+
if (_this.currentFeature) {
|
|
507
|
+
_this.props.removeLayerFeatures(_this.props.redlining.layer, [_this.currentFeature.getId()], true);
|
|
508
|
+
_this.currentFeature = null;
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
_defineProperty(_this, "commitCurrentFeature", function (redliningProps) {
|
|
512
|
+
var _feature$geometry;
|
|
513
|
+
var newFeature = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
514
|
+
var feature = _this.currentFeatureObject();
|
|
515
|
+
if (!feature) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
// Don't commit empty/invalid features
|
|
519
|
+
if (feature.shape === "Text" && !feature.properties.label || feature.shape === "Circle" && feature.circleParams.radius === 0 || ((_feature$geometry = feature.geometry) === null || _feature$geometry === void 0 ? void 0 : _feature$geometry.type) === "Polygon" && _this.currentFeature.getGeometry().getArea() === 0) {
|
|
520
|
+
if (!newFeature) {
|
|
521
|
+
_this.props.removeLayerFeatures(redliningProps.layer, [feature.id]);
|
|
522
|
+
}
|
|
523
|
+
_this.resetSelectedFeature();
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (feature.shape === "Circle") {
|
|
527
|
+
var _feature$circleParams = feature.circleParams,
|
|
528
|
+
center = _feature$circleParams.center,
|
|
529
|
+
radius = _feature$circleParams.radius;
|
|
530
|
+
var deg2rad = Math.PI / 180;
|
|
531
|
+
feature.geometry.type = "Polygon";
|
|
532
|
+
feature.geometry.coordinates = [Array.apply(null, Array(91)).map(function (item, index) {
|
|
533
|
+
return [center[0] + radius * Math.cos(4 * index * deg2rad), center[1] + radius * Math.sin(4 * index * deg2rad)];
|
|
534
|
+
})];
|
|
535
|
+
}
|
|
536
|
+
if (feature.geometry.type === "LineString" || feature.geometry.type === "Polygon") {
|
|
537
|
+
feature.geometry.coordinates = VectorLayerUtils.removeDuplicateNodes(feature.geometry.coordinates);
|
|
538
|
+
}
|
|
539
|
+
var layer = {
|
|
540
|
+
id: redliningProps.layer,
|
|
541
|
+
title: redliningProps.layerTitle,
|
|
542
|
+
role: LayerRole.USERLAYER
|
|
543
|
+
};
|
|
544
|
+
_this.props.addLayerFeatures(layer, [feature]);
|
|
545
|
+
_this.resetSelectedFeature();
|
|
546
|
+
});
|
|
547
|
+
_defineProperty(_this, "resetSelectedFeature", function () {
|
|
548
|
+
if (_this.currentFeature) {
|
|
549
|
+
// Reset selection style
|
|
550
|
+
var styleName = _this.currentFeature.get("shape") === "Text" ? "text" : "default";
|
|
551
|
+
var style = FeatureStyles[styleName](_this.currentFeature, _this.currentFeature.get('styleOptions'));
|
|
552
|
+
_this.currentFeature.setStyle(style);
|
|
553
|
+
_this.currentFeature.un('change', _this.updateMeasurements);
|
|
554
|
+
_this.currentFeature = null;
|
|
555
|
+
_this.props.changeRedliningState({
|
|
556
|
+
selectedFeature: null
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
_defineProperty(_this, "reset", function (redliningProps) {
|
|
561
|
+
while (_this.interactions.length > 0) {
|
|
562
|
+
_this.props.map.removeInteraction(_this.interactions.shift());
|
|
563
|
+
}
|
|
564
|
+
if (_this.picking) {
|
|
565
|
+
_this.commitCurrentFeature(redliningProps, false);
|
|
566
|
+
} else {
|
|
567
|
+
_this.resetSelectedFeature();
|
|
568
|
+
}
|
|
569
|
+
_this.props.map.un('click', _this.maybeEnterTemporaryDrawMode);
|
|
570
|
+
_this.picking = false;
|
|
571
|
+
});
|
|
572
|
+
_defineProperty(_this, "searchRedliningLayer", function (layerId) {
|
|
573
|
+
var _this$props$map$getLa;
|
|
574
|
+
return (_this$props$map$getLa = _this.props.map.getLayers().getArray().find(function (l) {
|
|
575
|
+
return l.get('id') === layerId;
|
|
576
|
+
})) !== null && _this$props$map$getLa !== void 0 ? _this$props$map$getLa : null;
|
|
577
|
+
});
|
|
578
|
+
_defineProperty(_this, "currentFeatureObject", function () {
|
|
579
|
+
if (!_this.currentFeature) {
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
var format = new ol.format.GeoJSON();
|
|
583
|
+
var feature = format.writeFeatureObject(_this.currentFeature);
|
|
584
|
+
if (_this.currentFeature.get("shape") === "Circle") {
|
|
585
|
+
feature.circleParams = {
|
|
586
|
+
center: _this.currentFeature.getGeometry().getCenter(),
|
|
587
|
+
radius: _this.currentFeature.getGeometry().getRadius()
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
feature.styleName = _this.currentFeature.get('styleName');
|
|
591
|
+
feature.styleOptions = _this.currentFeature.get('styleOptions');
|
|
592
|
+
feature.shape = _this.currentFeature.get('shape');
|
|
593
|
+
feature.measurements = _this.currentFeature.get('measurements');
|
|
594
|
+
feature.crs = _this.props.mapCrs;
|
|
595
|
+
// Don't pollute GeoJSON object properties with internal props
|
|
596
|
+
delete feature.properties.styleName;
|
|
597
|
+
delete feature.properties.styleOptions;
|
|
598
|
+
delete feature.properties.shape;
|
|
599
|
+
delete feature.properties.measurements;
|
|
600
|
+
delete feature.properties.circleParams;
|
|
601
|
+
// Don't store empty label prop
|
|
602
|
+
if (feature.properties.label === "") {
|
|
603
|
+
delete feature.properties.label;
|
|
604
|
+
}
|
|
605
|
+
return feature;
|
|
606
|
+
});
|
|
607
|
+
_this.interactions = [];
|
|
608
|
+
_this.picking = false;
|
|
609
|
+
_this.currentFeature = null;
|
|
610
|
+
_this.blockOnChange = false;
|
|
611
|
+
_this.selectedTextStyle = function (feature, opts) {
|
|
612
|
+
return new ol.style.Style({
|
|
613
|
+
text: new ol.style.Text({
|
|
614
|
+
font: '10pt sans-serif',
|
|
615
|
+
text: feature.getProperties().label || "",
|
|
616
|
+
rotation: feature.getProperties().rotation || 0,
|
|
617
|
+
scale: opts.strokeWidth,
|
|
618
|
+
fill: new ol.style.Fill({
|
|
619
|
+
color: opts.textFillColor
|
|
620
|
+
}),
|
|
621
|
+
stroke: new ol.style.Stroke({
|
|
622
|
+
color: [0, 0, 0, 0.5],
|
|
623
|
+
width: 4
|
|
624
|
+
})
|
|
625
|
+
})
|
|
626
|
+
});
|
|
627
|
+
};
|
|
628
|
+
var geometryFunction = function geometryFunction(feature) {
|
|
629
|
+
if (feature.getGeometry().getType() === "Point") {
|
|
630
|
+
return new ol.geom.MultiPoint([feature.getGeometry().getCoordinates()]);
|
|
631
|
+
} else if (feature.getGeometry().getType() === "LineString") {
|
|
632
|
+
return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates());
|
|
633
|
+
} else if (feature.getGeometry().getType() === "Polygon") {
|
|
634
|
+
return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates()[0]);
|
|
635
|
+
} else if (feature.getGeometry().getType() === "Circle") {
|
|
636
|
+
var center = feature.getGeometry().getCenter();
|
|
637
|
+
return new ol.geom.MultiPoint([center, [center[0] + feature.getGeometry().getRadius(), center[1]]]);
|
|
638
|
+
}
|
|
639
|
+
return null;
|
|
640
|
+
};
|
|
641
|
+
_this.selectedStyle = FeatureStyles.interactionVertex({
|
|
642
|
+
geometryFunction: geometryFunction
|
|
643
|
+
});
|
|
644
|
+
return _this;
|
|
645
|
+
}
|
|
646
|
+
_inherits(RedliningSupport, _React$Component);
|
|
647
|
+
return _createClass(RedliningSupport, [{
|
|
648
|
+
key: "componentDidUpdate",
|
|
649
|
+
value: function componentDidUpdate(prevProps) {
|
|
650
|
+
// Bind keyboard shortcuts to delete features
|
|
651
|
+
if (this.props.redlining.action && !prevProps.redlining.action) {
|
|
652
|
+
Mousetrap.bind('del', this.triggerDelete);
|
|
653
|
+
Mousetrap.bind('backspace', this.triggerDelete);
|
|
654
|
+
} else if (!this.props.redlining.action && prevProps.redlining.action) {
|
|
655
|
+
Mousetrap.unbind('del', this.triggerDelete);
|
|
656
|
+
Mousetrap.unbind('backspace', this.triggerDelete);
|
|
657
|
+
}
|
|
658
|
+
// Handle delete action immediately and reset the redlining state to the previous action
|
|
659
|
+
if (this.props.redlining.action === 'Delete') {
|
|
660
|
+
this.deleteCurrentFeature();
|
|
661
|
+
this.props.changeRedliningState(_objectSpread(_objectSpread({}, prevProps.redlining), {}, {
|
|
662
|
+
selectedFeature: null
|
|
663
|
+
}));
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
var recreateInteraction = this.props.redlining.action !== prevProps.redlining.action || this.props.redlining.layer !== prevProps.redlining.layer || ['Draw', 'PickDraw'].includes(this.props.redlining.action) && this.props.redlining.geomType !== prevProps.redlining.geomType || this.props.redlining.freehand !== prevProps.redlining.freehand || this.props.redlining.drawMultiple !== prevProps.redlining.drawMultiple;
|
|
667
|
+
if (recreateInteraction) {
|
|
668
|
+
// Commit to previous layer in case layer changed
|
|
669
|
+
this.reset(prevProps.redlining);
|
|
670
|
+
if (this.props.redlining.action === 'Draw') {
|
|
671
|
+
this.addDrawInteraction();
|
|
672
|
+
} else if (this.props.redlining.action === 'Transform') {
|
|
673
|
+
this.addTransformInteraction();
|
|
674
|
+
} else if (this.props.redlining.action === 'Pick' || this.props.redlining.action === 'Buffer') {
|
|
675
|
+
this.addPickInteraction();
|
|
676
|
+
} else if (this.props.redlining.action === 'PickDraw') {
|
|
677
|
+
this.addPickDrawInteraction();
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
if (this.currentFeature) {
|
|
681
|
+
// Update feature style
|
|
682
|
+
if (this.props.redlining.style !== prevProps.redlining.style) {
|
|
683
|
+
this.updateFeatureStyle(this.props.redlining.style);
|
|
684
|
+
}
|
|
685
|
+
// Update current feature measurements
|
|
686
|
+
if (this.props.map.displayCrs !== prevProps.map.displayCrs || this.props.redlining.measurements !== prevProps.redlining.measurements || this.props.redlining.lenUnit !== prevProps.redlining.lenUnit || this.props.redlining.areaUnit !== prevProps.redlining.areaUnit) {
|
|
687
|
+
this.currentFeature.changed();
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}, {
|
|
692
|
+
key: "render",
|
|
693
|
+
value: function render() {
|
|
694
|
+
var _this2 = this;
|
|
695
|
+
if (this.props.redlining.numericInput) {
|
|
696
|
+
return /*#__PURE__*/React.createElement(NumericInputWindow, {
|
|
697
|
+
feature: this.props.redlining.selectedFeature,
|
|
698
|
+
onClose: function onClose() {
|
|
699
|
+
return _this2.props.changeRedliningState({
|
|
700
|
+
numericInput: false
|
|
701
|
+
});
|
|
702
|
+
},
|
|
703
|
+
onFeatureChanged: this.updateCurrentFeature
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
return null;
|
|
707
|
+
}
|
|
708
|
+
}]);
|
|
709
|
+
}(React.Component);
|
|
710
|
+
_defineProperty(RedliningSupport, "propTypes", {
|
|
711
|
+
addLayerFeatures: PropTypes.func,
|
|
712
|
+
changeRedliningState: PropTypes.func,
|
|
713
|
+
displayCrs: PropTypes.string,
|
|
714
|
+
map: PropTypes.object,
|
|
715
|
+
mapCrs: PropTypes.string,
|
|
716
|
+
redlining: PropTypes.object,
|
|
717
|
+
removeLayerFeatures: PropTypes.func
|
|
718
|
+
});
|
|
719
|
+
_defineProperty(RedliningSupport, "defaultProps", {
|
|
720
|
+
redlining: {}
|
|
721
|
+
});
|
|
722
|
+
export default connect(function (state) {
|
|
723
|
+
return {
|
|
724
|
+
displayCrs: state.map.displayCrs,
|
|
725
|
+
mapCrs: state.map.projection,
|
|
726
|
+
redlining: state.redlining
|
|
727
|
+
};
|
|
728
|
+
}, {
|
|
729
|
+
changeRedliningState: changeRedliningState,
|
|
730
|
+
addLayerFeatures: addLayerFeatures,
|
|
731
|
+
removeLayerFeatures: removeLayerFeatures
|
|
732
|
+
})(RedliningSupport);
|