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/SearchProviders.js
CHANGED
|
@@ -1,24 +1,727 @@
|
|
|
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 _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
3
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
4
|
+
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."); }
|
|
5
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
6
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
7
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
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 _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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
16
|
+
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); } }
|
|
17
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
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 2016-2021 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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import axios from 'axios';
|
|
30
|
+
import yaml from 'js-yaml';
|
|
31
|
+
import polygonIntersectTest from 'polygon-intersect-test';
|
|
32
|
+
import { LayerRole } from '../actions/layers';
|
|
33
|
+
import ConfigUtils from './ConfigUtils';
|
|
34
|
+
import CoordinatesUtils from './CoordinatesUtils';
|
|
35
|
+
import IdentifyUtils from './IdentifyUtils';
|
|
36
|
+
import LayerUtils from './LayerUtils';
|
|
37
|
+
import LocaleUtils from './LocaleUtils';
|
|
38
|
+
import VectorLayerUtils from './VectorLayerUtils';
|
|
39
|
+
export var SearchResultType = {
|
|
40
|
+
PLACE: 0,
|
|
41
|
+
THEMELAYER: 1,
|
|
42
|
+
THEME: 2,
|
|
43
|
+
EXTERNALLAYER: 3,
|
|
44
|
+
TASK: 4
|
|
45
|
+
};
|
|
46
|
+
function coordinatesSearch(text, searchParams, callback) {
|
|
47
|
+
var displaycrs = searchParams.displaycrs || "EPSG:4326";
|
|
48
|
+
var matches = text.replace(/[’']/g, "").match(/^\s*([+-]?\d+\.?\d*)[,\s]\s*([+-]?\d+\.?\d*)\s*$/);
|
|
49
|
+
var items = [];
|
|
50
|
+
if (matches && matches.length >= 3) {
|
|
51
|
+
var x = parseFloat(matches[1]);
|
|
52
|
+
var y = parseFloat(matches[2]);
|
|
53
|
+
if (displaycrs !== "EPSG:4326") {
|
|
54
|
+
items.push({
|
|
55
|
+
id: "coord0",
|
|
56
|
+
text: x + ", " + y + " (" + displaycrs + ")",
|
|
57
|
+
x: x,
|
|
58
|
+
y: y,
|
|
59
|
+
crs: displaycrs,
|
|
60
|
+
bbox: [x, y, x, y]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (x >= -180 && x <= 180 && y >= -90 && y <= 90) {
|
|
64
|
+
var title = Math.abs(x) + (x >= 0 ? "°E" : "°W") + ", " + Math.abs(y) + (y >= 0 ? "°N" : "°S");
|
|
65
|
+
items.push({
|
|
66
|
+
id: "coord" + items.length,
|
|
67
|
+
text: title,
|
|
68
|
+
x: x,
|
|
69
|
+
y: y,
|
|
70
|
+
crs: "EPSG:4326",
|
|
71
|
+
bbox: [x, y, x, y]
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (x >= -90 && x <= 90 && y >= -180 && y <= 180 && x !== y) {
|
|
75
|
+
var _title = Math.abs(y) + (y >= 0 ? "°E" : "°W") + ", " + Math.abs(x) + (x >= 0 ? "°N" : "°S");
|
|
76
|
+
items.push({
|
|
77
|
+
id: "coord" + items.length,
|
|
78
|
+
text: _title,
|
|
79
|
+
x: y,
|
|
80
|
+
y: x,
|
|
81
|
+
crs: "EPSG:4326",
|
|
82
|
+
bbox: [y, x, y, x]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
var results = [];
|
|
87
|
+
if (items.length > 0) {
|
|
88
|
+
results.push({
|
|
89
|
+
id: "coords",
|
|
90
|
+
titlemsgid: LocaleUtils.trmsg("search.coordinates"),
|
|
91
|
+
type: SearchResultType.PLACE,
|
|
92
|
+
items: items
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
callback({
|
|
96
|
+
results: results
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** ************************************************************************ **/
|
|
101
|
+
var NominatimSearch = /*#__PURE__*/function () {
|
|
102
|
+
function NominatimSearch() {
|
|
103
|
+
_classCallCheck(this, NominatimSearch);
|
|
104
|
+
}
|
|
105
|
+
return _createClass(NominatimSearch, null, [{
|
|
106
|
+
key: "search",
|
|
107
|
+
value: function search(text, searchParams, callback) {
|
|
108
|
+
var viewboxParams = {};
|
|
109
|
+
if (searchParams.filterBBox) {
|
|
110
|
+
viewboxParams.viewbox = CoordinatesUtils.reprojectBbox(searchParams.filterBBox, searchParams.mapcrs, "EPSG:4326").join(",");
|
|
111
|
+
viewboxParams.bounded = 1;
|
|
112
|
+
}
|
|
113
|
+
axios.get("https://nominatim.openstreetmap.org/search", {
|
|
114
|
+
params: _objectSpread(_objectSpread({
|
|
115
|
+
'q': text,
|
|
116
|
+
'addressdetails': 1,
|
|
117
|
+
'polygon_geojson': 1,
|
|
118
|
+
'limit': 20,
|
|
119
|
+
'format': 'json',
|
|
120
|
+
'accept-language': searchParams.lang
|
|
121
|
+
}, searchParams.cfgParams || {}), viewboxParams)
|
|
122
|
+
}).then(function (response) {
|
|
123
|
+
var locale = searchParams.lang;
|
|
124
|
+
if (NominatimSearch.TRANSLATIONS[locale] === undefined) {
|
|
125
|
+
NominatimSearch.TRANSLATIONS[locale] = {
|
|
126
|
+
promise: NominatimSearch.loadLocale(locale)
|
|
127
|
+
};
|
|
128
|
+
NominatimSearch.TRANSLATIONS[locale].promise.then(function () {
|
|
129
|
+
NominatimSearch.parseResults(response.data, NominatimSearch.TRANSLATIONS[locale].strings, callback);
|
|
130
|
+
});
|
|
131
|
+
} else if (NominatimSearch.TRANSLATIONS[locale].promise) {
|
|
132
|
+
NominatimSearch.TRANSLATIONS[locale].promise.then(function () {
|
|
133
|
+
NominatimSearch.parseResults(response.data, NominatimSearch.TRANSLATIONS[locale].strings, callback);
|
|
134
|
+
});
|
|
135
|
+
} else if (NominatimSearch.TRANSLATIONS[locale].strings) {
|
|
136
|
+
NominatimSearch.parseResults(response.data, NominatimSearch.TRANSLATIONS[locale].strings, callback);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "parseResults",
|
|
142
|
+
value: function parseResults(obj, translations, callback) {
|
|
143
|
+
var results = [];
|
|
144
|
+
var groups = {};
|
|
145
|
+
var groupcounter = 0;
|
|
146
|
+
(obj || []).map(function (entry) {
|
|
147
|
+
if (!(entry["class"] in groups)) {
|
|
148
|
+
var title = entry.type;
|
|
149
|
+
try {
|
|
150
|
+
title = translations[entry["class"]][entry.type] || entry.type;
|
|
151
|
+
} catch (e) {
|
|
152
|
+
/* pass */
|
|
153
|
+
}
|
|
154
|
+
groups[entry["class"]] = {
|
|
155
|
+
id: "nominatimgroup" + groupcounter++,
|
|
156
|
+
// capitalize class
|
|
157
|
+
title: title,
|
|
158
|
+
type: SearchResultType.PLACE,
|
|
159
|
+
items: []
|
|
160
|
+
};
|
|
161
|
+
results.push(groups[entry["class"]]);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// shorten display_name
|
|
165
|
+
var text = entry.display_name.split(', ').slice(0, 3).join(', ');
|
|
166
|
+
// map label
|
|
167
|
+
var label = text;
|
|
168
|
+
|
|
169
|
+
// collect address fields
|
|
170
|
+
var address = [];
|
|
171
|
+
if (entry.address.town) {
|
|
172
|
+
address.push(entry.address.town);
|
|
173
|
+
}
|
|
174
|
+
if (entry.address.city) {
|
|
175
|
+
address.push(entry.address.city);
|
|
176
|
+
}
|
|
177
|
+
if (entry.address.state) {
|
|
178
|
+
address.push(entry.address.state);
|
|
179
|
+
}
|
|
180
|
+
if (entry.address.country) {
|
|
181
|
+
address.push(entry.address.country);
|
|
182
|
+
}
|
|
183
|
+
if (address.length > 0) {
|
|
184
|
+
text += "<br/><i>" + address.join(', ') + "</i>";
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// reorder coords from [miny, maxy, minx, maxx] to [minx, miny, maxx, maxy]
|
|
188
|
+
var b = entry.boundingbox.map(function (coord) {
|
|
189
|
+
return parseFloat(coord);
|
|
190
|
+
});
|
|
191
|
+
var bbox = [b[2], b[0], b[3], b[1]];
|
|
192
|
+
groups[entry["class"]].items.push({
|
|
193
|
+
id: entry.place_id,
|
|
194
|
+
// shorten display_name
|
|
195
|
+
text: text,
|
|
196
|
+
label: label,
|
|
197
|
+
bbox: bbox,
|
|
198
|
+
geometry: entry.geojson,
|
|
199
|
+
x: 0.5 * (bbox[0] + bbox[2]),
|
|
200
|
+
y: 0.5 * (bbox[1] + bbox[3]),
|
|
201
|
+
crs: "EPSG:4326",
|
|
202
|
+
provider: "nominatim"
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
callback({
|
|
206
|
+
results: results
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}, {
|
|
210
|
+
key: "loadLocale",
|
|
211
|
+
value: function loadLocale(locale) {
|
|
212
|
+
return new Promise(function (resolve) {
|
|
213
|
+
axios.get('https://raw.githubusercontent.com/openstreetmap/openstreetmap-website/master/config/locales/' + locale + '.yml').then(function (resp2) {
|
|
214
|
+
NominatimSearch.TRANSLATIONS[locale] = {
|
|
215
|
+
strings: NominatimSearch.parseLocale(resp2.data, locale)
|
|
216
|
+
};
|
|
217
|
+
resolve(true);
|
|
218
|
+
})["catch"](function () {
|
|
219
|
+
NominatimSearch.TRANSLATIONS[locale] = {
|
|
220
|
+
promise: axios.get('https://raw.githubusercontent.com/openstreetmap/openstreetmap-website/master/config/locales/' + locale.slice(0, 2) + '.yml').then(function (resp3) {
|
|
221
|
+
NominatimSearch.TRANSLATIONS[locale] = {
|
|
222
|
+
strings: NominatimSearch.parseLocale(resp3.data, locale.slice(0, 2))
|
|
223
|
+
};
|
|
224
|
+
resolve(true);
|
|
225
|
+
})["catch"](function () {
|
|
226
|
+
NominatimSearch.TRANSLATIONS[locale] = {
|
|
227
|
+
strings: {}
|
|
228
|
+
};
|
|
229
|
+
resolve(true);
|
|
230
|
+
})
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}, {
|
|
236
|
+
key: "parseLocale",
|
|
237
|
+
value: function parseLocale(data, locale) {
|
|
238
|
+
var doc = yaml.load(data, {
|
|
239
|
+
json: true
|
|
240
|
+
});
|
|
241
|
+
try {
|
|
242
|
+
return doc[locale].geocoder.search_osm_nominatim.prefix;
|
|
243
|
+
} catch (e) {
|
|
244
|
+
return {};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}]);
|
|
248
|
+
}();
|
|
249
|
+
/** ************************************************************************ **/
|
|
250
|
+
_defineProperty(NominatimSearch, "TRANSLATIONS", {});
|
|
251
|
+
var QgisSearch = /*#__PURE__*/function () {
|
|
252
|
+
function QgisSearch() {
|
|
253
|
+
_classCallCheck(this, QgisSearch);
|
|
254
|
+
}
|
|
255
|
+
return _createClass(QgisSearch, null, [{
|
|
256
|
+
key: "search",
|
|
257
|
+
value: function search(text, searchParams, callback) {
|
|
258
|
+
var filter = _objectSpread({}, searchParams.cfgParams.expression);
|
|
259
|
+
var values = {
|
|
260
|
+
TEXT: text
|
|
261
|
+
};
|
|
262
|
+
var params = {
|
|
263
|
+
SERVICE: 'WMS',
|
|
264
|
+
VERSION: searchParams.theme.version,
|
|
265
|
+
REQUEST: 'GetFeatureInfo',
|
|
266
|
+
CRS: searchParams.theme.mapCrs,
|
|
267
|
+
WIDTH: 100,
|
|
268
|
+
HEIGHT: 100,
|
|
269
|
+
LAYERS: [],
|
|
270
|
+
FILTER: [],
|
|
271
|
+
WITH_MAPTIP: false,
|
|
272
|
+
WITH_GEOMETRY: true,
|
|
273
|
+
feature_count: searchParams.cfgParams.featureCount || 100,
|
|
274
|
+
info_format: 'text/xml'
|
|
275
|
+
};
|
|
276
|
+
Object.keys(filter).forEach(function (layer) {
|
|
277
|
+
Object.entries(values).forEach(function (_ref) {
|
|
278
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
279
|
+
key = _ref2[0],
|
|
280
|
+
value = _ref2[1];
|
|
281
|
+
filter[layer] = filter[layer].replaceAll("$".concat(key, "$"), value.replace("'", "\\'"));
|
|
282
|
+
});
|
|
283
|
+
params.LAYERS.push(layer);
|
|
284
|
+
params.FILTER.push(layer + ":" + filter[layer]);
|
|
285
|
+
});
|
|
286
|
+
params.QUERY_LAYERS = params.LAYERS = params.LAYERS.join(",");
|
|
287
|
+
params.FILTER = params.FILTER.join(";");
|
|
288
|
+
axios.get(searchParams.theme.featureInfoUrl, {
|
|
289
|
+
params: params
|
|
290
|
+
}).then(function (response) {
|
|
291
|
+
callback(QgisSearch.searchResults(IdentifyUtils.parseResponse(response.data, searchParams.theme, 'text/xml', null, searchParams.mapcrs), searchParams.cfgParams.title, searchParams.cfgParams.resultTitle));
|
|
292
|
+
})["catch"](function () {
|
|
293
|
+
callback({
|
|
294
|
+
results: []
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}, {
|
|
299
|
+
key: "searchResults",
|
|
300
|
+
value: function searchResults(features, title, resultTitle) {
|
|
301
|
+
var results = [];
|
|
302
|
+
Object.entries(features).forEach(function (_ref3) {
|
|
303
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
304
|
+
layername = _ref4[0],
|
|
305
|
+
layerfeatures = _ref4[1];
|
|
306
|
+
var items = layerfeatures.map(function (feature) {
|
|
307
|
+
if (!feature.bbox || !feature.geometry) {
|
|
308
|
+
/* eslint-disable-next-line */
|
|
309
|
+
console.warn("Skipping result without geometry");
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
var values = _objectSpread(_objectSpread({}, feature.properties), {}, {
|
|
313
|
+
id: feature.id,
|
|
314
|
+
layername: layername
|
|
315
|
+
});
|
|
316
|
+
return {
|
|
317
|
+
id: "qgis." + layername + "." + feature.id,
|
|
318
|
+
text: resultTitle ? resultTitle.replace(/{([^}]+)}/g, function (match) {
|
|
319
|
+
return values[match.slice(1, -1)];
|
|
320
|
+
}) : feature.displayname,
|
|
321
|
+
x: 0.5 * (feature.bbox[0] + feature.bbox[2]),
|
|
322
|
+
y: 0.5 * (feature.bbox[1] + feature.bbox[3]),
|
|
323
|
+
crs: feature.crs,
|
|
324
|
+
bbox: feature.bbox,
|
|
325
|
+
geometry: feature.geometry,
|
|
326
|
+
layername: layername
|
|
327
|
+
};
|
|
328
|
+
}).filter(Boolean);
|
|
329
|
+
results.push({
|
|
330
|
+
id: "qgis." + layername,
|
|
331
|
+
title: title + ": " + layername,
|
|
332
|
+
type: SearchResultType.PLACE,
|
|
333
|
+
items: items
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
return {
|
|
337
|
+
results: results
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}, {
|
|
341
|
+
key: "getResultGeometry",
|
|
342
|
+
value: function getResultGeometry(resultItem, callback) {
|
|
343
|
+
callback({
|
|
344
|
+
geometry: resultItem.geometry,
|
|
345
|
+
crs: resultItem.crs
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}]);
|
|
349
|
+
}();
|
|
350
|
+
/** ************************************************************************ **/
|
|
351
|
+
export var FulltextSearch = /*#__PURE__*/function () {
|
|
352
|
+
function FulltextSearch() {
|
|
353
|
+
_classCallCheck(this, FulltextSearch);
|
|
354
|
+
}
|
|
355
|
+
return _createClass(FulltextSearch, null, [{
|
|
356
|
+
key: "search",
|
|
357
|
+
value: function search(searchText, searchParams, callback) {
|
|
358
|
+
var searchServiceUrl = ConfigUtils.getConfigProp("searchServiceUrl");
|
|
359
|
+
if (!searchServiceUrl) {
|
|
360
|
+
/* eslint-disable-next-line */
|
|
361
|
+
console.warn("Fulltext search failed: searchServiceUrl not set");
|
|
362
|
+
callback({
|
|
363
|
+
results: []
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
// Compute search filter
|
|
367
|
+
var searchFilter = new Set([].concat(_toConsumableArray(searchParams.cfgParams["default"] || []), _toConsumableArray(searchParams.searchTerms)));
|
|
368
|
+
var facetMap = searchParams.cfgParams.layers || {};
|
|
369
|
+
searchParams.activeLayers.forEach(function (layername) {
|
|
370
|
+
if (facetMap[layername]) {
|
|
371
|
+
searchFilter.add(facetMap[layername]);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
var params = {
|
|
375
|
+
searchtext: searchText,
|
|
376
|
+
filter: _toConsumableArray(searchFilter).join(","),
|
|
377
|
+
limit: searchParams.limit
|
|
378
|
+
};
|
|
379
|
+
var iconPath = ConfigUtils.getAssetsPath() + '/img/search/';
|
|
380
|
+
axios.get(searchServiceUrl, {
|
|
381
|
+
params: params
|
|
382
|
+
}).then(function (response) {
|
|
383
|
+
var data = FulltextSearch.filterFulltextResults(response.data, searchParams.filterPoly, searchParams.mapcrs);
|
|
384
|
+
var placeResultCount = (data.result_counts || []).reduce(function (res, entry) {
|
|
385
|
+
if (entry.dataproduct_id === 'dataproduct') {
|
|
386
|
+
return res;
|
|
387
|
+
} else if (res === -1 || entry.count === -1) {
|
|
388
|
+
return -1;
|
|
389
|
+
} else {
|
|
390
|
+
return res + entry.count;
|
|
391
|
+
}
|
|
392
|
+
}, 0);
|
|
393
|
+
var results = [];
|
|
394
|
+
// Layers
|
|
395
|
+
var _formatLayerEntry = function formatLayerEntry(dataproduct) {
|
|
396
|
+
return {
|
|
397
|
+
type: SearchResultType.THEMELAYER,
|
|
398
|
+
id: dataproduct.dataproduct_id,
|
|
399
|
+
text: dataproduct.display,
|
|
400
|
+
thumbnail: iconPath + "dataproduct.svg",
|
|
401
|
+
info: dataproduct.dset_info,
|
|
402
|
+
sublayers: dataproduct.sublayers ? dataproduct.sublayers.map(_formatLayerEntry) : null
|
|
403
|
+
};
|
|
404
|
+
};
|
|
405
|
+
results.push({
|
|
406
|
+
id: "fulltext.layers",
|
|
407
|
+
titlemsgid: LocaleUtils.trmsg("search.layers"),
|
|
408
|
+
type: SearchResultType.THEMELAYER,
|
|
409
|
+
items: data.results.filter(function (entry) {
|
|
410
|
+
return entry.dataproduct;
|
|
411
|
+
}).map(function (entry) {
|
|
412
|
+
return _formatLayerEntry(entry.dataproduct);
|
|
413
|
+
})
|
|
414
|
+
});
|
|
415
|
+
// Places
|
|
416
|
+
results.push({
|
|
417
|
+
id: "fulltext.places",
|
|
418
|
+
titlemsgid: LocaleUtils.trmsg("search.places"),
|
|
419
|
+
resultCount: placeResultCount,
|
|
420
|
+
type: SearchResultType.PLACE,
|
|
421
|
+
items: data.results.filter(function (entry) {
|
|
422
|
+
return entry.feature;
|
|
423
|
+
}).map(function (entry) {
|
|
424
|
+
return {
|
|
425
|
+
id: entry.feature.feature_id,
|
|
426
|
+
text: entry.feature.display,
|
|
427
|
+
x: 0.5 * (entry.feature.bbox[0] + entry.feature.bbox[2]),
|
|
428
|
+
y: 0.5 * (entry.feature.bbox[1] + entry.feature.bbox[3]),
|
|
429
|
+
crs: entry.feature.srid ? "EPSG:" + String(entry.feature.srid).replace(/^EPSG:/, '') : null,
|
|
430
|
+
bbox: entry.feature.bbox,
|
|
431
|
+
thumbnail: iconPath + entry.feature.dataproduct_id + ".svg",
|
|
432
|
+
// fulltext specific info
|
|
433
|
+
dataproduct_id: entry.feature.dataproduct_id,
|
|
434
|
+
id_field_name: entry.feature.id_field_name
|
|
435
|
+
};
|
|
436
|
+
})
|
|
437
|
+
});
|
|
438
|
+
callback({
|
|
439
|
+
results: results,
|
|
440
|
+
result_counts: data.result_counts
|
|
441
|
+
});
|
|
442
|
+
})["catch"](function (e) {
|
|
443
|
+
// eslint-disable-next-line
|
|
444
|
+
console.warn("Fulltext search failed: " + e);
|
|
445
|
+
callback({
|
|
446
|
+
results: []
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}, {
|
|
451
|
+
key: "filterFulltextResults",
|
|
452
|
+
value: function filterFulltextResults(data, filterPoly, mapCrs) {
|
|
453
|
+
if (!filterPoly) {
|
|
454
|
+
return data;
|
|
455
|
+
}
|
|
456
|
+
data.results = data.results.filter(function (result) {
|
|
457
|
+
if (!result.feature || !result.feature.bbox) {
|
|
458
|
+
return true;
|
|
459
|
+
}
|
|
460
|
+
var _CoordinatesUtils$rep = CoordinatesUtils.reprojectBbox(result.feature.bbox, "EPSG:" + result.feature.srid, mapCrs),
|
|
461
|
+
_CoordinatesUtils$rep2 = _slicedToArray(_CoordinatesUtils$rep, 4),
|
|
462
|
+
xmin = _CoordinatesUtils$rep2[0],
|
|
463
|
+
ymin = _CoordinatesUtils$rep2[1],
|
|
464
|
+
xmax = _CoordinatesUtils$rep2[2],
|
|
465
|
+
ymax = _CoordinatesUtils$rep2[3];
|
|
466
|
+
var intersects = polygonIntersectTest([[xmin, ymin], [xmax, ymin], [xmax, ymax], [xmin, ymax], [xmin, ymin]], filterPoly);
|
|
467
|
+
if (!intersects) {
|
|
468
|
+
data.result_counts.find(function (entry) {
|
|
469
|
+
return entry.dataproduct_id === result.feature.dataproduct_id;
|
|
470
|
+
}).count -= 1;
|
|
471
|
+
}
|
|
472
|
+
return intersects;
|
|
473
|
+
});
|
|
474
|
+
return data;
|
|
475
|
+
}
|
|
476
|
+
}, {
|
|
477
|
+
key: "getResultGeometry",
|
|
478
|
+
value: function getResultGeometry(resultItem, callback) {
|
|
479
|
+
var dataServiceUrl = ConfigUtils.getConfigProp("searchDataServiceUrl") || ConfigUtils.getConfigProp("dataServiceUrl");
|
|
480
|
+
if (!dataServiceUrl) {
|
|
481
|
+
callback(null);
|
|
482
|
+
}
|
|
483
|
+
// URL example: /api/data/v1/ch.so.afu.fliessgewaesser.netz/?filter=[["gewissnr","=",1179]]
|
|
484
|
+
var quot = typeof resultItem.id === 'string' ? '"' : '';
|
|
485
|
+
var filter = "[[\"".concat(resultItem.id_field_name, "\",\"=\", ").concat(quot).concat(resultItem.id).concat(quot, "]]");
|
|
486
|
+
axios.get(dataServiceUrl.replace(/\/?$/, "/") + resultItem.dataproduct_id + "/?filter=" + filter).then(function (response) {
|
|
487
|
+
var bbox = response.data.bbox;
|
|
488
|
+
var center = bbox ? [0.5 * (bbox[0] + bbox[2]), 0.5 * (bbox[1] + bbox[3])] : null;
|
|
489
|
+
callback({
|
|
490
|
+
bbox: bbox,
|
|
491
|
+
center: center,
|
|
492
|
+
feature: response.data,
|
|
493
|
+
crs: response.data.crs.properties.name
|
|
494
|
+
});
|
|
495
|
+
})["catch"](function () {
|
|
496
|
+
callback(null);
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
}, {
|
|
500
|
+
key: "getLayerDefinition",
|
|
501
|
+
value: function getLayerDefinition(resultItem, callback) {
|
|
502
|
+
var dataProductServiceUrl = ConfigUtils.getConfigProp("dataproductServiceUrl");
|
|
503
|
+
if (!dataProductServiceUrl) {
|
|
504
|
+
/* eslint-disable-next-line */
|
|
505
|
+
console.warn("Fulltext search: failed to get layer definition, dataproductServiceUrl is not defined");
|
|
506
|
+
callback(null);
|
|
507
|
+
}
|
|
508
|
+
var params = {
|
|
509
|
+
filter: resultItem.id
|
|
510
|
+
};
|
|
511
|
+
axios.get(dataProductServiceUrl.replace(/\/?$/, "/") + "weblayers", {
|
|
512
|
+
params: params
|
|
513
|
+
}).then(function (response) {
|
|
514
|
+
var _response$data$result;
|
|
515
|
+
callback((_response$data$result = response.data[resultItem.id]) === null || _response$data$result === void 0 ? void 0 : _response$data$result[0]);
|
|
516
|
+
})["catch"](function () {
|
|
517
|
+
callback(null);
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
}, {
|
|
521
|
+
key: "handleHighlightParameters",
|
|
522
|
+
value: function handleHighlightParameters(hp, hf, st, callback) {
|
|
523
|
+
var searchServiceUrl = ConfigUtils.getConfigProp("searchServiceUrl");
|
|
524
|
+
var dataServiceUrl = ConfigUtils.getConfigProp("searchDataServiceUrl") || ConfigUtils.getConfigProp("dataServiceUrl");
|
|
525
|
+
if (!searchServiceUrl || !dataServiceUrl) {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
var queryFeature = function queryFeature(filter) {
|
|
529
|
+
axios.get(dataServiceUrl.replace(/\/?$/, "/") + hp + "/?filter=" + filter).then(function (response) {
|
|
530
|
+
var bbox = response.data.bbox;
|
|
531
|
+
var item = {
|
|
532
|
+
x: 0.5 * [bbox[0] + bbox[2]],
|
|
533
|
+
y: 0.5 * [bbox[1] + bbox[3]],
|
|
534
|
+
label: st,
|
|
535
|
+
crs: response.data.crs.properties.name,
|
|
536
|
+
bbox: bbox
|
|
537
|
+
};
|
|
538
|
+
callback(item, {
|
|
539
|
+
feature: response.data,
|
|
540
|
+
crs: response.data.crs.properties.name
|
|
541
|
+
});
|
|
542
|
+
})["catch"](function () {});
|
|
543
|
+
};
|
|
544
|
+
if (hp && hf) {
|
|
545
|
+
queryFeature(hf);
|
|
546
|
+
} else if (hp && st) {
|
|
547
|
+
var params = {
|
|
548
|
+
searchtext: st,
|
|
549
|
+
filter: hp,
|
|
550
|
+
limit: 1
|
|
551
|
+
};
|
|
552
|
+
axios.get(searchServiceUrl, {
|
|
553
|
+
params: params
|
|
554
|
+
}).then(function (response) {
|
|
555
|
+
if (response.data.results && response.data.results.length === 1) {
|
|
556
|
+
var result = response.data.results[0].feature;
|
|
557
|
+
var quot = typeof result.feature_id === 'string' ? '"' : '';
|
|
558
|
+
var filter = "[[\"".concat(result.id_field_name, "\",\"=\", ").concat(quot).concat(result.feature_id).concat(quot, "]]");
|
|
559
|
+
queryFeature(filter);
|
|
560
|
+
}
|
|
561
|
+
})["catch"](function () {});
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}]);
|
|
565
|
+
}();
|
|
566
|
+
|
|
567
|
+
/** ************************************************************************ **/
|
|
568
|
+
|
|
569
|
+
var SearchProviders = {
|
|
570
|
+
coordinates: {
|
|
571
|
+
labelmsgid: "search.coordinates",
|
|
572
|
+
onSearch: coordinatesSearch,
|
|
573
|
+
handlesGeomFilter: false
|
|
574
|
+
},
|
|
575
|
+
nominatim: {
|
|
576
|
+
label: "OpenStreetMap",
|
|
577
|
+
onSearch: NominatimSearch.search,
|
|
578
|
+
handlesGeomFilter: false
|
|
579
|
+
},
|
|
580
|
+
qgis: {
|
|
581
|
+
label: "QGIS",
|
|
582
|
+
onSearch: QgisSearch.search,
|
|
583
|
+
getResultGeometry: QgisSearch.getResultGeometry,
|
|
584
|
+
handlesGeomFilter: false
|
|
585
|
+
},
|
|
586
|
+
fulltext: {
|
|
587
|
+
label: "Fulltext",
|
|
588
|
+
onSearch: FulltextSearch.search,
|
|
589
|
+
getResultGeometry: FulltextSearch.getResultGeometry,
|
|
590
|
+
getLayerDefinition: FulltextSearch.getLayerDefinition,
|
|
591
|
+
handlesGeomFilter: true
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
/** ************************************************************************ **/
|
|
596
|
+
|
|
597
|
+
var addedSearchProviders = new Set();
|
|
598
|
+
export function registerSearchProvider(key, config) {
|
|
599
|
+
SearchProviders[key] = config;
|
|
600
|
+
addedSearchProviders.add(key);
|
|
601
|
+
}
|
|
602
|
+
export function unregisterSearchProvider(key) {
|
|
603
|
+
delete SearchProviders[key];
|
|
604
|
+
addedSearchProviders["delete"](key);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// Uniformize the response of getResultGeometry
|
|
608
|
+
function getResultGeometry(provider, item, callback) {
|
|
609
|
+
provider.getResultGeometry(item, function (response) {
|
|
610
|
+
var features = [];
|
|
611
|
+
if (response !== null && response !== void 0 && response.geometry) {
|
|
612
|
+
var highlightFeature = response.geometry.coordinates ? {
|
|
613
|
+
type: "Feature",
|
|
614
|
+
geometry: response.geometry
|
|
615
|
+
} : VectorLayerUtils.wktToGeoJSON(response.geometry, response.crs, response.crs);
|
|
616
|
+
if (highlightFeature) {
|
|
617
|
+
features.push(highlightFeature);
|
|
618
|
+
}
|
|
619
|
+
} else if (response !== null && response !== void 0 && response.feature) {
|
|
620
|
+
if (response.feature.features) {
|
|
621
|
+
features.push.apply(features, _toConsumableArray(response.feature.features));
|
|
622
|
+
} else {
|
|
623
|
+
features.push(response.feature);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
if (features.length === 0) {
|
|
627
|
+
callback(null);
|
|
628
|
+
} else {
|
|
629
|
+
callback(_objectSpread(_objectSpread({
|
|
630
|
+
feature: {
|
|
631
|
+
type: "FeatureCollection",
|
|
632
|
+
features: features
|
|
633
|
+
},
|
|
634
|
+
crs: response.crs,
|
|
635
|
+
hidemarker: response.hidemarker
|
|
636
|
+
}, response.bbox && {
|
|
637
|
+
bbox: response.bbox
|
|
638
|
+
}), response.center && {
|
|
639
|
+
center: response.center
|
|
640
|
+
}));
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
export function collectSearchProviders(theme, layers) {
|
|
645
|
+
var mapScale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
646
|
+
// Collect active layers/search terms
|
|
647
|
+
var searchTerms = [];
|
|
648
|
+
var activeLayers = [];
|
|
649
|
+
var _iterator = _createForOfIteratorHelper(LayerUtils.explodeLayers(layers)),
|
|
650
|
+
_step;
|
|
651
|
+
try {
|
|
652
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
653
|
+
var entry = _step.value;
|
|
654
|
+
if (entry.layer.role === LayerRole.THEME && entry.sublayer.visibility === true && mapScale !== null && LayerUtils.layerScaleInRange(entry.sublayer, mapScale)) {
|
|
655
|
+
searchTerms = searchTerms.concat(entry.sublayer.searchterms || []);
|
|
656
|
+
activeLayers.push(entry.sublayer.name);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
} catch (err) {
|
|
660
|
+
_iterator.e(err);
|
|
661
|
+
} finally {
|
|
662
|
+
_iterator.f();
|
|
663
|
+
}
|
|
664
|
+
var searchProviders = _objectSpread(_objectSpread({}, SearchProviders), window.QWC2SearchProviders || {});
|
|
665
|
+
var availableProviders = {};
|
|
666
|
+
var themeLayerNames = layers.map(function (layer) {
|
|
667
|
+
return layer.role === LayerRole.THEME ? layer.params.LAYERS : "";
|
|
668
|
+
}).join(",").split(",").filter(function (entry) {
|
|
669
|
+
return entry;
|
|
670
|
+
});
|
|
671
|
+
var providerKeys = new Set();
|
|
672
|
+
var enabledProviders = [].concat(_toConsumableArray((theme === null || theme === void 0 ? void 0 : theme.searchProviders) || []), _toConsumableArray(addedSearchProviders));
|
|
673
|
+
var _iterator2 = _createForOfIteratorHelper(enabledProviders),
|
|
674
|
+
_step2;
|
|
675
|
+
try {
|
|
676
|
+
var _loop = function _loop() {
|
|
677
|
+
var _entry;
|
|
678
|
+
var entry = _step2.value;
|
|
679
|
+
if (typeof entry === 'string') {
|
|
680
|
+
entry = {
|
|
681
|
+
provider: entry
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
// Omit qgis provider with field configuration, this is only supported through the FeatureSearch plugin
|
|
685
|
+
if (entry.provider === 'qgis' && (_entry = entry) !== null && _entry !== void 0 && (_entry = _entry.params) !== null && _entry !== void 0 && _entry.fields) {
|
|
686
|
+
return 0; // continue
|
|
687
|
+
}
|
|
688
|
+
var provider = searchProviders[entry.provider];
|
|
689
|
+
if (provider) {
|
|
690
|
+
var _entry$key, _entry$label, _entry$labelmsgid;
|
|
691
|
+
if (provider.requiresLayer && !themeLayerNames.includes(provider.requiresLayer)) {
|
|
692
|
+
return 0; // continue
|
|
693
|
+
}
|
|
694
|
+
var key = (_entry$key = entry.key) !== null && _entry$key !== void 0 ? _entry$key : entry.provider;
|
|
695
|
+
if (providerKeys.has(key)) {
|
|
696
|
+
var i = 0;
|
|
697
|
+
for (i = 0; providerKeys.has(key + "_" + i); ++i);
|
|
698
|
+
key = key + "_" + i;
|
|
699
|
+
}
|
|
700
|
+
providerKeys.add(key);
|
|
701
|
+
availableProviders[key] = _objectSpread(_objectSpread({}, provider), {}, {
|
|
702
|
+
label: (_entry$label = entry.label) !== null && _entry$label !== void 0 ? _entry$label : provider.label,
|
|
703
|
+
labelmsgid: (_entry$labelmsgid = entry.labelmsgid) !== null && _entry$labelmsgid !== void 0 ? _entry$labelmsgid : provider.labelmsgid,
|
|
704
|
+
getResultGeometry: provider.getResultGeometry ? function (item, callback) {
|
|
705
|
+
return getResultGeometry(provider, item, callback);
|
|
706
|
+
} : null,
|
|
707
|
+
cfgParams: entry.params || {},
|
|
708
|
+
params: {
|
|
709
|
+
searchTerms: searchTerms,
|
|
710
|
+
activeLayers: activeLayers,
|
|
711
|
+
theme: theme
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
},
|
|
716
|
+
_ret;
|
|
717
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
718
|
+
_ret = _loop();
|
|
719
|
+
if (_ret === 0) continue;
|
|
720
|
+
}
|
|
721
|
+
} catch (err) {
|
|
722
|
+
_iterator2.e(err);
|
|
723
|
+
} finally {
|
|
724
|
+
_iterator2.f();
|
|
725
|
+
}
|
|
726
|
+
return availableProviders;
|
|
727
|
+
}
|