qwc2 2025.10.9 → 2025.10.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/display.js +30 -1
- package/actions/editing.js +22 -1
- package/actions/layerinfo.js +13 -1
- package/actions/layers.js +213 -3
- package/actions/localConfig.js +58 -1
- package/actions/locale.js +21 -1
- package/actions/locate.js +26 -1
- package/actions/logging.js +10 -1
- package/actions/map.js +105 -2
- package/actions/measurement.js +12 -1
- package/actions/processNotifications.js +37 -1
- package/actions/redlining.js +18 -1
- package/actions/redliningPick.js +12 -1
- package/actions/search.js +12 -1
- package/actions/serviceinfo.js +12 -1
- package/actions/task.js +55 -3
- package/actions/theme.js +339 -19
- package/actions/windows.js +164 -5
- package/components/AppMenu.js +435 -3
- package/components/AttributeForm.js +928 -32
- package/components/AttributeTableWidget.js +1105 -13
- package/components/AutoEditForm.js +189 -3
- package/components/CoordinateDisplayer.js +78 -2
- package/components/EditComboField.js +190 -6
- package/components/EditUploadField.js +315 -3
- package/components/ExportSelection.js +203 -2
- package/components/FullscreenSwitcher.js +90 -3
- package/components/Icon.js +81 -2
- package/components/IdentifyViewer.js +1161 -6
- package/components/ImportLayer.js +718 -20
- package/components/LayerInfoWindow.js +145 -2
- package/components/LinkFeatureForm.js +246 -5
- package/components/MapButton.js +88 -2
- package/components/MapSelection.js +287 -8
- package/components/MessageBar.js +68 -2
- package/components/NumericInputWindow.js +359 -2
- package/components/PickFeature.js +266 -2
- package/components/PluginsContainer.js +227 -8
- package/components/PrintSelection.js +620 -49
- package/components/ProcessNotifications.js +104 -2
- package/components/QtDesignerForm.js +1137 -18
- package/components/ResizeableWindow.js +591 -8
- package/components/SearchBox.js +1307 -20
- package/components/ServiceInfoWindow.js +107 -2
- package/components/SideBar.js +204 -4
- package/components/StandardApp.js +381 -20
- package/components/Swipeable.js +15 -1
- package/components/TaskBar.js +85 -2
- package/components/ThemeLayersListWindow.js +216 -4
- package/components/ThemeList.js +381 -7
- package/components/Toolbar.js +106 -2
- package/components/WindowManager.js +178 -2
- package/components/map/OlLayer.js +257 -6
- package/components/map/OlMap.js +405 -5
- package/components/map/layers/BingLayer.js +31 -2
- package/components/map/layers/GoogleLayer.js +222 -19
- package/components/map/layers/GraticuleLayer.js +21 -1
- package/components/map/layers/ImageLayer.js +15 -1
- package/components/map/layers/MVTLayer.js +52 -2
- package/components/map/layers/OSMLayer.js +24 -2
- package/components/map/layers/OverlayLayer.js +55 -3
- package/components/map/layers/VectorLayer.js +173 -8
- package/components/map/layers/WFSLayer.js +220 -6
- package/components/map/layers/WMSLayer.js +180 -6
- package/components/map/layers/WMTSLayer.js +67 -3
- package/components/map/layers/XYZLayer.js +24 -2
- package/components/map/layers/index.js +28 -1
- package/components/map3d/EditDataset3D.js +190 -3
- package/components/map3d/HeightProfile3D.js +402 -3
- package/components/map3d/ImportObjects3D.js +162 -2
- package/components/map3d/Map3D.js +1304 -38
- package/components/map3d/MapControls3D.js +392 -7
- package/components/map3d/SearchField3D.js +183 -11
- package/components/map3d/View3DSwitcher.js +98 -2
- package/components/map3d/drawtool/CreateTool3D.js +174 -4
- package/components/map3d/drawtool/EditTool3D.js +590 -6
- package/components/map3d/drawtool/NumericInput3D.js +336 -4
- package/components/map3d/layers/GeoTIFFLayer3D.js +15 -1
- package/components/map3d/layers/VectorLayer3D.js +53 -2
- package/components/map3d/layers/WFSLayer3D.js +109 -3
- package/components/map3d/layers/WMSLayer3D.js +70 -2
- package/components/map3d/layers/WMTSLayer3D.js +27 -3
- package/components/map3d/layers/index.js +14 -1
- package/components/map3d/utils/FirstPersonControls3D.js +423 -16
- package/components/map3d/utils/MiscUtils3D.js +221 -13
- package/components/map3d/utils/OrbitControls3D.js +176 -5
- package/components/map3d/utils/Tiles3DStyle.js +238 -9
- package/components/share/ShareLink.js +54 -2
- package/components/share/ShareQRCode.js +62 -2
- package/components/share/ShareSocials.js +125 -3
- package/components/timeline/FixedTimeline.js +236 -5
- package/components/timeline/InfiniteTimeline.js +347 -8
- package/components/timeline/TimelineFeaturesSlider.js +439 -5
- package/components/widgets/AccordeonWidget.js +96 -2
- package/components/widgets/ButtonBar.js +124 -2
- package/components/widgets/ColorButton.js +201 -3
- package/components/widgets/ComboBox.js +166 -2
- package/components/widgets/CopyButton.js +110 -2
- package/components/widgets/DateTimeInput.js +100 -3
- package/components/widgets/EditableSelect.js +230 -3
- package/components/widgets/FileSelector.js +128 -4
- package/components/widgets/Input.js +124 -2
- package/components/widgets/InputContainer.js +96 -2
- package/components/widgets/LayerCatalogWidget.js +219 -3
- package/components/widgets/MenuButton.js +157 -1
- package/components/widgets/ModalDialog.js +64 -2
- package/components/widgets/NavBar.js +119 -2
- package/components/widgets/NumberInput.js +226 -4
- package/components/widgets/PopupMenu.js +72 -1
- package/components/widgets/Primitives.js +6 -1
- package/components/widgets/ReCaptchaWidget.js +55 -1
- package/components/widgets/SearchWidget.js +255 -2
- package/components/widgets/Spinner.js +44 -2
- package/components/widgets/SuggestionInput.js +77 -2
- package/components/widgets/TextInput.js +308 -2
- package/components/widgets/ToggleSwitch.js +85 -2
- package/components/widgets/VectorLayerPicker.js +85 -3
- package/libs/openlayers.js +225 -5
- package/package.json +1 -1
- package/plugins/API.js +358 -15
- package/plugins/AttributeTable.js +109 -3
- package/plugins/Authentication.js +130 -5
- package/plugins/BackgroundSwitcher.js +218 -4
- package/plugins/Bookmark.js +289 -3
- package/plugins/BottomBar.js +298 -4
- package/plugins/CookiePopup.js +67 -3
- package/plugins/Cyclomedia.js +442 -5
- package/plugins/Editing.js +497 -9
- package/plugins/FeatureForm.js +366 -4
- package/plugins/FeatureSearch.js +458 -3
- package/plugins/GeometryDigitizer.js +664 -7
- package/plugins/HeightProfile.js +763 -15
- package/plugins/Help.js +102 -3
- package/plugins/HomeButton.js +80 -3
- package/plugins/Identify.js +543 -5
- package/plugins/LayerCatalog.js +215 -4
- package/plugins/LayerTree.js +1194 -6
- package/plugins/LocateButton.js +94 -3
- package/plugins/Map.js +320 -16
- package/plugins/MapCompare.js +94 -3
- package/plugins/MapCopyright.js +127 -5
- package/plugins/MapExport.js +613 -20
- package/plugins/MapFilter.js +868 -12
- package/plugins/MapInfoTooltip.js +277 -3
- package/plugins/MapLegend.js +253 -4
- package/plugins/MapTip.js +290 -4
- package/plugins/Measure.js +220 -4
- package/plugins/NewsPopup.js +137 -3
- package/plugins/OverviewMap.js +167 -7
- package/plugins/Panoramax.js +340 -2
- package/plugins/Portal.js +199 -4
- package/plugins/Print.js +1231 -15
- package/plugins/Redlining.js +750 -6
- package/plugins/Reports.js +332 -3
- package/plugins/Routing.js +1278 -15
- package/plugins/ScratchDrawing.js +173 -5
- package/plugins/Settings.js +241 -4
- package/plugins/Share.js +198 -3
- package/plugins/StartupMarker.js +84 -4
- package/plugins/TaskButton.js +88 -3
- package/plugins/ThemeSwitcher.js +164 -4
- package/plugins/TimeManager.js +971 -10
- package/plugins/TopBar.js +300 -7
- package/plugins/TourGuide.js +213 -2
- package/plugins/ValueTool.js +419 -4
- package/plugins/View3D.js +519 -14
- package/plugins/ZoomButtons.js +165 -3
- package/plugins/map/EditingSupport.js +199 -7
- package/plugins/map/LocateSupport.js +260 -4
- package/plugins/map/MeasurementSupport.js +216 -8
- package/plugins/map/RedliningPickSupport.js +201 -7
- package/plugins/map/RedliningSupport.js +726 -17
- package/plugins/map/SnapInteraction.js +101 -1
- package/plugins/map/SnapSupport.js +210 -2
- package/plugins/map/SnappingSupport.js +356 -17
- package/plugins/map3d/BackgroundSwitcher3D.js +44 -3
- package/plugins/map3d/BottomBar3D.js +118 -3
- package/plugins/map3d/Compare3D.js +422 -8
- package/plugins/map3d/Draw3D.js +353 -6
- package/plugins/map3d/ExportObjects3D.js +393 -18
- package/plugins/map3d/HideObjects3D.js +313 -12
- package/plugins/map3d/Identify3D.js +283 -12
- package/plugins/map3d/LayerTree3D.js +323 -3
- package/plugins/map3d/MapCopyright3D.js +128 -5
- package/plugins/map3d/MapExport3D.js +590 -10
- package/plugins/map3d/MapLight3D.js +553 -6
- package/plugins/map3d/Measure3D.js +571 -20
- package/plugins/map3d/OverviewMap3D.js +169 -3
- package/plugins/map3d/Settings3D.js +73 -3
- package/plugins/map3d/TopBar3D.js +207 -9
- package/plugins/redlining/RedliningBufferSupport.js +206 -3
- package/reducers/display.js +34 -2
- package/reducers/editing.js +68 -3
- package/reducers/index.js +9 -1
- package/reducers/layerinfo.js +26 -2
- package/reducers/layers.js +456 -9
- package/reducers/localConfig.js +122 -2
- package/reducers/locale.js +38 -2
- package/reducers/locate.js +40 -2
- package/reducers/map.js +176 -5
- package/reducers/measurement.js +42 -2
- package/reducers/processNotifications.js +49 -2
- package/reducers/redlining.js +50 -2
- package/reducers/redliningPick.js +27 -2
- package/reducers/search.js +20 -1
- package/reducers/serviceinfo.js +25 -2
- package/reducers/task.js +45 -2
- package/reducers/theme.js +51 -2
- package/reducers/windows.js +203 -2
- package/scripts/dist.sh +1 -1
- package/scripts/gen-plugin-docs.js +152 -2
- package/scripts/makeIconkit.js +85 -6
- package/scripts/themesConfig.js +742 -40
- package/scripts/updateTranslations.js +251 -10
- package/selectors/searchproviders.js +44 -2
- package/stores/StandardStore.js +42 -2
- package/utils/ConfigUtils.js +84 -3
- package/utils/CoordinatesUtils.js +234 -23
- package/utils/DxfUtils.js +237 -11
- package/utils/EditingInterface.js +421 -87
- package/utils/EditingUtils.js +357 -13
- package/utils/ElevationInterface.js +83 -22
- package/utils/FeatureStyles.js +429 -5
- package/utils/IdentifyUtils.js +443 -7
- package/utils/ImageEditor.js +79 -9
- package/utils/LayerUtils.js +1516 -50
- package/utils/LocaleUtils.js +117 -7
- package/utils/MapUtils.js +241 -59
- package/utils/MeasureUtils.js +323 -2
- package/utils/MiscUtils.js +189 -11
- package/utils/PermaLinkUtils.js +429 -6
- package/utils/PluginStore.js +27 -1
- package/utils/ResourceRegistry.js +15 -1
- package/utils/RoutingInterface.js +307 -7
- package/utils/SearchProviders.js +722 -19
- package/utils/ServiceLayerUtils.js +669 -14
- package/utils/Signal.js +32 -2
- package/utils/ThemeUtils.js +341 -7
- package/utils/VectorLayerUtils.js +589 -15
- package/utils/expr_grammar/grammar.js +2239 -2
- package/utils/expr_grammar/test.js +65 -3
package/utils/IdentifyUtils.js
CHANGED
|
@@ -1,12 +1,448 @@
|
|
|
1
|
-
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?
|
|
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 _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; } }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
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; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
9
|
+
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); }
|
|
10
|
+
/**
|
|
2
11
|
* Copyright 2016-2024 Sourcepole AG
|
|
3
12
|
* All rights reserved.
|
|
4
13
|
*
|
|
5
14
|
* This source code is licensed under the BSD-style license found in the
|
|
6
15
|
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import axios from 'axios';
|
|
19
|
+
import geojsonBbox from 'geojson-bounding-box';
|
|
20
|
+
import isEmpty from 'lodash.isempty';
|
|
21
|
+
import ol from 'openlayers';
|
|
22
|
+
import url from 'url';
|
|
23
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
24
|
+
import { LayerRole } from '../actions/layers';
|
|
25
|
+
import ConfigUtils from '../utils/ConfigUtils';
|
|
26
|
+
import CoordinatesUtils from '../utils/CoordinatesUtils';
|
|
27
|
+
import LayerUtils from '../utils/LayerUtils';
|
|
28
|
+
import MapUtils from '../utils/MapUtils';
|
|
29
|
+
import VectorLayerUtils from './VectorLayerUtils';
|
|
30
|
+
function identifyRequestParams(layer, queryLayers, projection, params) {
|
|
31
|
+
var _layer$format;
|
|
32
|
+
var format = 'text/plain';
|
|
33
|
+
var infoFormats = layer.infoFormats || [];
|
|
34
|
+
if (infoFormats.includes('text/xml') && (layer.serverType === 'qgis' || infoFormats.length === 1)) {
|
|
35
|
+
format = 'text/xml';
|
|
36
|
+
} else if (infoFormats.includes('application/geojson')) {
|
|
37
|
+
format = 'application/geojson';
|
|
38
|
+
} else if (infoFormats.includes('application/geo+json')) {
|
|
39
|
+
format = 'application/geo+json';
|
|
40
|
+
} else if (infoFormats.includes('application/json')) {
|
|
41
|
+
format = 'application/json';
|
|
42
|
+
} else if (infoFormats.includes('text/xml;subtype=gml/3.2.1')) {
|
|
43
|
+
format = 'text/xml;subtype=gml/3.2.1';
|
|
44
|
+
} else if (infoFormats.includes('text/xml;subtype=gml/3.2.0')) {
|
|
45
|
+
format = 'text/xml;subtype=gml/3.2.0';
|
|
46
|
+
} else if (infoFormats.includes('text/xml;subtype=gml/3.2')) {
|
|
47
|
+
format = 'text/xml;subtype=gml/3.2';
|
|
48
|
+
} else if (infoFormats.includes('text/xml;subtype=gml/3.1.1')) {
|
|
49
|
+
format = 'text/xml;subtype=gml/3.1.1';
|
|
50
|
+
} else if (infoFormats.includes('text/xml;subtype=gml/3.1.0')) {
|
|
51
|
+
format = 'text/xml;subtype=gml/3.1.0';
|
|
52
|
+
} else if (infoFormats.includes('text/xml;subtype=gml/3.1')) {
|
|
53
|
+
format = 'text/xml;subtype=gml/3.1';
|
|
54
|
+
} else if (infoFormats.includes('text/xml;subtype=gml/3.0')) {
|
|
55
|
+
format = 'text/xml;subtype=gml/3.0';
|
|
56
|
+
} else if (infoFormats.includes('text/html')) {
|
|
57
|
+
format = 'text/html';
|
|
58
|
+
} else if (infoFormats.includes('application/vnd.ogc.gml')) {
|
|
59
|
+
format = 'application/vnd.ogc.gml';
|
|
60
|
+
}
|
|
61
|
+
var styles = (layer.params.STYLES || "").split(',');
|
|
62
|
+
var styleMap = layer.params.LAYERS.split(',').reduce(function (res, lyr, idx) {
|
|
63
|
+
var _styles$idx;
|
|
64
|
+
return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, lyr, (_styles$idx = styles[idx]) !== null && _styles$idx !== void 0 ? _styles$idx : ''));
|
|
65
|
+
});
|
|
66
|
+
var queryStyles = queryLayers.split(',').map(function (lyr) {
|
|
67
|
+
var _styleMap$lyr;
|
|
68
|
+
return (_styleMap$lyr = styleMap[lyr]) !== null && _styleMap$lyr !== void 0 ? _styleMap$lyr : '';
|
|
69
|
+
}).join(",");
|
|
70
|
+
return {
|
|
71
|
+
url: layer.featureInfoUrl.split("?")[0],
|
|
72
|
+
params: _objectSpread(_objectSpread(_objectSpread({}, url.parse(layer.featureInfoUrl, true).query), {}, {
|
|
73
|
+
service: 'WMS',
|
|
74
|
+
version: layer.version,
|
|
75
|
+
request: 'GetFeatureInfo',
|
|
76
|
+
id: layer.id,
|
|
77
|
+
layers: queryLayers,
|
|
78
|
+
query_layers: queryLayers,
|
|
79
|
+
styles: queryStyles,
|
|
80
|
+
srs: projection,
|
|
81
|
+
crs: projection,
|
|
82
|
+
format: (_layer$format = layer.format) !== null && _layer$format !== void 0 ? _layer$format : 'image/png',
|
|
83
|
+
info_format: format,
|
|
84
|
+
with_geometry: true,
|
|
85
|
+
with_maptip: false
|
|
86
|
+
}, layer.dimensionValues), params)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
var IdentifyUtils = {
|
|
90
|
+
getQueryLayers: function getQueryLayers(maplayers, map) {
|
|
91
|
+
var queryableLayers = maplayers.filter(function (l) {
|
|
92
|
+
// All non-background WMS layers with a non-empty queryLayers list
|
|
93
|
+
return l.visibility && l.type === 'wms' && l.role !== LayerRole.BACKGROUND && (l.queryLayers || []).length > 0;
|
|
94
|
+
});
|
|
95
|
+
var mapScale = MapUtils.computeForZoom(map.scales, map.zoom);
|
|
96
|
+
var result = [];
|
|
97
|
+
queryableLayers.forEach(function (layer) {
|
|
98
|
+
var layers = [];
|
|
99
|
+
var queryLayers = layer.queryLayers;
|
|
100
|
+
for (var i = 0; i < queryLayers.length; ++i) {
|
|
101
|
+
if (layer.externalLayerMap && layer.externalLayerMap[queryLayers[i]]) {
|
|
102
|
+
var sublayer = LayerUtils.searchSubLayer(layer, "name", queryLayers[i]);
|
|
103
|
+
var sublayerVisible = LayerUtils.layerScaleInRange(sublayer, mapScale);
|
|
104
|
+
if (!isEmpty(layer.externalLayerMap[queryLayers[i]].queryLayers) && sublayerVisible) {
|
|
105
|
+
layers.push(layer.externalLayerMap[queryLayers[i]]);
|
|
106
|
+
}
|
|
107
|
+
} else if (layers.length > 0 && layers[layers.length - 1].id === layer.id) {
|
|
108
|
+
layers[layers.length - 1].queryLayers.push(queryLayers[i]);
|
|
109
|
+
} else {
|
|
110
|
+
layers.push(_objectSpread(_objectSpread({}, layer), {}, {
|
|
111
|
+
queryLayers: [queryLayers[i]]
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
result = result.concat(layers);
|
|
116
|
+
});
|
|
117
|
+
return result;
|
|
118
|
+
},
|
|
119
|
+
buildRequest: function buildRequest(layer, queryLayers, center, map) {
|
|
120
|
+
var _layer$params$FILTER;
|
|
121
|
+
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
122
|
+
var size = [101, 101];
|
|
123
|
+
var resolution = MapUtils.computeForZoom(map.resolutions, map.zoom);
|
|
124
|
+
var dx = 0.5 * resolution * size[0];
|
|
125
|
+
var dy = 0.5 * resolution * size[1];
|
|
126
|
+
var version = layer.version;
|
|
127
|
+
var bbox = [center[0] - dx, center[1] - dy, center[0] + dx, center[1] + dy];
|
|
128
|
+
if (CoordinatesUtils.getAxisOrder(map.projection).substr(0, 2) === 'ne' && version === '1.3.0') {
|
|
129
|
+
bbox = [center[1] - dx, center[0] - dy, center[1] + dx, center[0] + dy];
|
|
130
|
+
}
|
|
131
|
+
var params = _objectSpread({
|
|
132
|
+
height: size[0],
|
|
133
|
+
width: size[1],
|
|
134
|
+
feature_count: 100,
|
|
135
|
+
x: Math.round(size[0] * 0.5),
|
|
136
|
+
y: Math.round(size[1] * 0.5),
|
|
137
|
+
i: Math.round(size[0] * 0.5),
|
|
138
|
+
j: Math.round(size[1] * 0.5),
|
|
139
|
+
bbox: bbox.join(","),
|
|
140
|
+
filter: (_layer$params$FILTER = layer.params.FILTER) !== null && _layer$params$FILTER !== void 0 ? _layer$params$FILTER : ''
|
|
141
|
+
}, options);
|
|
142
|
+
return identifyRequestParams(layer, queryLayers, map.projection, params);
|
|
143
|
+
},
|
|
144
|
+
buildFilterRequest: function buildFilterRequest(layer, queryLayers, filterGeom, map) {
|
|
145
|
+
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
146
|
+
var params = _objectSpread({
|
|
147
|
+
feature_count: 100,
|
|
148
|
+
FILTER_GEOM: filterGeom
|
|
149
|
+
}, options);
|
|
150
|
+
return identifyRequestParams(layer, queryLayers, map.projection, params);
|
|
151
|
+
},
|
|
152
|
+
sendRequest: function sendRequest(request, responseHandler) {
|
|
153
|
+
var urlParts = url.parse(request.url, true);
|
|
154
|
+
urlParts.query = _objectSpread(_objectSpread({}, urlParts.query), request.params);
|
|
155
|
+
delete urlParts.search;
|
|
156
|
+
var requestUrl = url.format(urlParts);
|
|
157
|
+
var maxUrlLength = ConfigUtils.getConfigProp("wmsMaxGetUrlLength", null, 2048);
|
|
158
|
+
if (requestUrl.length > maxUrlLength) {
|
|
159
|
+
// Switch to POST if url is too long
|
|
160
|
+
var reqUrlParts = requestUrl.split("?");
|
|
161
|
+
var options = {
|
|
162
|
+
headers: {
|
|
163
|
+
'content-type': 'application/x-www-form-urlencoded'
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
axios.post(reqUrlParts[0], reqUrlParts[1], options).then(function (postResp) {
|
|
167
|
+
responseHandler(postResp.data);
|
|
168
|
+
})["catch"](function () {
|
|
169
|
+
axios.get(request.url, {
|
|
170
|
+
params: request.params
|
|
171
|
+
}).then(function (getResp) {
|
|
172
|
+
responseHandler(getResp.data);
|
|
173
|
+
})["catch"](function () {
|
|
174
|
+
responseHandler(null);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
axios.get(request.url, {
|
|
179
|
+
params: request.params
|
|
180
|
+
}).then(function (getResp) {
|
|
181
|
+
responseHandler(getResp.data);
|
|
182
|
+
})["catch"](function () {
|
|
183
|
+
responseHandler(null);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
parseResponse: function parseResponse(response, layer, format, clickPoint, projection, featureInfoReturnsLayerName) {
|
|
188
|
+
var decimals = CoordinatesUtils.getPrecision(projection);
|
|
189
|
+
var posstr = clickPoint ? clickPoint[0].toFixed(decimals) + ", " + clickPoint[1].toFixed(decimals) : "";
|
|
190
|
+
var results = {};
|
|
191
|
+
if (["application/json", "application/geojson", "application/geo+json", "GeoJSON"].includes(format)) {
|
|
192
|
+
results = IdentifyUtils.parseGeoJSONResponse(response, projection, layer);
|
|
193
|
+
} else if (format === "text/xml") {
|
|
194
|
+
results = IdentifyUtils.parseXmlResponse(response, projection, layer, posstr, featureInfoReturnsLayerName);
|
|
195
|
+
} else if (format === "application/vnd.ogc.gml") {
|
|
196
|
+
results = IdentifyUtils.parseGmlResponse(response, projection, layer, posstr);
|
|
197
|
+
} else if (format.startsWith("text/xml;subtype=gml/3.1") || format.startsWith("text/xml;subtype=gml/3.0")) {
|
|
198
|
+
results = IdentifyUtils.parseGml3Response(response, projection, layer);
|
|
199
|
+
} else if (format.startsWith("text/xml;subtype=gml/3.2")) {
|
|
200
|
+
results = IdentifyUtils.parseGml32Response(response, projection, layer);
|
|
201
|
+
} else if (format === "text/plain") {
|
|
202
|
+
results[layer.name] = [{
|
|
203
|
+
type: "text",
|
|
204
|
+
text: response,
|
|
205
|
+
id: posstr,
|
|
206
|
+
layername: layer.name,
|
|
207
|
+
layertitle: layer.title
|
|
208
|
+
}];
|
|
209
|
+
} else if (format === "text/html") {
|
|
210
|
+
results[layer.name] = [{
|
|
211
|
+
type: "html",
|
|
212
|
+
text: response,
|
|
213
|
+
id: posstr,
|
|
214
|
+
layername: layer.name,
|
|
215
|
+
layertitle: layer.title
|
|
216
|
+
}];
|
|
217
|
+
}
|
|
218
|
+
// Add clickPos, bounding box, displayname and layer name / title
|
|
219
|
+
for (var _i = 0, _Object$keys = Object.keys(results); _i < _Object$keys.length; _i++) {
|
|
220
|
+
var layername = _Object$keys[_i];
|
|
221
|
+
var _iterator = _createForOfIteratorHelper(results[layername]),
|
|
222
|
+
_step;
|
|
223
|
+
try {
|
|
224
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
225
|
+
var _item$layertitle;
|
|
226
|
+
var item = _step.value;
|
|
227
|
+
if (item.type === "Feature" && !item.bbox && item.geometry) {
|
|
228
|
+
item.crs = projection;
|
|
229
|
+
item.bbox = geojsonBbox(item);
|
|
230
|
+
}
|
|
231
|
+
item.clickPos = clickPoint;
|
|
232
|
+
item.displayname = IdentifyUtils.determineDisplayName(layer, layername, item);
|
|
233
|
+
item.layertitle = (_item$layertitle = item.layertitle) !== null && _item$layertitle !== void 0 ? _item$layertitle : layername;
|
|
234
|
+
}
|
|
235
|
+
} catch (err) {
|
|
236
|
+
_iterator.e(err);
|
|
237
|
+
} finally {
|
|
238
|
+
_iterator.f();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return results;
|
|
242
|
+
},
|
|
243
|
+
determineDisplayName: function determineDisplayName(layer, layername, item) {
|
|
244
|
+
var properties = item.properties || {};
|
|
245
|
+
if (item.displayfield) {
|
|
246
|
+
if (properties[item.displayfield] && properties[item.displayfield][0] !== "<") {
|
|
247
|
+
return properties[item.displayfield];
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
var sublayer = LayerUtils.searchSubLayer(layer, 'name', layername);
|
|
251
|
+
if (sublayer && sublayer.displayField) {
|
|
252
|
+
if (properties[sublayer.displayField] && properties[sublayer.displayField][0] !== "<") {
|
|
253
|
+
return properties[sublayer.displayField];
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return properties.name || properties.Name || properties.NAME || item.id;
|
|
257
|
+
},
|
|
258
|
+
parseXmlFeature: function parseXmlFeature(feature, geometrycrs, id, featurereport, displayfield, layername, layertitle, layerinfo, translations) {
|
|
259
|
+
var featureResult = {};
|
|
260
|
+
featureResult.type = "Feature";
|
|
261
|
+
featureResult.id = id;
|
|
262
|
+
featureResult.featurereport = featurereport;
|
|
263
|
+
featureResult.displayfield = displayfield;
|
|
264
|
+
featureResult.layername = layername;
|
|
265
|
+
featureResult.layertitle = layertitle;
|
|
266
|
+
featureResult.layerinfo = layerinfo;
|
|
267
|
+
var bboxes = feature.getElementsByTagName("BoundingBox");
|
|
268
|
+
if (bboxes.length > 0) {
|
|
269
|
+
var bbox = bboxes[0];
|
|
270
|
+
var crs = bbox.attributes.CRS ? bbox.attributes.CRS.value : bbox.attributes.SRS.value;
|
|
271
|
+
featureResult.bbox = [parseFloat(bbox.attributes.minx.value), parseFloat(bbox.attributes.miny.value), parseFloat(bbox.attributes.maxx.value), parseFloat(bbox.attributes.maxy.value)];
|
|
272
|
+
featureResult.crs = crs;
|
|
273
|
+
}
|
|
274
|
+
featureResult.properties = {};
|
|
275
|
+
var attrmapping = {};
|
|
276
|
+
var attributes = feature.getElementsByTagName("Attribute");
|
|
277
|
+
for (var i = 0; i < attributes.length; ++i) {
|
|
278
|
+
var attribute = attributes[i];
|
|
279
|
+
if (attribute.attributes.name.value === "geometry") {
|
|
280
|
+
var wkt = attribute.attributes.value.value;
|
|
281
|
+
var geoJsonFeature = VectorLayerUtils.wktToGeoJSON(wkt, geometrycrs, featureResult.crs);
|
|
282
|
+
if (geoJsonFeature) {
|
|
283
|
+
featureResult.geometry = geoJsonFeature.geometry;
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
var _translations$layers$, _translations$layers;
|
|
287
|
+
var attrname = (_translations$layers$ = translations === null || translations === void 0 || (_translations$layers = translations.layers) === null || _translations$layers === void 0 || (_translations$layers = _translations$layers[layername]) === null || _translations$layers === void 0 || (_translations$layers = _translations$layers.fields) === null || _translations$layers === void 0 ? void 0 : _translations$layers[attribute.attributes.name.value]) !== null && _translations$layers$ !== void 0 ? _translations$layers$ : attribute.attributes.name.value;
|
|
288
|
+
featureResult.properties[attrname] = attribute.attributes.value.value;
|
|
289
|
+
if (attribute.attributes.attrname) {
|
|
290
|
+
attrmapping[attrname] = attribute.attributes.attrname.value;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
var htmlContent = feature.getElementsByTagName("HtmlContent");
|
|
295
|
+
if (htmlContent.length > 0) {
|
|
296
|
+
featureResult.properties.htmlContent = htmlContent[0].textContent;
|
|
297
|
+
featureResult.properties.htmlContentInline = htmlContent[0].getAttribute("inline") === "1" || htmlContent[0].getAttribute("inline") === "true";
|
|
298
|
+
}
|
|
299
|
+
if (!isEmpty(attrmapping)) {
|
|
300
|
+
featureResult.attribnames = attrmapping;
|
|
301
|
+
}
|
|
302
|
+
return featureResult;
|
|
303
|
+
},
|
|
304
|
+
parseXmlResponse: function parseXmlResponse(response, geometrycrs, layer) {
|
|
305
|
+
var _doc$firstChild,
|
|
306
|
+
_doc$firstChild$getEl,
|
|
307
|
+
_this = this;
|
|
308
|
+
var posstr = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
309
|
+
var featureInfoReturnsLayerName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
310
|
+
var mapLayers = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
|
|
311
|
+
var parser = new DOMParser();
|
|
312
|
+
var doc = parser.parseFromString(response, "text/xml");
|
|
313
|
+
var layersEl = [].slice.call(((_doc$firstChild = doc.firstChild) === null || _doc$firstChild === void 0 || (_doc$firstChild$getEl = _doc$firstChild.getElementsByTagName) === null || _doc$firstChild$getEl === void 0 ? void 0 : _doc$firstChild$getEl.call(_doc$firstChild, "Layer")) || []);
|
|
314
|
+
var result = {};
|
|
315
|
+
var idcounter = 0;
|
|
316
|
+
var _iterator2 = _createForOfIteratorHelper(layersEl),
|
|
317
|
+
_step2;
|
|
318
|
+
try {
|
|
319
|
+
var _loop = function _loop() {
|
|
320
|
+
var layerEl = _step2.value;
|
|
321
|
+
var featurereport = layerEl.attributes.featurereport ? layerEl.attributes.featurereport.value : null;
|
|
322
|
+
var displayfield = layerEl.attributes.displayfield ? layerEl.attributes.displayfield.value : null;
|
|
323
|
+
var layername = "";
|
|
324
|
+
var layertitle = "";
|
|
325
|
+
if (layerEl.attributes.layername) {
|
|
326
|
+
var _layer$translations$l, _layer$translations;
|
|
327
|
+
layername = layerEl.attributes.layername.value;
|
|
328
|
+
layertitle = (_layer$translations$l = (_layer$translations = layer.translations) === null || _layer$translations === void 0 || (_layer$translations = _layer$translations.layertree) === null || _layer$translations === void 0 ? void 0 : _layer$translations[layername]) !== null && _layer$translations$l !== void 0 ? _layer$translations$l : layerEl.attributes.name.value;
|
|
329
|
+
} else if (featureInfoReturnsLayerName) {
|
|
330
|
+
var _LayerUtils$searchSub, _LayerUtils$searchSub2;
|
|
331
|
+
layername = layerEl.attributes.name.value;
|
|
332
|
+
layertitle = (_LayerUtils$searchSub = (_LayerUtils$searchSub2 = LayerUtils.searchSubLayer(layer, 'name', layername)) === null || _LayerUtils$searchSub2 === void 0 ? void 0 : _LayerUtils$searchSub2.title) !== null && _LayerUtils$searchSub !== void 0 ? _LayerUtils$searchSub : layername;
|
|
333
|
+
} else {
|
|
334
|
+
var _LayerUtils$searchSub3, _LayerUtils$searchSub4;
|
|
335
|
+
layertitle = layerEl.attributes.name.value;
|
|
336
|
+
layername = (_LayerUtils$searchSub3 = (_LayerUtils$searchSub4 = LayerUtils.searchSubLayer(layer, 'title', layertitle)) === null || _LayerUtils$searchSub4 === void 0 ? void 0 : _LayerUtils$searchSub4.name) !== null && _LayerUtils$searchSub3 !== void 0 ? _LayerUtils$searchSub3 : layertitle;
|
|
337
|
+
}
|
|
338
|
+
var layerinfo = layerEl.attributes.layerinfo ? layerEl.attributes.layerinfo.value : null;
|
|
339
|
+
var features = [].slice.call(layerEl.getElementsByTagName("Feature"));
|
|
340
|
+
if (features.length > 0) {
|
|
341
|
+
result[layername] = features.map(function (feature) {
|
|
342
|
+
return _this.parseXmlFeature(feature, geometrycrs, feature.attributes.id.value, featurereport, displayfield, layername, layertitle, layerinfo, layer.translations);
|
|
343
|
+
});
|
|
344
|
+
} else {
|
|
345
|
+
var attributes = [].slice.call(layerEl.getElementsByTagName("Attribute"));
|
|
346
|
+
if (attributes.length > 0) {
|
|
347
|
+
var id = posstr || "" + idcounter++;
|
|
348
|
+
result[layername] = [_this.parseXmlFeature(layerEl, geometrycrs, id, featurereport, displayfield, layername, layertitle, layerinfo)];
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
353
|
+
_loop();
|
|
354
|
+
}
|
|
355
|
+
} catch (err) {
|
|
356
|
+
_iterator2.e(err);
|
|
357
|
+
} finally {
|
|
358
|
+
_iterator2.f();
|
|
359
|
+
}
|
|
360
|
+
return result;
|
|
361
|
+
},
|
|
362
|
+
parseGeoJSONResponse: function parseGeoJSONResponse(response, geometrycrs, layer) {
|
|
363
|
+
var result = {};
|
|
364
|
+
(response.features || []).map(function (feature) {
|
|
365
|
+
// Deduce layer name as far as possible from feature id
|
|
366
|
+
var id = feature.id || (feature.properties || {}).OBJECTID || uuidv4();
|
|
367
|
+
if (result[layer.name] === undefined) {
|
|
368
|
+
result[layer.name] = [];
|
|
369
|
+
}
|
|
370
|
+
var geometry = feature.geometry;
|
|
371
|
+
if (geometry && response.crs) {
|
|
372
|
+
var _response$crs$propert, _response$crs$propert2;
|
|
373
|
+
// Reproject geometry only if there is crs information in GetFeatureInfo response
|
|
374
|
+
geometry = VectorLayerUtils.reprojectGeometry(geometry, (_response$crs$propert = (_response$crs$propert2 = response.crs.properties) === null || _response$crs$propert2 === void 0 ? void 0 : _response$crs$propert2.name) !== null && _response$crs$propert !== void 0 ? _response$crs$propert : "EPSG:4326", geometrycrs);
|
|
375
|
+
}
|
|
376
|
+
result[layer.name].push(_objectSpread(_objectSpread({}, feature), {}, {
|
|
377
|
+
id: id,
|
|
378
|
+
geometry: geometry,
|
|
379
|
+
layername: layer.name,
|
|
380
|
+
layertitle: layer.title
|
|
381
|
+
}));
|
|
382
|
+
});
|
|
383
|
+
return result;
|
|
384
|
+
},
|
|
385
|
+
parseGmlResponse: function parseGmlResponse(response, geometrycrs, layer, posstr) {
|
|
386
|
+
var parser = new DOMParser();
|
|
387
|
+
var doc = parser.parseFromString(response, "text/xml");
|
|
388
|
+
var result = {};
|
|
389
|
+
var msGMLOutput = doc.getElementsByTagName("msGMLOutput")[0];
|
|
390
|
+
if (msGMLOutput) {
|
|
391
|
+
var count = 0;
|
|
392
|
+
var _iterator3 = _createForOfIteratorHelper([].slice.call(msGMLOutput.children)),
|
|
393
|
+
_step3;
|
|
394
|
+
try {
|
|
395
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
396
|
+
var layerEl = _step3.value;
|
|
397
|
+
var layerName = layerEl.nodeName.replace(/_layer$/, "");
|
|
398
|
+
var featureName = layerName + "_feature";
|
|
399
|
+
result[layerName] = [];
|
|
400
|
+
var _iterator4 = _createForOfIteratorHelper([].slice.call(layerEl.getElementsByTagName(featureName))),
|
|
401
|
+
_step4;
|
|
402
|
+
try {
|
|
403
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
404
|
+
var featureEl = _step4.value;
|
|
405
|
+
var context = [{
|
|
406
|
+
featureType: featureName
|
|
407
|
+
}];
|
|
408
|
+
var feature = new ol.format.GeoJSON().writeFeatureObject(new ol.format.GML2().readFeatureElement(featureEl, context));
|
|
409
|
+
feature.id = count++;
|
|
410
|
+
feature.layername = layer.name;
|
|
411
|
+
feature.layertitle = layer.title;
|
|
412
|
+
delete feature.properties.boundedBy;
|
|
413
|
+
result[layerName].push(feature);
|
|
414
|
+
}
|
|
415
|
+
} catch (err) {
|
|
416
|
+
_iterator4.e(err);
|
|
417
|
+
} finally {
|
|
418
|
+
_iterator4.f();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
} catch (err) {
|
|
422
|
+
_iterator3.e(err);
|
|
423
|
+
} finally {
|
|
424
|
+
_iterator3.f();
|
|
425
|
+
}
|
|
426
|
+
} else {
|
|
427
|
+
result[layer.name] = [{
|
|
428
|
+
type: "text",
|
|
429
|
+
text: response,
|
|
430
|
+
id: posstr
|
|
431
|
+
}];
|
|
432
|
+
}
|
|
433
|
+
return result;
|
|
434
|
+
},
|
|
435
|
+
parseGml3Response: function parseGml3Response(response, geometrycrs, layer) {
|
|
436
|
+
var _fmtGeoJson$writeFeat, _fmtGeoJson$writeFeat2;
|
|
437
|
+
var fmtGml3 = new ol.format.GML3();
|
|
438
|
+
var fmtGeoJson = new ol.format.GeoJSON();
|
|
439
|
+
return _defineProperty({}, layer.name, (_fmtGeoJson$writeFeat = (_fmtGeoJson$writeFeat2 = fmtGeoJson.writeFeaturesObject(fmtGml3.readFeatures(response))) === null || _fmtGeoJson$writeFeat2 === void 0 ? void 0 : _fmtGeoJson$writeFeat2.features) !== null && _fmtGeoJson$writeFeat !== void 0 ? _fmtGeoJson$writeFeat : []);
|
|
440
|
+
},
|
|
441
|
+
parseGml32Response: function parseGml32Response(response, geometrycrs, layer) {
|
|
442
|
+
var _fmtGeoJson$writeFeat3, _fmtGeoJson$writeFeat4;
|
|
443
|
+
var fmtGml32 = new ol.format.GML32();
|
|
444
|
+
var fmtGeoJson = new ol.format.GeoJSON();
|
|
445
|
+
return _defineProperty({}, layer.name, (_fmtGeoJson$writeFeat3 = (_fmtGeoJson$writeFeat4 = fmtGeoJson.writeFeaturesObject(fmtGml32.readFeatures(response))) === null || _fmtGeoJson$writeFeat4 === void 0 ? void 0 : _fmtGeoJson$writeFeat4.features) !== null && _fmtGeoJson$writeFeat3 !== void 0 ? _fmtGeoJson$writeFeat3 : []);
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
export default IdentifyUtils;
|
package/utils/ImageEditor.js
CHANGED
|
@@ -4,12 +4,82 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import Painterro from 'painterro';
|
|
10
|
+
import LocaleUtils from '../utils/LocaleUtils';
|
|
11
|
+
import '../components/widgets/style/ModalDialog.css';
|
|
12
|
+
export function showImageEditor(imageData, imageDataCallback) {
|
|
13
|
+
// Do old-school JS rather than react portal as portal event bubbling messes up Painterro
|
|
14
|
+
var modalDialogContainer = document.createElement("div");
|
|
15
|
+
modalDialogContainer.className = "modal-dialog-container";
|
|
16
|
+
var modalDialog = document.createElement("div");
|
|
17
|
+
modalDialog.className = "modal-dialog";
|
|
18
|
+
modalDialog.style.width = '80%';
|
|
19
|
+
var modalDialogTitle = document.createElement("div");
|
|
20
|
+
modalDialogTitle.className = "modal-dialog-title";
|
|
21
|
+
var titleIcon = document.createElement("span");
|
|
22
|
+
titleIcon.className = "icon icon-paint";
|
|
23
|
+
modalDialogTitle.appendChild(titleIcon);
|
|
24
|
+
var titleLabel = document.createElement("span");
|
|
25
|
+
titleLabel.innerText = LocaleUtils.tr("imageeditor.title");
|
|
26
|
+
modalDialogTitle.appendChild(titleLabel);
|
|
27
|
+
var closeIcon = document.createElement("span");
|
|
28
|
+
closeIcon.className = "icon icon_clickable icon-remove";
|
|
29
|
+
modalDialogTitle.appendChild(closeIcon);
|
|
30
|
+
modalDialog.appendChild(modalDialogTitle);
|
|
31
|
+
var modalDialogBody = document.createElement("div");
|
|
32
|
+
modalDialogBody.className = "modal-dialog-body";
|
|
33
|
+
modalDialogBody.id = 'painterro';
|
|
34
|
+
modalDialogBody.addEventListener('keypress', function (ev) {
|
|
35
|
+
// Prevent i.e. +/- from triggering map zoom
|
|
36
|
+
ev.stopPropagation();
|
|
37
|
+
});
|
|
38
|
+
modalDialog.appendChild(modalDialogBody);
|
|
39
|
+
modalDialogContainer.appendChild(modalDialog);
|
|
40
|
+
document.body.appendChild(modalDialogContainer);
|
|
41
|
+
|
|
42
|
+
// eslint-disable-next-line
|
|
43
|
+
window.ptro = Painterro({
|
|
44
|
+
id: 'painterro',
|
|
45
|
+
hiddenTools: ['open'],
|
|
46
|
+
language: LocaleUtils.lang().slice(0, 2).toLowerCase(),
|
|
47
|
+
onBeforeClose: function onBeforeClose(hasUnsaved, doClose) {
|
|
48
|
+
if (hasUnsaved) {
|
|
49
|
+
// eslint-disable-next-line
|
|
50
|
+
if (confirm(LocaleUtils.tr("imageeditor.confirmclose"))) {
|
|
51
|
+
doClose();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
onClose: function onClose() {
|
|
56
|
+
window.ptro.hide();
|
|
57
|
+
delete window.ptro;
|
|
58
|
+
// Delay to next iteration to ensure ptro event handlers have executed
|
|
59
|
+
setTimeout(function () {
|
|
60
|
+
document.body.removeChild(modalDialogContainer);
|
|
61
|
+
}, 0);
|
|
62
|
+
},
|
|
63
|
+
saveHandler: function saveHandler(image, done) {
|
|
64
|
+
imageDataCallback(image.asDataURL('image/jpeg'));
|
|
65
|
+
done(true);
|
|
66
|
+
window.ptro.hide();
|
|
67
|
+
delete window.ptro;
|
|
68
|
+
// Delay to next iteration to ensure ptro event handlers have executed
|
|
69
|
+
setTimeout(function () {
|
|
70
|
+
document.body.removeChild(modalDialogContainer);
|
|
71
|
+
}, 0);
|
|
72
|
+
}
|
|
73
|
+
}).show(imageData);
|
|
74
|
+
closeIcon.addEventListener('click', function () {
|
|
75
|
+
// eslint-disable-next-line
|
|
76
|
+
if (confirm(LocaleUtils.tr("imageeditor.confirmclose"))) {
|
|
77
|
+
window.ptro.hide();
|
|
78
|
+
delete window.ptro;
|
|
79
|
+
// Delay to next iteration to ensure ptro event handlers have executed
|
|
80
|
+
setTimeout(function () {
|
|
81
|
+
document.body.removeChild(modalDialogContainer);
|
|
82
|
+
}, 0);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|