qwc2 2025.10.13 → 2025.10.15
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 +768 -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/utils/EditingUtils.js
CHANGED
|
@@ -1,18 +1,362 @@
|
|
|
1
|
-
var _FeatureCache,_KeyValCache;
|
|
1
|
+
var _FeatureCache, _KeyValCache;
|
|
2
|
+
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); }
|
|
3
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
4
|
+
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."); }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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; } }
|
|
10
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
11
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
18
|
+
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; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
20
|
+
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); }
|
|
21
|
+
/**
|
|
2
22
|
* Copyright 2024 Sourcepole AG
|
|
3
23
|
* All rights reserved.
|
|
4
24
|
*
|
|
5
25
|
* This source code is licensed under the BSD-style license found in the
|
|
6
26
|
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import nearley from 'nearley';
|
|
30
|
+
import toposort from 'toposort';
|
|
31
|
+
import { v5 as uuidv5 } from 'uuid';
|
|
32
|
+
import StandardApp from '../components/StandardApp';
|
|
33
|
+
import ConfigUtils from './ConfigUtils';
|
|
34
|
+
import LocaleUtils from './LocaleUtils';
|
|
35
|
+
import grammar from './expr_grammar/grammar';
|
|
36
|
+
var UUID_NS = '5ae5531d-8e21-4456-b45d-77e9840a5bb7';
|
|
37
|
+
export var FeatureCache = /*#__PURE__*/_createClass(function FeatureCache() {
|
|
38
|
+
_classCallCheck(this, FeatureCache);
|
|
39
|
+
});
|
|
40
|
+
_FeatureCache = FeatureCache;
|
|
41
|
+
_defineProperty(FeatureCache, "store", {});
|
|
42
|
+
_defineProperty(FeatureCache, "requestPromises", {});
|
|
43
|
+
_defineProperty(FeatureCache, "get", function (editIface, layerName, mapCrs, filterExpr) {
|
|
44
|
+
var key = layerName + uuidv5(JSON.stringify(filterExpr !== null && filterExpr !== void 0 ? filterExpr : null), UUID_NS);
|
|
45
|
+
if (key in _FeatureCache.store) {
|
|
46
|
+
return new Promise(function (resolve) {
|
|
47
|
+
return resolve(_FeatureCache.store[key]);
|
|
48
|
+
});
|
|
49
|
+
} else if (key in _FeatureCache.requestPromises) {
|
|
50
|
+
return _FeatureCache.requestPromises[key];
|
|
51
|
+
} else {
|
|
52
|
+
_FeatureCache.requestPromises[key] = new Promise(function (resolve) {
|
|
53
|
+
var _StandardApp$store$ge, _StandardApp$store$ge2;
|
|
54
|
+
var editConfig = (_StandardApp$store$ge = (_StandardApp$store$ge2 = StandardApp.store.getState().theme.current.editConfig) === null || _StandardApp$store$ge2 === void 0 ? void 0 : _StandardApp$store$ge2[layerName]) !== null && _StandardApp$store$ge !== void 0 ? _StandardApp$store$ge : {};
|
|
55
|
+
editIface.getFeatures(editConfig, mapCrs, function (result) {
|
|
56
|
+
if (key in _FeatureCache.requestPromises) {
|
|
57
|
+
if (((result === null || result === void 0 ? void 0 : result.features) || []).length === 1) {
|
|
58
|
+
_FeatureCache.store[key] = result.features[0];
|
|
59
|
+
} else {
|
|
60
|
+
_FeatureCache.store[key] = null;
|
|
61
|
+
}
|
|
62
|
+
if (key in _FeatureCache.requestPromises) {
|
|
63
|
+
resolve(_FeatureCache.store[key]);
|
|
64
|
+
delete _FeatureCache.requestPromises[key];
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
resolve(null);
|
|
68
|
+
}
|
|
69
|
+
}, null, filterExpr);
|
|
70
|
+
});
|
|
71
|
+
return _FeatureCache.requestPromises[key];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
_defineProperty(FeatureCache, "getSync", function (editIface, layerName, mapCrs, filterExpr) {
|
|
75
|
+
var promises = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
76
|
+
var key = layerName + uuidv5(JSON.stringify(filterExpr !== null && filterExpr !== void 0 ? filterExpr : null), UUID_NS);
|
|
77
|
+
if (key in _FeatureCache.store) {
|
|
78
|
+
return _FeatureCache.store[key];
|
|
79
|
+
} else {
|
|
80
|
+
promises.push(_FeatureCache.get(editIface, layerName, mapCrs, filterExpr));
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
_defineProperty(FeatureCache, "clear", function () {
|
|
85
|
+
_FeatureCache.store = {};
|
|
86
|
+
_FeatureCache.requests = new Set();
|
|
87
|
+
});
|
|
88
|
+
export var KeyValCache = /*#__PURE__*/_createClass(function KeyValCache() {
|
|
89
|
+
_classCallCheck(this, KeyValCache);
|
|
90
|
+
});
|
|
91
|
+
_KeyValCache = KeyValCache;
|
|
92
|
+
_defineProperty(KeyValCache, "store", {});
|
|
93
|
+
_defineProperty(KeyValCache, "requestPromises", {});
|
|
94
|
+
_defineProperty(KeyValCache, "get", function (editIface, keyvalrel, filterExpr) {
|
|
95
|
+
var key = keyvalrel + uuidv5(JSON.stringify(filterExpr !== null && filterExpr !== void 0 ? filterExpr : null), UUID_NS);
|
|
96
|
+
if (key in _KeyValCache.store) {
|
|
97
|
+
return new Promise(function (resolve) {
|
|
98
|
+
return resolve(_KeyValCache.store[key]);
|
|
99
|
+
});
|
|
100
|
+
} else if (key in _KeyValCache.requestPromises) {
|
|
101
|
+
return _KeyValCache.requestPromises[key];
|
|
102
|
+
} else {
|
|
103
|
+
_KeyValCache.requestPromises[key] = new Promise(function (resolve) {
|
|
104
|
+
editIface.getKeyValues(keyvalrel, function (result) {
|
|
105
|
+
if (key in _KeyValCache.requestPromises) {
|
|
106
|
+
var dataSet = keyvalrel.split(":")[0];
|
|
107
|
+
if (result.keyvalues && result.keyvalues[dataSet]) {
|
|
108
|
+
var values = result.keyvalues[dataSet].map(function (entry) {
|
|
109
|
+
return {
|
|
110
|
+
value: entry.key,
|
|
111
|
+
label: entry.value
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
_KeyValCache.store[key] = values;
|
|
115
|
+
} else {
|
|
116
|
+
_KeyValCache.store[key] = [];
|
|
117
|
+
}
|
|
118
|
+
resolve(_KeyValCache.store[key]);
|
|
119
|
+
delete _KeyValCache.requestPromises[key];
|
|
120
|
+
} else {
|
|
121
|
+
resolve([]);
|
|
122
|
+
}
|
|
123
|
+
}, filterExpr ? [filterExpr] : null);
|
|
124
|
+
});
|
|
125
|
+
return _KeyValCache.requestPromises[key];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
_defineProperty(KeyValCache, "getSync", function (editIface, keyvalrel, filterExpr) {
|
|
129
|
+
var promises = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
130
|
+
var key = keyvalrel + uuidv5(JSON.stringify(filterExpr !== null && filterExpr !== void 0 ? filterExpr : null), UUID_NS);
|
|
131
|
+
if (key in _KeyValCache.store) {
|
|
132
|
+
return _KeyValCache.store[key];
|
|
133
|
+
} else {
|
|
134
|
+
promises.push(_KeyValCache.get(editIface, keyvalrel, filterExpr));
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
_defineProperty(KeyValCache, "clear", function () {
|
|
139
|
+
_KeyValCache.store = {};
|
|
140
|
+
_KeyValCache.requestPromises = {};
|
|
141
|
+
});
|
|
142
|
+
function _representValue(attr, editConfig, editIface, promises) {
|
|
143
|
+
var _window$qwc2Expressio, _field$constraints;
|
|
144
|
+
// Resolve kvrel
|
|
145
|
+
var field = (editConfig.fields || []).find(function (f) {
|
|
146
|
+
return f.id === attr;
|
|
147
|
+
});
|
|
148
|
+
var value = (_window$qwc2Expressio = window.qwc2ExpressionParserContext.feature) === null || _window$qwc2Expressio === void 0 || (_window$qwc2Expressio = _window$qwc2Expressio.properties) === null || _window$qwc2Expressio === void 0 ? void 0 : _window$qwc2Expressio[attr];
|
|
149
|
+
var keyvalrel = field === null || field === void 0 || (_field$constraints = field.constraints) === null || _field$constraints === void 0 ? void 0 : _field$constraints.keyvalrel;
|
|
150
|
+
if (!keyvalrel) {
|
|
151
|
+
return value;
|
|
152
|
+
}
|
|
153
|
+
var keyvals = KeyValCache.getSync(editIface, keyvalrel, null, promises).reduce(function (res, entry) {
|
|
154
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, entry.value, entry.label));
|
|
155
|
+
}, {});
|
|
156
|
+
if (field.constraints.allowMulti) {
|
|
157
|
+
return '{' + _toConsumableArray(new Set(JSON.parse('[' + value.slice(1, -1) + ']'))).map(function (x) {
|
|
158
|
+
var _keyvals$x;
|
|
159
|
+
return (_keyvals$x = keyvals[x]) !== null && _keyvals$x !== void 0 ? _keyvals$x : x;
|
|
160
|
+
}).join(", ") + '}';
|
|
161
|
+
} else {
|
|
162
|
+
var _keyvals$value;
|
|
163
|
+
return (_keyvals$value = keyvals[value]) !== null && _keyvals$value !== void 0 ? _keyvals$value : value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
export function parseExpression(expr, feature, editConfig, editIface, mapPrefix, mapCrs, reevaluateCallback) {
|
|
167
|
+
var asFilter = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
168
|
+
var reevaluate = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
169
|
+
var parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar));
|
|
170
|
+
var promises = [];
|
|
171
|
+
window.qwc2ExpressionParserContext = {
|
|
172
|
+
feature: feature,
|
|
173
|
+
getFeature: function getFeature(layerName, attr, value) {
|
|
174
|
+
return FeatureCache.getSync(editIface, layerName, mapCrs, [[attr, '=', value]], promises);
|
|
175
|
+
},
|
|
176
|
+
representValue: function representValue(attr) {
|
|
177
|
+
return _representValue(attr, editConfig, editIface, promises);
|
|
178
|
+
},
|
|
179
|
+
asFilter: asFilter,
|
|
180
|
+
username: ConfigUtils.getConfigProp("username"),
|
|
181
|
+
layer: editConfig.layerName,
|
|
182
|
+
projection: mapCrs,
|
|
183
|
+
mapPrefix: mapPrefix,
|
|
184
|
+
lang: LocaleUtils.lang()
|
|
185
|
+
};
|
|
186
|
+
var result = null;
|
|
187
|
+
try {
|
|
188
|
+
parser.feed(expr.replace(/\n/, ' '));
|
|
189
|
+
result = parser.results[0];
|
|
190
|
+
} catch (e) {
|
|
191
|
+
/* eslint-disable-next-line */
|
|
192
|
+
console.warn("Failed to evaluate expression " + expr.replace(/\n/, ' '));
|
|
193
|
+
}
|
|
194
|
+
delete window.qwc2ExpressionParserContext;
|
|
195
|
+
if (promises.length > 0) {
|
|
196
|
+
// Expression evaluation is incomplete due to pending feature requests, reevaluate when promises are resolved
|
|
197
|
+
Promise.all(promises).then(function () {
|
|
198
|
+
return parseExpression(expr, feature, editConfig, editIface, mapPrefix, mapCrs, reevaluateCallback, asFilter, true);
|
|
199
|
+
});
|
|
200
|
+
return null;
|
|
201
|
+
} else {
|
|
202
|
+
if (reevaluate) {
|
|
203
|
+
reevaluateCallback();
|
|
204
|
+
}
|
|
205
|
+
if (asFilter) {
|
|
206
|
+
result = [result];
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
export function parseExpressionsAsync(fieldExpressions, feature, editConfig, editIface, mapPrefix, mapCrs, asFilter) {
|
|
212
|
+
var promises = [];
|
|
213
|
+
return new Promise(function (resolve) {
|
|
214
|
+
var newfeature = _objectSpread(_objectSpread({}, feature), {}, {
|
|
215
|
+
properties: _objectSpread({}, feature.properties)
|
|
216
|
+
});
|
|
217
|
+
window.qwc2ExpressionParserContext = {
|
|
218
|
+
feature: newfeature,
|
|
219
|
+
getFeature: function getFeature(layerName, attr, value) {
|
|
220
|
+
return FeatureCache.getSync(editIface, layerName, mapCrs, [[attr, '=', value]], promises);
|
|
221
|
+
},
|
|
222
|
+
representValue: function representValue(attr) {
|
|
223
|
+
return _representValue(attr, editConfig, editIface, promises);
|
|
224
|
+
},
|
|
225
|
+
asFilter: asFilter,
|
|
226
|
+
username: ConfigUtils.getConfigProp("username"),
|
|
227
|
+
layer: editConfig.layerName,
|
|
228
|
+
projection: mapCrs,
|
|
229
|
+
mapPrefix: mapPrefix,
|
|
230
|
+
lang: LocaleUtils.lang()
|
|
231
|
+
};
|
|
232
|
+
var results = fieldExpressions.reduce(function (res, _ref) {
|
|
233
|
+
var field = _ref.field,
|
|
234
|
+
expression = _ref.expression;
|
|
235
|
+
var parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar));
|
|
236
|
+
try {
|
|
237
|
+
parser.feed(expression.replace(/\n/, ' '));
|
|
238
|
+
// NOTE: include intermediate results in next context feature
|
|
239
|
+
newfeature.properties[field] = parser.results[0];
|
|
240
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, field, parser.results[0]));
|
|
241
|
+
} catch (e) {
|
|
242
|
+
/* eslint-disable-next-line */
|
|
243
|
+
console.warn("Failed to evaluate expression " + expression.replace(/\n/, ' '));
|
|
244
|
+
return res;
|
|
245
|
+
}
|
|
246
|
+
}, {});
|
|
247
|
+
delete window.qwc2ExpressionParserContext;
|
|
248
|
+
if (promises.length > 0) {
|
|
249
|
+
// Expression evaluation is incomplete due to pending feature requests, reevaluate when promises are resolved
|
|
250
|
+
Promise.all(promises).then(function () {
|
|
251
|
+
parseExpressionsAsync(fieldExpressions, newfeature, editConfig, editIface, mapPrefix, mapCrs, asFilter).then(function (results2) {
|
|
252
|
+
return resolve(results2);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
} else {
|
|
256
|
+
resolve(results);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
var FeatureTemplateFactories = {};
|
|
261
|
+
export function setFeatureTemplateFactory(dataset, factory) {
|
|
262
|
+
FeatureTemplateFactories[dataset] = factory;
|
|
263
|
+
}
|
|
264
|
+
export function getFeatureTemplate(editConfig, feature, editIface, mapPrefix, mapCrs, callback) {
|
|
265
|
+
if (editConfig.editDataset in FeatureTemplateFactories) {
|
|
266
|
+
feature = FeatureTemplateFactories[editConfig.editDataset](feature);
|
|
267
|
+
}
|
|
268
|
+
// Apply default values
|
|
269
|
+
var defaultFieldExpressions = editConfig.fields.reduce(function (res, field) {
|
|
270
|
+
if (field.defaultValue) {
|
|
271
|
+
return [].concat(_toConsumableArray(res), [{
|
|
272
|
+
field: field.id,
|
|
273
|
+
expression: field.defaultValue.replace(/^expr:/, '')
|
|
274
|
+
}]);
|
|
275
|
+
}
|
|
276
|
+
return res;
|
|
277
|
+
}, []);
|
|
278
|
+
FeatureCache.clear();
|
|
279
|
+
parseExpressionsAsync(defaultFieldExpressions, feature, editConfig, editIface, mapPrefix, mapCrs).then(function (result) {
|
|
280
|
+
// Adjust values based on field type
|
|
281
|
+
editConfig.fields.forEach(function (field) {
|
|
282
|
+
if (field.id in result && field.type === "date") {
|
|
283
|
+
result[field.id] = result[field.id].split("T")[0];
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
callback(_objectSpread(_objectSpread({}, feature), {}, {
|
|
287
|
+
properties: _objectSpread(_objectSpread({}, feature.properties), result)
|
|
288
|
+
}));
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
export function computeExpressionFields(editConfig, feature, editIface, mapCrs, callback) {
|
|
292
|
+
// Collect field expressions and dependencies
|
|
293
|
+
var dependencies = {};
|
|
294
|
+
var fieldExpressions = editConfig.fields.reduce(function (res, field) {
|
|
295
|
+
if (field.expression) {
|
|
296
|
+
var matches = _toConsumableArray(field.expression.matchAll(/"([^"]+)"/g)).map(function (m) {
|
|
297
|
+
return m[1];
|
|
298
|
+
});
|
|
299
|
+
dependencies[field.id] = _toConsumableArray(new Set(matches));
|
|
300
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, field.id, field.expression));
|
|
301
|
+
}
|
|
302
|
+
return res;
|
|
303
|
+
}, {});
|
|
304
|
+
// Topologically sort expressions so that fields depending on other fields are evaluated later
|
|
305
|
+
var edges = [];
|
|
306
|
+
var roots = [];
|
|
307
|
+
Object.entries(dependencies).forEach(function (_ref2) {
|
|
308
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
309
|
+
parent = _ref3[0],
|
|
310
|
+
children = _ref3[1];
|
|
311
|
+
if (children.length > 0) {
|
|
312
|
+
children.forEach(function (child) {
|
|
313
|
+
return edges.push([child, parent]);
|
|
314
|
+
});
|
|
315
|
+
} else {
|
|
316
|
+
roots.push(parent);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
try {
|
|
320
|
+
var sortededges = toposort(edges);
|
|
321
|
+
fieldExpressions = roots.concat(sortededges).reduce(function (res, field) {
|
|
322
|
+
if (field in fieldExpressions) {
|
|
323
|
+
return [].concat(_toConsumableArray(res), [{
|
|
324
|
+
field: field,
|
|
325
|
+
expression: fieldExpressions[field]
|
|
326
|
+
}]);
|
|
327
|
+
} else {
|
|
328
|
+
return res;
|
|
329
|
+
}
|
|
330
|
+
}, []);
|
|
331
|
+
} catch (e) {
|
|
332
|
+
/* eslint-disable-next-line */
|
|
333
|
+
console.warn("Failed to sort expressions, they probably contain cyclic dependencies");
|
|
334
|
+
fieldExpressions = Object.entries(fieldExpressions).map(function (res, _ref4) {
|
|
335
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
336
|
+
field = _ref5[0],
|
|
337
|
+
expression = _ref5[1];
|
|
338
|
+
return [].concat(_toConsumableArray(res), [{
|
|
339
|
+
field: field,
|
|
340
|
+
expression: expression
|
|
341
|
+
}]);
|
|
342
|
+
}, {});
|
|
343
|
+
}
|
|
344
|
+
// Evaluate expressions
|
|
345
|
+
FeatureCache.clear();
|
|
346
|
+
var mapPrefix = (editConfig.editDataset.match(/^[^.]+\./) || [""])[0];
|
|
347
|
+
parseExpressionsAsync(fieldExpressions, feature, editConfig, editIface, mapPrefix, mapCrs).then(function (result) {
|
|
348
|
+
// Adjust values based on field type
|
|
349
|
+
editConfig.fields.forEach(function (field) {
|
|
350
|
+
var _field$constraints2;
|
|
351
|
+
if (!((_field$constraints2 = field.constraints) !== null && _field$constraints2 !== void 0 && _field$constraints2.hidden)) {
|
|
352
|
+
// Remove hidden fields from result
|
|
353
|
+
delete result[field.id];
|
|
354
|
+
} else if (field.id in result && field.type === "date") {
|
|
355
|
+
result[field.id] = result[field.id].split("T")[0];
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
callback(_objectSpread(_objectSpread({}, feature), {}, {
|
|
359
|
+
properties: _objectSpread(_objectSpread({}, feature.properties), result)
|
|
360
|
+
}));
|
|
361
|
+
});
|
|
362
|
+
}
|
|
@@ -4,26 +4,87 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import axios from "axios";
|
|
10
|
+
import ConfigUtils from "./ConfigUtils";
|
|
11
|
+
|
|
12
|
+
/**
|
|
8
13
|
* Interface for querying elevations/height profiles
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
*/
|
|
15
|
+
var ElevationInterface = {
|
|
16
|
+
/**
|
|
17
|
+
* Query the elevation at the specified position
|
|
18
|
+
*
|
|
19
|
+
* * `pos`: query position, as tuple `[x, y]`
|
|
20
|
+
* * `crs`: CRS of the query position, as an EPSG string
|
|
21
|
+
*
|
|
22
|
+
* Returns: a promise which resolves to an elevation value (in meteres)
|
|
23
|
+
* or an object with a `list` property containing an array of objects with
|
|
24
|
+
* `elevation` and `dataset` properties, if multiple datasets are available.
|
|
25
|
+
*/
|
|
26
|
+
getElevation: function getElevation(pos, crs) {
|
|
27
|
+
return new Promise(function (resolve, reject) {
|
|
28
|
+
var serviceUrl = ConfigUtils.getConfigProp("elevationServiceUrl", null, "").replace(/\/$/, '');
|
|
29
|
+
if (!serviceUrl) {
|
|
30
|
+
reject(null);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
axios.get(serviceUrl + '/getelevation', {
|
|
34
|
+
params: {
|
|
35
|
+
pos: pos.join(","),
|
|
36
|
+
crs: crs
|
|
37
|
+
}
|
|
38
|
+
}).then(function (response) {
|
|
39
|
+
var _response$data$elevat;
|
|
40
|
+
resolve((_response$data$elevat = response.data.elevation) !== null && _response$data$elevat !== void 0 ? _response$data$elevat : {
|
|
41
|
+
list: response.data.elevation_list
|
|
42
|
+
});
|
|
43
|
+
})["catch"](function (e) {
|
|
44
|
+
reject(String(e));
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Query the elevation profile along the specified line
|
|
50
|
+
*
|
|
51
|
+
* * `coordinates`: line coordinates `[[x1, y1], [x2, y2], ...]`
|
|
52
|
+
* * `distances`: distances of the line segments `[dist1, dist2, ...]`
|
|
53
|
+
* * `crs`: CRS of the line coordinates, as an EPSG string
|
|
54
|
+
* * `samples`: the number of samples
|
|
55
|
+
*
|
|
56
|
+
* Returns a promise which resolves to the elevation values `[z1, z2, ...]`
|
|
57
|
+
* or an object with a `list` property containing an array of objects with
|
|
58
|
+
* `elevations` and `dataset` properties, if multiple datasets are available.
|
|
59
|
+
*/
|
|
60
|
+
getProfile: function getProfile(coordinates, distances, crs, samples) {
|
|
61
|
+
return new Promise(function (resolve, reject) {
|
|
62
|
+
var serviceUrl = ConfigUtils.getConfigProp("elevationServiceUrl", null, "").replace(/\/$/, '');
|
|
63
|
+
if (!serviceUrl) {
|
|
64
|
+
reject(null);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
axios.post(serviceUrl + '/getheightprofile', {
|
|
68
|
+
coordinates: coordinates,
|
|
69
|
+
distances: distances,
|
|
70
|
+
projection: crs,
|
|
71
|
+
samples: samples
|
|
72
|
+
}).then(function (response) {
|
|
73
|
+
resolve(response.data.elevations || {
|
|
74
|
+
list: response.data.elevations_list
|
|
75
|
+
});
|
|
76
|
+
})["catch"](function (e) {
|
|
77
|
+
var _e$response;
|
|
78
|
+
var error = (_e$response = e.response) !== null && _e$response !== void 0 && (_e$response = _e$response.data) !== null && _e$response !== void 0 && _e$response.error ? e.response.data.error : e;
|
|
79
|
+
/* eslint-disable-next-line */
|
|
80
|
+
console.log("Query failed: " + error);
|
|
81
|
+
reject(String(error));
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
export function getElevationInterface() {
|
|
87
|
+
var _window$QWC2Elevation;
|
|
88
|
+
return (_window$QWC2Elevation = window.QWC2ElevationInterface) !== null && _window$QWC2Elevation !== void 0 ? _window$QWC2Elevation : ElevationInterface;
|
|
89
|
+
}
|
|
90
|
+
;
|