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,54 +1,625 @@
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 _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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
13
+ 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); } }
14
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
15
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
16
+ 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); }
17
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
18
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
19
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
20
+ 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); }
21
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
22
+ 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; }
23
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
24
+ 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); }
25
+ /**
2
26
  * Copyright 2024 Stadtwerke München GmbH
3
27
  * All rights reserved.
4
28
  *
5
29
  * This source code is licensed under the BSD-style license found in the
6
30
  * LICENSE file in the root directory of this source tree.
7
- */import React from"react";import isEqual from"lodash.isequal";import ol from"openlayers";import PropTypes from"prop-types";import rotateCursor from"../resources/rotate.svg";import FeatureStyles from"../utils/FeatureStyles";import MapUtils from"../utils/MapUtils";var PrintSelection=/*#__PURE__*/function(_React$Component){function PrintSelection(props){var _this$map$getView$get;var _this;_classCallCheck(this,PrintSelection);_this=_callSuper(this,PrintSelection,[props]);_defineProperty(_this,"setViewportCursor",function(ev){if(_this.isInteracting){return}var overFeature=_this.map.getFeaturesAtPixel(ev.pixel,{hitTolerance:20,layerFilter:function layerFilter(layer){return layer===_this.selectionLayer}}).includes(_this.feature);if(!overFeature){_this.map.getViewport().style.cursor="";return}var sqdist=function sqdist(p,q){return(p[0]-q[0])*(p[0]-q[0])+(p[1]-q[1])*(p[1]-q[1])};var getPixelFromCoordinate=MapUtils.getHook(MapUtils.GET_PIXEL_FROM_COORDINATES_HOOK);var topright=getPixelFromCoordinate(_this.feature.getGeometry().getCoordinates()[0][0],false);var bottomright=getPixelFromCoordinate(_this.feature.getGeometry().getCoordinates()[0][1],false);var bottomleft=getPixelFromCoordinate(_this.feature.getGeometry().getCoordinates()[0][2],false);var topleft=getPixelFromCoordinate(_this.feature.getGeometry().getCoordinates()[0][3],false);if(sqdist(ev.pixel,topright)<400){_this.map.getViewport().style.cursor="nesw-resize"}else if(sqdist(ev.pixel,bottomright)<400){_this.map.getViewport().style.cursor="url(".concat(rotateCursor,") 12 12, auto")}else if(sqdist(ev.pixel,bottomleft)<400){_this.map.getViewport().style.cursor="nesw-resize"}else if(sqdist(ev.pixel,topleft)<400){_this.map.getViewport().style.cursor="nwse-resize"}else{_this.map.getViewport().style.cursor=""}});_defineProperty(_this,"getGeometry",function(){var modifyGeometry=_this.feature.get("modifyGeometry");return modifyGeometry?modifyGeometry.geometry:_this.feature.getGeometry()});_defineProperty(_this,"getBackgroundGeometry",function(feature){var background=feature.getGeometry().clone();if(_this.feature!==null){var geom=_this.getGeometry().clone();// ignore degenerate geometries
8
- if(geom.getArea()===0){return background}// make the current selection transparent
9
- background.appendLinearRing(geom.getLinearRing(0));// add the origin to the selected tiles
10
- var selected=["0,0"].concat(_toConsumableArray(_this.props.printSeriesSelected));// make the selected series transparent
11
- _this.seriesGeometries.filter(_this.isPrintSeriesSelected).forEach(function(entry){// add the inner part of the tile
12
- var clonedGeom=entry.geometry.clone();clonedGeom.scale(1-2*_this.props.printSeriesOverlap);background.appendLinearRing(clonedGeom.getLinearRing(0));// clone the original geometry and rotate it
13
- var clonedGeomBase=entry.geometry.clone();var center=ol.extent.getCenter(clonedGeomBase.getExtent());clonedGeomBase.rotate(entry.rotation,center);var extent=clonedGeomBase.getExtent();// create the geometries for the overlapping borders
14
- var clonedGeomLeft=clonedGeomBase.clone();var centerLeft=[extent[0],0.5*(extent[1]+extent[3])];clonedGeomLeft.scale(_this.props.printSeriesOverlap,1-2*_this.props.printSeriesOverlap,centerLeft);clonedGeomLeft.rotate(-entry.rotation,center);var clonedGeomRight=clonedGeomBase.clone();var centerRight=[extent[2],0.5*(extent[1]+extent[3])];clonedGeomRight.scale(_this.props.printSeriesOverlap,1-2*_this.props.printSeriesOverlap,centerRight);clonedGeomRight.rotate(-entry.rotation,center);var clonedGeomBottom=clonedGeomBase.clone();var centerBottom=[0.5*(extent[0]+extent[2]),extent[1]];clonedGeomBottom.scale(1-2*_this.props.printSeriesOverlap,_this.props.printSeriesOverlap,centerBottom);clonedGeomBottom.rotate(-entry.rotation,center);var clonedGeomTop=clonedGeomBase.clone();var centerTop=[0.5*(extent[0]+extent[2]),extent[3]];clonedGeomTop.scale(1-2*_this.props.printSeriesOverlap,_this.props.printSeriesOverlap,centerTop);clonedGeomTop.rotate(-entry.rotation,center);// create the geometries for the overlapping corners
15
- var clonedGeomBottomLeft=clonedGeomBase.clone();var bottomLeft=[extent[0],extent[1]];clonedGeomBottomLeft.scale(_this.props.printSeriesOverlap,_this.props.printSeriesOverlap,bottomLeft);clonedGeomBottomLeft.rotate(-entry.rotation,center);var clonedGeomBottomRight=clonedGeomBase.clone();var bottomRight=[extent[2],extent[1]];clonedGeomBottomRight.scale(_this.props.printSeriesOverlap,_this.props.printSeriesOverlap,bottomRight);clonedGeomBottomRight.rotate(-entry.rotation,center);var clonedGeomTopLeft=clonedGeomBase.clone();var topLeft=[extent[0],extent[3]];clonedGeomTopLeft.scale(_this.props.printSeriesOverlap,_this.props.printSeriesOverlap,topLeft);clonedGeomTopLeft.rotate(-entry.rotation,center);var clonedGeomTopRight=clonedGeomBase.clone();var topRight=[extent[2],extent[3]];clonedGeomTopRight.scale(_this.props.printSeriesOverlap,_this.props.printSeriesOverlap,topRight);clonedGeomTopRight.rotate(-entry.rotation,center);// calculate the neighbours of the current tile
16
- var topNeighbour=[entry.index[0]-1,entry.index[1]].join(",");var bottomNeighbour=[entry.index[0]+1,entry.index[1]].join(",");var leftNeighbour=[entry.index[0],entry.index[1]-1].join(",");var rightNeighbour=[entry.index[0],entry.index[1]+1].join(",");var topLeftNeighbour=[entry.index[0]-1,entry.index[1]-1].join(",");var topRightNeighbour=[entry.index[0]-1,entry.index[1]+1].join(",");var bottomLeftNeighbour=[entry.index[0]+1,entry.index[1]-1].join(",");var bottomRightNeighbour=[entry.index[0]+1,entry.index[1]+1].join(",");// Each tile is responsible to draw its border facing away from the origin.
17
- // left border
18
- if(!selected.includes(leftNeighbour)||entry.index[1]<=0){background.appendLinearRing(clonedGeomLeft.getLinearRing(0))}// right border
19
- if(!selected.includes(rightNeighbour)||entry.index[1]>=0){background.appendLinearRing(clonedGeomRight.getLinearRing(0))}// top border
20
- if(!selected.includes(topNeighbour)||entry.index[0]<=0){background.appendLinearRing(clonedGeomTop.getLinearRing(0))}// bottom border
21
- if(!selected.includes(bottomNeighbour)||entry.index[0]>=0){background.appendLinearRing(clonedGeomBottom.getLinearRing(0))}// The corners are drawn by the tile facing away from the origin, and in counter-clockwise order.
22
- // top-left corner
23
- if(entry.index[0]<=0&&entry.index[1]<=0||entry.index[0]<=0&&!selected.includes(leftNeighbour)||entry.index[1]<=0&&!selected.includes(topNeighbour)&&!selected.includes(topLeftNeighbour)||!selected.includes(leftNeighbour)&&!selected.includes(topNeighbour)&&!selected.includes(topLeftNeighbour)){background.appendLinearRing(clonedGeomTopLeft.getLinearRing(0))}// top-right corner
24
- if(entry.index[0]<=0&&entry.index[1]>=0||entry.index[0]<=0&&!selected.includes(rightNeighbour)||entry.index[1]>=0&&!selected.includes(topNeighbour)&&!selected.includes(topRightNeighbour)||!selected.includes(rightNeighbour)&&!selected.includes(topNeighbour)&&!selected.includes(topRightNeighbour)){background.appendLinearRing(clonedGeomTopRight.getLinearRing(0))}// bottom-left corner
25
- if(entry.index[0]>=0&&entry.index[1]<=0||entry.index[0]>=0&&!selected.includes(leftNeighbour)||entry.index[1]<=0&&!selected.includes(bottomNeighbour)&&!selected.includes(bottomLeftNeighbour)||!selected.includes(leftNeighbour)&&!selected.includes(bottomNeighbour)&&!selected.includes(bottomLeftNeighbour)){background.appendLinearRing(clonedGeomBottomLeft.getLinearRing(0))}// bottom-right corner
26
- if(entry.index[0]>=0&&entry.index[1]>=0||entry.index[0]>=0&&!selected.includes(rightNeighbour)||entry.index[1]>=0&&!selected.includes(bottomNeighbour)&&!selected.includes(bottomRightNeighbour)||!selected.includes(rightNeighbour)&&!selected.includes(bottomNeighbour)&&!selected.includes(bottomRightNeighbour)){background.appendLinearRing(clonedGeomBottomRight.getLinearRing(0))}})}return background});_defineProperty(_this,"calculateSeriesGeometries",function(){var featureGeometry=_this.getGeometry();var coordinates=featureGeometry.getCoordinates()[0];var dx1=coordinates[1][0]-coordinates[2][0];var dy1=coordinates[1][1]-coordinates[2][1];var dx2=coordinates[2][0]-coordinates[3][0];var dy2=coordinates[2][1]-coordinates[3][1];var rotation=-Math.atan2(dy1,dx1);var gridSize=_this.props.printSeriesEnabled?_this.props.printSeriesGridSize:0;var geometries=[];for(var i=-gridSize;i<=gridSize;i++){for(var j=-gridSize;j<=gridSize;j++){var index=[i,j];var geometry=featureGeometry.clone();geometry.translate((1-_this.props.printSeriesOverlap)*(j*dx1+i*dx2),(1-_this.props.printSeriesOverlap)*(j*dy1+i*dy2));geometries.push({index:index,geometry:geometry,rotation:rotation})}}return geometries});_defineProperty(_this,"layerStyle",function(feature){// background geometry with own styling
27
- if(feature===_this.backgroundFeature){return FeatureStyles.printInteractionBackground({geometryFunction:_this.getBackgroundGeometry})}// draw series geometries with own styling
28
- if(feature===_this.printSeriesFeature&&_this.props.printSeriesEnabled){var styles=[];var size=Math.min(_this.props.fixedFrame.width,_this.props.fixedFrame.height);var radius=Math.min(_this.props.scale*size/_this.map.getView().getResolution()/100000,2);_this.seriesGeometries.forEach(function(entry){// ignore the center geometry
29
- if(!isEqual(entry.index,[0,0])){styles.push(FeatureStyles.printInteractionSeries({geometryFunction:entry.geometry}));styles.push.apply(styles,_toConsumableArray(FeatureStyles.printInteractionSeriesIcon({geometryFunction:new ol.geom.Point(ol.extent.getCenter(entry.geometry.getExtent())),rotation:entry.rotation,radius:radius,img:_this.isPrintSeriesSelected(entry)?"minus":"plus"})))}});return styles}// main feature
30
- if(feature===_this.feature){var _styles=[FeatureStyles.printInteraction({geometryFunction:_this.getGeometry})];var coordinates=_this.getGeometry().getCoordinates()[0];if(coordinates&&_this.props.fixedFrame){if(_this.props.allowScaling){// vertices to scale the selection
31
- _styles.push(FeatureStyles.printInteractionVertex({geometryFunction:new ol.geom.MultiPoint(coordinates.slice(2))}))}if(_this.props.allowScaling||_this.props.allowRotation){// vertices to scale or rotate the selection
32
- _styles.push(FeatureStyles.printInteractionVertex({geometryFunction:new ol.geom.MultiPoint(coordinates.slice(1,2)),fill:_this.props.allowRotation}))}}return _styles}return null});_defineProperty(_this,"scaleRotateStyle",function(feature){feature.get("features").forEach(function(modifyFeature){var modifyGeometry=modifyFeature.get("modifyGeometry");if(modifyGeometry){var point=feature.getGeometry().getCoordinates();// rotate only with vertex on bottom-right
33
- var isRotationVertex=isEqual(point,modifyFeature.getGeometry().getCoordinates()[0][1]);if(!modifyGeometry.point){// save the initial geometry and vertex position
34
- modifyGeometry.point=point;modifyGeometry.initialGeometry=modifyGeometry.geometry}var center=ol.extent.getCenter(modifyGeometry.initialGeometry.getExtent());var _this$calculateRotati=_this.calculateRotationScale(modifyGeometry.point,point,center),_this$calculateRotati2=_slicedToArray(_this$calculateRotati,2),rotation=_this$calculateRotati2[0],scale=_this$calculateRotati2[1];var geometry=modifyGeometry.initialGeometry.clone();if(_this.props.allowRotation&&isRotationVertex){geometry.rotate(rotation,center)}else if(_this.props.allowScaling){geometry.scale(scale,undefined,center)}modifyGeometry.geometry=geometry}});return null});_defineProperty(_this,"isPrintSeriesSelected",function(entry){return _this.props.printSeriesSelected.includes(entry.index.join(","))});_defineProperty(_this,"calculateExtents",function(){_this.seriesGeometries=_this.calculateSeriesGeometries();_this.selectionLayer.changed();return _this.seriesGeometries.filter(function(entry){return isEqual(entry.index,[0,0])||_this.isPrintSeriesSelected(entry)}).map(function(entry){var clonedGeom=entry.geometry.clone();var center=ol.extent.getCenter(clonedGeom.getExtent());clonedGeom.rotate(-_this.props.rotation*Math.PI/180,center);return clonedGeom.getExtent()})});_defineProperty(_this,"geometryChanged",function(){var geometry=_this.getGeometry();var extent=geometry.getExtent();var point=geometry.getCoordinates()[0][0];var center=ol.extent.getCenter(extent);// Update series geometries and obtain extents
35
- var extents=_this.calculateExtents();var rotation=0;var scale=null;if(_this.initialWidth!==null&&_this.initialHeight!==null){var initialPoint=[center[0]+0.5*_this.initialWidth,center[1]+0.5*_this.initialHeight];var _this$calculateRotati3=_this.calculateRotationScale(initialPoint,point,center),_this$calculateRotati4=_slicedToArray(_this$calculateRotati3,2),calcRotation=_this$calculateRotati4[0],calcScale=_this$calculateRotati4[1];var degree=(360+calcRotation*180/Math.PI)%360;rotation=Math.round(degree*10)/10%360;scale=Math.round(1000*calcScale)}_this.props.geometryChanged(center,extents,rotation,scale)});_defineProperty(_this,"calculateRotationScale",function(p1,p2,center){var dx=p1[0]-center[0];var dy=p1[1]-center[1];var initialAngle=Math.atan2(dy,dx);var initialRadius=Math.sqrt(dx*dx+dy*dy);dx=p2[0]-center[0];dy=p2[1]-center[1];var currentAngle=Math.atan2(dy,dx);var currentRadius=Math.sqrt(dx*dx+dy*dy);return[currentAngle-initialAngle,currentRadius/initialRadius]});_this.map=MapUtils.getHook(MapUtils.GET_MAP);// create a layer to draw on
36
- _this.source=new ol.source.Vector;_this.selectionLayer=new ol.layer.Vector({source:_this.source,zIndex:1000000,style:_this.layerStyle});// create a geometry for the background feature
37
- var _extent=(_this$map$getView$get=_this.map.getView().getProjection().getExtent())!==null&&_this$map$getView$get!==void 0?_this$map$getView$get:[Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER];var _geometry=ol.geom.polygonFromExtent(_extent);_this.backgroundFeature=new ol.Feature(_geometry);_this.source.addFeature(_this.backgroundFeature);_this.printSeriesFeature=new ol.Feature(_geometry);_this.source.addFeature(_this.printSeriesFeature);_this.feature=null;_this.initialWidth=null;_this.initialHeight=null;_this.seriesGeometries=[];_this.translateInteraction=null;_this.scaleRotateInteraction=null;_this.selectPrintSeriesInteraction=null;_this.drawInteraction=null;_this.isInteracting=false;return _this}_inherits(PrintSelection,_React$Component);return _createClass(PrintSelection,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(!isEqual(prevProps.fixedFrame,this.props.fixedFrame)||!isEqual(prevProps.center,this.props.center)||prevProps.rotation!==this.props.rotation||prevProps.scale!==this.props.scale){if(!this.isInteracting){this.recomputeFeature()}}if(prevProps.printSeriesEnabled!==this.props.printSeriesEnabled||prevProps.printSeriesOverlap!==this.props.printSeriesOverlap||prevProps.printSeriesSelected!==this.props.printSeriesSelected){this.geometryChanged()}}},{key:"recomputeFeature",value:function recomputeFeature(){// delete the old feature
38
- if(this.feature!==null){// remove old feature
39
- this.source.removeFeature(this.feature);this.feature=null;this.initialWidth=null;this.initialHeight=null;this.seriesGeometries=[]}// render the current feature if given a fixed frame
40
- if(this.props.fixedFrame!==null){// calculate actual width and height
41
- var _MapUtils$transformEx=MapUtils.transformExtent(this.map.getView().getProjection(),this.props.center,this.props.fixedFrame.width,this.props.fixedFrame.height),width=_MapUtils$transformEx.width,height=_MapUtils$transformEx.height;// add rectangle
42
- var x1=this.props.center[0]+0.5*width;var x2=this.props.center[0]-0.5*width;var y1=this.props.center[1]+0.5*height;var y2=this.props.center[1]-0.5*height;var geometry=new ol.geom.Polygon([[[x1,y1],[x1,y2],[x2,y2],[x2,y1],[x1,y1]]]);// rotate and scale rectangle
43
- if(this.props.rotation){geometry.rotate(this.props.rotation*Math.PI/180,this.props.center)}if(this.props.scale){geometry.scale(this.props.scale/1000,undefined,this.props.center)}// add feature to layer
44
- this.feature=new ol.Feature(geometry);this.feature.on("change",this.geometryChanged);this.source.addFeature(this.feature);// store initial width and height for future updates
45
- this.initialWidth=width;this.initialHeight=height;// update geometry to new extent
46
- this.geometryChanged()}}},{key:"componentDidMount",value:function componentDidMount(){this.map.on("pointermove",this.setViewportCursor);this.map.addLayer(this.selectionLayer);this.addInteractions();this.recomputeFeature()}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.map.un("pointermove",this.setViewportCursor);this.map.removeLayer(this.selectionLayer);this.removeInteractions()}},{key:"addInteractions",value:function addInteractions(){var _this2=this;// move the selection
47
- var translateCondition=function translateCondition(ev){return ol.events.condition.primaryAction(ev)&&_this2.props.fixedFrame&&_this2.props.allowTranslation};this.translateInteraction=new ol.interaction.Translate({condition:translateCondition,// add condition to filter for correct cursor selection
48
- filter:function filter(feature){return _this2.props.fixedFrame&&_this2.props.allowTranslation&&feature===_this2.feature},layers:[this.selectionLayer]});this.translateInteraction.on("translatestart",function(){_this2.isInteracting=true});this.translateInteraction.on("translateend",function(){_this2.isInteracting=false});// scale and rotate the selection
49
- var modifyCondition=function modifyCondition(ev){return ol.events.condition.primaryAction(ev)&&_this2.props.fixedFrame&&(_this2.props.allowScaling||_this2.props.allowRotation)};this.scaleRotateInteraction=new ol.interaction.Modify({source:this.source,condition:modifyCondition,deleteCondition:ol.events.condition.never,insertVertexCondition:ol.events.condition.never,pixelTolerance:20,style:this.scaleRotateStyle});this.scaleRotateInteraction.on("modifystart",function(ev){_this2.isInteracting=true;ev.features.forEach(function(feature){feature.set("modifyGeometry",{geometry:feature.getGeometry().clone()},true)})});this.scaleRotateInteraction.on("modifyend",function(ev){_this2.isInteracting=false;ev.features.forEach(function(feature){var modifyGeometry=feature.get("modifyGeometry");if(modifyGeometry){feature.setGeometry(modifyGeometry.geometry);feature.unset("modifyGeometry",true)}});_this2.recomputeFeature()});// select frames for printing a series
50
- this.selectPrintSeriesInteraction=new ol.interaction.Select({filter:function filter(feature){return feature===_this2.printSeriesFeature},layers:[this.selectionLayer],condition:ol.events.condition.click,addCondition:ol.events.condition.always,removeCondition:ol.events.condition.always,style:null});this.selectPrintSeriesInteraction.on("select",function(ev){var coordinate=ev.mapBrowserEvent.coordinate;var intersecting=_this2.seriesGeometries.find(function(entry){return!isEqual(entry.index,[0,0])&&entry.geometry.intersectsCoordinate(coordinate)});if(intersecting){var selected=_this2.props.printSeriesSelected;if(selected.includes(intersecting.index.join(","))){selected=selected.filter(function(index){return index!==intersecting.index.join(",")})}else{selected=[].concat(_toConsumableArray(selected),[intersecting.index.join(",")])}_this2.props.printSeriesChanged(selected)}});// select a new area when no frame is given (only added when no fixed frame is given)
51
- var drawCondition=function drawCondition(ev){return ol.events.condition.primaryAction(ev)&&!_this2.props.fixedFrame};this.drawInteraction=new ol.interaction.Draw({source:this.source,type:"Circle",style:FeatureStyles.printInteraction(),geometryFunction:ol.interaction.createBox(),condition:ol.events.condition.never,freehandCondition:drawCondition});this.drawInteraction.on("drawstart",function(ev){_this2.isInteracting=true;_this2.feature=ev.feature;_this2.feature.on("change",_this2.geometryChanged)});this.drawInteraction.on("drawend",function(){_this2.isInteracting=false;_this2.geometryChanged()});// register interactions
52
- this.map.addInteraction(this.translateInteraction);this.map.addInteraction(this.scaleRotateInteraction);this.map.addInteraction(this.selectPrintSeriesInteraction);this.map.addInteraction(this.drawInteraction)}},{key:"removeInteractions",value:function removeInteractions(){if(this.translateInteraction!==null){this.map.removeInteraction(this.translateInteraction);this.translateInteraction=null}if(this.scaleRotateInteraction!==null){this.map.removeInteraction(this.scaleRotateInteraction);this.scaleRotateInteraction=null}if(this.selectPrintSeriesInteraction!==null){this.map.removeInteraction(this.selectPrintSeriesInteraction);this.selectPrintSeriesInteraction=null}if(this.drawInteraction!==null){this.map.removeInteraction(this.drawInteraction);this.drawInteraction=null}}},{key:"render",value:function render(){return null}}])}(React.Component);_defineProperty(PrintSelection,"propTypes",{allowRotation:PropTypes.bool,allowScaling:PropTypes.bool,allowTranslation:PropTypes.bool,center:PropTypes.arrayOf(PropTypes.number),fixedFrame:PropTypes.shape({width:PropTypes.number,// in meters
53
- height:PropTypes.number// in meters
54
- }),geometryChanged:PropTypes.func,printSeriesChanged:PropTypes.func,printSeriesEnabled:PropTypes.bool,printSeriesGridSize:PropTypes.number,printSeriesOverlap:PropTypes.number,printSeriesSelected:PropTypes.arrayOf(PropTypes.string),rotation:PropTypes.number,scale:PropTypes.number});_defineProperty(PrintSelection,"defaultProps",{allowRotation:true,allowScaling:true,allowTranslation:true,fixedFrame:null,geometryChanged:function geometryChanged(){},printSeriesChanged:function printSeriesChanged(){},printSeriesEnabled:false,printSeriesGridSize:2,printSeriesOverlap:0,printSeriesSelected:[],rotation:0,scale:1000});export{PrintSelection as default};
31
+ */
32
+
33
+ import React from 'react';
34
+ import isEqual from 'lodash.isequal';
35
+ import ol from 'openlayers';
36
+ import PropTypes from 'prop-types';
37
+ import rotateCursor from '../resources/rotate.svg';
38
+ import FeatureStyles from '../utils/FeatureStyles';
39
+ import MapUtils from '../utils/MapUtils';
40
+ var PrintSelection = /*#__PURE__*/function (_React$Component) {
41
+ function PrintSelection(props) {
42
+ var _this$map$getView$get;
43
+ var _this;
44
+ _classCallCheck(this, PrintSelection);
45
+ _this = _callSuper(this, PrintSelection, [props]);
46
+ _defineProperty(_this, "setViewportCursor", function (ev) {
47
+ if (_this.isInteracting) {
48
+ return;
49
+ }
50
+ var overFeature = _this.map.getFeaturesAtPixel(ev.pixel, {
51
+ hitTolerance: 20,
52
+ layerFilter: function layerFilter(layer) {
53
+ return layer === _this.selectionLayer;
54
+ }
55
+ }).includes(_this.feature);
56
+ if (!overFeature) {
57
+ _this.map.getViewport().style.cursor = '';
58
+ return;
59
+ }
60
+ var sqdist = function sqdist(p, q) {
61
+ return (p[0] - q[0]) * (p[0] - q[0]) + (p[1] - q[1]) * (p[1] - q[1]);
62
+ };
63
+ var getPixelFromCoordinate = MapUtils.getHook(MapUtils.GET_PIXEL_FROM_COORDINATES_HOOK);
64
+ var topright = getPixelFromCoordinate(_this.feature.getGeometry().getCoordinates()[0][0], false);
65
+ var bottomright = getPixelFromCoordinate(_this.feature.getGeometry().getCoordinates()[0][1], false);
66
+ var bottomleft = getPixelFromCoordinate(_this.feature.getGeometry().getCoordinates()[0][2], false);
67
+ var topleft = getPixelFromCoordinate(_this.feature.getGeometry().getCoordinates()[0][3], false);
68
+ if (sqdist(ev.pixel, topright) < 400) {
69
+ _this.map.getViewport().style.cursor = 'nesw-resize';
70
+ } else if (sqdist(ev.pixel, bottomright) < 400) {
71
+ _this.map.getViewport().style.cursor = "url(".concat(rotateCursor, ") 12 12, auto");
72
+ } else if (sqdist(ev.pixel, bottomleft) < 400) {
73
+ _this.map.getViewport().style.cursor = 'nesw-resize';
74
+ } else if (sqdist(ev.pixel, topleft) < 400) {
75
+ _this.map.getViewport().style.cursor = 'nwse-resize';
76
+ } else {
77
+ _this.map.getViewport().style.cursor = '';
78
+ }
79
+ });
80
+ _defineProperty(_this, "getGeometry", function () {
81
+ var modifyGeometry = _this.feature.get('modifyGeometry');
82
+ return modifyGeometry ? modifyGeometry.geometry : _this.feature.getGeometry();
83
+ });
84
+ _defineProperty(_this, "getBackgroundGeometry", function (feature) {
85
+ var background = feature.getGeometry().clone();
86
+ if (_this.feature !== null) {
87
+ var geom = _this.getGeometry().clone();
88
+
89
+ // ignore degenerate geometries
90
+ if (geom.getArea() === 0) {
91
+ return background;
92
+ }
93
+
94
+ // make the current selection transparent
95
+ background.appendLinearRing(geom.getLinearRing(0));
96
+
97
+ // add the origin to the selected tiles
98
+ var selected = ['0,0'].concat(_toConsumableArray(_this.props.printSeriesSelected));
99
+
100
+ // make the selected series transparent
101
+ _this.seriesGeometries.filter(_this.isPrintSeriesSelected).forEach(function (entry) {
102
+ // add the inner part of the tile
103
+ var clonedGeom = entry.geometry.clone();
104
+ clonedGeom.scale(1 - 2 * _this.props.printSeriesOverlap);
105
+ background.appendLinearRing(clonedGeom.getLinearRing(0));
106
+
107
+ // clone the original geometry and rotate it
108
+ var clonedGeomBase = entry.geometry.clone();
109
+ var center = ol.extent.getCenter(clonedGeomBase.getExtent());
110
+ clonedGeomBase.rotate(entry.rotation, center);
111
+ var extent = clonedGeomBase.getExtent();
112
+
113
+ // create the geometries for the overlapping borders
114
+ var clonedGeomLeft = clonedGeomBase.clone();
115
+ var centerLeft = [extent[0], 0.5 * (extent[1] + extent[3])];
116
+ clonedGeomLeft.scale(_this.props.printSeriesOverlap, 1 - 2 * _this.props.printSeriesOverlap, centerLeft);
117
+ clonedGeomLeft.rotate(-entry.rotation, center);
118
+ var clonedGeomRight = clonedGeomBase.clone();
119
+ var centerRight = [extent[2], 0.5 * (extent[1] + extent[3])];
120
+ clonedGeomRight.scale(_this.props.printSeriesOverlap, 1 - 2 * _this.props.printSeriesOverlap, centerRight);
121
+ clonedGeomRight.rotate(-entry.rotation, center);
122
+ var clonedGeomBottom = clonedGeomBase.clone();
123
+ var centerBottom = [0.5 * (extent[0] + extent[2]), extent[1]];
124
+ clonedGeomBottom.scale(1 - 2 * _this.props.printSeriesOverlap, _this.props.printSeriesOverlap, centerBottom);
125
+ clonedGeomBottom.rotate(-entry.rotation, center);
126
+ var clonedGeomTop = clonedGeomBase.clone();
127
+ var centerTop = [0.5 * (extent[0] + extent[2]), extent[3]];
128
+ clonedGeomTop.scale(1 - 2 * _this.props.printSeriesOverlap, _this.props.printSeriesOverlap, centerTop);
129
+ clonedGeomTop.rotate(-entry.rotation, center);
130
+
131
+ // create the geometries for the overlapping corners
132
+ var clonedGeomBottomLeft = clonedGeomBase.clone();
133
+ var bottomLeft = [extent[0], extent[1]];
134
+ clonedGeomBottomLeft.scale(_this.props.printSeriesOverlap, _this.props.printSeriesOverlap, bottomLeft);
135
+ clonedGeomBottomLeft.rotate(-entry.rotation, center);
136
+ var clonedGeomBottomRight = clonedGeomBase.clone();
137
+ var bottomRight = [extent[2], extent[1]];
138
+ clonedGeomBottomRight.scale(_this.props.printSeriesOverlap, _this.props.printSeriesOverlap, bottomRight);
139
+ clonedGeomBottomRight.rotate(-entry.rotation, center);
140
+ var clonedGeomTopLeft = clonedGeomBase.clone();
141
+ var topLeft = [extent[0], extent[3]];
142
+ clonedGeomTopLeft.scale(_this.props.printSeriesOverlap, _this.props.printSeriesOverlap, topLeft);
143
+ clonedGeomTopLeft.rotate(-entry.rotation, center);
144
+ var clonedGeomTopRight = clonedGeomBase.clone();
145
+ var topRight = [extent[2], extent[3]];
146
+ clonedGeomTopRight.scale(_this.props.printSeriesOverlap, _this.props.printSeriesOverlap, topRight);
147
+ clonedGeomTopRight.rotate(-entry.rotation, center);
148
+
149
+ // calculate the neighbours of the current tile
150
+ var topNeighbour = [entry.index[0] - 1, entry.index[1]].join(',');
151
+ var bottomNeighbour = [entry.index[0] + 1, entry.index[1]].join(',');
152
+ var leftNeighbour = [entry.index[0], entry.index[1] - 1].join(',');
153
+ var rightNeighbour = [entry.index[0], entry.index[1] + 1].join(',');
154
+ var topLeftNeighbour = [entry.index[0] - 1, entry.index[1] - 1].join(',');
155
+ var topRightNeighbour = [entry.index[0] - 1, entry.index[1] + 1].join(',');
156
+ var bottomLeftNeighbour = [entry.index[0] + 1, entry.index[1] - 1].join(',');
157
+ var bottomRightNeighbour = [entry.index[0] + 1, entry.index[1] + 1].join(',');
158
+
159
+ // Each tile is responsible to draw its border facing away from the origin.
160
+
161
+ // left border
162
+ if (!selected.includes(leftNeighbour) || entry.index[1] <= 0) {
163
+ background.appendLinearRing(clonedGeomLeft.getLinearRing(0));
164
+ }
165
+ // right border
166
+ if (!selected.includes(rightNeighbour) || entry.index[1] >= 0) {
167
+ background.appendLinearRing(clonedGeomRight.getLinearRing(0));
168
+ }
169
+ // top border
170
+ if (!selected.includes(topNeighbour) || entry.index[0] <= 0) {
171
+ background.appendLinearRing(clonedGeomTop.getLinearRing(0));
172
+ }
173
+ // bottom border
174
+ if (!selected.includes(bottomNeighbour) || entry.index[0] >= 0) {
175
+ background.appendLinearRing(clonedGeomBottom.getLinearRing(0));
176
+ }
177
+
178
+ // The corners are drawn by the tile facing away from the origin, and in counter-clockwise order.
179
+
180
+ // top-left corner
181
+ if (entry.index[0] <= 0 && entry.index[1] <= 0 || entry.index[0] <= 0 && !selected.includes(leftNeighbour) || entry.index[1] <= 0 && !selected.includes(topNeighbour) && !selected.includes(topLeftNeighbour) || !selected.includes(leftNeighbour) && !selected.includes(topNeighbour) && !selected.includes(topLeftNeighbour)) {
182
+ background.appendLinearRing(clonedGeomTopLeft.getLinearRing(0));
183
+ }
184
+ // top-right corner
185
+ if (entry.index[0] <= 0 && entry.index[1] >= 0 || entry.index[0] <= 0 && !selected.includes(rightNeighbour) || entry.index[1] >= 0 && !selected.includes(topNeighbour) && !selected.includes(topRightNeighbour) || !selected.includes(rightNeighbour) && !selected.includes(topNeighbour) && !selected.includes(topRightNeighbour)) {
186
+ background.appendLinearRing(clonedGeomTopRight.getLinearRing(0));
187
+ }
188
+ // bottom-left corner
189
+ if (entry.index[0] >= 0 && entry.index[1] <= 0 || entry.index[0] >= 0 && !selected.includes(leftNeighbour) || entry.index[1] <= 0 && !selected.includes(bottomNeighbour) && !selected.includes(bottomLeftNeighbour) || !selected.includes(leftNeighbour) && !selected.includes(bottomNeighbour) && !selected.includes(bottomLeftNeighbour)) {
190
+ background.appendLinearRing(clonedGeomBottomLeft.getLinearRing(0));
191
+ }
192
+ // bottom-right corner
193
+ if (entry.index[0] >= 0 && entry.index[1] >= 0 || entry.index[0] >= 0 && !selected.includes(rightNeighbour) || entry.index[1] >= 0 && !selected.includes(bottomNeighbour) && !selected.includes(bottomRightNeighbour) || !selected.includes(rightNeighbour) && !selected.includes(bottomNeighbour) && !selected.includes(bottomRightNeighbour)) {
194
+ background.appendLinearRing(clonedGeomBottomRight.getLinearRing(0));
195
+ }
196
+ });
197
+ }
198
+ return background;
199
+ });
200
+ _defineProperty(_this, "calculateSeriesGeometries", function () {
201
+ var featureGeometry = _this.getGeometry();
202
+ var coordinates = featureGeometry.getCoordinates()[0];
203
+ var dx1 = coordinates[1][0] - coordinates[2][0];
204
+ var dy1 = coordinates[1][1] - coordinates[2][1];
205
+ var dx2 = coordinates[2][0] - coordinates[3][0];
206
+ var dy2 = coordinates[2][1] - coordinates[3][1];
207
+ var rotation = -Math.atan2(dy1, dx1);
208
+ var gridSize = _this.props.printSeriesEnabled ? _this.props.printSeriesGridSize : 0;
209
+ var geometries = [];
210
+ for (var i = -gridSize; i <= gridSize; i++) {
211
+ for (var j = -gridSize; j <= gridSize; j++) {
212
+ var index = [i, j];
213
+ var geometry = featureGeometry.clone();
214
+ geometry.translate((1 - _this.props.printSeriesOverlap) * (j * dx1 + i * dx2), (1 - _this.props.printSeriesOverlap) * (j * dy1 + i * dy2));
215
+ geometries.push({
216
+ index: index,
217
+ geometry: geometry,
218
+ rotation: rotation
219
+ });
220
+ }
221
+ }
222
+ return geometries;
223
+ });
224
+ _defineProperty(_this, "layerStyle", function (feature) {
225
+ // background geometry with own styling
226
+ if (feature === _this.backgroundFeature) {
227
+ return FeatureStyles.printInteractionBackground({
228
+ geometryFunction: _this.getBackgroundGeometry
229
+ });
230
+ }
231
+
232
+ // draw series geometries with own styling
233
+ if (feature === _this.printSeriesFeature && _this.props.printSeriesEnabled) {
234
+ var styles = [];
235
+ var size = Math.min(_this.props.fixedFrame.width, _this.props.fixedFrame.height);
236
+ var radius = Math.min(_this.props.scale * size / _this.map.getView().getResolution() / 100000, 2);
237
+ _this.seriesGeometries.forEach(function (entry) {
238
+ // ignore the center geometry
239
+ if (!isEqual(entry.index, [0, 0])) {
240
+ styles.push(FeatureStyles.printInteractionSeries({
241
+ geometryFunction: entry.geometry
242
+ }));
243
+ styles.push.apply(styles, _toConsumableArray(FeatureStyles.printInteractionSeriesIcon({
244
+ geometryFunction: new ol.geom.Point(ol.extent.getCenter(entry.geometry.getExtent())),
245
+ rotation: entry.rotation,
246
+ radius: radius,
247
+ img: _this.isPrintSeriesSelected(entry) ? 'minus' : 'plus'
248
+ })));
249
+ }
250
+ });
251
+ return styles;
252
+ }
253
+
254
+ // main feature
255
+ if (feature === _this.feature) {
256
+ var _styles = [FeatureStyles.printInteraction({
257
+ geometryFunction: _this.getGeometry
258
+ })];
259
+ var coordinates = _this.getGeometry().getCoordinates()[0];
260
+ if (coordinates && _this.props.fixedFrame) {
261
+ if (_this.props.allowScaling) {
262
+ // vertices to scale the selection
263
+ _styles.push(FeatureStyles.printInteractionVertex({
264
+ geometryFunction: new ol.geom.MultiPoint(coordinates.slice(2))
265
+ }));
266
+ }
267
+ if (_this.props.allowScaling || _this.props.allowRotation) {
268
+ // vertices to scale or rotate the selection
269
+ _styles.push(FeatureStyles.printInteractionVertex({
270
+ geometryFunction: new ol.geom.MultiPoint(coordinates.slice(1, 2)),
271
+ fill: _this.props.allowRotation
272
+ }));
273
+ }
274
+ }
275
+ return _styles;
276
+ }
277
+ return null;
278
+ });
279
+ _defineProperty(_this, "scaleRotateStyle", function (feature) {
280
+ feature.get('features').forEach(function (modifyFeature) {
281
+ var modifyGeometry = modifyFeature.get('modifyGeometry');
282
+ if (modifyGeometry) {
283
+ var point = feature.getGeometry().getCoordinates();
284
+ // rotate only with vertex on bottom-right
285
+ var isRotationVertex = isEqual(point, modifyFeature.getGeometry().getCoordinates()[0][1]);
286
+ if (!modifyGeometry.point) {
287
+ // save the initial geometry and vertex position
288
+ modifyGeometry.point = point;
289
+ modifyGeometry.initialGeometry = modifyGeometry.geometry;
290
+ }
291
+ var center = ol.extent.getCenter(modifyGeometry.initialGeometry.getExtent());
292
+ var _this$calculateRotati = _this.calculateRotationScale(modifyGeometry.point, point, center),
293
+ _this$calculateRotati2 = _slicedToArray(_this$calculateRotati, 2),
294
+ rotation = _this$calculateRotati2[0],
295
+ scale = _this$calculateRotati2[1];
296
+ var geometry = modifyGeometry.initialGeometry.clone();
297
+ if (_this.props.allowRotation && isRotationVertex) {
298
+ geometry.rotate(rotation, center);
299
+ } else if (_this.props.allowScaling) {
300
+ geometry.scale(scale, undefined, center);
301
+ }
302
+ modifyGeometry.geometry = geometry;
303
+ }
304
+ });
305
+ return null;
306
+ });
307
+ _defineProperty(_this, "isPrintSeriesSelected", function (entry) {
308
+ return _this.props.printSeriesSelected.includes(entry.index.join(','));
309
+ });
310
+ _defineProperty(_this, "calculateExtents", function () {
311
+ _this.seriesGeometries = _this.calculateSeriesGeometries();
312
+ _this.selectionLayer.changed();
313
+ return _this.seriesGeometries.filter(function (entry) {
314
+ return isEqual(entry.index, [0, 0]) || _this.isPrintSeriesSelected(entry);
315
+ }).map(function (entry) {
316
+ var clonedGeom = entry.geometry.clone();
317
+ var center = ol.extent.getCenter(clonedGeom.getExtent());
318
+ clonedGeom.rotate(-_this.props.rotation * Math.PI / 180, center);
319
+ return clonedGeom.getExtent();
320
+ });
321
+ });
322
+ _defineProperty(_this, "geometryChanged", function () {
323
+ var geometry = _this.getGeometry();
324
+ var extent = geometry.getExtent();
325
+ var point = geometry.getCoordinates()[0][0];
326
+ var center = ol.extent.getCenter(extent);
327
+
328
+ // Update series geometries and obtain extents
329
+ var extents = _this.calculateExtents();
330
+ var rotation = 0;
331
+ var scale = null;
332
+ if (_this.initialWidth !== null && _this.initialHeight !== null) {
333
+ var initialPoint = [center[0] + 0.5 * _this.initialWidth, center[1] + 0.5 * _this.initialHeight];
334
+ var _this$calculateRotati3 = _this.calculateRotationScale(initialPoint, point, center),
335
+ _this$calculateRotati4 = _slicedToArray(_this$calculateRotati3, 2),
336
+ calcRotation = _this$calculateRotati4[0],
337
+ calcScale = _this$calculateRotati4[1];
338
+ var degree = (360 + calcRotation * 180 / Math.PI) % 360;
339
+ rotation = Math.round(degree * 10) / 10 % 360;
340
+ scale = Math.round(1000 * calcScale);
341
+ }
342
+ _this.props.geometryChanged(center, extents, rotation, scale);
343
+ });
344
+ _defineProperty(_this, "calculateRotationScale", function (p1, p2, center) {
345
+ var dx = p1[0] - center[0];
346
+ var dy = p1[1] - center[1];
347
+ var initialAngle = Math.atan2(dy, dx);
348
+ var initialRadius = Math.sqrt(dx * dx + dy * dy);
349
+ dx = p2[0] - center[0];
350
+ dy = p2[1] - center[1];
351
+ var currentAngle = Math.atan2(dy, dx);
352
+ var currentRadius = Math.sqrt(dx * dx + dy * dy);
353
+ return [currentAngle - initialAngle, currentRadius / initialRadius];
354
+ });
355
+ _this.map = MapUtils.getHook(MapUtils.GET_MAP);
356
+
357
+ // create a layer to draw on
358
+ _this.source = new ol.source.Vector();
359
+ _this.selectionLayer = new ol.layer.Vector({
360
+ source: _this.source,
361
+ zIndex: 1000000,
362
+ style: _this.layerStyle
363
+ });
364
+
365
+ // create a geometry for the background feature
366
+ var _extent = (_this$map$getView$get = _this.map.getView().getProjection().getExtent()) !== null && _this$map$getView$get !== void 0 ? _this$map$getView$get : [Number.MIN_SAFE_INTEGER, Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER];
367
+ var _geometry = ol.geom.polygonFromExtent(_extent);
368
+ _this.backgroundFeature = new ol.Feature(_geometry);
369
+ _this.source.addFeature(_this.backgroundFeature);
370
+ _this.printSeriesFeature = new ol.Feature(_geometry);
371
+ _this.source.addFeature(_this.printSeriesFeature);
372
+ _this.feature = null;
373
+ _this.initialWidth = null;
374
+ _this.initialHeight = null;
375
+ _this.seriesGeometries = [];
376
+ _this.translateInteraction = null;
377
+ _this.scaleRotateInteraction = null;
378
+ _this.selectPrintSeriesInteraction = null;
379
+ _this.drawInteraction = null;
380
+ _this.isInteracting = false;
381
+ return _this;
382
+ }
383
+ _inherits(PrintSelection, _React$Component);
384
+ return _createClass(PrintSelection, [{
385
+ key: "componentDidUpdate",
386
+ value: function componentDidUpdate(prevProps) {
387
+ if (!isEqual(prevProps.fixedFrame, this.props.fixedFrame) || !isEqual(prevProps.center, this.props.center) || prevProps.rotation !== this.props.rotation || prevProps.scale !== this.props.scale) {
388
+ if (!this.isInteracting) {
389
+ this.recomputeFeature();
390
+ }
391
+ }
392
+ if (prevProps.printSeriesEnabled !== this.props.printSeriesEnabled || prevProps.printSeriesOverlap !== this.props.printSeriesOverlap || prevProps.printSeriesSelected !== this.props.printSeriesSelected) {
393
+ this.geometryChanged();
394
+ }
395
+ }
396
+ }, {
397
+ key: "recomputeFeature",
398
+ value: function recomputeFeature() {
399
+ // delete the old feature
400
+ if (this.feature !== null) {
401
+ // remove old feature
402
+ this.source.removeFeature(this.feature);
403
+ this.feature = null;
404
+ this.initialWidth = null;
405
+ this.initialHeight = null;
406
+ this.seriesGeometries = [];
407
+ }
408
+ // render the current feature if given a fixed frame
409
+ if (this.props.fixedFrame !== null) {
410
+ // calculate actual width and height
411
+ var _MapUtils$transformEx = MapUtils.transformExtent(this.map.getView().getProjection(), this.props.center, this.props.fixedFrame.width, this.props.fixedFrame.height),
412
+ width = _MapUtils$transformEx.width,
413
+ height = _MapUtils$transformEx.height;
414
+ // add rectangle
415
+ var x1 = this.props.center[0] + 0.5 * width;
416
+ var x2 = this.props.center[0] - 0.5 * width;
417
+ var y1 = this.props.center[1] + 0.5 * height;
418
+ var y2 = this.props.center[1] - 0.5 * height;
419
+ var geometry = new ol.geom.Polygon([[[x1, y1], [x1, y2], [x2, y2], [x2, y1], [x1, y1]]]);
420
+ // rotate and scale rectangle
421
+ if (this.props.rotation) {
422
+ geometry.rotate(this.props.rotation * Math.PI / 180, this.props.center);
423
+ }
424
+ if (this.props.scale) {
425
+ geometry.scale(this.props.scale / 1000, undefined, this.props.center);
426
+ }
427
+ // add feature to layer
428
+ this.feature = new ol.Feature(geometry);
429
+ this.feature.on('change', this.geometryChanged);
430
+ this.source.addFeature(this.feature);
431
+ // store initial width and height for future updates
432
+ this.initialWidth = width;
433
+ this.initialHeight = height;
434
+ // update geometry to new extent
435
+ this.geometryChanged();
436
+ }
437
+ }
438
+ }, {
439
+ key: "componentDidMount",
440
+ value: function componentDidMount() {
441
+ this.map.on('pointermove', this.setViewportCursor);
442
+ this.map.addLayer(this.selectionLayer);
443
+ this.addInteractions();
444
+ this.recomputeFeature();
445
+ }
446
+ }, {
447
+ key: "componentWillUnmount",
448
+ value: function componentWillUnmount() {
449
+ this.map.un('pointermove', this.setViewportCursor);
450
+ this.map.removeLayer(this.selectionLayer);
451
+ this.removeInteractions();
452
+ }
453
+ }, {
454
+ key: "addInteractions",
455
+ value: function addInteractions() {
456
+ var _this2 = this;
457
+ // move the selection
458
+ var translateCondition = function translateCondition(ev) {
459
+ return ol.events.condition.primaryAction(ev) && _this2.props.fixedFrame && _this2.props.allowTranslation;
460
+ };
461
+ this.translateInteraction = new ol.interaction.Translate({
462
+ condition: translateCondition,
463
+ // add condition to filter for correct cursor selection
464
+ filter: function filter(feature) {
465
+ return _this2.props.fixedFrame && _this2.props.allowTranslation && feature === _this2.feature;
466
+ },
467
+ layers: [this.selectionLayer]
468
+ });
469
+ this.translateInteraction.on('translatestart', function () {
470
+ _this2.isInteracting = true;
471
+ });
472
+ this.translateInteraction.on('translateend', function () {
473
+ _this2.isInteracting = false;
474
+ });
475
+
476
+ // scale and rotate the selection
477
+ var modifyCondition = function modifyCondition(ev) {
478
+ return ol.events.condition.primaryAction(ev) && _this2.props.fixedFrame && (_this2.props.allowScaling || _this2.props.allowRotation);
479
+ };
480
+ this.scaleRotateInteraction = new ol.interaction.Modify({
481
+ source: this.source,
482
+ condition: modifyCondition,
483
+ deleteCondition: ol.events.condition.never,
484
+ insertVertexCondition: ol.events.condition.never,
485
+ pixelTolerance: 20,
486
+ style: this.scaleRotateStyle
487
+ });
488
+ this.scaleRotateInteraction.on('modifystart', function (ev) {
489
+ _this2.isInteracting = true;
490
+ ev.features.forEach(function (feature) {
491
+ feature.set('modifyGeometry', {
492
+ geometry: feature.getGeometry().clone()
493
+ }, true);
494
+ });
495
+ });
496
+ this.scaleRotateInteraction.on('modifyend', function (ev) {
497
+ _this2.isInteracting = false;
498
+ ev.features.forEach(function (feature) {
499
+ var modifyGeometry = feature.get('modifyGeometry');
500
+ if (modifyGeometry) {
501
+ feature.setGeometry(modifyGeometry.geometry);
502
+ feature.unset('modifyGeometry', true);
503
+ }
504
+ });
505
+ _this2.recomputeFeature();
506
+ });
507
+
508
+ // select frames for printing a series
509
+ this.selectPrintSeriesInteraction = new ol.interaction.Select({
510
+ filter: function filter(feature) {
511
+ return feature === _this2.printSeriesFeature;
512
+ },
513
+ layers: [this.selectionLayer],
514
+ condition: ol.events.condition.click,
515
+ addCondition: ol.events.condition.always,
516
+ removeCondition: ol.events.condition.always,
517
+ style: null
518
+ });
519
+ this.selectPrintSeriesInteraction.on('select', function (ev) {
520
+ var coordinate = ev.mapBrowserEvent.coordinate;
521
+ var intersecting = _this2.seriesGeometries.find(function (entry) {
522
+ return !isEqual(entry.index, [0, 0]) && entry.geometry.intersectsCoordinate(coordinate);
523
+ });
524
+ if (intersecting) {
525
+ var selected = _this2.props.printSeriesSelected;
526
+ if (selected.includes(intersecting.index.join(','))) {
527
+ selected = selected.filter(function (index) {
528
+ return index !== intersecting.index.join(',');
529
+ });
530
+ } else {
531
+ selected = [].concat(_toConsumableArray(selected), [intersecting.index.join(',')]);
532
+ }
533
+ _this2.props.printSeriesChanged(selected);
534
+ }
535
+ });
536
+
537
+ // select a new area when no frame is given (only added when no fixed frame is given)
538
+ var drawCondition = function drawCondition(ev) {
539
+ return ol.events.condition.primaryAction(ev) && !_this2.props.fixedFrame;
540
+ };
541
+ this.drawInteraction = new ol.interaction.Draw({
542
+ source: this.source,
543
+ type: 'Circle',
544
+ style: FeatureStyles.printInteraction(),
545
+ geometryFunction: ol.interaction.createBox(),
546
+ condition: ol.events.condition.never,
547
+ freehandCondition: drawCondition
548
+ });
549
+ this.drawInteraction.on('drawstart', function (ev) {
550
+ _this2.isInteracting = true;
551
+ _this2.feature = ev.feature;
552
+ _this2.feature.on('change', _this2.geometryChanged);
553
+ });
554
+ this.drawInteraction.on('drawend', function () {
555
+ _this2.isInteracting = false;
556
+ _this2.geometryChanged();
557
+ });
558
+
559
+ // register interactions
560
+ this.map.addInteraction(this.translateInteraction);
561
+ this.map.addInteraction(this.scaleRotateInteraction);
562
+ this.map.addInteraction(this.selectPrintSeriesInteraction);
563
+ this.map.addInteraction(this.drawInteraction);
564
+ }
565
+ }, {
566
+ key: "removeInteractions",
567
+ value: function removeInteractions() {
568
+ if (this.translateInteraction !== null) {
569
+ this.map.removeInteraction(this.translateInteraction);
570
+ this.translateInteraction = null;
571
+ }
572
+ if (this.scaleRotateInteraction !== null) {
573
+ this.map.removeInteraction(this.scaleRotateInteraction);
574
+ this.scaleRotateInteraction = null;
575
+ }
576
+ if (this.selectPrintSeriesInteraction !== null) {
577
+ this.map.removeInteraction(this.selectPrintSeriesInteraction);
578
+ this.selectPrintSeriesInteraction = null;
579
+ }
580
+ if (this.drawInteraction !== null) {
581
+ this.map.removeInteraction(this.drawInteraction);
582
+ this.drawInteraction = null;
583
+ }
584
+ }
585
+ }, {
586
+ key: "render",
587
+ value: function render() {
588
+ return null;
589
+ }
590
+ }]);
591
+ }(React.Component);
592
+ _defineProperty(PrintSelection, "propTypes", {
593
+ allowRotation: PropTypes.bool,
594
+ allowScaling: PropTypes.bool,
595
+ allowTranslation: PropTypes.bool,
596
+ center: PropTypes.arrayOf(PropTypes.number),
597
+ fixedFrame: PropTypes.shape({
598
+ width: PropTypes.number,
599
+ // in meters
600
+ height: PropTypes.number // in meters
601
+ }),
602
+ geometryChanged: PropTypes.func,
603
+ printSeriesChanged: PropTypes.func,
604
+ printSeriesEnabled: PropTypes.bool,
605
+ printSeriesGridSize: PropTypes.number,
606
+ printSeriesOverlap: PropTypes.number,
607
+ printSeriesSelected: PropTypes.arrayOf(PropTypes.string),
608
+ rotation: PropTypes.number,
609
+ scale: PropTypes.number
610
+ });
611
+ _defineProperty(PrintSelection, "defaultProps", {
612
+ allowRotation: true,
613
+ allowScaling: true,
614
+ allowTranslation: true,
615
+ fixedFrame: null,
616
+ geometryChanged: function geometryChanged() {},
617
+ printSeriesChanged: function printSeriesChanged() {},
618
+ printSeriesEnabled: false,
619
+ printSeriesGridSize: 2,
620
+ printSeriesOverlap: 0,
621
+ printSeriesSelected: [],
622
+ rotation: 0,
623
+ scale: 1000
624
+ });
625
+ export { PrintSelection as default };