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,12 +1,756 @@
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 _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(r,l){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,n,i,u,a=[],f=!0,o=!1;try{if(i=(t=t.call(r)).next,0===l){if(Object(t)!==t)return;f=!1}else for(;!(f=(e=i.call(t)).done)&&(a.push(e.value),a.length!==l);f=!0);}catch(r){o=!0,n=r}finally{try{if(!f&&null!=t["return"]&&(u=t["return"](),Object(u)!==u))return}finally{if(o)throw n}}return a}}function _arrayWithHoles(r){if(Array.isArray(r))return r}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 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 _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 _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 _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
5
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
6
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
7
+ 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."); }
8
+ 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; } }
9
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
10
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
11
+ 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; }
12
+ 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; }
13
+ 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; }
14
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
15
+ 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); } }
16
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
17
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
18
+ 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); }
19
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
20
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
21
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
22
+ 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); }
23
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
24
+ 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; }
25
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
26
+ 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); }
27
+ /**
2
28
  * Copyright 2017-2024 Sourcepole AG
3
29
  * All rights reserved.
4
30
  *
5
31
  * This source code is licensed under the BSD-style license found in the
6
32
  * LICENSE file in the root directory of this source tree.
7
- */import React from"react";import{connect}from"react-redux";import FileSaver from"file-saver";import ol from"openlayers";import PropTypes from"prop-types";import{LayerRole,addLayer}from"../actions/layers";import{setSnappingConfig}from"../actions/map";import{changeRedliningState,resetRedliningState}from"../actions/redlining";import Icon from"../components/Icon";import TaskBar from"../components/TaskBar";import ButtonBar from"../components/widgets/ButtonBar";import ColorButton from"../components/widgets/ColorButton";import ComboBox from"../components/widgets/ComboBox";import MenuButton from"../components/widgets/MenuButton";import NumberInput from"../components/widgets/NumberInput";import VectorLayerPicker from"../components/widgets/VectorLayerPicker";import ConfigUtils from"../utils/ConfigUtils";import{END_MARKERS}from"../utils/FeatureStyles";import LocaleUtils from"../utils/LocaleUtils";import MapUtils from"../utils/MapUtils";import VectorLayerUtils from"../utils/VectorLayerUtils";import"./style/Redlining.css";/**
33
+ */
34
+
35
+ import React from 'react';
36
+ import { connect } from 'react-redux';
37
+ import FileSaver from 'file-saver';
38
+ import ol from 'openlayers';
39
+ import PropTypes from 'prop-types';
40
+ import { LayerRole, addLayer } from '../actions/layers';
41
+ import { setSnappingConfig } from '../actions/map';
42
+ import { changeRedliningState, resetRedliningState } from '../actions/redlining';
43
+ import Icon from '../components/Icon';
44
+ import TaskBar from '../components/TaskBar';
45
+ import ButtonBar from '../components/widgets/ButtonBar';
46
+ import ColorButton from '../components/widgets/ColorButton';
47
+ import ComboBox from '../components/widgets/ComboBox';
48
+ import MenuButton from '../components/widgets/MenuButton';
49
+ import NumberInput from '../components/widgets/NumberInput';
50
+ import VectorLayerPicker from '../components/widgets/VectorLayerPicker';
51
+ import ConfigUtils from '../utils/ConfigUtils';
52
+ import { END_MARKERS } from '../utils/FeatureStyles';
53
+ import LocaleUtils from '../utils/LocaleUtils';
54
+ import MapUtils from '../utils/MapUtils';
55
+ import VectorLayerUtils from '../utils/VectorLayerUtils';
56
+ import './style/Redlining.css';
57
+
58
+ /**
8
59
  * Allows drawing figures and text labels on the map.
9
- */var Redlining=/*#__PURE__*/function(_React$Component){function Redlining(props){var _this;_classCallCheck(this,Redlining);_this=_callSuper(this,Redlining,[props]);_defineProperty(_this,"state",{selectText:false});_defineProperty(_this,"onShow",function(mode,data){var _data$geomType;_this.props.changeRedliningState(_objectSpread({action:mode!==null&&mode!==void 0?mode:"Pick",geomType:(_data$geomType=data===null||data===void 0?void 0:data.geomType)!==null&&_data$geomType!==void 0?_data$geomType:null},_this.redliningStateDefaults()));_this.props.setSnappingConfig(_this.props.snapping,_this.props.snappingActive);if(data&&data.layerId){var layer=_this.props.layers.find(function(l){return l.id===data.layerId});if(layer){_this.changeRedliningLayer(layer)}}});_defineProperty(_this,"onHide",function(){_this.props.resetRedliningState()});_defineProperty(_this,"redliningStateDefaults",function(){return{style:_objectSpread(_objectSpread({},_this.props.redlining.style),{},{borderColor:_this.props.defaultBorderColor,fillColor:_this.props.defaultFillColor,textOutlineColor:_this.props.defaultTextOutlineColor,textFillColor:_this.props.defaultTextFillColor}),lenUnit:_this.props.defaultLengthUnit,areaUnit:_this.props.defaultAreaUnit}});_defineProperty(_this,"generateDashIcons",function(){_this.dashIcons=_this.props.predefinedDashPatterns.reduce(function(res,pattern){var svg="<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"16\"><line x1=\"0\" y1=\"8\" x2=\"32\" y2=\"8\" stroke=\"black\" stroke-width=\"2\" stroke-dasharray=\"".concat(pattern.join(" "),"\"></line></svg>");res[pattern.join(":")]="data:image/svg+xml;base64,".concat(btoa(svg));return res},{})});_defineProperty(_this,"updateRedliningStyle",function(diff){var newStyle=_objectSpread(_objectSpread({},_this.props.redlining.style),diff);_this.props.changeRedliningState({style:newStyle})});_defineProperty(_this,"renderBody",function(){var _this$props$layers$fi;var toolEnabled=function toolEnabled(tool){return!_this.props.hiddenTools.includes(tool)};var activeButton=_this.props.redlining.action==="Draw"?_this.props.redlining.geomType:_this.props.redlining.action;var drawButtons=[{key:"Point",tooltip:LocaleUtils.tr("redlining.point"),icon:"point",data:{action:"Draw",geomType:"Point",text:""}},{key:"LineString",tooltip:LocaleUtils.tr("redlining.line"),icon:"line",data:{action:"Draw",geomType:"LineString",text:""}},{key:"Polygon",tooltip:LocaleUtils.tr("redlining.polygon"),icon:"polygon",data:{action:"Draw",geomType:"Polygon",text:""}},[toolEnabled("Circle")?{key:"Circle",tooltip:LocaleUtils.tr("redlining.circle"),icon:"circle",data:{action:"Draw",geomType:"Circle",text:""}}:null,toolEnabled("Ellipse")?{key:"Ellipse",tooltip:LocaleUtils.tr("redlining.ellipse"),icon:"ellipse",data:{action:"Draw",geomType:"Ellipse",text:""}}:null,toolEnabled("Square")?{key:"Square",tooltip:LocaleUtils.tr("redlining.square"),icon:"box",data:{action:"Draw",geomType:"Square",text:""}}:null,toolEnabled("Box")?{key:"Box",tooltip:LocaleUtils.tr("redlining.rectangle"),icon:"rect",data:{action:"Draw",geomType:"Box",text:""}}:null].filter(Boolean),{key:"Text",tooltip:LocaleUtils.tr("redlining.text"),icon:"text",data:{action:"Draw",geomType:"Text",text:"",measurements:false}}];if(ConfigUtils.isMobile()){drawButtons=[drawButtons.flat()]}var activeFreeHand=_this.props.redlining.freehand?"HandDrawing":null;var freehandButtons=toolEnabled("HandWriting")?[{key:"HandDrawing",tooltip:LocaleUtils.tr("redlining.freehand"),icon:"freehand",data:{action:"Draw",geomType:_this.props.redlining.geomType,text:"",freehand:!_this.props.redlining.freehand},disabled:_this.props.redlining.geomType!=="LineString"&&_this.props.redlining.geomType!=="Polygon"}]:[];var editButtons=[{key:"Pick",tooltip:LocaleUtils.tr("redlining.pick"),icon:"nodetool",data:{action:"Pick",geomType:null,text:""}},toolEnabled("Transform")?{key:"Transform",tooltip:LocaleUtils.tr("redlining.transform"),icon:"transformtool",data:{action:"Transform",geomType:null,text:""}}:null,{key:"Delete",tooltip:LocaleUtils.tr("redlining.delete"),icon:"trash",data:{action:"Delete",geomType:null},disabled:!_this.props.redlining.selectedFeature}].filter(Boolean);var extraButtons=toolEnabled("NumericInput")?[{key:"NumericInput",tooltip:LocaleUtils.tr("redlining.numericinput"),icon:"numericinput"}]:[];for(var _i=0,_Object$values=Object.values(_this.props.plugins||{});_i<_Object$values.length;_i++){var plugin=_Object$values[_i];if(toolEnabled(plugin.cfg.key)){editButtons.push(_objectSpread(_objectSpread({},plugin.cfg),{},{tooltip:plugin.cfg.tooltip?LocaleUtils.tr(plugin.cfg.tooltip):undefined}))}}var vectorLayers=_this.props.layers.filter(function(layer){return layer.type==="vector"&&layer.role===LayerRole.USERLAYER&&!layer.readonly});// Ensure list always contains at least a "Redlining" layer
10
- if(vectorLayers.length===0){vectorLayers=[{id:"redlining",title:LocaleUtils.tr("redlining.layertitle")}].concat(_toConsumableArray(vectorLayers))}var haveLayer=(((_this$props$layers$fi=_this.props.layers.find(function(l){return l.id===_this.props.redlining.layer}))===null||_this$props$layers$fi===void 0||(_this$props$layers$fi=_this$props$layers$fi.features)===null||_this$props$layers$fi===void 0?void 0:_this$props$layers$fi.length)||0)>0;var activePlugin=Object.values(_this.props.plugins||{}).find(function(plugin){return plugin.cfg.key===_this.props.redlining.action});var controls=activePlugin?/*#__PURE__*/React.createElement(activePlugin.controls,null):_this.renderStandardControls();return/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("div",{className:"redlining-controlsbar"},/*#__PURE__*/React.createElement("div",{className:"redlining-groupcontrol"},/*#__PURE__*/React.createElement("div",null,LocaleUtils.tr("redlining.layer")),/*#__PURE__*/React.createElement(VectorLayerPicker,{addLayer:_this.props.addLayer,layers:vectorLayers,onChange:_this.changeRedliningLayer,value:_this.props.redlining.layer})),/*#__PURE__*/React.createElement("div",{className:"redlining-groupcontrol"},/*#__PURE__*/React.createElement("div",null,LocaleUtils.tr("redlining.draw")),/*#__PURE__*/React.createElement("div",{className:"controlgroup"},/*#__PURE__*/React.createElement(ButtonBar,{active:activeButton,buttons:drawButtons,onClick:function onClick(key,data){return _this.actionChanged(data)}}),_this.props.redlining.action==="Draw"&&(_this.props.redlining.geomType==="LineString"||_this.props.redlining.geomType==="Polygon")?/*#__PURE__*/React.createElement(ButtonBar,{active:activeFreeHand,buttons:freehandButtons,onClick:function onClick(key,data){return _this.actionChanged(data)}}):null)),/*#__PURE__*/React.createElement("div",{className:"redlining-groupcontrol"},/*#__PURE__*/React.createElement("div",null,LocaleUtils.tr("redlining.edit")),/*#__PURE__*/React.createElement(ButtonBar,{active:activeButton,buttons:editButtons,onClick:function onClick(key,data){return _this.actionChanged(data)}})),/*#__PURE__*/React.createElement("div",{className:"redlining-groupcontrol"},/*#__PURE__*/React.createElement("div",null,"\xA0"),/*#__PURE__*/React.createElement(ButtonBar,{active:_this.props.redlining.numericInput?"NumericInput":null,buttons:extraButtons,onClick:function onClick(){return _this.props.changeRedliningState({numericInput:!_this.props.redlining.numericInput})}})),toolEnabled("Export")?/*#__PURE__*/React.createElement("div",{className:"redlining-groupcontrol"},/*#__PURE__*/React.createElement("div",null,"\xA0"),/*#__PURE__*/React.createElement(MenuButton,{className:"redlining-export-menu",disabled:!haveLayer,menuIcon:"export",onActivate:_this["export"],tooltip:LocaleUtils.tr("redlining.export")},/*#__PURE__*/React.createElement("div",{className:"redlining-export-menu-entry",key:"GeoJSON",value:"geojson"},"GeoJSON"),/*#__PURE__*/React.createElement("div",{className:"redlining-export-menu-entry",key:"KML",value:"kml"},"KML"))):null),controls)});_defineProperty(_this,"export",function(type){if(type==="geojson"){var layer=_this.props.layers.find(function(l){return l.id===_this.props.redlining.layer});if(!layer){return}var geojson=JSON.stringify({type:"FeatureCollection",features:layer.features.map(function(feature){var newFeature=_objectSpread(_objectSpread({},feature),{},{geometry:VectorLayerUtils.reprojectGeometry(feature.geometry,feature.crs||_this.props.mapCrs,"EPSG:4326")});delete newFeature.crs;return newFeature})},null," ");FileSaver.saveAs(new Blob([geojson],{type:"text/plain;charset=utf-8"}),layer.title+".json")}else if(type==="kml"){var getNativeLayer=MapUtils.getHook(MapUtils.GET_NATIVE_LAYER);var _layer=_this.props.layers.find(function(l){return l.id===_this.props.redlining.layer});var nativeLayer=getNativeLayer(_this.props.redlining.layer);if(!nativeLayer){return}var kmlFormat=new ol.format.KML;var features=nativeLayer.getSource().getFeatures().map(function(feature){// Circle is not supported by kml format
11
- if(feature.getGeometry()instanceof ol.geom.Circle){feature=feature.clone();feature.setGeometry(ol.geom.polygonFromCircle(feature.getGeometry()))}return feature});var data=kmlFormat.writeFeatures(features,{featureProjection:_this.props.mapCrs});FileSaver.saveAs(new Blob([data],{type:"application/vnd.google-earth.kml+xml"}),_layer.title+".kml")}});_defineProperty(_this,"renderStandardControls",function(){var sizeLabel=LocaleUtils.tr("redlining.line");var showDash=true;if(["Text","Point"].includes(_this.props.redlining.geomType)){sizeLabel=LocaleUtils.tr("redlining.size");showDash=false}var labelPlaceholder=LocaleUtils.tr("redlining.label");if(_this.props.redlining.geomType==="Text"){labelPlaceholder=LocaleUtils.tr("redlining.text")}if(_this.props.redlining.action!=="Draw"&&!_this.props.redlining.selectedFeature){return null}return/*#__PURE__*/React.createElement("div",{className:"redlining-controlsbar"},/*#__PURE__*/React.createElement("div",{className:"redlining-control"},/*#__PURE__*/React.createElement(Icon,{className:"redlining-control-icon",icon:"pen",size:"large"}),_this.props.redlining.geomType==="Text"?/*#__PURE__*/React.createElement(ColorButton,{color:_this.props.redlining.style.textOutlineColor,defaultColors:_this.props.predefinedBorderColors,onColorChanged:function onColorChanged(color){return _this.updateRedliningStyle({textOutlineColor:color})}}):/*#__PURE__*/React.createElement(ColorButton,{color:_this.props.redlining.style.borderColor,defaultColors:_this.props.predefinedBorderColors,onColorChanged:function onColorChanged(color){return _this.updateRedliningStyle({borderColor:color})}})),_this.props.redlining.geomType==="LineString"?null:/*#__PURE__*/React.createElement("div",{className:"redlining-control"},/*#__PURE__*/React.createElement(Icon,{className:"redlining-control-icon",icon:"fill",size:"large"}),_this.props.redlining.geomType==="Text"?/*#__PURE__*/React.createElement(ColorButton,{color:_this.props.redlining.style.textFillColor,defaultColors:_this.props.predefinedFillColors,onColorChanged:function onColorChanged(color){return _this.updateRedliningStyle({textFillColor:color})}}):/*#__PURE__*/React.createElement(ColorButton,{color:_this.props.redlining.style.fillColor,defaultColors:_this.props.predefinedFillColors,onColorChanged:function onColorChanged(color){return _this.updateRedliningStyle({fillColor:color})}})),/*#__PURE__*/React.createElement("div",{className:"redlining-control"},/*#__PURE__*/React.createElement("span",null,sizeLabel,":\xA0"),/*#__PURE__*/React.createElement(NumberInput,{max:99,min:1,mobile:true,onChange:function onChange(nr){return _this.updateRedliningStyle({size:nr})},value:_this.props.redlining.style.size}),showDash?/*#__PURE__*/React.createElement(ComboBox,{onChange:function onChange(value){return _this.updateRedliningStyle({strokeDash:value.split(":").filter(Boolean).map(Number)})},value:_this.props.redlining.style.strokeDash.join(":")},_this.props.predefinedDashPatterns.map(function(pattern){var value=pattern.join(":");return/*#__PURE__*/React.createElement("div",{className:"redlining-dash-combo-entry",key:value,value:value},/*#__PURE__*/React.createElement("img",{src:_this.dashIcons[value]}))})):null),_this.props.redlining.geomType==="LineString"?/*#__PURE__*/React.createElement("div",{className:"redlining-control"},/*#__PURE__*/React.createElement("span",null,LocaleUtils.tr("redlining.markers"),":\xA0"),/*#__PURE__*/React.createElement("div",{className:"controlgroup"},/*#__PURE__*/React.createElement(ComboBox,{className:"redlining-marker-combo",onChange:function onChange(value){return _this.updateRedliningStyle({headmarker:value})},value:_this.props.redlining.style.headmarker||""},/*#__PURE__*/React.createElement("div",{className:"redlining-marker-combo-entry",value:""}),Object.entries(END_MARKERS).map(function(_ref){var _ref2=_slicedToArray(_ref,2),key=_ref2[0],params=_ref2[1];return/*#__PURE__*/React.createElement("div",{className:"redlining-marker-combo-entry",key:key,value:key},/*#__PURE__*/React.createElement("img",{src:params.src,style:{transform:"rotate("+params.baserotation+"deg)"}}))})),/*#__PURE__*/React.createElement(ComboBox,{className:"redlining-marker-combo",onChange:function onChange(value){return _this.updateRedliningStyle({tailmarker:value})},value:_this.props.redlining.style.tailmarker||""},/*#__PURE__*/React.createElement("div",{className:"redlining-marker-combo-entry",value:""}),Object.entries(END_MARKERS).map(function(_ref3){var _ref4=_slicedToArray(_ref3,2),key=_ref4[0],params=_ref4[1];return/*#__PURE__*/React.createElement("div",{className:"redlining-marker-combo-entry",key:key,value:key},/*#__PURE__*/React.createElement("img",{src:params.src,style:{transform:"rotate("+(180+params.baserotation)+"deg)"}}))})))):null,/*#__PURE__*/React.createElement("div",{className:"redlining-control redlining-control-fill"},/*#__PURE__*/React.createElement("div",{className:"controlgroup"},_this.props.redlining.geomType!=="Text"&&_this.props.allowGeometryLabels?/*#__PURE__*/React.createElement("button",{className:"button"+(_this.props.redlining.measurements?" pressed":""),onClick:function onClick(){return _this.props.changeRedliningState({measurements:!_this.props.redlining.measurements,style:_objectSpread(_objectSpread({},_this.props.redlining.style),{},{text:""})})},title:LocaleUtils.tr("redlining.measurements")},/*#__PURE__*/React.createElement(Icon,{icon:"measure"})):null,(_this.props.redlining.geomType==="Text"||_this.props.allowGeometryLabels)&&!_this.props.redlining.measurements?/*#__PURE__*/React.createElement("input",{className:"controlgroup-fillitem",onChange:function onChange(ev){return _this.updateRedliningStyle({text:ev.target.value})},placeholder:labelPlaceholder,readOnly:_this.props.redlining.measurements,ref:function ref(el){return _this.setLabelRef(el)},type:"text",value:_this.props.redlining.style.text}):null,_this.props.redlining.measurements&&["LineString","Circle"].includes(_this.props.redlining.geomType)?/*#__PURE__*/React.createElement("select",{className:"controlgroup-fillitem",onChange:function onChange(ev){return _this.props.changeRedliningState({lenUnit:ev.target.value})},value:_this.props.redlining.lenUnit},/*#__PURE__*/React.createElement("option",{value:"metric"},LocaleUtils.tr("measureComponent.metric")),/*#__PURE__*/React.createElement("option",{value:"imperial"},LocaleUtils.tr("measureComponent.imperial")),/*#__PURE__*/React.createElement("option",{value:"m"},"m"),/*#__PURE__*/React.createElement("option",{value:"km"},"km"),/*#__PURE__*/React.createElement("option",{value:"ft"},"ft"),/*#__PURE__*/React.createElement("option",{value:"mi"},"mi")):null,_this.props.redlining.measurements&&["Polygon","Ellipse","Square","Box"].includes(_this.props.redlining.geomType)?/*#__PURE__*/React.createElement("select",{className:"controlgroup-fillitem",onChange:function onChange(ev){return _this.props.changeRedliningState({areaUnit:ev.target.value})},value:_this.props.redlining.areaUnit},/*#__PURE__*/React.createElement("option",{value:"metric"},LocaleUtils.tr("measureComponent.metric")),/*#__PURE__*/React.createElement("option",{value:"imperial"},LocaleUtils.tr("measureComponent.imperial")),/*#__PURE__*/React.createElement("option",{value:"sqm"},"m\xB2"),/*#__PURE__*/React.createElement("option",{value:"ha"},"ha"),/*#__PURE__*/React.createElement("option",{value:"sqkm"},"km\xB2"),/*#__PURE__*/React.createElement("option",{value:"sqft"},"ft\xB2"),/*#__PURE__*/React.createElement("option",{value:"acre"},"acre"),/*#__PURE__*/React.createElement("option",{value:"sqmi"},"mi\xB2")):null)))});_defineProperty(_this,"setLabelRef",function(el){_this.labelInput=el;if(el&&_this.state.selectText){el.focus();el.select();_this.setState({selectText:false})}});_defineProperty(_this,"actionChanged",function(data){if(data.action==="Draw"&&data.geomType==="Text"){data=_objectSpread(_objectSpread({},data),{},{style:{text:LocaleUtils.tr("redlining.text")}})}else if(!_this.props.allowGeometryLabels){data=_objectSpread(_objectSpread({},data),{},{style:{text:""}})}_this.props.changeRedliningState(data)});_defineProperty(_this,"changeRedliningLayer",function(layer){var action=["Draw","Pick","Transform"].includes(_this.props.redlining.action)?_this.props.redlining.action:"Pick";_this.props.changeRedliningState({layer:layer.id,layerTitle:layer.title,action:action})});_this.labelInput=null;_this.dashIcons={};return _this}_inherits(Redlining,_React$Component);return _createClass(Redlining,[{key:"componentDidMount",value:function componentDidMount(){this.componentDidUpdate({redlining:{}})}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){var _this2=this;if(this.props.defaultBorderColor!==prevProps.defaultBorderColor||this.props.defaultFillColor!==prevProps.defaultFillColor||this.props.defaultLengthUnit!==prevProps.defaultLengthUnit||this.props.defaultAreaUnit!==prevProps.defaultAreaUnit||this.props.defaultTextFillColor!==prevProps.defaultTextFillColor||this.props.defaultTextOutlineColor!==prevProps.defaultTextOutlineColor){this.props.changeRedliningState(this.redliningStateDefaults())}if(prevProps.redlining.geomType!==this.props.redlining.geomType&&this.props.redlining.geomType==="Text"&&!this.state.selectText){this.setState({selectText:true})}if(!this.props.layers.find(function(layer){return layer.id===_this2.props.redlining.layer})){var vectorLayers=this.props.layers.filter(function(layer){return layer.type==="vector"&&layer.role===LayerRole.USERLAYER&&!layer.readonly});if(vectorLayers.length>=1){this.props.changeRedliningState({layer:vectorLayers[0].id,layerTitle:vectorLayers[0].title})}else if(this.props.redlining.layer!=="redlining"){this.props.changeRedliningState({layer:"redlining",layerTitle:LocaleUtils.tr("redlining.layertitle")})}}if(this.props.predefinedDashPatterns!==prevProps.predefinedDashPatterns){this.generateDashIcons()}}},{key:"render",value:function render(){var _this3=this;return/*#__PURE__*/React.createElement(TaskBar,{onHide:this.onHide,onShow:this.onShow,task:"Redlining"},function(){return{body:_this3.renderBody()}})}}])}(React.Component);_defineProperty(Redlining,"propTypes",{addLayer:PropTypes.func,/** Whether to allow labeling geometric figures. */allowGeometryLabels:PropTypes.bool,changeRedliningState:PropTypes.func,/** Default area unit. Options: `metric`, `imperial`, `sqm`, `ha`, `sqkm`, `sqft`, `acre`, `sqmi` */defaultAreaUnit:PropTypes.string,/** Default border color. In format `[r, g, b, a]`. */defaultBorderColor:PropTypes.array,/** Default fill color. In format `[r, g, b, a]`. */defaultFillColor:PropTypes.array,/** Default length unit. Options: `metric`, `imperial`, `m`, `km`, `ft`, `mi` */defaultLengthUnit:PropTypes.string,/** Default text fill color. In format `[r, g, b, a]`. */defaultTextFillColor:PropTypes.array,/** Default text outline color. In format `[r, g, b, a]`. */defaultTextOutlineColor:PropTypes.array,/** Tools to hide. Available tools: `Circle`, `Ellipse`, `Square`, `Box`, `HandDrawing`, `Transform`, `NumericInput`, `Buffer`, `Export`. */hiddenTools:PropTypes.array,layers:PropTypes.array,mapCrs:PropTypes.string,plugins:PropTypes.object,/** Predefined border colors. In format `[[r, g, b, a], ...]`. */predefinedBorderColors:PropTypes.arrayOf(PropTypes.array),/** Predefined dash patterns. In format `[<dash-array>, ...]`, where a dash-array is list of alternating dash and gap widths, i.e. `[8 4]` for long dashes followed by shorter gaps. */predefinedDashPatterns:PropTypes.arrayOf(PropTypes.array),/** Predefined fill colors. In format `[[r, g, b, a], ...]`. */predefinedFillColors:PropTypes.arrayOf(PropTypes.array),redlining:PropTypes.object,resetRedliningState:PropTypes.func,setCurrentTask:PropTypes.func,setSnappingConfig:PropTypes.func,/** Whether snapping is available when editing. */snapping:PropTypes.bool,/** Whether snapping is enabled by default when editing.
12
- * Either `false`, `edge`, `vertex` or `true` (i.e. both vertex and edge). */snappingActive:PropTypes.oneOfType([PropTypes.bool,PropTypes.string])});_defineProperty(Redlining,"defaultProps",{allowGeometryLabels:true,hiddenTools:[],snapping:true,snappingActive:true,plugins:[],defaultBorderColor:[255,0,0,1],defaultFillColor:[255,255,255,1],defaultTextFillColor:[0,0,0,1],defaultTextOutlineColor:[255,255,255,1],defaultAreaUnit:"metric",defaultLengthUnit:"metric",predefinedDashPatterns:[[],[8,8],[1,8],[8,8,1,8]]});export default(function(plugins){return connect(function(state){return{layers:state.layers.flat,redlining:state.redlining,mapCrs:state.map.projection,plugins:plugins}},{changeRedliningState:changeRedliningState,addLayer:addLayer,resetRedliningState:resetRedliningState,setSnappingConfig:setSnappingConfig})(Redlining)});
60
+ */
61
+ var Redlining = /*#__PURE__*/function (_React$Component) {
62
+ function Redlining(props) {
63
+ var _this;
64
+ _classCallCheck(this, Redlining);
65
+ _this = _callSuper(this, Redlining, [props]);
66
+ _defineProperty(_this, "state", {
67
+ selectText: false
68
+ });
69
+ _defineProperty(_this, "onShow", function (mode, data) {
70
+ var _data$geomType;
71
+ _this.props.changeRedliningState(_objectSpread({
72
+ action: mode !== null && mode !== void 0 ? mode : 'Pick',
73
+ geomType: (_data$geomType = data === null || data === void 0 ? void 0 : data.geomType) !== null && _data$geomType !== void 0 ? _data$geomType : null
74
+ }, _this.redliningStateDefaults()));
75
+ _this.props.setSnappingConfig(_this.props.snapping, _this.props.snappingActive);
76
+ if (data && data.layerId) {
77
+ var layer = _this.props.layers.find(function (l) {
78
+ return l.id === data.layerId;
79
+ });
80
+ if (layer) {
81
+ _this.changeRedliningLayer(layer);
82
+ }
83
+ }
84
+ });
85
+ _defineProperty(_this, "onHide", function () {
86
+ _this.props.resetRedliningState();
87
+ });
88
+ _defineProperty(_this, "redliningStateDefaults", function () {
89
+ return {
90
+ style: _objectSpread(_objectSpread({}, _this.props.redlining.style), {}, {
91
+ borderColor: _this.props.defaultBorderColor,
92
+ fillColor: _this.props.defaultFillColor,
93
+ textOutlineColor: _this.props.defaultTextOutlineColor,
94
+ textFillColor: _this.props.defaultTextFillColor
95
+ }),
96
+ lenUnit: _this.props.defaultLengthUnit,
97
+ areaUnit: _this.props.defaultAreaUnit
98
+ };
99
+ });
100
+ _defineProperty(_this, "generateDashIcons", function () {
101
+ _this.dashIcons = _this.props.predefinedDashPatterns.reduce(function (res, pattern) {
102
+ var svg = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"16\"><line x1=\"0\" y1=\"8\" x2=\"32\" y2=\"8\" stroke=\"black\" stroke-width=\"2\" stroke-dasharray=\"".concat(pattern.join(" "), "\"></line></svg>");
103
+ res[pattern.join(":")] = "data:image/svg+xml;base64,".concat(btoa(svg));
104
+ return res;
105
+ }, {});
106
+ });
107
+ _defineProperty(_this, "updateRedliningStyle", function (diff) {
108
+ var newStyle = _objectSpread(_objectSpread({}, _this.props.redlining.style), diff);
109
+ _this.props.changeRedliningState({
110
+ style: newStyle
111
+ });
112
+ });
113
+ _defineProperty(_this, "renderBody", function () {
114
+ var _this$props$layers$fi;
115
+ var toolEnabled = function toolEnabled(tool) {
116
+ return !_this.props.hiddenTools.includes(tool);
117
+ };
118
+ var activeButton = _this.props.redlining.action === "Draw" ? _this.props.redlining.geomType : _this.props.redlining.action;
119
+ var drawButtons = [{
120
+ key: "Point",
121
+ tooltip: LocaleUtils.tr("redlining.point"),
122
+ icon: "point",
123
+ data: {
124
+ action: "Draw",
125
+ geomType: "Point",
126
+ text: ""
127
+ }
128
+ }, {
129
+ key: "LineString",
130
+ tooltip: LocaleUtils.tr("redlining.line"),
131
+ icon: "line",
132
+ data: {
133
+ action: "Draw",
134
+ geomType: "LineString",
135
+ text: ""
136
+ }
137
+ }, {
138
+ key: "Polygon",
139
+ tooltip: LocaleUtils.tr("redlining.polygon"),
140
+ icon: "polygon",
141
+ data: {
142
+ action: "Draw",
143
+ geomType: "Polygon",
144
+ text: ""
145
+ }
146
+ }, [toolEnabled("Circle") ? {
147
+ key: "Circle",
148
+ tooltip: LocaleUtils.tr("redlining.circle"),
149
+ icon: "circle",
150
+ data: {
151
+ action: "Draw",
152
+ geomType: "Circle",
153
+ text: ""
154
+ }
155
+ } : null, toolEnabled("Ellipse") ? {
156
+ key: "Ellipse",
157
+ tooltip: LocaleUtils.tr("redlining.ellipse"),
158
+ icon: "ellipse",
159
+ data: {
160
+ action: "Draw",
161
+ geomType: "Ellipse",
162
+ text: ""
163
+ }
164
+ } : null, toolEnabled("Square") ? {
165
+ key: "Square",
166
+ tooltip: LocaleUtils.tr("redlining.square"),
167
+ icon: "box",
168
+ data: {
169
+ action: "Draw",
170
+ geomType: "Square",
171
+ text: ""
172
+ }
173
+ } : null, toolEnabled("Box") ? {
174
+ key: "Box",
175
+ tooltip: LocaleUtils.tr("redlining.rectangle"),
176
+ icon: "rect",
177
+ data: {
178
+ action: "Draw",
179
+ geomType: "Box",
180
+ text: ""
181
+ }
182
+ } : null].filter(Boolean), {
183
+ key: "Text",
184
+ tooltip: LocaleUtils.tr("redlining.text"),
185
+ icon: "text",
186
+ data: {
187
+ action: "Draw",
188
+ geomType: "Text",
189
+ text: "",
190
+ measurements: false
191
+ }
192
+ }];
193
+ if (ConfigUtils.isMobile()) {
194
+ drawButtons = [drawButtons.flat()];
195
+ }
196
+ var activeFreeHand = _this.props.redlining.freehand ? "HandDrawing" : null;
197
+ var freehandButtons = toolEnabled("HandWriting") ? [{
198
+ key: "HandDrawing",
199
+ tooltip: LocaleUtils.tr("redlining.freehand"),
200
+ icon: "freehand",
201
+ data: {
202
+ action: "Draw",
203
+ geomType: _this.props.redlining.geomType,
204
+ text: "",
205
+ freehand: !_this.props.redlining.freehand
206
+ },
207
+ disabled: _this.props.redlining.geomType !== "LineString" && _this.props.redlining.geomType !== "Polygon"
208
+ }] : [];
209
+ var editButtons = [{
210
+ key: "Pick",
211
+ tooltip: LocaleUtils.tr("redlining.pick"),
212
+ icon: "nodetool",
213
+ data: {
214
+ action: "Pick",
215
+ geomType: null,
216
+ text: ""
217
+ }
218
+ }, toolEnabled("Transform") ? {
219
+ key: "Transform",
220
+ tooltip: LocaleUtils.tr("redlining.transform"),
221
+ icon: "transformtool",
222
+ data: {
223
+ action: "Transform",
224
+ geomType: null,
225
+ text: ""
226
+ }
227
+ } : null, {
228
+ key: "Delete",
229
+ tooltip: LocaleUtils.tr("redlining.delete"),
230
+ icon: "trash",
231
+ data: {
232
+ action: "Delete",
233
+ geomType: null
234
+ },
235
+ disabled: !_this.props.redlining.selectedFeature
236
+ }].filter(Boolean);
237
+ var extraButtons = toolEnabled("NumericInput") ? [{
238
+ key: "NumericInput",
239
+ tooltip: LocaleUtils.tr("redlining.numericinput"),
240
+ icon: "numericinput"
241
+ }] : [];
242
+ for (var _i = 0, _Object$values = Object.values(_this.props.plugins || {}); _i < _Object$values.length; _i++) {
243
+ var plugin = _Object$values[_i];
244
+ if (toolEnabled(plugin.cfg.key)) {
245
+ editButtons.push(_objectSpread(_objectSpread({}, plugin.cfg), {}, {
246
+ tooltip: plugin.cfg.tooltip ? LocaleUtils.tr(plugin.cfg.tooltip) : undefined
247
+ }));
248
+ }
249
+ }
250
+ var vectorLayers = _this.props.layers.filter(function (layer) {
251
+ return layer.type === "vector" && layer.role === LayerRole.USERLAYER && !layer.readonly;
252
+ });
253
+ // Ensure list always contains at least a "Redlining" layer
254
+ if (vectorLayers.length === 0) {
255
+ vectorLayers = [{
256
+ id: 'redlining',
257
+ title: LocaleUtils.tr('redlining.layertitle')
258
+ }].concat(_toConsumableArray(vectorLayers));
259
+ }
260
+ var haveLayer = (((_this$props$layers$fi = _this.props.layers.find(function (l) {
261
+ return l.id === _this.props.redlining.layer;
262
+ })) === null || _this$props$layers$fi === void 0 || (_this$props$layers$fi = _this$props$layers$fi.features) === null || _this$props$layers$fi === void 0 ? void 0 : _this$props$layers$fi.length) || 0) > 0;
263
+ var activePlugin = Object.values(_this.props.plugins || {}).find(function (plugin) {
264
+ return plugin.cfg.key === _this.props.redlining.action;
265
+ });
266
+ var controls = activePlugin ? /*#__PURE__*/React.createElement(activePlugin.controls, null) : _this.renderStandardControls();
267
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
268
+ className: "redlining-controlsbar"
269
+ }, /*#__PURE__*/React.createElement("div", {
270
+ className: "redlining-groupcontrol"
271
+ }, /*#__PURE__*/React.createElement("div", null, LocaleUtils.tr("redlining.layer")), /*#__PURE__*/React.createElement(VectorLayerPicker, {
272
+ addLayer: _this.props.addLayer,
273
+ layers: vectorLayers,
274
+ onChange: _this.changeRedliningLayer,
275
+ value: _this.props.redlining.layer
276
+ })), /*#__PURE__*/React.createElement("div", {
277
+ className: "redlining-groupcontrol"
278
+ }, /*#__PURE__*/React.createElement("div", null, LocaleUtils.tr("redlining.draw")), /*#__PURE__*/React.createElement("div", {
279
+ className: "controlgroup"
280
+ }, /*#__PURE__*/React.createElement(ButtonBar, {
281
+ active: activeButton,
282
+ buttons: drawButtons,
283
+ onClick: function onClick(key, data) {
284
+ return _this.actionChanged(data);
285
+ }
286
+ }), _this.props.redlining.action === "Draw" && (_this.props.redlining.geomType === "LineString" || _this.props.redlining.geomType === "Polygon") ? /*#__PURE__*/React.createElement(ButtonBar, {
287
+ active: activeFreeHand,
288
+ buttons: freehandButtons,
289
+ onClick: function onClick(key, data) {
290
+ return _this.actionChanged(data);
291
+ }
292
+ }) : null)), /*#__PURE__*/React.createElement("div", {
293
+ className: "redlining-groupcontrol"
294
+ }, /*#__PURE__*/React.createElement("div", null, LocaleUtils.tr("redlining.edit")), /*#__PURE__*/React.createElement(ButtonBar, {
295
+ active: activeButton,
296
+ buttons: editButtons,
297
+ onClick: function onClick(key, data) {
298
+ return _this.actionChanged(data);
299
+ }
300
+ })), /*#__PURE__*/React.createElement("div", {
301
+ className: "redlining-groupcontrol"
302
+ }, /*#__PURE__*/React.createElement("div", null, "\xA0"), /*#__PURE__*/React.createElement(ButtonBar, {
303
+ active: _this.props.redlining.numericInput ? "NumericInput" : null,
304
+ buttons: extraButtons,
305
+ onClick: function onClick() {
306
+ return _this.props.changeRedliningState({
307
+ numericInput: !_this.props.redlining.numericInput
308
+ });
309
+ }
310
+ })), toolEnabled("Export") ? /*#__PURE__*/React.createElement("div", {
311
+ className: "redlining-groupcontrol"
312
+ }, /*#__PURE__*/React.createElement("div", null, "\xA0"), /*#__PURE__*/React.createElement(MenuButton, {
313
+ className: "redlining-export-menu",
314
+ disabled: !haveLayer,
315
+ menuIcon: "export",
316
+ onActivate: _this["export"],
317
+ tooltip: LocaleUtils.tr("redlining.export")
318
+ }, /*#__PURE__*/React.createElement("div", {
319
+ className: "redlining-export-menu-entry",
320
+ key: "GeoJSON",
321
+ value: "geojson"
322
+ }, "GeoJSON"), /*#__PURE__*/React.createElement("div", {
323
+ className: "redlining-export-menu-entry",
324
+ key: "KML",
325
+ value: "kml"
326
+ }, "KML"))) : null), controls);
327
+ });
328
+ _defineProperty(_this, "export", function (type) {
329
+ if (type === "geojson") {
330
+ var layer = _this.props.layers.find(function (l) {
331
+ return l.id === _this.props.redlining.layer;
332
+ });
333
+ if (!layer) {
334
+ return;
335
+ }
336
+ var geojson = JSON.stringify({
337
+ type: "FeatureCollection",
338
+ features: layer.features.map(function (feature) {
339
+ var newFeature = _objectSpread(_objectSpread({}, feature), {}, {
340
+ geometry: VectorLayerUtils.reprojectGeometry(feature.geometry, feature.crs || _this.props.mapCrs, 'EPSG:4326')
341
+ });
342
+ delete newFeature.crs;
343
+ return newFeature;
344
+ })
345
+ }, null, ' ');
346
+ FileSaver.saveAs(new Blob([geojson], {
347
+ type: "text/plain;charset=utf-8"
348
+ }), layer.title + ".json");
349
+ } else if (type === "kml") {
350
+ var getNativeLayer = MapUtils.getHook(MapUtils.GET_NATIVE_LAYER);
351
+ var _layer = _this.props.layers.find(function (l) {
352
+ return l.id === _this.props.redlining.layer;
353
+ });
354
+ var nativeLayer = getNativeLayer(_this.props.redlining.layer);
355
+ if (!nativeLayer) {
356
+ return;
357
+ }
358
+ var kmlFormat = new ol.format.KML();
359
+ var features = nativeLayer.getSource().getFeatures().map(function (feature) {
360
+ // Circle is not supported by kml format
361
+ if (feature.getGeometry() instanceof ol.geom.Circle) {
362
+ feature = feature.clone();
363
+ feature.setGeometry(ol.geom.polygonFromCircle(feature.getGeometry()));
364
+ }
365
+ return feature;
366
+ });
367
+ var data = kmlFormat.writeFeatures(features, {
368
+ featureProjection: _this.props.mapCrs
369
+ });
370
+ FileSaver.saveAs(new Blob([data], {
371
+ type: "application/vnd.google-earth.kml+xml"
372
+ }), _layer.title + ".kml");
373
+ }
374
+ });
375
+ _defineProperty(_this, "renderStandardControls", function () {
376
+ var sizeLabel = LocaleUtils.tr("redlining.line");
377
+ var showDash = true;
378
+ if (["Text", "Point"].includes(_this.props.redlining.geomType)) {
379
+ sizeLabel = LocaleUtils.tr("redlining.size");
380
+ showDash = false;
381
+ }
382
+ var labelPlaceholder = LocaleUtils.tr("redlining.label");
383
+ if (_this.props.redlining.geomType === "Text") {
384
+ labelPlaceholder = LocaleUtils.tr("redlining.text");
385
+ }
386
+ if (_this.props.redlining.action !== 'Draw' && !_this.props.redlining.selectedFeature) {
387
+ return null;
388
+ }
389
+ return /*#__PURE__*/React.createElement("div", {
390
+ className: "redlining-controlsbar"
391
+ }, /*#__PURE__*/React.createElement("div", {
392
+ className: "redlining-control"
393
+ }, /*#__PURE__*/React.createElement(Icon, {
394
+ className: "redlining-control-icon",
395
+ icon: "pen",
396
+ size: "large"
397
+ }), _this.props.redlining.geomType === 'Text' ? /*#__PURE__*/React.createElement(ColorButton, {
398
+ color: _this.props.redlining.style.textOutlineColor,
399
+ defaultColors: _this.props.predefinedBorderColors,
400
+ onColorChanged: function onColorChanged(color) {
401
+ return _this.updateRedliningStyle({
402
+ textOutlineColor: color
403
+ });
404
+ }
405
+ }) : /*#__PURE__*/React.createElement(ColorButton, {
406
+ color: _this.props.redlining.style.borderColor,
407
+ defaultColors: _this.props.predefinedBorderColors,
408
+ onColorChanged: function onColorChanged(color) {
409
+ return _this.updateRedliningStyle({
410
+ borderColor: color
411
+ });
412
+ }
413
+ })), _this.props.redlining.geomType === 'LineString' ? null : /*#__PURE__*/React.createElement("div", {
414
+ className: "redlining-control"
415
+ }, /*#__PURE__*/React.createElement(Icon, {
416
+ className: "redlining-control-icon",
417
+ icon: "fill",
418
+ size: "large"
419
+ }), _this.props.redlining.geomType === 'Text' ? /*#__PURE__*/React.createElement(ColorButton, {
420
+ color: _this.props.redlining.style.textFillColor,
421
+ defaultColors: _this.props.predefinedFillColors,
422
+ onColorChanged: function onColorChanged(color) {
423
+ return _this.updateRedliningStyle({
424
+ textFillColor: color
425
+ });
426
+ }
427
+ }) : /*#__PURE__*/React.createElement(ColorButton, {
428
+ color: _this.props.redlining.style.fillColor,
429
+ defaultColors: _this.props.predefinedFillColors,
430
+ onColorChanged: function onColorChanged(color) {
431
+ return _this.updateRedliningStyle({
432
+ fillColor: color
433
+ });
434
+ }
435
+ })), /*#__PURE__*/React.createElement("div", {
436
+ className: "redlining-control"
437
+ }, /*#__PURE__*/React.createElement("span", null, sizeLabel, ":\xA0"), /*#__PURE__*/React.createElement(NumberInput, {
438
+ max: 99,
439
+ min: 1,
440
+ mobile: true,
441
+ onChange: function onChange(nr) {
442
+ return _this.updateRedliningStyle({
443
+ size: nr
444
+ });
445
+ },
446
+ value: _this.props.redlining.style.size
447
+ }), showDash ? /*#__PURE__*/React.createElement(ComboBox, {
448
+ onChange: function onChange(value) {
449
+ return _this.updateRedliningStyle({
450
+ strokeDash: value.split(":").filter(Boolean).map(Number)
451
+ });
452
+ },
453
+ value: _this.props.redlining.style.strokeDash.join(":")
454
+ }, _this.props.predefinedDashPatterns.map(function (pattern) {
455
+ var value = pattern.join(":");
456
+ return /*#__PURE__*/React.createElement("div", {
457
+ className: "redlining-dash-combo-entry",
458
+ key: value,
459
+ value: value
460
+ }, /*#__PURE__*/React.createElement("img", {
461
+ src: _this.dashIcons[value]
462
+ }));
463
+ })) : null), _this.props.redlining.geomType === 'LineString' ? /*#__PURE__*/React.createElement("div", {
464
+ className: "redlining-control"
465
+ }, /*#__PURE__*/React.createElement("span", null, LocaleUtils.tr("redlining.markers"), ":\xA0"), /*#__PURE__*/React.createElement("div", {
466
+ className: "controlgroup"
467
+ }, /*#__PURE__*/React.createElement(ComboBox, {
468
+ className: "redlining-marker-combo",
469
+ onChange: function onChange(value) {
470
+ return _this.updateRedliningStyle({
471
+ headmarker: value
472
+ });
473
+ },
474
+ value: _this.props.redlining.style.headmarker || ""
475
+ }, /*#__PURE__*/React.createElement("div", {
476
+ className: "redlining-marker-combo-entry",
477
+ value: ""
478
+ }), Object.entries(END_MARKERS).map(function (_ref) {
479
+ var _ref2 = _slicedToArray(_ref, 2),
480
+ key = _ref2[0],
481
+ params = _ref2[1];
482
+ return /*#__PURE__*/React.createElement("div", {
483
+ className: "redlining-marker-combo-entry",
484
+ key: key,
485
+ value: key
486
+ }, /*#__PURE__*/React.createElement("img", {
487
+ src: params.src,
488
+ style: {
489
+ transform: 'rotate(' + params.baserotation + 'deg)'
490
+ }
491
+ }));
492
+ })), /*#__PURE__*/React.createElement(ComboBox, {
493
+ className: "redlining-marker-combo",
494
+ onChange: function onChange(value) {
495
+ return _this.updateRedliningStyle({
496
+ tailmarker: value
497
+ });
498
+ },
499
+ value: _this.props.redlining.style.tailmarker || ""
500
+ }, /*#__PURE__*/React.createElement("div", {
501
+ className: "redlining-marker-combo-entry",
502
+ value: ""
503
+ }), Object.entries(END_MARKERS).map(function (_ref3) {
504
+ var _ref4 = _slicedToArray(_ref3, 2),
505
+ key = _ref4[0],
506
+ params = _ref4[1];
507
+ return /*#__PURE__*/React.createElement("div", {
508
+ className: "redlining-marker-combo-entry",
509
+ key: key,
510
+ value: key
511
+ }, /*#__PURE__*/React.createElement("img", {
512
+ src: params.src,
513
+ style: {
514
+ transform: 'rotate(' + (180 + params.baserotation) + 'deg)'
515
+ }
516
+ }));
517
+ })))) : null, /*#__PURE__*/React.createElement("div", {
518
+ className: "redlining-control redlining-control-fill"
519
+ }, /*#__PURE__*/React.createElement("div", {
520
+ className: "controlgroup"
521
+ }, _this.props.redlining.geomType !== 'Text' && _this.props.allowGeometryLabels ? /*#__PURE__*/React.createElement("button", {
522
+ className: "button" + (_this.props.redlining.measurements ? " pressed" : ""),
523
+ onClick: function onClick() {
524
+ return _this.props.changeRedliningState({
525
+ measurements: !_this.props.redlining.measurements,
526
+ style: _objectSpread(_objectSpread({}, _this.props.redlining.style), {}, {
527
+ text: ''
528
+ })
529
+ });
530
+ },
531
+ title: LocaleUtils.tr("redlining.measurements")
532
+ }, /*#__PURE__*/React.createElement(Icon, {
533
+ icon: "measure"
534
+ })) : null, (_this.props.redlining.geomType === 'Text' || _this.props.allowGeometryLabels) && !_this.props.redlining.measurements ? /*#__PURE__*/React.createElement("input", {
535
+ className: "controlgroup-fillitem",
536
+ onChange: function onChange(ev) {
537
+ return _this.updateRedliningStyle({
538
+ text: ev.target.value
539
+ });
540
+ },
541
+ placeholder: labelPlaceholder,
542
+ readOnly: _this.props.redlining.measurements,
543
+ ref: function ref(el) {
544
+ return _this.setLabelRef(el);
545
+ },
546
+ type: "text",
547
+ value: _this.props.redlining.style.text
548
+ }) : null, _this.props.redlining.measurements && ['LineString', 'Circle'].includes(_this.props.redlining.geomType) ? /*#__PURE__*/React.createElement("select", {
549
+ className: "controlgroup-fillitem",
550
+ onChange: function onChange(ev) {
551
+ return _this.props.changeRedliningState({
552
+ lenUnit: ev.target.value
553
+ });
554
+ },
555
+ value: _this.props.redlining.lenUnit
556
+ }, /*#__PURE__*/React.createElement("option", {
557
+ value: "metric"
558
+ }, LocaleUtils.tr("measureComponent.metric")), /*#__PURE__*/React.createElement("option", {
559
+ value: "imperial"
560
+ }, LocaleUtils.tr("measureComponent.imperial")), /*#__PURE__*/React.createElement("option", {
561
+ value: "m"
562
+ }, "m"), /*#__PURE__*/React.createElement("option", {
563
+ value: "km"
564
+ }, "km"), /*#__PURE__*/React.createElement("option", {
565
+ value: "ft"
566
+ }, "ft"), /*#__PURE__*/React.createElement("option", {
567
+ value: "mi"
568
+ }, "mi")) : null, _this.props.redlining.measurements && ['Polygon', 'Ellipse', 'Square', 'Box'].includes(_this.props.redlining.geomType) ? /*#__PURE__*/React.createElement("select", {
569
+ className: "controlgroup-fillitem",
570
+ onChange: function onChange(ev) {
571
+ return _this.props.changeRedliningState({
572
+ areaUnit: ev.target.value
573
+ });
574
+ },
575
+ value: _this.props.redlining.areaUnit
576
+ }, /*#__PURE__*/React.createElement("option", {
577
+ value: "metric"
578
+ }, LocaleUtils.tr("measureComponent.metric")), /*#__PURE__*/React.createElement("option", {
579
+ value: "imperial"
580
+ }, LocaleUtils.tr("measureComponent.imperial")), /*#__PURE__*/React.createElement("option", {
581
+ value: "sqm"
582
+ }, "m\xB2"), /*#__PURE__*/React.createElement("option", {
583
+ value: "ha"
584
+ }, "ha"), /*#__PURE__*/React.createElement("option", {
585
+ value: "sqkm"
586
+ }, "km\xB2"), /*#__PURE__*/React.createElement("option", {
587
+ value: "sqft"
588
+ }, "ft\xB2"), /*#__PURE__*/React.createElement("option", {
589
+ value: "acre"
590
+ }, "acre"), /*#__PURE__*/React.createElement("option", {
591
+ value: "sqmi"
592
+ }, "mi\xB2")) : null)));
593
+ });
594
+ _defineProperty(_this, "setLabelRef", function (el) {
595
+ _this.labelInput = el;
596
+ if (el && _this.state.selectText) {
597
+ el.focus();
598
+ el.select();
599
+ _this.setState({
600
+ selectText: false
601
+ });
602
+ }
603
+ });
604
+ _defineProperty(_this, "actionChanged", function (data) {
605
+ if (data.action === "Draw" && data.geomType === "Text") {
606
+ data = _objectSpread(_objectSpread({}, data), {}, {
607
+ style: {
608
+ text: LocaleUtils.tr("redlining.text")
609
+ }
610
+ });
611
+ } else if (!_this.props.allowGeometryLabels) {
612
+ data = _objectSpread(_objectSpread({}, data), {}, {
613
+ style: {
614
+ text: ''
615
+ }
616
+ });
617
+ }
618
+ _this.props.changeRedliningState(data);
619
+ });
620
+ _defineProperty(_this, "changeRedliningLayer", function (layer) {
621
+ var action = ["Draw", "Pick", "Transform"].includes(_this.props.redlining.action) ? _this.props.redlining.action : "Pick";
622
+ _this.props.changeRedliningState({
623
+ layer: layer.id,
624
+ layerTitle: layer.title,
625
+ action: action
626
+ });
627
+ });
628
+ _this.labelInput = null;
629
+ _this.dashIcons = {};
630
+ return _this;
631
+ }
632
+ _inherits(Redlining, _React$Component);
633
+ return _createClass(Redlining, [{
634
+ key: "componentDidMount",
635
+ value: function componentDidMount() {
636
+ this.componentDidUpdate({
637
+ redlining: {}
638
+ });
639
+ }
640
+ }, {
641
+ key: "componentDidUpdate",
642
+ value: function componentDidUpdate(prevProps) {
643
+ var _this2 = this;
644
+ if (this.props.defaultBorderColor !== prevProps.defaultBorderColor || this.props.defaultFillColor !== prevProps.defaultFillColor || this.props.defaultLengthUnit !== prevProps.defaultLengthUnit || this.props.defaultAreaUnit !== prevProps.defaultAreaUnit || this.props.defaultTextFillColor !== prevProps.defaultTextFillColor || this.props.defaultTextOutlineColor !== prevProps.defaultTextOutlineColor) {
645
+ this.props.changeRedliningState(this.redliningStateDefaults());
646
+ }
647
+ if (prevProps.redlining.geomType !== this.props.redlining.geomType && this.props.redlining.geomType === 'Text' && !this.state.selectText) {
648
+ this.setState({
649
+ selectText: true
650
+ });
651
+ }
652
+ if (!this.props.layers.find(function (layer) {
653
+ return layer.id === _this2.props.redlining.layer;
654
+ })) {
655
+ var vectorLayers = this.props.layers.filter(function (layer) {
656
+ return layer.type === "vector" && layer.role === LayerRole.USERLAYER && !layer.readonly;
657
+ });
658
+ if (vectorLayers.length >= 1) {
659
+ this.props.changeRedliningState({
660
+ layer: vectorLayers[0].id,
661
+ layerTitle: vectorLayers[0].title
662
+ });
663
+ } else if (this.props.redlining.layer !== 'redlining') {
664
+ this.props.changeRedliningState({
665
+ layer: 'redlining',
666
+ layerTitle: LocaleUtils.tr('redlining.layertitle')
667
+ });
668
+ }
669
+ }
670
+ if (this.props.predefinedDashPatterns !== prevProps.predefinedDashPatterns) {
671
+ this.generateDashIcons();
672
+ }
673
+ }
674
+ }, {
675
+ key: "render",
676
+ value: function render() {
677
+ var _this3 = this;
678
+ return /*#__PURE__*/React.createElement(TaskBar, {
679
+ onHide: this.onHide,
680
+ onShow: this.onShow,
681
+ task: "Redlining"
682
+ }, function () {
683
+ return {
684
+ body: _this3.renderBody()
685
+ };
686
+ });
687
+ }
688
+ }]);
689
+ }(React.Component);
690
+ _defineProperty(Redlining, "propTypes", {
691
+ addLayer: PropTypes.func,
692
+ /** Whether to allow labeling geometric figures. */
693
+ allowGeometryLabels: PropTypes.bool,
694
+ changeRedliningState: PropTypes.func,
695
+ /** Default area unit. Options: `metric`, `imperial`, `sqm`, `ha`, `sqkm`, `sqft`, `acre`, `sqmi` */
696
+ defaultAreaUnit: PropTypes.string,
697
+ /** Default border color. In format `[r, g, b, a]`. */
698
+ defaultBorderColor: PropTypes.array,
699
+ /** Default fill color. In format `[r, g, b, a]`. */
700
+ defaultFillColor: PropTypes.array,
701
+ /** Default length unit. Options: `metric`, `imperial`, `m`, `km`, `ft`, `mi` */
702
+ defaultLengthUnit: PropTypes.string,
703
+ /** Default text fill color. In format `[r, g, b, a]`. */
704
+ defaultTextFillColor: PropTypes.array,
705
+ /** Default text outline color. In format `[r, g, b, a]`. */
706
+ defaultTextOutlineColor: PropTypes.array,
707
+ /** Tools to hide. Available tools: `Circle`, `Ellipse`, `Square`, `Box`, `HandDrawing`, `Transform`, `NumericInput`, `Buffer`, `Export`. */
708
+ hiddenTools: PropTypes.array,
709
+ layers: PropTypes.array,
710
+ mapCrs: PropTypes.string,
711
+ plugins: PropTypes.object,
712
+ /** Predefined border colors. In format `[[r, g, b, a], ...]`. */
713
+ predefinedBorderColors: PropTypes.arrayOf(PropTypes.array),
714
+ /** Predefined dash patterns. In format `[<dash-array>, ...]`, where a dash-array is list of alternating dash and gap widths, i.e. `[8 4]` for long dashes followed by shorter gaps. */
715
+ predefinedDashPatterns: PropTypes.arrayOf(PropTypes.array),
716
+ /** Predefined fill colors. In format `[[r, g, b, a], ...]`. */
717
+ predefinedFillColors: PropTypes.arrayOf(PropTypes.array),
718
+ redlining: PropTypes.object,
719
+ resetRedliningState: PropTypes.func,
720
+ setCurrentTask: PropTypes.func,
721
+ setSnappingConfig: PropTypes.func,
722
+ /** Whether snapping is available when editing. */
723
+ snapping: PropTypes.bool,
724
+ /** Whether snapping is enabled by default when editing.
725
+ * Either `false`, `edge`, `vertex` or `true` (i.e. both vertex and edge). */
726
+ snappingActive: PropTypes.oneOfType([PropTypes.bool, PropTypes.string])
727
+ });
728
+ _defineProperty(Redlining, "defaultProps", {
729
+ allowGeometryLabels: true,
730
+ hiddenTools: [],
731
+ snapping: true,
732
+ snappingActive: true,
733
+ plugins: [],
734
+ defaultBorderColor: [255, 0, 0, 1],
735
+ defaultFillColor: [255, 255, 255, 1],
736
+ defaultTextFillColor: [0, 0, 0, 1],
737
+ defaultTextOutlineColor: [255, 255, 255, 1],
738
+ defaultAreaUnit: 'metric',
739
+ defaultLengthUnit: 'metric',
740
+ predefinedDashPatterns: [[], [8, 8], [1, 8], [8, 8, 1, 8]]
741
+ });
742
+ export default (function (plugins) {
743
+ return connect(function (state) {
744
+ return {
745
+ layers: state.layers.flat,
746
+ redlining: state.redlining,
747
+ mapCrs: state.map.projection,
748
+ plugins: plugins
749
+ };
750
+ }, {
751
+ changeRedliningState: changeRedliningState,
752
+ addLayer: addLayer,
753
+ resetRedliningState: resetRedliningState,
754
+ setSnappingConfig: setSnappingConfig
755
+ })(Redlining);
756
+ });