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
package/plugins/HeightProfile.js
CHANGED
|
@@ -1,11 +1,256 @@
|
|
|
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 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; }
|
|
7
|
+
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; }
|
|
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
|
-
*/
|
|
8
|
-
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import React from 'react';
|
|
36
|
+
import { Line } from "react-chartjs-2";
|
|
37
|
+
import ReactDOM from 'react-dom';
|
|
38
|
+
import { connect } from 'react-redux';
|
|
39
|
+
import axios from 'axios';
|
|
40
|
+
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Filler, BubbleController } from 'chart.js';
|
|
41
|
+
import FileSaver from 'file-saver';
|
|
42
|
+
import isEmpty from 'lodash.isempty';
|
|
43
|
+
import PropTypes from 'prop-types';
|
|
44
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
45
|
+
import { addMarker, removeMarker } from '../actions/layers';
|
|
46
|
+
import { changeMeasurementState } from '../actions/measurement';
|
|
47
|
+
import Icon from '../components/Icon';
|
|
48
|
+
import ResizeableWindow from '../components/ResizeableWindow';
|
|
49
|
+
import Spinner from '../components/widgets/Spinner';
|
|
50
|
+
import { getElevationInterface } from '../utils/ElevationInterface';
|
|
51
|
+
import LayerUtils from '../utils/LayerUtils';
|
|
52
|
+
import LocaleUtils from '../utils/LocaleUtils';
|
|
53
|
+
import MapUtils from '../utils/MapUtils';
|
|
54
|
+
import MeasureUtils from '../utils/MeasureUtils';
|
|
55
|
+
import MiscUtils from '../utils/MiscUtils';
|
|
56
|
+
import VectorLayerUtils from '../utils/VectorLayerUtils';
|
|
57
|
+
import './style/HeightProfile.css';
|
|
58
|
+
ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Filler, BubbleController);
|
|
59
|
+
var HeightProfilePrintDialog_ = /*#__PURE__*/function (_React$PureComponent) {
|
|
60
|
+
function HeightProfilePrintDialog_(props) {
|
|
61
|
+
var _this;
|
|
62
|
+
_classCallCheck(this, HeightProfilePrintDialog_);
|
|
63
|
+
_this = _callSuper(this, HeightProfilePrintDialog_, [props]);
|
|
64
|
+
_defineProperty(_this, "state", {
|
|
65
|
+
initialized: false,
|
|
66
|
+
imageUrl: ''
|
|
67
|
+
});
|
|
68
|
+
_defineProperty(_this, "closePrintWindow", function () {
|
|
69
|
+
_this.externalWindow.close();
|
|
70
|
+
});
|
|
71
|
+
_defineProperty(_this, "setWindowContent", function () {
|
|
72
|
+
_this.externalWindow.addEventListener('beforeunload', _this.props.onClose, false);
|
|
73
|
+
var container = _this.externalWindow.document.getElementById("heightprofilecontainer");
|
|
74
|
+
if (container) {
|
|
75
|
+
var printBtn = _this.externalWindow.document.createElement('div');
|
|
76
|
+
printBtn.id = "print";
|
|
77
|
+
printBtn.style.marginBottom = "1em";
|
|
78
|
+
printBtn.innerHTML = '<style type="text/css">@media print{ #print { display: none; }}</style>' + '<button onClick="(function(){window.print();})()">' + LocaleUtils.tr("heightprofile.print") + '</button>';
|
|
79
|
+
container.appendChild(printBtn);
|
|
80
|
+
_this.imageEl = _this.externalWindow.document.createElement('div');
|
|
81
|
+
_this.imageEl.id = 'map';
|
|
82
|
+
_this.imageEl.innerHTML = LocaleUtils.tr("heightprofile.loadingimage");
|
|
83
|
+
container.appendChild(_this.imageEl);
|
|
84
|
+
_this.portalEl = _this.externalWindow.document.createElement('div');
|
|
85
|
+
_this.portalEl.id = 'profile';
|
|
86
|
+
container.appendChild(_this.portalEl);
|
|
87
|
+
_this.setState({
|
|
88
|
+
initialized: true
|
|
89
|
+
});
|
|
90
|
+
_this.externalWindow.document.body.style.overflowX = 'hidden';
|
|
91
|
+
} else {
|
|
92
|
+
_this.externalWindow.document.body.innerHTML = "Broken template. An element with id=heightprofilecontainer must exist.";
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
_defineProperty(_this, "refreshImage", function () {
|
|
96
|
+
var measurement = _this.props.measurement;
|
|
97
|
+
var layer = {
|
|
98
|
+
type: 'vector',
|
|
99
|
+
opacity: 255,
|
|
100
|
+
features: [].concat(_toConsumableArray(measurement.coordinates.map(function (coord) {
|
|
101
|
+
return {
|
|
102
|
+
type: 'Feature',
|
|
103
|
+
geometry: {
|
|
104
|
+
coordinates: coord,
|
|
105
|
+
type: 'Point'
|
|
106
|
+
},
|
|
107
|
+
styleOptions: {
|
|
108
|
+
fillColor: [255, 255, 255, 1],
|
|
109
|
+
strokeColor: [255, 0, 0, 1],
|
|
110
|
+
strokeWidth: 2,
|
|
111
|
+
circleRadius: 6
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
})), [{
|
|
115
|
+
type: 'Feature',
|
|
116
|
+
geometry: {
|
|
117
|
+
coordinates: measurement.coordinates,
|
|
118
|
+
type: 'LineString'
|
|
119
|
+
},
|
|
120
|
+
styleOptions: {
|
|
121
|
+
strokeColor: [255, 0, 0, 1],
|
|
122
|
+
strokeWidth: 4,
|
|
123
|
+
headmarker: _this.props.measurement.lineHeadMarker,
|
|
124
|
+
tailmarker: _this.props.measurement.lineTailMarker
|
|
125
|
+
},
|
|
126
|
+
properties: {
|
|
127
|
+
segment_labels: measurement.segment_lengths.map(function (length) {
|
|
128
|
+
return MeasureUtils.formatMeasurement(length, false, measurement.lenUnit);
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
}])
|
|
132
|
+
};
|
|
133
|
+
var mapCrs = _this.props.map.projection;
|
|
134
|
+
var scale = Math.round(MapUtils.computeForZoom(_this.props.map.scales, _this.props.map.zoom));
|
|
135
|
+
var exportParams = LayerUtils.collectPrintParams(_this.props.layers, _this.props.theme, scale, mapCrs, true, false);
|
|
136
|
+
var highlightParams = VectorLayerUtils.createPrintHighlighParams([layer], mapCrs, scale);
|
|
137
|
+
var imageParams = _objectSpread({
|
|
138
|
+
SERVICE: 'WMS',
|
|
139
|
+
VERSION: '1.3.0',
|
|
140
|
+
REQUEST: 'GetMap',
|
|
141
|
+
TRANSPARENT: 'true',
|
|
142
|
+
TILED: 'false',
|
|
143
|
+
CRS: _this.props.map.projection,
|
|
144
|
+
BBOX: _this.props.map.bbox.bounds,
|
|
145
|
+
WIDTH: _this.props.map.size.width,
|
|
146
|
+
HEIGHT: _this.props.map.size.height,
|
|
147
|
+
HIGHLIGHT_GEOM: highlightParams.geoms.join(";"),
|
|
148
|
+
HIGHLIGHT_SYMBOL: highlightParams.styles.join(";"),
|
|
149
|
+
HIGHLIGHT_LABELSTRING: highlightParams.labels.join(";"),
|
|
150
|
+
HIGHLIGHT_LABELCOLOR: highlightParams.labelFillColors.join(";"),
|
|
151
|
+
HIGHLIGHT_LABELBUFFERCOLOR: highlightParams.labelOutlineColors.join(";"),
|
|
152
|
+
HIGHLIGHT_LABELBUFFERSIZE: highlightParams.labelOutlineSizes.join(";"),
|
|
153
|
+
HIGHLIGHT_LABELSIZE: highlightParams.labelSizes.join(";"),
|
|
154
|
+
HIGHLIGHT_LABEL_DISTANCE: highlightParams.labelDist.join(";"),
|
|
155
|
+
HIGHLIGHT_LABEL_ROTATION: highlightParams.labelRotations.join(";"),
|
|
156
|
+
csrf_token: MiscUtils.getCsrfToken()
|
|
157
|
+
}, exportParams);
|
|
158
|
+
var baseUrl = _this.props.theme.url.split("?")[0];
|
|
159
|
+
var query = Object.entries(imageParams).map(function (_ref) {
|
|
160
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
161
|
+
k = _ref2[0],
|
|
162
|
+
v = _ref2[1];
|
|
163
|
+
return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
|
|
164
|
+
}).join('&');
|
|
165
|
+
var src = baseUrl + "?" + query;
|
|
166
|
+
if (src === _this.state.imageUrl) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
_this.setState({
|
|
170
|
+
imageUrl: src
|
|
171
|
+
});
|
|
172
|
+
var options = {
|
|
173
|
+
headers: {
|
|
174
|
+
'content-type': 'application/x-www-form-urlencoded'
|
|
175
|
+
},
|
|
176
|
+
responseType: "blob"
|
|
177
|
+
};
|
|
178
|
+
axios.post(baseUrl, query, options).then(function (response) {
|
|
179
|
+
var reader = new FileReader();
|
|
180
|
+
reader.readAsDataURL(response.data);
|
|
181
|
+
reader.onload = function () {
|
|
182
|
+
_this.imageEl.innerHTML = "<img src=\"".concat(reader.result, "\" style=\"width: 100%\" />");
|
|
183
|
+
};
|
|
184
|
+
})["catch"](function () {
|
|
185
|
+
// Fall back to GET
|
|
186
|
+
_this.imageEl.innerHTML = "<img src=\"".concat(src, "\" style=\"width: 100%\" />");
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
_defineProperty(_this, "windowResized", function () {
|
|
190
|
+
if (_this.chart) {
|
|
191
|
+
_this.chart.resize();
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
_this.externalWindow = null;
|
|
195
|
+
_this.chart = null;
|
|
196
|
+
_this.portalEl = null;
|
|
197
|
+
_this.imageEl = null;
|
|
198
|
+
return _this;
|
|
199
|
+
}
|
|
200
|
+
_inherits(HeightProfilePrintDialog_, _React$PureComponent);
|
|
201
|
+
return _createClass(HeightProfilePrintDialog_, [{
|
|
202
|
+
key: "componentDidMount",
|
|
203
|
+
value: function componentDidMount() {
|
|
204
|
+
var templatePath = MiscUtils.resolveAssetsPath(this.props.templatePath);
|
|
205
|
+
this.externalWindow = window.open(templatePath, LocaleUtils.tr("heightprofile.title"), "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes");
|
|
206
|
+
this.externalWindow.addEventListener('load', this.setWindowContent, false);
|
|
207
|
+
this.externalWindow.addEventListener('resize', this.windowResized, false);
|
|
208
|
+
window.addEventListener('beforeunload', this.closePrintWindow);
|
|
209
|
+
}
|
|
210
|
+
}, {
|
|
211
|
+
key: "componentDidUpdate",
|
|
212
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
213
|
+
if (this.props.layers !== prevProps.layers || this.props.map.bbox !== prevProps.map.bbox || this.state.initialized && !prevState.initialized) {
|
|
214
|
+
this.refreshImage();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, {
|
|
218
|
+
key: "componentWillUnmount",
|
|
219
|
+
value: function componentWillUnmount() {
|
|
220
|
+
this.closePrintWindow();
|
|
221
|
+
window.removeEventListener('beforeunload', this.closePrintWindow);
|
|
222
|
+
}
|
|
223
|
+
}, {
|
|
224
|
+
key: "render",
|
|
225
|
+
value: function render() {
|
|
226
|
+
var _this2 = this;
|
|
227
|
+
if (!this.state.initialized) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
return /*#__PURE__*/ReactDOM.createPortal(this.props.children(function (el) {
|
|
231
|
+
_this2.chart = el;
|
|
232
|
+
}, false), this.portalEl);
|
|
233
|
+
}
|
|
234
|
+
}]);
|
|
235
|
+
}(React.PureComponent);
|
|
236
|
+
_defineProperty(HeightProfilePrintDialog_, "propTypes", {
|
|
237
|
+
children: PropTypes.func,
|
|
238
|
+
layers: PropTypes.array,
|
|
239
|
+
map: PropTypes.object,
|
|
240
|
+
measurement: PropTypes.object,
|
|
241
|
+
onClose: PropTypes.func,
|
|
242
|
+
templatePath: PropTypes.string,
|
|
243
|
+
theme: PropTypes.object
|
|
244
|
+
});
|
|
245
|
+
var HeightProfilePrintDialog = connect(function (state) {
|
|
246
|
+
return {
|
|
247
|
+
layers: state.layers.flat,
|
|
248
|
+
map: state.map,
|
|
249
|
+
theme: state.theme.current
|
|
250
|
+
};
|
|
251
|
+
}, {})(HeightProfilePrintDialog_);
|
|
252
|
+
|
|
253
|
+
/**
|
|
9
254
|
* Displays a height profile along a measured line.
|
|
10
255
|
*
|
|
11
256
|
* Triggered automatically when a line is measured via the `Measure` plugin.
|
|
@@ -16,15 +261,518 @@ _this.imageEl.innerHTML="<img src=\"".concat(src,"\" style=\"width: 100%\" />")}
|
|
|
16
261
|
*
|
|
17
262
|
* The print height profile functionality requires a template located by default at `assets/templates/heightprofileprint.html`
|
|
18
263
|
* with containing a container element with `id=heightprofilecontainer`.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
264
|
+
*/
|
|
265
|
+
var HeightProfile = /*#__PURE__*/function (_React$Component) {
|
|
266
|
+
function HeightProfile(props) {
|
|
267
|
+
var _this3;
|
|
268
|
+
_classCallCheck(this, HeightProfile);
|
|
269
|
+
_this3 = _callSuper(this, HeightProfile, [props]);
|
|
270
|
+
_defineProperty(_this3, "state", {
|
|
271
|
+
data: {},
|
|
272
|
+
selectedDatasetIndices: [0],
|
|
273
|
+
reqId: null,
|
|
274
|
+
drawnodes: true,
|
|
275
|
+
printdialog: false
|
|
276
|
+
});
|
|
277
|
+
_defineProperty(_this3, "onClose", function () {
|
|
278
|
+
_this3.setState({
|
|
279
|
+
data: {},
|
|
280
|
+
isloading: false
|
|
281
|
+
});
|
|
282
|
+
_this3.props.changeMeasurementState(_objectSpread(_objectSpread({}, _this3.props.measurement), {}, {
|
|
283
|
+
pickPositionCallback: null
|
|
284
|
+
}));
|
|
285
|
+
});
|
|
286
|
+
_defineProperty(_this3, "renderHeightProfile", function (saveRef, interactive) {
|
|
287
|
+
var _this3$state$selected2;
|
|
288
|
+
if (_this3.props.measurement.drawing) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
if (_this3.state.data.error) {
|
|
292
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
293
|
+
className: "height-profile-error",
|
|
294
|
+
role: "body"
|
|
295
|
+
}, LocaleUtils.tr("heightprofile.error") + ": " + _this3.state.data.error);
|
|
296
|
+
}
|
|
297
|
+
var distanceStr = LocaleUtils.tr("heightprofile.distance");
|
|
298
|
+
var heightStr = LocaleUtils.tr("heightprofile.height");
|
|
299
|
+
var aslStr = LocaleUtils.tr("heightprofile.asl");
|
|
300
|
+
var _this3$state$selected = _this3.state.selectedDatasetIndices,
|
|
301
|
+
selectedDatasetIndices = _this3$state$selected === void 0 ? [] : _this3$state$selected;
|
|
302
|
+
var datasets = selectedDatasetIndices.flatMap(function (idx) {
|
|
303
|
+
return [{
|
|
304
|
+
label: _this3.state.data[idx].dataset,
|
|
305
|
+
data: _this3.state.data[idx].y.map(function (y, i) {
|
|
306
|
+
return {
|
|
307
|
+
x: _this3.state.data[idx].x[i],
|
|
308
|
+
y: y
|
|
309
|
+
};
|
|
310
|
+
}),
|
|
311
|
+
fill: true,
|
|
312
|
+
backgroundColor: "rgba(255,0,0,0.5)",
|
|
313
|
+
borderColor: "rgb(255,0,0)",
|
|
314
|
+
borderWidth: 2,
|
|
315
|
+
pointRadius: 0,
|
|
316
|
+
order: 1
|
|
317
|
+
}, {
|
|
318
|
+
type: 'bubble',
|
|
319
|
+
data: _this3.state.data[idx].nodes,
|
|
320
|
+
backgroundColor: 'rgb(255, 255, 255)',
|
|
321
|
+
borderColor: 'rgb(255, 0, 0)',
|
|
322
|
+
borderWidth: 2,
|
|
323
|
+
radius: 5,
|
|
324
|
+
hoverRadius: 0,
|
|
325
|
+
hoverBorderWidth: 2,
|
|
326
|
+
order: 0,
|
|
327
|
+
hidden: !_this3.state.drawnodes
|
|
328
|
+
}];
|
|
329
|
+
});
|
|
330
|
+
var data = {
|
|
331
|
+
labels: _this3.state.data[0].x,
|
|
332
|
+
// X-axis labels are all the same
|
|
333
|
+
datasets: datasets
|
|
334
|
+
};
|
|
335
|
+
var sampleDataset = _this3.state.data[(_this3$state$selected2 = _this3.state.selectedDatasetIndices[0]) !== null && _this3$state$selected2 !== void 0 ? _this3$state$selected2 : 0]; // first selected dataset for chart scale etc.
|
|
336
|
+
|
|
337
|
+
// Approx 10 ticks
|
|
338
|
+
var stepSizeFact = Math.pow(10, Math.ceil(Math.log10(sampleDataset.totLength / 10)));
|
|
339
|
+
var stepSize = Math.round(sampleDataset.totLength / stepSizeFact) * stepSizeFact / 10;
|
|
340
|
+
var prec = _this3.props.heightProfilePrecision;
|
|
341
|
+
var options = {
|
|
342
|
+
responsive: true,
|
|
343
|
+
maintainAspectRatio: false,
|
|
344
|
+
animation: {
|
|
345
|
+
duration: 0
|
|
346
|
+
},
|
|
347
|
+
plugins: {
|
|
348
|
+
legend: {
|
|
349
|
+
display: false
|
|
350
|
+
},
|
|
351
|
+
tooltip: {
|
|
352
|
+
enabled: interactive,
|
|
353
|
+
intersect: false,
|
|
354
|
+
displayColors: false,
|
|
355
|
+
bodyFont: {
|
|
356
|
+
weight: 'bold'
|
|
357
|
+
},
|
|
358
|
+
callbacks: {
|
|
359
|
+
title: function title(ctx) {
|
|
360
|
+
return distanceStr + ": " + MeasureUtils.formatMeasurement(ctx[0].parsed.x, false, 'metric');
|
|
361
|
+
},
|
|
362
|
+
label: function label(ctx) {
|
|
363
|
+
return _this3.state.data.length > 1 ? "".concat(heightStr, " (").concat(ctx.dataset.label, "): ").concat(ctx.parsed.y.toFixed(prec), " m ").concat(aslStr) : "".concat(heightStr, ": ").concat(ctx.parsed.y.toFixed(prec), " m ").concat(aslStr);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
scales: {
|
|
369
|
+
x: {
|
|
370
|
+
type: 'linear',
|
|
371
|
+
ticks: {
|
|
372
|
+
stepSize: stepSize,
|
|
373
|
+
font: {
|
|
374
|
+
size: 10
|
|
375
|
+
},
|
|
376
|
+
callback: function callback(value) {
|
|
377
|
+
return value;
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
title: {
|
|
381
|
+
display: true,
|
|
382
|
+
text: distanceStr + " [m]",
|
|
383
|
+
padding: 0
|
|
384
|
+
},
|
|
385
|
+
max: Math.ceil(sampleDataset.totLength)
|
|
386
|
+
},
|
|
387
|
+
y: {
|
|
388
|
+
ticks: {
|
|
389
|
+
font: {
|
|
390
|
+
size: 10
|
|
391
|
+
},
|
|
392
|
+
callback: function callback(value) {
|
|
393
|
+
return value.toFixed(prec);
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
title: {
|
|
397
|
+
display: true,
|
|
398
|
+
text: heightStr + " [m " + aslStr + "]"
|
|
399
|
+
},
|
|
400
|
+
max: Math.ceil(Math.max.apply(Math, _toConsumableArray(selectedDatasetIndices.map(function (idx) {
|
|
401
|
+
var _this3$state$data$idx;
|
|
402
|
+
return (_this3$state$data$idx = _this3.state.data[idx]) === null || _this3$state$data$idx === void 0 ? void 0 : _this3$state$data$idx.maxY;
|
|
403
|
+
})))),
|
|
404
|
+
min: Math.floor(Math.min.apply(Math, _toConsumableArray(selectedDatasetIndices.map(function (idx) {
|
|
405
|
+
var _this3$state$data$idx2;
|
|
406
|
+
return (_this3$state$data$idx2 = _this3.state.data[idx]) === null || _this3$state$data$idx2 === void 0 ? void 0 : _this3$state$data$idx2.minY;
|
|
407
|
+
}))))
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
onHover: interactive ? function (evt, activeEls, chart) {
|
|
411
|
+
var chartArea = chart.chartArea;
|
|
412
|
+
var chartX = Math.min(Math.max(evt.x - chartArea.left), chartArea.width);
|
|
413
|
+
_this3.updateMarker(chartX / chartArea.width * sampleDataset.totLength);
|
|
414
|
+
} : undefined
|
|
415
|
+
};
|
|
416
|
+
var datasetSelector = null;
|
|
417
|
+
if (_this3.state.data.length > 1) {
|
|
418
|
+
datasetSelector = /*#__PURE__*/React.createElement("div", {
|
|
419
|
+
className: "height-profile-dataset-select"
|
|
420
|
+
}, _this3.state.data.map(function (dataset, idx) {
|
|
421
|
+
var _this3$state$selected3;
|
|
422
|
+
var isSelected = (_this3$state$selected3 = _this3.state.selectedDatasetIndices) === null || _this3$state$selected3 === void 0 ? void 0 : _this3$state$selected3.includes(idx);
|
|
423
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
424
|
+
key: "".concat(dataset.dataset, "-").concat(idx)
|
|
425
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
426
|
+
icon: isSelected ? "checked" : "unchecked",
|
|
427
|
+
onClick: function onClick() {
|
|
428
|
+
var selected = new Set(_this3.state.selectedDatasetIndices || []);
|
|
429
|
+
if (isSelected) {
|
|
430
|
+
selected["delete"](idx);
|
|
431
|
+
} else {
|
|
432
|
+
selected.add(idx);
|
|
433
|
+
}
|
|
434
|
+
_this3.setState({
|
|
435
|
+
selectedDatasetIndices: Array.from(selected)
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
}), /*#__PURE__*/React.createElement("span", null, dataset.dataset));
|
|
439
|
+
}));
|
|
440
|
+
}
|
|
441
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
442
|
+
className: "height-profile-chart-container",
|
|
443
|
+
role: "body",
|
|
444
|
+
style: {
|
|
445
|
+
position: 'relative'
|
|
446
|
+
}
|
|
447
|
+
}, datasetSelector, /*#__PURE__*/React.createElement(Line, {
|
|
448
|
+
data: data,
|
|
449
|
+
options: options,
|
|
450
|
+
ref: saveRef
|
|
451
|
+
}));
|
|
452
|
+
});
|
|
453
|
+
_defineProperty(_this3, "resizeChart", function () {
|
|
454
|
+
if (_this3.chart) {
|
|
455
|
+
_this3.chart.resize();
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
_defineProperty(_this3, "updateMarker", function (x) {
|
|
459
|
+
var segmentLengths = _this3.props.measurement.segment_lengths;
|
|
460
|
+
var coo = _this3.props.measurement.coordinates;
|
|
461
|
+
if (isEmpty(segmentLengths) || isEmpty(coo)) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
var i = 0;
|
|
465
|
+
var runl = 0;
|
|
466
|
+
while (i < segmentLengths.length - 1 && x > runl + segmentLengths[i]) {
|
|
467
|
+
runl += segmentLengths[i++];
|
|
468
|
+
}
|
|
469
|
+
var lambda = (x - runl) / segmentLengths[i];
|
|
470
|
+
var p = [coo[i][0] + lambda * (coo[i + 1][0] - coo[i][0]), coo[i][1] + lambda * (coo[i + 1][1] - coo[i][1])];
|
|
471
|
+
_this3.props.addMarker('heightprofile', p, '', _this3.props.projection, 1000001); // 1000001: one higher than the zIndex in MeasurementSupport...
|
|
472
|
+
});
|
|
473
|
+
_defineProperty(_this3, "showTooltip", function (idx) {
|
|
474
|
+
if (!_this3.chart) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
var chartArea = _this3.chart.chartArea;
|
|
478
|
+
var activeElements = _this3.chart.data.datasets.map(function (ds, i) {
|
|
479
|
+
return {
|
|
480
|
+
ds: ds,
|
|
481
|
+
i: i
|
|
482
|
+
};
|
|
483
|
+
}).filter(function (_ref3) {
|
|
484
|
+
var ds = _ref3.ds;
|
|
485
|
+
return ds.type !== 'bubble';
|
|
486
|
+
}).map(function (_ref4) {
|
|
487
|
+
var i = _ref4.i;
|
|
488
|
+
return {
|
|
489
|
+
datasetIndex: i,
|
|
490
|
+
index: idx
|
|
491
|
+
};
|
|
492
|
+
});
|
|
493
|
+
_this3.chart.tooltip.setActiveElements(activeElements, {
|
|
494
|
+
x: (chartArea.left + chartArea.right) / 2,
|
|
495
|
+
y: (chartArea.top + chartArea.bottom) / 2
|
|
496
|
+
});
|
|
497
|
+
_this3.chart.update();
|
|
498
|
+
});
|
|
499
|
+
_defineProperty(_this3, "clearMarkerAndTooltip", function () {
|
|
500
|
+
_this3.props.removeMarker('heightprofile');
|
|
501
|
+
if (_this3.chart) {
|
|
502
|
+
_this3.chart.tooltip.setActiveElements([], {
|
|
503
|
+
x: 0,
|
|
504
|
+
y: 0
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
_defineProperty(_this3, "pickPositionCallback", function (pos) {
|
|
509
|
+
var _this3$state$selected4;
|
|
510
|
+
if (!pos || isEmpty(_this3.state.data)) {
|
|
511
|
+
_this3.clearMarkerAndTooltip();
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
var data = _this3.state.data[(_this3$state$selected4 = _this3.state.selectedDatasetIndices[0]) !== null && _this3$state$selected4 !== void 0 ? _this3$state$selected4 : 0];
|
|
515
|
+
|
|
516
|
+
// Find sample index
|
|
517
|
+
var segmentLengths = _this3.props.measurement.segment_lengths;
|
|
518
|
+
var coo = _this3.props.measurement.coordinates;
|
|
519
|
+
var x = 0;
|
|
520
|
+
for (var iSegment = 0; iSegment < coo.length - 1; ++iSegment) {
|
|
521
|
+
if (_this3.pointOnSegment(pos, coo[iSegment], coo[iSegment + 1])) {
|
|
522
|
+
var len = MeasureUtils.computeSegmentLengths([pos, coo[iSegment]], _this3.props.projection, _this3.props.measurement.geodesic)[0];
|
|
523
|
+
x += len;
|
|
524
|
+
break;
|
|
525
|
+
} else {
|
|
526
|
+
x += segmentLengths[iSegment];
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
var k = Math.min(1, x / data.totLength);
|
|
530
|
+
var idx = Math.min(data.y.length - 1, Math.floor(k * _this3.props.samples));
|
|
531
|
+
_this3.showTooltip(idx);
|
|
532
|
+
});
|
|
533
|
+
_defineProperty(_this3, "pointOnSegment", function (q, p1, p2) {
|
|
534
|
+
var tol = 1E-3;
|
|
535
|
+
// Determine whether points lie on same line: cross-product (P2-P1) x (Q - P1) zero?
|
|
536
|
+
var cross = (p2[0] - p1[0]) * (q[1] - p1[1]) - (q[0] - p1[0]) * (p2[1] - p1[1]);
|
|
537
|
+
if (Math.abs(cross) > tol) {
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
// Determine if coordinates lie within segment coordinates
|
|
541
|
+
if (Math.abs(p1[0] - p2[0]) > tol) {
|
|
542
|
+
return p1[0] <= q[0] && q[0] <= p2[0] || p2[0] <= q[0] && q[0] <= p1[0];
|
|
543
|
+
} else {
|
|
544
|
+
return p1[1] <= q[1] && q[1] <= p2[1] || p2[1] <= q[1] && q[1] <= p1[1];
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
_defineProperty(_this3, "exportProfile", function () {
|
|
548
|
+
// const data = this.state.data[this.state.selectedDatasetIndex];
|
|
549
|
+
|
|
550
|
+
_this3.state.selectedDatasetIndices.forEach(function (index) {
|
|
551
|
+
var data = _this3.state.data[index];
|
|
552
|
+
if (!data.x) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
var csv = "";
|
|
556
|
+
csv += "index" + "\t" + "distance" + "\t" + "elevation" + "\n";
|
|
557
|
+
data.x.forEach(function (x, idx) {
|
|
558
|
+
var sample = {
|
|
559
|
+
x: x,
|
|
560
|
+
y: data.y[idx]
|
|
561
|
+
};
|
|
562
|
+
var prec = _this3.props.heightProfilePrecision;
|
|
563
|
+
var distance = Math.round(sample.x * Math.pow(10, prec)) / Math.pow(10, prec);
|
|
564
|
+
var height = Math.round(sample.y * Math.pow(10, prec)) / Math.pow(10, prec);
|
|
565
|
+
csv += String(idx).replace('"', '""') + "\t" + String(distance) + "\t" + String(height) + "\n";
|
|
566
|
+
});
|
|
567
|
+
FileSaver.saveAs(new Blob([csv], {
|
|
568
|
+
type: "text/plain;charset=utf-8"
|
|
569
|
+
}), _this3.state.data.length > 1 ? "heightprofile-".concat(data.dataset, ".csv") : "heightprofile.csv");
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
_this3.chart = null;
|
|
573
|
+
_this3.profilePrintWindow = null;
|
|
574
|
+
return _this3;
|
|
575
|
+
}
|
|
576
|
+
_inherits(HeightProfile, _React$Component);
|
|
577
|
+
return _createClass(HeightProfile, [{
|
|
578
|
+
key: "componentDidUpdate",
|
|
579
|
+
value: function componentDidUpdate(prevProps) {
|
|
580
|
+
if (this.props.measurement.coordinates !== prevProps.measurement.coordinates) {
|
|
581
|
+
if (this.props.measurement.drawing === false && this.props.measurement.geomType === "LineString" && !isEmpty(this.props.measurement.coordinates)) {
|
|
582
|
+
this.queryElevations(this.props.measurement.coordinates, this.props.measurement.segment_lengths, this.props.projection);
|
|
583
|
+
} else if (!isEmpty(this.state.data)) {
|
|
584
|
+
this.setState({
|
|
585
|
+
data: {}
|
|
586
|
+
});
|
|
587
|
+
this.props.changeMeasurementState(_objectSpread(_objectSpread({}, this.props.measurement), {}, {
|
|
588
|
+
pickPositionCallback: null
|
|
589
|
+
}));
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}, {
|
|
594
|
+
key: "queryElevations",
|
|
595
|
+
value: function queryElevations(coordinates, distances, projection) {
|
|
596
|
+
var _this4 = this;
|
|
597
|
+
var reqId = uuidv4();
|
|
598
|
+
this.setState({
|
|
599
|
+
reqId: reqId
|
|
600
|
+
});
|
|
601
|
+
var totLength = this.props.measurement.length;
|
|
602
|
+
getElevationInterface().getProfile(coordinates, distances, projection, this.props.samples).then(function (response) {
|
|
603
|
+
// Request changed
|
|
604
|
+
if (_this4.state.reqId !== reqId) {
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
var elevationsList = response.list;
|
|
608
|
+
if (!elevationsList) {
|
|
609
|
+
elevationsList = [{
|
|
610
|
+
elevations: response,
|
|
611
|
+
dataset: null
|
|
612
|
+
}];
|
|
613
|
+
}
|
|
614
|
+
var data = elevationsList.map(function (entry, index) {
|
|
615
|
+
var elevations = entry.elevations;
|
|
616
|
+
|
|
617
|
+
// Compute x-axis distances and get node points
|
|
618
|
+
var nodes = [];
|
|
619
|
+
var cumDist = distances[0];
|
|
620
|
+
var distIdx = 0;
|
|
621
|
+
var y = elevations;
|
|
622
|
+
var x = y.map(function (value, idx, a) {
|
|
623
|
+
var dist = idx / (a.length - 1) * totLength;
|
|
624
|
+
if (dist >= cumDist) {
|
|
625
|
+
nodes.push({
|
|
626
|
+
x: dist,
|
|
627
|
+
y: y[idx]
|
|
628
|
+
});
|
|
629
|
+
cumDist += distances[++distIdx];
|
|
630
|
+
}
|
|
631
|
+
return dist;
|
|
632
|
+
});
|
|
633
|
+
// First and last node
|
|
634
|
+
nodes.unshift({
|
|
635
|
+
x: x[0],
|
|
636
|
+
y: y[0]
|
|
637
|
+
});
|
|
638
|
+
nodes.push({
|
|
639
|
+
x: x[x.length - 1],
|
|
640
|
+
y: y[y.length - 1]
|
|
641
|
+
});
|
|
642
|
+
var nonZeroElevations = elevations.filter(function (elev) {
|
|
643
|
+
return elev !== 0;
|
|
644
|
+
});
|
|
645
|
+
if (nonZeroElevations.length > 0) {
|
|
646
|
+
return {
|
|
647
|
+
dataset: entry.dataset || "".concat(LocaleUtils.tr("heightprofile.dhmdefaultname"), " ").concat(index + 1),
|
|
648
|
+
x: x,
|
|
649
|
+
y: elevations,
|
|
650
|
+
maxY: Math.max.apply(Math, _toConsumableArray(elevations)),
|
|
651
|
+
minY: Math.min.apply(Math, _toConsumableArray(nonZeroElevations)),
|
|
652
|
+
totLength: totLength,
|
|
653
|
+
nodes: nodes
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
return null;
|
|
657
|
+
}).filter(function (entry) {
|
|
658
|
+
return entry !== null;
|
|
659
|
+
});
|
|
660
|
+
_this4.setState(function (prevState) {
|
|
661
|
+
return {
|
|
662
|
+
reqId: null,
|
|
663
|
+
data: data,
|
|
664
|
+
selectedDatasetIndices: prevState.selectedDatasetIndices.filter(function (i) {
|
|
665
|
+
return i < data.length;
|
|
666
|
+
}) ? prevState.selectedDatasetIndices : [0]
|
|
667
|
+
};
|
|
668
|
+
});
|
|
669
|
+
_this4.props.changeMeasurementState(_objectSpread(_objectSpread({}, _this4.props.measurement), {}, {
|
|
670
|
+
pickPositionCallback: _this4.pickPositionCallback
|
|
671
|
+
}));
|
|
672
|
+
})["catch"](function (error) {
|
|
673
|
+
_this4.setState({
|
|
674
|
+
reqId: null,
|
|
675
|
+
data: error ? {
|
|
676
|
+
error: error
|
|
677
|
+
} : {}
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
}, {
|
|
682
|
+
key: "render",
|
|
683
|
+
value: function render() {
|
|
684
|
+
var _this5 = this;
|
|
685
|
+
if (isEmpty(this.state.data) && !this.state.isloading) {
|
|
686
|
+
return null;
|
|
687
|
+
}
|
|
688
|
+
var extraControls = [{
|
|
689
|
+
icon: 'circle',
|
|
690
|
+
active: this.state.drawnodes,
|
|
691
|
+
callback: function callback() {
|
|
692
|
+
return _this5.setState(function (state) {
|
|
693
|
+
return {
|
|
694
|
+
drawnodes: !state.drawnodes
|
|
695
|
+
};
|
|
696
|
+
});
|
|
697
|
+
},
|
|
698
|
+
title: LocaleUtils.tr("heightprofile.drawnodes")
|
|
699
|
+
}, {
|
|
700
|
+
icon: 'export',
|
|
701
|
+
callback: this.exportProfile,
|
|
702
|
+
title: LocaleUtils.tr("heightprofile.export")
|
|
703
|
+
}, {
|
|
704
|
+
icon: 'print',
|
|
705
|
+
active: this.state.printdialog,
|
|
706
|
+
callback: function callback() {
|
|
707
|
+
return _this5.setState(function (state) {
|
|
708
|
+
return {
|
|
709
|
+
printdialog: !state.printdialog
|
|
710
|
+
};
|
|
711
|
+
});
|
|
712
|
+
},
|
|
713
|
+
title: LocaleUtils.tr("heightprofile.print")
|
|
714
|
+
}];
|
|
715
|
+
return [/*#__PURE__*/React.createElement(ResizeableWindow, {
|
|
716
|
+
dockable: "bottom",
|
|
717
|
+
extraControls: extraControls,
|
|
718
|
+
icon: "line",
|
|
719
|
+
initialHeight: this.props.height,
|
|
720
|
+
initialWidth: 600,
|
|
721
|
+
initiallyDocked: true,
|
|
722
|
+
key: "ProfileDialog",
|
|
723
|
+
onClose: this.onClose,
|
|
724
|
+
onExternalWindowResized: this.resizeChart,
|
|
725
|
+
splitScreenWhenDocked: true,
|
|
726
|
+
title: LocaleUtils.tr("heightprofile.title"),
|
|
727
|
+
usePortal: false
|
|
728
|
+
}, this.state.isloading ? /*#__PURE__*/React.createElement("div", {
|
|
729
|
+
className: "height-profile-loading-indicator",
|
|
730
|
+
role: "body"
|
|
731
|
+
}, /*#__PURE__*/React.createElement(Spinner, {
|
|
732
|
+
className: "spinner"
|
|
733
|
+
}), " ", LocaleUtils.tr("heightprofile.loading")) : this.renderHeightProfile(function (el) {
|
|
734
|
+
_this5.chart = el;
|
|
735
|
+
}, true)), this.state.printdialog ? /*#__PURE__*/React.createElement(HeightProfilePrintDialog, {
|
|
736
|
+
key: "ProfilePrintDialog",
|
|
737
|
+
measurement: this.props.measurement,
|
|
738
|
+
onClose: function onClose() {
|
|
739
|
+
return _this5.setState({
|
|
740
|
+
printdialog: false
|
|
741
|
+
});
|
|
742
|
+
},
|
|
743
|
+
templatePath: this.props.templatePath
|
|
744
|
+
}, this.renderHeightProfile) : null];
|
|
745
|
+
}
|
|
746
|
+
}]);
|
|
747
|
+
}(React.Component);
|
|
748
|
+
_defineProperty(HeightProfile, "propTypes", {
|
|
749
|
+
addMarker: PropTypes.func,
|
|
750
|
+
changeMeasurementState: PropTypes.func,
|
|
751
|
+
/** The height of the height profile widget in pixels. */
|
|
752
|
+
height: PropTypes.number,
|
|
753
|
+
/** The precision of displayed and exported values (0: no decimals, 1: 1 decimal position, etc). */
|
|
754
|
+
heightProfilePrecision: PropTypes.number,
|
|
755
|
+
measurement: PropTypes.object,
|
|
756
|
+
projection: PropTypes.string,
|
|
757
|
+
removeMarker: PropTypes.func,
|
|
758
|
+
/** The number of elevation samples to query. */
|
|
759
|
+
samples: PropTypes.number,
|
|
760
|
+
/** Template location for the height profile print functionality */
|
|
761
|
+
templatePath: PropTypes.string
|
|
762
|
+
});
|
|
763
|
+
_defineProperty(HeightProfile, "defaultProps", {
|
|
764
|
+
samples: 500,
|
|
765
|
+
heightProfilePrecision: 0,
|
|
766
|
+
height: 150,
|
|
767
|
+
templatePath: ":/templates/heightprofileprint.html"
|
|
768
|
+
});
|
|
769
|
+
export default connect(function (state) {
|
|
770
|
+
return {
|
|
771
|
+
measurement: state.measurement,
|
|
772
|
+
projection: state.map.projection
|
|
773
|
+
};
|
|
774
|
+
}, {
|
|
775
|
+
addMarker: addMarker,
|
|
776
|
+
changeMeasurementState: changeMeasurementState,
|
|
777
|
+
removeMarker: removeMarker
|
|
778
|
+
})(HeightProfile);
|