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.
- package/actions/display.js +30 -1
- package/actions/editing.js +22 -1
- package/actions/layerinfo.js +13 -1
- package/actions/layers.js +213 -3
- package/actions/localConfig.js +58 -1
- package/actions/locale.js +21 -1
- package/actions/locate.js +26 -1
- package/actions/logging.js +10 -1
- package/actions/map.js +105 -2
- package/actions/measurement.js +12 -1
- package/actions/processNotifications.js +37 -1
- package/actions/redlining.js +18 -1
- package/actions/redliningPick.js +12 -1
- package/actions/search.js +12 -1
- package/actions/serviceinfo.js +12 -1
- package/actions/task.js +55 -3
- package/actions/theme.js +339 -19
- package/actions/windows.js +164 -5
- package/components/AppMenu.js +435 -3
- package/components/AttributeForm.js +928 -32
- package/components/AttributeTableWidget.js +1105 -13
- package/components/AutoEditForm.js +189 -3
- package/components/CoordinateDisplayer.js +78 -2
- package/components/EditComboField.js +190 -6
- package/components/EditUploadField.js +315 -3
- package/components/ExportSelection.js +203 -2
- package/components/FullscreenSwitcher.js +90 -3
- package/components/Icon.js +81 -2
- package/components/IdentifyViewer.js +1161 -6
- package/components/ImportLayer.js +718 -20
- package/components/LayerInfoWindow.js +145 -2
- package/components/LinkFeatureForm.js +246 -5
- package/components/MapButton.js +88 -2
- package/components/MapSelection.js +287 -8
- package/components/MessageBar.js +68 -2
- package/components/NumericInputWindow.js +359 -2
- package/components/PickFeature.js +266 -2
- package/components/PluginsContainer.js +227 -8
- package/components/PrintSelection.js +620 -49
- package/components/ProcessNotifications.js +104 -2
- package/components/QtDesignerForm.js +1137 -18
- package/components/ResizeableWindow.js +591 -8
- package/components/SearchBox.js +1307 -20
- package/components/ServiceInfoWindow.js +107 -2
- package/components/SideBar.js +204 -4
- package/components/StandardApp.js +381 -20
- package/components/Swipeable.js +15 -1
- package/components/TaskBar.js +85 -2
- package/components/ThemeLayersListWindow.js +216 -4
- package/components/ThemeList.js +381 -7
- package/components/Toolbar.js +106 -2
- package/components/WindowManager.js +178 -2
- package/components/map/OlLayer.js +257 -6
- package/components/map/OlMap.js +405 -5
- package/components/map/layers/BingLayer.js +31 -2
- package/components/map/layers/GoogleLayer.js +222 -19
- package/components/map/layers/GraticuleLayer.js +21 -1
- package/components/map/layers/ImageLayer.js +15 -1
- package/components/map/layers/MVTLayer.js +52 -2
- package/components/map/layers/OSMLayer.js +24 -2
- package/components/map/layers/OverlayLayer.js +55 -3
- package/components/map/layers/VectorLayer.js +173 -8
- package/components/map/layers/WFSLayer.js +220 -6
- package/components/map/layers/WMSLayer.js +180 -6
- package/components/map/layers/WMTSLayer.js +67 -3
- package/components/map/layers/XYZLayer.js +24 -2
- package/components/map/layers/index.js +28 -1
- package/components/map3d/EditDataset3D.js +190 -3
- package/components/map3d/HeightProfile3D.js +402 -3
- package/components/map3d/ImportObjects3D.js +162 -2
- package/components/map3d/Map3D.js +1304 -38
- package/components/map3d/MapControls3D.js +392 -7
- package/components/map3d/SearchField3D.js +183 -11
- package/components/map3d/View3DSwitcher.js +98 -2
- package/components/map3d/drawtool/CreateTool3D.js +174 -4
- package/components/map3d/drawtool/EditTool3D.js +590 -6
- package/components/map3d/drawtool/NumericInput3D.js +336 -4
- package/components/map3d/layers/GeoTIFFLayer3D.js +15 -1
- package/components/map3d/layers/VectorLayer3D.js +53 -2
- package/components/map3d/layers/WFSLayer3D.js +109 -3
- package/components/map3d/layers/WMSLayer3D.js +70 -2
- package/components/map3d/layers/WMTSLayer3D.js +27 -3
- package/components/map3d/layers/index.js +14 -1
- package/components/map3d/utils/FirstPersonControls3D.js +423 -16
- package/components/map3d/utils/MiscUtils3D.js +221 -13
- package/components/map3d/utils/OrbitControls3D.js +176 -5
- package/components/map3d/utils/Tiles3DStyle.js +238 -9
- package/components/share/ShareLink.js +54 -2
- package/components/share/ShareQRCode.js +62 -2
- package/components/share/ShareSocials.js +125 -3
- package/components/timeline/FixedTimeline.js +236 -5
- package/components/timeline/InfiniteTimeline.js +347 -8
- package/components/timeline/TimelineFeaturesSlider.js +439 -5
- package/components/widgets/AccordeonWidget.js +96 -2
- package/components/widgets/ButtonBar.js +124 -2
- package/components/widgets/ColorButton.js +201 -3
- package/components/widgets/ComboBox.js +166 -2
- package/components/widgets/CopyButton.js +110 -2
- package/components/widgets/DateTimeInput.js +100 -3
- package/components/widgets/EditableSelect.js +230 -3
- package/components/widgets/FileSelector.js +128 -4
- package/components/widgets/Input.js +124 -2
- package/components/widgets/InputContainer.js +96 -2
- package/components/widgets/LayerCatalogWidget.js +219 -3
- package/components/widgets/MenuButton.js +157 -1
- package/components/widgets/ModalDialog.js +64 -2
- package/components/widgets/NavBar.js +119 -2
- package/components/widgets/NumberInput.js +226 -4
- package/components/widgets/PopupMenu.js +72 -1
- package/components/widgets/Primitives.js +6 -1
- package/components/widgets/ReCaptchaWidget.js +55 -1
- package/components/widgets/SearchWidget.js +255 -2
- package/components/widgets/Spinner.js +44 -2
- package/components/widgets/SuggestionInput.js +77 -2
- package/components/widgets/TextInput.js +308 -2
- package/components/widgets/ToggleSwitch.js +85 -2
- package/components/widgets/VectorLayerPicker.js +85 -3
- package/libs/openlayers.js +225 -5
- package/package.json +1 -1
- package/plugins/API.js +358 -15
- package/plugins/AttributeTable.js +109 -3
- package/plugins/Authentication.js +130 -5
- package/plugins/BackgroundSwitcher.js +218 -4
- package/plugins/Bookmark.js +289 -3
- package/plugins/BottomBar.js +298 -4
- package/plugins/CookiePopup.js +67 -3
- package/plugins/Cyclomedia.js +442 -5
- package/plugins/Editing.js +497 -9
- package/plugins/FeatureForm.js +366 -4
- package/plugins/FeatureSearch.js +458 -3
- package/plugins/GeometryDigitizer.js +664 -7
- package/plugins/HeightProfile.js +763 -15
- package/plugins/Help.js +102 -3
- package/plugins/HomeButton.js +80 -3
- package/plugins/Identify.js +543 -5
- package/plugins/LayerCatalog.js +215 -4
- package/plugins/LayerTree.js +1194 -6
- package/plugins/LocateButton.js +94 -3
- package/plugins/Map.js +320 -16
- package/plugins/MapCompare.js +94 -3
- package/plugins/MapCopyright.js +127 -5
- package/plugins/MapExport.js +613 -20
- package/plugins/MapFilter.js +868 -12
- package/plugins/MapInfoTooltip.js +277 -3
- package/plugins/MapLegend.js +253 -4
- package/plugins/MapTip.js +290 -4
- package/plugins/Measure.js +220 -4
- package/plugins/NewsPopup.js +137 -3
- package/plugins/OverviewMap.js +167 -7
- package/plugins/Panoramax.js +340 -2
- package/plugins/Portal.js +199 -4
- package/plugins/Print.js +1231 -15
- package/plugins/Redlining.js +750 -6
- package/plugins/Reports.js +332 -3
- package/plugins/Routing.js +1278 -15
- package/plugins/ScratchDrawing.js +173 -5
- package/plugins/Settings.js +241 -4
- package/plugins/Share.js +198 -3
- package/plugins/StartupMarker.js +84 -4
- package/plugins/TaskButton.js +88 -3
- package/plugins/ThemeSwitcher.js +164 -4
- package/plugins/TimeManager.js +971 -10
- package/plugins/TopBar.js +300 -7
- package/plugins/TourGuide.js +213 -2
- package/plugins/ValueTool.js +419 -4
- package/plugins/View3D.js +519 -14
- package/plugins/ZoomButtons.js +165 -3
- package/plugins/map/EditingSupport.js +199 -7
- package/plugins/map/LocateSupport.js +260 -4
- package/plugins/map/MeasurementSupport.js +216 -8
- package/plugins/map/RedliningPickSupport.js +201 -7
- package/plugins/map/RedliningSupport.js +726 -17
- package/plugins/map/SnapInteraction.js +101 -1
- package/plugins/map/SnapSupport.js +210 -2
- package/plugins/map/SnappingSupport.js +356 -17
- package/plugins/map3d/BackgroundSwitcher3D.js +44 -3
- package/plugins/map3d/BottomBar3D.js +118 -3
- package/plugins/map3d/Compare3D.js +422 -8
- package/plugins/map3d/Draw3D.js +353 -6
- package/plugins/map3d/ExportObjects3D.js +393 -18
- package/plugins/map3d/HideObjects3D.js +313 -12
- package/plugins/map3d/Identify3D.js +283 -12
- package/plugins/map3d/LayerTree3D.js +323 -3
- package/plugins/map3d/MapCopyright3D.js +128 -5
- package/plugins/map3d/MapExport3D.js +590 -10
- package/plugins/map3d/MapLight3D.js +553 -6
- package/plugins/map3d/Measure3D.js +571 -20
- package/plugins/map3d/OverviewMap3D.js +169 -3
- package/plugins/map3d/Settings3D.js +73 -3
- package/plugins/map3d/TopBar3D.js +207 -9
- package/plugins/redlining/RedliningBufferSupport.js +206 -3
- package/reducers/display.js +34 -2
- package/reducers/editing.js +68 -3
- package/reducers/index.js +9 -1
- package/reducers/layerinfo.js +26 -2
- package/reducers/layers.js +456 -9
- package/reducers/localConfig.js +122 -2
- package/reducers/locale.js +38 -2
- package/reducers/locate.js +40 -2
- package/reducers/map.js +176 -5
- package/reducers/measurement.js +42 -2
- package/reducers/processNotifications.js +49 -2
- package/reducers/redlining.js +50 -2
- package/reducers/redliningPick.js +27 -2
- package/reducers/search.js +20 -1
- package/reducers/serviceinfo.js +25 -2
- package/reducers/task.js +45 -2
- package/reducers/theme.js +51 -2
- package/reducers/windows.js +203 -2
- package/scripts/dist.sh +1 -1
- package/scripts/gen-plugin-docs.js +152 -2
- package/scripts/makeIconkit.js +85 -6
- package/scripts/themesConfig.js +742 -40
- package/scripts/updateTranslations.js +251 -10
- package/selectors/searchproviders.js +44 -2
- package/stores/StandardStore.js +42 -2
- package/utils/ConfigUtils.js +84 -3
- package/utils/CoordinatesUtils.js +234 -23
- package/utils/DxfUtils.js +237 -11
- package/utils/EditingInterface.js +421 -87
- package/utils/EditingUtils.js +357 -13
- package/utils/ElevationInterface.js +83 -22
- package/utils/FeatureStyles.js +429 -5
- package/utils/IdentifyUtils.js +443 -7
- package/utils/ImageEditor.js +79 -9
- package/utils/LayerUtils.js +1516 -50
- package/utils/LocaleUtils.js +117 -7
- package/utils/MapUtils.js +241 -59
- package/utils/MeasureUtils.js +323 -2
- package/utils/MiscUtils.js +189 -11
- package/utils/PermaLinkUtils.js +429 -6
- package/utils/PluginStore.js +27 -1
- package/utils/ResourceRegistry.js +15 -1
- package/utils/RoutingInterface.js +307 -7
- package/utils/SearchProviders.js +722 -19
- package/utils/ServiceLayerUtils.js +669 -14
- package/utils/Signal.js +32 -2
- package/utils/ThemeUtils.js +341 -7
- package/utils/VectorLayerUtils.js +589 -15
- package/utils/expr_grammar/grammar.js +2239 -2
- package/utils/expr_grammar/test.js +65 -3
|
@@ -1,54 +1,625 @@
|
|
|
1
|
-
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
6
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
7
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
10
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
11
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
13
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
14
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
15
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
16
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
17
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
18
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
19
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
20
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
21
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
22
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
23
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
24
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
25
|
+
/**
|
|
2
26
|
* Copyright 2024 Stadtwerke München GmbH
|
|
3
27
|
* All rights reserved.
|
|
4
28
|
*
|
|
5
29
|
* This source code is licensed under the BSD-style license found in the
|
|
6
30
|
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import React from 'react';
|
|
34
|
+
import isEqual from 'lodash.isequal';
|
|
35
|
+
import ol from 'openlayers';
|
|
36
|
+
import PropTypes from 'prop-types';
|
|
37
|
+
import rotateCursor from '../resources/rotate.svg';
|
|
38
|
+
import FeatureStyles from '../utils/FeatureStyles';
|
|
39
|
+
import MapUtils from '../utils/MapUtils';
|
|
40
|
+
var PrintSelection = /*#__PURE__*/function (_React$Component) {
|
|
41
|
+
function PrintSelection(props) {
|
|
42
|
+
var _this$map$getView$get;
|
|
43
|
+
var _this;
|
|
44
|
+
_classCallCheck(this, PrintSelection);
|
|
45
|
+
_this = _callSuper(this, PrintSelection, [props]);
|
|
46
|
+
_defineProperty(_this, "setViewportCursor", function (ev) {
|
|
47
|
+
if (_this.isInteracting) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
var overFeature = _this.map.getFeaturesAtPixel(ev.pixel, {
|
|
51
|
+
hitTolerance: 20,
|
|
52
|
+
layerFilter: function layerFilter(layer) {
|
|
53
|
+
return layer === _this.selectionLayer;
|
|
54
|
+
}
|
|
55
|
+
}).includes(_this.feature);
|
|
56
|
+
if (!overFeature) {
|
|
57
|
+
_this.map.getViewport().style.cursor = '';
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
var sqdist = function sqdist(p, q) {
|
|
61
|
+
return (p[0] - q[0]) * (p[0] - q[0]) + (p[1] - q[1]) * (p[1] - q[1]);
|
|
62
|
+
};
|
|
63
|
+
var getPixelFromCoordinate = MapUtils.getHook(MapUtils.GET_PIXEL_FROM_COORDINATES_HOOK);
|
|
64
|
+
var topright = getPixelFromCoordinate(_this.feature.getGeometry().getCoordinates()[0][0], false);
|
|
65
|
+
var bottomright = getPixelFromCoordinate(_this.feature.getGeometry().getCoordinates()[0][1], false);
|
|
66
|
+
var bottomleft = getPixelFromCoordinate(_this.feature.getGeometry().getCoordinates()[0][2], false);
|
|
67
|
+
var topleft = getPixelFromCoordinate(_this.feature.getGeometry().getCoordinates()[0][3], false);
|
|
68
|
+
if (sqdist(ev.pixel, topright) < 400) {
|
|
69
|
+
_this.map.getViewport().style.cursor = 'nesw-resize';
|
|
70
|
+
} else if (sqdist(ev.pixel, bottomright) < 400) {
|
|
71
|
+
_this.map.getViewport().style.cursor = "url(".concat(rotateCursor, ") 12 12, auto");
|
|
72
|
+
} else if (sqdist(ev.pixel, bottomleft) < 400) {
|
|
73
|
+
_this.map.getViewport().style.cursor = 'nesw-resize';
|
|
74
|
+
} else if (sqdist(ev.pixel, topleft) < 400) {
|
|
75
|
+
_this.map.getViewport().style.cursor = 'nwse-resize';
|
|
76
|
+
} else {
|
|
77
|
+
_this.map.getViewport().style.cursor = '';
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
_defineProperty(_this, "getGeometry", function () {
|
|
81
|
+
var modifyGeometry = _this.feature.get('modifyGeometry');
|
|
82
|
+
return modifyGeometry ? modifyGeometry.geometry : _this.feature.getGeometry();
|
|
83
|
+
});
|
|
84
|
+
_defineProperty(_this, "getBackgroundGeometry", function (feature) {
|
|
85
|
+
var background = feature.getGeometry().clone();
|
|
86
|
+
if (_this.feature !== null) {
|
|
87
|
+
var geom = _this.getGeometry().clone();
|
|
88
|
+
|
|
89
|
+
// ignore degenerate geometries
|
|
90
|
+
if (geom.getArea() === 0) {
|
|
91
|
+
return background;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// make the current selection transparent
|
|
95
|
+
background.appendLinearRing(geom.getLinearRing(0));
|
|
96
|
+
|
|
97
|
+
// add the origin to the selected tiles
|
|
98
|
+
var selected = ['0,0'].concat(_toConsumableArray(_this.props.printSeriesSelected));
|
|
99
|
+
|
|
100
|
+
// make the selected series transparent
|
|
101
|
+
_this.seriesGeometries.filter(_this.isPrintSeriesSelected).forEach(function (entry) {
|
|
102
|
+
// add the inner part of the tile
|
|
103
|
+
var clonedGeom = entry.geometry.clone();
|
|
104
|
+
clonedGeom.scale(1 - 2 * _this.props.printSeriesOverlap);
|
|
105
|
+
background.appendLinearRing(clonedGeom.getLinearRing(0));
|
|
106
|
+
|
|
107
|
+
// clone the original geometry and rotate it
|
|
108
|
+
var clonedGeomBase = entry.geometry.clone();
|
|
109
|
+
var center = ol.extent.getCenter(clonedGeomBase.getExtent());
|
|
110
|
+
clonedGeomBase.rotate(entry.rotation, center);
|
|
111
|
+
var extent = clonedGeomBase.getExtent();
|
|
112
|
+
|
|
113
|
+
// create the geometries for the overlapping borders
|
|
114
|
+
var clonedGeomLeft = clonedGeomBase.clone();
|
|
115
|
+
var centerLeft = [extent[0], 0.5 * (extent[1] + extent[3])];
|
|
116
|
+
clonedGeomLeft.scale(_this.props.printSeriesOverlap, 1 - 2 * _this.props.printSeriesOverlap, centerLeft);
|
|
117
|
+
clonedGeomLeft.rotate(-entry.rotation, center);
|
|
118
|
+
var clonedGeomRight = clonedGeomBase.clone();
|
|
119
|
+
var centerRight = [extent[2], 0.5 * (extent[1] + extent[3])];
|
|
120
|
+
clonedGeomRight.scale(_this.props.printSeriesOverlap, 1 - 2 * _this.props.printSeriesOverlap, centerRight);
|
|
121
|
+
clonedGeomRight.rotate(-entry.rotation, center);
|
|
122
|
+
var clonedGeomBottom = clonedGeomBase.clone();
|
|
123
|
+
var centerBottom = [0.5 * (extent[0] + extent[2]), extent[1]];
|
|
124
|
+
clonedGeomBottom.scale(1 - 2 * _this.props.printSeriesOverlap, _this.props.printSeriesOverlap, centerBottom);
|
|
125
|
+
clonedGeomBottom.rotate(-entry.rotation, center);
|
|
126
|
+
var clonedGeomTop = clonedGeomBase.clone();
|
|
127
|
+
var centerTop = [0.5 * (extent[0] + extent[2]), extent[3]];
|
|
128
|
+
clonedGeomTop.scale(1 - 2 * _this.props.printSeriesOverlap, _this.props.printSeriesOverlap, centerTop);
|
|
129
|
+
clonedGeomTop.rotate(-entry.rotation, center);
|
|
130
|
+
|
|
131
|
+
// create the geometries for the overlapping corners
|
|
132
|
+
var clonedGeomBottomLeft = clonedGeomBase.clone();
|
|
133
|
+
var bottomLeft = [extent[0], extent[1]];
|
|
134
|
+
clonedGeomBottomLeft.scale(_this.props.printSeriesOverlap, _this.props.printSeriesOverlap, bottomLeft);
|
|
135
|
+
clonedGeomBottomLeft.rotate(-entry.rotation, center);
|
|
136
|
+
var clonedGeomBottomRight = clonedGeomBase.clone();
|
|
137
|
+
var bottomRight = [extent[2], extent[1]];
|
|
138
|
+
clonedGeomBottomRight.scale(_this.props.printSeriesOverlap, _this.props.printSeriesOverlap, bottomRight);
|
|
139
|
+
clonedGeomBottomRight.rotate(-entry.rotation, center);
|
|
140
|
+
var clonedGeomTopLeft = clonedGeomBase.clone();
|
|
141
|
+
var topLeft = [extent[0], extent[3]];
|
|
142
|
+
clonedGeomTopLeft.scale(_this.props.printSeriesOverlap, _this.props.printSeriesOverlap, topLeft);
|
|
143
|
+
clonedGeomTopLeft.rotate(-entry.rotation, center);
|
|
144
|
+
var clonedGeomTopRight = clonedGeomBase.clone();
|
|
145
|
+
var topRight = [extent[2], extent[3]];
|
|
146
|
+
clonedGeomTopRight.scale(_this.props.printSeriesOverlap, _this.props.printSeriesOverlap, topRight);
|
|
147
|
+
clonedGeomTopRight.rotate(-entry.rotation, center);
|
|
148
|
+
|
|
149
|
+
// calculate the neighbours of the current tile
|
|
150
|
+
var topNeighbour = [entry.index[0] - 1, entry.index[1]].join(',');
|
|
151
|
+
var bottomNeighbour = [entry.index[0] + 1, entry.index[1]].join(',');
|
|
152
|
+
var leftNeighbour = [entry.index[0], entry.index[1] - 1].join(',');
|
|
153
|
+
var rightNeighbour = [entry.index[0], entry.index[1] + 1].join(',');
|
|
154
|
+
var topLeftNeighbour = [entry.index[0] - 1, entry.index[1] - 1].join(',');
|
|
155
|
+
var topRightNeighbour = [entry.index[0] - 1, entry.index[1] + 1].join(',');
|
|
156
|
+
var bottomLeftNeighbour = [entry.index[0] + 1, entry.index[1] - 1].join(',');
|
|
157
|
+
var bottomRightNeighbour = [entry.index[0] + 1, entry.index[1] + 1].join(',');
|
|
158
|
+
|
|
159
|
+
// Each tile is responsible to draw its border facing away from the origin.
|
|
160
|
+
|
|
161
|
+
// left border
|
|
162
|
+
if (!selected.includes(leftNeighbour) || entry.index[1] <= 0) {
|
|
163
|
+
background.appendLinearRing(clonedGeomLeft.getLinearRing(0));
|
|
164
|
+
}
|
|
165
|
+
// right border
|
|
166
|
+
if (!selected.includes(rightNeighbour) || entry.index[1] >= 0) {
|
|
167
|
+
background.appendLinearRing(clonedGeomRight.getLinearRing(0));
|
|
168
|
+
}
|
|
169
|
+
// top border
|
|
170
|
+
if (!selected.includes(topNeighbour) || entry.index[0] <= 0) {
|
|
171
|
+
background.appendLinearRing(clonedGeomTop.getLinearRing(0));
|
|
172
|
+
}
|
|
173
|
+
// bottom border
|
|
174
|
+
if (!selected.includes(bottomNeighbour) || entry.index[0] >= 0) {
|
|
175
|
+
background.appendLinearRing(clonedGeomBottom.getLinearRing(0));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// The corners are drawn by the tile facing away from the origin, and in counter-clockwise order.
|
|
179
|
+
|
|
180
|
+
// top-left corner
|
|
181
|
+
if (entry.index[0] <= 0 && entry.index[1] <= 0 || entry.index[0] <= 0 && !selected.includes(leftNeighbour) || entry.index[1] <= 0 && !selected.includes(topNeighbour) && !selected.includes(topLeftNeighbour) || !selected.includes(leftNeighbour) && !selected.includes(topNeighbour) && !selected.includes(topLeftNeighbour)) {
|
|
182
|
+
background.appendLinearRing(clonedGeomTopLeft.getLinearRing(0));
|
|
183
|
+
}
|
|
184
|
+
// top-right corner
|
|
185
|
+
if (entry.index[0] <= 0 && entry.index[1] >= 0 || entry.index[0] <= 0 && !selected.includes(rightNeighbour) || entry.index[1] >= 0 && !selected.includes(topNeighbour) && !selected.includes(topRightNeighbour) || !selected.includes(rightNeighbour) && !selected.includes(topNeighbour) && !selected.includes(topRightNeighbour)) {
|
|
186
|
+
background.appendLinearRing(clonedGeomTopRight.getLinearRing(0));
|
|
187
|
+
}
|
|
188
|
+
// bottom-left corner
|
|
189
|
+
if (entry.index[0] >= 0 && entry.index[1] <= 0 || entry.index[0] >= 0 && !selected.includes(leftNeighbour) || entry.index[1] <= 0 && !selected.includes(bottomNeighbour) && !selected.includes(bottomLeftNeighbour) || !selected.includes(leftNeighbour) && !selected.includes(bottomNeighbour) && !selected.includes(bottomLeftNeighbour)) {
|
|
190
|
+
background.appendLinearRing(clonedGeomBottomLeft.getLinearRing(0));
|
|
191
|
+
}
|
|
192
|
+
// bottom-right corner
|
|
193
|
+
if (entry.index[0] >= 0 && entry.index[1] >= 0 || entry.index[0] >= 0 && !selected.includes(rightNeighbour) || entry.index[1] >= 0 && !selected.includes(bottomNeighbour) && !selected.includes(bottomRightNeighbour) || !selected.includes(rightNeighbour) && !selected.includes(bottomNeighbour) && !selected.includes(bottomRightNeighbour)) {
|
|
194
|
+
background.appendLinearRing(clonedGeomBottomRight.getLinearRing(0));
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return background;
|
|
199
|
+
});
|
|
200
|
+
_defineProperty(_this, "calculateSeriesGeometries", function () {
|
|
201
|
+
var featureGeometry = _this.getGeometry();
|
|
202
|
+
var coordinates = featureGeometry.getCoordinates()[0];
|
|
203
|
+
var dx1 = coordinates[1][0] - coordinates[2][0];
|
|
204
|
+
var dy1 = coordinates[1][1] - coordinates[2][1];
|
|
205
|
+
var dx2 = coordinates[2][0] - coordinates[3][0];
|
|
206
|
+
var dy2 = coordinates[2][1] - coordinates[3][1];
|
|
207
|
+
var rotation = -Math.atan2(dy1, dx1);
|
|
208
|
+
var gridSize = _this.props.printSeriesEnabled ? _this.props.printSeriesGridSize : 0;
|
|
209
|
+
var geometries = [];
|
|
210
|
+
for (var i = -gridSize; i <= gridSize; i++) {
|
|
211
|
+
for (var j = -gridSize; j <= gridSize; j++) {
|
|
212
|
+
var index = [i, j];
|
|
213
|
+
var geometry = featureGeometry.clone();
|
|
214
|
+
geometry.translate((1 - _this.props.printSeriesOverlap) * (j * dx1 + i * dx2), (1 - _this.props.printSeriesOverlap) * (j * dy1 + i * dy2));
|
|
215
|
+
geometries.push({
|
|
216
|
+
index: index,
|
|
217
|
+
geometry: geometry,
|
|
218
|
+
rotation: rotation
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return geometries;
|
|
223
|
+
});
|
|
224
|
+
_defineProperty(_this, "layerStyle", function (feature) {
|
|
225
|
+
// background geometry with own styling
|
|
226
|
+
if (feature === _this.backgroundFeature) {
|
|
227
|
+
return FeatureStyles.printInteractionBackground({
|
|
228
|
+
geometryFunction: _this.getBackgroundGeometry
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// draw series geometries with own styling
|
|
233
|
+
if (feature === _this.printSeriesFeature && _this.props.printSeriesEnabled) {
|
|
234
|
+
var styles = [];
|
|
235
|
+
var size = Math.min(_this.props.fixedFrame.width, _this.props.fixedFrame.height);
|
|
236
|
+
var radius = Math.min(_this.props.scale * size / _this.map.getView().getResolution() / 100000, 2);
|
|
237
|
+
_this.seriesGeometries.forEach(function (entry) {
|
|
238
|
+
// ignore the center geometry
|
|
239
|
+
if (!isEqual(entry.index, [0, 0])) {
|
|
240
|
+
styles.push(FeatureStyles.printInteractionSeries({
|
|
241
|
+
geometryFunction: entry.geometry
|
|
242
|
+
}));
|
|
243
|
+
styles.push.apply(styles, _toConsumableArray(FeatureStyles.printInteractionSeriesIcon({
|
|
244
|
+
geometryFunction: new ol.geom.Point(ol.extent.getCenter(entry.geometry.getExtent())),
|
|
245
|
+
rotation: entry.rotation,
|
|
246
|
+
radius: radius,
|
|
247
|
+
img: _this.isPrintSeriesSelected(entry) ? 'minus' : 'plus'
|
|
248
|
+
})));
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
return styles;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// main feature
|
|
255
|
+
if (feature === _this.feature) {
|
|
256
|
+
var _styles = [FeatureStyles.printInteraction({
|
|
257
|
+
geometryFunction: _this.getGeometry
|
|
258
|
+
})];
|
|
259
|
+
var coordinates = _this.getGeometry().getCoordinates()[0];
|
|
260
|
+
if (coordinates && _this.props.fixedFrame) {
|
|
261
|
+
if (_this.props.allowScaling) {
|
|
262
|
+
// vertices to scale the selection
|
|
263
|
+
_styles.push(FeatureStyles.printInteractionVertex({
|
|
264
|
+
geometryFunction: new ol.geom.MultiPoint(coordinates.slice(2))
|
|
265
|
+
}));
|
|
266
|
+
}
|
|
267
|
+
if (_this.props.allowScaling || _this.props.allowRotation) {
|
|
268
|
+
// vertices to scale or rotate the selection
|
|
269
|
+
_styles.push(FeatureStyles.printInteractionVertex({
|
|
270
|
+
geometryFunction: new ol.geom.MultiPoint(coordinates.slice(1, 2)),
|
|
271
|
+
fill: _this.props.allowRotation
|
|
272
|
+
}));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return _styles;
|
|
276
|
+
}
|
|
277
|
+
return null;
|
|
278
|
+
});
|
|
279
|
+
_defineProperty(_this, "scaleRotateStyle", function (feature) {
|
|
280
|
+
feature.get('features').forEach(function (modifyFeature) {
|
|
281
|
+
var modifyGeometry = modifyFeature.get('modifyGeometry');
|
|
282
|
+
if (modifyGeometry) {
|
|
283
|
+
var point = feature.getGeometry().getCoordinates();
|
|
284
|
+
// rotate only with vertex on bottom-right
|
|
285
|
+
var isRotationVertex = isEqual(point, modifyFeature.getGeometry().getCoordinates()[0][1]);
|
|
286
|
+
if (!modifyGeometry.point) {
|
|
287
|
+
// save the initial geometry and vertex position
|
|
288
|
+
modifyGeometry.point = point;
|
|
289
|
+
modifyGeometry.initialGeometry = modifyGeometry.geometry;
|
|
290
|
+
}
|
|
291
|
+
var center = ol.extent.getCenter(modifyGeometry.initialGeometry.getExtent());
|
|
292
|
+
var _this$calculateRotati = _this.calculateRotationScale(modifyGeometry.point, point, center),
|
|
293
|
+
_this$calculateRotati2 = _slicedToArray(_this$calculateRotati, 2),
|
|
294
|
+
rotation = _this$calculateRotati2[0],
|
|
295
|
+
scale = _this$calculateRotati2[1];
|
|
296
|
+
var geometry = modifyGeometry.initialGeometry.clone();
|
|
297
|
+
if (_this.props.allowRotation && isRotationVertex) {
|
|
298
|
+
geometry.rotate(rotation, center);
|
|
299
|
+
} else if (_this.props.allowScaling) {
|
|
300
|
+
geometry.scale(scale, undefined, center);
|
|
301
|
+
}
|
|
302
|
+
modifyGeometry.geometry = geometry;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
return null;
|
|
306
|
+
});
|
|
307
|
+
_defineProperty(_this, "isPrintSeriesSelected", function (entry) {
|
|
308
|
+
return _this.props.printSeriesSelected.includes(entry.index.join(','));
|
|
309
|
+
});
|
|
310
|
+
_defineProperty(_this, "calculateExtents", function () {
|
|
311
|
+
_this.seriesGeometries = _this.calculateSeriesGeometries();
|
|
312
|
+
_this.selectionLayer.changed();
|
|
313
|
+
return _this.seriesGeometries.filter(function (entry) {
|
|
314
|
+
return isEqual(entry.index, [0, 0]) || _this.isPrintSeriesSelected(entry);
|
|
315
|
+
}).map(function (entry) {
|
|
316
|
+
var clonedGeom = entry.geometry.clone();
|
|
317
|
+
var center = ol.extent.getCenter(clonedGeom.getExtent());
|
|
318
|
+
clonedGeom.rotate(-_this.props.rotation * Math.PI / 180, center);
|
|
319
|
+
return clonedGeom.getExtent();
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
_defineProperty(_this, "geometryChanged", function () {
|
|
323
|
+
var geometry = _this.getGeometry();
|
|
324
|
+
var extent = geometry.getExtent();
|
|
325
|
+
var point = geometry.getCoordinates()[0][0];
|
|
326
|
+
var center = ol.extent.getCenter(extent);
|
|
327
|
+
|
|
328
|
+
// Update series geometries and obtain extents
|
|
329
|
+
var extents = _this.calculateExtents();
|
|
330
|
+
var rotation = 0;
|
|
331
|
+
var scale = null;
|
|
332
|
+
if (_this.initialWidth !== null && _this.initialHeight !== null) {
|
|
333
|
+
var initialPoint = [center[0] + 0.5 * _this.initialWidth, center[1] + 0.5 * _this.initialHeight];
|
|
334
|
+
var _this$calculateRotati3 = _this.calculateRotationScale(initialPoint, point, center),
|
|
335
|
+
_this$calculateRotati4 = _slicedToArray(_this$calculateRotati3, 2),
|
|
336
|
+
calcRotation = _this$calculateRotati4[0],
|
|
337
|
+
calcScale = _this$calculateRotati4[1];
|
|
338
|
+
var degree = (360 + calcRotation * 180 / Math.PI) % 360;
|
|
339
|
+
rotation = Math.round(degree * 10) / 10 % 360;
|
|
340
|
+
scale = Math.round(1000 * calcScale);
|
|
341
|
+
}
|
|
342
|
+
_this.props.geometryChanged(center, extents, rotation, scale);
|
|
343
|
+
});
|
|
344
|
+
_defineProperty(_this, "calculateRotationScale", function (p1, p2, center) {
|
|
345
|
+
var dx = p1[0] - center[0];
|
|
346
|
+
var dy = p1[1] - center[1];
|
|
347
|
+
var initialAngle = Math.atan2(dy, dx);
|
|
348
|
+
var initialRadius = Math.sqrt(dx * dx + dy * dy);
|
|
349
|
+
dx = p2[0] - center[0];
|
|
350
|
+
dy = p2[1] - center[1];
|
|
351
|
+
var currentAngle = Math.atan2(dy, dx);
|
|
352
|
+
var currentRadius = Math.sqrt(dx * dx + dy * dy);
|
|
353
|
+
return [currentAngle - initialAngle, currentRadius / initialRadius];
|
|
354
|
+
});
|
|
355
|
+
_this.map = MapUtils.getHook(MapUtils.GET_MAP);
|
|
356
|
+
|
|
357
|
+
// create a layer to draw on
|
|
358
|
+
_this.source = new ol.source.Vector();
|
|
359
|
+
_this.selectionLayer = new ol.layer.Vector({
|
|
360
|
+
source: _this.source,
|
|
361
|
+
zIndex: 1000000,
|
|
362
|
+
style: _this.layerStyle
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
// create a geometry for the background feature
|
|
366
|
+
var _extent = (_this$map$getView$get = _this.map.getView().getProjection().getExtent()) !== null && _this$map$getView$get !== void 0 ? _this$map$getView$get : [Number.MIN_SAFE_INTEGER, Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER];
|
|
367
|
+
var _geometry = ol.geom.polygonFromExtent(_extent);
|
|
368
|
+
_this.backgroundFeature = new ol.Feature(_geometry);
|
|
369
|
+
_this.source.addFeature(_this.backgroundFeature);
|
|
370
|
+
_this.printSeriesFeature = new ol.Feature(_geometry);
|
|
371
|
+
_this.source.addFeature(_this.printSeriesFeature);
|
|
372
|
+
_this.feature = null;
|
|
373
|
+
_this.initialWidth = null;
|
|
374
|
+
_this.initialHeight = null;
|
|
375
|
+
_this.seriesGeometries = [];
|
|
376
|
+
_this.translateInteraction = null;
|
|
377
|
+
_this.scaleRotateInteraction = null;
|
|
378
|
+
_this.selectPrintSeriesInteraction = null;
|
|
379
|
+
_this.drawInteraction = null;
|
|
380
|
+
_this.isInteracting = false;
|
|
381
|
+
return _this;
|
|
382
|
+
}
|
|
383
|
+
_inherits(PrintSelection, _React$Component);
|
|
384
|
+
return _createClass(PrintSelection, [{
|
|
385
|
+
key: "componentDidUpdate",
|
|
386
|
+
value: function componentDidUpdate(prevProps) {
|
|
387
|
+
if (!isEqual(prevProps.fixedFrame, this.props.fixedFrame) || !isEqual(prevProps.center, this.props.center) || prevProps.rotation !== this.props.rotation || prevProps.scale !== this.props.scale) {
|
|
388
|
+
if (!this.isInteracting) {
|
|
389
|
+
this.recomputeFeature();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (prevProps.printSeriesEnabled !== this.props.printSeriesEnabled || prevProps.printSeriesOverlap !== this.props.printSeriesOverlap || prevProps.printSeriesSelected !== this.props.printSeriesSelected) {
|
|
393
|
+
this.geometryChanged();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}, {
|
|
397
|
+
key: "recomputeFeature",
|
|
398
|
+
value: function recomputeFeature() {
|
|
399
|
+
// delete the old feature
|
|
400
|
+
if (this.feature !== null) {
|
|
401
|
+
// remove old feature
|
|
402
|
+
this.source.removeFeature(this.feature);
|
|
403
|
+
this.feature = null;
|
|
404
|
+
this.initialWidth = null;
|
|
405
|
+
this.initialHeight = null;
|
|
406
|
+
this.seriesGeometries = [];
|
|
407
|
+
}
|
|
408
|
+
// render the current feature if given a fixed frame
|
|
409
|
+
if (this.props.fixedFrame !== null) {
|
|
410
|
+
// calculate actual width and height
|
|
411
|
+
var _MapUtils$transformEx = MapUtils.transformExtent(this.map.getView().getProjection(), this.props.center, this.props.fixedFrame.width, this.props.fixedFrame.height),
|
|
412
|
+
width = _MapUtils$transformEx.width,
|
|
413
|
+
height = _MapUtils$transformEx.height;
|
|
414
|
+
// add rectangle
|
|
415
|
+
var x1 = this.props.center[0] + 0.5 * width;
|
|
416
|
+
var x2 = this.props.center[0] - 0.5 * width;
|
|
417
|
+
var y1 = this.props.center[1] + 0.5 * height;
|
|
418
|
+
var y2 = this.props.center[1] - 0.5 * height;
|
|
419
|
+
var geometry = new ol.geom.Polygon([[[x1, y1], [x1, y2], [x2, y2], [x2, y1], [x1, y1]]]);
|
|
420
|
+
// rotate and scale rectangle
|
|
421
|
+
if (this.props.rotation) {
|
|
422
|
+
geometry.rotate(this.props.rotation * Math.PI / 180, this.props.center);
|
|
423
|
+
}
|
|
424
|
+
if (this.props.scale) {
|
|
425
|
+
geometry.scale(this.props.scale / 1000, undefined, this.props.center);
|
|
426
|
+
}
|
|
427
|
+
// add feature to layer
|
|
428
|
+
this.feature = new ol.Feature(geometry);
|
|
429
|
+
this.feature.on('change', this.geometryChanged);
|
|
430
|
+
this.source.addFeature(this.feature);
|
|
431
|
+
// store initial width and height for future updates
|
|
432
|
+
this.initialWidth = width;
|
|
433
|
+
this.initialHeight = height;
|
|
434
|
+
// update geometry to new extent
|
|
435
|
+
this.geometryChanged();
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}, {
|
|
439
|
+
key: "componentDidMount",
|
|
440
|
+
value: function componentDidMount() {
|
|
441
|
+
this.map.on('pointermove', this.setViewportCursor);
|
|
442
|
+
this.map.addLayer(this.selectionLayer);
|
|
443
|
+
this.addInteractions();
|
|
444
|
+
this.recomputeFeature();
|
|
445
|
+
}
|
|
446
|
+
}, {
|
|
447
|
+
key: "componentWillUnmount",
|
|
448
|
+
value: function componentWillUnmount() {
|
|
449
|
+
this.map.un('pointermove', this.setViewportCursor);
|
|
450
|
+
this.map.removeLayer(this.selectionLayer);
|
|
451
|
+
this.removeInteractions();
|
|
452
|
+
}
|
|
453
|
+
}, {
|
|
454
|
+
key: "addInteractions",
|
|
455
|
+
value: function addInteractions() {
|
|
456
|
+
var _this2 = this;
|
|
457
|
+
// move the selection
|
|
458
|
+
var translateCondition = function translateCondition(ev) {
|
|
459
|
+
return ol.events.condition.primaryAction(ev) && _this2.props.fixedFrame && _this2.props.allowTranslation;
|
|
460
|
+
};
|
|
461
|
+
this.translateInteraction = new ol.interaction.Translate({
|
|
462
|
+
condition: translateCondition,
|
|
463
|
+
// add condition to filter for correct cursor selection
|
|
464
|
+
filter: function filter(feature) {
|
|
465
|
+
return _this2.props.fixedFrame && _this2.props.allowTranslation && feature === _this2.feature;
|
|
466
|
+
},
|
|
467
|
+
layers: [this.selectionLayer]
|
|
468
|
+
});
|
|
469
|
+
this.translateInteraction.on('translatestart', function () {
|
|
470
|
+
_this2.isInteracting = true;
|
|
471
|
+
});
|
|
472
|
+
this.translateInteraction.on('translateend', function () {
|
|
473
|
+
_this2.isInteracting = false;
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
// scale and rotate the selection
|
|
477
|
+
var modifyCondition = function modifyCondition(ev) {
|
|
478
|
+
return ol.events.condition.primaryAction(ev) && _this2.props.fixedFrame && (_this2.props.allowScaling || _this2.props.allowRotation);
|
|
479
|
+
};
|
|
480
|
+
this.scaleRotateInteraction = new ol.interaction.Modify({
|
|
481
|
+
source: this.source,
|
|
482
|
+
condition: modifyCondition,
|
|
483
|
+
deleteCondition: ol.events.condition.never,
|
|
484
|
+
insertVertexCondition: ol.events.condition.never,
|
|
485
|
+
pixelTolerance: 20,
|
|
486
|
+
style: this.scaleRotateStyle
|
|
487
|
+
});
|
|
488
|
+
this.scaleRotateInteraction.on('modifystart', function (ev) {
|
|
489
|
+
_this2.isInteracting = true;
|
|
490
|
+
ev.features.forEach(function (feature) {
|
|
491
|
+
feature.set('modifyGeometry', {
|
|
492
|
+
geometry: feature.getGeometry().clone()
|
|
493
|
+
}, true);
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
this.scaleRotateInteraction.on('modifyend', function (ev) {
|
|
497
|
+
_this2.isInteracting = false;
|
|
498
|
+
ev.features.forEach(function (feature) {
|
|
499
|
+
var modifyGeometry = feature.get('modifyGeometry');
|
|
500
|
+
if (modifyGeometry) {
|
|
501
|
+
feature.setGeometry(modifyGeometry.geometry);
|
|
502
|
+
feature.unset('modifyGeometry', true);
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
_this2.recomputeFeature();
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
// select frames for printing a series
|
|
509
|
+
this.selectPrintSeriesInteraction = new ol.interaction.Select({
|
|
510
|
+
filter: function filter(feature) {
|
|
511
|
+
return feature === _this2.printSeriesFeature;
|
|
512
|
+
},
|
|
513
|
+
layers: [this.selectionLayer],
|
|
514
|
+
condition: ol.events.condition.click,
|
|
515
|
+
addCondition: ol.events.condition.always,
|
|
516
|
+
removeCondition: ol.events.condition.always,
|
|
517
|
+
style: null
|
|
518
|
+
});
|
|
519
|
+
this.selectPrintSeriesInteraction.on('select', function (ev) {
|
|
520
|
+
var coordinate = ev.mapBrowserEvent.coordinate;
|
|
521
|
+
var intersecting = _this2.seriesGeometries.find(function (entry) {
|
|
522
|
+
return !isEqual(entry.index, [0, 0]) && entry.geometry.intersectsCoordinate(coordinate);
|
|
523
|
+
});
|
|
524
|
+
if (intersecting) {
|
|
525
|
+
var selected = _this2.props.printSeriesSelected;
|
|
526
|
+
if (selected.includes(intersecting.index.join(','))) {
|
|
527
|
+
selected = selected.filter(function (index) {
|
|
528
|
+
return index !== intersecting.index.join(',');
|
|
529
|
+
});
|
|
530
|
+
} else {
|
|
531
|
+
selected = [].concat(_toConsumableArray(selected), [intersecting.index.join(',')]);
|
|
532
|
+
}
|
|
533
|
+
_this2.props.printSeriesChanged(selected);
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
// select a new area when no frame is given (only added when no fixed frame is given)
|
|
538
|
+
var drawCondition = function drawCondition(ev) {
|
|
539
|
+
return ol.events.condition.primaryAction(ev) && !_this2.props.fixedFrame;
|
|
540
|
+
};
|
|
541
|
+
this.drawInteraction = new ol.interaction.Draw({
|
|
542
|
+
source: this.source,
|
|
543
|
+
type: 'Circle',
|
|
544
|
+
style: FeatureStyles.printInteraction(),
|
|
545
|
+
geometryFunction: ol.interaction.createBox(),
|
|
546
|
+
condition: ol.events.condition.never,
|
|
547
|
+
freehandCondition: drawCondition
|
|
548
|
+
});
|
|
549
|
+
this.drawInteraction.on('drawstart', function (ev) {
|
|
550
|
+
_this2.isInteracting = true;
|
|
551
|
+
_this2.feature = ev.feature;
|
|
552
|
+
_this2.feature.on('change', _this2.geometryChanged);
|
|
553
|
+
});
|
|
554
|
+
this.drawInteraction.on('drawend', function () {
|
|
555
|
+
_this2.isInteracting = false;
|
|
556
|
+
_this2.geometryChanged();
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
// register interactions
|
|
560
|
+
this.map.addInteraction(this.translateInteraction);
|
|
561
|
+
this.map.addInteraction(this.scaleRotateInteraction);
|
|
562
|
+
this.map.addInteraction(this.selectPrintSeriesInteraction);
|
|
563
|
+
this.map.addInteraction(this.drawInteraction);
|
|
564
|
+
}
|
|
565
|
+
}, {
|
|
566
|
+
key: "removeInteractions",
|
|
567
|
+
value: function removeInteractions() {
|
|
568
|
+
if (this.translateInteraction !== null) {
|
|
569
|
+
this.map.removeInteraction(this.translateInteraction);
|
|
570
|
+
this.translateInteraction = null;
|
|
571
|
+
}
|
|
572
|
+
if (this.scaleRotateInteraction !== null) {
|
|
573
|
+
this.map.removeInteraction(this.scaleRotateInteraction);
|
|
574
|
+
this.scaleRotateInteraction = null;
|
|
575
|
+
}
|
|
576
|
+
if (this.selectPrintSeriesInteraction !== null) {
|
|
577
|
+
this.map.removeInteraction(this.selectPrintSeriesInteraction);
|
|
578
|
+
this.selectPrintSeriesInteraction = null;
|
|
579
|
+
}
|
|
580
|
+
if (this.drawInteraction !== null) {
|
|
581
|
+
this.map.removeInteraction(this.drawInteraction);
|
|
582
|
+
this.drawInteraction = null;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}, {
|
|
586
|
+
key: "render",
|
|
587
|
+
value: function render() {
|
|
588
|
+
return null;
|
|
589
|
+
}
|
|
590
|
+
}]);
|
|
591
|
+
}(React.Component);
|
|
592
|
+
_defineProperty(PrintSelection, "propTypes", {
|
|
593
|
+
allowRotation: PropTypes.bool,
|
|
594
|
+
allowScaling: PropTypes.bool,
|
|
595
|
+
allowTranslation: PropTypes.bool,
|
|
596
|
+
center: PropTypes.arrayOf(PropTypes.number),
|
|
597
|
+
fixedFrame: PropTypes.shape({
|
|
598
|
+
width: PropTypes.number,
|
|
599
|
+
// in meters
|
|
600
|
+
height: PropTypes.number // in meters
|
|
601
|
+
}),
|
|
602
|
+
geometryChanged: PropTypes.func,
|
|
603
|
+
printSeriesChanged: PropTypes.func,
|
|
604
|
+
printSeriesEnabled: PropTypes.bool,
|
|
605
|
+
printSeriesGridSize: PropTypes.number,
|
|
606
|
+
printSeriesOverlap: PropTypes.number,
|
|
607
|
+
printSeriesSelected: PropTypes.arrayOf(PropTypes.string),
|
|
608
|
+
rotation: PropTypes.number,
|
|
609
|
+
scale: PropTypes.number
|
|
610
|
+
});
|
|
611
|
+
_defineProperty(PrintSelection, "defaultProps", {
|
|
612
|
+
allowRotation: true,
|
|
613
|
+
allowScaling: true,
|
|
614
|
+
allowTranslation: true,
|
|
615
|
+
fixedFrame: null,
|
|
616
|
+
geometryChanged: function geometryChanged() {},
|
|
617
|
+
printSeriesChanged: function printSeriesChanged() {},
|
|
618
|
+
printSeriesEnabled: false,
|
|
619
|
+
printSeriesGridSize: 2,
|
|
620
|
+
printSeriesOverlap: 0,
|
|
621
|
+
printSeriesSelected: [],
|
|
622
|
+
rotation: 0,
|
|
623
|
+
scale: 1000
|
|
624
|
+
});
|
|
625
|
+
export { PrintSelection as default };
|