UNPKG

qwc2-lts

Version:
602 lines (598 loc) 30.8 kB
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 _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 _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 _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 _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 _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 _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 _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); } /** * Copyright 2017-2024 Sourcepole AG * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ import React from 'react'; import { connect } from 'react-redux'; import axios from 'axios'; import dayjs from 'dayjs'; import FileSaver from 'file-saver'; import formDataEntries from 'formdata-json'; 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 LayerUtils from '../utils/LayerUtils'; import LocaleUtils from '../utils/LocaleUtils'; import MapUtils from '../utils/MapUtils'; import MiscUtils from '../utils/MiscUtils'; import VectorLayerUtils from '../utils/VectorLayerUtils'; import './style/MapExport.css'; /** * Allows exporting a selected portion of the map to a variety of formats. */ 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: '', scale: null, pageSize: null, dpi: 96 }); _defineProperty(_this, "changeFormat", function (ev) { var _this$props$formatCon; var selectedFormat = ev.target.value; var selectedFormatConfiguration = ((((_this$props$formatCon = _this.props.formatConfiguration) === null || _this$props$formatCon === void 0 ? void 0 : _this$props$formatCon[selectedFormat]) || [])[0] || {}).name; _this.setState({ selectedFormat: selectedFormat, selectedFormatConfiguration: selectedFormatConfiguration }); }); _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$formatCon2, _this$state$extents$a; 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 formatConfiguration = ((_this$props$formatCon2 = _this.props.formatConfiguration) === null || _this$props$formatCon2 === void 0 ? void 0 : _this$props$formatCon2[_this.state.selectedFormat.split(";")[0]]) || []; 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 }); } var action = _this.props.theme.url; var exportExternalLayers = _this.state.selectedFormat !== "application/dxf" && _this.props.exportExternalLayers && ConfigUtils.getConfigProp("qgisServerVersion", null, 3) >= 3; var selectedFormatConfiguration = formatConfiguration.find(function (entry) { return entry.name === _this.state.selectedFormatConfiguration; }) || {}; var exportParams = LayerUtils.collectPrintParams(_this.props.layers, _this.props.theme, _this.state.scale, _this.props.map.projection, exportExternalLayers, !!selectedFormatConfiguration.baseLayer); var highlightParams = VectorLayerUtils.createPrintHighlighParams(_this.props.layers, _this.props.map.projection, _this.state.scale, _this.state.dpi); var version = _this.props.theme.version; var crs = _this.props.map.projection; var extent = (_this$state$extents$a = _this.state.extents.at(0)) !== null && _this$state$extents$a !== void 0 ? _this$state$extents$a : [0, 0, 0, 0]; 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.abs(p1[0] - p2[0]) * _this.state.dpi / 96; var height = Math.abs(p1[1] - p2[1]) * _this.state.dpi / 96; return /*#__PURE__*/React.createElement("div", { className: "mapexport-body" }, /*#__PURE__*/React.createElement("form", { action: 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", { name: "FORMAT", 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); })))), formatConfiguration.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: function onChange(ev) { return _this.setState({ selectedFormatConfiguration: ev.target.value }); }, value: _this.state.selectedFormatConfiguration }, formatConfiguration.map(function (config) { return /*#__PURE__*/React.createElement("option", { key: config.name, value: config.name }, 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", { name: "DPI", 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)), /*#__PURE__*/React.createElement("input", { name: "SERVICE", readOnly: true, type: "hidden", value: "WMS" }), /*#__PURE__*/React.createElement("input", { name: "VERSION", readOnly: true, type: "hidden", value: _this.props.theme.version }), /*#__PURE__*/React.createElement("input", { name: "REQUEST", readOnly: true, type: "hidden", value: "GetMap" }), Object.entries(exportParams).map(function (_ref) { var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1]; return /*#__PURE__*/React.createElement("input", { key: key, name: key, type: "hidden", value: value }); }), /*#__PURE__*/React.createElement("input", { name: "TRANSPARENT", readOnly: true, type: "hidden", value: "true" }), /*#__PURE__*/React.createElement("input", { name: "TILED", readOnly: true, type: "hidden", value: "false" }), /*#__PURE__*/React.createElement("input", { name: "CRS", readOnly: true, type: "hidden", value: _this.props.map.projection }), /*#__PURE__*/React.createElement("input", { name: "BBOX", readOnly: true, type: "hidden", value: formattedExtent }), /*#__PURE__*/React.createElement("input", { name: "WIDTH", readOnly: true, type: "hidden", value: Math.round(width) }), /*#__PURE__*/React.createElement("input", { name: "HEIGHT", readOnly: true, type: "hidden", value: Math.round(height) }), Object.keys(_this.props.theme.watermark || {}).map(function (key) { return /*#__PURE__*/React.createElement("input", { key: key, name: "WATERMARK_" + key.toUpperCase(), readOnly: true, type: "hidden", value: _this.props.theme.watermark[key] }); }), /*#__PURE__*/React.createElement("input", { name: "HIGHLIGHT_GEOM", readOnly: true, type: "hidden", value: highlightParams.geoms.join(";") }), /*#__PURE__*/React.createElement("input", { name: "HIGHLIGHT_SYMBOL", readOnly: true, type: "hidden", value: highlightParams.styles.join(";") }), /*#__PURE__*/React.createElement("input", { name: "HIGHLIGHT_LABELSTRING", readOnly: true, type: "hidden", value: highlightParams.labels.join(";") }), /*#__PURE__*/React.createElement("input", { name: "HIGHLIGHT_LABELCOLOR", readOnly: true, type: "hidden", value: highlightParams.labelFillColors.join(";") }), /*#__PURE__*/React.createElement("input", { name: "HIGHLIGHT_LABELBUFFERCOLOR", readOnly: true, type: "hidden", value: highlightParams.labelOutlineColors.join(";") }), /*#__PURE__*/React.createElement("input", { name: "HIGHLIGHT_LABELBUFFERSIZE", readOnly: true, type: "hidden", value: highlightParams.labelOutlineSizes.join(";") }), /*#__PURE__*/React.createElement("input", { name: "HIGHLIGHT_LABELSIZE", readOnly: true, type: "hidden", value: highlightParams.labelSizes.join(";") }), /*#__PURE__*/React.createElement("input", { name: "HIGHLIGHT_LABEL_DISTANCE", readOnly: true, type: "hidden", value: highlightParams.labelDist.join(";") }), /*#__PURE__*/React.createElement("input", { name: "HIGHLIGHT_LABEL_ROTATION", readOnly: true, type: "hidden", value: highlightParams.labelRotations.join(";") }), /*#__PURE__*/React.createElement("input", { name: "csrf_token", type: "hidden", value: MiscUtils.getCsrfToken() }), /*#__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$formatCon3; 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 = availableFormats.filter(function (fmt) { return _this.props.allowedFormats.includes(fmt); }); } var selectedFormat = _this.props.defaultFormat && availableFormats.includes(_this.props.defaultFormat) ? _this.props.defaultFormat : availableFormats[0]; var selectedFormatConfiguration = ((((_this$props$formatCon3 = _this.props.formatConfiguration) === null || _this$props$formatCon3 === void 0 ? void 0 : _this$props$formatCon3[selectedFormat]) || [])[0] || {}).name; _this.setState({ scale: scale, availableFormats: availableFormats, selectedFormat: selectedFormat, selectedFormatConfiguration: selectedFormatConfiguration }); _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$formatCon4, _formatConfiguration$2; ev.preventDefault(); _this.setState({ exporting: true }); var params = formDataEntries(new FormData(_this.form)); // Add dimension values _this.props.layers.forEach(function (layer) { if (layer.role === LayerRole.THEME) { Object.entries(layer.dimensionValues || {}).forEach(function (_ref3) { var _ref4 = _slicedToArray(_ref3, 2), key = _ref4[0], value = _ref4[1]; if (value !== undefined) { params[key] = value; } }); } }); // Add parameters from custom format configuration var format = _this.state.selectedFormat.split(";")[0]; var formatConfiguration = (((_this$props$formatCon4 = _this.props.formatConfiguration) === null || _this$props$formatCon4 === void 0 ? void 0 : _this$props$formatCon4[format]) || []).find(function (entry) { return entry.name === _this.state.selectedFormatConfiguration; }); var ext = format.split("/").pop(); var timestamp = dayjs(new Date()).format("YYYYMMDD_HHmmss"); var fileName = _this.props.fileNameTemplate.replace("{theme}", _this.props.theme.id).replace("{timestamp}", timestamp) + "." + ext; params.filename = fileName; 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)); } } } 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'); }); }); _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. */ 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. * If more than one configuration per format is provided, a selection combo will be displayed. * `extraQuery` will be appended to the query string (replacing any existing parameters). * `formatOptions` will be passed as FORMAT_OPTIONS. * `baseLayer` will be appended to the LAYERS instead of the background layer. * `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, extraQuery: PropTypes.string, formatOptions: PropTypes.string, baseLayer: PropTypes.string, 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);