qwc2 2025.10.13 → 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/scripts/themesConfig.js
CHANGED
|
@@ -1,48 +1,750 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Copyright 2016-2024 Sourcepole AG
|
|
4
5
|
* All rights reserved.
|
|
5
6
|
*
|
|
6
7
|
* This source code is licensed under the BSD-style license found in the
|
|
7
8
|
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
*/
|
|
10
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
11
|
+
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."); }
|
|
12
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
13
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
|
+
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); }
|
|
19
|
+
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; } } }; }
|
|
20
|
+
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; } }
|
|
21
|
+
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; }
|
|
22
|
+
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); }
|
|
23
|
+
var urlUtil = require('url');
|
|
24
|
+
var axios = require('axios');
|
|
25
|
+
var XMLParser = require('fast-xml-parser').XMLParser;
|
|
26
|
+
var fs = require('fs');
|
|
27
|
+
var path = require('path');
|
|
28
|
+
var objectPath = require('object-path');
|
|
29
|
+
var isEmpty = require('lodash.isempty');
|
|
30
|
+
var uuidv4 = require('uuid').v1;
|
|
31
|
+
var os = require('os');
|
|
32
|
+
var dns = require('dns');
|
|
33
|
+
var _dns$promises = dns.promises,
|
|
34
|
+
lookup = _dns$promises.lookup,
|
|
35
|
+
lookupService = _dns$promises.lookupService;
|
|
36
|
+
var hostFqdn = "";
|
|
37
|
+
var themesConfigPath = process.env.QWC2_THEMES_CONFIG || "static/themesConfig.json";
|
|
38
|
+
var usedThemeIds = [];
|
|
39
|
+
var autogenExternalLayers = [];
|
|
40
|
+
function uniqueThemeId(themeName) {
|
|
41
|
+
if (!themeName) {
|
|
42
|
+
return uuidv4();
|
|
43
|
+
}
|
|
44
|
+
if (usedThemeIds.includes(themeName)) {
|
|
45
|
+
var i = 1;
|
|
46
|
+
for (; usedThemeIds.includes(themeName + i); ++i);
|
|
47
|
+
usedThemeIds.push(themeName + i);
|
|
48
|
+
return themeName + i;
|
|
49
|
+
} else {
|
|
50
|
+
usedThemeIds.push(themeName);
|
|
51
|
+
return themeName;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// load thumbnail from file or GetMap
|
|
56
|
+
function getThumbnail(configItem, resultItem, layers, crs, extent, resolve, proxy) {
|
|
57
|
+
if (configItem.thumbnail !== undefined) {
|
|
58
|
+
// check if thumbnail can be read
|
|
59
|
+
if (fs.existsSync("./static/assets/img/mapthumbs/" + configItem.thumbnail)) {
|
|
60
|
+
resultItem.thumbnail = "img/mapthumbs/" + configItem.thumbnail;
|
|
61
|
+
// finish task
|
|
62
|
+
resolve(true);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* eslint-disable-next-line */
|
|
68
|
+
console.error("Using WMS GetMap to generate thumbnail for " + configItem.url);
|
|
69
|
+
|
|
70
|
+
// WMS GetMap request
|
|
71
|
+
var parsedUrl = urlUtil.parse(urlUtil.resolve(hostFqdn, configItem.url), true);
|
|
72
|
+
parsedUrl.search = '';
|
|
73
|
+
parsedUrl.query.SERVICE = "WMS";
|
|
74
|
+
parsedUrl.query.VERSION = "1.3.0";
|
|
75
|
+
parsedUrl.query.REQUEST = "GetMap";
|
|
76
|
+
parsedUrl.query.FORMAT = "image/png";
|
|
77
|
+
parsedUrl.query.TRANSPARENT = "TRUE";
|
|
78
|
+
parsedUrl.query.STYLES = "";
|
|
79
|
+
parsedUrl.query.WIDTH = 200;
|
|
80
|
+
parsedUrl.query.HEIGHT = 100;
|
|
81
|
+
parsedUrl.query.CRS = crs;
|
|
82
|
+
var bboxw = extent[2] - extent[0];
|
|
83
|
+
var bboxh = extent[3] - extent[1];
|
|
84
|
+
var bboxcx = 0.5 * (extent[0] + extent[2]);
|
|
85
|
+
var bboxcy = 0.5 * (extent[1] + extent[3]);
|
|
86
|
+
var imgratio = 200 / 100;
|
|
87
|
+
if (bboxw > bboxh) {
|
|
88
|
+
var bboxratio = bboxw / bboxh;
|
|
89
|
+
if (bboxratio > imgratio) {
|
|
90
|
+
bboxh = bboxw / imgratio;
|
|
91
|
+
} else {
|
|
92
|
+
bboxw = bboxh * imgratio;
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
bboxw = bboxh * imgratio;
|
|
96
|
+
}
|
|
97
|
+
var adjustedExtent = [bboxcx - 0.5 * bboxw, bboxcy - 0.5 * bboxh, bboxcx + 0.5 * bboxw, bboxcy + 0.5 * bboxh];
|
|
98
|
+
parsedUrl.query.BBOX = adjustedExtent.join(',');
|
|
99
|
+
parsedUrl.query.LAYERS = layers.join(',');
|
|
100
|
+
var getMapUrl = urlUtil.format(parsedUrl);
|
|
101
|
+
axios.get(getMapUrl, {
|
|
102
|
+
proxy: proxy,
|
|
103
|
+
responseType: "arraybuffer",
|
|
104
|
+
auth: configItem.wmsBasicAuth
|
|
105
|
+
}).then(function (response) {
|
|
106
|
+
var basename = configItem.url.replace(/.*\//, "").replace(/\?.*$/, "") + ".png";
|
|
107
|
+
try {
|
|
108
|
+
fs.mkdirSync("./static/assets/img/genmapthumbs/");
|
|
109
|
+
} catch (err) {
|
|
110
|
+
if (err.code !== 'EEXIST') throw err;
|
|
111
|
+
}
|
|
112
|
+
fs.writeFileSync("./static/assets/img/genmapthumbs/" + basename, response.data);
|
|
113
|
+
resultItem.thumbnail = "img/genmapthumbs/" + basename;
|
|
114
|
+
// finish task
|
|
115
|
+
resolve(true);
|
|
116
|
+
})["catch"](function (error) {
|
|
117
|
+
/* eslint-disable-next-line */
|
|
118
|
+
console.error("ERROR generating thumbnail for WMS " + configItem.url + ":\n", error);
|
|
119
|
+
resultItem.thumbnail = "img/mapthumbs/default.jpg";
|
|
120
|
+
// finish task
|
|
121
|
+
resolve(false);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function getEditConfig(editConfig) {
|
|
125
|
+
if (isEmpty(editConfig)) {
|
|
126
|
+
return null;
|
|
127
|
+
} else if (_typeof(editConfig) === "object") {
|
|
128
|
+
return editConfig;
|
|
129
|
+
} else if (path.isAbsolute(editConfig) && fs.existsSync(editConfig)) {
|
|
130
|
+
return JSON.parse(fs.readFileSync(path, "utf8"));
|
|
131
|
+
} else if (fs.existsSync(process.cwd() + '/' + editConfig)) {
|
|
132
|
+
return JSON.parse(fs.readFileSync(process.cwd() + '/' + editConfig, "utf8"));
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
// convert non-array object to array containing the object
|
|
15
137
|
// used to restore arrays lost by xml -> json conversion
|
|
16
|
-
function toArray(obj){
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
138
|
+
function toArray(obj) {
|
|
139
|
+
if (obj !== undefined) {
|
|
140
|
+
return Array.isArray(obj) ? obj : [obj];
|
|
141
|
+
}
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// recursively get layer tree
|
|
146
|
+
function getLayerTree(layer, resultLayers, visibleLayers, printLayers, level, collapseBelowLevel, titleNameMap, featureReports, externalLayers) {
|
|
147
|
+
// skip print layers
|
|
148
|
+
var _iterator = _createForOfIteratorHelper(printLayers),
|
|
149
|
+
_step;
|
|
150
|
+
try {
|
|
151
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
152
|
+
var printLayer = _step.value;
|
|
153
|
+
if (Array.isArray(printLayer)) {
|
|
154
|
+
if (printLayer.find(function (entry) {
|
|
155
|
+
return entry.name === layer.Name;
|
|
156
|
+
})) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
} else if (printLayer === layer.Name) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
} catch (err) {
|
|
164
|
+
_iterator.e(err);
|
|
165
|
+
} finally {
|
|
166
|
+
_iterator.f();
|
|
167
|
+
}
|
|
168
|
+
var layerEntry = {
|
|
169
|
+
name: layer.Name,
|
|
170
|
+
title: layer.Title
|
|
171
|
+
};
|
|
172
|
+
if (layer.Layer === undefined) {
|
|
173
|
+
if (layer.$_geometryType === "WKBNoGeometry" || layer.$_geometryType === "NoGeometry") {
|
|
174
|
+
// skip layers without geometry
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// layer
|
|
179
|
+
layerEntry.geometryType = layer.$_geometryType;
|
|
180
|
+
if (layer.$_visibilityChecked !== undefined) {
|
|
181
|
+
layerEntry.visibility = layer.$_visibilityChecked === '1';
|
|
182
|
+
} else {
|
|
183
|
+
layerEntry.visibility = layer.$_visible === '1';
|
|
184
|
+
}
|
|
185
|
+
if (layerEntry.visibility) {
|
|
186
|
+
// collect visible layers
|
|
187
|
+
visibleLayers.push(layer.Name);
|
|
188
|
+
}
|
|
189
|
+
layerEntry.queryable = layer.$_queryable === '1';
|
|
190
|
+
if (layerEntry.queryable) {
|
|
191
|
+
layerEntry.displayField = layer.$_displayField;
|
|
192
|
+
}
|
|
193
|
+
if (layer.Attribution) {
|
|
194
|
+
layerEntry.attribution = {
|
|
195
|
+
Title: layer.Attribution.Title,
|
|
196
|
+
OnlineResource: layer.Attribution.OnlineResource ? layer.Attribution.OnlineResource.$_href : ""
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (layer.Abstract) {
|
|
200
|
+
layerEntry["abstract"] = layer.Abstract;
|
|
201
|
+
}
|
|
202
|
+
if (layer.DataURL && layer.DataURL.OnlineResource) {
|
|
203
|
+
layerEntry.dataUrl = layer.DataURL.OnlineResource.$_href;
|
|
204
|
+
if (layerEntry.dataUrl.startsWith("wms:")) {
|
|
205
|
+
externalLayers.push({
|
|
206
|
+
internalLayer: layer.Name,
|
|
207
|
+
name: layerEntry.dataUrl
|
|
208
|
+
});
|
|
209
|
+
layerEntry.dataUrl = "";
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (layer.MetadataURL && layer.MetadataURL.OnlineResource) {
|
|
213
|
+
layerEntry.metadataUrl = layer.MetadataURL.OnlineResource.$_href;
|
|
214
|
+
}
|
|
215
|
+
if (layer.$_transparency) {
|
|
216
|
+
layerEntry.opacity = 255 - Math.floor(parseFloat(layer.$_transparency) * 255);
|
|
217
|
+
} else if (layer.$_opacity) {
|
|
218
|
+
layerEntry.opacity = Math.round(parseFloat(layer.$_opacity) * 255);
|
|
219
|
+
} else {
|
|
220
|
+
layerEntry.opacity = 255;
|
|
221
|
+
}
|
|
222
|
+
if (layer.KeywordList) {
|
|
223
|
+
var keywords = [];
|
|
224
|
+
toArray(layer.KeywordList.Keyword).map(function (entry) {
|
|
225
|
+
keywords.push(_typeof(entry) === 'object' ? entry._ : entry);
|
|
226
|
+
});
|
|
227
|
+
layerEntry.keywords = keywords.join(", ");
|
|
228
|
+
}
|
|
229
|
+
if (layer.Style) {
|
|
230
|
+
var _Object$keys$;
|
|
231
|
+
layerEntry.styles = toArray(layer.Style).reduce(function (res, entry) {
|
|
232
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, entry.Name, entry.Title));
|
|
233
|
+
}, {});
|
|
234
|
+
layerEntry.style = layerEntry.styles["default"] ? 'default' : (_Object$keys$ = Object.keys(layerEntry.styles)[0]) !== null && _Object$keys$ !== void 0 ? _Object$keys$ : '';
|
|
235
|
+
}
|
|
236
|
+
if (layer.MinScaleDenominator !== undefined) {
|
|
237
|
+
layerEntry.minScale = Math.round(parseFloat(layer.MinScaleDenominator));
|
|
238
|
+
layerEntry.maxScale = Math.round(parseFloat(layer.MaxScaleDenominator));
|
|
239
|
+
}
|
|
240
|
+
// use geographic bounding box, as default CRS may have inverted axis order with WMS 1.3.0
|
|
241
|
+
if (layer.EX_GeographicBoundingBox) {
|
|
242
|
+
layerEntry.bbox = {
|
|
243
|
+
crs: "EPSG:4326",
|
|
244
|
+
bounds: [parseFloat(layer.EX_GeographicBoundingBox.westBoundLongitude), parseFloat(layer.EX_GeographicBoundingBox.southBoundLatitude), parseFloat(layer.EX_GeographicBoundingBox.eastBoundLongitude), parseFloat(layer.EX_GeographicBoundingBox.northBoundLatitude)]
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
if (featureReports[layer.Name]) {
|
|
248
|
+
layerEntry.featureReport = featureReports[layer.Name];
|
|
249
|
+
}
|
|
250
|
+
layerEntry.dimensions = [];
|
|
251
|
+
toArray(layer.Dimension).forEach(function (dim) {
|
|
252
|
+
layerEntry.dimensions.push({
|
|
253
|
+
units: dim.$_units,
|
|
254
|
+
name: dim.$_name,
|
|
255
|
+
multiple: dim.$_multipleValues === "1",
|
|
256
|
+
value: dim._,
|
|
257
|
+
fieldName: dim.$_fieldName,
|
|
258
|
+
endFieldName: dim.$_endFieldName
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
} else {
|
|
262
|
+
// group
|
|
263
|
+
layerEntry.mutuallyExclusive = layer.$_mutuallyExclusive === '1';
|
|
264
|
+
if (layer.$_visibilityChecked !== undefined) {
|
|
265
|
+
layerEntry.visibility = layer.$_visibilityChecked === '1';
|
|
266
|
+
} else {
|
|
267
|
+
layerEntry.visibility = layer.$_visible === '1';
|
|
268
|
+
}
|
|
269
|
+
layerEntry.sublayers = [];
|
|
270
|
+
if (layer.$_expanded === '0' || collapseBelowLevel >= 0 && level >= collapseBelowLevel) {
|
|
271
|
+
layerEntry.expanded = false;
|
|
272
|
+
} else {
|
|
273
|
+
layerEntry.expanded = true;
|
|
274
|
+
}
|
|
275
|
+
var _iterator2 = _createForOfIteratorHelper(toArray(layer.Layer)),
|
|
276
|
+
_step2;
|
|
277
|
+
try {
|
|
278
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
279
|
+
var subLayer = _step2.value;
|
|
280
|
+
getLayerTree(subLayer, layerEntry.sublayers, visibleLayers, printLayers, level + 1, collapseBelowLevel, titleNameMap, featureReports, externalLayers);
|
|
281
|
+
}
|
|
282
|
+
} catch (err) {
|
|
283
|
+
_iterator2.e(err);
|
|
284
|
+
} finally {
|
|
285
|
+
_iterator2.f();
|
|
286
|
+
}
|
|
287
|
+
if (layerEntry.sublayers.length === 0) {
|
|
288
|
+
// skip empty groups
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
resultLayers.push(layerEntry);
|
|
293
|
+
titleNameMap[layer.TreeName] = layer.Name;
|
|
294
|
+
}
|
|
295
|
+
function flatLayers(layer) {
|
|
296
|
+
var result = [layer];
|
|
297
|
+
(layer.Layer || []).forEach(function (sublayer) {
|
|
298
|
+
return result.push(sublayer);
|
|
299
|
+
});
|
|
300
|
+
return result;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// parse GetCapabilities for theme
|
|
304
|
+
function getTheme(config, configItem, result, resultItem, proxy) {
|
|
305
|
+
if (configItem.disabled) {
|
|
306
|
+
/* eslint-disable-next-line no-console */
|
|
307
|
+
console.log("Item ".concat(configItem.url) + (configItem.title ? " (".concat(configItem.title, ")") : "") + " has been disabled");
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
var parsedUrl = urlUtil.parse(urlUtil.resolve(hostFqdn, configItem.url), true);
|
|
311
|
+
parsedUrl.search = '';
|
|
312
|
+
parsedUrl.query.SERVICE = "WMS";
|
|
313
|
+
parsedUrl.query.VERSION = "1.3.0";
|
|
314
|
+
parsedUrl.query.REQUEST = "GetProjectSettings";
|
|
315
|
+
var getCapabilitiesUrl = urlUtil.format(parsedUrl);
|
|
316
|
+
return new Promise(function (resolve, reject) {
|
|
317
|
+
axios.get(getCapabilitiesUrl, {
|
|
318
|
+
proxy: proxy,
|
|
319
|
+
auth: configItem.wmsBasicAuth
|
|
320
|
+
}).then(function (response) {
|
|
321
|
+
var _XMLParser$parse;
|
|
322
|
+
// parse capabilities
|
|
323
|
+
var parseOptions = {
|
|
324
|
+
removeNSPrefix: true,
|
|
325
|
+
isArray: function isArray() {
|
|
326
|
+
return false;
|
|
327
|
+
},
|
|
328
|
+
ignoreAttributes: false,
|
|
329
|
+
attributeNamePrefix: "$_",
|
|
330
|
+
textNodeName: "_"
|
|
331
|
+
};
|
|
332
|
+
var capabilities = (_XMLParser$parse = new XMLParser(parseOptions).parse(response.data)) === null || _XMLParser$parse === void 0 ? void 0 : _XMLParser$parse.WMS_Capabilities;
|
|
333
|
+
if (capabilities === undefined) {
|
|
334
|
+
// show response data on parse error
|
|
335
|
+
throw new Error(response.data);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/* eslint-disable-next-line */
|
|
339
|
+
console.log("Parsing WMS GetProjectSettings of " + configItem.url + (configItem.title ? " (".concat(configItem.title, ")") : ""));
|
|
340
|
+
var topLayer = capabilities.Capability.Layer;
|
|
341
|
+
var wmsName = configItem.url.replace(/.*\//, '').replace(/\?^/, '');
|
|
342
|
+
|
|
343
|
+
// use name from config or fallback to WMS title
|
|
344
|
+
var wmsTitle = configItem.title || capabilities.Service.Title || topLayer.Title || wmsName;
|
|
345
|
+
|
|
346
|
+
// keywords
|
|
347
|
+
var keywords = [];
|
|
348
|
+
if (capabilities.Service.KeywordList) {
|
|
349
|
+
toArray(capabilities.Service.KeywordList.Keyword).map(function (entry) {
|
|
350
|
+
var value = _typeof(entry) === 'object' ? entry._ : entry;
|
|
351
|
+
if (value !== "infoMapAccessService") {
|
|
352
|
+
keywords.push(value);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// use first CRS for thumbnail request
|
|
358
|
+
var crs = toArray(topLayer.CRS).filter(function (item) {
|
|
359
|
+
return item !== 'CRS:84';
|
|
360
|
+
})[0];
|
|
361
|
+
var extent = [];
|
|
362
|
+
var _iterator3 = _createForOfIteratorHelper(toArray(topLayer.BoundingBox)),
|
|
363
|
+
_step3;
|
|
364
|
+
try {
|
|
365
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
366
|
+
var bbox = _step3.value;
|
|
367
|
+
if (bbox.$_CRS === crs) {
|
|
368
|
+
extent = [parseFloat(bbox.$_minx), parseFloat(bbox.$_miny), parseFloat(bbox.$_maxx), parseFloat(bbox.$_maxy)];
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// collect WMS layers for printing
|
|
374
|
+
} catch (err) {
|
|
375
|
+
_iterator3.e(err);
|
|
376
|
+
} finally {
|
|
377
|
+
_iterator3.f();
|
|
378
|
+
}
|
|
379
|
+
var printLayers = configItem.extraPrintLayers || [];
|
|
380
|
+
if (configItem.backgroundLayers !== undefined) {
|
|
381
|
+
printLayers = configItem.backgroundLayers.reduce(function (printLyrs, entry) {
|
|
382
|
+
if (entry.printLayer) {
|
|
383
|
+
printLyrs.push(entry.printLayer);
|
|
384
|
+
}
|
|
385
|
+
return printLyrs;
|
|
386
|
+
}, []);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// layer tree and visible layers
|
|
390
|
+
var collapseLayerGroupsBelowLevel = configItem.collapseLayerGroupsBelowLevel || -1;
|
|
391
|
+
var layerTree = [];
|
|
392
|
+
var visibleLayers = [];
|
|
393
|
+
var titleNameMap = {};
|
|
394
|
+
var externalLayers = [];
|
|
395
|
+
getLayerTree(topLayer, layerTree, visibleLayers, printLayers, 1, collapseLayerGroupsBelowLevel, titleNameMap, configItem.featureReport || {}, externalLayers);
|
|
396
|
+
autogenExternalLayers.push.apply(autogenExternalLayers, _toConsumableArray(externalLayers.map(function (entry) {
|
|
397
|
+
return entry.name;
|
|
398
|
+
})));
|
|
399
|
+
externalLayers.push.apply(externalLayers, _toConsumableArray(configItem.externalLayers || []));
|
|
400
|
+
visibleLayers.reverse();
|
|
401
|
+
|
|
402
|
+
// print templates
|
|
403
|
+
var printTemplates = [];
|
|
404
|
+
if (capabilities.Capability.ComposerTemplates !== undefined) {
|
|
405
|
+
var templates = capabilities.Capability.ComposerTemplates.ComposerTemplate;
|
|
406
|
+
if (!templates.length) {
|
|
407
|
+
templates = [templates];
|
|
408
|
+
}
|
|
409
|
+
var composerTemplateMap = {};
|
|
410
|
+
var _iterator4 = _createForOfIteratorHelper(templates),
|
|
411
|
+
_step4;
|
|
412
|
+
try {
|
|
413
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
414
|
+
var composerTemplate = _step4.value;
|
|
415
|
+
if (composerTemplate.ComposerMap !== undefined) {
|
|
416
|
+
composerTemplateMap[composerTemplate.$_name] = composerTemplate;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
} catch (err) {
|
|
420
|
+
_iterator4.e(err);
|
|
421
|
+
} finally {
|
|
422
|
+
_iterator4.f();
|
|
423
|
+
}
|
|
424
|
+
Object.values(composerTemplateMap).forEach(function (composerTemplate) {
|
|
425
|
+
var templateName = composerTemplate.$_name;
|
|
426
|
+
if (templateName.endsWith("_legend") && templateName.slice(0, -7) in composerTemplateMap) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
// use first map from GetProjectSettings
|
|
430
|
+
var composerMap = toArray(composerTemplate.ComposerMap)[0];
|
|
431
|
+
var printTemplate = {
|
|
432
|
+
name: templateName,
|
|
433
|
+
map: {
|
|
434
|
+
name: composerMap.$_name,
|
|
435
|
+
width: parseFloat(composerMap.$_width),
|
|
436
|
+
height: parseFloat(composerMap.$_height)
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
if (printTemplate.name + "_legend" in composerTemplateMap) {
|
|
440
|
+
printTemplate.legendLayout = printTemplate.name + "_legend";
|
|
441
|
+
}
|
|
442
|
+
if (composerTemplate.ComposerLabel !== undefined) {
|
|
443
|
+
printTemplate.labels = toArray(composerTemplate.ComposerLabel).map(function (entry) {
|
|
444
|
+
return entry.$_name;
|
|
445
|
+
}).filter(function (label) {
|
|
446
|
+
return !(configItem.printLabelBlacklist || []).includes(label);
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
printTemplate["default"] = configItem.defaultPrintLayout === printTemplate.name;
|
|
450
|
+
if (composerTemplate.$_atlasEnabled === '1') {
|
|
451
|
+
var atlasLayer = composerTemplate.$_atlasCoverageLayer;
|
|
452
|
+
try {
|
|
453
|
+
var layers = flatLayers(capabilities.Capability.Layer);
|
|
454
|
+
var pk = layers.find(function (l) {
|
|
455
|
+
return l.Name === atlasLayer;
|
|
456
|
+
}).PrimaryKey.PrimaryKeyAttribute;
|
|
457
|
+
printTemplate.atlasCoverageLayer = atlasLayer;
|
|
458
|
+
printTemplate.atlas_pk = pk;
|
|
459
|
+
} catch (e) {
|
|
460
|
+
/* eslint-disable-next-line */
|
|
461
|
+
console.warn("Failed to determine primary key for atlas layer " + atlasLayer);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
printTemplates.push(printTemplate);
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// drawing order
|
|
469
|
+
var drawingOrder = (capabilities.Capability.LayerDrawingOrder || "").split(",").map(function (title) {
|
|
470
|
+
return title in titleNameMap ? titleNameMap[title] : title;
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
// update theme config
|
|
474
|
+
resultItem.url = configItem.url;
|
|
475
|
+
resultItem.id = uniqueThemeId(configItem.id || wmsName);
|
|
476
|
+
resultItem.name = topLayer.Name;
|
|
477
|
+
resultItem.title = wmsTitle;
|
|
478
|
+
resultItem.description = configItem.description || "";
|
|
479
|
+
resultItem.attribution = {
|
|
480
|
+
Title: configItem.attribution || "",
|
|
481
|
+
OnlineResource: configItem.attributionUrl || ""
|
|
482
|
+
};
|
|
483
|
+
// service info
|
|
484
|
+
resultItem["abstract"] = capabilities.Service.Abstract || "";
|
|
485
|
+
resultItem.keywords = keywords.join(', ');
|
|
486
|
+
resultItem.onlineResource = capabilities.Service.OnlineResource.$_href;
|
|
487
|
+
resultItem.contact = {
|
|
488
|
+
person: objectPath.get(capabilities, "Service.ContactInformation.ContactPersonPrimary.ContactPerson", ""),
|
|
489
|
+
organization: objectPath.get(capabilities, "Service.ContactInformation.ContactPersonPrimary.ContactOrganization", ""),
|
|
490
|
+
position: objectPath.get(capabilities, "Service.ContactInformation.ContactPosition", ""),
|
|
491
|
+
phone: objectPath.get(capabilities, "Service.ContactInformation.ContactVoiceTelephone", ""),
|
|
492
|
+
email: objectPath.get(capabilities, "Service.ContactInformation.ContactElectronicMailAddress", "")
|
|
493
|
+
};
|
|
494
|
+
resultItem.format = configItem.format;
|
|
495
|
+
resultItem.availableFormats = capabilities.Capability.Request.GetMap.Format;
|
|
496
|
+
resultItem.tiled = configItem.tiled;
|
|
497
|
+
resultItem.tileSize = configItem.tileSize;
|
|
498
|
+
resultItem.version = configItem.version ? configItem.version : config.defaultWMSVersion;
|
|
499
|
+
resultItem.infoFormats = capabilities.Capability.Request.GetFeatureInfo.Format;
|
|
500
|
+
// use geographic bounding box for theme, as default CRS may have inverted axis order with WMS 1.3.0
|
|
501
|
+
var bounds = [parseFloat(topLayer.EX_GeographicBoundingBox.westBoundLongitude), parseFloat(topLayer.EX_GeographicBoundingBox.southBoundLatitude), parseFloat(topLayer.EX_GeographicBoundingBox.eastBoundLongitude), parseFloat(topLayer.EX_GeographicBoundingBox.northBoundLatitude)];
|
|
502
|
+
resultItem.bbox = {
|
|
503
|
+
crs: "EPSG:4326",
|
|
504
|
+
bounds: bounds
|
|
505
|
+
};
|
|
506
|
+
if (configItem.extent) {
|
|
507
|
+
resultItem.initialBbox = {
|
|
508
|
+
crs: configItem.mapCrs || result.themes.defaultMapCrs,
|
|
509
|
+
bounds: configItem.extent
|
|
510
|
+
};
|
|
511
|
+
} else {
|
|
512
|
+
resultItem.initialBbox = resultItem.bbox;
|
|
513
|
+
}
|
|
514
|
+
resultItem.scales = configItem.scales;
|
|
515
|
+
resultItem.printScales = configItem.printScales;
|
|
516
|
+
resultItem.printResolutions = configItem.printResolutions;
|
|
517
|
+
resultItem.printGrid = configItem.printGrid;
|
|
518
|
+
// NOTE: skip root WMS layer
|
|
519
|
+
resultItem.sublayers = isEmpty(layerTree) ? [] : layerTree[0].sublayers;
|
|
520
|
+
resultItem.expanded = true;
|
|
521
|
+
resultItem.externalLayers = externalLayers;
|
|
522
|
+
resultItem.backgroundLayers = configItem.backgroundLayers;
|
|
523
|
+
resultItem.searchProviders = configItem.searchProviders;
|
|
524
|
+
resultItem.additionalMouseCrs = configItem.additionalMouseCrs;
|
|
525
|
+
resultItem.mapCrs = configItem.mapCrs || result.themes.defaultMapCrs;
|
|
526
|
+
resultItem.defaultDisplayCrs = configItem.defaultDisplayCrs;
|
|
527
|
+
if (printTemplates.length > 0) {
|
|
528
|
+
resultItem.print = printTemplates;
|
|
529
|
+
}
|
|
530
|
+
resultItem.drawingOrder = drawingOrder;
|
|
531
|
+
if (configItem.extraDxfParameters) {
|
|
532
|
+
resultItem.extraDxfParameters = configItem.extraDxfParameters;
|
|
533
|
+
}
|
|
534
|
+
if (configItem.extraPrintParameters) {
|
|
535
|
+
resultItem.extraPrintParameters = configItem.extraPrintParameters;
|
|
536
|
+
}
|
|
537
|
+
if (configItem.legendUrl) {
|
|
538
|
+
resultItem.legendUrl = configItem.legendUrl;
|
|
539
|
+
} else {
|
|
540
|
+
resultItem.legendUrl = capabilities.Capability.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.$_href.replace(/\?$/, "") + "?" + (configItem.extraLegendParameters ? configItem.extraLegendParameters : '');
|
|
541
|
+
}
|
|
542
|
+
if (configItem.featureInfoUrl) {
|
|
543
|
+
resultItem.featureInfoUrl = configItem.featureInfoUrl;
|
|
544
|
+
} else {
|
|
545
|
+
resultItem.featureInfoUrl = capabilities.Capability.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.$_href.replace(/\?$/, "") + "?";
|
|
546
|
+
}
|
|
547
|
+
if (configItem.printUrl) {
|
|
548
|
+
resultItem.printUrl = configItem.printUrl;
|
|
549
|
+
} else {
|
|
550
|
+
resultItem.printUrl = capabilities.Capability.Request.GetPrint.DCPType.HTTP.Get.OnlineResource.$_href.replace(/\?$/, "") + "?";
|
|
551
|
+
}
|
|
552
|
+
if (configItem.printLabelForSearchResult) {
|
|
553
|
+
resultItem.printLabelForSearchResult = configItem.printLabelForSearchResult;
|
|
554
|
+
}
|
|
555
|
+
if (configItem.printLabelForAttribution) {
|
|
556
|
+
resultItem.printLabelForAttribution = configItem.printLabelForAttribution;
|
|
557
|
+
}
|
|
558
|
+
if (configItem.printLabelConfig) {
|
|
559
|
+
resultItem.printLabelConfig = configItem.printLabelConfig;
|
|
560
|
+
}
|
|
561
|
+
if (configItem.watermark) {
|
|
562
|
+
resultItem.watermark = configItem.watermark;
|
|
563
|
+
}
|
|
564
|
+
if (configItem.pluginData) {
|
|
565
|
+
resultItem.pluginData = configItem.pluginData;
|
|
566
|
+
}
|
|
567
|
+
if (configItem.predefinedFilters) {
|
|
568
|
+
resultItem.predefinedFilters = configItem.predefinedFilters;
|
|
569
|
+
}
|
|
570
|
+
if (configItem.snapping) {
|
|
571
|
+
resultItem.snapping = configItem.snapping;
|
|
572
|
+
}
|
|
573
|
+
if (configItem.minSearchScaleDenom) {
|
|
574
|
+
resultItem.minSearchScaleDenom = configItem.minSearchScaleDenom;
|
|
575
|
+
} else if (configItem.minSearchScale) {
|
|
576
|
+
// Legacy name
|
|
577
|
+
resultItem.minSearchScaleDenom = configItem.minSearchScale;
|
|
578
|
+
}
|
|
579
|
+
if (configItem.themeInfoLinks) {
|
|
580
|
+
resultItem.themeInfoLinks = configItem.themeInfoLinks;
|
|
581
|
+
}
|
|
582
|
+
if (configItem.layerTreeHiddenSublayers) {
|
|
583
|
+
resultItem.layerTreeHiddenSublayers = configItem.layerTreeHiddenSublayers;
|
|
584
|
+
}
|
|
585
|
+
resultItem.skipEmptyFeatureAttributes = configItem.skipEmptyFeatureAttributes;
|
|
586
|
+
resultItem.config = configItem.config;
|
|
587
|
+
resultItem.flags = configItem.flags;
|
|
588
|
+
resultItem.mapTips = configItem.mapTips;
|
|
589
|
+
resultItem.userMap = configItem.userMap;
|
|
590
|
+
resultItem.map3d = configItem.map3d;
|
|
591
|
+
resultItem.viewMode = configItem.viewMode;
|
|
592
|
+
resultItem.editConfig = getEditConfig(configItem.editConfig);
|
|
593
|
+
|
|
594
|
+
// set default theme
|
|
595
|
+
if (configItem["default"] || !result.themes.defaultTheme) {
|
|
596
|
+
result.themes.defaultTheme = resultItem.id;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// get thumbnail asynchronously
|
|
600
|
+
getThumbnail(configItem, resultItem, visibleLayers, crs, extent, resolve, proxy);
|
|
601
|
+
})["catch"](function (error) {
|
|
602
|
+
/* eslint-disable-next-line */
|
|
603
|
+
console.error("ERROR reading WMS GetProjectSettings of " + configItem.url + ":\n", error);
|
|
604
|
+
resultItem.error = "Could not read GetProjectSettings";
|
|
605
|
+
resultItem.title = "Error";
|
|
606
|
+
// finish task
|
|
607
|
+
reject(resultItem.error);
|
|
608
|
+
});
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// asynchronous tasks
|
|
613
|
+
var tasks = [];
|
|
614
|
+
|
|
615
|
+
// recursively get themes for groups
|
|
616
|
+
function getGroupThemes(config, configGroup, result, resultGroup, proxy, groupCounter) {
|
|
617
|
+
var _iterator5 = _createForOfIteratorHelper(configGroup.items),
|
|
618
|
+
_step5;
|
|
619
|
+
try {
|
|
620
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
621
|
+
var item = _step5.value;
|
|
622
|
+
var itemEntry = {};
|
|
623
|
+
var task = getTheme(config, item, result, itemEntry, proxy);
|
|
624
|
+
if (task) {
|
|
625
|
+
tasks.push(task);
|
|
626
|
+
resultGroup.items.push(itemEntry);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
} catch (err) {
|
|
630
|
+
_iterator5.e(err);
|
|
631
|
+
} finally {
|
|
632
|
+
_iterator5.f();
|
|
633
|
+
}
|
|
634
|
+
if (configGroup.groups !== undefined) {
|
|
635
|
+
var _iterator6 = _createForOfIteratorHelper(configGroup.groups),
|
|
636
|
+
_step6;
|
|
637
|
+
try {
|
|
638
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
639
|
+
var group = _step6.value;
|
|
640
|
+
var groupEntry = {
|
|
641
|
+
id: 'g' + ++groupCounter,
|
|
642
|
+
title: group.title,
|
|
643
|
+
items: [],
|
|
644
|
+
subdirs: []
|
|
645
|
+
};
|
|
646
|
+
getGroupThemes(config, group, result, groupEntry, proxy, groupCounter);
|
|
647
|
+
resultGroup.subdirs.push(groupEntry);
|
|
648
|
+
}
|
|
649
|
+
} catch (err) {
|
|
650
|
+
_iterator6.e(err);
|
|
651
|
+
} finally {
|
|
652
|
+
_iterator6.f();
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
function genThemes(themesConfig) {
|
|
657
|
+
// load themesConfig.json
|
|
658
|
+
var config = JSON.parse(fs.readFileSync(process.cwd() + '/' + themesConfig, "utf8"));
|
|
659
|
+
var result = {
|
|
660
|
+
themes: {
|
|
661
|
+
title: "root",
|
|
662
|
+
subdirs: [],
|
|
663
|
+
items: [],
|
|
664
|
+
defaultTheme: config.defaultTheme,
|
|
665
|
+
defaultMapCrs: config.defaultMapCrs || 'EPSG:3857',
|
|
666
|
+
defaultDisplayCrs: config.defaultDisplayCrs,
|
|
667
|
+
defaultScales: config.defaultScales,
|
|
668
|
+
defaultPrintScales: config.defaultPrintScales,
|
|
669
|
+
defaultPrintResolutions: config.defaultPrintResolutions,
|
|
670
|
+
defaultPrintGrid: config.defaultPrintGrid,
|
|
671
|
+
defaultSearchProviders: config.defaultSearchProviders,
|
|
672
|
+
defaultBackgroundLayers: config.defaultBackgroundLayers || [],
|
|
673
|
+
externalLayers: config.themes.externalLayers || [],
|
|
674
|
+
pluginData: config.themes.pluginData,
|
|
675
|
+
themeInfoLinks: config.themes.themeInfoLinks,
|
|
676
|
+
backgroundLayers: config.themes.backgroundLayers.map(function (bglayer) {
|
|
677
|
+
bglayer.attribution = {
|
|
678
|
+
Title: bglayer.attribution,
|
|
679
|
+
OnlineResource: bglayer.attributionUrl
|
|
680
|
+
};
|
|
681
|
+
delete bglayer.attributionUrl;
|
|
682
|
+
return bglayer;
|
|
683
|
+
}),
|
|
684
|
+
defaultWMSVersion: config.defaultWMSVersion
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
var proxy = config.proxy || null;
|
|
688
|
+
var groupCounter = 0;
|
|
689
|
+
getGroupThemes(config, config.themes, result, result.themes, proxy, groupCounter);
|
|
690
|
+
Promise.all(tasks).then(function () {
|
|
691
|
+
for (var _i = 0, _autogenExternalLayer = autogenExternalLayers; _i < _autogenExternalLayer.length; _i++) {
|
|
692
|
+
var entry = _autogenExternalLayer[_i];
|
|
693
|
+
var cpos = entry.indexOf(":");
|
|
694
|
+
var hpos = entry.lastIndexOf('#');
|
|
695
|
+
var type = entry.slice(0, cpos);
|
|
696
|
+
var url = entry.slice(cpos + 1, hpos);
|
|
697
|
+
var layername = entry.slice(hpos + 1);
|
|
698
|
+
result.themes.externalLayers.push({
|
|
699
|
+
name: entry,
|
|
700
|
+
type: type,
|
|
701
|
+
url: url,
|
|
702
|
+
params: {
|
|
703
|
+
LAYERS: layername
|
|
704
|
+
},
|
|
705
|
+
infoFormats: ["text/plain"]
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
if (result.themes.backgroundLayers !== undefined) {
|
|
709
|
+
// get thumbnails for background layers
|
|
710
|
+
result.themes.backgroundLayers.map(function (backgroundLayer) {
|
|
711
|
+
var imgPath = "img/mapthumbs/" + backgroundLayer.thumbnail;
|
|
712
|
+
if (!fs.existsSync("./static/assets/" + imgPath)) {
|
|
713
|
+
imgPath = "img/mapthumbs/default.jpg";
|
|
714
|
+
}
|
|
715
|
+
backgroundLayer.thumbnail = imgPath;
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// write config file
|
|
720
|
+
fs.writeFile(process.cwd() + '/static/themes.json', JSON.stringify(result, null, 2), function (error) {
|
|
721
|
+
if (error) {
|
|
722
|
+
/* eslint-disable-next-line */
|
|
723
|
+
console.error("ERROR:", error);
|
|
724
|
+
process.exit(1);
|
|
725
|
+
} else {
|
|
726
|
+
/* eslint-disable-next-line */
|
|
727
|
+
console.log("\nCreated themes.json\n\n");
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
})["catch"](function (error) {
|
|
731
|
+
/* eslint-disable-next-line */
|
|
732
|
+
console.error("ERROR:", error);
|
|
733
|
+
process.exit(1);
|
|
734
|
+
});
|
|
735
|
+
return result;
|
|
736
|
+
}
|
|
737
|
+
lookup(os.hostname(), {
|
|
738
|
+
hints: dns.ADDRCONFIG
|
|
739
|
+
}).then(function (result) {
|
|
740
|
+
return lookupService(result.address, 0);
|
|
741
|
+
}).then(function (result) {
|
|
742
|
+
hostFqdn = "http://" + result.hostname;
|
|
743
|
+
/* eslint-disable-next-line */
|
|
744
|
+
console.log("Reading " + themesConfigPath);
|
|
745
|
+
genThemes(themesConfigPath);
|
|
746
|
+
})["catch"](function (error) {
|
|
747
|
+
process.nextTick(function () {
|
|
748
|
+
throw error;
|
|
749
|
+
});
|
|
750
|
+
});
|