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.
Files changed (241) hide show
  1. package/actions/display.js +30 -1
  2. package/actions/editing.js +22 -1
  3. package/actions/layerinfo.js +13 -1
  4. package/actions/layers.js +213 -3
  5. package/actions/localConfig.js +58 -1
  6. package/actions/locale.js +21 -1
  7. package/actions/locate.js +26 -1
  8. package/actions/logging.js +10 -1
  9. package/actions/map.js +105 -2
  10. package/actions/measurement.js +12 -1
  11. package/actions/processNotifications.js +37 -1
  12. package/actions/redlining.js +18 -1
  13. package/actions/redliningPick.js +12 -1
  14. package/actions/search.js +12 -1
  15. package/actions/serviceinfo.js +12 -1
  16. package/actions/task.js +55 -3
  17. package/actions/theme.js +339 -19
  18. package/actions/windows.js +164 -5
  19. package/components/AppMenu.js +435 -3
  20. package/components/AttributeForm.js +928 -32
  21. package/components/AttributeTableWidget.js +1105 -13
  22. package/components/AutoEditForm.js +189 -3
  23. package/components/CoordinateDisplayer.js +78 -2
  24. package/components/EditComboField.js +190 -6
  25. package/components/EditUploadField.js +315 -3
  26. package/components/ExportSelection.js +203 -2
  27. package/components/FullscreenSwitcher.js +90 -3
  28. package/components/Icon.js +81 -2
  29. package/components/IdentifyViewer.js +1161 -6
  30. package/components/ImportLayer.js +718 -20
  31. package/components/LayerInfoWindow.js +145 -2
  32. package/components/LinkFeatureForm.js +246 -5
  33. package/components/MapButton.js +88 -2
  34. package/components/MapSelection.js +287 -8
  35. package/components/MessageBar.js +68 -2
  36. package/components/NumericInputWindow.js +359 -2
  37. package/components/PickFeature.js +266 -2
  38. package/components/PluginsContainer.js +227 -8
  39. package/components/PrintSelection.js +620 -49
  40. package/components/ProcessNotifications.js +104 -2
  41. package/components/QtDesignerForm.js +1137 -18
  42. package/components/ResizeableWindow.js +591 -8
  43. package/components/SearchBox.js +1307 -20
  44. package/components/ServiceInfoWindow.js +107 -2
  45. package/components/SideBar.js +204 -4
  46. package/components/StandardApp.js +381 -20
  47. package/components/Swipeable.js +15 -1
  48. package/components/TaskBar.js +85 -2
  49. package/components/ThemeLayersListWindow.js +216 -4
  50. package/components/ThemeList.js +381 -7
  51. package/components/Toolbar.js +106 -2
  52. package/components/WindowManager.js +178 -2
  53. package/components/map/OlLayer.js +257 -6
  54. package/components/map/OlMap.js +405 -5
  55. package/components/map/layers/BingLayer.js +31 -2
  56. package/components/map/layers/GoogleLayer.js +222 -19
  57. package/components/map/layers/GraticuleLayer.js +21 -1
  58. package/components/map/layers/ImageLayer.js +15 -1
  59. package/components/map/layers/MVTLayer.js +52 -2
  60. package/components/map/layers/OSMLayer.js +24 -2
  61. package/components/map/layers/OverlayLayer.js +55 -3
  62. package/components/map/layers/VectorLayer.js +173 -8
  63. package/components/map/layers/WFSLayer.js +220 -6
  64. package/components/map/layers/WMSLayer.js +180 -6
  65. package/components/map/layers/WMTSLayer.js +67 -3
  66. package/components/map/layers/XYZLayer.js +24 -2
  67. package/components/map/layers/index.js +28 -1
  68. package/components/map3d/EditDataset3D.js +190 -3
  69. package/components/map3d/HeightProfile3D.js +402 -3
  70. package/components/map3d/ImportObjects3D.js +162 -2
  71. package/components/map3d/Map3D.js +1304 -38
  72. package/components/map3d/MapControls3D.js +392 -7
  73. package/components/map3d/SearchField3D.js +183 -11
  74. package/components/map3d/View3DSwitcher.js +98 -2
  75. package/components/map3d/drawtool/CreateTool3D.js +174 -4
  76. package/components/map3d/drawtool/EditTool3D.js +590 -6
  77. package/components/map3d/drawtool/NumericInput3D.js +336 -4
  78. package/components/map3d/layers/GeoTIFFLayer3D.js +15 -1
  79. package/components/map3d/layers/VectorLayer3D.js +53 -2
  80. package/components/map3d/layers/WFSLayer3D.js +109 -3
  81. package/components/map3d/layers/WMSLayer3D.js +70 -2
  82. package/components/map3d/layers/WMTSLayer3D.js +27 -3
  83. package/components/map3d/layers/index.js +14 -1
  84. package/components/map3d/utils/FirstPersonControls3D.js +423 -16
  85. package/components/map3d/utils/MiscUtils3D.js +221 -13
  86. package/components/map3d/utils/OrbitControls3D.js +176 -5
  87. package/components/map3d/utils/Tiles3DStyle.js +238 -9
  88. package/components/share/ShareLink.js +54 -2
  89. package/components/share/ShareQRCode.js +62 -2
  90. package/components/share/ShareSocials.js +125 -3
  91. package/components/timeline/FixedTimeline.js +236 -5
  92. package/components/timeline/InfiniteTimeline.js +347 -8
  93. package/components/timeline/TimelineFeaturesSlider.js +439 -5
  94. package/components/widgets/AccordeonWidget.js +96 -2
  95. package/components/widgets/ButtonBar.js +124 -2
  96. package/components/widgets/ColorButton.js +201 -3
  97. package/components/widgets/ComboBox.js +166 -2
  98. package/components/widgets/CopyButton.js +110 -2
  99. package/components/widgets/DateTimeInput.js +100 -3
  100. package/components/widgets/EditableSelect.js +230 -3
  101. package/components/widgets/FileSelector.js +128 -4
  102. package/components/widgets/Input.js +124 -2
  103. package/components/widgets/InputContainer.js +96 -2
  104. package/components/widgets/LayerCatalogWidget.js +219 -3
  105. package/components/widgets/MenuButton.js +157 -1
  106. package/components/widgets/ModalDialog.js +64 -2
  107. package/components/widgets/NavBar.js +119 -2
  108. package/components/widgets/NumberInput.js +226 -4
  109. package/components/widgets/PopupMenu.js +72 -1
  110. package/components/widgets/Primitives.js +6 -1
  111. package/components/widgets/ReCaptchaWidget.js +55 -1
  112. package/components/widgets/SearchWidget.js +255 -2
  113. package/components/widgets/Spinner.js +44 -2
  114. package/components/widgets/SuggestionInput.js +77 -2
  115. package/components/widgets/TextInput.js +308 -2
  116. package/components/widgets/ToggleSwitch.js +85 -2
  117. package/components/widgets/VectorLayerPicker.js +85 -3
  118. package/libs/openlayers.js +225 -5
  119. package/package.json +1 -1
  120. package/plugins/API.js +358 -15
  121. package/plugins/AttributeTable.js +109 -3
  122. package/plugins/Authentication.js +130 -5
  123. package/plugins/BackgroundSwitcher.js +218 -4
  124. package/plugins/Bookmark.js +289 -3
  125. package/plugins/BottomBar.js +298 -4
  126. package/plugins/CookiePopup.js +67 -3
  127. package/plugins/Cyclomedia.js +442 -5
  128. package/plugins/Editing.js +497 -9
  129. package/plugins/FeatureForm.js +366 -4
  130. package/plugins/FeatureSearch.js +458 -3
  131. package/plugins/GeometryDigitizer.js +664 -7
  132. package/plugins/HeightProfile.js +763 -15
  133. package/plugins/Help.js +102 -3
  134. package/plugins/HomeButton.js +80 -3
  135. package/plugins/Identify.js +543 -5
  136. package/plugins/LayerCatalog.js +215 -4
  137. package/plugins/LayerTree.js +1194 -6
  138. package/plugins/LocateButton.js +94 -3
  139. package/plugins/Map.js +320 -16
  140. package/plugins/MapCompare.js +94 -3
  141. package/plugins/MapCopyright.js +127 -5
  142. package/plugins/MapExport.js +613 -20
  143. package/plugins/MapFilter.js +868 -12
  144. package/plugins/MapInfoTooltip.js +277 -3
  145. package/plugins/MapLegend.js +253 -4
  146. package/plugins/MapTip.js +290 -4
  147. package/plugins/Measure.js +220 -4
  148. package/plugins/NewsPopup.js +137 -3
  149. package/plugins/OverviewMap.js +167 -7
  150. package/plugins/Panoramax.js +340 -2
  151. package/plugins/Portal.js +199 -4
  152. package/plugins/Print.js +1231 -15
  153. package/plugins/Redlining.js +750 -6
  154. package/plugins/Reports.js +332 -3
  155. package/plugins/Routing.js +1278 -15
  156. package/plugins/ScratchDrawing.js +173 -5
  157. package/plugins/Settings.js +241 -4
  158. package/plugins/Share.js +198 -3
  159. package/plugins/StartupMarker.js +84 -4
  160. package/plugins/TaskButton.js +88 -3
  161. package/plugins/ThemeSwitcher.js +164 -4
  162. package/plugins/TimeManager.js +971 -10
  163. package/plugins/TopBar.js +300 -7
  164. package/plugins/TourGuide.js +213 -2
  165. package/plugins/ValueTool.js +419 -4
  166. package/plugins/View3D.js +519 -14
  167. package/plugins/ZoomButtons.js +165 -3
  168. package/plugins/map/EditingSupport.js +199 -7
  169. package/plugins/map/LocateSupport.js +260 -4
  170. package/plugins/map/MeasurementSupport.js +216 -8
  171. package/plugins/map/RedliningPickSupport.js +201 -7
  172. package/plugins/map/RedliningSupport.js +726 -17
  173. package/plugins/map/SnapInteraction.js +101 -1
  174. package/plugins/map/SnapSupport.js +210 -2
  175. package/plugins/map/SnappingSupport.js +356 -17
  176. package/plugins/map3d/BackgroundSwitcher3D.js +44 -3
  177. package/plugins/map3d/BottomBar3D.js +118 -3
  178. package/plugins/map3d/Compare3D.js +422 -8
  179. package/plugins/map3d/Draw3D.js +353 -6
  180. package/plugins/map3d/ExportObjects3D.js +393 -18
  181. package/plugins/map3d/HideObjects3D.js +313 -12
  182. package/plugins/map3d/Identify3D.js +283 -12
  183. package/plugins/map3d/LayerTree3D.js +323 -3
  184. package/plugins/map3d/MapCopyright3D.js +128 -5
  185. package/plugins/map3d/MapExport3D.js +590 -10
  186. package/plugins/map3d/MapLight3D.js +553 -6
  187. package/plugins/map3d/Measure3D.js +571 -20
  188. package/plugins/map3d/OverviewMap3D.js +169 -3
  189. package/plugins/map3d/Settings3D.js +73 -3
  190. package/plugins/map3d/TopBar3D.js +207 -9
  191. package/plugins/redlining/RedliningBufferSupport.js +206 -3
  192. package/reducers/display.js +34 -2
  193. package/reducers/editing.js +68 -3
  194. package/reducers/index.js +9 -1
  195. package/reducers/layerinfo.js +26 -2
  196. package/reducers/layers.js +456 -9
  197. package/reducers/localConfig.js +122 -2
  198. package/reducers/locale.js +38 -2
  199. package/reducers/locate.js +40 -2
  200. package/reducers/map.js +176 -5
  201. package/reducers/measurement.js +42 -2
  202. package/reducers/processNotifications.js +49 -2
  203. package/reducers/redlining.js +50 -2
  204. package/reducers/redliningPick.js +27 -2
  205. package/reducers/search.js +20 -1
  206. package/reducers/serviceinfo.js +25 -2
  207. package/reducers/task.js +45 -2
  208. package/reducers/theme.js +51 -2
  209. package/reducers/windows.js +203 -2
  210. package/scripts/dist.sh +1 -1
  211. package/scripts/gen-plugin-docs.js +152 -2
  212. package/scripts/makeIconkit.js +85 -6
  213. package/scripts/themesConfig.js +742 -40
  214. package/scripts/updateTranslations.js +251 -10
  215. package/selectors/searchproviders.js +44 -2
  216. package/stores/StandardStore.js +42 -2
  217. package/utils/ConfigUtils.js +84 -3
  218. package/utils/CoordinatesUtils.js +234 -23
  219. package/utils/DxfUtils.js +237 -11
  220. package/utils/EditingInterface.js +421 -87
  221. package/utils/EditingUtils.js +357 -13
  222. package/utils/ElevationInterface.js +83 -22
  223. package/utils/FeatureStyles.js +429 -5
  224. package/utils/IdentifyUtils.js +443 -7
  225. package/utils/ImageEditor.js +79 -9
  226. package/utils/LayerUtils.js +1516 -50
  227. package/utils/LocaleUtils.js +117 -7
  228. package/utils/MapUtils.js +241 -59
  229. package/utils/MeasureUtils.js +323 -2
  230. package/utils/MiscUtils.js +189 -11
  231. package/utils/PermaLinkUtils.js +429 -6
  232. package/utils/PluginStore.js +27 -1
  233. package/utils/ResourceRegistry.js +15 -1
  234. package/utils/RoutingInterface.js +307 -7
  235. package/utils/SearchProviders.js +722 -19
  236. package/utils/ServiceLayerUtils.js +669 -14
  237. package/utils/Signal.js +32 -2
  238. package/utils/ThemeUtils.js +341 -7
  239. package/utils/VectorLayerUtils.js +589 -15
  240. package/utils/expr_grammar/grammar.js +2239 -2
  241. package/utils/expr_grammar/test.js +65 -3
@@ -1,23 +1,732 @@
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)}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}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.")}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}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}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}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}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)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}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)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}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)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}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}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
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
- */import React from"react";import{connect}from"react-redux";import Mousetrap from"mousetrap";import ol from"openlayers";import PropTypes from"prop-types";import{v4 as uuidv4}from"uuid";import{LayerRole,addLayerFeatures,removeLayerFeatures}from"../../actions/layers";import{changeRedliningState}from"../../actions/redlining";import NumericInputWindow from"../../components/NumericInputWindow";import{OlLayerAdded,OlLayerUpdated}from"../../components/map/OlLayer";import FeatureStyles from"../../utils/FeatureStyles";import MapUtils from"../../utils/MapUtils";import MeasureUtils from"../../utils/MeasureUtils";import VectorLayerUtils from"../../utils/VectorLayerUtils";var GeomTypeConfig={Text:{drawInteraction:function drawInteraction(opts){return new ol.interaction.Draw(_objectSpread(_objectSpread({},opts),{},{type:"Point"}))},editTool:"Pick",drawNodes:true},Point:{drawInteraction:function drawInteraction(opts){return new ol.interaction.Draw(_objectSpread(_objectSpread({},opts),{},{type:"Point"}))},editTool:"Pick",drawNodes:true},LineString:{drawInteraction:function drawInteraction(opts){return new ol.interaction.Draw(_objectSpread(_objectSpread({},opts),{},{type:"LineString"}))},editTool:"Pick",drawNodes:true},Polygon:{drawInteraction:function drawInteraction(opts){return new ol.interaction.Draw(_objectSpread(_objectSpread({},opts),{},{type:"Polygon"}))},editTool:"Pick",drawNodes:true},Circle:{drawInteraction:function drawInteraction(opts){return new ol.interaction.Draw(_objectSpread(_objectSpread({},opts),{},{type:"Circle"}))},editTool:"Pick",drawNodes:true,regular:true},Ellipse:{drawInteraction:function drawInteraction(opts){return new ol.interaction.DrawRegular(_objectSpread(_objectSpread({},opts),{},{sides:0}))},editTool:"Transform",drawNodes:false},Box:{drawInteraction:function drawInteraction(opts){return new ol.interaction.Draw(_objectSpread(_objectSpread({},opts),{},{type:"Circle",geometryFunction:ol.interaction.createBox()}))},editTool:"Transform",drawNodes:true},Square:{drawInteraction:function drawInteraction(opts){return new ol.interaction.DrawRegular(_objectSpread(_objectSpread({},opts),{},{sides:4,squareCondition:function squareCondition(){return true}}))},editTool:"Transform",regular:true}};/**
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
- */var RedliningSupport=/*#__PURE__*/function(_React$Component){function RedliningSupport(props){var _this;_classCallCheck(this,RedliningSupport);_this=_callSuper(this,RedliningSupport,[props]);_defineProperty(_this,"updateCurrentFeature",function(feature){if(_this.currentFeature&&_this.props.redlining.selectedFeature){if(feature.circleParams){var circleParams=feature.circleParams;_this.currentFeature.setGeometry(new ol.geom.Circle(circleParams.center,circleParams.radius))}else{_this.currentFeature.getGeometry().setCoordinates(feature.geometry.coordinates)}_this.props.changeRedliningState({selectedFeature:feature,geomType:feature.shape})}});_defineProperty(_this,"styleOptions",function(styleProps,isText){return{strokeColor:isText?styleProps.textOutlineColor:styleProps.borderColor,strokeWidth:1+0.5*styleProps.size,strokeDash:styleProps.strokeDash,fillColor:isText?styleProps.textFillColor:styleProps.fillColor,circleRadius:5+styleProps.size,headmarker:styleProps.headmarker,tailmarker:styleProps.tailmarker}});_defineProperty(_this,"styleProps",function(feature){var styleOptions=feature.get("styleOptions");var label=feature.get("label")||"";var isText=feature.get("shape")==="Text";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)});_defineProperty(_this,"updateFeatureStyle",function(styleProps){var isText=_this.currentFeature.get("shape")==="Text";var styleName=isText?"text":"default";var opts=_this.styleOptions(styleProps,isText);_this.blockOnChange=true;_this.currentFeature.set("label",styleProps.text);_this.currentFeature.set("styleName",styleName);_this.currentFeature.set("styleOptions",opts);_this.blockOnChange=false});_defineProperty(_this,"styleFunction",function(feature){var styleOptions=feature.get("styleOptions");var styleName=feature.get("styleName");var styles=[];if(styleName==="text"){styles.push(_this.selectedTextStyle(feature,styleOptions))}styles.push.apply(styles,_toConsumableArray(FeatureStyles[styleName](feature,styleOptions)));var shape=feature.get("shape");var geomTypeConfig=GeomTypeConfig[shape];if((geomTypeConfig||{}).drawNodes!==false){styles.push(_this.selectedStyle)}return styles});_defineProperty(_this,"setCurrentFeature",function(feature){var _featureObj$shape;_this.currentFeature=feature;_this.currentFeature.setStyle(_this.styleFunction);var circleParams=_this.currentFeature.get("circleParams");if(circleParams){_this.currentFeature.setGeometry(new ol.geom.Circle(circleParams.center,circleParams.radius))}var measurements=_this.currentFeature.get("measurements");var featureObj=_this.currentFeatureObject();var newRedliningState={style:_this.styleProps(_this.currentFeature),measurements:!!_this.currentFeature.get("measurements"),selectedFeature:featureObj,geomType:(_featureObj$shape=featureObj===null||featureObj===void 0?void 0:featureObj.shape)!==null&&_featureObj$shape!==void 0?_featureObj$shape:_this.props.redlining.geomType};if(measurements){newRedliningState.lenUnit=measurements.lenUnit;newRedliningState.areaUnit=measurements.areaUnit}_this.props.changeRedliningState(newRedliningState);_this.currentFeature.on("change",_this.updateMeasurements)});_defineProperty(_this,"addDrawInteraction",function(){var geomTypeConfig=GeomTypeConfig[_this.props.redlining.geomType];if(!geomTypeConfig){return}var isFreeHand=_this.props.redlining.freehand;var drawInteraction=geomTypeConfig.drawInteraction({stopClick:true,condition:function condition(event){return event.originalEvent.buttons===1},style:function style(){return _this.picking?[]:FeatureStyles.sketchInteraction()},freehand:isFreeHand});drawInteraction.on("drawstart",function(evt){if(_this.picking&&_this.props.redlining.drawMultiple===false){return}_this.leaveTemporaryEditMode();_this.currentFeature=evt.feature;_this.currentFeature.setId(uuidv4());_this.currentFeature.set("shape",_this.props.redlining.geomType);_this.currentFeature.setStyle(_this.styleFunction);_this.updateFeatureStyle(_this.props.redlining.style);_this.currentFeature.on("change",_this.updateMeasurements)},_this);drawInteraction.on("drawend",function(){var featureId=_this.currentFeature.getId();_this.commitCurrentFeature(_this.props.redlining,true);_this.enterTemporaryEditMode(featureId,_this.props.redlining.layer,geomTypeConfig.editTool)},_this);_this.props.map.addInteraction(drawInteraction);_this.interactions.push(drawInteraction)});_defineProperty(_this,"updateMeasurements",function(){if(_this.blockOnChange||!_this.currentFeature){return}var feature=_this.currentFeature;var hadMeasurements=!!feature.get("measurements");if(_this.props.redlining.measurements){var settings={displayCrs:_this.props.displayCrs,lenUnit:_this.props.redlining.lenUnit,areaUnit:_this.props.redlining.areaUnit};MeasureUtils.updateFeatureMeasurements(feature,feature.get("shape"),_this.props.mapCrs,settings)}else if(hadMeasurements){feature.set("measurements",undefined);feature.set("segment_labels",undefined);feature.set("label","")}});_defineProperty(_this,"waitForFeatureAndLayer",function(layerId,featureId,callback){var redliningLayer=_this.searchRedliningLayer(layerId);if(!redliningLayer){OlLayerAdded.connect(function(layer){if(layer.get("id")===layerId){var feature=featureId?layer.getSource().getFeatureById(featureId):null;callback(layer,feature);return true}return false})}else if(featureId){var feature=redliningLayer.getSource().getFeatureById(featureId);if(feature){callback(redliningLayer,feature)}else{OlLayerUpdated.connect(function(layer){if(layer.get("id")===layerId){var feat=layer.getSource().getFeatureById(featureId);if(feat){callback(layer,feat);return true}}return false})}}else{callback(redliningLayer,null)}});_defineProperty(_this,"enterTemporaryEditMode",function(featureId,layerId,editTool){_this.waitForFeatureAndLayer(layerId,featureId,function(redliningLayer,feature){if(!feature){return}_this.setCurrentFeature(feature);if(editTool==="Transform"){_this.setupTransformInteraction([_this.currentFeature])}else{_this.setupModifyInteraction([_this.currentFeature])}_this.picking=true})});_defineProperty(_this,"leaveTemporaryEditMode",function(){if(_this.currentFeature){_this.commitCurrentFeature(_this.props.redlining)}if(_this.picking){// Remove modify interactions
10
- _this.props.map.removeInteraction(_this.interactions.pop());_this.picking=false}});_defineProperty(_this,"addPickInteraction",function(){var redliningLayer=_this.searchRedliningLayer(_this.props.redlining.layer);if(!redliningLayer){return}var selectInteraction=new ol.interaction.Select({layers:[redliningLayer],hitTolerance:5});var currentEditInteraction=null;selectInteraction.on("select",function(evt){if(evt.selected.length===1&&evt.selected[0]===_this.currentFeature){return}if(_this.currentFeature){_this.commitCurrentFeature(_this.props.redlining)}if(currentEditInteraction){_this.props.map.removeInteraction(currentEditInteraction);_this.interactions=_this.interactions.filter(function(i){return i!==currentEditInteraction});currentEditInteraction=null}if(evt.selected.length===1){_this.setCurrentFeature(evt.selected[0]);var geomTypeConfig=GeomTypeConfig[_this.currentFeature.get("shape")];if(geomTypeConfig&&geomTypeConfig.editTool==="Transform"){currentEditInteraction=_this.setupTransformInteraction([_this.currentFeature]);currentEditInteraction.on("select",function(ev){// Clear selection when selecting a different feature, and let the parent select interaction deal with the new feature
11
- if(_this.currentFeature&&ev.feature!==_this.currentFeature){_this.commitCurrentFeature(_this.props.redlining);currentEditInteraction.setSelection(new ol.Collection)}})}else{currentEditInteraction=_this.setupModifyInteraction(selectInteraction.getFeatures().getArray())}}},_this);if(_this.props.redlining.action==="PickDraw"){_this.props.map.on("click",_this.maybeEnterTemporaryDrawMode)}_this.props.map.addInteraction(selectInteraction);_this.interactions.push(selectInteraction);_this.picking=true});_defineProperty(_this,"addTransformInteraction",function(){var redliningLayer=_this.searchRedliningLayer(_this.props.redlining.layer);if(!redliningLayer){return}var transformInteraction=_this.setupTransformInteraction();transformInteraction.on("select",function(evt){if(evt.feature===_this.currentFeature){return}if(_this.currentFeature){_this.commitCurrentFeature(_this.props.redlining)}if(evt.feature){_this.setCurrentFeature(evt.feature)}});_this.picking=true});_defineProperty(_this,"addPickDrawInteraction",function(){_this.waitForFeatureAndLayer(_this.props.redlining.layer,null,function(){return _this.addPickInteraction()})});_defineProperty(_this,"maybeEnterTemporaryDrawMode",function(ev){var redliningLayer=_this.searchRedliningLayer(_this.props.redlining.layer);if(_this.currentFeature||!_this.props.redlining.drawMultiple&&redliningLayer.getSource().getFeatures().length>0){return}var featureHit=false;_this.props.map.forEachFeatureAtPixel(ev.pixel,function(feature,layer){featureHit|=layer===redliningLayer},{hitTolerance:5});if(!redliningLayer||featureHit){return}_this.reset(_this.props.redlining);_this.props.map.un("click",_this.maybeEnterTemporaryDrawMode);var geomTypeConfig=GeomTypeConfig[_this.props.redlining.geomType];if(!geomTypeConfig){return}var isFreeHand=_this.props.redlining.freehand;var drawInteraction=geomTypeConfig.drawInteraction({stopClick:true,condition:function condition(event){return event.originalEvent.buttons===1},style:function style(){return _this.picking?[]:FeatureStyles.sketchInteraction()},freehand:isFreeHand});drawInteraction.on("drawstart",function(evt){_this.currentFeature=evt.feature;_this.currentFeature.setId(uuidv4());_this.currentFeature.set("shape",_this.props.redlining.geomType);_this.currentFeature.setStyle(_this.styleFunction);_this.updateFeatureStyle(_this.props.redlining.style);_this.currentFeature.on("change",_this.updateMeasurements)},_this);drawInteraction.on("drawend",function(){// Draw end
12
- _this.commitCurrentFeature(_this.props.redlining,true);_this.reset(_this.props.redlining);// Ughh... Apparently we need to wait 250ms for the 'singleclick' event processing to finish to avoid pick interactions picking up the current event
13
- setTimeout(function(){return _this.addPickInteraction(true)},300)},_this);_this.props.map.addInteraction(drawInteraction);_this.interactions.push(drawInteraction);_this.picking=false;var clickCoord=MapUtils.getHook(MapUtils.GET_SNAPPED_COORDINATES_FROM_PIXEL_HOOK)(ev.pixel);drawInteraction.appendCoordinates([clickCoord]);if(_this.props.redlining.geomType==="Point"){drawInteraction.finishDrawing()}});_defineProperty(_this,"setupModifyInteraction",function(){var selectedFeatures=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var modifyInteraction=new ol.interaction.Modify({features:new ol.Collection(selectedFeatures),condition:function condition(event){return event.originalEvent.buttons===1},deleteCondition:function deleteCondition(event){// delete vertices on SHIFT + click
14
- if(event.type==="pointerdown"&&ol.events.condition.shiftKeyOnly(event)){_this.props.map.setIgnoreNextClick(true)}return ol.events.condition.shiftKeyOnly(event)&&ol.events.condition.singleClick(event)}});modifyInteraction.on("modifyend",_this.updateSelectedFeature);_this.props.map.addInteraction(modifyInteraction);_this.interactions.push(modifyInteraction);return modifyInteraction});_defineProperty(_this,"setupTransformInteraction",function(){var selectedFeatures=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var transformInteraction=new ol.interaction.Transform({stretch:false,keepAspectRatio:function keepAspectRatio(ev){return _this.currentFeature?GeomTypeConfig[_this.currentFeature.get("shape")].regular||ol.events.condition.shiftKeyOnly(ev):false}});transformInteraction.on("rotating",function(e){if(_this.currentFeature.get("shape")==="Text"){_this.currentFeature.set("rotation",-e.angle)}});transformInteraction.on("rotateend",_this.updateSelectedFeature);transformInteraction.on("translateend",_this.updateSelectedFeature);transformInteraction.on("scaleend",_this.updateSelectedFeature);_this.props.map.addInteraction(transformInteraction);_this.interactions.push(transformInteraction);transformInteraction.setSelection(new ol.Collection(selectedFeatures));return transformInteraction});_defineProperty(_this,"updateSelectedFeature",function(){var _featureObj$shape2;var featureObj=_this.currentFeatureObject();_this.props.changeRedliningState({selectedFeature:featureObj,geomType:(_featureObj$shape2=featureObj===null||featureObj===void 0?void 0:featureObj.shape)!==null&&_featureObj$shape2!==void 0?_featureObj$shape2:_this.props.redlining.geomType})});_defineProperty(_this,"triggerDelete",function(){_this.props.changeRedliningState({action:"Delete"})});_defineProperty(_this,"deleteCurrentFeature",function(){if(_this.currentFeature){_this.props.removeLayerFeatures(_this.props.redlining.layer,[_this.currentFeature.getId()],true);_this.currentFeature=null}});_defineProperty(_this,"commitCurrentFeature",function(redliningProps){var _feature$geometry;var newFeature=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var feature=_this.currentFeatureObject();if(!feature){return}// Don't commit empty/invalid features
15
- 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){if(!newFeature){_this.props.removeLayerFeatures(redliningProps.layer,[feature.id])}_this.resetSelectedFeature();return}if(feature.shape==="Circle"){var _feature$circleParams=feature.circleParams,center=_feature$circleParams.center,radius=_feature$circleParams.radius;var deg2rad=Math.PI/180;feature.geometry.type="Polygon";feature.geometry.coordinates=[Array.apply(null,Array(91)).map(function(item,index){return[center[0]+radius*Math.cos(4*index*deg2rad),center[1]+radius*Math.sin(4*index*deg2rad)]})]}if(feature.geometry.type==="LineString"||feature.geometry.type==="Polygon"){feature.geometry.coordinates=VectorLayerUtils.removeDuplicateNodes(feature.geometry.coordinates)}var layer={id:redliningProps.layer,title:redliningProps.layerTitle,role:LayerRole.USERLAYER};_this.props.addLayerFeatures(layer,[feature]);_this.resetSelectedFeature()});_defineProperty(_this,"resetSelectedFeature",function(){if(_this.currentFeature){// Reset selection style
16
- var styleName=_this.currentFeature.get("shape")==="Text"?"text":"default";var style=FeatureStyles[styleName](_this.currentFeature,_this.currentFeature.get("styleOptions"));_this.currentFeature.setStyle(style);_this.currentFeature.un("change",_this.updateMeasurements);_this.currentFeature=null;_this.props.changeRedliningState({selectedFeature:null})}});_defineProperty(_this,"reset",function(redliningProps){while(_this.interactions.length>0){_this.props.map.removeInteraction(_this.interactions.shift())}if(_this.picking){_this.commitCurrentFeature(redliningProps,false)}else{_this.resetSelectedFeature()}_this.props.map.un("click",_this.maybeEnterTemporaryDrawMode);_this.picking=false});_defineProperty(_this,"searchRedliningLayer",function(layerId){var _this$props$map$getLa;return(_this$props$map$getLa=_this.props.map.getLayers().getArray().find(function(l){return l.get("id")===layerId}))!==null&&_this$props$map$getLa!==void 0?_this$props$map$getLa:null});_defineProperty(_this,"currentFeatureObject",function(){if(!_this.currentFeature){return null}var format=new ol.format.GeoJSON;var feature=format.writeFeatureObject(_this.currentFeature);if(_this.currentFeature.get("shape")==="Circle"){feature.circleParams={center:_this.currentFeature.getGeometry().getCenter(),radius:_this.currentFeature.getGeometry().getRadius()}}feature.styleName=_this.currentFeature.get("styleName");feature.styleOptions=_this.currentFeature.get("styleOptions");feature.shape=_this.currentFeature.get("shape");feature.measurements=_this.currentFeature.get("measurements");feature.crs=_this.props.mapCrs;// Don't pollute GeoJSON object properties with internal props
17
- delete feature.properties.styleName;delete feature.properties.styleOptions;delete feature.properties.shape;delete feature.properties.measurements;delete feature.properties.circleParams;// Don't store empty label prop
18
- if(feature.properties.label===""){delete feature.properties.label}return feature});_this.interactions=[];_this.picking=false;_this.currentFeature=null;_this.blockOnChange=false;_this.selectedTextStyle=function(feature,opts){return new ol.style.Style({text:new ol.style.Text({font:"10pt sans-serif",text:feature.getProperties().label||"",rotation:feature.getProperties().rotation||0,scale:opts.strokeWidth,fill:new ol.style.Fill({color:opts.textFillColor}),stroke:new ol.style.Stroke({color:[0,0,0,0.5],width:4})})})};var geometryFunction=function geometryFunction(feature){if(feature.getGeometry().getType()==="Point"){return new ol.geom.MultiPoint([feature.getGeometry().getCoordinates()])}else if(feature.getGeometry().getType()==="LineString"){return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates())}else if(feature.getGeometry().getType()==="Polygon"){return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates()[0])}else if(feature.getGeometry().getType()==="Circle"){var center=feature.getGeometry().getCenter();return new ol.geom.MultiPoint([center,[center[0]+feature.getGeometry().getRadius(),center[1]]])}return null};_this.selectedStyle=FeatureStyles.interactionVertex({geometryFunction:geometryFunction});return _this}_inherits(RedliningSupport,_React$Component);return _createClass(RedliningSupport,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){// Bind keyboard shortcuts to delete features
19
- if(this.props.redlining.action&&!prevProps.redlining.action){Mousetrap.bind("del",this.triggerDelete);Mousetrap.bind("backspace",this.triggerDelete)}else if(!this.props.redlining.action&&prevProps.redlining.action){Mousetrap.unbind("del",this.triggerDelete);Mousetrap.unbind("backspace",this.triggerDelete)}// Handle delete action immediately and reset the redlining state to the previous action
20
- if(this.props.redlining.action==="Delete"){this.deleteCurrentFeature();this.props.changeRedliningState(_objectSpread(_objectSpread({},prevProps.redlining),{},{selectedFeature:null}));return}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;if(recreateInteraction){// Commit to previous layer in case layer changed
21
- this.reset(prevProps.redlining);if(this.props.redlining.action==="Draw"){this.addDrawInteraction()}else if(this.props.redlining.action==="Transform"){this.addTransformInteraction()}else if(this.props.redlining.action==="Pick"||this.props.redlining.action==="Buffer"){this.addPickInteraction()}else if(this.props.redlining.action==="PickDraw"){this.addPickDrawInteraction()}}if(this.currentFeature){// Update feature style
22
- if(this.props.redlining.style!==prevProps.redlining.style){this.updateFeatureStyle(this.props.redlining.style)}// Update current feature measurements
23
- 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){this.currentFeature.changed()}}}},{key:"render",value:function render(){var _this2=this;if(this.props.redlining.numericInput){return/*#__PURE__*/React.createElement(NumericInputWindow,{feature:this.props.redlining.selectedFeature,onClose:function onClose(){return _this2.props.changeRedliningState({numericInput:false})},onFeatureChanged:this.updateCurrentFeature})}return null}}])}(React.Component);_defineProperty(RedliningSupport,"propTypes",{addLayerFeatures:PropTypes.func,changeRedliningState:PropTypes.func,displayCrs:PropTypes.string,map:PropTypes.object,mapCrs:PropTypes.string,redlining:PropTypes.object,removeLayerFeatures:PropTypes.func});_defineProperty(RedliningSupport,"defaultProps",{redlining:{}});export default connect(function(state){return{displayCrs:state.map.displayCrs,mapCrs:state.map.projection,redlining:state.redlining}},{changeRedliningState:changeRedliningState,addLayerFeatures:addLayerFeatures,removeLayerFeatures:removeLayerFeatures})(RedliningSupport);
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);