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
|
@@ -1,20 +1,594 @@
|
|
|
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 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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
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); }
|
|
7
|
+
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; } } }; }
|
|
8
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
9
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
12
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
13
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
|
+
/**
|
|
2
15
|
* Copyright 2017-2024 Sourcepole AG
|
|
3
16
|
* All rights reserved.
|
|
4
17
|
*
|
|
5
18
|
* This source code is licensed under the BSD-style license found in the
|
|
6
19
|
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import geojsonBbox from 'geojson-bounding-box';
|
|
23
|
+
import isEmpty from 'lodash.isempty';
|
|
24
|
+
import { getDefaultImageStyle } from 'ol/format/KML';
|
|
25
|
+
import ol from 'openlayers';
|
|
26
|
+
import simplepolygon from 'simplepolygon';
|
|
27
|
+
import svgpath from 'svgpath';
|
|
28
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
29
|
+
import ConfigUtils from '../utils/ConfigUtils';
|
|
30
|
+
import CoordinatesUtils from '../utils/CoordinatesUtils';
|
|
31
|
+
import { END_MARKERS, computeFeatureStyle } from '../utils/FeatureStyles';
|
|
32
|
+
var VectorLayerUtils = {
|
|
33
|
+
createPrintHighlighParams: function createPrintHighlighParams(layers, printCrs, printScale) {
|
|
34
|
+
var dpi = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 96;
|
|
35
|
+
var scaleFactor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1.0;
|
|
36
|
+
var qgisServerVersion = ConfigUtils.getConfigProp("qgisServerVersion", null, 3);
|
|
37
|
+
var params = {
|
|
38
|
+
geoms: [],
|
|
39
|
+
styles: [],
|
|
40
|
+
labels: [],
|
|
41
|
+
labelFillColors: [],
|
|
42
|
+
labelOutlineColors: [],
|
|
43
|
+
labelOutlineSizes: [],
|
|
44
|
+
labelRotations: [],
|
|
45
|
+
labelSizes: [],
|
|
46
|
+
labelDist: []
|
|
47
|
+
};
|
|
48
|
+
var ensureHex = null;
|
|
49
|
+
if (qgisServerVersion >= 3) {
|
|
50
|
+
ensureHex = function ensureHex(rgb) {
|
|
51
|
+
return !Array.isArray(rgb) ? rgb : '#' + [255 - (rgb.length > 3 ? rgb[3] : 1) * 255].concat(_toConsumableArray(rgb.slice(0, 3))).map(function (v) {
|
|
52
|
+
return Math.round(v).toString(16).padStart(2, '0');
|
|
53
|
+
}).join('');
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
ensureHex = function ensureHex(rgb) {
|
|
57
|
+
return !Array.isArray(rgb) ? rgb : '#' + (0x1000000 + (rgb[2] | rgb[1] << 8 | rgb[0] << 16)).toString(16).slice(1);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
var _iterator = _createForOfIteratorHelper(layers.slice(0).reverse()),
|
|
61
|
+
_step;
|
|
62
|
+
try {
|
|
63
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
64
|
+
var layer = _step.value;
|
|
65
|
+
if (layer.type !== 'vector' || (layer.features || []).length === 0 || layer.visibility === false || layer.skipPrint === true) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
var features = layer.features.map(function (feature) {
|
|
69
|
+
var _feature$geometry;
|
|
70
|
+
if ((_feature$geometry = feature.geometry) !== null && _feature$geometry !== void 0 && _feature$geometry.coordinates) {
|
|
71
|
+
feature = _objectSpread(_objectSpread({}, feature), {}, {
|
|
72
|
+
geometry: _objectSpread(_objectSpread({}, feature.geometry), {}, {
|
|
73
|
+
coordinates: VectorLayerUtils.removeDuplicateNodes(feature.geometry.coordinates)
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return VectorLayerUtils.simplifyFeature(feature);
|
|
78
|
+
}).flat();
|
|
79
|
+
var _iterator2 = _createForOfIteratorHelper(features),
|
|
80
|
+
_step2;
|
|
81
|
+
try {
|
|
82
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
83
|
+
var feature = _step2.value;
|
|
84
|
+
if (!VectorLayerUtils.validateGeometry(feature.geometry)) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
var styleOptions = computeFeatureStyle(layer, feature);
|
|
88
|
+
var properties = feature.properties || {};
|
|
89
|
+
var geometry = VectorLayerUtils.reprojectGeometry(feature.geometry, feature.crs || printCrs, printCrs);
|
|
90
|
+
if (feature.geometry.type === "LineString") {
|
|
91
|
+
// Generate arrow heads
|
|
92
|
+
if (styleOptions.headmarker) {
|
|
93
|
+
VectorLayerUtils.generateMarkerGeometry(params, styleOptions.headmarker, false, feature, layer, dpi, printScale, printCrs, scaleFactor);
|
|
94
|
+
}
|
|
95
|
+
if (styleOptions.tailmarker) {
|
|
96
|
+
VectorLayerUtils.generateMarkerGeometry(params, styleOptions.tailmarker, true, feature, layer, dpi, printScale, printCrs, scaleFactor);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (feature.geometry.type === "LineString" && !isEmpty(properties.segment_labels)) {
|
|
100
|
+
// Split line into single segments and label them individually
|
|
101
|
+
var coords = geometry.coordinates;
|
|
102
|
+
for (var i = 0; i < coords.length - 1; ++i) {
|
|
103
|
+
var segment = {
|
|
104
|
+
type: "LineString",
|
|
105
|
+
coordinates: [coords[i], coords[i + 1]]
|
|
106
|
+
};
|
|
107
|
+
params.styles.push(VectorLayerUtils.createSld(segment.type, feature.styleName, styleOptions, layer.opacity, dpi, scaleFactor));
|
|
108
|
+
params.labels.push(properties.segment_labels[i] || " ");
|
|
109
|
+
params.geoms.push(VectorLayerUtils.geoJSONGeomToWkt(segment));
|
|
110
|
+
params.labelFillColors.push(ensureHex(styleOptions.textFill));
|
|
111
|
+
params.labelOutlineColors.push(ensureHex(styleOptions.textStroke));
|
|
112
|
+
params.labelOutlineSizes.push(scaleFactor);
|
|
113
|
+
params.labelSizes.push(Math.round(10 * scaleFactor));
|
|
114
|
+
params.labelDist.push("-5");
|
|
115
|
+
params.labelRotations.push("0");
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
params.styles.push(VectorLayerUtils.createSld(geometry.type, feature.styleName, styleOptions, layer.opacity, dpi, scaleFactor));
|
|
119
|
+
params.labels.push(properties.label || " ");
|
|
120
|
+
if (feature.styleName === "text") {
|
|
121
|
+
// Make point a tiny square, so that QGIS server centers the text inside the polygon when labelling
|
|
122
|
+
var x = geometry.coordinates[0];
|
|
123
|
+
var y = geometry.coordinates[1];
|
|
124
|
+
geometry = {
|
|
125
|
+
type: "Polygon",
|
|
126
|
+
coordinates: [[[x - 0.01, y - 0.01], [x + 0.01, y - 0.01], [x + 0.01, y + 0.01], [x - 0.01, y + 0.01], [x - 0.01, y - 0.01]]]
|
|
127
|
+
};
|
|
128
|
+
params.geoms.push(VectorLayerUtils.geoJSONGeomToWkt(geometry));
|
|
129
|
+
params.labelFillColors.push(ensureHex(styleOptions.fillColor));
|
|
130
|
+
params.labelOutlineColors.push(ensureHex(styleOptions.strokeColor));
|
|
131
|
+
params.labelOutlineSizes.push(scaleFactor * styleOptions.strokeWidth * 0.5);
|
|
132
|
+
params.labelSizes.push(Math.round(10 * styleOptions.strokeWidth * scaleFactor));
|
|
133
|
+
params.labelDist.push("5");
|
|
134
|
+
params.labelRotations.push(((properties.rotation || 0) / Math.PI * 180).toFixed(0));
|
|
135
|
+
} else {
|
|
136
|
+
params.geoms.push(VectorLayerUtils.geoJSONGeomToWkt(geometry));
|
|
137
|
+
params.labelFillColors.push(ensureHex(styleOptions.textFill));
|
|
138
|
+
params.labelOutlineColors.push(ensureHex(styleOptions.textStroke));
|
|
139
|
+
params.labelOutlineSizes.push(scaleFactor);
|
|
140
|
+
params.labelSizes.push(Math.round(10 * scaleFactor));
|
|
141
|
+
params.labelDist.push("-5");
|
|
142
|
+
params.labelRotations.push("0");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
} catch (err) {
|
|
147
|
+
_iterator2.e(err);
|
|
148
|
+
} finally {
|
|
149
|
+
_iterator2.f();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
} catch (err) {
|
|
153
|
+
_iterator.e(err);
|
|
154
|
+
} finally {
|
|
155
|
+
_iterator.f();
|
|
156
|
+
}
|
|
157
|
+
return params;
|
|
158
|
+
},
|
|
159
|
+
removeDuplicateNodes: function removeDuplicateNodes(coordinates) {
|
|
160
|
+
if (Array.isArray(coordinates[0][0])) {
|
|
161
|
+
return coordinates.map(VectorLayerUtils.removeDuplicateNodes);
|
|
162
|
+
} else if (Array.isArray(coordinates[0])) {
|
|
163
|
+
return coordinates.filter(function (item, pos, arr) {
|
|
164
|
+
return pos === 0 || item[0] !== arr[pos - 1][0] || item[1] !== arr[pos - 1][1];
|
|
165
|
+
});
|
|
166
|
+
} else {
|
|
167
|
+
return coordinates;
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
simplifyFeature: function simplifyFeature(feature) {
|
|
171
|
+
if (!feature.geometry) {
|
|
172
|
+
return feature;
|
|
173
|
+
} else if (feature.geometry.type === "MultiPolygon") {
|
|
174
|
+
return feature.geometry.coordinates.map(function (part) {
|
|
175
|
+
return VectorLayerUtils.simplifyFeature(_objectSpread(_objectSpread({}, feature), {}, {
|
|
176
|
+
geometry: {
|
|
177
|
+
type: "Polygon",
|
|
178
|
+
coordinates: part
|
|
179
|
+
}
|
|
180
|
+
}));
|
|
181
|
+
}).flat();
|
|
182
|
+
} else if (feature.geometry.type === "Polygon") {
|
|
183
|
+
return simplepolygon(feature).features.map(function (feat, idx, features) {
|
|
184
|
+
if (feat.properties.parent >= 0) {
|
|
185
|
+
features[feat.properties.parent].geometry.coordinates.push(feat.geometry.coordinates[0]);
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
return feat;
|
|
189
|
+
}).filter(function (x) {
|
|
190
|
+
return x;
|
|
191
|
+
}).map(function (feat) {
|
|
192
|
+
return _objectSpread(_objectSpread({}, feature), {}, {
|
|
193
|
+
geometry: feat.geometry
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
} else {
|
|
197
|
+
return feature;
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
validateGeometry: function validateGeometry(geometry) {
|
|
201
|
+
if (!geometry) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
if (geometry.type === "GeometryCollection") {
|
|
205
|
+
return geometry.geometries.every(VectorLayerUtils.validateGeometry);
|
|
206
|
+
}
|
|
207
|
+
if (geometry.type === "Point") {
|
|
208
|
+
return !isEmpty(geometry.coordinates);
|
|
209
|
+
}
|
|
210
|
+
var minLength = geometry.type.endsWith("LineString") ? 2 : 3;
|
|
211
|
+
var _isDegenerate = function isDegenerate(coordinates) {
|
|
212
|
+
if (Array.isArray(coordinates[0][0])) {
|
|
213
|
+
return coordinates.map(_isDegenerate).find(function (entry) {
|
|
214
|
+
return entry === false;
|
|
215
|
+
});
|
|
216
|
+
} else {
|
|
217
|
+
return coordinates.length < minLength;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
return !_isDegenerate(geometry.coordinates);
|
|
221
|
+
},
|
|
222
|
+
createSld: function createSld(geometrytype, styleName, styleOptions, layerOpacity) {
|
|
223
|
+
var dpi = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 96;
|
|
224
|
+
var scaleFactor = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1.0;
|
|
225
|
+
var opts = {};
|
|
226
|
+
var dpiScale = dpi / 96 * scaleFactor;
|
|
227
|
+
// Special cases
|
|
228
|
+
if (styleName === 'text') {
|
|
229
|
+
// Make geometry transparent
|
|
230
|
+
opts = {
|
|
231
|
+
strokeColor: [0, 0, 0, 0],
|
|
232
|
+
fillColor: [0, 0, 0, 0]
|
|
233
|
+
};
|
|
234
|
+
} else if (styleName === 'marker') {
|
|
235
|
+
opts = {
|
|
236
|
+
strokeColor: [0, 0, 255, 1],
|
|
237
|
+
strokeWidth: 1 * dpiScale,
|
|
238
|
+
fillColor: [255, 255, 255, 1],
|
|
239
|
+
circleRadius: 2 * dpiScale
|
|
240
|
+
};
|
|
241
|
+
} else {
|
|
242
|
+
// Default style
|
|
243
|
+
opts = styleOptions;
|
|
244
|
+
}
|
|
245
|
+
var ensureHex = function ensureHex(rgb) {
|
|
246
|
+
return !Array.isArray(rgb) ? rgb : '#' + (0x1000000 + (rgb[2] | rgb[1] << 8 | rgb[0] << 16)).toString(16).slice(1);
|
|
247
|
+
};
|
|
248
|
+
var opacity = function opacity(rgb) {
|
|
249
|
+
if (Array.isArray(rgb) && rgb.length > 3) {
|
|
250
|
+
return rgb[3] * layerOpacity / 255;
|
|
251
|
+
}
|
|
252
|
+
return 1 * layerOpacity / 255;
|
|
253
|
+
};
|
|
254
|
+
var stroke = '<se:Stroke>' + '<se:SvgParameter name="stroke">' + ensureHex(opts.strokeColor) + '</se:SvgParameter>' + '<se:SvgParameter name="stroke-opacity">' + opacity(opts.strokeColor) + '</se:SvgParameter>' + '<se:SvgParameter name="stroke-width">' + opts.strokeWidth * dpiScale + '</se:SvgParameter>' + '<se:SvgParameter name="stroke-linejoin">round</se:SvgParameter>' + (!isEmpty(opts.strokeDash) ? '<se:SvgParameter name="stroke-dasharray">' + opts.strokeDash.map(function (x) {
|
|
255
|
+
return x * dpiScale;
|
|
256
|
+
}).join(' ') + '</se:SvgParameter>' : '') + '</se:Stroke>';
|
|
257
|
+
var fill = '<se:Fill>' + '<se:SvgParameter name="fill">' + ensureHex(opts.fillColor) + '</se:SvgParameter>' + '<se:SvgParameter name="fill-opacity">' + opacity(opts.fillColor) + '</se:SvgParameter>' + '</se:Fill>';
|
|
258
|
+
var rule = null;
|
|
259
|
+
if (geometrytype.endsWith("Point")) {
|
|
260
|
+
rule = '<se:PointSymbolizer>' + '<se:Graphic>' + '<se:Mark>' + '<se:WellKnownName>circle</se:WellKnownName>' + '<se:Stroke>' + '<se:SvgParameter name="stroke">' + ensureHex(opts.strokeColor) + '</se:SvgParameter>' + '<se:SvgParameter name="stroke-opacity">' + opacity(opts.strokeColor) + '</se:SvgParameter>' + '<se:SvgParameter name="stroke-width">' + opts.strokeWidth * dpiScale + '</se:SvgParameter>' + '</se:Stroke>' + fill + '</se:Mark>' + '<se:Size>' + 2 * opts.circleRadius * dpiScale + '</se:Size>' + '</se:Graphic>' + '</se:PointSymbolizer>';
|
|
261
|
+
} else if (geometrytype.endsWith("LineString")) {
|
|
262
|
+
rule = '<se:LineSymbolizer>' + stroke + '</se:LineSymbolizer>';
|
|
263
|
+
} else if (geometrytype.endsWith("Polygon")) {
|
|
264
|
+
rule = '<se:PolygonSymbolizer>' + stroke + fill + '</se:PolygonSymbolizer>';
|
|
265
|
+
}
|
|
266
|
+
if (rule) {
|
|
267
|
+
return '<?xml version="1.0" encoding="UTF-8"?>' + '<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:se="http://www.opengis.net/se">' + '<UserStyle>' + '<se:FeatureTypeStyle>' + '<se:Rule>' + rule + '</se:Rule>' + '</se:FeatureTypeStyle>' + '</UserStyle>' + '</StyledLayerDescriptor>';
|
|
268
|
+
}
|
|
269
|
+
return null;
|
|
270
|
+
},
|
|
271
|
+
generateMarkerGeometry: function generateMarkerGeometry(params, markername, tail, feature, layer, dpi, mapScale, printCrs, scaleFactor) {
|
|
272
|
+
if (!END_MARKERS[markername]) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
var marker = END_MARKERS[markername];
|
|
276
|
+
// Read the SVG and generate a matching WKT geometry for the marker
|
|
277
|
+
var path = '';
|
|
278
|
+
var width = 0;
|
|
279
|
+
var height = 0;
|
|
280
|
+
try {
|
|
281
|
+
var parser = new DOMParser();
|
|
282
|
+
var svgSrc = atob(marker.src.slice(26));
|
|
283
|
+
var svgDoc = parser.parseFromString(svgSrc, "text/xml");
|
|
284
|
+
width = parseInt(svgDoc.getElementsByTagName("svg")[0].getAttribute("width"), 10);
|
|
285
|
+
height = parseInt(svgDoc.getElementsByTagName("svg")[0].getAttribute("height"), 10);
|
|
286
|
+
path = svgDoc.getElementsByTagName("path")[0].getAttribute("d");
|
|
287
|
+
} catch (e) {
|
|
288
|
+
/* eslint-disable-next-line */
|
|
289
|
+
console.warn("Could not parse path for marker " + markername);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
// [ Same as in FeatureStyles.js ] [ pixel to map units ]
|
|
293
|
+
var markerScaleFactor = 0.125 * (1 + feature.styleOptions.strokeWidth) / dpi * 0.0254 * mapScale * scaleFactor;
|
|
294
|
+
var origin = feature.geometry.coordinates[tail ? feature.geometry.coordinates.length - 1 : 0];
|
|
295
|
+
var p2 = feature.geometry.coordinates[tail ? feature.geometry.coordinates.length - 2 : 1];
|
|
296
|
+
var coordinates = [];
|
|
297
|
+
var angle = 0.5 * Math.PI + Math.atan2(origin[0] - p2[0], origin[1] - p2[1]);
|
|
298
|
+
var alpha = marker.baserotation / 180 * Math.PI + angle;
|
|
299
|
+
var cosa = Math.cos(alpha);
|
|
300
|
+
var sina = Math.sin(alpha);
|
|
301
|
+
svgpath(path).iterate(function (segment, index, x, y) {
|
|
302
|
+
// Skip move instructions
|
|
303
|
+
if (["m", "M"].includes(segment[0])) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
var dx = (x - marker.anchor[0] * width) * markerScaleFactor;
|
|
307
|
+
var dy = (y - marker.anchor[1] * height) * markerScaleFactor;
|
|
308
|
+
var rx = cosa * dx + sina * dy;
|
|
309
|
+
var ry = -sina * dx + cosa * dy;
|
|
310
|
+
coordinates.push([origin[0] + rx, origin[1] + ry]);
|
|
311
|
+
});
|
|
312
|
+
// Closing coordinate
|
|
313
|
+
coordinates.push(coordinates[0]);
|
|
314
|
+
var geometry = {
|
|
315
|
+
type: "Polygon",
|
|
316
|
+
coordinates: [coordinates]
|
|
317
|
+
};
|
|
318
|
+
var styleOptions = {
|
|
319
|
+
strokeWidth: 1,
|
|
320
|
+
strokeDash: [],
|
|
321
|
+
strokeColor: feature.styleOptions.strokeColor,
|
|
322
|
+
fillColor: feature.styleOptions.strokeColor
|
|
323
|
+
};
|
|
324
|
+
params.styles.push(VectorLayerUtils.createSld(geometry.type, "default", styleOptions, layer.opacity, dpi, scaleFactor));
|
|
325
|
+
params.geoms.push(VectorLayerUtils.geoJSONGeomToWkt(geometry));
|
|
326
|
+
params.labels.push(" ");
|
|
327
|
+
params.labelFillColors.push("#FFF");
|
|
328
|
+
params.labelOutlineColors.push("#FFF");
|
|
329
|
+
params.labelOutlineSizes.push(scaleFactor);
|
|
330
|
+
params.labelSizes.push(Math.round(10 * scaleFactor));
|
|
331
|
+
params.labelDist.push("0");
|
|
332
|
+
},
|
|
333
|
+
reprojectGeometry: function reprojectGeometry(geometry, srccrs, dstcrs) {
|
|
334
|
+
if (srccrs === dstcrs || !srccrs || !dstcrs) {
|
|
335
|
+
return geometry;
|
|
336
|
+
}
|
|
337
|
+
if (geometry.type === "Point") {
|
|
338
|
+
var wgscoo = CoordinatesUtils.reproject(geometry.coordinates, srccrs, dstcrs);
|
|
339
|
+
return {
|
|
340
|
+
type: geometry.type,
|
|
341
|
+
coordinates: wgscoo
|
|
342
|
+
};
|
|
343
|
+
} else if (geometry.type === "LineString" || geometry.type === "MultiPoint") {
|
|
344
|
+
return {
|
|
345
|
+
type: geometry.type,
|
|
346
|
+
coordinates: geometry.coordinates.map(function (tuple) {
|
|
347
|
+
return CoordinatesUtils.reproject(tuple, srccrs, dstcrs);
|
|
348
|
+
})
|
|
349
|
+
};
|
|
350
|
+
} else if (geometry.type === "Polygon" || geometry.type === "MultiLineString") {
|
|
351
|
+
return {
|
|
352
|
+
type: geometry.type,
|
|
353
|
+
coordinates: geometry.coordinates.map(function (ring) {
|
|
354
|
+
return ring.map(function (tuple) {
|
|
355
|
+
return CoordinatesUtils.reproject(tuple, srccrs, dstcrs);
|
|
356
|
+
});
|
|
357
|
+
})
|
|
358
|
+
};
|
|
359
|
+
} else if (geometry.type === "MultiPolygon") {
|
|
360
|
+
return {
|
|
361
|
+
type: geometry.type,
|
|
362
|
+
coordinates: geometry.coordinates.map(function (part) {
|
|
363
|
+
return part.map(function (ring) {
|
|
364
|
+
return ring.map(function (tuple) {
|
|
365
|
+
return CoordinatesUtils.reproject(tuple, srccrs, dstcrs);
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
})
|
|
369
|
+
};
|
|
370
|
+
} else {
|
|
371
|
+
return geometry;
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
reprojectFeature: function reprojectFeature(feature, srccrs, dstcrs) {
|
|
375
|
+
if (srccrs === dstcrs || !srccrs || !dstcrs) {
|
|
376
|
+
return feature;
|
|
377
|
+
}
|
|
378
|
+
if (feature.features) {
|
|
379
|
+
return _objectSpread(_objectSpread({}, feature), {}, {
|
|
380
|
+
features: feature.features.map(function (f) {
|
|
381
|
+
return VectorLayerUtils.reprojectFeature(srccrs, dstcrs);
|
|
382
|
+
})
|
|
383
|
+
});
|
|
384
|
+
} else {
|
|
385
|
+
return _objectSpread(_objectSpread({}, feature), {}, {
|
|
386
|
+
geometry: VectorLayerUtils.reprojectGeometry(feature.geometry, srccrs, dstcrs)
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
wktToGeoJSON: function wktToGeoJSON(wkt, srccrs, dstcrs) {
|
|
391
|
+
var id = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : uuidv4();
|
|
392
|
+
wkt = wkt.replace(/Point(\w+)/i, "Point $1").replace(/LineString(\w+)/i, "LineString $1").replace(/Polygon(\w+)/i, "Polygon $1").replace(/MultiSurface(\w*)/i, "GeometryCollection $1");
|
|
393
|
+
try {
|
|
394
|
+
var feature = new ol.format.WKT().readFeature(wkt, {
|
|
395
|
+
dataProjection: srccrs,
|
|
396
|
+
featureProjection: dstcrs
|
|
397
|
+
});
|
|
398
|
+
var featureObj = new ol.format.GeoJSON().writeFeatureObject(feature);
|
|
399
|
+
featureObj.id = id;
|
|
400
|
+
return featureObj;
|
|
401
|
+
} catch (e) {
|
|
402
|
+
/* eslint-disable-next-line */
|
|
403
|
+
console.warn("Failed to parse geometry: " + wkt);
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
geoJSONGeomToWkt: function geoJSONGeomToWkt(gj) {
|
|
408
|
+
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
409
|
+
if (precision === undefined) {
|
|
410
|
+
precision = ConfigUtils.getConfigProp("wmsWktPrecision", null, 4);
|
|
411
|
+
}
|
|
412
|
+
if (gj.type === 'Feature') {
|
|
413
|
+
gj = gj.geometry;
|
|
414
|
+
}
|
|
415
|
+
var wrapParens = function wrapParens(s) {
|
|
416
|
+
return '(' + s + ')';
|
|
417
|
+
};
|
|
418
|
+
var pairWKT = function pairWKT(c) {
|
|
419
|
+
return c.map(function (x) {
|
|
420
|
+
return x.toFixed(precision);
|
|
421
|
+
}).join(' ');
|
|
422
|
+
};
|
|
423
|
+
var ringWKT = function ringWKT(r) {
|
|
424
|
+
return r.map(pairWKT).join(', ');
|
|
425
|
+
};
|
|
426
|
+
var ringsWKT = function ringsWKT(r) {
|
|
427
|
+
return r.map(ringWKT).map(wrapParens).join(', ');
|
|
428
|
+
};
|
|
429
|
+
var multiRingsWKT = function multiRingsWKT(r) {
|
|
430
|
+
return r.map(ringsWKT).map(wrapParens).join(', ');
|
|
431
|
+
};
|
|
432
|
+
switch (gj.type) {
|
|
433
|
+
case 'Point':
|
|
434
|
+
return 'POINT (' + pairWKT(gj.coordinates) + ')';
|
|
435
|
+
case 'LineString':
|
|
436
|
+
return 'LINESTRING (' + ringWKT(gj.coordinates) + ')';
|
|
437
|
+
case 'Polygon':
|
|
438
|
+
return 'POLYGON (' + ringsWKT(gj.coordinates) + ')';
|
|
439
|
+
case 'MultiPoint':
|
|
440
|
+
return 'MULTIPOINT (' + ringWKT(gj.coordinates) + ')';
|
|
441
|
+
case 'MultiPolygon':
|
|
442
|
+
return 'MULTIPOLYGON (' + multiRingsWKT(gj.coordinates) + ')';
|
|
443
|
+
case 'MultiLineString':
|
|
444
|
+
return 'MULTILINESTRING (' + ringsWKT(gj.coordinates) + ')';
|
|
445
|
+
case 'GeometryCollection':
|
|
446
|
+
return 'GEOMETRYCOLLECTION (' + gj.geometries.map(function (x) {
|
|
447
|
+
return VectorLayerUtils.geoJSONGeomToWkt(x, precision);
|
|
448
|
+
}).join(', ') + ')';
|
|
449
|
+
default:
|
|
450
|
+
throw new Error('Invalid geometry object');
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
kmlToGeoJSON: function kmlToGeoJSON(kml) {
|
|
454
|
+
var kmlFormat = new ol.format.KML({
|
|
455
|
+
defaultStyle: [new ol.style.Style()]
|
|
456
|
+
});
|
|
457
|
+
var geojsonFormat = new ol.format.GeoJSON();
|
|
458
|
+
var features = [];
|
|
459
|
+
var _iterator3 = _createForOfIteratorHelper(kmlFormat.readFeatures(kml)),
|
|
460
|
+
_step3;
|
|
461
|
+
try {
|
|
462
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
463
|
+
var _feature$geometry2;
|
|
464
|
+
var olFeature = _step3.value;
|
|
465
|
+
var style = olFeature.getStyleFunction()(olFeature);
|
|
466
|
+
style = style[0] || style;
|
|
467
|
+
var styleOptions = {
|
|
468
|
+
strokeColor: style.getStroke() ? style.getStroke().getColor() : [0, 0, 0, 1],
|
|
469
|
+
strokeWidth: style.getStroke() ? style.getStroke().getWidth() : 1,
|
|
470
|
+
strokeDash: style.getStroke() ? style.getStroke().getLineDash() : [],
|
|
471
|
+
fillColor: style.getFill() ? style.getFill().getColor() : [255, 255, 255, 1],
|
|
472
|
+
textFill: style.getText() && style.getText().getFill() ? style.getText().getFill().getColor() : [0, 0, 0, 1],
|
|
473
|
+
textStroke: style.getText() && style.getText().getStroke() ? style.getText().getStroke().getColor() : [255, 255, 255, 1]
|
|
474
|
+
};
|
|
475
|
+
if (style.getImage() && style.getImage() !== getDefaultImageStyle() && style.getImage().getSrc()) {
|
|
476
|
+
// FIXME: Uses private members of ol.style.Icon, style.getImage().getAnchor() returns null because style.getImage.getSize() is null because the the image is not yet loaded
|
|
477
|
+
var anchor = style.getImage().anchor_ || [0.5, 0.5];
|
|
478
|
+
var anchorOrigin = (style.getImage().anchorOrigin_ || "").split("-");
|
|
479
|
+
if (anchorOrigin.includes("right")) {
|
|
480
|
+
anchor[0] = 1 - anchor[0];
|
|
481
|
+
}
|
|
482
|
+
if (anchorOrigin.includes("bottom")) {
|
|
483
|
+
anchor[1] = 1 - anchor[1];
|
|
484
|
+
}
|
|
485
|
+
styleOptions.iconSrc = style.getImage().getSrc();
|
|
486
|
+
styleOptions.iconAnchor = anchor;
|
|
487
|
+
}
|
|
488
|
+
var feature = geojsonFormat.writeFeatureObject(olFeature);
|
|
489
|
+
Object.assign(feature, {
|
|
490
|
+
styleName: styleOptions.iconSrc && ((_feature$geometry2 = feature.geometry) === null || _feature$geometry2 === void 0 ? void 0 : _feature$geometry2.type) === "Point" ? 'marker' : 'default',
|
|
491
|
+
styleOptions: styleOptions,
|
|
492
|
+
id: uuidv4(),
|
|
493
|
+
crs: "EPSG:4326",
|
|
494
|
+
properties: {}
|
|
495
|
+
});
|
|
496
|
+
var properties = olFeature.getProperties();
|
|
497
|
+
var excludedProperties = ['visibility', olFeature.getGeometryName()];
|
|
498
|
+
for (var _i = 0, _Object$keys = Object.keys(properties); _i < _Object$keys.length; _i++) {
|
|
499
|
+
var key = _Object$keys[_i];
|
|
500
|
+
if (!excludedProperties.includes(key)) {
|
|
501
|
+
feature.properties[key] = properties[key];
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (properties.name && feature.styleName === 'marker') {
|
|
505
|
+
feature.properties.label = properties.name;
|
|
506
|
+
}
|
|
507
|
+
features.push(feature);
|
|
508
|
+
}
|
|
509
|
+
} catch (err) {
|
|
510
|
+
_iterator3.e(err);
|
|
511
|
+
} finally {
|
|
512
|
+
_iterator3.f();
|
|
513
|
+
}
|
|
514
|
+
return features;
|
|
515
|
+
},
|
|
516
|
+
convert3dto2d: function convert3dto2d(entry) {
|
|
517
|
+
if (!Array.isArray(entry)) {
|
|
518
|
+
return entry;
|
|
519
|
+
} else if (entry.length >= 3 && !Array.isArray(entry[0])) {
|
|
520
|
+
return [entry[0], entry[1]];
|
|
521
|
+
} else if (Array.isArray(entry[0])) {
|
|
522
|
+
return entry.map(VectorLayerUtils.convert3dto2d);
|
|
523
|
+
}
|
|
524
|
+
return entry;
|
|
525
|
+
},
|
|
526
|
+
computeFeaturesBBox: function computeFeaturesBBox(features) {
|
|
527
|
+
var featureCrs = new Set();
|
|
528
|
+
features.forEach(function (feature) {
|
|
529
|
+
if (feature.crs) {
|
|
530
|
+
featureCrs.add(feature.crs);
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
var bboxCrs = featureCrs.size === 1 ? _toConsumableArray(featureCrs.keys())[0] : "EPSG:4326";
|
|
534
|
+
var bounds = geojsonBbox({
|
|
535
|
+
type: "FeatureCollection",
|
|
536
|
+
features: features.filter(function (feature) {
|
|
537
|
+
return feature.geometry;
|
|
538
|
+
}).map(function (feature) {
|
|
539
|
+
return _objectSpread(_objectSpread({}, feature), {}, {
|
|
540
|
+
geometry: feature.crs ? VectorLayerUtils.reprojectGeometry(feature.geometry, feature.crs, bboxCrs) : feature.geometry
|
|
541
|
+
});
|
|
542
|
+
})
|
|
543
|
+
});
|
|
544
|
+
// Discard z component
|
|
545
|
+
if (bounds.length === 6) {
|
|
546
|
+
bounds = [bounds[0], bounds[1], bounds[3], bounds[4]];
|
|
547
|
+
}
|
|
548
|
+
return {
|
|
549
|
+
crs: bboxCrs,
|
|
550
|
+
bounds: bounds
|
|
551
|
+
};
|
|
552
|
+
},
|
|
553
|
+
computeFeatureBBox: function computeFeatureBBox(feature) {
|
|
554
|
+
var bounds = geojsonBbox(feature);
|
|
555
|
+
// Discard z component
|
|
556
|
+
if (bounds.length === 6) {
|
|
557
|
+
bounds = [bounds[0], bounds[1], bounds[3], bounds[4]];
|
|
558
|
+
}
|
|
559
|
+
return bounds;
|
|
560
|
+
},
|
|
561
|
+
getFeatureCenter: function getFeatureCenter(feature) {
|
|
562
|
+
var geojson = new ol.format.GeoJSON().readFeature(feature);
|
|
563
|
+
var geometry = geojson.getGeometry();
|
|
564
|
+
var type = geometry.getType();
|
|
565
|
+
var center = null;
|
|
566
|
+
switch (type) {
|
|
567
|
+
case "Polygon":
|
|
568
|
+
center = geometry.getInteriorPoint().getCoordinates();
|
|
569
|
+
break;
|
|
570
|
+
case "MultiPolygon":
|
|
571
|
+
center = geometry.getInteriorPoints().getClosestPoint(ol.extent.getCenter(geometry.getExtent()));
|
|
572
|
+
break;
|
|
573
|
+
case "Point":
|
|
574
|
+
center = geometry.getCoordinates();
|
|
575
|
+
break;
|
|
576
|
+
case "MultiPoint":
|
|
577
|
+
center = geometry.getClosestPoint(ol.extent.getCenter(geometry.getExtent()));
|
|
578
|
+
break;
|
|
579
|
+
case "LineString":
|
|
580
|
+
center = geometry.getCoordinateAt(0.5);
|
|
581
|
+
break;
|
|
582
|
+
case "MultiLineString":
|
|
583
|
+
center = geometry.getClosestPoint(ol.extent.getCenter(geometry.getExtent()));
|
|
584
|
+
break;
|
|
585
|
+
case "Circle":
|
|
586
|
+
center = geometry.getCenter();
|
|
587
|
+
break;
|
|
588
|
+
default:
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
return center;
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
export default VectorLayerUtils;
|