qwc2 2025.3.31
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/LICENSE +28 -0
- package/README.md +68 -0
- package/actions/display.js +7 -0
- package/actions/editing.js +7 -0
- package/actions/layerinfo.js +7 -0
- package/actions/layers.js +8 -0
- package/actions/localConfig.js +7 -0
- package/actions/locale.js +10 -0
- package/actions/locate.js +8 -0
- package/actions/logging.js +7 -0
- package/actions/map.js +15 -0
- package/actions/measurement.js +8 -0
- package/actions/processNotifications.js +7 -0
- package/actions/redlining.js +7 -0
- package/actions/redliningPick.js +7 -0
- package/actions/serviceinfo.js +7 -0
- package/actions/task.js +9 -0
- package/actions/theme.js +24 -0
- package/actions/windows.js +10 -0
- package/components/AppMenu.js +8 -0
- package/components/AttributeForm.js +34 -0
- package/components/AutoEditForm.js +8 -0
- package/components/CoordinateDisplayer.js +7 -0
- package/components/EditComboField.js +10 -0
- package/components/EditUploadField.js +8 -0
- package/components/FullscreenSwitcher.js +8 -0
- package/components/Icon.js +7 -0
- package/components/IdentifyViewer.js +16 -0
- package/components/ImportLayer.js +25 -0
- package/components/LayerInfoWindow.js +7 -0
- package/components/LinkFeatureForm.js +10 -0
- package/components/MapSelection.js +13 -0
- package/components/NumericInputWindow.js +7 -0
- package/components/PickFeature.js +7 -0
- package/components/PluginsContainer.js +8 -0
- package/components/PrintSelection.js +54 -0
- package/components/QtDesignerForm.js +30 -0
- package/components/ResizeableWindow.js +12 -0
- package/components/SearchBox.js +26 -0
- package/components/ServiceInfoWindow.js +7 -0
- package/components/SideBar.js +9 -0
- package/components/StandardApp.js +35 -0
- package/components/Swipeable.js +1 -0
- package/components/TaskBar.js +7 -0
- package/components/ThemeLayersListWindow.js +9 -0
- package/components/ThemeList.js +12 -0
- package/components/Toolbar.js +7 -0
- package/components/WindowManager.js +7 -0
- package/components/map/OlLayer.js +12 -0
- package/components/map/OlLocate.css +56 -0
- package/components/map/OlLocate.js +17 -0
- package/components/map/OlMap.js +11 -0
- package/components/map/layers/BingLayer.js +8 -0
- package/components/map/layers/GoogleLayer.js +27 -0
- package/components/map/layers/GraticuleLayer.js +8 -0
- package/components/map/layers/ImageLayer.js +8 -0
- package/components/map/layers/MVTLayer.js +7 -0
- package/components/map/layers/OSMLayer.js +8 -0
- package/components/map/layers/OverlayLayer.js +10 -0
- package/components/map/layers/VectorLayer.js +14 -0
- package/components/map/layers/WFSLayer.js +11 -0
- package/components/map/layers/WMSLayer.js +11 -0
- package/components/map/layers/WMTSLayer.js +9 -0
- package/components/map/layers/XYZLayer.js +7 -0
- package/components/map/layers/index.js +8 -0
- package/components/map3d/BottomBar3D.js +7 -0
- package/components/map3d/Compare3D.js +12 -0
- package/components/map3d/Draw3D.js +10 -0
- package/components/map3d/ExportObjects3D.js +17 -0
- package/components/map3d/HeightProfile3D.js +8 -0
- package/components/map3d/HideObjects3D.js +12 -0
- package/components/map3d/Identify3D.js +13 -0
- package/components/map3d/LayerTree3D.js +8 -0
- package/components/map3d/Map3D.js +29 -0
- package/components/map3d/Map3DLight.js +10 -0
- package/components/map3d/MapControls3D.js +20 -0
- package/components/map3d/MapExport3D.js +11 -0
- package/components/map3d/Measure3D.js +23 -0
- package/components/map3d/OverviewMap3D.js +9 -0
- package/components/map3d/SearchField3D.js +16 -0
- package/components/map3d/TopBar3D.js +7 -0
- package/components/map3d/View3DSwitcher.js +7 -0
- package/components/map3d/drawtool/CreateTool3D.js +9 -0
- package/components/map3d/drawtool/EditTool3D.js +9 -0
- package/components/map3d/drawtool/NumericInput3D.js +7 -0
- package/components/map3d/img/viewcone.svg +124 -0
- package/components/map3d/layers/VectorLayer3D.js +7 -0
- package/components/map3d/layers/WFSLayer3D.js +8 -0
- package/components/map3d/layers/WMSLayer3D.js +7 -0
- package/components/map3d/layers/WMTSLayer3D.js +9 -0
- package/components/map3d/layers/index.js +8 -0
- package/components/map3d/models/arrow.glb +0 -0
- package/components/map3d/models/pin.glb +0 -0
- package/components/map3d/slices/map3d.js +1 -0
- package/components/map3d/style/BottomBar3D.css +67 -0
- package/components/map3d/style/Compare3D.css +57 -0
- package/components/map3d/style/Draw3D.css +7 -0
- package/components/map3d/style/HideObjects3D.css +29 -0
- package/components/map3d/style/LayerTree3D.css +126 -0
- package/components/map3d/style/Map3D.css +42 -0
- package/components/map3d/style/Map3DLight.css +72 -0
- package/components/map3d/style/MapControls3D.css +56 -0
- package/components/map3d/style/MapExport3D.css +25 -0
- package/components/map3d/style/OverviewMap3D.css +37 -0
- package/components/map3d/style/SearchField3D.css +7 -0
- package/components/map3d/style/View3DSwitcher.css +27 -0
- package/components/map3d/utils/Tiles3DStyle.js +1 -0
- package/components/share/ShareLink.js +7 -0
- package/components/share/ShareQRCode.js +8 -0
- package/components/share/ShareSocials.js +9 -0
- package/components/share/style/ShareLink.css +13 -0
- package/components/share/style/ShareSocials.css +9 -0
- package/components/style/App.css +229 -0
- package/components/style/AppMenu.css +162 -0
- package/components/style/AttributeForm.css +57 -0
- package/components/style/AutoEditForm.css +64 -0
- package/components/style/DefaultColorScheme.css +60 -0
- package/components/style/EditUploadField.css +103 -0
- package/components/style/FullscreenSwitcher.css +25 -0
- package/components/style/Icon.css +26 -0
- package/components/style/IdentifyViewer.css +249 -0
- package/components/style/ImportLayer.css +28 -0
- package/components/style/LayerInfoWindow.css +46 -0
- package/components/style/LinkFeatureForm.css +48 -0
- package/components/style/NumericInputWindow.css +11 -0
- package/components/style/PickFeature.css +25 -0
- package/components/style/PluginsContainer.css +4 -0
- package/components/style/QtDesignerForm.css +225 -0
- package/components/style/ResizeableWindow.css +178 -0
- package/components/style/SearchBox.css +159 -0
- package/components/style/ServiceInfoWindow.css +34 -0
- package/components/style/SideBar.css +100 -0
- package/components/style/TaskBar.css +35 -0
- package/components/style/ThemeLayersListWindow.css +47 -0
- package/components/style/ThemeList.css +200 -0
- package/components/style/Toolbar.css +20 -0
- package/components/style/WindowManager.css +50 -0
- package/components/timeline/FixedTimeline.js +10 -0
- package/components/timeline/InfiniteTimeline.js +13 -0
- package/components/timeline/TimelineFeaturesSlider.js +10 -0
- package/components/timeline/style/FixedTimeline.css +76 -0
- package/components/timeline/style/InfiniteTimeline.css +94 -0
- package/components/timeline/style/TimelineFeaturesSlider.css +131 -0
- package/components/widgets/AccordeonWidget.js +7 -0
- package/components/widgets/ButtonBar.js +7 -0
- package/components/widgets/ColorButton.js +8 -0
- package/components/widgets/ComboBox.js +7 -0
- package/components/widgets/CopyButton.js +7 -0
- package/components/widgets/DateTimeInput.js +8 -0
- package/components/widgets/EditableSelect.js +8 -0
- package/components/widgets/FileSelector.js +9 -0
- package/components/widgets/Input.js +7 -0
- package/components/widgets/InputContainer.js +7 -0
- package/components/widgets/LayerCatalogWidget.js +3 -0
- package/components/widgets/MenuButton.js +1 -0
- package/components/widgets/ModalDialog.js +7 -0
- package/components/widgets/NavBar.js +7 -0
- package/components/widgets/NumberInput.js +9 -0
- package/components/widgets/PopupMenu.js +1 -0
- package/components/widgets/Primitives.js +7 -0
- package/components/widgets/ReCaptchaWidget.js +1 -0
- package/components/widgets/SearchWidget.js +7 -0
- package/components/widgets/Spinner.js +6 -0
- package/components/widgets/SuggestionInput.js +7 -0
- package/components/widgets/TextInput.js +7 -0
- package/components/widgets/ToggleSwitch.js +7 -0
- package/components/widgets/VectorLayerPicker.js +8 -0
- package/components/widgets/style/AccordeonWidget.css +22 -0
- package/components/widgets/style/ButtonBar.css +88 -0
- package/components/widgets/style/ColorButton.css +88 -0
- package/components/widgets/style/ComboBox.css +83 -0
- package/components/widgets/style/CopyButton.css +21 -0
- package/components/widgets/style/EditableSelect.css +47 -0
- package/components/widgets/style/FileSelector.css +14 -0
- package/components/widgets/style/InputContainer.css +34 -0
- package/components/widgets/style/LayerCatalogWidget.css +59 -0
- package/components/widgets/style/MenuButton.css +122 -0
- package/components/widgets/style/ModalDialog.css +50 -0
- package/components/widgets/style/NavBar.css +12 -0
- package/components/widgets/style/NumberInput.css +76 -0
- package/components/widgets/style/SearchWidget.css +43 -0
- package/components/widgets/style/Spinner.css +32 -0
- package/components/widgets/style/SuggestionInput.css +8 -0
- package/components/widgets/style/TextInput.css +94 -0
- package/components/widgets/style/ToggleSwitch.css +61 -0
- package/components/widgets/style/VectorLayerPicker.css +3 -0
- package/icons/2d.svg +70 -0
- package/icons/3d.svg +70 -0
- package/icons/3d2d.svg +92 -0
- package/icons/after.svg +76 -0
- package/icons/arrow-down.svg +60 -0
- package/icons/arrow-up.svg +60 -0
- package/icons/before.svg +76 -0
- package/icons/bglayer.svg +71 -0
- package/icons/bookmark.svg +170 -0
- package/icons/box.svg +63 -0
- package/icons/buffer.svg +67 -0
- package/icons/camera.svg +118 -0
- package/icons/catalog.svg +62 -0
- package/icons/checked.svg +80 -0
- package/icons/chevron-down.svg +60 -0
- package/icons/chevron-left.svg +59 -0
- package/icons/chevron-right.svg +60 -0
- package/icons/chevron-up.svg +60 -0
- package/icons/circle.svg +70 -0
- package/icons/clear.svg +62 -0
- package/icons/clock.svg +71 -0
- package/icons/cog.svg +60 -0
- package/icons/collapse.svg +73 -0
- package/icons/compare.svg +72 -0
- package/icons/cone.svg +58 -0
- package/icons/confirm.svg +62 -0
- package/icons/copy.svg +60 -0
- package/icons/cuboid.svg +58 -0
- package/icons/cyclomedia.svg +47 -0
- package/icons/cylinder.svg +58 -0
- package/icons/dataimport.svg +116 -0
- package/icons/detach.svg +79 -0
- package/icons/dock.svg +82 -0
- package/icons/dock_bottom.svg +82 -0
- package/icons/dock_left.svg +84 -0
- package/icons/dock_right.svg +84 -0
- package/icons/dock_top.svg +84 -0
- package/icons/draw.svg +78 -0
- package/icons/editdraw.svg +84 -0
- package/icons/edited.svg +78 -0
- package/icons/editing.svg +118 -0
- package/icons/ellipse.svg +72 -0
- package/icons/embed.svg +88 -0
- package/icons/expand.svg +73 -0
- package/icons/export.svg +126 -0
- package/icons/eye.svg +127 -0
- package/icons/featureform.svg +115 -0
- package/icons/fill.svg +62 -0
- package/icons/filter.svg +69 -0
- package/icons/folder-open.svg +60 -0
- package/icons/freehand.svg +82 -0
- package/icons/group.svg +76 -0
- package/icons/home.svg +60 -0
- package/icons/identify_radius.svg +71 -0
- package/icons/identify_region.svg +71 -0
- package/icons/import.svg +62 -0
- package/icons/info-sign.svg +60 -0
- package/icons/info.svg +80 -0
- package/icons/layers.svg +71 -0
- package/icons/light.svg +77 -0
- package/icons/line.svg +61 -0
- package/icons/line_buffer.svg +65 -0
- package/icons/link.svg +75 -0
- package/icons/list-alt.svg +111 -0
- package/icons/lock.svg +54 -0
- package/icons/login.svg +56 -0
- package/icons/logout.svg +56 -0
- package/icons/map3d.svg +51 -0
- package/icons/maximize.svg +84 -0
- package/icons/measure.svg +82 -0
- package/icons/measure_line.svg +87 -0
- package/icons/measure_polygon.svg +88 -0
- package/icons/menu-hamburger.svg +60 -0
- package/icons/minimize.svg +76 -0
- package/icons/minus-sign.svg +60 -0
- package/icons/minus.svg +61 -0
- package/icons/nav-end.svg +74 -0
- package/icons/nav-left.svg +74 -0
- package/icons/nav-right.svg +74 -0
- package/icons/nav-start.svg +73 -0
- package/icons/new.svg +84 -0
- package/icons/nodetool.svg +68 -0
- package/icons/numericinput.svg +86 -0
- package/icons/ok.svg +60 -0
- package/icons/open.svg +79 -0
- package/icons/open_link.svg +74 -0
- package/icons/paint.svg +75 -0
- package/icons/pen.svg +41 -0
- package/icons/person.svg +44 -0
- package/icons/pick.svg +67 -0
- package/icons/pick_point.svg +74 -0
- package/icons/pick_region.svg +71 -0
- package/icons/plus.svg +60 -0
- package/icons/point.svg +67 -0
- package/icons/point_buffer.svg +74 -0
- package/icons/polygon.svg +61 -0
- package/icons/print.svg +60 -0
- package/icons/pyramid.svg +58 -0
- package/icons/radio_checked.svg +78 -0
- package/icons/radio_tristate.svg +75 -0
- package/icons/radio_unchecked.svg +72 -0
- package/icons/rasterexport.svg +124 -0
- package/icons/rect.svg +63 -0
- package/icons/refresh.svg +44 -0
- package/icons/remove.svg +60 -0
- package/icons/report.svg +84 -0
- package/icons/routing-bicycle.svg +40 -0
- package/icons/routing-bus.svg +40 -0
- package/icons/routing-cablecar.svg +40 -0
- package/icons/routing-car.svg +40 -0
- package/icons/routing-ship.svg +40 -0
- package/icons/routing-train.svg +40 -0
- package/icons/routing-tram.svg +40 -0
- package/icons/routing-truck.svg +40 -0
- package/icons/routing-walking.svg +40 -0
- package/icons/routing.svg +68 -0
- package/icons/save.svg +190 -0
- package/icons/scale.svg +62 -0
- package/icons/screenshot.svg +60 -0
- package/icons/search.svg +60 -0
- package/icons/selectbox.svg +79 -0
- package/icons/share.svg +64 -0
- package/icons/snap_edge.svg +79 -0
- package/icons/snap_vertex.svg +79 -0
- package/icons/sphere.svg +58 -0
- package/icons/square.svg +68 -0
- package/icons/sync.svg +72 -0
- package/icons/text.svg +68 -0
- package/icons/themes.svg +81 -0
- package/icons/tilt-down.svg +67 -0
- package/icons/tilt-left.svg +48 -0
- package/icons/tilt-right.svg +48 -0
- package/icons/tilt-up.svg +67 -0
- package/icons/today.svg +45 -0
- package/icons/tools.svg +77 -0
- package/icons/transformtool.svg +74 -0
- package/icons/transparency.svg +132 -0
- package/icons/trash.svg +60 -0
- package/icons/tree_minus.svg +81 -0
- package/icons/tree_plus.svg +81 -0
- package/icons/triangle-down.svg +59 -0
- package/icons/triangle-left.svg +60 -0
- package/icons/triangle-right.svg +60 -0
- package/icons/triangle-up.svg +59 -0
- package/icons/tristate.svg +79 -0
- package/icons/unchecked.svg +74 -0
- package/icons/undock.svg +82 -0
- package/icons/undock_bottom.svg +82 -0
- package/icons/undock_left.svg +82 -0
- package/icons/undock_right.svg +84 -0
- package/icons/undock_top.svg +84 -0
- package/icons/unmaximize.svg +84 -0
- package/icons/unminimize.svg +76 -0
- package/icons/up-down-arrow.svg +66 -0
- package/icons/warning.svg +72 -0
- package/icons/wedge.svg +58 -0
- package/icons/zoom.svg +60 -0
- package/icons/zoomin.svg +71 -0
- package/icons/zoomout.svg +80 -0
- package/libs/openlayers.js +11 -0
- package/package.json +135 -0
- package/plugins/API.js +114 -0
- package/plugins/AttributeTable.js +25 -0
- package/plugins/Authentication.js +13 -0
- package/plugins/BackgroundSwitcher.js +10 -0
- package/plugins/Bookmark.js +13 -0
- package/plugins/BottomBar.js +10 -0
- package/plugins/CookiePopup.js +9 -0
- package/plugins/Cyclomedia.js +11 -0
- package/plugins/Editing.js +21 -0
- package/plugins/FeatureForm.js +21 -0
- package/plugins/FeatureSearch.js +11 -0
- package/plugins/GeometryDigitizer.js +43 -0
- package/plugins/HeightProfile.js +26 -0
- package/plugins/Help.js +11 -0
- package/plugins/HomeButton.js +9 -0
- package/plugins/Identify.js +18 -0
- package/plugins/LayerCatalog.js +45 -0
- package/plugins/LayerTree.js +15 -0
- package/plugins/LocateButton.js +10 -0
- package/plugins/Map.js +22 -0
- package/plugins/MapCompare.js +11 -0
- package/plugins/MapCopyright.js +11 -0
- package/plugins/MapExport.js +23 -0
- package/plugins/MapFilter.js +20 -0
- package/plugins/MapInfoTooltip.js +32 -0
- package/plugins/MapLegend.js +14 -0
- package/plugins/MapTip.js +15 -0
- package/plugins/Measure.js +10 -0
- package/plugins/NewsPopup.js +12 -0
- package/plugins/Panoramax.js +10 -0
- package/plugins/Portal.js +10 -0
- package/plugins/Print.js +22 -0
- package/plugins/ProcessNotifications.js +11 -0
- package/plugins/Redlining.js +12 -0
- package/plugins/Reports.js +15 -0
- package/plugins/Routing.js +23 -0
- package/plugins/ScratchDrawing.js +15 -0
- package/plugins/Settings.js +12 -0
- package/plugins/Share.js +11 -0
- package/plugins/StartupMarker.js +12 -0
- package/plugins/TaskButton.js +9 -0
- package/plugins/ThemeSwitcher.js +10 -0
- package/plugins/TimeManager.js +21 -0
- package/plugins/TopBar.js +13 -0
- package/plugins/ValueTool.js +11 -0
- package/plugins/View3D.js +34 -0
- package/plugins/ZoomButtons.js +11 -0
- package/plugins/map/EditingSupport.js +13 -0
- package/plugins/map/LocateSupport.js +14 -0
- package/plugins/map/MeasurementSupport.js +15 -0
- package/plugins/map/OverviewSupport.js +14 -0
- package/plugins/map/RedliningPickSupport.js +12 -0
- package/plugins/map/RedliningSupport.js +28 -0
- package/plugins/map/ScaleBarSupport.js +10 -0
- package/plugins/map/SnapInteraction.js +1 -0
- package/plugins/map/SnapSupport.js +7 -0
- package/plugins/map/SnappingSupport.js +23 -0
- package/plugins/map/style/OverviewSupport.css +42 -0
- package/plugins/map/style/ScaleBarSupport.css +18 -0
- package/plugins/map/style/SnappingSupport.css +33 -0
- package/plugins/redlining/RedliningBufferSupport.js +8 -0
- package/plugins/style/AttributeTable.css +220 -0
- package/plugins/style/Authentication.css +16 -0
- package/plugins/style/BackgroundSwitcher.css +99 -0
- package/plugins/style/Bookmark.css +62 -0
- package/plugins/style/BottomBar.css +53 -0
- package/plugins/style/Buttons.css +68 -0
- package/plugins/style/CookiePopup.css +24 -0
- package/plugins/style/Cyclomedia.css +66 -0
- package/plugins/style/Editing.css +40 -0
- package/plugins/style/FeatureForm.css +21 -0
- package/plugins/style/FeatureSearch.css +71 -0
- package/plugins/style/GeometryDigitizer.css +28 -0
- package/plugins/style/HeightProfile.css +26 -0
- package/plugins/style/Identify.css +4 -0
- package/plugins/style/LayerCatalog.css +8 -0
- package/plugins/style/LayerTree.css +316 -0
- package/plugins/style/Map.css +43 -0
- package/plugins/style/MapCompare.css +27 -0
- package/plugins/style/MapCopyright.css +17 -0
- package/plugins/style/MapExport.css +55 -0
- package/plugins/style/MapFilter.css +101 -0
- package/plugins/style/MapInfoTooltip.css +78 -0
- package/plugins/style/MapLegend.css +36 -0
- package/plugins/style/MapTip.css +22 -0
- package/plugins/style/Measure.css +23 -0
- package/plugins/style/NewsPopup.css +87 -0
- package/plugins/style/Panoramax.css +15 -0
- package/plugins/style/Portal.css +115 -0
- package/plugins/style/Print.css +116 -0
- package/plugins/style/ProcessNotifications.css +55 -0
- package/plugins/style/Redlining.css +101 -0
- package/plugins/style/Reports.css +11 -0
- package/plugins/style/Routing.css +243 -0
- package/plugins/style/ScratchDrawing.css +8 -0
- package/plugins/style/Settings.css +11 -0
- package/plugins/style/Share.css +59 -0
- package/plugins/style/ThemeSwitcher.css +7 -0
- package/plugins/style/TimeManager.css +91 -0
- package/plugins/style/TopBar.css +50 -0
- package/plugins/style/ValueTool.css +60 -0
- package/reducers/display.js +7 -0
- package/reducers/editing.js +8 -0
- package/reducers/index.js +7 -0
- package/reducers/layerinfo.js +7 -0
- package/reducers/layers.js +14 -0
- package/reducers/localConfig.js +8 -0
- package/reducers/locale.js +8 -0
- package/reducers/locate.js +8 -0
- package/reducers/map.js +11 -0
- package/reducers/measurement.js +8 -0
- package/reducers/processNotifications.js +7 -0
- package/reducers/redlining.js +7 -0
- package/reducers/redliningPick.js +7 -0
- package/reducers/serviceinfo.js +7 -0
- package/reducers/task.js +7 -0
- package/reducers/theme.js +7 -0
- package/reducers/windows.js +7 -0
- package/scripts/dist.sh +16 -0
- package/scripts/gen-plugin-docs.js +9 -0
- package/scripts/makeIconkit.js +7 -0
- package/scripts/package-commands.bat +8 -0
- package/scripts/package-commands.sh +22 -0
- package/scripts/themesConfig.js +48 -0
- package/scripts/themesConfig.py +659 -0
- package/scripts/translateui.sh +51 -0
- package/scripts/updateTranslations.js +17 -0
- package/scripts/wmts_config_generator.py +169 -0
- package/selectors/searchproviders.js +12 -0
- package/static/translations/bg-BG.json +709 -0
- package/static/translations/ca-ES.json +709 -0
- package/static/translations/cs-CZ.json +709 -0
- package/static/translations/de-CH.json +709 -0
- package/static/translations/de-DE.json +709 -0
- package/static/translations/en-US.json +709 -0
- package/static/translations/es-ES.json +709 -0
- package/static/translations/fi-FI.json +709 -0
- package/static/translations/fr-FR.json +709 -0
- package/static/translations/hu-HU.json +709 -0
- package/static/translations/it-IT.json +709 -0
- package/static/translations/ja-JP.json +709 -0
- package/static/translations/nl-NL.json +709 -0
- package/static/translations/no-NO.json +709 -0
- package/static/translations/pl-PL.json +709 -0
- package/static/translations/pt-BR.json +709 -0
- package/static/translations/pt-PT.json +709 -0
- package/static/translations/ro-RO.json +709 -0
- package/static/translations/ru-RU.json +709 -0
- package/static/translations/sv-SE.json +709 -0
- package/static/translations/tr-TR.json +709 -0
- package/static/translations/tsconfig.json +606 -0
- package/stores/StandardStore.js +8 -0
- package/utils/ConfigUtils.js +9 -0
- package/utils/CoordinatesUtils.js +29 -0
- package/utils/DxfUtils.js +10 -0
- package/utils/EditingInterface.js +67 -0
- package/utils/EditingUtils.js +11 -0
- package/utils/FeatureStyles.js +10 -0
- package/utils/IdentifyUtils.js +12 -0
- package/utils/ImageEditor.js +15 -0
- package/utils/LayerUtils.js +57 -0
- package/utils/LocaleUtils.js +9 -0
- package/utils/MapUtils.js +66 -0
- package/utils/MeasureUtils.js +9 -0
- package/utils/MiscUtils.js +15 -0
- package/utils/PermaLinkUtils.js +11 -0
- package/utils/ResourceRegistry.js +7 -0
- package/utils/RoutingInterface.js +12 -0
- package/utils/SearchProviders.js +19 -0
- package/utils/ServiceLayerUtils.js +20 -0
- package/utils/Signal.js +2 -0
- package/utils/ThemeUtils.js +12 -0
- package/utils/VectorLayerUtils.js +20 -0
- package/utils/expr_grammar/README.md +3 -0
- package/utils/expr_grammar/grammar.js +3 -0
- package/utils/expr_grammar/grammar.ne +118 -0
- package/utils/expr_grammar/test.js +13 -0
- package/utils/img/README.markers +1 -0
- package/utils/img/arrowhead.svg +4 -0
- package/utils/img/marker-icon.png +0 -0
- package/utils/img/measurehead.svg +4 -0
|
@@ -0,0 +1,13 @@
|
|
|
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)}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}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}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2016-2024 Sourcepole AG
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/import React from"react";import{connect}from"react-redux";import classnames from"classnames";import isEmpty from"lodash.isempty";import PropTypes from"prop-types";import{toggleFullscreen}from"../actions/display";import{openExternalUrl,setTopbarHeight}from"../actions/windows";import{Swipeable}from"../components/Swipeable";import ConfigUtils from"../utils/ConfigUtils";import LocaleUtils from"../utils/LocaleUtils";import ThemeUtils from"../utils/ThemeUtils";import"./style/TopBar.css";/**
|
|
8
|
+
* Top bar, containing the logo, searchbar, task buttons and app menu.
|
|
9
|
+
*/var TopBar=/*#__PURE__*/function(_React$Component){function TopBar(){var _this;_classCallCheck(this,TopBar);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,TopBar,[].concat(args));_defineProperty(_this,"state",{allowedMenuItems:[],allowedToolbarItems:[]});_defineProperty(_this,"openUrl",function(url,target,title,icon){if(target==="iframe"){target=":iframedialog:externallinkiframe"}_this.props.openExternalUrl(url,target,{title:title,icon:icon})});_defineProperty(_this,"storeHeight",function(el){if(el){_this.props.setTopbarHeight(el.clientHeight)}});_defineProperty(_this,"allowedItems",function(items){return items.map(function(item){if(item.subitems){var subitems=_this.allowedItems(item.subitems);if(!isEmpty(subitems)){return _objectSpread(_objectSpread({},item),{},{subitems:subitems})}else{return null}}else if(_this.props.currentTheme){if(!ThemeUtils.themeFlagsAllowed(_this.props.currentTheme,item.themeFlagWhitelist,item.themeFlagBlacklist)){return null}if(item.themeBlacklist&&(item.themeBlacklist.includes(_this.props.currentTheme.title)||item.themeBlacklist.includes(_this.props.currentTheme.name))){return null}if(item.themeWhitelist&&!(item.themeWhitelist.includes(_this.props.currentTheme.title)||item.themeWhitelist.includes(_this.props.currentTheme.name))){return null}if(item.requireAuth&&!ConfigUtils.getConfigProp("username")){return null}}return item}).filter(Boolean)});return _this}_inherits(TopBar,_React$Component);return _createClass(TopBar,[{key:"componentDidMount",value:function componentDidMount(){this.setState({allowedToolbarItems:this.allowedItems(this.props.toolbarItems),allowedMenuItems:this.allowedItems(this.props.menuItems)})}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(this.props.currentTheme!==prevProps.currentTheme){this.setState({allowedToolbarItems:this.allowedItems(this.props.toolbarItems),allowedMenuItems:this.allowedItems(this.props.menuItems)})}}},{key:"render",value:function render(){var _this2=this;var logo;var assetsPath=ConfigUtils.getAssetsPath();var isMobile=ConfigUtils.isMobile();if(isMobile||this.props.appMenuCompact){logo=assetsPath+"/img/logo-mobile."+this.props.logoFormat}else{logo=assetsPath+"/img/logo."+this.props.logoFormat}var classes=classnames({TopBar:true,mobile:isMobile,fullscreen:this.props.fullscreen});var logoEl=/*#__PURE__*/React.createElement("img",{className:"topbar-logo",src:this.props.logoSrc||logo});if(this.props.logoUrl){logoEl=/*#__PURE__*/React.createElement("a",{href:this.props.logoUrl,rel:"noreferrer",target:"_blank"},logoEl)}// Convert legacy minScale option to minScaleDenom
|
|
10
|
+
var searchOptions=_objectSpread({},this.props.searchOptions);searchOptions.minScaleDenom=searchOptions.minScaleDenom||searchOptions.minScale;delete searchOptions.minScale;// Menu compact only available for desktop client
|
|
11
|
+
var menuCompact=!isMobile?this.props.appMenuCompact:false;// Keep menu open when appMenu is in compact mode (Visible on Hover)
|
|
12
|
+
var keepMenuOpen=menuCompact;// Menu should be visible on startup when appMenu is in compact mode (Visible on Hover)
|
|
13
|
+
var showOnStartup=this.props.appMenuVisibleOnStartup||menuCompact;var style=this.props.mapMargins.splitTopAndBottomBar?{marginLeft:this.props.mapMargins.left+"px",marginRight:this.props.mapMargins.right+"px"}:{};return/*#__PURE__*/React.createElement(Swipeable,{onSwipedDown:function onSwipedDown(){return _this2.props.toggleFullscreen(false)},onSwipedUp:function onSwipedUp(){return _this2.props.toggleFullscreen(true)}},/*#__PURE__*/React.createElement("div",{className:classes,ref:this.storeHeight,style:style},logoEl,/*#__PURE__*/React.createElement("div",{className:"topbar-center-span"},this.props.components.Search?/*#__PURE__*/React.createElement("div",{className:"topbar-search-container"},/*#__PURE__*/React.createElement(this.props.components.Search,{searchOptions:searchOptions})):null,this.props.components.Toolbar?/*#__PURE__*/React.createElement(this.props.components.Toolbar,{openExternalUrl:this.openUrl,toolbarItems:this.state.allowedToolbarItems,toolbarItemsShortcutPrefix:this.props.toolbarItemsShortcutPrefix}):null),this.props.components.AppMenu&&!this.props.appMenuHidden?/*#__PURE__*/React.createElement(this.props.components.AppMenu,{appMenuClearsTask:this.props.appMenuClearsTask,appMenuShortcut:this.props.appMenuShortcut,buttonLabel:LocaleUtils.tr("appmenu.menulabel"),keepMenuOpen:keepMenuOpen,menuCompact:menuCompact,menuItems:this.state.allowedMenuItems,openExternalUrl:this.openUrl,showFilterField:this.props.appMenuFilterField,showOnStartup:showOnStartup}):null,this.props.components.FullscreenSwitcher?/*#__PURE__*/React.createElement(this.props.components.FullscreenSwitcher,null):null))}}])}(React.Component);_defineProperty(TopBar,"propTypes",{/** Whether opening the app menu clears the active task. */appMenuClearsTask:PropTypes.bool,/** Whether show an appMenu compact (menu visible on icons hover) - Only available for desktop client. */appMenuCompact:PropTypes.bool,/** Whether to display the filter field in the app menu. */appMenuFilterField:PropTypes.bool,/** Whether to hide the app menu (useful primarely as a theme specific setting). */appMenuHidden:PropTypes.bool,/** The shortcut for tiggering the app menu, i.e. alt+shift+m. */appMenuShortcut:PropTypes.string,/** Whether to open the app menu on application startup. */appMenuVisibleOnStartup:PropTypes.bool,components:PropTypes.object,currentTheme:PropTypes.object,fullscreen:PropTypes.bool,/** The logo file format. */logoFormat:PropTypes.string,/** The logo image URL if a different source than the default assets/img/logo.<ext> and assets/img/logo-mobile.<ext> is desired. */logoSrc:PropTypes.string,/** The hyperlink to open when the logo is clicked. */logoUrl:PropTypes.string,mapMargins:PropTypes.object,/** The menu items. Refer to the corresponding chapter of the viewer documentation and the sample config.json. */menuItems:PropTypes.array,openExternalUrl:PropTypes.func,/** Options passed down to the search component. */searchOptions:PropTypes.shape({/** Whether to show the search filter widget. */allowSearchFilters:PropTypes.bool,/** Whether to hide the result labels on the map. */hideResultLabels:PropTypes.bool,/** The style used for highlighting search result geometries. */highlightStyle:PropTypes.shape({/* Stroke color rgba array, i.e. [255, 0, 0, 0.5] */strokeColor:PropTypes.array,/* Stroke width */strokeWidth:PropTypes.number,/* Stroke dash/gap pattern array. Empty for solid line. */strokeDash:PropTypes.array,/* Fill color rgba array, i.e. [255, 0, 0, 0.33] */fillColor:PropTypes.array}),/** Minimum scale denominator when zooming to search result. */minScaleDenom:PropTypes.number,/** Result count limit which is passed to the search provider. */resultLimit:PropTypes.number,/** Whether to collapse search sections by default. */sectionsDefaultCollapsed:PropTypes.bool,/** Whether to show the layer tree after selecting a theme result. */showLayerAfterChangeTheme:PropTypes.bool,/** Whether to show layer results before pkaces in the result menu. */showLayerResultsBeforePlaces:PropTypes.bool,/** Whether to replace the search text with the selected search result text. */showResultInSearchText:PropTypes.bool,/** Whether to zoom to layer search results. */zoomToLayers:PropTypes.bool}),setTopbarHeight:PropTypes.func,toggleFullscreen:PropTypes.func,/** The toolbar. Refer to the corresponding chapter of the viewer documentation and the sample config.json. */toolbarItems:PropTypes.array,/** The keyboard shortcut prefix for triggering toolbar tasks. I.e. alt+shift. The task are then triggered by <prefix>+{1,2,3,...} for the 1st, 2nd, 3rd... toolbar icon. */toolbarItemsShortcutPrefix:PropTypes.string});_defineProperty(TopBar,"defaultProps",{searchOptions:{showResultInSearchText:true},menuItems:[],toolbarItems:[],logoFormat:"svg"});export default(function(components){return connect(function(state){return{fullscreen:state.display.fullscreen,components:components,currentTheme:state.theme.current,mapMargins:state.windows.mapMargins}},{toggleFullscreen:toggleFullscreen,openExternalUrl:openExternalUrl,setTopbarHeight:setTopbarHeight})(TopBar)});
|
|
@@ -0,0 +1,11 @@
|
|
|
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)}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}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}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}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.")}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}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}}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}function _iterableToArrayLimit(r,l){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,n,i,u,a=[],f=!0,o=!1;try{if(i=(t=t.call(r)).next,0===l){if(Object(t)!==t)return;f=!1}else for(;!(f=(e=i.call(t)).done)&&(a.push(e.value),a.length!==l);f=!0);}catch(r){o=!0,n=r}finally{try{if(!f&&null!=t["return"]&&(u=t["return"](),Object(u)!==u))return}finally{if(o)throw n}}return a}}function _arrayWithHoles(r){if(Array.isArray(r))return r}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2025 Sourcepole AG
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/import React from"react";import{Line}from"react-chartjs-2";import{connect}from"react-redux";import isEmpty from"lodash.isempty";import PropTypes from"prop-types";import{v1 as uuidv1}from"uuid";import{LayerRole}from"../actions/layers";import{setCurrentTask}from"../actions/task";import Icon from"../components/Icon";import ResizeableWindow from"../components/ResizeableWindow";import ButtonBar from"../components/widgets/ButtonBar";import TextInput from"../components/widgets/TextInput";import IdentifyUtils from"../utils/IdentifyUtils";import LayerUtils from"../utils/LayerUtils";import LocaleUtils from"../utils/LocaleUtils";import MapUtils from"../utils/MapUtils";import"./style/ValueTool.css";/**
|
|
8
|
+
* Displays raster band values of active raster layers at the hovered mouse position,
|
|
9
|
+
* queried via GetFeatureInfo.
|
|
10
|
+
*/var ValueTool=/*#__PURE__*/function(_React$Component){function ValueTool(props){var _this;_classCallCheck(this,ValueTool);_this=_callSuper(this,ValueTool,[props]);_defineProperty(_this,"renderTableTab",function(){if(isEmpty(_this.state.values)){return/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement("i",null,LocaleUtils.tr("valuetool.nodata")))}return/*#__PURE__*/React.createElement("table",{className:"valuetool-table"},/*#__PURE__*/React.createElement("tbody",null,Object.entries(_this.state.values).map(function(_ref){var _ref2=_slicedToArray(_ref,2),key=_ref2[0],data=_ref2[1];var bandvals=Object.entries(data.values);if(_this.state.selectedBands[key]){var activeBands=_this.state.selectedBands[key].split(",").map(function(x){return parseInt(x.trim(),10)-1});bandvals=bandvals.filter(function(_,i){return activeBands.includes(i)})}return[/*#__PURE__*/React.createElement("tr",{key:key},/*#__PURE__*/React.createElement("th",{colSpan:"2"},data.layertitle)),bandvals.map(function(_ref3){var _ref4=_slicedToArray(_ref3,2),bandname=_ref4[0],bandval=_ref4[1];return/*#__PURE__*/React.createElement("tr",{key:key+"_"+bandname},/*#__PURE__*/React.createElement("td",null,bandname),/*#__PURE__*/React.createElement("td",null,bandval))})]})))});_defineProperty(_this,"renderGraphTab",function(){var values=Object.values(_this.state.values).map(function(x){return Object.values(x.values)}).flat().filter(function(x){return x});var data={labels:values.map(function(_,i){return String(i)}),datasets:[{data:values,borderColor:"rgb(255,0,0)",borderWidth:2}]};var options={responsive:true,maintainAspectRatio:false,animation:{duration:0}};return/*#__PURE__*/React.createElement("div",{className:"valuetool-chart-container"},/*#__PURE__*/React.createElement(Line,{data:data,options:options}))});_defineProperty(_this,"renderOptionsTab",function(){var options=_this.state.showLayers==="selected"||_this.state.showBands==="selected"?[/*#__PURE__*/React.createElement("hr",{key:"sep"}),/*#__PURE__*/React.createElement("div",{key:"label"},LocaleUtils.tr("valuetool.selectlayersbands")),/*#__PURE__*/React.createElement("table",{className:"valuetool-table-selection",key:"table"},/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("th",null,LocaleUtils.tr("valuetool.layer")),_this.state.showBands==="selected"?/*#__PURE__*/React.createElement("th",null,LocaleUtils.tr("valuetool.bands")):null),_this.props.layers.map(function(layer){var sublayers=LayerUtils.getSublayerNames(layer,true,function(sublayer){return sublayer.geometryType===null});return sublayers.map(function(sublayer){var key=layer.url+"#"+sublayer;return/*#__PURE__*/React.createElement("tr",{key:key},/*#__PURE__*/React.createElement("td",null,_this.state.showLayers==="selected"?/*#__PURE__*/React.createElement(Icon,{icon:_this.state.selectedLayers.includes(key)?"checked":"unchecked",onClick:function onClick(){return _this.toggleSelectedLayer(key)}}):null,sublayer),_this.state.showBands==="selected"?/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(TextInput,{onChange:function onChange(value){return _this.setLayerBands(key,value)},placeholder:LocaleUtils.tr("valuetool.all"),value:_this.state.selectedBands[key]||""})):null)})})))]:null;return/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("table",{className:"valuetool-table-options"},/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("valuetool.showlayers"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.setState({showLayers:ev.target.value})},value:_this.state.showLayers},/*#__PURE__*/React.createElement("option",{value:"visible"},LocaleUtils.tr("valuetool.visiblelayers")),/*#__PURE__*/React.createElement("option",{value:"all"},LocaleUtils.tr("valuetool.alllayers")),/*#__PURE__*/React.createElement("option",{value:"selected"},LocaleUtils.tr("valuetool.selectedlayers"))))),/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("valuetool.showbands"),":"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:function onChange(ev){return _this.setState({showBands:ev.target.value})},value:_this.state.showBands},/*#__PURE__*/React.createElement("option",{value:"all"},LocaleUtils.tr("valuetool.allbands")),/*#__PURE__*/React.createElement("option",{value:"selected"},LocaleUtils.tr("valuetool.selectedbands"))))))),options)});_defineProperty(_this,"toggleSelectedLayer",function(key){_this.setState(function(state){return{selectedLayers:state.selectedLayers.includes(key)?state.selectedLayers.filter(function(x){return x!==key}):[].concat(_toConsumableArray(state.selectedLayers),[key])}})});_defineProperty(_this,"setLayerBands",function(key,bands){_this.setState(function(state){return{selectedBands:_objectSpread(_objectSpread({},state.selectedBands),{},_defineProperty({},key,_toConsumableArray(new Set(bands.split(",").map(function(x){return parseInt(x.trim(),10)||0}).sort().filter(function(x){return x}))).join(", ")))}})});_defineProperty(_this,"onWindowClose",function(){_this.props.setCurrentTask(null)});_defineProperty(_this,"scheduleQueryValues",function(ev){var coordinate=ev.coordinate;clearTimeout(_this.queryTimeout);_this.queryTimeout=setTimeout(function(){return _this.queryValues(coordinate)},100)});_defineProperty(_this,"queryValues",function(coordinate){var options={info_format:"text/xml",feature_count:5,with_geometry:false,with_htmlcontent:false};var reqId=uuidv1();_this.reqId=reqId;var newValues={};_this.props.layers.forEach(function(layer){var layerActive=null;if(_this.state.showLayers==="all"){layerActive=function layerActive(){return true}}else if(_this.state.showLayers==="selected"){layerActive=function layerActive(sublayer){return _this.state.selectedLayers.includes(layer.url+"#"+sublayer.name)}}else if(_this.state.showLayers==="visible"){layerActive=function layerActive(sublayer){return sublayer.visibility}}var queryLayers=LayerUtils.getSublayerNames(layer,true,function(sublayer){return layerActive(sublayer)&&sublayer.geometryType===null});if(isEmpty(queryLayers)){return}// Preserve previous result rows, but with empty values, to prevent "flickering"
|
|
11
|
+
queryLayers.forEach(function(sublayername){var key=layer.url+"#"+sublayername;if(_this.state.values[key]){newValues[key]=_objectSpread(_objectSpread({},_this.state.values[key]),{},{values:Object.fromEntries(Object.keys(_this.state.values[key].values).map(function(k){return[k,""]}))})}});var request=IdentifyUtils.buildRequest(layer,queryLayers.join(","),coordinate,_this.props.map,options);IdentifyUtils.sendRequest(request,function(response){if(_this.reqId===reqId){var result=IdentifyUtils.parseXmlResponse(response||"",_this.props.map.projection);_this.setState(function(state){return{values:_objectSpread(_objectSpread({},state.values),Object.entries(result).reduce(function(res,_ref5){var _ref6=_slicedToArray(_ref5,2),sublayername=_ref6[0],features=_ref6[1];var key=layer.url+"#"+sublayername;res[key]={layertitle:features[0].layertitle,values:features[0].properties};return res},{}))}})}})});_this.setState({values:newValues})});_this.queryTimeout=null;_this.reqId=null;_this.state=ValueTool.defaultState;return _this}_inherits(ValueTool,_React$Component);return _createClass(ValueTool,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(this.props.enabled&&!prevProps.enabled){MapUtils.getHook(MapUtils.GET_MAP).on("pointermove",this.scheduleQueryValues)}else if(!this.props.enabled&&prevProps.enabled){MapUtils.getHook(MapUtils.GET_MAP).un("pointermove",this.scheduleQueryValues);clearTimeout(this.queryTimeout);this.queryTimeout=null;this.setState(ValueTool.defaultState)}}},{key:"render",value:function render(){var _this2=this;if(!this.props.enabled){return null}var buttons=[{key:"Table",label:LocaleUtils.tr("valuetool.table")},{key:"Graph",label:LocaleUtils.tr("valuetool.graph")},{key:"Options",label:LocaleUtils.tr("valuetool.options")}];var tab=null;if(this.state.activeTab==="Table"){tab=this.renderTableTab()}else if(this.state.activeTab==="Graph"){tab=this.renderGraphTab()}else if(this.state.activeTab==="Options"){tab=this.renderOptionsTab()}return/*#__PURE__*/React.createElement(ResizeableWindow,{dockable:this.props.geometry.side,icon:"info-sign",initialHeight:this.props.geometry.initialHeight,initialWidth:this.props.geometry.initialWidth,initialX:this.props.geometry.initialX,initialY:this.props.geometry.initialY,initiallyDocked:this.props.geometry.initiallyDocked,onClose:this.onWindowClose,title:LocaleUtils.tr("valuetool.title")},/*#__PURE__*/React.createElement("div",{className:"valuetool-body",role:"body"},/*#__PURE__*/React.createElement(ButtonBar,{active:this.state.activeTab,buttons:buttons,onClick:function onClick(key){return _this2.setState({activeTab:key})}}),tab))}}])}(React.Component);_defineProperty(ValueTool,"propTypes",{/** The number of decimal places to display for elevation values. */enabled:PropTypes.bool,/** Default window geometry with size, position and docking status. Positive position values (including '0') are related to top (InitialY) and left (InitialX), negative values (including '-0') to bottom (InitialY) and right (InitialX). */geometry:PropTypes.shape({initialWidth:PropTypes.number,initialHeight:PropTypes.number,initialX:PropTypes.number,initialY:PropTypes.number,initiallyDocked:PropTypes.bool,side:PropTypes.string}),layers:PropTypes.array,map:PropTypes.object,setCurrentTask:PropTypes.func});_defineProperty(ValueTool,"defaultProps",{geometry:{initialWidth:240,initialHeight:320,initialX:0,initialY:0,initiallyDocked:false,side:"left"}});_defineProperty(ValueTool,"defaultState",{activeTab:"Table",showLayers:"visible",showBands:"all",selectedLayers:[],selectedBands:{},values:{}});export default connect(function(state){return{enabled:state.task.id==="ValueTool",layers:state.layers.flat.filter(function(layer){return(layer.role===LayerRole.THEME||layer.role===LayerRole.USERLAYER)&&(layer.infoFormats||[]).includes("text/xml")}),map:state.map}},{setCurrentTask:setCurrentTask})(ValueTool);
|
|
@@ -0,0 +1,34 @@
|
|
|
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)}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}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}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2024 Sourcepole AG
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/import React from"react";import{connect,Provider}from"react-redux";import PropTypes from"prop-types";import{createSelector}from"reselect";import*as displayExports from"../actions/display";import{setView3dMode,View3DMode}from"../actions/display";import{setCurrentTask}from"../actions/task";import*as themeExports from"../actions/theme";import PluginsContainer from"../components/PluginsContainer";import ResizeableWindow from"../components/ResizeableWindow";import StandardApp from"../components/StandardApp";import View3DSwitcher from"../components/map3d/View3DSwitcher";import map3dReducer from"../components/map3d/slices/map3d";import ReducerIndex from"../reducers/index";import searchProvidersSelector from"../selectors/searchproviders";import{createStore}from"../stores/StandardStore";import LocaleUtils from"../utils/LocaleUtils";import{UrlParams}from"../utils/PermaLinkUtils";/**
|
|
8
|
+
* Displays a 3D map view.
|
|
9
|
+
*
|
|
10
|
+
* To add a 3D View to a theme, add the following configuration block to a theme item in `themesConfig.json`:
|
|
11
|
+
* ```
|
|
12
|
+
* "map3d": {
|
|
13
|
+
* "dtm": {"url": "<url_to_dtm.tif>", "crs": "<dtm_epsg_code>},
|
|
14
|
+
* "basemaps": [
|
|
15
|
+
* {"name": "<name_of_background_layer>", "visibility": true},
|
|
16
|
+
* {"name": "<name_of_background_layer>"},
|
|
17
|
+
* ...
|
|
18
|
+
* ],
|
|
19
|
+
* "tiles3d": [
|
|
20
|
+
* {"name": "<name>", "url": "<url_to_tileset.json>", "title": "<title>", "colorAttr": "<tile_batch_attr>"}
|
|
21
|
+
* ]
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
* Where:
|
|
25
|
+
*
|
|
26
|
+
* - The DTM should be a cloud optimized GeoTIFF.
|
|
27
|
+
* - The background layer names refer to the names of the entries defined in `backgroundLayers` in the `themesConfig.json`.
|
|
28
|
+
* - The optional `colorAttr` is the name of an attribute stored in the tileset batch table which stores the batch color, as a 0xRRGGBB integer.
|
|
29
|
+
*/var View3D=/*#__PURE__*/function(_React$Component){function View3D(props){var _this;_classCallCheck(this,View3D);_this=_callSuper(this,View3D,[props]);_defineProperty(_this,"state",{componentLoaded:false,windowDetached:false});_defineProperty(_this,"render3DWindow",function(){if(_this.props.display.view3dMode>View3DMode.DISABLED){var extraControls=[{icon:"sync",callback:_this.setViewToExtent,title:LocaleUtils.tr("map3d.syncview")}];if(!_this.state.windowDetached){extraControls.push({icon:"maximize",callback:function callback(){return _this.props.setView3dMode(View3DMode.FULLSCREEN)},title:LocaleUtils.tr("window.maximize")})}var Map3D=_this.map3dComponent;return/*#__PURE__*/React.createElement(ResizeableWindow,{extraControls:extraControls,fullscreen:_this.props.display.view3dMode===View3DMode.FULLSCREEN,icon:"map3d",initialHeight:_this.props.geometry.initialHeight,initialWidth:_this.props.geometry.initialWidth,initialX:_this.props.geometry.initialX,initialY:_this.props.geometry.initialY,initiallyDocked:_this.props.geometry.initiallyDocked,key:"View3DWindow",maximizeable:false,onClose:_this.onClose,onExternalWindowResized:_this.redrawScene,onGeometryChanged:_this.onGeometryChanged,splitScreenWhenDocked:true,splitTopAndBottomBar:true,title:LocaleUtils.tr("map3d.title")},_this.state.componentLoaded?/*#__PURE__*/React.createElement(Provider,{role:"body",store:_this.store},/*#__PURE__*/React.createElement(Map3D,{innerRef:_this.setRef,onMapInitialized:_this.setupMap,options:_this.props.options,searchProviders:_this.props.searchProviders,theme:_this.props.theme}),_this.props.view3dMode===View3DMode.FULLSCREEN?/*#__PURE__*/React.createElement(PluginsContainer,{plugins:_this.props.plugins,pluginsAppConfig:{},pluginsConfig:_this.props.pluginsConfig}):null):null)}return null});_defineProperty(_this,"onClose",function(){_this.props.setView3dMode(View3DMode.DISABLED);UrlParams.updateParams({v3d:undefined})});_defineProperty(_this,"onGeometryChanged",function(geometry){if(geometry.maximized&&_this.props.display.view3dMode!==View3DMode.FULLSCREEN){_this.props.setView3dMode(View3DMode.FULLSCREEN)}_this.setState({windowDetached:geometry.detached})});_defineProperty(_this,"setRef",function(ref){_this.map3dComponentRef=ref});_defineProperty(_this,"setViewToExtent",function(){if(_this.map3dComponentRef){_this.map3dComponentRef.setViewToExtent(_this.props.mapBBox.bounds,_this.props.mapBBox.rotation)}});_defineProperty(_this,"setupMap",function(){if(_this.map3dComponentRef&&_this.restoreOnComponentLoad){_this.restoreOnComponentLoad=false;var state3d=_objectSpread({},_this.props.startupState.map3d);if(_this.props.startupParams.v3d){var values=_this.props.startupParams.v3d.split(",").map(parseFloat).filter(function(x){return!isNaN(x)});if(values.length===6){state3d.center=[values[0],values[1],values[2]];state3d.cameraPos=[values[3],values[4],values[5]]}}_this.map3dComponentRef.restore3dState(state3d);if(!_this.props.startupParams.v3d){_this.setViewToExtent()}}else{_this.setViewToExtent()}});_defineProperty(_this,"redrawScene",function(ev){if(_this.map3dComponentRef){_this.map3dComponentRef.redrawScene(ev)}});_this.map3dComponent=null;_this.map3dComponentRef=null;// Subset of 2d reducers
|
|
30
|
+
var _ReducerIndex$reducer=ReducerIndex.reducers,task=_ReducerIndex$reducer.task,windows=_ReducerIndex$reducer.windows;// Reducer for syncronization with parent store
|
|
31
|
+
var forwardReducer=function forwardReducer(key,forwardActions,syncAction){return function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments.length>1?arguments[1]:undefined;if(forwardActions.includes(action.type)){// Forward to parent store
|
|
32
|
+
StandardApp.store.dispatch(action);return state}else{return action.type===syncAction?action[key]:state}}};var displayActions=Object.values(displayExports).filter(function(x){return typeof x==="string"});var themeActions=Object.values(themeExports).filter(function(x){return typeof x==="string"});var display=forwardReducer("display",displayActions,"SYNC_DISPLAY_FROM_PARENT_STORE");var layers=forwardReducer("layers",[],"SYNC_LAYERS_FROM_PARENT_STORE");var localConfig=forwardReducer("localConfig",[],"SYNC_LOCAL_CONFIG_FROM_PARENT_STORE");var theme=forwardReducer("theme",themeActions,"SYNC_THEME_FROM_PARENT_STORE");_this.store=createStore({display:display,layers:layers,localConfig:localConfig,map:map3dReducer,theme:theme,task:task,windows:windows});return _this}_inherits(View3D,_React$Component);return _createClass(View3D,[{key:"componentDidMount",value:function componentDidMount(){if(this.props.startupParams.v==="3d"){this.props.setView3dMode(View3DMode.FULLSCREEN);this.restoreOnComponentLoad=true}else if(this.props.startupParams.v==="3d2d"){this.props.setView3dMode(View3DMode.SPLITSCREEN);this.restoreOnComponentLoad=true}}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){var _this2=this,_this$props$theme$cur;if(this.props.enabled&&!prevProps.enabled){this.setState({mode:View3DMode.FULLSCREEN});this.props.setCurrentTask(null)}else if(this.props.display.view3dMode!==View3DMode.DISABLED&&prevProps.display.view3dMode===View3DMode.DISABLED){import("../components/map3d/Map3D").then(function(component){_this2.map3dComponent=component["default"];_this2.map3dComponentRef=null;_this2.setState({componentLoaded:true})})}else if(this.props.display.view3dMode===View3DMode.DISABLED&&prevProps.display.view3dMode!==View3DMode.DISABLED){this.map3dComponent=null;this.map3dComponentRef=null;this.setState({componentLoaded:false})}// Sync parts of parent store
|
|
33
|
+
if(this.props.display!==prevProps.display){this.store.dispatch({type:"SYNC_DISPLAY_FROM_PARENT_STORE",display:this.props.display})}if(this.props.theme!==prevProps.theme){this.store.dispatch({type:"SYNC_THEME_FROM_PARENT_STORE",theme:this.props.theme})}if(this.props.localConfig!==prevProps.localConfig){this.store.dispatch({type:"SYNC_LOCAL_CONFIG_FROM_PARENT_STORE",localConfig:this.props.localConfig})}if(this.props.layers!==prevProps.layers){this.store.dispatch({type:"SYNC_LAYERS_FROM_PARENT_STORE",layers:this.props.layers})}if(this.props.view3dMode!==prevProps.view3dMode){if(this.props.view3dMode===View3DMode.FULLSCREEN){UrlParams.updateParams({v:"3d"})}else if(this.props.view3dMode===View3DMode.SPLITSCREEN){UrlParams.updateParams({v:"3d2d"})}else{UrlParams.updateParams({v:undefined})}}// Switch to 2D mode if new theme has no 3D configuration
|
|
34
|
+
if(this.props.theme.current!==prevProps.theme.current&&!((_this$props$theme$cur=this.props.theme.current)!==null&&_this$props$theme$cur!==void 0&&_this$props$theme$cur.map3d)&&this.props.view3dMode!==View3DMode.DISABLED){this.props.setView3dMode(View3D.DISABLED)}}},{key:"render",value:function render(){var _this$props$theme$cur2;var button=(_this$props$theme$cur2=this.props.theme.current)!==null&&_this$props$theme$cur2!==void 0&&_this$props$theme$cur2.map3d?/*#__PURE__*/React.createElement(View3DSwitcher,{key:"View3DButton",position:this.props.buttonPosition}):null;return[button,this.render3DWindow()]}}])}(React.Component);_defineProperty(View3D,"propTypes",{/** The position slot index of the 3d switch map button, from the bottom (0: bottom slot). */buttonPosition:PropTypes.number,display:PropTypes.object,enabled:PropTypes.bool,/** Default window geometry. */geometry:PropTypes.shape({initialWidth:PropTypes.number,initialHeight:PropTypes.number,initialX:PropTypes.number,initialY:PropTypes.number,initiallyDocked:PropTypes.bool}),layers:PropTypes.object,localConfig:PropTypes.object,mapBBox:PropTypes.object,/** Various configuration options */options:PropTypes.shape({/** Minimum scale denominator when zooming to search result. */searchMinScaleDenom:PropTypes.number}),plugins:PropTypes.object,pluginsConfig:PropTypes.object,projection:PropTypes.string,searchProviders:PropTypes.object,setCurrentTask:PropTypes.func,setView3dMode:PropTypes.func,startupParams:PropTypes.object,startupState:PropTypes.object,theme:PropTypes.object,view3dMode:PropTypes.number});_defineProperty(View3D,"defaultProps",{buttonPosition:6,geometry:{initialWidth:600,initialHeight:800,initialX:0,initialY:0,initiallyDocked:true},options:{searchMinScaleDenom:1000}});export default connect(createSelector([function(state){return state},searchProvidersSelector],function(state,searchProviders){return{enabled:state.task.id==="View3D",display:state.display,mapBBox:state.map.bbox,projection:state.map.projection,layers:state.layers,pluginsConfig:state.localConfig.plugins,theme:state.theme,localConfig:state.localConfig,view3dMode:state.display.view3dMode,startupParams:state.localConfig.startupParams,startupState:state.localConfig.startupState,searchProviders:searchProviders}}),{setCurrentTask:setCurrentTask,setView3dMode:setView3dMode})(View3D);
|
|
@@ -0,0 +1,11 @@
|
|
|
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)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2016-2024 Sourcepole AG
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/import React from"react";import{connect}from"react-redux";import classnames from"classnames";import PropTypes from"prop-types";import{changeZoomLevel,zoomToExtent,zoomToPoint}from"../actions/map";import{setCurrentTask}from"../actions/task";import Icon from"../components/Icon";import MapSelection from"../components/MapSelection";import LocaleUtils from"../utils/LocaleUtils";import ThemeUtils from"../utils/ThemeUtils";import"./style/Buttons.css";/**
|
|
8
|
+
* Map button for zooming the map.
|
|
9
|
+
*
|
|
10
|
+
* Two specific plugins exist: ZoomInPlugin and ZoomOutPlugin, which are instances of ZoomButton for the respective zoom directions.
|
|
11
|
+
*/var ZoomButton=/*#__PURE__*/function(_React$Component){function ZoomButton(props){var _this;_classCallCheck(this,ZoomButton);_this=_callSuper(this,ZoomButton,[props]);_defineProperty(_this,"state",{disabled:false});_defineProperty(_this,"buttonClicked",function(){if(_this.props.enableZoomByBoxSelection){_this.props.setCurrentTask(_this.props.currentTask===_this.task?null:_this.task)}else if(!_this.state.disabled){_this.props.changeZoomLevel(_this.props.currentZoom+_this.props.direction)}});_defineProperty(_this,"updateZoom",function(geom){var zoomBox=geom.coordinates[0];if(_this.props.direction>0){_this.props.zoomToExtent(zoomBox,_this.props.mapCrs)}else{var center=[0.5*(zoomBox[0]+zoomBox[2]),0.5*(zoomBox[1]+zoomBox[3])];var zoom=Math.max(0,_this.props.currentZoom+_this.props.direction);_this.props.zoomToPoint(center,zoom,_this.props.mapCrs)}});_this.task=props.direction>0?"ZoomIn":"ZoomOut";return _this}_inherits(ZoomButton,_React$Component);return _createClass(ZoomButton,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(prevProps.currentZoom!==this.props.currentZoom||prevProps.maxZoom!==this.props.maxZoom){if(this.props.direction>0){this.setState({disabled:this.props.currentZoom>=this.props.maxZoom})}else if(this.props.direction<0){this.setState({disabled:this.props.currentZoom<=0})}}if(this.props.currentTask===this.task&&this.props.click!==prevProps.click){var _this$props$click;var point=(_this$props$click=this.props.click)===null||_this$props$click===void 0?void 0:_this$props$click.coordinate;if(point){var zoom=Math.max(0,this.props.currentZoom+this.props.direction);this.props.zoomToPoint(point,zoom,this.mapCrs)}}}},{key:"render",value:function render(){var _this2=this;if(!ThemeUtils.themeFlagsAllowed(this.props.theme,this.props.themeFlagWhitelist,this.props.themeFlagBlacklist)){return null}var defaultPosition=this.props.direction>0?4:3;var position=this.props.position>=0?this.props.position:defaultPosition;var right=this.props.mapMargins.right;var bottom=this.props.mapMargins.bottom;var style={right:"calc(1.5em + "+right+"px)",bottom:"calc(var(--bottombar-height) + "+bottom+"px + "+(3+4*position)+"em)"};var tooltip=this.props.direction>0?LocaleUtils.tr("tooltip.zoomin"):LocaleUtils.tr("tooltip.zoomout");var classes=classnames({"map-button":true,"map-button-active":this.props.enableZoomByBoxSelection&&this.props.currentTask===this.task,"map-button-disabled":this.state.disabled});return[/*#__PURE__*/React.createElement("button",{className:classes,key:this.task+"Button",onClick:this.buttonClicked,style:style,title:tooltip},/*#__PURE__*/React.createElement(Icon,{icon:this.props.direction>0?"plus":"minus",title:tooltip})),this.props.currentTask===this.task?/*#__PURE__*/React.createElement(MapSelection,{active:true,cursor:this.props.direction>0?"zoom-in":"zoom-out",geomType:"DragBox",geometryChanged:function geometryChanged(geom){return _this2.updateZoom(geom)},key:"MapSelection"}):null]}}])}(React.Component);_defineProperty(ZoomButton,"propTypes",{changeZoomLevel:PropTypes.func,click:PropTypes.object,currentTask:PropTypes.string,currentZoom:PropTypes.number,direction:PropTypes.number,/** Enable zoom in or out by box selection. */enableZoomByBoxSelection:PropTypes.bool,mapCrs:PropTypes.string,mapMargins:PropTypes.object,maxZoom:PropTypes.number,/** The position slot index of the map button, from the bottom (0: bottom slot). */position:PropTypes.number,setCurrentTask:PropTypes.func,theme:PropTypes.object,/** Omit the button in themes matching one of these flags. */themeFlagBlacklist:PropTypes.arrayOf(PropTypes.string),/** Only show the button in themes matching one of these flags. */themeFlagWhitelist:PropTypes.arrayOf(PropTypes.string),zoomToExtent:PropTypes.func,zoomToPoint:PropTypes.func});export var ZoomInPlugin=connect(function(state){return{click:state.map.click,currentTask:state.task.id,currentZoom:state.map.zoom,maxZoom:state.map.resolutions.length-1,direction:+1,mapCrs:state.map.projection,mapMargins:state.windows.mapMargins,theme:state.theme.current}},{changeZoomLevel:changeZoomLevel,setCurrentTask:setCurrentTask,zoomToExtent:zoomToExtent,zoomToPoint:zoomToPoint})(ZoomButton);export var ZoomOutPlugin=connect(function(state){return{click:state.map.click||{},currentTask:state.task.id,currentZoom:state.map.zoom,maxZoom:state.map.resolutions.length-1,direction:-1,mapCrs:state.map.projection,mapMargins:state.windows.mapMargins,theme:state.theme.current}},{changeZoomLevel:changeZoomLevel,setCurrentTask:setCurrentTask,zoomToExtent:zoomToExtent,zoomToPoint:zoomToPoint})(ZoomButton);
|
|
@@ -0,0 +1,13 @@
|
|
|
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)}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}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.")}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}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}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}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}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}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2017-2024 Sourcepole AG
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/import React from"react";import{connect}from"react-redux";import ol from"openlayers";import PropTypes from"prop-types";import{setEditContext}from"../../actions/editing";import FeatureStyles from"../../utils/FeatureStyles";/**
|
|
8
|
+
* Editing support for the map component.
|
|
9
|
+
*/var EditingSupport=/*#__PURE__*/function(_React$Component){function EditingSupport(props){var _this;_classCallCheck(this,EditingSupport);_this=_callSuper(this,EditingSupport,[props]);_defineProperty(_this,"editStyle",function(){var geometryFunction=function geometryFunction(feature){if(feature.getGeometry().getType()==="Point"){return new ol.geom.MultiPoint([feature.getGeometry().getCoordinates()])}else if(feature.getGeometry().getType()==="LineString"){return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates())}else if(feature.getGeometry().getType()==="Polygon"){return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates()[0])}else if(feature.getGeometry().getType()==="MultiPoint"){return feature.getGeometry()}else if(feature.getGeometry().getType()==="MultiLineString"){return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates()[0])}else if(feature.getGeometry().getType()==="MultiPolygon"){return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates()[0][0])}return feature.getGeometry()};return[FeatureStyles.interaction(_this.props.editContext.geometryStyle),FeatureStyles.interactionVertex(_objectSpread({geometryFunction:geometryFunction},_this.props.editContext.vertexStyle))]});_defineProperty(_this,"createLayer",function(){var source=new ol.source.Vector;_this.layer=new ol.layer.Vector({source:source,zIndex:1000000,style:_this.editStyle()});_this.props.map.addLayer(_this.layer)});_defineProperty(_this,"addDrawInteraction",function(){_this.reset();_this.createLayer();var drawInteraction=new ol.interaction.Draw({stopClick:true,type:_this.props.editContext.geomType.replace(/Z$/,""),source:_this.layer.getSource(),condition:function condition(event){return event.originalEvent.buttons===1},style:_this.editStyle()});drawInteraction.on("drawstart",function(evt){_this.currentFeature=evt.feature},_this);drawInteraction.on("drawend",function(){_this.commitCurrentFeature();_this.props.map.removeInteraction(drawInteraction)},_this);_this.props.map.addInteraction(drawInteraction);_this.interaction=drawInteraction});_defineProperty(_this,"addEditInteraction",function(){_this.reset();_this.createLayer();var format=new ol.format.GeoJSON;_this.currentFeature=format.readFeature(_this.props.editContext.feature);_this.layer.getSource().addFeature(_this.currentFeature);var modifyInteraction=new ol.interaction.Modify({features:new ol.Collection([_this.currentFeature]),condition:function condition(event){return event.originalEvent.buttons===1},deleteCondition:function deleteCondition(event){// delete vertices on SHIFT + click
|
|
10
|
+
if(event.type==="pointerdown"&&ol.events.condition.shiftKeyOnly(event)){_this.props.map.setIgnoreNextClick(true)}return ol.events.condition.shiftKeyOnly(event)&&ol.events.condition.singleClick(event)},style:FeatureStyles.sketchInteraction()});modifyInteraction.on("modifyend",function(){_this.commitCurrentFeature()},_this);modifyInteraction.setActive(!_this.props.editContext.geomReadOnly&&_this.props.editContext.geomType);_this.props.map.addInteraction(modifyInteraction);_this.interaction=modifyInteraction});_defineProperty(_this,"commitCurrentFeature",function(){if(!_this.currentFeature){return}var format=new ol.format.GeoJSON;var feature=format.writeFeatureObject(_this.currentFeature);if(_this.props.editContext.feature){feature=_objectSpread(_objectSpread({},_this.props.editContext.feature),{},{geometry:feature.geometry})}var _addZCoordinateIfNeeded=function addZCoordinateIfNeeded(entry){return Array.isArray(entry[0])?entry.map(_addZCoordinateIfNeeded):[].concat(_toConsumableArray(entry.slice(0,2)),[0])};if(_this.props.editContext.geomType.endsWith("Z")){feature.geometry.coordinates=_addZCoordinateIfNeeded(feature.geometry.coordinates)}_this.props.setEditContext(_this.props.editContext.id,{feature:feature,changed:true})});_defineProperty(_this,"reset",function(){if(_this.interaction){_this.props.map.removeInteraction(_this.interaction)}_this.interaction=null;_this.currentFeature=null;if(_this.layer){_this.props.map.removeLayer(_this.layer)}_this.layer=null});_this.interaction=null;_this.layer=null;_this.currentFeature=null;return _this}_inherits(EditingSupport,_React$Component);return _createClass(EditingSupport,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(this.props.editContext===prevProps.editContext){// pass
|
|
11
|
+
}else if(this.props.editContext.action==="Pick"&&this.props.editContext.feature){// If a feature without geometry was picked, enter draw mode, otherwise enter edit mode
|
|
12
|
+
if(!this.props.editContext.feature.geometry&&this.props.editContext.geomType){this.addDrawInteraction()}else{this.addEditInteraction()}}else if(this.props.editContext.action==="Draw"&&this.props.editContext.geomType){// Usually, draw mode starts without a feature, but draw also can start with a pre-set geometry
|
|
13
|
+
if(!(this.props.editContext.feature||{}).geometry||prevProps.editContext.geomType!==this.props.editContext.geomType){this.addDrawInteraction()}else if((this.props.editContext.feature||{}).geometry){this.addEditInteraction()}}else{this.reset()}}},{key:"render",value:function render(){return null}}])}(React.Component);_defineProperty(EditingSupport,"propTypes",{editContext:PropTypes.object,map:PropTypes.object,setEditContext:PropTypes.func});export default connect(function(state){return{editContext:state.editing.contexts[state.editing.currentContext]||{}}},{setEditContext:setEditContext})(EditingSupport);
|
|
@@ -0,0 +1,14 @@
|
|
|
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)}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}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}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2015 GeoSolutions Sas
|
|
3
|
+
* Copyright 2016-2024 Sourcepole AG
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the BSD-style license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
*/import React from"react";import{connect}from"react-redux";import PropTypes from"prop-types";import{changeLocateState,changeLocatePosition,onLocateError}from"../../actions/locate";import OlLocate from"../../components/map/OlLocate";/**
|
|
10
|
+
* GPS locate support for the map component.
|
|
11
|
+
*/var LocateSupport=/*#__PURE__*/function(_React$Component){function LocateSupport(){var _this;_classCallCheck(this,LocateSupport);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}_this=_callSuper(this,LocateSupport,[].concat(args));_defineProperty(_this,"configureLocate",function(newState){var state=_this.locate.get("state");if(newState==="ENABLED"&&state==="DISABLED"){_this.locate.start()}else if(newState==="FOLLOWING"&&state==="ENABLED"){_this.locate.startFollow()}else if(newState==="FOLLOWING"&&state==="DISABLED"){_this.locate.start();_this.locate.startFollow()}else if(newState==="DISABLED"){_this.locate.stop()}});_defineProperty(_this,"onPropChange",function(key,value){if(key==="state"&&_this.props.locateState.state!==value){_this.props.changeLocateState(value)}else if(key==="position"&&_this.props.locateState.position!==value){_this.props.changeLocatePosition(value)}});_defineProperty(_this,"onLocationError",function(err){_this.props.onLocateError(err.message);// User denied geolocation prompt
|
|
12
|
+
if(err.code===1){_this.props.changeLocateState("PERMISSION_DENIED")}else{_this.props.changeLocateState("DISABLED")}});return _this}_inherits(LocateSupport,_React$Component);return _createClass(LocateSupport,[{key:"componentDidMount",value:function componentDidMount(){var _this2=this;var options=_objectSpread(_objectSpread({},LocateSupport.defaultOpt),this.props.options);this.locate=new OlLocate(this.props.map,options);this.locate.options.onLocationError=this.onLocationError;this.locate.on("propertychange",function(e){_this2.onPropChange(e.key,e.target.get(e.key))});this.configureLocate(this.props.locateState.state);var startupMode=options.startupMode.toUpperCase();var startupParams=this.props.startupParams;var highlightCenter=["true","1"].includes((startupParams.hc||"").toLowerCase());var searchParams=startupParams.hp||startupParams.hf||startupParams.st;if(startupMode!=="DISABLED"&&!searchParams&&!highlightCenter){this.props.changeLocateState(startupMode)}}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(this.props.locateState.state!==prevProps.locateState.state){this.configureLocate(this.props.locateState.state)}if(this.props.projection!==prevProps.projection){this.locate.setProjection(this.props.projection)}}},{key:"render",value:function render(){return null}}])}(React.Component);_defineProperty(LocateSupport,"propTypes",{changeLocatePosition:PropTypes.func,changeLocateState:PropTypes.func,locateState:PropTypes.object,map:PropTypes.object,onLocateError:PropTypes.func,options:PropTypes.object,projection:PropTypes.string,startupParams:PropTypes.object});_defineProperty(LocateSupport,"defaultProps",{options:{}});_defineProperty(LocateSupport,"defaultOpt",{startupMode:"DISABLED",// either "DISABLED", "ENABLED" or "FOLLOWING"
|
|
13
|
+
follow:false,// follow with zoom and pan the user's location
|
|
14
|
+
remainActive:true,metric:true,stopFollowingOnDrag:false,keepCurrentZoomLevel:true,locateOptions:{maximumAge:2000,enableHighAccuracy:true,timeout:10000,maxZoom:18}});export default connect(function(state){return{locateState:state.locate,startupParams:state.localConfig.startupParams}},{changeLocateState:changeLocateState,changeLocatePosition:changeLocatePosition,onLocateError:onLocateError})(LocateSupport);
|
|
@@ -0,0 +1,15 @@
|
|
|
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)}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}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.")}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}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}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}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}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}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2016 GeoSolutions Sas
|
|
3
|
+
* Copyright 2016-2024 Sourcepole AG
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the BSD-style license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/import React from"react";import{connect}from"react-redux";import ol from"openlayers";import PropTypes from"prop-types";import{changeMeasurementState}from"../../actions/measurement";import FeatureStyles from"../../utils/FeatureStyles";import MeasureUtils from"../../utils/MeasureUtils";/**
|
|
9
|
+
* Measurement support for the map component.
|
|
10
|
+
*/var MeasurementSupport=/*#__PURE__*/function(_React$Component){function MeasurementSupport(props){var _this;_classCallCheck(this,MeasurementSupport);_this=_callSuper(this,MeasurementSupport,[props]);_defineProperty(_this,"addDrawInteraction",function(newProps){_this.reset();// Create a layer to draw on
|
|
11
|
+
_this.measureLayer=new ol.layer.Vector({source:new ol.source.Vector,zIndex:1000000});_this.props.map.addLayer(_this.measureLayer);var geometryType=newProps.measurement.geomType;if(geometryType==="Bearing"){geometryType="LineString"}// create an interaction to draw with
|
|
12
|
+
_this.drawInteraction=new ol.interaction.Draw({stopClick:true,source:_this.measureLayer.getSource(),condition:function condition(event){return event.originalEvent.buttons===1},type:geometryType,style:function style(){return _this.modifyInteraction?[]:FeatureStyles.sketchInteraction()}});_this.drawInteraction.on("drawstart",function(ev){_this.leaveTemporaryPickMode();_this.measureLayer.getSource().clear();_this.sketchFeature=ev.feature;_this.sketchFeature.setStyle(_this.featureStyleFunction);_this.sketchFeature.on("change",function(evt){return _this.updateMeasurementResults(evt.target)})});_this.drawInteraction.on("drawend",function(){_this.updateMeasurementResults(_this.sketchFeature,false);_this.enterTemporaryPickMode()});_this.props.map.addInteraction(_this.drawInteraction)});_defineProperty(_this,"reset",function(){if(_this.drawInteraction!==null){_this.props.map.removeInteraction(_this.drawInteraction);_this.drawInteraction=null;_this.leaveTemporaryPickMode();_this.props.map.removeLayer(_this.measureLayer);_this.measureLayer=null;_this.sketchFeature=null}});_defineProperty(_this,"enterTemporaryPickMode",function(){_this.modifyInteraction=new ol.interaction.Modify({features:new ol.Collection([_this.sketchFeature]),condition:function condition(event){return event.originalEvent.buttons===1},insertVertexCondition:function insertVertexCondition(){return _this.props.measurement.geomType==="Bearing"?false:true},deleteCondition:function deleteCondition(event){return ol.events.condition.shiftKeyOnly(event)&&ol.events.condition.singleClick(event)},style:function style(feature){// Hack to get cursor position over geometry...
|
|
13
|
+
if(_this.props.measurement.pickPositionCallback){clearTimeout(_this.pickPositionCallbackTimeout);_this.props.measurement.pickPositionCallback(feature.getGeometry().getCoordinates())}return FeatureStyles.sketchInteraction()}});_this.props.map.on("pointermove",_this.clearPickPosition);_this.modifyInteraction.on("modifyend",function(){_this.updateMeasurementResults(_this.sketchFeature,false)});_this.props.map.addInteraction(_this.modifyInteraction)});_defineProperty(_this,"leaveTemporaryPickMode",function(){if(_this.modifyInteraction){_this.props.map.un("pointermove",_this.clearPickPosition);_this.props.map.removeInteraction(_this.modifyInteraction);_this.modifyInteraction=null}});_defineProperty(_this,"clearPickPosition",function(){if(_this.props.measurement.pickPositionCallback){clearTimeout(_this.pickPositionCallbackTimeout);// Works because style function clears timeout if marker is rendered, i.e. if mouse is over measure geometry
|
|
14
|
+
_this.pickPositionCallbackTimeout=setTimeout(function(){if(_this.props.measurement.pickPositionCallback){_this.props.measurement.pickPositionCallback(null)}},50)}});_defineProperty(_this,"updateMeasurementResults",function(feature){var drawing=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var geomType=_this.props.measurement.geomType;var settings={lenUnit:_this.props.measurement.lenUnit,areaUnit:_this.props.measurement.areaUnit,displayCrs:_this.props.map.displayCrs};MeasureUtils.updateFeatureMeasurements(feature,geomType,_this.props.projection,settings);// Only one segment for bearing measurement
|
|
15
|
+
if(geomType==="Bearing"&&feature.getGeometry().getCoordinates().length>2){_this.drawInteraction.finishDrawing()}_this.measureLayer.getSource().changed();_this.props.changeMeasurementState(_objectSpread({geomType:_this.props.measurement.geomType,drawing:drawing,coordinates:feature.getGeometry().getCoordinates()},feature.get("measurements")))});_defineProperty(_this,"featureStyleFunction",function(feature){var geometryFunction=function geometryFunction(f){if(f.getGeometry().getType()==="Point"){return new ol.geom.MultiPoint([f.getGeometry().getCoordinates()])}else if(f.getGeometry().getType()==="LineString"){return new ol.geom.MultiPoint(f.getGeometry().getCoordinates())}return new ol.geom.MultiPoint(f.getGeometry().getCoordinates()[0])};return[].concat(_toConsumableArray(FeatureStyles.measureInteraction(feature)),[FeatureStyles.measureInteractionVertex({geometryFunction:geometryFunction})])});_this.pickPositionCallbackTimeout=null;_this.measureLayer=null;return _this}_inherits(MeasurementSupport,_React$Component);return _createClass(MeasurementSupport,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(this.props.measurement.geomType&&this.props.measurement.geomType!==prevProps.measurement.geomType){this.addDrawInteraction(this.props)}else if(!this.props.measurement.geomType){this.reset()}else if(this.sketchFeature&&(this.props.measurement.lenUnit!==prevProps.measurement.lenUnit||this.props.measurement.areaUnit!==prevProps.measurement.areaUnit||this.props.displayCrs!==prevProps.displayCrs)){this.updateMeasurementResults(this.sketchFeature,this.props.measurement.drawing)}}},{key:"render",value:function render(){return null}}])}(React.Component);_defineProperty(MeasurementSupport,"propTypes",{changeMeasurementState:PropTypes.func,displayCrs:PropTypes.string,map:PropTypes.object,measurement:PropTypes.object,projection:PropTypes.string});export default connect(function(state){return{displayCrs:state.map.displayCrs,measurement:state.measurement}},{changeMeasurementState:changeMeasurementState})(MeasurementSupport);
|
|
@@ -0,0 +1,14 @@
|
|
|
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)}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}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}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2015 GeoSolutions Sas
|
|
3
|
+
* Copyright 2016-2024 Sourcepole AG
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the BSD-style license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/import React from"react";import{connect}from"react-redux";import ol from"openlayers";import PropTypes from"prop-types";import{v1 as uuidv1}from"uuid";import{LayerRole}from"../../actions/layers";import OlLayer from"../../components/map/OlLayer";import"./style/OverviewSupport.css";/**
|
|
9
|
+
* Overview map support for the map component.
|
|
10
|
+
*/var OverviewMap=/*#__PURE__*/function(_React$Component){function OverviewMap(props){var _this;_classCallCheck(this,OverviewMap);_this=_callSuper(this,OverviewMap,[props]);_defineProperty(_this,"state",{overviewView:null,overviewLayer:null});_defineProperty(_this,"initOverviewMap",function(el){if(el){var opt=_objectSpread({className:"overview-map",collapseLabel:"\xBB",label:"\xAB",collapsed:true,collapsible:true},_this.props.options);delete opt.layer;delete opt.viewOptions;_this.overview=new ol.control.OverviewMap(opt);_this.overview.setTarget(el);_this.props.map.addControl(_this.overview);_this.setupView()}});_defineProperty(_this,"setupView",function(){var overviewView=new ol.View(_objectSpread({projection:_this.props.projection},_this.props.options.viewOptions||{}));_this.overview.getOverviewMap().setView(overviewView);overviewView.setZoom(_this.props.zoom*0.8);overviewView.setCenter(_this.props.center);_this.setState({overviewView:overviewView,overviewLayer:null})});_defineProperty(_this,"componentWillUnmount",function(){if(_this.overview){_this.props.map.removeControl(_this.overview)}});_this.overview=null;return _this}_inherits(OverviewMap,_React$Component);return _createClass(OverviewMap,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){if(this.props.theme!==prevProps.theme){this.setupView()}else if(this.state.overviewView!==prevState.overviewView){var _find,_this$props$theme;var overviewLayerName=(_find=(((_this$props$theme=this.props.theme)===null||_this$props$theme===void 0?void 0:_this$props$theme.backgroundLayers)||[]).find(function(entry){return entry.overview}))===null||_find===void 0?void 0:_find.name;var overviewLayer=null;if(this.props.options.layer){overviewLayer=_objectSpread(_objectSpread({},this.props.options.layer),{},{visibility:true,id:uuidv1()});if(overviewLayer.type==="wms"){var _this$props$themes;overviewLayer.version=overviewLayer.params.VERSION||overviewLayer.version||((_this$props$themes=this.props.themes)===null||_this$props$themes===void 0?void 0:_this$props$themes.defaultWMSVersion)||"1.3.0"}}else if(overviewLayerName){overviewLayer=this.props.layers.find(function(l){return l.role===LayerRole.BACKGROUND&&l.name===overviewLayerName});if(overviewLayer){overviewLayer=_objectSpread(_objectSpread({},overviewLayer),{},{visibility:true})}}else{overviewLayer=this.props.backgroundLayer}this.setState({overviewLayer:overviewLayer})}else if(this.props.backgroundLayer!==prevProps.backgroundLayer&&!this.props.options.layer){this.setState({overviewLayer:this.props.backgroundLayer})}}},{key:"render",value:function render(){return[/*#__PURE__*/React.createElement("div",{key:"OverviewMap",ref:this.initOverviewMap}),this.state.overviewLayer?/*#__PURE__*/React.createElement(OlLayer,{key:this.state.overviewLayer.id,map:this.overview.getOverviewMap(),options:this.state.overviewLayer,projection:this.props.projection}):null]}}])}(React.Component);_defineProperty(OverviewMap,"propTypes",{backgroundLayer:PropTypes.object,center:PropTypes.array,layers:PropTypes.array,map:PropTypes.object,/** See [OpenLayers API doc](https://openlayers.org/en/latest/apidoc/module-ol_control_OverviewMap-OverviewMap.html) for general options.
|
|
11
|
+
* Additionally, you can specify:
|
|
12
|
+
* - `layer`: Custom overview layer, in the same form as background layer definitions (`{type: "<wms|wmts>", "url": ...}`).
|
|
13
|
+
* - `viewOptions`: Options for the OverviewMap View, see [OpenLayers API doc](https://openlayers.org/en/latest/apidoc/module-ol_View.html).
|
|
14
|
+
*/options:PropTypes.object,projection:PropTypes.string,theme:PropTypes.object,themes:PropTypes.object,zoom:PropTypes.number});_defineProperty(OverviewMap,"defaultProps",{options:{}});export default connect(function(state){return{theme:state.theme.current,themes:state.theme.themes,layers:state.layers.flat,backgroundLayer:state.layers.flat.find(function(l){return l.role===LayerRole.BACKGROUND&&l.visibility}),projection:state.map.projection,center:state.map.center,zoom:state.map.zoom}},{})(OverviewMap);
|
|
@@ -0,0 +1,12 @@
|
|
|
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)}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}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.")}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}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}}}}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}}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}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2017-2024 Sourcepole AG
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/import React from"react";import{connect}from"react-redux";import isEmpty from"lodash.isempty";import ol from"openlayers";import PropTypes from"prop-types";import{changeRedliningPickState}from"../../actions/redliningPick";import FeatureStyles from"../../utils/FeatureStyles";var RedliningPickSupport=/*#__PURE__*/function(_React$Component){function RedliningPickSupport(props){var _this;_classCallCheck(this,RedliningPickSupport);_this=_callSuper(this,RedliningPickSupport,[props]);_defineProperty(_this,"addPickInteraction",function(layerId){_this.reset(layerId);var redliningLayer=_this.searchRedliningLayer(layerId);if(!redliningLayer){return}var selectInteraction=new ol.interaction.Select({layers:[redliningLayer],toggleCondition:function toggleCondition(){return true}});selectInteraction.on("select",function(evt){var selectedFeatures=_this.props.redliningPick.selectedFeatures.slice(0);// Add newly selected features
|
|
8
|
+
var _iterator=_createForOfIteratorHelper(evt.selected||[]),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var feature=_step.value;// Skip text features for now
|
|
9
|
+
if(feature.shape==="Text"){continue}selectedFeatures.push(feature.getId());_this.selectFeature(feature)}// Deselect currently selected features
|
|
10
|
+
}catch(err){_iterator.e(err)}finally{_iterator.f()}var _iterator2=_createForOfIteratorHelper(evt.deselected||[]),_step2;try{var _loop=function _loop(){var feature=_step2.value;selectedFeatures=selectedFeatures.filter(function(id){return id!==feature.getId()});_this.deselectFeature(feature)};for(_iterator2.s();!(_step2=_iterator2.n()).done;){_loop()}}catch(err){_iterator2.e(err)}finally{_iterator2.f()}_this.props.changeRedliningPickState({selectedFeatures:selectedFeatures})},_this);_this.props.map.addInteraction(selectInteraction);_this.interactions=[selectInteraction]});_defineProperty(_this,"reset",function(layerId){while(_this.interactions.length>0){_this.props.map.removeInteraction(_this.interactions.shift())}_this.deselectAllFeatures(layerId);_this.props.changeRedliningPickState({selectedFeatures:[]})});_defineProperty(_this,"selectFeature",function(feature){var style=feature.getStyle();if(Array.isArray(style)){style=[].concat(_toConsumableArray(style),[_this.selectedStyle])}else{style=[style,_this.selectedStyle]}feature.setStyle(style)});_defineProperty(_this,"deselectFeature",function(feature){var style=feature.getStyle();if(Array.isArray(style)){style=feature.getStyle().filter(function(entry){return entry!==_this.selectedStyle});feature.setStyle(style.length>1?style:style[0])}});_defineProperty(_this,"deselectAllFeatures",function(layerId){var redliningLayer=_this.searchRedliningLayer(layerId);if(redliningLayer){var _iterator3=_createForOfIteratorHelper(_this.props.redliningPick.selectedFeatures||[]),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var id=_step3.value;var feature=redliningLayer.getSource().getFeatureById(id);if(feature){_this.deselectFeature(feature)}}}catch(err){_iterator3.e(err)}finally{_iterator3.f()}}});_defineProperty(_this,"searchRedliningLayer",function(layerId){var redliningLayer=null;_this.props.map.getLayers().forEach(function(olLayer){if(olLayer.get("id")===layerId){redliningLayer=olLayer}});return redliningLayer});_this.interactions=[];_this.selectedFeatures=[];var geometryFunction=function geometryFunction(feature){if(feature.getGeometry().getType()==="Point"){return new ol.geom.MultiPoint([feature.getGeometry().getCoordinates()])}else if(feature.getGeometry().getType()==="LineString"){return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates())}return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates()[0])};_this.selectedStyle=FeatureStyles.interactionVertex({geometryFunction:geometryFunction});return _this}_inherits(RedliningPickSupport,_React$Component);return _createClass(RedliningPickSupport,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(this.props.redliningPick===prevProps.redliningPick){// pass
|
|
11
|
+
}else if(!this.props.redliningPick.active&&prevProps.redliningPick.active){this.reset(this.props.redliningPick.layer)}else if(this.props.redliningPick.active&&!prevProps.redliningPick.active){this.addPickInteraction(this.props.redliningPick.layer)}else if(this.props.redliningPick.active===prevProps.redliningPick.active&&isEmpty(this.props.redliningPick.selectedFeatures)&&!isEmpty(prevProps.redliningPick.selectedFeatures)){// Re-initialize
|
|
12
|
+
this.reset(prevProps.redliningPick.layer);this.addPickInteraction(this.props.redliningPick.layer)}}},{key:"render",value:function render(){return null}}])}(React.Component);_defineProperty(RedliningPickSupport,"propTypes",{changeRedliningPickState:PropTypes.func,changeState:PropTypes.func,map:PropTypes.object,redliningPick:PropTypes.object});export default connect(function(state){return{redliningPick:state.redliningPick}},{changeRedliningPickState:changeRedliningPickState})(RedliningPickSupport);
|
|
@@ -0,0 +1,28 @@
|
|
|
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)}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}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.")}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}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}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}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}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}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2017-2024 Sourcepole AG
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/import React from"react";import{connect}from"react-redux";import Mousetrap from"mousetrap";import ol from"openlayers";import PropTypes from"prop-types";import{v4 as uuidv4}from"uuid";import{LayerRole,addLayerFeatures,removeLayerFeatures}from"../../actions/layers";import{changeRedliningState}from"../../actions/redlining";import NumericInputWindow from"../../components/NumericInputWindow";import{OlLayerAdded,OlLayerUpdated}from"../../components/map/OlLayer";import FeatureStyles from"../../utils/FeatureStyles";import MapUtils from"../../utils/MapUtils";import MeasureUtils from"../../utils/MeasureUtils";import VectorLayerUtils from"../../utils/VectorLayerUtils";var GeomTypeConfig={Text:{drawInteraction:function drawInteraction(opts){return new ol.interaction.Draw(_objectSpread(_objectSpread({},opts),{},{type:"Point"}))},editTool:"Pick",drawNodes:true},Point:{drawInteraction:function drawInteraction(opts){return new ol.interaction.Draw(_objectSpread(_objectSpread({},opts),{},{type:"Point"}))},editTool:"Pick",drawNodes:true},LineString:{drawInteraction:function drawInteraction(opts){return new ol.interaction.Draw(_objectSpread(_objectSpread({},opts),{},{type:"LineString"}))},editTool:"Pick",drawNodes:true},Polygon:{drawInteraction:function drawInteraction(opts){return new ol.interaction.Draw(_objectSpread(_objectSpread({},opts),{},{type:"Polygon"}))},editTool:"Pick",drawNodes:true},Circle:{drawInteraction:function drawInteraction(opts){return new ol.interaction.Draw(_objectSpread(_objectSpread({},opts),{},{type:"Circle"}))},editTool:"Pick",drawNodes:true,regular:true},Ellipse:{drawInteraction:function drawInteraction(opts){return new ol.interaction.DrawRegular(_objectSpread(_objectSpread({},opts),{},{sides:0}))},editTool:"Transform",drawNodes:false},Box:{drawInteraction:function drawInteraction(opts){return new ol.interaction.Draw(_objectSpread(_objectSpread({},opts),{},{type:"Circle",geometryFunction:ol.interaction.createBox()}))},editTool:"Transform",drawNodes:true},Square:{drawInteraction:function drawInteraction(opts){return new ol.interaction.DrawRegular(_objectSpread(_objectSpread({},opts),{},{sides:4,squareCondition:function squareCondition(){return true}}))},editTool:"Transform",regular:true}};/**
|
|
8
|
+
* Redlining support for the map component.
|
|
9
|
+
*/var RedliningSupport=/*#__PURE__*/function(_React$Component){function RedliningSupport(props){var _this;_classCallCheck(this,RedliningSupport);_this=_callSuper(this,RedliningSupport,[props]);_defineProperty(_this,"updateCurrentFeature",function(feature){if(_this.currentFeature&&_this.props.redlining.selectedFeature){if(feature.circleParams){var circleParams=feature.circleParams;_this.currentFeature.setGeometry(new ol.geom.Circle(circleParams.center,circleParams.radius))}else{_this.currentFeature.getGeometry().setCoordinates(feature.geometry.coordinates)}_this.props.changeRedliningState({selectedFeature:feature})}});_defineProperty(_this,"styleOptions",function(styleProps,isText){return{strokeColor:isText?styleProps.textOutlineColor:styleProps.borderColor,strokeWidth:1+0.5*styleProps.size,fillColor:isText?styleProps.textFillColor:styleProps.fillColor,circleRadius:5+styleProps.size,strokeDash:[],headmarker:styleProps.headmarker,tailmarker:styleProps.tailmarker}});_defineProperty(_this,"styleProps",function(feature){var styleOptions=feature.get("styleOptions");var label=feature.get("label")||"";var isText=feature.get("shape")==="Text";return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},isText?"textOutlineColor":"borderColor",styleOptions.strokeColor),"size",(styleOptions.strokeWidth-1)*2),isText?"textFillColor":"fillColor",styleOptions.fillColor),"text",label),"headmarker",styleOptions.headmarker),"tailmarker",styleOptions.tailmarker)});_defineProperty(_this,"updateFeatureStyle",function(styleProps){var isText=_this.currentFeature.get("shape")==="Text";var styleName=isText?"text":"default";var opts=_this.styleOptions(styleProps,isText);_this.blockOnChange=true;_this.currentFeature.set("label",styleProps.text);_this.currentFeature.set("styleName",styleName);_this.currentFeature.set("styleOptions",opts);_this.blockOnChange=false});_defineProperty(_this,"styleFunction",function(feature){var styleOptions=feature.get("styleOptions");var styleName=feature.get("styleName");var styles=[];if(styleName==="text"){styles.push(_this.selectedTextStyle(feature,styleOptions))}styles.push.apply(styles,_toConsumableArray(FeatureStyles[styleName](feature,styleOptions)));var shape=feature.get("shape");var geomTypeConfig=GeomTypeConfig[shape];if((geomTypeConfig||{}).drawNodes!==false){styles.push(_this.selectedStyle)}return styles});_defineProperty(_this,"setCurrentFeature",function(feature){_this.currentFeature=feature;_this.currentFeature.setStyle(_this.styleFunction);var circleParams=_this.currentFeature.get("circleParams");if(circleParams){_this.currentFeature.setGeometry(new ol.geom.Circle(circleParams.center,circleParams.radius))}var measurements=_this.currentFeature.get("measurements");var newRedliningState={style:_this.styleProps(_this.currentFeature),measurements:!!_this.currentFeature.get("measurements"),selectedFeature:_this.currentFeatureObject()};if(measurements){newRedliningState.lenUnit=measurements.lenUnit;newRedliningState.areaUnit=measurements.areaUnit}_this.props.changeRedliningState(newRedliningState);_this.currentFeature.on("change",_this.updateMeasurements)});_defineProperty(_this,"addDrawInteraction",function(){var geomTypeConfig=GeomTypeConfig[_this.props.redlining.geomType];if(!geomTypeConfig){return}var isFreeHand=_this.props.redlining.freehand;var drawInteraction=geomTypeConfig.drawInteraction({stopClick:true,condition:function condition(event){return event.originalEvent.buttons===1},style:function style(){return _this.picking?[]:FeatureStyles.sketchInteraction()},freehand:isFreeHand});drawInteraction.on("drawstart",function(evt){if(_this.picking&&_this.props.redlining.drawMultiple===false){return}_this.leaveTemporaryEditMode();_this.currentFeature=evt.feature;_this.currentFeature.setId(uuidv4());_this.currentFeature.set("shape",_this.props.redlining.geomType);_this.currentFeature.setStyle(_this.styleFunction);_this.updateFeatureStyle(_this.props.redlining.style);_this.currentFeature.on("change",_this.updateMeasurements)},_this);drawInteraction.on("drawend",function(){var featureId=_this.currentFeature.getId();_this.commitCurrentFeature(_this.props.redlining,true);_this.enterTemporaryEditMode(featureId,_this.props.redlining.layer,geomTypeConfig.editTool)},_this);_this.props.map.addInteraction(drawInteraction);_this.interactions.push(drawInteraction)});_defineProperty(_this,"updateMeasurements",function(){if(_this.blockOnChange||!_this.currentFeature){return}var feature=_this.currentFeature;var hadMeasurements=!!feature.get("measurements");if(_this.props.redlining.measurements){var settings={displayCrs:_this.props.displayCrs,lenUnit:_this.props.redlining.lenUnit,areaUnit:_this.props.redlining.areaUnit};MeasureUtils.updateFeatureMeasurements(feature,feature.get("shape"),_this.props.mapCrs,settings)}else if(hadMeasurements){feature.set("measurements",undefined);feature.set("segment_labels",undefined);feature.set("label","")}});_defineProperty(_this,"waitForFeatureAndLayer",function(layerId,featureId,callback){var redliningLayer=_this.searchRedliningLayer(layerId);if(!redliningLayer){OlLayerAdded.connect(function(layer){if(layer.get("id")===layerId){var feature=featureId?layer.getSource().getFeatureById(featureId):null;callback(layer,feature);return true}return false})}else if(featureId){var feature=redliningLayer.getSource().getFeatureById(featureId);if(feature){callback(redliningLayer,feature)}else{OlLayerUpdated.connect(function(layer){if(layer.get("id")===layerId){var feat=layer.getSource().getFeatureById(featureId);if(feat){callback(layer,feat);return true}}return false})}}else{callback(redliningLayer,null)}});_defineProperty(_this,"enterTemporaryEditMode",function(featureId,layerId,editTool){_this.waitForFeatureAndLayer(layerId,featureId,function(redliningLayer,feature){if(!feature){return}_this.setCurrentFeature(feature);if(editTool==="Transform"){_this.setupTransformInteraction([_this.currentFeature])}else{_this.setupModifyInteraction([_this.currentFeature])}_this.picking=true})});_defineProperty(_this,"leaveTemporaryEditMode",function(){if(_this.currentFeature){_this.commitCurrentFeature(_this.props.redlining)}if(_this.picking){// Remove modify interactions
|
|
10
|
+
_this.props.map.removeInteraction(_this.interactions.pop());_this.picking=false}});_defineProperty(_this,"addPickInteraction",function(){var redliningLayer=_this.searchRedliningLayer(_this.props.redlining.layer);if(!redliningLayer){return}var selectInteraction=new ol.interaction.Select({layers:[redliningLayer],hitTolerance:5});var currentEditInteraction=null;selectInteraction.on("select",function(evt){if(evt.selected.length===1&&evt.selected[0]===_this.currentFeature){return}if(_this.currentFeature){_this.commitCurrentFeature(_this.props.redlining)}if(currentEditInteraction){_this.props.map.removeInteraction(currentEditInteraction);_this.interactions=_this.interactions.filter(function(i){return i!==currentEditInteraction});currentEditInteraction=null}if(evt.selected.length===1){_this.setCurrentFeature(evt.selected[0]);var geomTypeConfig=GeomTypeConfig[_this.currentFeature.get("shape")];if(geomTypeConfig&&geomTypeConfig.editTool==="Transform"){currentEditInteraction=_this.setupTransformInteraction([_this.currentFeature]);currentEditInteraction.on("select",function(ev){// Clear selection when selecting a different feature, and let the parent select interaction deal with the new feature
|
|
11
|
+
if(_this.currentFeature&&ev.feature!==_this.currentFeature){_this.commitCurrentFeature(_this.props.redlining);currentEditInteraction.setSelection(new ol.Collection)}})}else{currentEditInteraction=_this.setupModifyInteraction(selectInteraction.getFeatures().getArray())}}/* else { // FIXME NECESSARY?
|
|
12
|
+
this.props.changeRedliningState({
|
|
13
|
+
geomType: this.props.redlining.action === 'PickDraw' ? this.props.redlining.geomType : null,
|
|
14
|
+
selectedFeature: null
|
|
15
|
+
});
|
|
16
|
+
}*/},_this);if(_this.props.redlining.action==="PickDraw"){_this.props.map.on("click",_this.maybeEnterTemporaryDrawMode)}_this.props.map.addInteraction(selectInteraction);_this.interactions.push(selectInteraction);_this.picking=true});_defineProperty(_this,"addTransformInteraction",function(){var redliningLayer=_this.searchRedliningLayer(_this.props.redlining.layer);if(!redliningLayer){return}var transformInteraction=_this.setupTransformInteraction();transformInteraction.on("select",function(evt){if(evt.feature===_this.currentFeature){return}if(_this.currentFeature){_this.commitCurrentFeature(_this.props.redlining)}if(evt.feature){_this.setCurrentFeature(evt.feature)}});_this.picking=true});_defineProperty(_this,"addPickDrawInteraction",function(){_this.waitForFeatureAndLayer(_this.props.redlining.layer,null,function(){return _this.addPickInteraction()})});_defineProperty(_this,"maybeEnterTemporaryDrawMode",function(ev){var redliningLayer=_this.searchRedliningLayer(_this.props.redlining.layer);if(_this.currentFeature||!_this.props.redlining.drawMultiple&&redliningLayer.getSource().getFeatures().length>0){return}var featureHit=false;_this.props.map.forEachFeatureAtPixel(ev.pixel,function(feature,layer){featureHit|=layer===redliningLayer},{hitTolerance:5});if(!redliningLayer||featureHit){return}_this.reset(_this.props.redlining);_this.props.map.un("click",_this.maybeEnterTemporaryDrawMode);var geomTypeConfig=GeomTypeConfig[_this.props.redlining.geomType];if(!geomTypeConfig){return}var isFreeHand=_this.props.redlining.freehand;var drawInteraction=geomTypeConfig.drawInteraction({stopClick:true,condition:function condition(event){return event.originalEvent.buttons===1},style:function style(){return _this.picking?[]:FeatureStyles.sketchInteraction()},freehand:isFreeHand});drawInteraction.on("drawstart",function(evt){_this.currentFeature=evt.feature;_this.currentFeature.setId(uuidv4());_this.currentFeature.set("shape",_this.props.redlining.geomType);_this.currentFeature.setStyle(_this.styleFunction);_this.updateFeatureStyle(_this.props.redlining.style);_this.currentFeature.on("change",_this.updateMeasurements)},_this);drawInteraction.on("drawend",function(){// Draw end
|
|
17
|
+
_this.commitCurrentFeature(_this.props.redlining,true);_this.reset(_this.props.redlining);// Ughh... Apparently we need to wait 250ms for the 'singleclick' event processing to finish to avoid pick interactions picking up the current event
|
|
18
|
+
setTimeout(function(){return _this.addPickInteraction(true)},300)},_this);_this.props.map.addInteraction(drawInteraction);_this.interactions.push(drawInteraction);_this.picking=false;var clickCoord=MapUtils.getHook(MapUtils.GET_SNAPPED_COORDINATES_FROM_PIXEL_HOOK)(ev.pixel);drawInteraction.appendCoordinates([clickCoord]);if(_this.props.redlining.geomType==="Point"){drawInteraction.finishDrawing()}});_defineProperty(_this,"setupModifyInteraction",function(){var selectedFeatures=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var modifyInteraction=new ol.interaction.Modify({features:new ol.Collection(selectedFeatures),condition:function condition(event){return event.originalEvent.buttons===1},deleteCondition:function deleteCondition(event){// delete vertices on SHIFT + click
|
|
19
|
+
if(event.type==="pointerdown"&&ol.events.condition.shiftKeyOnly(event)){_this.props.map.setIgnoreNextClick(true)}return ol.events.condition.shiftKeyOnly(event)&&ol.events.condition.singleClick(event)}});modifyInteraction.on("modifyend",function(){_this.props.changeRedliningState({selectedFeature:_this.currentFeatureObject()})});_this.props.map.addInteraction(modifyInteraction);_this.interactions.push(modifyInteraction);return modifyInteraction});_defineProperty(_this,"setupTransformInteraction",function(){var selectedFeatures=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var transformInteraction=new ol.interaction.Transform({stretch:false,keepAspectRatio:function keepAspectRatio(ev){return _this.currentFeature?GeomTypeConfig[_this.currentFeature.get("shape")].regular||ol.events.condition.shiftKeyOnly(ev):false}});transformInteraction.on("rotating",function(e){if(_this.currentFeature.get("shape")==="Text"){_this.currentFeature.set("rotation",-e.angle)}});transformInteraction.on("rotateend",function(e){_this.props.changeRedliningState({selectedFeature:_this.currentFeatureObject()})});transformInteraction.on("translateend",function(){_this.props.changeRedliningState({selectedFeature:_this.currentFeatureObject()})});transformInteraction.on("scaleend",function(){_this.props.changeRedliningState({selectedFeature:_this.currentFeatureObject()})});_this.props.map.addInteraction(transformInteraction);_this.interactions.push(transformInteraction);transformInteraction.setSelection(new ol.Collection(selectedFeatures));return transformInteraction});_defineProperty(_this,"triggerDelete",function(){_this.props.changeRedliningState({action:"Delete"})});_defineProperty(_this,"deleteCurrentFeature",function(){if(_this.currentFeature){_this.props.removeLayerFeatures(_this.props.redlining.layer,[_this.currentFeature.getId()],true);_this.currentFeature=null}});_defineProperty(_this,"commitCurrentFeature",function(redliningProps){var _feature$geometry;var newFeature=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var feature=_this.currentFeatureObject();if(!feature){return}// Don't commit empty/invalid features
|
|
20
|
+
if(feature.shape==="Text"&&!feature.properties.label||feature.shape==="Circle"&&feature.circleParams.radius===0||((_feature$geometry=feature.geometry)===null||_feature$geometry===void 0?void 0:_feature$geometry.type)==="Polygon"&&_this.currentFeature.getGeometry().getArea()===0){if(!newFeature){_this.props.removeLayerFeatures(redliningProps.layer,[feature.id])}_this.resetSelectedFeature();return}if(feature.shape==="Circle"){var _feature$circleParams=feature.circleParams,center=_feature$circleParams.center,radius=_feature$circleParams.radius;var deg2rad=Math.PI/180;feature.geometry.type="Polygon";feature.geometry.coordinates=[Array.apply(null,Array(91)).map(function(item,index){return[center[0]+radius*Math.cos(4*index*deg2rad),center[1]+radius*Math.sin(4*index*deg2rad)]})]}if(feature.geometry.type==="LineString"||feature.geometry.type==="Polygon"){feature.geometry.coordinates=VectorLayerUtils.removeDuplicateNodes(feature.geometry.coordinates)}var layer={id:redliningProps.layer,title:redliningProps.layerTitle,role:LayerRole.USERLAYER};_this.props.addLayerFeatures(layer,[feature]);_this.resetSelectedFeature()});_defineProperty(_this,"resetSelectedFeature",function(){if(_this.currentFeature){// Reset selection style
|
|
21
|
+
var styleName=_this.currentFeature.get("shape")==="Text"?"text":"default";var style=FeatureStyles[styleName](_this.currentFeature,_this.currentFeature.get("styleOptions"));_this.currentFeature.setStyle(style);_this.currentFeature.un("change",_this.updateMeasurements);_this.currentFeature=null;_this.props.changeRedliningState({selectedFeature:null})}});_defineProperty(_this,"reset",function(redliningProps){while(_this.interactions.length>0){_this.props.map.removeInteraction(_this.interactions.shift())}if(_this.picking){_this.commitCurrentFeature(redliningProps,false)}else{_this.resetSelectedFeature()}_this.props.map.un("click",_this.maybeEnterTemporaryDrawMode);_this.picking=false});_defineProperty(_this,"searchRedliningLayer",function(layerId){var _this$props$map$getLa;return(_this$props$map$getLa=_this.props.map.getLayers().getArray().find(function(l){return l.get("id")===layerId}))!==null&&_this$props$map$getLa!==void 0?_this$props$map$getLa:null});_defineProperty(_this,"currentFeatureObject",function(){if(!_this.currentFeature){return null}var format=new ol.format.GeoJSON;var feature=format.writeFeatureObject(_this.currentFeature);if(_this.currentFeature.get("shape")==="Circle"){feature.circleParams={center:_this.currentFeature.getGeometry().getCenter(),radius:_this.currentFeature.getGeometry().getRadius()}}feature.styleName=_this.currentFeature.get("styleName");feature.styleOptions=_this.currentFeature.get("styleOptions");feature.shape=_this.currentFeature.get("shape");feature.measurements=_this.currentFeature.get("measurements");feature.crs=_this.props.mapCrs;// Don't pollute GeoJSON object properties with internal props
|
|
22
|
+
delete feature.properties.styleName;delete feature.properties.styleOptions;delete feature.properties.shape;delete feature.properties.measurements;delete feature.properties.circleParams;// Don't store empty label prop
|
|
23
|
+
if(feature.properties.label===""){delete feature.properties.label}return feature});_this.interactions=[];_this.picking=false;_this.currentFeature=null;_this.blockOnChange=false;_this.selectedTextStyle=function(feature,opts){return new ol.style.Style({text:new ol.style.Text({font:"10pt sans-serif",text:feature.getProperties().label||"",rotation:feature.getProperties().rotation||0,scale:opts.strokeWidth,fill:new ol.style.Fill({color:opts.textFillColor}),stroke:new ol.style.Stroke({color:[0,0,0,0.5],width:4})})})};var geometryFunction=function geometryFunction(feature){if(feature.getGeometry().getType()==="Point"){return new ol.geom.MultiPoint([feature.getGeometry().getCoordinates()])}else if(feature.getGeometry().getType()==="LineString"){return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates())}else if(feature.getGeometry().getType()==="Polygon"){return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates()[0])}else if(feature.getGeometry().getType()==="Circle"){var center=feature.getGeometry().getCenter();return new ol.geom.MultiPoint([center,[center[0]+feature.getGeometry().getRadius(),center[1]]])}return null};_this.selectedStyle=FeatureStyles.interactionVertex({geometryFunction:geometryFunction});return _this}_inherits(RedliningSupport,_React$Component);return _createClass(RedliningSupport,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){// Bind keyboard shortcuts to delete features
|
|
24
|
+
if(this.props.redlining.action&&!prevProps.redlining.action){Mousetrap.bind("del",this.triggerDelete);Mousetrap.bind("backspace",this.triggerDelete)}else if(!this.props.redlining.action&&prevProps.redlining.action){Mousetrap.unbind("del",this.triggerDelete);Mousetrap.unbind("backspace",this.triggerDelete)}// Handle delete action immediately and reset the redlining state to the previous action
|
|
25
|
+
if(this.props.redlining.action==="Delete"){this.deleteCurrentFeature();this.props.changeRedliningState(_objectSpread(_objectSpread({},prevProps.redlining),{},{selectedFeature:null}));return}var recreateInteraction=this.props.redlining.action!==prevProps.redlining.action||this.props.redlining.layer!==prevProps.redlining.layer||this.props.redlining.geomType!==prevProps.redlining.geomType||this.props.redlining.freehand!==prevProps.redlining.freehand||this.props.redlining.drawMultiple!==prevProps.redlining.drawMultiple;if(recreateInteraction){// Commit to previous layer in case layer changed
|
|
26
|
+
this.reset(prevProps.redlining);if(this.props.redlining.action==="Draw"){this.addDrawInteraction()}else if(this.props.redlining.action==="Transform"){this.addTransformInteraction()}else if(this.props.redlining.action==="Pick"||this.props.redlining.action==="Buffer"){this.addPickInteraction()}else if(this.props.redlining.action==="PickDraw"){this.addPickDrawInteraction()}}if(this.currentFeature){// Update feature style
|
|
27
|
+
if(this.props.redlining.style!==prevProps.redlining.style){this.updateFeatureStyle(this.props.redlining.style)}// Update current feature measurements
|
|
28
|
+
if(this.props.map.displayCrs!==prevProps.map.displayCrs||this.props.redlining.measurements!==prevProps.redlining.measurements||this.props.redlining.lenUnit!==prevProps.redlining.lenUnit||this.props.redlining.areaUnit!==prevProps.redlining.areaUnit){this.currentFeature.changed()}}}},{key:"render",value:function render(){var _this2=this;if(this.props.redlining.numericInput){return/*#__PURE__*/React.createElement(NumericInputWindow,{feature:this.props.redlining.selectedFeature,onClose:function onClose(){return _this2.props.changeRedliningState({numericInput:false})},onFeatureChanged:this.updateCurrentFeature})}return null}}])}(React.Component);_defineProperty(RedliningSupport,"propTypes",{addLayerFeatures:PropTypes.func,changeRedliningState:PropTypes.func,displayCrs:PropTypes.string,map:PropTypes.object,mapCrs:PropTypes.string,redlining:PropTypes.object,removeLayerFeatures:PropTypes.func});_defineProperty(RedliningSupport,"defaultProps",{redlining:{}});export default connect(function(state){return{displayCrs:state.map.displayCrs,mapCrs:state.map.projection,redlining:state.redlining}},{changeRedliningState:changeRedliningState,addLayerFeatures:addLayerFeatures,removeLayerFeatures:removeLayerFeatures})(RedliningSupport);
|
|
@@ -0,0 +1,10 @@
|
|
|
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)}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}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}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2015 GeoSolutions Sas
|
|
3
|
+
* Copyright 2016-2024 Sourcepole AG
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the BSD-style license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/import React from"react";import{connect}from"react-redux";import ol from"openlayers";import PropTypes from"prop-types";import"./style/ScaleBarSupport.css";/**
|
|
9
|
+
* Scalebar support for the map component.
|
|
10
|
+
*/var ScaleBarSupport=/*#__PURE__*/function(_React$Component){function ScaleBarSupport(props){var _this;_classCallCheck(this,ScaleBarSupport);_this=_callSuper(this,ScaleBarSupport,[props]);_defineProperty(_this,"componentWillUnmount",function(){if(_this.scalebar){_this.props.map.removeControl(_this.scalebar)}});_defineProperty(_this,"initScaleBar",function(el){_this.scalebar=new ol.control.ScaleLine(_objectSpread(_objectSpread({target:el},ScaleBarSupport.defaultOpt),_this.props.options));_this.props.map.addControl(_this.scalebar)});_this.scalebar=null;return _this}_inherits(ScaleBarSupport,_React$Component);return _createClass(ScaleBarSupport,[{key:"render",value:function render(){var style=this.props.mapMargins.splitTopAndBottomBar?{marginLeft:this.props.mapMargins.left+"px"}:{};return/*#__PURE__*/React.createElement("div",{id:"ScaleBar",ref:this.initScaleBar,style:style})}}])}(React.Component);_defineProperty(ScaleBarSupport,"propTypes",{map:PropTypes.object,mapMargins:PropTypes.object,/** See [OpenLayers API doc](https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-ScaleLine.html) */options:PropTypes.object});_defineProperty(ScaleBarSupport,"defaultOpt",{minWidth:64,units:"metric"});export default connect(function(state){return{mapMargins:state.windows.mapMargins}})(ScaleBarSupport);
|
|
@@ -0,0 +1 @@
|
|
|
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)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t)}:p}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},_get.apply(null,arguments)}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}import ol from"openlayers";var SnapInteraction=/*#__PURE__*/function(_ol$interaction$Snap){function SnapInteraction(options){var _this;_classCallCheck(this,SnapInteraction);_this=_callSuper(this,SnapInteraction,[options]);_this.layer=new ol.layer.Vector({source:new ol.source.Vector,zIndex:Infinity});_this.currentMap=null;return _this}_inherits(SnapInteraction,_ol$interaction$Snap);return _createClass(SnapInteraction,[{key:"handleEvent",value:function handleEvent(evt){var result=this.snapTo(evt.pixel,evt.coordinate,evt.map);this.layer.getSource().clear();if(result){evt.coordinate=result.vertex.slice(0,2);evt.pixel=result.vertexPixel;var feature=new ol.Feature({geometry:new ol.geom.Point(evt.coordinate)});if(result.segment){feature.setStyle(new ol.style.Style({image:new ol.style.RegularShape({stroke:new ol.style.Stroke({color:"#FF0000",width:3}),points:4,radius:14,angle:Math.PI/4})}))}else{feature.setStyle(new ol.style.Style({image:new ol.style.Circle({stroke:new ol.style.Stroke({color:"#FF0000",width:3}),radius:10})}))}this.layer.getSource().addFeature(feature)}return ol.interaction.Pointer.prototype.handleEvent.call(this,evt)}},{key:"setMap",value:function setMap(map){if(map){map.addLayer(this.layer);this.currentMap=map}else if(this.currentMap){this.currentMap.removeLayer(this.layer);this.currentMap=null}_superPropGet(SnapInteraction,"setMap",this,3)([map])}},{key:"setActive",value:function setActive(active){if(this.layer){this.layer.setVisible(active)}_superPropGet(SnapInteraction,"setActive",this,3)([active])}},{key:"setSnapEdge",value:function setSnapEdge(snap){this.edge_=snap}},{key:"setSnapVertex",value:function setSnapVertex(snap){this.vertex_=snap}}])}(ol.interaction.Snap);export{SnapInteraction as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
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)}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}}}}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}}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}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2019, norBIT GmbH.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/import React from"react";import{connect}from"react-redux";import axios from"axios";import ol from"openlayers";import PropTypes from"prop-types";import{v4 as uuidv4}from"uuid";import{LayerRole}from"../../actions/layers";import FeatureStyles from"../../utils/FeatureStyles";import IdentifyUtils from"../../utils/IdentifyUtils";import MapUtils from"../../utils/MapUtils";var SnapSupport=/*#__PURE__*/function(_React$Component){function SnapSupport(props){var _this;_classCallCheck(this,SnapSupport);_this=_callSuper(this,SnapSupport,[props]);_defineProperty(_this,"state",{mousePos:null});_defineProperty(_this,"getMapMousePos",function(ev){_this.setState({mousePos:{coordinate:ev.coordinate,pixel:ev.pixel}})});_defineProperty(_this,"addSnapFeatures",function(geojson){_this.reset();var format=new ol.format.GeoJSON;var features=format.readFeatures(geojson);var _iterator=_createForOfIteratorHelper(features),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var feature=_step.value;_this.snapSource.addFeature(feature)}}catch(err){_iterator.e(err)}finally{_iterator.f()}});_defineProperty(_this,"addSnapInteraction",function(){_this.snapInteraction=new ol.interaction.Snap({source:_this.snapSource});_this.props.map.addInteraction(_this.snapInteraction)});_defineProperty(_this,"getFeature",function(){_this.timeoutId=null;var layers=_this.props.layers.find(function(layer){return layer.role===LayerRole.THEME});var queryLayers=_this.props.layers.reduce(function(accum,layer){return layer.role===LayerRole.THEME?accum.concat(layer.queryLayers):accum},[]).join(",");if(!layers||!queryLayers){return}var options={info_format:"text/xml",feature_count:20,FI_POINT_TOLERANCE:16,FI_LINE_TOLERANCE:8,FI_POLYGON_TOLERANCE:4};var request=IdentifyUtils.buildRequest(layers,queryLayers,_this.state.mousePos.coordinate,_this.props.mapObj,options);axios.get(request.url,{params:request.params}).then(function(response){var results=IdentifyUtils.parseXmlResponse(response.data,_this.props.mapObj.projection);var features=[];results.forEach(function(result){var _iterator2=_createForOfIteratorHelper(result),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var feature=_step2.value;if(feature.geometry){feature.id=uuidv4();features.push(feature)}}}catch(err){_iterator2.e(err)}finally{_iterator2.f()}});if(!features){return}var geojson={type:"FeatureCollection",crs:{type:"name",properties:{name:_this.props.mapObj.projection}},features:features};_this.addSnapFeatures(geojson);_this.addSnapInteraction()})});_defineProperty(_this,"reset",function(){if(_this.snapInteractions){_this.props.map.removeInteraction(_this.snapInteraction)}var _iterator3=_createForOfIteratorHelper(_this.snapSource.getFeatures()),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var feature=_step3.value;_this.snapSource.removeFeature(feature)}}catch(err){_iterator3.e(err)}finally{_iterator3.f()}});var geometryFunction=function geometryFunction(feature){if(feature.getGeometry().getType()==="Point"){return new ol.geom.MultiPoint([feature.getGeometry().getCoordinates()])}else if(feature.getGeometry().getType()==="LineString"){return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates())}return new ol.geom.MultiPoint(feature.getGeometry().getCoordinates()[0])};_this.snapSource=new ol.source.Vector;_this.snapLayer=new ol.layer.Vector({source:_this.snapSource,zIndex:1000000,style:[FeatureStyles.interaction({},true),FeatureStyles.interactionVertex({geometryFunction:geometryFunction},true)]});_this.props.map.addLayer(_this.snapLayer);_this.curPos=null;return _this}_inherits(SnapSupport,_React$Component);return _createClass(SnapSupport,[{key:"componentDidMount",value:function componentDidMount(){MapUtils.getHook(MapUtils.GET_MAP).on("pointermove",this.getMapMousePos)}},{key:"componentWillUnmount",value:function componentWillUnmount(){MapUtils.getHook(MapUtils.GET_MAP).un("pointermove",this.getMapMousePos)}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){var _this2=this;if(this.props.drawing&&this.state.mousePos&&(!this.curPos||Math.abs(this.state.mousePos.pixel[0]-this.curPos[0])>5||Math.abs(this.state.mousePos.pixel[1]-this.curPos[1])>5)){clearTimeout(this.timeoutId);this.curPos=this.state.mousePos.pixel;this.timeoutId=setTimeout(function(){return _this2.getFeature()},500)}else if(!this.props.drawing&&prevProps.drawing){this.reset()}}},{key:"render",value:function render(){return null}}])}(React.Component);_defineProperty(SnapSupport,"propTypes",{drawing:PropTypes.bool,layers:PropTypes.array,map:PropTypes.object,mapObj:PropTypes.object});var selector=function selector(state){return{drawing:["Redlining","Measure","Editing"].includes(state.task.id),mapObj:state.map,layers:state.layers.flat}};export default connect(selector,{})(SnapSupport);
|
|
@@ -0,0 +1,23 @@
|
|
|
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)}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}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}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}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.")}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}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}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}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}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}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}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)}/**
|
|
2
|
+
* Copyright 2017-2024 Sourcepole AG
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/import React from"react";import{connect}from"react-redux";import isEmpty from"lodash.isempty";import ol from"openlayers";import PropTypes from"prop-types";import{v1 as uuidv1}from"uuid";import{LayerRole}from"../../actions/layers";import{setSnappingConfig}from"../../actions/map";import Icon from"../../components/Icon";import Spinner from"../../components/widgets/Spinner";import IdentifyUtils from"../../utils/IdentifyUtils";import LocaleUtils from"../../utils/LocaleUtils";import MapUtils from"../../utils/MapUtils";import VectorLayerUtils from"../../utils/VectorLayerUtils";import SnapInteraction from"./SnapInteraction";import"./style/SnappingSupport.css";/**
|
|
8
|
+
* Snapping support for the map component.
|
|
9
|
+
*/var SnappingSupport=/*#__PURE__*/function(_React$Component){function SnappingSupport(props){var _this;_classCallCheck(this,SnappingSupport);_this=_callSuper(this,SnappingSupport,[props]);_defineProperty(_this,"state",{reqId:null,// FeatureInfo request ID
|
|
10
|
+
invalid:true,// Whether the feature cache needs to be rebuilt
|
|
11
|
+
havesnaplayers:false,// Whether there are any snaplayers
|
|
12
|
+
drawing:false// Whether a drawing interaction is active,
|
|
13
|
+
});_defineProperty(_this,"snapToEdge",function(snappingConfig){return snappingConfig.active===true||snappingConfig.active==="edge"});_defineProperty(_this,"snapToVertex",function(snappingConfig){return snappingConfig.active===true||snappingConfig.active==="vertex"});_defineProperty(_this,"toggleSnap",function(mode){var active=_this.props.mapObj.snapping.active;if(mode==="edge"){if(active===true){active="vertex"}else if(active==="edge"){active=false}else if(active==="vertex"){active=true}else{active="edge"}}else if(mode==="vertex"){if(active===true){active="edge"}else if(active==="vertex"){active=false}else if(active==="edge"){active=true}else{active="vertex"}}_this.props.setSnappingConfig(true,active)});_defineProperty(_this,"handleInteractionAdded",function(ev){if(_this.inEventHandler){return}_this.inEventHandler=true;_this.addSnapInteractionIfNeeded(ev.target);_this.inEventHandler=false});_defineProperty(_this,"handleInteractionRemoved",function(ev){if(_this.inEventHandler){return}_this.inEventHandler=true;// If the removed interaction is the snap interaction, which should always be
|
|
14
|
+
// the last interaction, remove the interaction preceding the snap interaction
|
|
15
|
+
if(ev.element===_this.snapInteraction){ev.target.pop()}_this.addSnapInteractionIfNeeded(ev.target);_this.inEventHandler=false});_defineProperty(_this,"addSnapInteractionIfNeeded",function(interactions){// Just to be sure
|
|
16
|
+
interactions.remove(_this.snapInteraction);// If there is any draw or modify interaction, add snapping interaction
|
|
17
|
+
var added=false;if(_this.props.mapObj.snapping.enabled){for(var i=0;i<interactions.getLength();++i){var interaction=interactions.item(i);if(interaction instanceof ol.interaction.Draw||interaction instanceof ol.interaction.Modify||interaction instanceof ol.interaction.Select){interactions.push(_this.snapInteraction);added=true;break}}}_this.setState({drawing:added})});_defineProperty(_this,"refreshFeatureCache",function(force){if(!_this.state.invalid&&!force||!_this.state.drawing){return}_this.source.clear();var themeLayer=_this.props.layers.find(function(layer){return layer.role===LayerRole.THEME});if(!_this.props.theme||!themeLayer||!_this.state.drawing){return}var snappingConfig=_this.props.theme.snapping||{};// Gather snapping layers based on visibility scale ranges
|
|
18
|
+
var scale=MapUtils.computeForZoom(_this.props.mapObj.scales,_this.props.mapObj.zoom);var snapLayers=(snappingConfig.snaplayers||[]).reduce(function(res,cur){if(cur.min!==undefined&&cur.min!==null&&scale<cur.min){// Below scale range
|
|
19
|
+
return res}if(cur.max!==undefined&&cur.max!==null&&scale>=cur.max){// Above scale range
|
|
20
|
+
return res}return[].concat(_toConsumableArray(res),[cur.name])},[]);// Gather local snap layers
|
|
21
|
+
var snapToWfs=scale<snappingConfig.wfsMaxScale;var localLayers=[];_this.props.layers.forEach(function(layer){if(layer.role===LayerRole.USERLAYER&&(layer.type==="vector"||layer.type==="wfs"&&snapToWfs)){var olLayer=_this.props.map.getLayers().getArray().find(function(l){return l.get("id")===layer.id});if(olLayer&&olLayer.getSource()&&olLayer.getSource().getFeaturesInExtent){localLayers.push(olLayer)}}});_this.setState({reqId:null,havesnaplayers:!isEmpty(snapLayers)||!isEmpty(localLayers)});if(!_this.snapInteraction.getMap()||!_this.snapInteraction.getActive()){return}if(snapLayers.length===0){_this.addLocalSnapFeatures(localLayers);return}var xmin=_this.props.mapObj.bbox.bounds[0];var ymin=_this.props.mapObj.bbox.bounds[1];var xmax=_this.props.mapObj.bbox.bounds[2];var ymax=_this.props.mapObj.bbox.bounds[3];var filterGeom=VectorLayerUtils.geoJSONGeomToWkt({type:"Polygon",coordinates:[[[xmin,ymin],[xmax,ymin],[xmax,ymax],[xmin,ymax],[xmin,ymin]]]});var options={LAYERATTRIBS:JSON.stringify([]),with_htmlcontent:false,with_bbox:false,feature_count:snappingConfig.featureCount||500};var request=IdentifyUtils.buildFilterRequest(themeLayer,snapLayers.join(","),filterGeom,_this.props.mapObj,options);var reqId=uuidv1();_this.setState({reqId:reqId});IdentifyUtils.sendRequest(request,function(response){if(_this.state.reqId!==reqId){return}if(response){var result=IdentifyUtils.parseXmlResponse(response,_this.props.mapObj.projection);var features=Object.values(result).reduce(function(res,cur){return[].concat(_toConsumableArray(res),_toConsumableArray(cur))},[]);var format=new ol.format.GeoJSON;var olFeatures=format.readFeatures({type:"FeatureCollection",features:features.map(function(feature){return _objectSpread(_objectSpread({},feature),{},{id:uuidv1()})})});_this.source.addFeatures(olFeatures);// Add features from local layers
|
|
22
|
+
_this.addLocalSnapFeatures(localLayers);_this.setState({invalid:false,reqId:null,havesnaplayers:true})}else{_this.setState({reqId:null})}})});_defineProperty(_this,"addLocalSnapFeatures",function(localLayers){var extent=_this.props.mapObj.bbox.bounds;var projection=ol.proj.get(_this.props.mapObj.projection);localLayers.forEach(function(olLayer){var olFeatures=olLayer.getSource().getFeaturesInExtent(extent,projection);_this.source.addFeatures(olFeatures)})});_this.source=new ol.source.Vector;_this.snapInteraction=new SnapInteraction({source:_this.source,edge:_this.snapToEdge(props.mapObj.snapping),vertex:_this.snapToVertex(props.mapObj.snapping)});_this.snapInteraction.setActive(_this.props.mapObj.snapping.active);_this.inEventHandler=false;props.map.getInteractions().on("add",_this.handleInteractionAdded);props.map.getInteractions().on("remove",_this.handleInteractionRemoved);MapUtils.registerHook(MapUtils.GET_SNAPPED_COORDINATES_FROM_PIXEL_HOOK,function(pixel){var coo=props.map.getCoordinateFromPixel(pixel);var snapResult=_this.snapInteraction.snapTo(pixel,coo,props.map);return snapResult?props.map.getCoordinateFromPixel(snapResult.vertexPixel):coo});return _this}_inherits(SnappingSupport,_React$Component);return _createClass(SnappingSupport,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){var _this2=this;if(this.state.drawing&&(this.props.mapObj.bbox!==prevProps.mapObj.bbox||this.props.theme!==prevProps.theme)){this.setState({invalid:true});this.refreshFeatureCache(true)}else if(this.state.drawing&&this.props.layers!==prevProps.layers){var layersChanged=this.props.layers.find(function(layer){if(layer.role===LayerRole.THEME){var prev=prevProps.layers.find(function(prevLayer){return layer.uuid===prevLayer.uuid});return!prev||layer.rev!==prev.rev}else if(layer.role===LayerRole.USERLAYER&&layer.type==="vector"){var _prev=prevProps.layers.find(function(prevLayer){return layer.uuid===prevLayer.uuid});return!_prev||_prev.features!==layer.features}return false});if(layersChanged){this.setState({invalid:true});// Delay to avoid refreshing the cache before QGIS Server can pick up the new feature
|
|
23
|
+
setTimeout(function(){_this2.refreshFeatureCache(true)},1500)}}if(this.props.mapObj.snapping.active!==prevProps.mapObj.snapping.active||this.state.drawing!==prevState.drawing){this.snapInteraction.setActive(this.props.mapObj.snapping.active!==false);this.snapInteraction.setSnapEdge(this.snapToEdge(this.props.mapObj.snapping));this.snapInteraction.setSnapVertex(this.snapToVertex(this.props.mapObj.snapping));if(this.props.mapObj.snapping.active){this.refreshFeatureCache()}}}},{key:"render",value:function render(){var _this3=this;if(!this.state.drawing||!this.props.mapObj.snapping.enabled){return null}var disabled=!this.state.havesnaplayers||this.props.mapObj.snapping.active===false;var toolbarClass=disabled?"snapping-toolbar-inactive":"";var snapEdge=this.snapToEdge(this.props.mapObj.snapping);var snapVertex=this.snapToVertex(this.props.mapObj.snapping);return/*#__PURE__*/React.createElement("div",{className:"snapping-toolbar-container"},/*#__PURE__*/React.createElement("div",{className:toolbarClass},this.state.reqId!==null?/*#__PURE__*/React.createElement(Spinner,null):/*#__PURE__*/React.createElement("span",null,/*#__PURE__*/React.createElement("button",{className:"button"+(snapVertex?" pressed":""),onClick:function onClick(){return _this3.toggleSnap("vertex")},title:LocaleUtils.tr("snapping.vertex")},/*#__PURE__*/React.createElement(Icon,{icon:"snap_vertex",size:"large"})),/*#__PURE__*/React.createElement("button",{className:"button"+(snapEdge?" pressed":""),onClick:function onClick(){return _this3.toggleSnap("edge")},title:LocaleUtils.tr("snapping.edge")},/*#__PURE__*/React.createElement(Icon,{icon:"snap_edge",size:"large"}))),"\xA0",this.state.reqId?LocaleUtils.tr("snapping.loading"):LocaleUtils.tr("snapping.snappingenabled")))}}])}(React.Component);_defineProperty(SnappingSupport,"propTypes",{layers:PropTypes.array,map:PropTypes.object,mapObj:PropTypes.object,setSnappingConfig:PropTypes.func,task:PropTypes.string,theme:PropTypes.object});export default connect(function(state){return{layers:state.layers.flat,mapObj:state.map,task:state.task.id,theme:state.theme.current}},{setSnappingConfig:setSnappingConfig})(SnappingSupport);
|