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,26 +1,619 @@
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 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 _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 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; }
3
+ 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; }
4
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
5
+ 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."); }
6
+ 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; } }
7
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
8
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
9
+ 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."); }
10
+ 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; } }
11
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
12
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
13
+ 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; }
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{TextEncoder,TextDecoder}from"@kayahr/text-encoding";import axios from"axios";import dayjs from"dayjs";import FileSaver from"file-saver";import isEmpty from"lodash.isempty";import PropTypes from"prop-types";import{LayerRole}from"../actions/layers";import{setSnappingConfig}from"../actions/map";import Icon from"../components/Icon";import PrintSelection from"../components/PrintSelection";import SideBar from"../components/SideBar";import NumberInput from"../components/widgets/NumberInput";import Spinner from"../components/widgets/Spinner";import ConfigUtils from"../utils/ConfigUtils";import CoordinatesUtils from"../utils/CoordinatesUtils";import{explodeDxf,implodeDxf,mergeDxf}from"../utils/DxfUtils";import LayerUtils from"../utils/LayerUtils";import LocaleUtils from"../utils/LocaleUtils";import MapUtils from"../utils/MapUtils";import VectorLayerUtils from"../utils/VectorLayerUtils";import"./style/MapExport.css";import"@kayahr/text-encoding/encodings/windows-1252";/**
33
+ */
34
+
35
+ import React from 'react';
36
+ import { connect } from 'react-redux';
37
+ import { TextEncoder, TextDecoder } from "@kayahr/text-encoding";
38
+ import axios from 'axios';
39
+ import dayjs from 'dayjs';
40
+ import FileSaver from 'file-saver';
41
+ import isEmpty from 'lodash.isempty';
42
+ import PropTypes from 'prop-types';
43
+ import { LayerRole } from '../actions/layers';
44
+ import { setSnappingConfig } from '../actions/map';
45
+ import Icon from '../components/Icon';
46
+ import PrintSelection from '../components/PrintSelection';
47
+ import SideBar from '../components/SideBar';
48
+ import NumberInput from '../components/widgets/NumberInput';
49
+ import Spinner from '../components/widgets/Spinner';
50
+ import ConfigUtils from '../utils/ConfigUtils';
51
+ import CoordinatesUtils from '../utils/CoordinatesUtils';
52
+ import { explodeDxf, implodeDxf, mergeDxf } from '../utils/DxfUtils';
53
+ import LayerUtils from '../utils/LayerUtils';
54
+ import LocaleUtils from '../utils/LocaleUtils';
55
+ import MapUtils from '../utils/MapUtils';
56
+ import VectorLayerUtils from '../utils/VectorLayerUtils';
57
+ import './style/MapExport.css';
58
+ import "@kayahr/text-encoding/encodings/windows-1252";
59
+
60
+ /**
8
61
  * Allows exporting a selected portion of the map to a variety of formats.
9
- */var MapExport=/*#__PURE__*/function(_React$Component){function MapExport(props){var _this;_classCallCheck(this,MapExport);_this=_callSuper(this,MapExport,[props]);_defineProperty(_this,"state",{extents:[],exporting:false,availableFormats:[],selectedFormat:null,selectedFormatConfiguration:"",exportProjection:null,scale:null,pageSize:null,dpi:96});_defineProperty(_this,"changeFormat",function(ev){var _this$props$formatCon,_formatConfigurations,_formatConfigurations2;var selectedFormat=ev.target.value;var formatConfigurations=((_this$props$formatCon=_this.props.formatConfiguration)===null||_this$props$formatCon===void 0?void 0:_this$props$formatCon[selectedFormat.split(";")[0]])||[];_this.setState({selectedFormat:selectedFormat,selectedFormatConfiguration:(_formatConfigurations=formatConfigurations[0])===null||_formatConfigurations===void 0?void 0:_formatConfigurations.name,exportProjection:_this.getExportProjection((_formatConfigurations2=formatConfigurations[0])===null||_formatConfigurations2===void 0?void 0:_formatConfigurations2.projections)})});_defineProperty(_this,"setSelectedFormatConfiguration",function(ev){var _this$props$formatCon2;var selectedFormatConfiguration=ev.target.value;var formatConfigurations=((_this$props$formatCon2=_this.props.formatConfiguration)===null||_this$props$formatCon2===void 0?void 0:_this$props$formatCon2[_this.state.selectedFormat.split(";")[0]])||[];var formatConfiguration=formatConfigurations.find(function(entry){return entry.name===selectedFormatConfiguration});_this.setState({selectedFormatConfiguration:selectedFormatConfiguration,exportProjection:_this.getExportProjection(formatConfiguration.projections)})});_defineProperty(_this,"getExportProjection",function(projections){if(isEmpty(projections)){return _this.props.map.projection}else{return projections.indexOf(_this.props.map.projection)!==-1?_this.props.map.projection:projections[0]}});_defineProperty(_this,"changeScale",function(value){_this.setState({scale:Math.max(1,parseInt(value,10)||0)})});_defineProperty(_this,"changeResolution",function(ev){_this.setState({dpi:parseInt(ev.target.value,10)||0})});_defineProperty(_this,"renderBody",function(){var _this$props$formatCon3;if(!_this.props.theme||!_this.state.selectedFormat){return null}var formatMap={"image/jpeg":"JPEG","image/png":"PNG","image/png; mode=16bit":"PNG 16bit","image/png; mode=8bit":"PNG 8bit","image/png; mode=1bit":"PNG 1bit","image/geotiff":"GeoTIFF","image/tiff":"GeoTIFF","application/dxf":"DXF","application/pdf":"GeoPDF"};var formatConfigurations=((_this$props$formatCon3=_this.props.formatConfiguration)===null||_this$props$formatCon3===void 0?void 0:_this$props$formatCon3[_this.state.selectedFormat.split(";")[0]])||[];var formatConfiguration=formatConfigurations.find(function(entry){return entry.name===_this.state.selectedFormatConfiguration});var scaleChooser=null;if(!isEmpty(_this.props.allowedScales)){scaleChooser=/*#__PURE__*/React.createElement("select",{onChange:_this.changeScale,value:_this.state.scale||""},/*#__PURE__*/React.createElement("option",{hidden:true,value:_this.state.scale||""},_this.state.scale||""),_this.props.allowedScales.map(function(scale){return/*#__PURE__*/React.createElement("option",{key:scale,value:scale},"1 : ",scale)}))}else if(_this.props.allowedScales!==false){scaleChooser=/*#__PURE__*/React.createElement(NumberInput,{min:1,mobile:true,onChange:_this.changeScale,prefix:"1 : ",value:_this.state.scale||null})}return/*#__PURE__*/React.createElement("div",{className:"mapexport-body"},/*#__PURE__*/React.createElement("form",{action:"#",method:"POST",onSubmit:_this["export"],ref:function ref(el){_this.form=el}},/*#__PURE__*/React.createElement("table",{className:"options-table"},/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("mapexport.format")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:_this.changeFormat,value:_this.state.selectedFormat},_this.state.availableFormats.map(function(format){return/*#__PURE__*/React.createElement("option",{key:format,value:format},formatMap[format]||format)})))),formatConfigurations.length>1?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("mapexport.configuration")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:_this.setSelectedFormatConfiguration,value:_this.state.selectedFormatConfiguration},formatConfigurations.map(function(config){return/*#__PURE__*/React.createElement("option",{key:config.name,value:config.name},config.labelMsgId?LocaleUtils.tr(config.labelMsgId):config.name)})))):null,!isEmpty(_this.props.pageSizes)?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("mapexport.size")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.setState({pageSize:ev.target.value||null})},value:_this.state.pageSize||""},/*#__PURE__*/React.createElement("option",{value:""},LocaleUtils.tr("mapexport.usersize")),_this.props.pageSizes.map(function(entry,idx){return/*#__PURE__*/React.createElement("option",{key:"size_"+idx,value:idx},entry.name)})))):null,scaleChooser&&_this.state.pageSize!==null?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("mapexport.scale")),/*#__PURE__*/React.createElement("td",null,scaleChooser)):null,_this.props.dpis&&_this.state.selectedFormat!=="application/dxf"?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("mapexport.resolution")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:_this.changeResolution,value:_this.state.dpi},_this.props.dpis.map(function(dpi){return/*#__PURE__*/React.createElement("option",{key:dpi+"dpi",value:dpi},dpi+" dpi")})))):null,((formatConfiguration===null||formatConfiguration===void 0?void 0:formatConfiguration.projections)||[]).length>1?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("mapexport.projection")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.setState({exportProjection:ev.target.value})},value:_this.state.exportProjection},formatConfiguration.projections.map(function(proj){return/*#__PURE__*/React.createElement("option",{key:proj,value:proj},proj)})))):null)),/*#__PURE__*/React.createElement("div",{className:"button-bar"},/*#__PURE__*/React.createElement("button",{className:"button",disabled:_this.state.exporting||isEmpty(_this.state.extents),type:"submit"},_this.state.exporting?/*#__PURE__*/React.createElement("span",{className:"mapexport-wait"},/*#__PURE__*/React.createElement(Spinner,null)," ",LocaleUtils.tr("mapexport.wait")):LocaleUtils.tr("mapexport.submit")))))});_defineProperty(_this,"renderPrintSelection",function(){if(_this.state.pageSize!==null){var pageSize=_this.props.pageSizes[_this.state.pageSize];var frame={width:pageSize.width,height:pageSize.height};return/*#__PURE__*/React.createElement(PrintSelection,{allowRotation:false,allowScaling:_this.props.allowedScales!==false,center:_this.props.map.center,fixedFrame:frame,geometryChanged:_this.geometryChanged,key:"PrintSelection",scale:_this.state.scale})}else{return/*#__PURE__*/React.createElement(PrintSelection,{allowRotation:false,geometryChanged:_this.geometryChanged,key:"PrintSelection"})}});_defineProperty(_this,"onShow",function(){var _this$props$formatCon4,_formatConfigurations3,_formatConfigurations4;var scale=Math.round(MapUtils.computeForZoom(_this.props.map.scales,_this.props.map.zoom)*_this.props.defaultScaleFactor);if(!isEmpty(_this.props.allowedScales)){var closestVal=Math.abs(scale-_this.props.allowedScales[0]);var closestIdx=0;for(var i=1;i<_this.props.allowedScales.length;++i){var currVal=Math.abs(scale-_this.props.allowedScales[i]);if(currVal<closestVal){closestVal=currVal;closestIdx=i}}scale=_this.props.allowedScales[closestIdx]}var availableFormats=_toConsumableArray(_this.props.theme.availableFormats);(_this.props.forceAvailableFormats||[]).forEach(function(format){if(!availableFormats.includes(format)){availableFormats.push(format)}});if(!isEmpty(_this.props.allowedFormats)){availableFormats=_this.props.allowedFormats.filter(function(fmt){return availableFormats.includes(fmt)})}var selectedFormat=_this.props.defaultFormat&&availableFormats.includes(_this.props.defaultFormat)?_this.props.defaultFormat:availableFormats[0];var formatConfigurations=((_this$props$formatCon4=_this.props.formatConfiguration)===null||_this$props$formatCon4===void 0?void 0:_this$props$formatCon4[selectedFormat.split(";")[0]])||[];_this.setState({scale:scale,availableFormats:availableFormats,selectedFormat:selectedFormat,selectedFormatConfiguration:(_formatConfigurations3=formatConfigurations[0])===null||_formatConfigurations3===void 0?void 0:_formatConfigurations3.name,exportProjection:_this.getExportProjection((_formatConfigurations4=formatConfigurations[0])===null||_formatConfigurations4===void 0?void 0:_formatConfigurations4.projections)});_this.props.setSnappingConfig(false,false)});_defineProperty(_this,"onHide",function(){_this.setState({extents:[],width:0,height:0,scale:null,pageSize:null})});_defineProperty(_this,"geometryChanged",function(center,extents,rotation,scale){_this.setState(function(state){return{extents:extents,scale:scale!==null&&scale!==void 0?scale:state.scale}})});_defineProperty(_this,"export",function(ev){var _this$props$formatCon5,_this$state$extents$a;ev.preventDefault();_this.setState({exporting:true});var format=_this.state.selectedFormat.split(";")[0];var formatConfiguration=(((_this$props$formatCon5=_this.props.formatConfiguration)===null||_this$props$formatCon5===void 0?void 0:_this$props$formatCon5[format])||[]).find(function(entry){return entry.name===_this.state.selectedFormatConfiguration});var version=_this.props.theme.version;var crs=_this.state.exportProjection;var extent=CoordinatesUtils.reprojectBbox((_this$state$extents$a=_this.state.extents.at(0))!==null&&_this$state$extents$a!==void 0?_this$state$extents$a:[0,0,0,0],_this.props.map.projection,crs);var formattedExtent=CoordinatesUtils.getAxisOrder(crs).substring(0,2)==="ne"&&version==="1.3.0"?extent[1]+","+extent[0]+","+extent[3]+","+extent[2]:extent.join(",");var getPixelFromCoordinate=MapUtils.getHook(MapUtils.GET_PIXEL_FROM_COORDINATES_HOOK);var p1=getPixelFromCoordinate(extent.slice(0,2));var p2=getPixelFromCoordinate(extent.slice(2,4));var width=Math.round(Math.abs(p1[0]-p2[0])*_this.state.dpi/96);var height=Math.round(Math.abs(p1[1]-p2[1])*_this.state.dpi/96);var ext=format.split("/").pop();var timestamp=dayjs(new Date).format("YYYYMMDD_HHmmss");var fileName=_this.props.fileNameTemplate.replace("{username}",ConfigUtils.getConfigProp("username",null,"")).replace("{tenant}",ConfigUtils.getConfigProp("tenant",null,"")).replace("{theme}",_this.props.theme.id).replace("{themeTitle}",_this.props.theme.title||"").replace("{timestamp}",timestamp)+"."+ext;var params={};// Base request params
10
- params.SERVICE="WMS";params.VERSION=version;params.REQUEST="GetMap";params.FORMAT=_this.state.selectedFormat;params.DPI=_this.state.dpi;params.TRANSPARENT=true;params.TILED=false;params.CRS=crs;params.BBOX=formattedExtent;params.WIDTH=width;params.HEIGHT=height;params.filename=fileName;// Dimension values
11
- _this.props.layers.forEach(function(layer){if(layer.role===LayerRole.THEME){Object.entries(layer.dimensionValues||{}).forEach(function(_ref){var _ref2=_slicedToArray(_ref,2),key=_ref2[0],value=_ref2[1];if(value!==undefined){params[key]=value}})}});// Add parameters from custom format configuration
12
- if(formatConfiguration){var _formatConfiguration$;var keyCaseMap=Object.keys(params).reduce(function(res,key){return _objectSpread(_objectSpread({},res),{},_defineProperty({},key.toLowerCase(),key))},{});(formatConfiguration.extraQuery||"").split(/[?&]/).filter(Boolean).forEach(function(entry){var _entry$split=entry.split("="),_entry$split2=_slicedToArray(_entry$split,2),key=_entry$split2[0],value=_entry$split2[1];var caseKey=keyCaseMap[key.toLowerCase()]||key;params[caseKey]=value!==null&&value!==void 0?value:""});params.FORMAT_OPTIONS=(_formatConfiguration$=formatConfiguration.formatOptions)!==null&&_formatConfiguration$!==void 0?_formatConfiguration$:"";if(formatConfiguration.baseLayer){var layers=params[keyCaseMap.layers].split(",");if(!layers.includes(formatConfiguration.baseLayer)){params[keyCaseMap.layers]=[formatConfiguration.baseLayer].concat(_toConsumableArray(layers))}}}if(_this.state.selectedFormat==="application/dxf"){_this.dxfExport(params,fileName,formatConfiguration)}else{_this.genericExport(params,fileName,formatConfiguration)}});_defineProperty(_this,"genericExport",function(params,fileName,formatConfiguration){var _formatConfiguration$2;// Layer params
13
- var exportExternalLayers=_this.props.exportExternalLayers&&ConfigUtils.getConfigProp("qgisServerVersion",null,3)>=3;var exportParams=LayerUtils.collectPrintParams(_this.props.layers,_this.props.theme,_this.state.scale,_this.state.exportProjection,exportExternalLayers,!!(formatConfiguration!==null&&formatConfiguration!==void 0&&formatConfiguration.baseLayer));Object.assign(params,exportParams);// Highlight params
14
- var highlightParams=VectorLayerUtils.createPrintHighlighParams(_this.props.layers,_this.state.exportProjection,_this.state.scale,_this.state.dpi);params.HIGHLIGHT_GEOM=highlightParams.geoms.join(";");params.HIGHLIGHT_SYMBOL=highlightParams.styles.join(";");params.HIGHLIGHT_LABELSTRING=highlightParams.labels.join(";");params.HIGHLIGHT_LABELCOLOR=highlightParams.labelFillColors.join(";");params.HIGHLIGHT_LABELBUFFERCOLOR=highlightParams.labelOutlineColors.join(";");params.HIGHLIGHT_LABELBUFFERSIZE=highlightParams.labelOutlineSizes.join(";");params.HIGHLIGHT_LABELSIZE=highlightParams.labelSizes.join(";");params.HIGHLIGHT_LABEL_DISTANCE=highlightParams.labelDist.join(";");params.HIGHLIGHT_LABEL_ROTATION=highlightParams.labelRotations.join(";");// Watermark params
15
- Object.keys(_this.props.theme.watermark||{}).forEach(function(key){params["WATERMARK_"+key.toUpperCase()]=_this.props.theme.watermark[key]});var data=Object.entries(params).map(function(pair){return pair.map(function(entry){return encodeURIComponent(entry).replace(/%20/g,"+")}).join("=")}).join("&");var config={headers:{"Content-Type":"application/x-www-form-urlencoded"},responseType:"arraybuffer"};axios.post((_formatConfiguration$2=formatConfiguration===null||formatConfiguration===void 0?void 0:formatConfiguration.serviceUrl)!==null&&_formatConfiguration$2!==void 0?_formatConfiguration$2:_this.props.theme.url,data,config).then(function(response){_this.setState({exporting:false});var contentType=response.headers["content-type"];FileSaver.saveAs(new Blob([response.data],{type:contentType}),fileName)})["catch"](function(e){_this.setState({exporting:false});if(e.response){/* eslint-disable-next-line */console.log(new TextDecoder().decode(e.response.data))}/* eslint-disable-next-line */alert("Export failed")})});_defineProperty(_this,"dxfExport",function(baseParams,fileName,formatConfiguration){var promises=_this.props.layers.filter(function(layer){var _layer$mapFormats;return layer.type==="wms"&&layer.role>LayerRole.BACKGROUND&&((_layer$mapFormats=layer.mapFormats)===null||_layer$mapFormats===void 0?void 0:_layer$mapFormats.includes("application/dxf"))}).reverse().map(function(layer){var _layer$params$FILTER,_layer$params$FILTER_;var params=_objectSpread(_objectSpread({},baseParams),{},{LAYERS:layer.params.LAYERS,OPACITIES:layer.params.OPACITIES,STYLES:layer.params.STYLES,FILTER:(_layer$params$FILTER=layer.params.FILTER)!==null&&_layer$params$FILTER!==void 0?_layer$params$FILTER:"",FILTER_GEOM:(_layer$params$FILTER_=layer.params.FILTER_GEOM)!==null&&_layer$params$FILTER_!==void 0?_layer$params$FILTER_:""});var data=Object.entries(params).map(function(pair){return pair.map(function(entry){return encodeURIComponent(entry).replace(/%20/g,"+")}).join("=")}).join("&");var config={headers:{"Content-Type":"application/x-www-form-urlencoded"},responseType:"arraybuffer"};return new Promise(function(resolve,reject){var _formatConfiguration$3;axios.post((_formatConfiguration$3=formatConfiguration===null||formatConfiguration===void 0?void 0:formatConfiguration.serviceUrl)!==null&&_formatConfiguration$3!==void 0?_formatConfiguration$3:layer.url,data,config).then(function(response){resolve(response)})["catch"](function(e){/* eslint-disable-next-line */console.warn(e);resolve(null)})})});Promise.all(promises).then(function(responses){var decoder=new TextDecoder("iso-8859-1");var dxfDocuments=responses.filter(function(response){return response.headers["content-type"]==="application/dxf"}).map(function(response){return explodeDxf(decoder.decode(response.data))});var dxfDocument=mergeDxf(dxfDocuments);var result=implodeDxf(dxfDocument);var encoder=new TextEncoder("iso-8859-1");FileSaver.saveAs(new Blob([encoder.encode(result)],{type:"application/dxf"}),fileName);/*
16
- responses.forEach((response, idx) => {
17
- FileSaver.saveAs(new Blob([response.data], {type: "application/dxf"}), "orig_" + idx + "_" + fileName);
18
- });
19
- */_this.setState({exporting:false})})});_this.form=null;_this.state.dpi=(props.dpis||[])[0]||96;return _this}_inherits(MapExport,_React$Component);return _createClass(MapExport,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){if(this.state.pageSize===null&&prevState.pageSize!==null){this.setState({extents:[]})}}},{key:"render",value:function render(){var _this2=this;var minMaxTooltip=this.state.minimized?LocaleUtils.tr("print.maximize"):LocaleUtils.tr("print.minimize");var extraTitlebarContent=/*#__PURE__*/React.createElement(Icon,{className:"mapexport-minimize-maximize",icon:this.state.minimized?"chevron-down":"chevron-up",onClick:function onClick(){return _this2.setState(function(state){return{minimized:!state.minimized}})},title:minMaxTooltip});return/*#__PURE__*/React.createElement(SideBar,{extraClasses:"MapExport",extraTitlebarContent:extraTitlebarContent,icon:"rasterexport",id:"MapExport",key:"MapExport",onHide:this.onHide,onShow:this.onShow,side:this.props.side,title:LocaleUtils.tr("appmenu.items.MapExport"),width:"20em"},function(){return{body:_this2.state.minimized?null:_this2.renderBody(),extra:[_this2.renderPrintSelection()]}})}}])}(React.Component);_defineProperty(MapExport,"propTypes",{/** Whitelist of allowed export format mimetypes. If empty, supported formats are listed. */allowedFormats:PropTypes.arrayOf(PropTypes.string),/** List of scales at which to export the map. If empty, scale can be freely specified. If `false`, the map can only be exported at the current scale. */allowedScales:PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number),PropTypes.bool]),/** Default export format mimetype. If empty, first available format is used. */defaultFormat:PropTypes.string,/** The factor to apply to the map scale to determine the initial export map scale (if `allowedScales` is not `false`). */defaultScaleFactor:PropTypes.number,/** List of dpis at which to export the map. If empty, the default server dpi is used. */dpis:PropTypes.arrayOf(PropTypes.number),/** Whether to include external layers in the image. Requires QGIS Server 3.x! */exportExternalLayers:PropTypes.bool,/** Template for the name of the generated files when downloading. Can contain the placeholders `{username}`, `{tenant}`, `{theme}`, `{themeTitle}`, `{timestamp}`. */fileNameTemplate:PropTypes.string,/** Formats to force as available even if the map capabilities report otherwise. Useful if a serviceUrl is defined in a format configuration. */forceAvailableFormats:PropTypes.array,/** Custom export configuration per format.
20
- * If more than one configuration per format is provided, a selection combo will be displayed.
21
- * `labelMsgId` is a translation string message id for the combo label. If not defined, `name` will be displayed.
22
- * `extraQuery` will be appended to the query string (replacing any existing parameters).
23
- * `formatOptions` will be passed as FORMAT_OPTIONS.
24
- * `baseLayer` will be appended to the LAYERS instead of the background layer.
25
- * `projections` is a list of export projections. If empty, the map projection is automatically used.
26
- * `serviceUrl` is the address of a custom service to use instead of the layer OWS service url. */formatConfiguration:PropTypes.shape({format:PropTypes.arrayOf(PropTypes.shape({name:PropTypes.string,labelMsgId:PropTypes.string,extraQuery:PropTypes.string,formatOptions:PropTypes.string,baseLayer:PropTypes.string,projections:PropTypes.array,serviceUrl:PropTypes.string}))}),layers:PropTypes.array,map:PropTypes.object,/** List of image sizes to offer, in addition to the free-hand selection. The width and height are in millimeters. */pageSizes:PropTypes.arrayOf(PropTypes.shape({name:PropTypes.string,width:PropTypes.number,height:PropTypes.number})),setIdentifyEnabled:PropTypes.func,setSnappingConfig:PropTypes.func,/** The side of the application on which to display the sidebar. */side:PropTypes.string,theme:PropTypes.object});_defineProperty(MapExport,"defaultProps",{defaultScaleFactor:1,exportExternalLayers:true,fileNameTemplate:"{theme}_{timestamp}",side:"right",pageSizes:[]});var selector=function selector(state){return{theme:state.theme.current,map:state.map,layers:state.layers.flat}};export default connect(selector,{setSnappingConfig:setSnappingConfig})(MapExport);
62
+ */
63
+ var MapExport = /*#__PURE__*/function (_React$Component) {
64
+ function MapExport(props) {
65
+ var _this;
66
+ _classCallCheck(this, MapExport);
67
+ _this = _callSuper(this, MapExport, [props]);
68
+ _defineProperty(_this, "state", {
69
+ extents: [],
70
+ exporting: false,
71
+ availableFormats: [],
72
+ selectedFormat: null,
73
+ selectedFormatConfiguration: '',
74
+ exportProjection: null,
75
+ scale: null,
76
+ pageSize: null,
77
+ dpi: 96
78
+ });
79
+ _defineProperty(_this, "changeFormat", function (ev) {
80
+ var _this$props$formatCon, _formatConfigurations, _formatConfigurations2;
81
+ var selectedFormat = ev.target.value;
82
+ var formatConfigurations = ((_this$props$formatCon = _this.props.formatConfiguration) === null || _this$props$formatCon === void 0 ? void 0 : _this$props$formatCon[selectedFormat.split(";")[0]]) || [];
83
+ _this.setState({
84
+ selectedFormat: selectedFormat,
85
+ selectedFormatConfiguration: (_formatConfigurations = formatConfigurations[0]) === null || _formatConfigurations === void 0 ? void 0 : _formatConfigurations.name,
86
+ exportProjection: _this.getExportProjection((_formatConfigurations2 = formatConfigurations[0]) === null || _formatConfigurations2 === void 0 ? void 0 : _formatConfigurations2.projections)
87
+ });
88
+ });
89
+ _defineProperty(_this, "setSelectedFormatConfiguration", function (ev) {
90
+ var _this$props$formatCon2;
91
+ var selectedFormatConfiguration = ev.target.value;
92
+ var formatConfigurations = ((_this$props$formatCon2 = _this.props.formatConfiguration) === null || _this$props$formatCon2 === void 0 ? void 0 : _this$props$formatCon2[_this.state.selectedFormat.split(";")[0]]) || [];
93
+ var formatConfiguration = formatConfigurations.find(function (entry) {
94
+ return entry.name === selectedFormatConfiguration;
95
+ });
96
+ _this.setState({
97
+ selectedFormatConfiguration: selectedFormatConfiguration,
98
+ exportProjection: _this.getExportProjection(formatConfiguration.projections)
99
+ });
100
+ });
101
+ _defineProperty(_this, "getExportProjection", function (projections) {
102
+ if (isEmpty(projections)) {
103
+ return _this.props.map.projection;
104
+ } else {
105
+ return projections.indexOf(_this.props.map.projection) !== -1 ? _this.props.map.projection : projections[0];
106
+ }
107
+ });
108
+ _defineProperty(_this, "changeScale", function (value) {
109
+ _this.setState({
110
+ scale: Math.max(1, parseInt(value, 10) || 0)
111
+ });
112
+ });
113
+ _defineProperty(_this, "changeResolution", function (ev) {
114
+ _this.setState({
115
+ dpi: parseInt(ev.target.value, 10) || 0
116
+ });
117
+ });
118
+ _defineProperty(_this, "renderBody", function () {
119
+ var _this$props$formatCon3;
120
+ if (!_this.props.theme || !_this.state.selectedFormat) {
121
+ return null;
122
+ }
123
+ var formatMap = {
124
+ "image/jpeg": "JPEG",
125
+ "image/png": "PNG",
126
+ "image/png; mode=16bit": "PNG 16bit",
127
+ "image/png; mode=8bit": "PNG 8bit",
128
+ "image/png; mode=1bit": "PNG 1bit",
129
+ "image/geotiff": "GeoTIFF",
130
+ "image/tiff": "GeoTIFF",
131
+ "application/dxf": "DXF",
132
+ "application/pdf": "GeoPDF"
133
+ };
134
+ var formatConfigurations = ((_this$props$formatCon3 = _this.props.formatConfiguration) === null || _this$props$formatCon3 === void 0 ? void 0 : _this$props$formatCon3[_this.state.selectedFormat.split(";")[0]]) || [];
135
+ var formatConfiguration = formatConfigurations.find(function (entry) {
136
+ return entry.name === _this.state.selectedFormatConfiguration;
137
+ });
138
+ var scaleChooser = null;
139
+ if (!isEmpty(_this.props.allowedScales)) {
140
+ scaleChooser = /*#__PURE__*/React.createElement("select", {
141
+ onChange: _this.changeScale,
142
+ value: _this.state.scale || ""
143
+ }, /*#__PURE__*/React.createElement("option", {
144
+ hidden: true,
145
+ value: _this.state.scale || ""
146
+ }, _this.state.scale || ""), _this.props.allowedScales.map(function (scale) {
147
+ return /*#__PURE__*/React.createElement("option", {
148
+ key: scale,
149
+ value: scale
150
+ }, "1 : ", scale);
151
+ }));
152
+ } else if (_this.props.allowedScales !== false) {
153
+ scaleChooser = /*#__PURE__*/React.createElement(NumberInput, {
154
+ min: 1,
155
+ mobile: true,
156
+ onChange: _this.changeScale,
157
+ prefix: "1 : ",
158
+ value: _this.state.scale || null
159
+ });
160
+ }
161
+ return /*#__PURE__*/React.createElement("div", {
162
+ className: "mapexport-body"
163
+ }, /*#__PURE__*/React.createElement("form", {
164
+ action: "#",
165
+ method: "POST",
166
+ onSubmit: _this["export"],
167
+ ref: function ref(el) {
168
+ _this.form = el;
169
+ }
170
+ }, /*#__PURE__*/React.createElement("table", {
171
+ className: "options-table"
172
+ }, /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("mapexport.format")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("select", {
173
+ onChange: _this.changeFormat,
174
+ value: _this.state.selectedFormat
175
+ }, _this.state.availableFormats.map(function (format) {
176
+ return /*#__PURE__*/React.createElement("option", {
177
+ key: format,
178
+ value: format
179
+ }, formatMap[format] || format);
180
+ })))), formatConfigurations.length > 1 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("mapexport.configuration")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("select", {
181
+ onChange: _this.setSelectedFormatConfiguration,
182
+ value: _this.state.selectedFormatConfiguration
183
+ }, formatConfigurations.map(function (config) {
184
+ return /*#__PURE__*/React.createElement("option", {
185
+ key: config.name,
186
+ value: config.name
187
+ }, config.labelMsgId ? LocaleUtils.tr(config.labelMsgId) : config.name);
188
+ })))) : null, !isEmpty(_this.props.pageSizes) ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("mapexport.size")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("select", {
189
+ onChange: function onChange(ev) {
190
+ return _this.setState({
191
+ pageSize: ev.target.value || null
192
+ });
193
+ },
194
+ value: _this.state.pageSize || ""
195
+ }, /*#__PURE__*/React.createElement("option", {
196
+ value: ""
197
+ }, LocaleUtils.tr("mapexport.usersize")), _this.props.pageSizes.map(function (entry, idx) {
198
+ return /*#__PURE__*/React.createElement("option", {
199
+ key: "size_" + idx,
200
+ value: idx
201
+ }, entry.name);
202
+ })))) : null, scaleChooser && _this.state.pageSize !== null ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("mapexport.scale")), /*#__PURE__*/React.createElement("td", null, scaleChooser)) : null, _this.props.dpis && _this.state.selectedFormat !== "application/dxf" ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("mapexport.resolution")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("select", {
203
+ onChange: _this.changeResolution,
204
+ value: _this.state.dpi
205
+ }, _this.props.dpis.map(function (dpi) {
206
+ return /*#__PURE__*/React.createElement("option", {
207
+ key: dpi + "dpi",
208
+ value: dpi
209
+ }, dpi + " dpi");
210
+ })))) : null, ((formatConfiguration === null || formatConfiguration === void 0 ? void 0 : formatConfiguration.projections) || []).length > 1 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, LocaleUtils.tr("mapexport.projection")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("select", {
211
+ onChange: function onChange(ev) {
212
+ return _this.setState({
213
+ exportProjection: ev.target.value
214
+ });
215
+ },
216
+ value: _this.state.exportProjection
217
+ }, formatConfiguration.projections.map(function (proj) {
218
+ return /*#__PURE__*/React.createElement("option", {
219
+ key: proj,
220
+ value: proj
221
+ }, proj);
222
+ })))) : null)), /*#__PURE__*/React.createElement("div", {
223
+ className: "button-bar"
224
+ }, /*#__PURE__*/React.createElement("button", {
225
+ className: "button",
226
+ disabled: _this.state.exporting || isEmpty(_this.state.extents),
227
+ type: "submit"
228
+ }, _this.state.exporting ? /*#__PURE__*/React.createElement("span", {
229
+ className: "mapexport-wait"
230
+ }, /*#__PURE__*/React.createElement(Spinner, null), " ", LocaleUtils.tr("mapexport.wait")) : LocaleUtils.tr("mapexport.submit")))));
231
+ });
232
+ _defineProperty(_this, "renderPrintSelection", function () {
233
+ if (_this.state.pageSize !== null) {
234
+ var pageSize = _this.props.pageSizes[_this.state.pageSize];
235
+ var frame = {
236
+ width: pageSize.width,
237
+ height: pageSize.height
238
+ };
239
+ return /*#__PURE__*/React.createElement(PrintSelection, {
240
+ allowRotation: false,
241
+ allowScaling: _this.props.allowedScales !== false,
242
+ center: _this.props.map.center,
243
+ fixedFrame: frame,
244
+ geometryChanged: _this.geometryChanged,
245
+ key: "PrintSelection",
246
+ scale: _this.state.scale
247
+ });
248
+ } else {
249
+ return /*#__PURE__*/React.createElement(PrintSelection, {
250
+ allowRotation: false,
251
+ geometryChanged: _this.geometryChanged,
252
+ key: "PrintSelection"
253
+ });
254
+ }
255
+ });
256
+ _defineProperty(_this, "onShow", function () {
257
+ var _this$props$formatCon4, _formatConfigurations3, _formatConfigurations4;
258
+ var scale = Math.round(MapUtils.computeForZoom(_this.props.map.scales, _this.props.map.zoom) * _this.props.defaultScaleFactor);
259
+ if (!isEmpty(_this.props.allowedScales)) {
260
+ var closestVal = Math.abs(scale - _this.props.allowedScales[0]);
261
+ var closestIdx = 0;
262
+ for (var i = 1; i < _this.props.allowedScales.length; ++i) {
263
+ var currVal = Math.abs(scale - _this.props.allowedScales[i]);
264
+ if (currVal < closestVal) {
265
+ closestVal = currVal;
266
+ closestIdx = i;
267
+ }
268
+ }
269
+ scale = _this.props.allowedScales[closestIdx];
270
+ }
271
+ var availableFormats = _toConsumableArray(_this.props.theme.availableFormats);
272
+ (_this.props.forceAvailableFormats || []).forEach(function (format) {
273
+ if (!availableFormats.includes(format)) {
274
+ availableFormats.push(format);
275
+ }
276
+ });
277
+ if (!isEmpty(_this.props.allowedFormats)) {
278
+ availableFormats = _this.props.allowedFormats.filter(function (fmt) {
279
+ return availableFormats.includes(fmt);
280
+ });
281
+ }
282
+ var selectedFormat = _this.props.defaultFormat && availableFormats.includes(_this.props.defaultFormat) ? _this.props.defaultFormat : availableFormats[0];
283
+ var formatConfigurations = ((_this$props$formatCon4 = _this.props.formatConfiguration) === null || _this$props$formatCon4 === void 0 ? void 0 : _this$props$formatCon4[selectedFormat.split(";")[0]]) || [];
284
+ _this.setState({
285
+ scale: scale,
286
+ availableFormats: availableFormats,
287
+ selectedFormat: selectedFormat,
288
+ selectedFormatConfiguration: (_formatConfigurations3 = formatConfigurations[0]) === null || _formatConfigurations3 === void 0 ? void 0 : _formatConfigurations3.name,
289
+ exportProjection: _this.getExportProjection((_formatConfigurations4 = formatConfigurations[0]) === null || _formatConfigurations4 === void 0 ? void 0 : _formatConfigurations4.projections)
290
+ });
291
+ _this.props.setSnappingConfig(false, false);
292
+ });
293
+ _defineProperty(_this, "onHide", function () {
294
+ _this.setState({
295
+ extents: [],
296
+ width: 0,
297
+ height: 0,
298
+ scale: null,
299
+ pageSize: null
300
+ });
301
+ });
302
+ _defineProperty(_this, "geometryChanged", function (center, extents, rotation, scale) {
303
+ _this.setState(function (state) {
304
+ return {
305
+ extents: extents,
306
+ scale: scale !== null && scale !== void 0 ? scale : state.scale
307
+ };
308
+ });
309
+ });
310
+ _defineProperty(_this, "export", function (ev) {
311
+ var _this$props$formatCon5, _this$state$extents$a;
312
+ ev.preventDefault();
313
+ _this.setState({
314
+ exporting: true
315
+ });
316
+ var format = _this.state.selectedFormat.split(";")[0];
317
+ var formatConfiguration = (((_this$props$formatCon5 = _this.props.formatConfiguration) === null || _this$props$formatCon5 === void 0 ? void 0 : _this$props$formatCon5[format]) || []).find(function (entry) {
318
+ return entry.name === _this.state.selectedFormatConfiguration;
319
+ });
320
+ var version = _this.props.theme.version;
321
+ var crs = _this.state.exportProjection;
322
+ var extent = CoordinatesUtils.reprojectBbox((_this$state$extents$a = _this.state.extents.at(0)) !== null && _this$state$extents$a !== void 0 ? _this$state$extents$a : [0, 0, 0, 0], _this.props.map.projection, crs);
323
+ var formattedExtent = CoordinatesUtils.getAxisOrder(crs).substring(0, 2) === 'ne' && version === '1.3.0' ? extent[1] + "," + extent[0] + "," + extent[3] + "," + extent[2] : extent.join(',');
324
+ var getPixelFromCoordinate = MapUtils.getHook(MapUtils.GET_PIXEL_FROM_COORDINATES_HOOK);
325
+ var p1 = getPixelFromCoordinate(extent.slice(0, 2));
326
+ var p2 = getPixelFromCoordinate(extent.slice(2, 4));
327
+ var width = Math.round(Math.abs(p1[0] - p2[0]) * _this.state.dpi / 96);
328
+ var height = Math.round(Math.abs(p1[1] - p2[1]) * _this.state.dpi / 96);
329
+ var ext = format.split("/").pop();
330
+ var timestamp = dayjs(new Date()).format("YYYYMMDD_HHmmss");
331
+ var fileName = _this.props.fileNameTemplate.replace("{username}", ConfigUtils.getConfigProp("username", null, "")).replace("{tenant}", ConfigUtils.getConfigProp("tenant", null, "")).replace("{theme}", _this.props.theme.id).replace("{themeTitle}", _this.props.theme.title || "").replace("{timestamp}", timestamp) + "." + ext;
332
+ var params = {};
333
+
334
+ // Base request params
335
+ params.SERVICE = "WMS";
336
+ params.VERSION = version;
337
+ params.REQUEST = "GetMap";
338
+ params.FORMAT = _this.state.selectedFormat;
339
+ params.DPI = _this.state.dpi;
340
+ params.TRANSPARENT = true;
341
+ params.TILED = false;
342
+ params.CRS = crs;
343
+ params.BBOX = formattedExtent;
344
+ params.WIDTH = width;
345
+ params.HEIGHT = height;
346
+ params.filename = fileName;
347
+
348
+ // Dimension values
349
+ _this.props.layers.forEach(function (layer) {
350
+ if (layer.role === LayerRole.THEME) {
351
+ Object.entries(layer.dimensionValues || {}).forEach(function (_ref) {
352
+ var _ref2 = _slicedToArray(_ref, 2),
353
+ key = _ref2[0],
354
+ value = _ref2[1];
355
+ if (value !== undefined) {
356
+ params[key] = value;
357
+ }
358
+ });
359
+ }
360
+ });
361
+
362
+ // Add parameters from custom format configuration
363
+ if (formatConfiguration) {
364
+ var _formatConfiguration$;
365
+ var keyCaseMap = Object.keys(params).reduce(function (res, key) {
366
+ return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, key.toLowerCase(), key));
367
+ }, {});
368
+ (formatConfiguration.extraQuery || "").split(/[?&]/).filter(Boolean).forEach(function (entry) {
369
+ var _entry$split = entry.split("="),
370
+ _entry$split2 = _slicedToArray(_entry$split, 2),
371
+ key = _entry$split2[0],
372
+ value = _entry$split2[1];
373
+ var caseKey = keyCaseMap[key.toLowerCase()] || key;
374
+ params[caseKey] = value !== null && value !== void 0 ? value : "";
375
+ });
376
+ params.FORMAT_OPTIONS = (_formatConfiguration$ = formatConfiguration.formatOptions) !== null && _formatConfiguration$ !== void 0 ? _formatConfiguration$ : "";
377
+ if (formatConfiguration.baseLayer) {
378
+ var layers = params[keyCaseMap.layers].split(",");
379
+ if (!layers.includes(formatConfiguration.baseLayer)) {
380
+ params[keyCaseMap.layers] = [formatConfiguration.baseLayer].concat(_toConsumableArray(layers));
381
+ }
382
+ }
383
+ }
384
+ if (_this.state.selectedFormat === "application/dxf") {
385
+ _this.dxfExport(params, fileName, formatConfiguration);
386
+ } else {
387
+ _this.genericExport(params, fileName, formatConfiguration);
388
+ }
389
+ });
390
+ _defineProperty(_this, "genericExport", function (params, fileName, formatConfiguration) {
391
+ var _formatConfiguration$2;
392
+ // Layer params
393
+ var exportExternalLayers = _this.props.exportExternalLayers && ConfigUtils.getConfigProp("qgisServerVersion", null, 3) >= 3;
394
+ var exportParams = LayerUtils.collectPrintParams(_this.props.layers, _this.props.theme, _this.state.scale, _this.state.exportProjection, exportExternalLayers, !!(formatConfiguration !== null && formatConfiguration !== void 0 && formatConfiguration.baseLayer));
395
+ Object.assign(params, exportParams);
396
+
397
+ // Highlight params
398
+ var highlightParams = VectorLayerUtils.createPrintHighlighParams(_this.props.layers, _this.state.exportProjection, _this.state.scale, _this.state.dpi);
399
+ params.HIGHLIGHT_GEOM = highlightParams.geoms.join(";");
400
+ params.HIGHLIGHT_SYMBOL = highlightParams.styles.join(";");
401
+ params.HIGHLIGHT_LABELSTRING = highlightParams.labels.join(";");
402
+ params.HIGHLIGHT_LABELCOLOR = highlightParams.labelFillColors.join(";");
403
+ params.HIGHLIGHT_LABELBUFFERCOLOR = highlightParams.labelOutlineColors.join(";");
404
+ params.HIGHLIGHT_LABELBUFFERSIZE = highlightParams.labelOutlineSizes.join(";");
405
+ params.HIGHLIGHT_LABELSIZE = highlightParams.labelSizes.join(";");
406
+ params.HIGHLIGHT_LABEL_DISTANCE = highlightParams.labelDist.join(";");
407
+ params.HIGHLIGHT_LABEL_ROTATION = highlightParams.labelRotations.join(";");
408
+
409
+ // Watermark params
410
+ Object.keys(_this.props.theme.watermark || {}).forEach(function (key) {
411
+ params["WATERMARK_" + key.toUpperCase()] = _this.props.theme.watermark[key];
412
+ });
413
+ var data = Object.entries(params).map(function (pair) {
414
+ return pair.map(function (entry) {
415
+ return encodeURIComponent(entry).replace(/%20/g, '+');
416
+ }).join("=");
417
+ }).join("&");
418
+ var config = {
419
+ headers: {
420
+ 'Content-Type': 'application/x-www-form-urlencoded'
421
+ },
422
+ responseType: "arraybuffer"
423
+ };
424
+ axios.post((_formatConfiguration$2 = formatConfiguration === null || formatConfiguration === void 0 ? void 0 : formatConfiguration.serviceUrl) !== null && _formatConfiguration$2 !== void 0 ? _formatConfiguration$2 : _this.props.theme.url, data, config).then(function (response) {
425
+ _this.setState({
426
+ exporting: false
427
+ });
428
+ var contentType = response.headers["content-type"];
429
+ FileSaver.saveAs(new Blob([response.data], {
430
+ type: contentType
431
+ }), fileName);
432
+ })["catch"](function (e) {
433
+ _this.setState({
434
+ exporting: false
435
+ });
436
+ if (e.response) {
437
+ /* eslint-disable-next-line */
438
+ console.log(new TextDecoder().decode(e.response.data));
439
+ }
440
+ /* eslint-disable-next-line */
441
+ alert('Export failed');
442
+ });
443
+ });
444
+ _defineProperty(_this, "dxfExport", function (baseParams, fileName, formatConfiguration) {
445
+ var promises = _this.props.layers.filter(function (layer) {
446
+ var _layer$mapFormats;
447
+ return layer.type === 'wms' && layer.role > LayerRole.BACKGROUND && ((_layer$mapFormats = layer.mapFormats) === null || _layer$mapFormats === void 0 ? void 0 : _layer$mapFormats.includes("application/dxf"));
448
+ }).reverse().map(function (layer) {
449
+ var _layer$params$FILTER, _layer$params$FILTER_;
450
+ var params = _objectSpread(_objectSpread({}, baseParams), {}, {
451
+ LAYERS: layer.params.LAYERS,
452
+ OPACITIES: layer.params.OPACITIES,
453
+ STYLES: layer.params.STYLES,
454
+ FILTER: (_layer$params$FILTER = layer.params.FILTER) !== null && _layer$params$FILTER !== void 0 ? _layer$params$FILTER : '',
455
+ FILTER_GEOM: (_layer$params$FILTER_ = layer.params.FILTER_GEOM) !== null && _layer$params$FILTER_ !== void 0 ? _layer$params$FILTER_ : ''
456
+ });
457
+ var data = Object.entries(params).map(function (pair) {
458
+ return pair.map(function (entry) {
459
+ return encodeURIComponent(entry).replace(/%20/g, '+');
460
+ }).join("=");
461
+ }).join("&");
462
+ var config = {
463
+ headers: {
464
+ 'Content-Type': 'application/x-www-form-urlencoded'
465
+ },
466
+ responseType: "arraybuffer"
467
+ };
468
+ return new Promise(function (resolve, reject) {
469
+ var _formatConfiguration$3;
470
+ axios.post((_formatConfiguration$3 = formatConfiguration === null || formatConfiguration === void 0 ? void 0 : formatConfiguration.serviceUrl) !== null && _formatConfiguration$3 !== void 0 ? _formatConfiguration$3 : layer.url, data, config).then(function (response) {
471
+ resolve(response);
472
+ })["catch"](function (e) {
473
+ /* eslint-disable-next-line */
474
+ console.warn(e);
475
+ resolve(null);
476
+ });
477
+ });
478
+ });
479
+ Promise.all(promises).then(function (responses) {
480
+ var decoder = new TextDecoder("iso-8859-1");
481
+ var dxfDocuments = responses.filter(function (response) {
482
+ return response.headers['content-type'] === "application/dxf";
483
+ }).map(function (response) {
484
+ return explodeDxf(decoder.decode(response.data));
485
+ });
486
+ var dxfDocument = mergeDxf(dxfDocuments);
487
+ var result = implodeDxf(dxfDocument);
488
+ var encoder = new TextEncoder("iso-8859-1");
489
+ FileSaver.saveAs(new Blob([encoder.encode(result)], {
490
+ type: "application/dxf"
491
+ }), fileName);
492
+ /*
493
+ responses.forEach((response, idx) => {
494
+ FileSaver.saveAs(new Blob([response.data], {type: "application/dxf"}), "orig_" + idx + "_" + fileName);
495
+ });
496
+ */
497
+ _this.setState({
498
+ exporting: false
499
+ });
500
+ });
501
+ });
502
+ _this.form = null;
503
+ _this.state.dpi = (props.dpis || [])[0] || 96;
504
+ return _this;
505
+ }
506
+ _inherits(MapExport, _React$Component);
507
+ return _createClass(MapExport, [{
508
+ key: "componentDidUpdate",
509
+ value: function componentDidUpdate(prevProps, prevState) {
510
+ if (this.state.pageSize === null && prevState.pageSize !== null) {
511
+ this.setState({
512
+ extents: []
513
+ });
514
+ }
515
+ }
516
+ }, {
517
+ key: "render",
518
+ value: function render() {
519
+ var _this2 = this;
520
+ var minMaxTooltip = this.state.minimized ? LocaleUtils.tr("print.maximize") : LocaleUtils.tr("print.minimize");
521
+ var extraTitlebarContent = /*#__PURE__*/React.createElement(Icon, {
522
+ className: "mapexport-minimize-maximize",
523
+ icon: this.state.minimized ? 'chevron-down' : 'chevron-up',
524
+ onClick: function onClick() {
525
+ return _this2.setState(function (state) {
526
+ return {
527
+ minimized: !state.minimized
528
+ };
529
+ });
530
+ },
531
+ title: minMaxTooltip
532
+ });
533
+ return /*#__PURE__*/React.createElement(SideBar, {
534
+ extraClasses: "MapExport",
535
+ extraTitlebarContent: extraTitlebarContent,
536
+ icon: "rasterexport",
537
+ id: "MapExport",
538
+ key: "MapExport",
539
+ onHide: this.onHide,
540
+ onShow: this.onShow,
541
+ side: this.props.side,
542
+ title: LocaleUtils.tr("appmenu.items.MapExport"),
543
+ width: "20em"
544
+ }, function () {
545
+ return {
546
+ body: _this2.state.minimized ? null : _this2.renderBody(),
547
+ extra: [_this2.renderPrintSelection()]
548
+ };
549
+ });
550
+ }
551
+ }]);
552
+ }(React.Component);
553
+ _defineProperty(MapExport, "propTypes", {
554
+ /** Whitelist of allowed export format mimetypes. If empty, supported formats are listed. */
555
+ allowedFormats: PropTypes.arrayOf(PropTypes.string),
556
+ /** List of scales at which to export the map. If empty, scale can be freely specified. If `false`, the map can only be exported at the current scale. */
557
+ allowedScales: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.bool]),
558
+ /** Default export format mimetype. If empty, first available format is used. */
559
+ defaultFormat: PropTypes.string,
560
+ /** The factor to apply to the map scale to determine the initial export map scale (if `allowedScales` is not `false`). */
561
+ defaultScaleFactor: PropTypes.number,
562
+ /** List of dpis at which to export the map. If empty, the default server dpi is used. */
563
+ dpis: PropTypes.arrayOf(PropTypes.number),
564
+ /** Whether to include external layers in the image. Requires QGIS Server 3.x! */
565
+ exportExternalLayers: PropTypes.bool,
566
+ /** Template for the name of the generated files when downloading. Can contain the placeholders `{username}`, `{tenant}`, `{theme}`, `{themeTitle}`, `{timestamp}`. */
567
+ fileNameTemplate: PropTypes.string,
568
+ /** Formats to force as available even if the map capabilities report otherwise. Useful if a serviceUrl is defined in a format configuration. */
569
+ forceAvailableFormats: PropTypes.array,
570
+ /** Custom export configuration per format.
571
+ * If more than one configuration per format is provided, a selection combo will be displayed.
572
+ * `labelMsgId` is a translation string message id for the combo label. If not defined, `name` will be displayed.
573
+ * `extraQuery` will be appended to the query string (replacing any existing parameters).
574
+ * `formatOptions` will be passed as FORMAT_OPTIONS.
575
+ * `baseLayer` will be appended to the LAYERS instead of the background layer.
576
+ * `projections` is a list of export projections. If empty, the map projection is automatically used.
577
+ * `serviceUrl` is the address of a custom service to use instead of the layer OWS service url. */
578
+ formatConfiguration: PropTypes.shape({
579
+ format: PropTypes.arrayOf(PropTypes.shape({
580
+ name: PropTypes.string,
581
+ labelMsgId: PropTypes.string,
582
+ extraQuery: PropTypes.string,
583
+ formatOptions: PropTypes.string,
584
+ baseLayer: PropTypes.string,
585
+ projections: PropTypes.array,
586
+ serviceUrl: PropTypes.string
587
+ }))
588
+ }),
589
+ layers: PropTypes.array,
590
+ map: PropTypes.object,
591
+ /** List of image sizes to offer, in addition to the free-hand selection. The width and height are in millimeters. */
592
+ pageSizes: PropTypes.arrayOf(PropTypes.shape({
593
+ name: PropTypes.string,
594
+ width: PropTypes.number,
595
+ height: PropTypes.number
596
+ })),
597
+ setIdentifyEnabled: PropTypes.func,
598
+ setSnappingConfig: PropTypes.func,
599
+ /** The side of the application on which to display the sidebar. */
600
+ side: PropTypes.string,
601
+ theme: PropTypes.object
602
+ });
603
+ _defineProperty(MapExport, "defaultProps", {
604
+ defaultScaleFactor: 1,
605
+ exportExternalLayers: true,
606
+ fileNameTemplate: '{theme}_{timestamp}',
607
+ side: 'right',
608
+ pageSizes: []
609
+ });
610
+ var selector = function selector(state) {
611
+ return {
612
+ theme: state.theme.current,
613
+ map: state.map,
614
+ layers: state.layers.flat
615
+ };
616
+ };
617
+ export default connect(selector, {
618
+ setSnappingConfig: setSnappingConfig
619
+ })(MapExport);