@collabdt/core 0.14.0 → 0.15.0
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/dist/core/components/ui/Command.d.ts +3 -3
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.d.ts.map +1 -1
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.js +13 -0
- package/dist/core/components/ui/FilesManager/src/FileItemComponent.js.map +1 -1
- package/dist/core/components/ui/FilesManager/src/fileType.d.ts +1 -0
- package/dist/core/components/ui/FilesManager/src/fileType.d.ts.map +1 -1
- package/dist/core/components/ui/FilesManager/src/fileType.js +5 -0
- package/dist/core/components/ui/FilesManager/src/fileType.js.map +1 -1
- package/dist/core/components/ui/Sensors/SensorComparisonChart.d.ts.map +1 -1
- package/dist/core/components/ui/Sensors/SensorComparisonChart.js +2 -2
- package/dist/core/components/ui/Sensors/SensorComparisonChart.js.map +1 -1
- package/dist/core/components/ui/Sensors/SensorDetailDialog.js +3 -3
- package/dist/core/components/ui/Sensors/SensorDetailDialog.js.map +1 -1
- package/dist/core/components/ui/Sensors/SensorsSection.d.ts.map +1 -1
- package/dist/core/components/ui/Sensors/SensorsSection.js +45 -9
- package/dist/core/components/ui/Sensors/SensorsSection.js.map +1 -1
- package/dist/core/components/ui/Sensors/sensorScope.d.ts +5 -0
- package/dist/core/components/ui/Sensors/sensorScope.d.ts.map +1 -1
- package/dist/core/components/ui/Sensors/sensorScope.js +4 -0
- package/dist/core/components/ui/Sensors/sensorScope.js.map +1 -1
- package/dist/core/components/ui/Sensors/useSensorsInView.d.ts +6 -0
- package/dist/core/components/ui/Sensors/useSensorsInView.d.ts.map +1 -0
- package/dist/core/components/ui/Sensors/useSensorsInView.js +17 -0
- package/dist/core/components/ui/Sensors/useSensorsInView.js.map +1 -0
- package/dist/core/components/viewers/Data/buildingDetails/GeocoderInput.d.ts.map +1 -1
- package/dist/core/components/viewers/Data/buildingDetails/GeocoderInput.js +23 -7
- package/dist/core/components/viewers/Data/buildingDetails/GeocoderInput.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/BimSection.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/BimSection.js +28 -61
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/BimSection.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/FileAppearanceDialog.d.ts +9 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/FileAppearanceDialog.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/FileAppearanceDialog.js +29 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/FileAppearanceDialog.js.map +1 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/partitionFileTab.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/partitionFileTab.js +3 -5
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/partitionFileTab.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceControls.d.ts +9 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceControls.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceControls.js +91 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceControls.js.map +1 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceSwatch.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceSwatch.js +9 -83
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceSwatch.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/BimTreeView.js +20 -3
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/BimTreeView.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/CustomSection.js +5 -5
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/CustomSection.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/DrawingModelFilter.d.ts +4 -0
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/DrawingModelFilter.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/DrawingModelFilter.js +3 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/DrawingModelFilter.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/ElevationsSection.js +5 -5
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/ElevationsSection.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/FloorplanSection.js +5 -5
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/FloorplanSection.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/IfcClassesSection.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/IfcClassesSection.js +25 -3
- package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/IfcClassesSection.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/src/RenderMode.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/src/RenderMode.js +3 -15
- package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/src/RenderMode.js.map +1 -1
- package/dist/core/components/viewers/bim/src/ElementAppearance.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/ElementAppearance.js +4 -1
- package/dist/core/components/viewers/bim/src/ElementAppearance.js.map +1 -1
- package/dist/core/components/viewers/bim/src/Highlighter/index.d.ts +1 -0
- package/dist/core/components/viewers/bim/src/Highlighter/index.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/Highlighter/index.js +8 -2
- package/dist/core/components/viewers/bim/src/Highlighter/index.js.map +1 -1
- package/dist/core/components/viewers/bim/src/Selection/index.d.ts +1 -0
- package/dist/core/components/viewers/bim/src/Selection/index.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/Selection/index.js +8 -2
- package/dist/core/components/viewers/bim/src/Selection/index.js.map +1 -1
- package/dist/core/components/viewers/bim/src/ViewportGizmo.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/ViewportGizmo.js +2 -5
- package/dist/core/components/viewers/bim/src/ViewportGizmo.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/ViewSectionList.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/ViewSectionList.js +4 -3
- package/dist/core/components/viewers/bim/src/lib/ViewSectionList.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.d.ts +2 -2
- package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.js +2 -1
- package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/bimTree.d.ts +6 -0
- package/dist/core/components/viewers/bim/src/lib/bimTree.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/bimTree.js +29 -0
- package/dist/core/components/viewers/bim/src/lib/bimTree.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/clickGuard.d.ts +10 -0
- package/dist/core/components/viewers/bim/src/lib/clickGuard.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/lib/clickGuard.js +50 -0
- package/dist/core/components/viewers/bim/src/lib/clickGuard.js.map +1 -0
- package/dist/core/components/viewers/bim/src/lib/useBimTreeControls.d.ts +1 -1
- package/dist/core/components/viewers/bim/src/lib/useBimTreeControls.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/useBimTreeControls.js +3 -3
- package/dist/core/components/viewers/bim/src/lib/useBimTreeControls.js.map +1 -1
- package/dist/core/components/viewers/bim/src/propertiesMenu/index.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/propertiesMenu/index.js +25 -12
- package/dist/core/components/viewers/bim/src/propertiesMenu/index.js.map +1 -1
- package/dist/core/components/viewers/bim/src/propertiesMenu/src/fileIdentityGroup.d.ts +2 -0
- package/dist/core/components/viewers/bim/src/propertiesMenu/src/fileIdentityGroup.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/propertiesMenu/src/fileIdentityGroup.js +36 -7
- package/dist/core/components/viewers/bim/src/propertiesMenu/src/fileIdentityGroup.js.map +1 -1
- package/dist/core/components/viewers/bim/src/propertiesMenu/src/useElementProperties.d.ts +1 -1
- package/dist/core/components/viewers/bim/src/propertiesMenu/src/useElementProperties.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/propertiesMenu/src/useElementProperties.js +15 -19
- package/dist/core/components/viewers/bim/src/propertiesMenu/src/useElementProperties.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingsTools.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingsTools.js +36 -24
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingsTools.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/deletedModelIds.d.ts +6 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/deletedModelIds.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/deletedModelIds.js +8 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/deletedModelIds.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.js +60 -17
- package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.d.ts +8 -12
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.js +12 -14
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingColourExpression.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingPopupEntry.d.ts +12 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingPopupEntry.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingPopupEntry.js +18 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/buildingPopupEntry.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/drawnFootprints.d.ts +12 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/drawnFootprints.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/drawnFootprints.js +51 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/drawnFootprints.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.js +47 -48
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/osmIdExpression.d.ts +10 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/osmIdExpression.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/osmIdExpression.js +25 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/osmIdExpression.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/DrawnBuildingsLayer.d.ts +9 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/DrawnBuildingsLayer.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/DrawnBuildingsLayer.js +114 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/DrawnBuildingsLayer.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/FootprintEditor.d.ts +3 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/FootprintEditor.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/FootprintEditor.js +70 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/FootprintEditor.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/useViewBounds.d.ts +5 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/useViewBounds.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/useViewBounds.js +26 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/useViewBounds.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/useDatasetFeatures.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/useDatasetFeatures.js +2 -2
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/useDatasetFeatures.js.map +1 -1
- package/dist/core/components/viewers/map/src/Placement/resolveClickPlacement.d.ts +3 -0
- package/dist/core/components/viewers/map/src/Placement/resolveClickPlacement.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/Placement/resolveClickPlacement.js +10 -4
- package/dist/core/components/viewers/map/src/Placement/resolveClickPlacement.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddBuilding/BuildingAdder.d.ts +9 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/AddBuilding/BuildingAdder.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddBuilding/BuildingAdder.js +213 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/AddBuilding/BuildingAdder.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddBuilding/newBuilding.d.ts +16 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/AddBuilding/newBuilding.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/AddBuilding/newBuilding.js +34 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/AddBuilding/newBuilding.js.map +1 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/AddSite/SiteAdder.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddSite/SiteAdder.js +23 -268
- package/dist/core/components/viewers/map/src/tools/AddTools/AddSite/SiteAdder.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddToMap.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddToMap.js +7 -10
- package/dist/core/components/viewers/map/src/tools/AddTools/AddToMap.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/shared/ringEditing.d.ts +14 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/shared/ringEditing.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/shared/ringEditing.js +43 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/shared/ringEditing.js.map +1 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/shared/useMapToolSession.d.ts +17 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/shared/useMapToolSession.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/shared/useMapToolSession.js +52 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/shared/useMapToolSession.js.map +1 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/shared/usePolygonDraw.d.ts +40 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/shared/usePolygonDraw.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/shared/usePolygonDraw.js +245 -0
- package/dist/core/components/viewers/map/src/tools/AddTools/shared/usePolygonDraw.js.map +1 -0
- package/dist/core/components/viewers/map/src/tools/mapTools.d.ts +1 -1
- package/dist/core/components/viewers/map/src/tools/mapTools.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/tools/mapTools.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoder.d.ts +4 -0
- package/dist/core/components/viewers/map/utils/geocoder.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoder.js +14 -0
- package/dist/core/components/viewers/map/utils/geocoder.js.map +1 -1
- package/dist/core/components/viewers/map/utils/hasMapApi.d.ts +4 -0
- package/dist/core/components/viewers/map/utils/hasMapApi.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/hasMapApi.js +6 -0
- package/dist/core/components/viewers/map/utils/hasMapApi.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.js +2 -2
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.js.map +1 -1
- package/dist/core/components/viewers/map/utils/validateBounds.d.ts +2 -0
- package/dist/core/components/viewers/map/utils/validateBounds.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/validateBounds.js +5 -0
- package/dist/core/components/viewers/map/utils/validateBounds.js.map +1 -1
- package/dist/core/hooks/buildings/createBuildingHooks.d.ts.map +1 -1
- package/dist/core/hooks/buildings/createBuildingHooks.js +3 -2
- package/dist/core/hooks/buildings/createBuildingHooks.js.map +1 -1
- package/dist/core/hooks/files/createFileHooks.d.ts.map +1 -1
- package/dist/core/hooks/files/createFileHooks.js +4 -8
- package/dist/core/hooks/files/createFileHooks.js.map +1 -1
- package/dist/core/i18n/messages/en.json +52 -4
- package/dist/core/i18n/messages/es.json +52 -4
- package/dist/core/i18n/messages/fr.json +52 -4
- package/dist/core/plugins/host/runtimeShims.js +1 -0
- package/dist/core/plugins/host/runtimeShims.js.map +1 -1
- package/dist/core/plugins/sdk/data.d.ts +2 -0
- package/dist/core/plugins/sdk/data.d.ts.map +1 -1
- package/dist/core/plugins/sdk/data.js +2 -0
- package/dist/core/plugins/sdk/data.js.map +1 -1
- package/dist/core/plugins/sdk/user.d.ts +7 -0
- package/dist/core/plugins/sdk/user.d.ts.map +1 -0
- package/dist/core/plugins/sdk/user.js +14 -0
- package/dist/core/plugins/sdk/user.js.map +1 -0
- package/dist/core/store/Map/context.d.ts.map +1 -1
- package/dist/core/store/Map/context.js +1 -0
- package/dist/core/store/Map/context.js.map +1 -1
- package/dist/core/store/Map/reducer.d.ts +6 -0
- package/dist/core/store/Map/reducer.d.ts.map +1 -1
- package/dist/core/store/Map/reducer.js +4 -0
- package/dist/core/store/Map/reducer.js.map +1 -1
- package/dist/core/types/global.d.ts +1 -1
- package/dist/core/types/global.d.ts.map +1 -1
- package/dist/core/types/global.js.map +1 -1
- package/dist/core/utils/colourUtils.d.ts +5 -0
- package/dist/core/utils/colourUtils.d.ts.map +1 -1
- package/dist/core/utils/colourUtils.js +9 -0
- package/dist/core/utils/colourUtils.js.map +1 -1
- package/dist/core/utils/utils.d.ts +2 -0
- package/dist/core/utils/utils.d.ts.map +1 -1
- package/dist/core/utils/utils.js +5 -1
- package/dist/core/utils/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMapToolSession.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/map/src/tools/AddTools/shared/useMapToolSession.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAA;AACxF,OAAO,KAAK,KAAK,UAAU,MAAM,aAAa,CAAA;AAE9C,KAAK,YAAY,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,aAAa,KAAK,IAAI,CAAA;AAEzD,sIAAsI;AACtI,wBAAgB,iBAAiB,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE;IACnI,GAAG,EAAE,UAAU,CAAC,GAAG,GAAG,IAAI,GAAG,SAAS,CAAA;IACtC,eAAe,CAAC,EAAE,eAAe,GAAG,IAAI,CAAA;IACxC,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,YAAY,CAAA;IACrB,SAAS,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAA;IACrC,WAAW,CAAC,EAAE,YAAY,CAAA;IAC1B,WAAW,CAAC,EAAE,YAAY,CAAA;IAC1B,SAAS,CAAC,EAAE,YAAY,CAAA;CACzB,QA0CA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { hasMapApi } from "../../../../utils/hasMapApi";
|
|
3
|
+
function useMapToolSession({ map, mapClickManager, active, cursor, onClick, onKeyDown, onMouseDown, onMouseMove, onMouseUp }) {
|
|
4
|
+
const handlers = React.useRef({ cursor, onClick, onKeyDown, onMouseDown, onMouseMove, onMouseUp });
|
|
5
|
+
handlers.current = { cursor, onClick, onKeyDown, onMouseDown, onMouseMove, onMouseUp };
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
if (!active || !hasMapApi(map)) return;
|
|
8
|
+
map.getCanvas().style.cursor = cursor;
|
|
9
|
+
}, [active, map, cursor]);
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
if (!active || !hasMapApi(map)) return;
|
|
12
|
+
const canvas = map.getCanvas();
|
|
13
|
+
const holdCursor = () => {
|
|
14
|
+
if (canvas.style.cursor !== handlers.current.cursor) canvas.style.cursor = handlers.current.cursor;
|
|
15
|
+
};
|
|
16
|
+
const click = (e) => handlers.current.onClick(e);
|
|
17
|
+
const keyDown = (e) => handlers.current.onKeyDown(e);
|
|
18
|
+
const mouseDown = (e) => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
return (_b = (_a = handlers.current).onMouseDown) == null ? void 0 : _b.call(_a, e);
|
|
21
|
+
};
|
|
22
|
+
const mouseMove = (e) => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
(_b = (_a = handlers.current).onMouseMove) == null ? void 0 : _b.call(_a, e);
|
|
25
|
+
holdCursor();
|
|
26
|
+
};
|
|
27
|
+
const mouseUp = (e) => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
return (_b = (_a = handlers.current).onMouseUp) == null ? void 0 : _b.call(_a, e);
|
|
30
|
+
};
|
|
31
|
+
mapClickManager == null ? void 0 : mapClickManager.setSuspended(true);
|
|
32
|
+
holdCursor();
|
|
33
|
+
map.on("click", click);
|
|
34
|
+
map.on("mousedown", mouseDown);
|
|
35
|
+
map.on("mousemove", mouseMove);
|
|
36
|
+
map.on("mouseup", mouseUp);
|
|
37
|
+
window.addEventListener("keydown", keyDown);
|
|
38
|
+
return () => {
|
|
39
|
+
mapClickManager == null ? void 0 : mapClickManager.setSuspended(false);
|
|
40
|
+
canvas.style.cursor = "";
|
|
41
|
+
map.off("click", click);
|
|
42
|
+
map.off("mousedown", mouseDown);
|
|
43
|
+
map.off("mousemove", mouseMove);
|
|
44
|
+
map.off("mouseup", mouseUp);
|
|
45
|
+
window.removeEventListener("keydown", keyDown);
|
|
46
|
+
};
|
|
47
|
+
}, [active, map, mapClickManager]);
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
useMapToolSession
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=useMapToolSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/tools/AddTools/shared/useMapToolSession.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\n\nimport { hasMapApi } from '../../../../utils/hasMapApi'\n\nimport type { MapClickManager } from '../../../../utils/MapEventManager/MapClickManager'\nimport type * as maplibregl from 'maplibre-gl'\n\ntype MouseHandler = (e: maplibregl.MapMouseEvent) => void\n\n/** While active, pauses the map's click popups, holds the cursor, and sends map clicks, pointer moves and key presses to the tool. */\nexport function useMapToolSession({ map, mapClickManager, active, cursor, onClick, onKeyDown, onMouseDown, onMouseMove, onMouseUp }: {\n map: maplibregl.Map | null | undefined\n mapClickManager?: MapClickManager | null\n active: boolean\n cursor: string\n onClick: MouseHandler\n onKeyDown: (e: KeyboardEvent) => void\n onMouseDown?: MouseHandler\n onMouseMove?: MouseHandler\n onMouseUp?: MouseHandler\n}) {\n const handlers = React.useRef({ cursor, onClick, onKeyDown, onMouseDown, onMouseMove, onMouseUp })\n handlers.current = { cursor, onClick, onKeyDown, onMouseDown, onMouseMove, onMouseUp }\n\n React.useEffect(() => {\n if (!active || !hasMapApi(map)) return\n map.getCanvas().style.cursor = cursor\n }, [active, map, cursor])\n\n React.useEffect(() => {\n if (!active || !hasMapApi(map)) return\n\n const canvas = map.getCanvas()\n const holdCursor = () => {\n if (canvas.style.cursor !== handlers.current.cursor) canvas.style.cursor = handlers.current.cursor\n }\n const click = (e: maplibregl.MapMouseEvent) => handlers.current.onClick(e)\n const keyDown = (e: KeyboardEvent) => handlers.current.onKeyDown(e)\n const mouseDown = (e: maplibregl.MapMouseEvent) => handlers.current.onMouseDown?.(e)\n const mouseMove = (e: maplibregl.MapMouseEvent) => {\n handlers.current.onMouseMove?.(e)\n holdCursor()\n }\n const mouseUp = (e: maplibregl.MapMouseEvent) => handlers.current.onMouseUp?.(e)\n\n mapClickManager?.setSuspended(true)\n holdCursor()\n map.on('click', click)\n map.on('mousedown', mouseDown)\n map.on('mousemove', mouseMove)\n map.on('mouseup', mouseUp)\n window.addEventListener('keydown', keyDown)\n return () => {\n mapClickManager?.setSuspended(false)\n canvas.style.cursor = ''\n map.off('click', click)\n map.off('mousedown', mouseDown)\n map.off('mousemove', mouseMove)\n map.off('mouseup', mouseUp)\n window.removeEventListener('keydown', keyDown)\n }\n }, [active, map, mapClickManager])\n}\n"],"mappings":"AAGA,YAAY,WAAW;AAEvB,SAAS,iBAAiB;AAQnB,SAAS,kBAAkB,EAAE,KAAK,iBAAiB,QAAQ,QAAQ,SAAS,WAAW,aAAa,aAAa,UAAU,GAU/H;AACD,QAAM,WAAW,MAAM,OAAO,EAAE,QAAQ,SAAS,WAAW,aAAa,aAAa,UAAU,CAAC;AACjG,WAAS,UAAU,EAAE,QAAQ,SAAS,WAAW,aAAa,aAAa,UAAU;AAErF,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,UAAU,CAAC,UAAU,GAAG,EAAG;AAChC,QAAI,UAAU,EAAE,MAAM,SAAS;AAAA,EACjC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC;AAExB,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,UAAU,CAAC,UAAU,GAAG,EAAG;AAEhC,UAAM,SAAS,IAAI,UAAU;AAC7B,UAAM,aAAa,MAAM;AACvB,UAAI,OAAO,MAAM,WAAW,SAAS,QAAQ,OAAQ,QAAO,MAAM,SAAS,SAAS,QAAQ;AAAA,IAC9F;AACA,UAAM,QAAQ,CAAC,MAAgC,SAAS,QAAQ,QAAQ,CAAC;AACzE,UAAM,UAAU,CAAC,MAAqB,SAAS,QAAQ,UAAU,CAAC;AAClE,UAAM,YAAY,CAAC,MAA6B;AAzCpD;AAyCuD,kCAAS,SAAQ,gBAAjB,4BAA+B;AAAA;AAClF,UAAM,YAAY,CAAC,MAAgC;AA1CvD;AA2CM,2BAAS,SAAQ,gBAAjB,4BAA+B;AAC/B,iBAAW;AAAA,IACb;AACA,UAAM,UAAU,CAAC,MAA6B;AA9ClD;AA8CqD,kCAAS,SAAQ,cAAjB,4BAA6B;AAAA;AAE9E,uDAAiB,aAAa;AAC9B,eAAW;AACX,QAAI,GAAG,SAAS,KAAK;AACrB,QAAI,GAAG,aAAa,SAAS;AAC7B,QAAI,GAAG,aAAa,SAAS;AAC7B,QAAI,GAAG,WAAW,OAAO;AACzB,WAAO,iBAAiB,WAAW,OAAO;AAC1C,WAAO,MAAM;AACX,yDAAiB,aAAa;AAC9B,aAAO,MAAM,SAAS;AACtB,UAAI,IAAI,SAAS,KAAK;AACtB,UAAI,IAAI,aAAa,SAAS;AAC9B,UAAI,IAAI,aAAa,SAAS;AAC9B,UAAI,IAAI,WAAW,OAAO;AAC1B,aAAO,oBAAoB,WAAW,OAAO;AAAA,IAC/C;AAAA,EACF,GAAG,CAAC,QAAQ,KAAK,eAAe,CAAC;AACnC;","names":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { MapClickManager } from '../../../../utils/MapEventManager/MapClickManager';
|
|
2
|
+
import type { Ring } from '../../../MapLayers/src/SiteLayer/siteGeometry';
|
|
3
|
+
import type * as maplibregl from 'maplibre-gl';
|
|
4
|
+
/** Toast and error strings, so each tool words its own shape. */
|
|
5
|
+
export interface PolygonDrawLabels {
|
|
6
|
+
mapNotReady: string;
|
|
7
|
+
cancelled: string;
|
|
8
|
+
needThreePoints: string;
|
|
9
|
+
title: string;
|
|
10
|
+
readyTitle?: string;
|
|
11
|
+
hint: (count: number) => string;
|
|
12
|
+
readyHint?: (count: number) => string;
|
|
13
|
+
finish: string;
|
|
14
|
+
cancel: string;
|
|
15
|
+
}
|
|
16
|
+
type Translate = (key: string, values?: {
|
|
17
|
+
count: number;
|
|
18
|
+
}) => string;
|
|
19
|
+
/** Labels for a tool whose i18n namespace carries the shared `draw*` keys. */
|
|
20
|
+
export declare const toolDrawLabels: (t: Translate) => PolygonDrawLabels;
|
|
21
|
+
/** Rejecting keeps the drawing on the map so the user can retry finishing. */
|
|
22
|
+
export type FinishPolygon = (ring: Ring) => Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Click-to-place polygon drawing: Enter or the first corner finishes, Esc cancels. Corners drag,
|
|
25
|
+
* Ctrl+click on an edge inserts one, Delete removes the hovered corner or else the last one.
|
|
26
|
+
*/
|
|
27
|
+
export declare function usePolygonDraw({ map, mapClickManager, enabled, toastId, labels, onFinish, onCancel }: {
|
|
28
|
+
map: maplibregl.Map | null | undefined;
|
|
29
|
+
mapClickManager?: MapClickManager | null;
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
toastId: string;
|
|
32
|
+
labels: PolygonDrawLabels;
|
|
33
|
+
onFinish: FinishPolygon;
|
|
34
|
+
onCancel?: () => void;
|
|
35
|
+
}): {
|
|
36
|
+
isDrawing: boolean;
|
|
37
|
+
start: (initialRing?: Ring) => boolean;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=usePolygonDraw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePolygonDraw.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/map/src/tools/AddTools/shared/usePolygonDraw.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAA;AACxF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,+CAA+C,CAAA;AACzE,OAAO,KAAK,KAAK,UAAU,MAAM,aAAa,CAAA;AAM9C,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAC/B,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,KAAK,MAAM,CAAA;AAEpE,8EAA8E;AAC9E,eAAO,MAAM,cAAc,GAAI,GAAG,SAAS,KAAG,iBAU5C,CAAA;AAEF,8EAA8E;AAC9E,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAuEzD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;IACrG,GAAG,EAAE,UAAU,CAAC,GAAG,GAAG,IAAI,GAAG,SAAS,CAAA;IACtC,eAAe,CAAC,EAAE,eAAe,GAAG,IAAI,CAAA;IACxC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,iBAAiB,CAAA;IACzB,QAAQ,EAAE,aAAa,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;;0BA2C+C,IAAI,KAAQ,OAAO;EAyHlE"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { toast } from "sonner";
|
|
3
|
+
import { hasMapApi } from "../../../../utils/hasMapApi";
|
|
4
|
+
import { insertCorner, moveCorner, nearestCornerIndex, nearestEdgeIndex, removeCorner } from "./ringEditing";
|
|
5
|
+
import { useMapToolSession } from "./useMapToolSession";
|
|
6
|
+
const SOURCE_ID = "add-geojson";
|
|
7
|
+
const CORNER_PIXEL_THRESHOLD = 14;
|
|
8
|
+
const EDGE_PIXEL_THRESHOLD = 8;
|
|
9
|
+
const toolDrawLabels = (t) => ({
|
|
10
|
+
mapNotReady: t("mapNotReady"),
|
|
11
|
+
cancelled: t("drawCancelled"),
|
|
12
|
+
needThreePoints: t("needThreePoints"),
|
|
13
|
+
title: t("drawTitle"),
|
|
14
|
+
readyTitle: t("drawReadyTitle"),
|
|
15
|
+
hint: (count) => t("drawHint", { count }),
|
|
16
|
+
readyHint: (count) => t("drawReadyHint", { count }),
|
|
17
|
+
finish: t("finish"),
|
|
18
|
+
cancel: t("cancel")
|
|
19
|
+
});
|
|
20
|
+
function drawingFeatures(points, hoveredIndex) {
|
|
21
|
+
const closable = points.length >= 3;
|
|
22
|
+
const features = points.map((point, index) => ({
|
|
23
|
+
type: "Feature",
|
|
24
|
+
geometry: { type: "Point", coordinates: point },
|
|
25
|
+
properties: { isDrawPoint: true, closable: closable && index === 0, hovered: index === hoveredIndex }
|
|
26
|
+
}));
|
|
27
|
+
if (points.length > 1) {
|
|
28
|
+
features.push({
|
|
29
|
+
type: "Feature",
|
|
30
|
+
geometry: { type: "LineString", coordinates: closable ? [...points, points[0]] : points },
|
|
31
|
+
properties: { isDrawing: true }
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (closable) {
|
|
35
|
+
features.push({
|
|
36
|
+
type: "Feature",
|
|
37
|
+
geometry: { type: "Polygon", coordinates: [[...points, points[0]]] },
|
|
38
|
+
properties: { isDrawPreview: true }
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return { type: "FeatureCollection", features };
|
|
42
|
+
}
|
|
43
|
+
function addDrawingLayers(map) {
|
|
44
|
+
if (!map.getSource(SOURCE_ID)) {
|
|
45
|
+
map.addSource(SOURCE_ID, { type: "geojson", data: { type: "FeatureCollection", features: [] } });
|
|
46
|
+
}
|
|
47
|
+
if (!map.getLayer("add-draw-fill")) {
|
|
48
|
+
map.addLayer({
|
|
49
|
+
id: "add-draw-fill",
|
|
50
|
+
type: "fill",
|
|
51
|
+
source: SOURCE_ID,
|
|
52
|
+
paint: { "fill-color": "#3b82f6", "fill-opacity": 0.2 },
|
|
53
|
+
filter: ["all", ["in", "$type", "Polygon"], ["==", "isDrawPreview", true]]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (!map.getLayer("add-draw-points")) {
|
|
57
|
+
map.addLayer({
|
|
58
|
+
id: "add-draw-points",
|
|
59
|
+
type: "circle",
|
|
60
|
+
source: SOURCE_ID,
|
|
61
|
+
paint: {
|
|
62
|
+
"circle-radius": ["case", ["==", ["get", "closable"], true], 8, ["==", ["get", "hovered"], true], 7, 5],
|
|
63
|
+
"circle-color": ["case", ["==", ["get", "closable"], true], "#22c55e", ["==", ["get", "hovered"], true], "#3b82f6", "#ffffff"],
|
|
64
|
+
"circle-stroke-width": 2,
|
|
65
|
+
"circle-stroke-color": ["case", ["==", ["get", "closable"], true], "#15803d", "#000000"]
|
|
66
|
+
},
|
|
67
|
+
filter: ["all", ["in", "$type", "Point"], ["==", "isDrawPoint", true]]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (!map.getLayer("add-draw-lines")) {
|
|
71
|
+
map.addLayer({
|
|
72
|
+
id: "add-draw-lines",
|
|
73
|
+
type: "line",
|
|
74
|
+
source: SOURCE_ID,
|
|
75
|
+
layout: { "line-cap": "round", "line-join": "round" },
|
|
76
|
+
paint: { "line-color": "#fff", "line-width": 2.5, "line-dasharray": [2, 2] },
|
|
77
|
+
filter: ["all", ["in", "$type", "LineString"], ["==", "isDrawing", true]]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function usePolygonDraw({ map, mapClickManager, enabled, toastId, labels, onFinish, onCancel }) {
|
|
82
|
+
const [isDrawing, setIsDrawing] = React.useState(false);
|
|
83
|
+
const [isFinishing, setIsFinishing] = React.useState(false);
|
|
84
|
+
const [pointCount, setPointCount] = React.useState(0);
|
|
85
|
+
const [hoveredIndex, setHoveredIndex] = React.useState(-1);
|
|
86
|
+
const [draggingIndex, setDraggingIndex] = React.useState(-1);
|
|
87
|
+
const pointsRef = React.useRef([]);
|
|
88
|
+
const hoveredRef = React.useRef(-1);
|
|
89
|
+
const draggedRef = React.useRef(false);
|
|
90
|
+
const finishingRef = React.useRef(false);
|
|
91
|
+
const latest = React.useRef({ labels, onFinish, onCancel });
|
|
92
|
+
latest.current = { labels, onFinish, onCancel };
|
|
93
|
+
const render = React.useCallback(() => {
|
|
94
|
+
const source = map == null ? void 0 : map.getSource(SOURCE_ID);
|
|
95
|
+
void (source == null ? void 0 : source.setData(drawingFeatures(pointsRef.current, hoveredRef.current)));
|
|
96
|
+
}, [map]);
|
|
97
|
+
const hover = React.useCallback((index) => {
|
|
98
|
+
if (hoveredRef.current === index) return;
|
|
99
|
+
hoveredRef.current = index;
|
|
100
|
+
setHoveredIndex(index);
|
|
101
|
+
render();
|
|
102
|
+
}, [render]);
|
|
103
|
+
const commit = React.useCallback((points) => {
|
|
104
|
+
pointsRef.current = points;
|
|
105
|
+
if (hoveredRef.current >= points.length) {
|
|
106
|
+
hoveredRef.current = -1;
|
|
107
|
+
setHoveredIndex(-1);
|
|
108
|
+
}
|
|
109
|
+
setPointCount(points.length);
|
|
110
|
+
render();
|
|
111
|
+
}, [render]);
|
|
112
|
+
const stop = React.useCallback(() => {
|
|
113
|
+
hover(-1);
|
|
114
|
+
setDraggingIndex(-1);
|
|
115
|
+
commit([]);
|
|
116
|
+
setIsDrawing(false);
|
|
117
|
+
toast.dismiss(toastId);
|
|
118
|
+
}, [commit, hover, toastId]);
|
|
119
|
+
const start = React.useCallback((initialRing = []) => {
|
|
120
|
+
if (!hasMapApi(map)) {
|
|
121
|
+
toast.error(latest.current.labels.mapNotReady);
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
addDrawingLayers(map);
|
|
125
|
+
commit([...initialRing]);
|
|
126
|
+
setIsDrawing(true);
|
|
127
|
+
return true;
|
|
128
|
+
}, [map, commit]);
|
|
129
|
+
const cancel = React.useCallback(() => {
|
|
130
|
+
var _a, _b;
|
|
131
|
+
stop();
|
|
132
|
+
toast.info(latest.current.labels.cancelled);
|
|
133
|
+
(_b = (_a = latest.current).onCancel) == null ? void 0 : _b.call(_a);
|
|
134
|
+
}, [stop]);
|
|
135
|
+
const finish = React.useCallback(async () => {
|
|
136
|
+
if (finishingRef.current) return;
|
|
137
|
+
const ring = [...pointsRef.current];
|
|
138
|
+
if (ring.length < 3) {
|
|
139
|
+
toast.warning(latest.current.labels.needThreePoints);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
finishingRef.current = true;
|
|
143
|
+
setIsFinishing(true);
|
|
144
|
+
try {
|
|
145
|
+
await latest.current.onFinish(ring);
|
|
146
|
+
stop();
|
|
147
|
+
} catch (e) {
|
|
148
|
+
} finally {
|
|
149
|
+
finishingRef.current = false;
|
|
150
|
+
setIsFinishing(false);
|
|
151
|
+
}
|
|
152
|
+
}, [stop]);
|
|
153
|
+
const screenCorners = () => map ? pointsRef.current.map((point) => map.project(point)) : [];
|
|
154
|
+
const cornerAt = (e) => nearestCornerIndex(screenCorners(), e.point, CORNER_PIXEL_THRESHOLD);
|
|
155
|
+
const lngLatOf = (e) => [e.lngLat.lng, e.lngLat.lat];
|
|
156
|
+
const removeHoveredOrLast = () => {
|
|
157
|
+
const points = pointsRef.current;
|
|
158
|
+
const index = hoveredRef.current >= 0 ? hoveredRef.current : points.length - 1;
|
|
159
|
+
if (index >= 0) commit(removeCorner(points, index));
|
|
160
|
+
};
|
|
161
|
+
const placeCorner = (e) => {
|
|
162
|
+
const points = pointsRef.current;
|
|
163
|
+
const corner = cornerAt(e);
|
|
164
|
+
if (corner === 0 && points.length >= 3) {
|
|
165
|
+
void finish();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (corner >= 0) return;
|
|
169
|
+
const splitsEdge = e.originalEvent.ctrlKey || e.originalEvent.metaKey;
|
|
170
|
+
const edge = splitsEdge ? nearestEdgeIndex(screenCorners(), e.point, EDGE_PIXEL_THRESHOLD) : -1;
|
|
171
|
+
commit(edge >= 0 ? insertCorner(points, edge, lngLatOf(e)) : [...points, lngLatOf(e)]);
|
|
172
|
+
};
|
|
173
|
+
useMapToolSession({
|
|
174
|
+
map,
|
|
175
|
+
mapClickManager,
|
|
176
|
+
active: isDrawing && !isFinishing,
|
|
177
|
+
cursor: draggingIndex >= 0 ? "grabbing" : hoveredIndex >= 0 ? "grab" : "crosshair",
|
|
178
|
+
onMouseDown: (e) => {
|
|
179
|
+
const index = cornerAt(e);
|
|
180
|
+
if (index < 0) return;
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
draggedRef.current = false;
|
|
183
|
+
setDraggingIndex(index);
|
|
184
|
+
},
|
|
185
|
+
onMouseMove: (e) => {
|
|
186
|
+
const dragging = draggingIndex >= 0 && e.originalEvent.buttons !== 0;
|
|
187
|
+
if (!dragging) {
|
|
188
|
+
if (draggingIndex >= 0) setDraggingIndex(-1);
|
|
189
|
+
hover(cornerAt(e));
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
draggedRef.current = true;
|
|
193
|
+
commit(moveCorner(pointsRef.current, draggingIndex, lngLatOf(e)));
|
|
194
|
+
},
|
|
195
|
+
onMouseUp: () => setDraggingIndex(-1),
|
|
196
|
+
onClick: (e) => {
|
|
197
|
+
if (draggedRef.current) draggedRef.current = false;
|
|
198
|
+
else placeCorner(e);
|
|
199
|
+
},
|
|
200
|
+
onKeyDown: (e) => {
|
|
201
|
+
if (e.key === "Enter") {
|
|
202
|
+
e.preventDefault();
|
|
203
|
+
void finish();
|
|
204
|
+
} else if (e.key === "Escape") {
|
|
205
|
+
e.preventDefault();
|
|
206
|
+
cancel();
|
|
207
|
+
} else if (e.key === "Delete" || e.key === "Backspace") {
|
|
208
|
+
e.preventDefault();
|
|
209
|
+
removeHoveredOrLast();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
React.useEffect(() => {
|
|
214
|
+
if (!enabled && isDrawing) stop();
|
|
215
|
+
}, [enabled, isDrawing, stop]);
|
|
216
|
+
React.useEffect(() => {
|
|
217
|
+
var _a, _b;
|
|
218
|
+
if (!isDrawing || isFinishing) {
|
|
219
|
+
toast.dismiss(toastId);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const { labels: text } = latest.current;
|
|
223
|
+
const canFinish = pointCount >= 3;
|
|
224
|
+
const title = canFinish ? (_a = text.readyTitle) != null ? _a : text.title : text.title;
|
|
225
|
+
const hint = canFinish ? (_b = text.readyHint) != null ? _b : text.hint : text.hint;
|
|
226
|
+
toast.info(title, {
|
|
227
|
+
id: toastId,
|
|
228
|
+
description: hint(pointCount),
|
|
229
|
+
duration: Infinity,
|
|
230
|
+
action: canFinish ? { label: text.finish, onClick: () => {
|
|
231
|
+
void finish();
|
|
232
|
+
} } : void 0,
|
|
233
|
+
cancel: { label: text.cancel, onClick: cancel }
|
|
234
|
+
});
|
|
235
|
+
}, [isDrawing, isFinishing, pointCount, toastId, finish, cancel]);
|
|
236
|
+
React.useEffect(() => () => {
|
|
237
|
+
toast.dismiss(toastId);
|
|
238
|
+
}, [toastId]);
|
|
239
|
+
return { isDrawing, start };
|
|
240
|
+
}
|
|
241
|
+
export {
|
|
242
|
+
toolDrawLabels,
|
|
243
|
+
usePolygonDraw
|
|
244
|
+
};
|
|
245
|
+
//# sourceMappingURL=usePolygonDraw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/tools/AddTools/shared/usePolygonDraw.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\nimport { toast } from 'sonner'\n\nimport { hasMapApi } from '../../../../utils/hasMapApi'\n\nimport { insertCorner, moveCorner, nearestCornerIndex, nearestEdgeIndex, removeCorner } from './ringEditing'\nimport { useMapToolSession } from './useMapToolSession'\n\nimport type { MapClickManager } from '../../../../utils/MapEventManager/MapClickManager'\nimport type { Ring } from '../../../MapLayers/src/SiteLayer/siteGeometry'\nimport type * as maplibregl from 'maplibre-gl'\n\nconst SOURCE_ID = 'add-geojson'\nconst CORNER_PIXEL_THRESHOLD = 14\nconst EDGE_PIXEL_THRESHOLD = 8\n\n/** Toast and error strings, so each tool words its own shape. */\nexport interface PolygonDrawLabels {\n mapNotReady: string\n cancelled: string\n needThreePoints: string\n title: string\n readyTitle?: string\n hint: (count: number) => string\n readyHint?: (count: number) => string\n finish: string\n cancel: string\n}\n\ntype Translate = (key: string, values?: { count: number }) => string\n\n/** Labels for a tool whose i18n namespace carries the shared `draw*` keys. */\nexport const toolDrawLabels = (t: Translate): PolygonDrawLabels => ({\n mapNotReady: t('mapNotReady'),\n cancelled: t('drawCancelled'),\n needThreePoints: t('needThreePoints'),\n title: t('drawTitle'),\n readyTitle: t('drawReadyTitle'),\n hint: count => t('drawHint', { count }),\n readyHint: count => t('drawReadyHint', { count }),\n finish: t('finish'),\n cancel: t('cancel'),\n})\n\n/** Rejecting keeps the drawing on the map so the user can retry finishing. */\nexport type FinishPolygon = (ring: Ring) => Promise<void>\n\nfunction drawingFeatures(points: Ring, hoveredIndex: number): GeoJSON.FeatureCollection {\n const closable = points.length >= 3\n const features: GeoJSON.Feature[] = points.map((point, index) => ({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: point },\n properties: { isDrawPoint: true, closable: closable && index === 0, hovered: index === hoveredIndex },\n }))\n\n if (points.length > 1) {\n features.push({\n type: 'Feature',\n geometry: { type: 'LineString', coordinates: closable ? [...points, points[0]] : points },\n properties: { isDrawing: true },\n })\n }\n\n if (closable) {\n features.push({\n type: 'Feature',\n geometry: { type: 'Polygon', coordinates: [[...points, points[0]]] },\n properties: { isDrawPreview: true },\n })\n }\n\n return { type: 'FeatureCollection', features }\n}\n\nfunction addDrawingLayers(map: maplibregl.Map) {\n if (!map.getSource(SOURCE_ID)) {\n map.addSource(SOURCE_ID, { type: 'geojson', data: { type: 'FeatureCollection', features: [] } })\n }\n\n if (!map.getLayer('add-draw-fill')) {\n map.addLayer({\n id: 'add-draw-fill',\n type: 'fill',\n source: SOURCE_ID,\n paint: { 'fill-color': '#3b82f6', 'fill-opacity': 0.2 },\n filter: ['all', ['in', '$type', 'Polygon'], ['==', 'isDrawPreview', true]],\n })\n }\n\n if (!map.getLayer('add-draw-points')) {\n map.addLayer({\n id: 'add-draw-points',\n type: 'circle',\n source: SOURCE_ID,\n paint: {\n 'circle-radius': ['case', ['==', ['get', 'closable'], true], 8, ['==', ['get', 'hovered'], true], 7, 5],\n 'circle-color': ['case', ['==', ['get', 'closable'], true], '#22c55e', ['==', ['get', 'hovered'], true], '#3b82f6', '#ffffff'],\n 'circle-stroke-width': 2,\n 'circle-stroke-color': ['case', ['==', ['get', 'closable'], true], '#15803d', '#000000'],\n },\n filter: ['all', ['in', '$type', 'Point'], ['==', 'isDrawPoint', true]],\n })\n }\n\n if (!map.getLayer('add-draw-lines')) {\n map.addLayer({\n id: 'add-draw-lines',\n type: 'line',\n source: SOURCE_ID,\n layout: { 'line-cap': 'round', 'line-join': 'round' },\n paint: { 'line-color': '#fff', 'line-width': 2.5, 'line-dasharray': [2, 2] },\n filter: ['all', ['in', '$type', 'LineString'], ['==', 'isDrawing', true]],\n })\n }\n}\n\n/**\n * Click-to-place polygon drawing: Enter or the first corner finishes, Esc cancels. Corners drag,\n * Ctrl+click on an edge inserts one, Delete removes the hovered corner or else the last one.\n */\nexport function usePolygonDraw({ map, mapClickManager, enabled, toastId, labels, onFinish, onCancel }: {\n map: maplibregl.Map | null | undefined\n mapClickManager?: MapClickManager | null\n enabled: boolean\n toastId: string\n labels: PolygonDrawLabels\n onFinish: FinishPolygon\n onCancel?: () => void\n}) {\n const [isDrawing, setIsDrawing] = React.useState(false)\n const [isFinishing, setIsFinishing] = React.useState(false)\n const [pointCount, setPointCount] = React.useState(0)\n const [hoveredIndex, setHoveredIndex] = React.useState(-1)\n const [draggingIndex, setDraggingIndex] = React.useState(-1)\n const pointsRef = React.useRef<Ring>([])\n const hoveredRef = React.useRef(-1)\n const draggedRef = React.useRef(false)\n const finishingRef = React.useRef(false)\n const latest = React.useRef({ labels, onFinish, onCancel })\n latest.current = { labels, onFinish, onCancel }\n\n const render = React.useCallback(() => {\n const source = map?.getSource(SOURCE_ID) as maplibregl.GeoJSONSource | undefined\n void source?.setData(drawingFeatures(pointsRef.current, hoveredRef.current))\n }, [map])\n\n const hover = React.useCallback((index: number) => {\n if (hoveredRef.current === index) return\n hoveredRef.current = index\n setHoveredIndex(index)\n render()\n }, [render])\n\n const commit = React.useCallback((points: Ring) => {\n pointsRef.current = points\n if (hoveredRef.current >= points.length) {\n hoveredRef.current = -1\n setHoveredIndex(-1)\n }\n setPointCount(points.length)\n render()\n }, [render])\n\n const stop = React.useCallback(() => {\n hover(-1)\n setDraggingIndex(-1)\n commit([])\n setIsDrawing(false)\n toast.dismiss(toastId)\n }, [commit, hover, toastId])\n\n const start = React.useCallback((initialRing: Ring = []): boolean => {\n if (!hasMapApi(map)) {\n toast.error(latest.current.labels.mapNotReady)\n return false\n }\n addDrawingLayers(map)\n commit([...initialRing])\n setIsDrawing(true)\n return true\n }, [map, commit])\n\n const cancel = React.useCallback(() => {\n stop()\n toast.info(latest.current.labels.cancelled)\n latest.current.onCancel?.()\n }, [stop])\n\n const finish = React.useCallback(async () => {\n if (finishingRef.current) return\n const ring = [...pointsRef.current]\n if (ring.length < 3) {\n toast.warning(latest.current.labels.needThreePoints)\n return\n }\n finishingRef.current = true\n setIsFinishing(true)\n try {\n await latest.current.onFinish(ring)\n stop()\n }\n catch {\n // onFinish reports its own failure.\n }\n finally {\n finishingRef.current = false\n setIsFinishing(false)\n }\n }, [stop])\n\n const screenCorners = () => (map ? pointsRef.current.map(point => map.project(point)) : [])\n const cornerAt = (e: maplibregl.MapMouseEvent) => nearestCornerIndex(screenCorners(), e.point, CORNER_PIXEL_THRESHOLD)\n const lngLatOf = (e: maplibregl.MapMouseEvent): [number, number] => [e.lngLat.lng, e.lngLat.lat]\n\n const removeHoveredOrLast = () => {\n const points = pointsRef.current\n const index = hoveredRef.current >= 0 ? hoveredRef.current : points.length - 1\n if (index >= 0) commit(removeCorner(points, index))\n }\n\n const placeCorner = (e: maplibregl.MapMouseEvent) => {\n const points = pointsRef.current\n const corner = cornerAt(e)\n if (corner === 0 && points.length >= 3) {\n void finish()\n return\n }\n if (corner >= 0) return\n const splitsEdge = e.originalEvent.ctrlKey || e.originalEvent.metaKey\n const edge = splitsEdge ? nearestEdgeIndex(screenCorners(), e.point, EDGE_PIXEL_THRESHOLD) : -1\n commit(edge >= 0 ? insertCorner(points, edge, lngLatOf(e)) : [...points, lngLatOf(e)])\n }\n\n useMapToolSession({\n map,\n mapClickManager,\n active: isDrawing && !isFinishing,\n cursor: draggingIndex >= 0 ? 'grabbing' : hoveredIndex >= 0 ? 'grab' : 'crosshair',\n onMouseDown: (e) => {\n const index = cornerAt(e)\n if (index < 0) return\n e.preventDefault()\n draggedRef.current = false\n setDraggingIndex(index)\n },\n onMouseMove: (e) => {\n const dragging = draggingIndex >= 0 && e.originalEvent.buttons !== 0\n if (!dragging) {\n if (draggingIndex >= 0) setDraggingIndex(-1)\n hover(cornerAt(e))\n return\n }\n draggedRef.current = true\n commit(moveCorner(pointsRef.current, draggingIndex, lngLatOf(e)))\n },\n onMouseUp: () => setDraggingIndex(-1),\n onClick: (e) => {\n if (draggedRef.current) draggedRef.current = false\n else placeCorner(e)\n },\n onKeyDown: (e) => {\n if (e.key === 'Enter') { e.preventDefault(); void finish() }\n else if (e.key === 'Escape') { e.preventDefault(); cancel() }\n else if (e.key === 'Delete' || e.key === 'Backspace') { e.preventDefault(); removeHoveredOrLast() }\n },\n })\n\n React.useEffect(() => {\n if (!enabled && isDrawing) stop()\n }, [enabled, isDrawing, stop])\n\n React.useEffect(() => {\n if (!isDrawing || isFinishing) {\n toast.dismiss(toastId)\n return\n }\n const { labels: text } = latest.current\n const canFinish = pointCount >= 3\n const title = canFinish ? text.readyTitle ?? text.title : text.title\n const hint = canFinish ? text.readyHint ?? text.hint : text.hint\n toast.info(title, {\n id: toastId,\n description: hint(pointCount),\n duration: Infinity,\n action: canFinish ? { label: text.finish, onClick: () => { void finish() } } : undefined,\n cancel: { label: text.cancel, onClick: cancel },\n })\n }, [isDrawing, isFinishing, pointCount, toastId, finish, cancel])\n\n React.useEffect(() => () => { toast.dismiss(toastId) }, [toastId])\n\n return { isDrawing, start }\n}\n"],"mappings":"AAGA,YAAY,WAAW;AACvB,SAAS,aAAa;AAEtB,SAAS,iBAAiB;AAE1B,SAAS,cAAc,YAAY,oBAAoB,kBAAkB,oBAAoB;AAC7F,SAAS,yBAAyB;AAMlC,MAAM,YAAY;AAClB,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB;AAkBtB,MAAM,iBAAiB,CAAC,OAAqC;AAAA,EAClE,aAAa,EAAE,aAAa;AAAA,EAC5B,WAAW,EAAE,eAAe;AAAA,EAC5B,iBAAiB,EAAE,iBAAiB;AAAA,EACpC,OAAO,EAAE,WAAW;AAAA,EACpB,YAAY,EAAE,gBAAgB;AAAA,EAC9B,MAAM,WAAS,EAAE,YAAY,EAAE,MAAM,CAAC;AAAA,EACtC,WAAW,WAAS,EAAE,iBAAiB,EAAE,MAAM,CAAC;AAAA,EAChD,QAAQ,EAAE,QAAQ;AAAA,EAClB,QAAQ,EAAE,QAAQ;AACpB;AAKA,SAAS,gBAAgB,QAAc,cAAiD;AACtF,QAAM,WAAW,OAAO,UAAU;AAClC,QAAM,WAA8B,OAAO,IAAI,CAAC,OAAO,WAAW;AAAA,IAChE,MAAM;AAAA,IACN,UAAU,EAAE,MAAM,SAAS,aAAa,MAAM;AAAA,IAC9C,YAAY,EAAE,aAAa,MAAM,UAAU,YAAY,UAAU,GAAG,SAAS,UAAU,aAAa;AAAA,EACtG,EAAE;AAEF,MAAI,OAAO,SAAS,GAAG;AACrB,aAAS,KAAK;AAAA,MACZ,MAAM;AAAA,MACN,UAAU,EAAE,MAAM,cAAc,aAAa,WAAW,CAAC,GAAG,QAAQ,OAAO,CAAC,CAAC,IAAI,OAAO;AAAA,MACxF,YAAY,EAAE,WAAW,KAAK;AAAA,IAChC,CAAC;AAAA,EACH;AAEA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,QAAQ,KAAK;AAC/D,UAAM,OAAO,aAAY,UAAK,cAAL,YAAkB,KAAK,OAAO,KAAK;AAC5D,UAAM,KAAK,OAAO;AAAA,MAChB,IAAI;AAAA,MACJ,aAAa,KAAK,UAAU;AAAA,MAC5B,UAAU;AAAA,MACV,QAAQ,YAAY,EAAE,OAAO,KAAK,QAAQ,SAAS,MAAM;AAAE,aAAK,OAAO;AAAA,MAAE,EAAE,IAAI;AAAA,MAC/E,QAAQ,EAAE,OAAO,KAAK,QAAQ,SAAS,OAAO;AAAA,IAChD,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,aAAa,YAAY,SAAS,QAAQ,MAAM,CAAC;AAEhE,QAAM,UAAU,MAAM,MAAM;AAAE,UAAM,QAAQ,OAAO;AAAA,EAAE,GAAG,CAAC,OAAO,CAAC;AAEjE,SAAO,EAAE,WAAW,MAAM;AAC5B;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Organization } from '../../../../../types/dbTypes';
|
|
2
2
|
import type { Tool } from '../../../../../types/tools';
|
|
3
|
-
export type MapToolbarToolType = 'map-dimensions' | 'map-media' | 'map-compare' | 'map-database' | 'map-add' | 'map-add-comment' | 'map-add-dataset' | 'map-add-site' | 'map-add-building' | 'map-add-sensor' | 'map-add-file' | 'map-measure' | 'map-share' | 'map-compare-buildings' | 'open-building-page' | 'open-bim-viewer';
|
|
3
|
+
export type MapToolbarToolType = 'map-dimensions' | 'map-media' | 'map-compare' | 'map-database' | 'map-add' | 'map-add-comment' | 'map-add-dataset' | 'map-add-site' | 'map-add-building' | 'map-add-sensor' | 'map-add-file' | 'map-measure' | 'map-share' | 'map-compare-buildings' | 'open-building-page' | 'open-bim-viewer' | 'map-edit-footprint';
|
|
4
4
|
type MapToolsConfig = {
|
|
5
5
|
martinBaseUrl?: string;
|
|
6
6
|
minioBaseUrl?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapTools.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/src/tools/mapTools.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AAOtD,MAAM,MAAM,kBAAkB,GAC9B,gBAAgB,GAChB,WAAW,GACX,aAAa,GACb,cAAc,GACd,SAAS,GACT,iBAAiB,GACjB,iBAAiB,GACjB,cAAc,GACd,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,GACd,aAAa,GACb,WAAW,GACX,uBAAuB,GACvB,oBAAoB,GACpB,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"mapTools.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/src/tools/mapTools.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AAOtD,MAAM,MAAM,kBAAkB,GAC9B,gBAAgB,GAChB,WAAW,GACX,aAAa,GACb,cAAc,GACd,SAAS,GACT,iBAAiB,GACjB,iBAAiB,GACjB,cAAc,GACd,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,GACd,aAAa,GACb,WAAW,GACX,uBAAuB,GACvB,oBAAoB,GACpB,iBAAiB,GACjB,oBAAoB,CAAA;AAEpB,KAAK,cAAc,GAAG;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAGD,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,EAAE,CA2ClE;AAED,gGAAgG;AAChG,eAAO,MAAM,eAAe,2BAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/tools/mapTools.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as LR from 'lucide-react'\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\n\nimport { usePluginToolbarTools } from '../../../../../plugins/host/usePluginToolbarTools'\nimport { useMapViewer } from '../../../../../plugins/sdk/mapViewer'\n// Utilities\nimport Compare from '../compare'\n\nimport AddToMap from './AddTools/AddToMap'\nimport DatasetMapTool from './DatasetMapTool'\nimport { MeasureMapTool } from './measureMapTool'\nimport { ShareMapTool } from './shareMapTool'\n\nimport type { Organization } from '../../../../../types/dbTypes'\nimport type { Tool } from '../../../../../types/tools'\n\n// Icons\n\n// Custom toolbar buttons\n\n\nexport type MapToolbarToolType =\n'map-dimensions' |\n'map-media' |\n'map-compare' |\n'map-database' |\n'map-add' |\n'map-add-comment' |\n'map-add-dataset' |\n'map-add-site' |\n'map-add-building' |\n'map-add-sensor' |\n'map-add-file' |\n'map-measure' |\n'map-share' |\n'map-compare-buildings' |\n'open-building-page' |\n'open-bim-viewer'\n\ntype MapToolsConfig = {\n martinBaseUrl?: string\n minioBaseUrl?: string\n organization?: Organization\n geocodeEarthApiKey?: string\n geocoderUrl?: string\n}\n\n// Export toolbar configuration\nexport function useMapToolbarTools(config?: MapToolsConfig): Tool[] {\n // Translation\n const t = useTranslations('mapToolbarTools')\n\n const extraProps = (config ?? {}) as unknown as Record<string, unknown>\n\n // Map plugin tools get the MapLibre handle as `MapToolProps`, alongside the\n // same config core tools receive. Imported from `sdk/mapViewer`, not the\n // `sdk/viewer` barrel, so the BIM engine stays out of this eager bundle.\n // Memoized: a fresh object every render would recompute the tool list each time.\n const viewer = useMapViewer()\n const pluginProps = React.useMemo(\n () => ({ ...extraProps, ...viewer }),\n [extraProps, viewer],\n )\n const pluginTools = usePluginToolbarTools('map.tools', pluginProps)\n\n return [\n { id: 'map-compare', title: t('compareTitle'), url: '/', icon: LR.Columns3, component: Compare },\n { id: 'map-database', title: t('datasetsTitle'), url: '/', icon: LR.Database, component: DatasetMapTool, extraProps },\n {\n id: 'map-add',\n title: t('addTitle'),\n icon: LR.Plus,\n component: AddToMap,\n extraProps,\n },\n {\n id: 'map-measure',\n title: t('measureTitle'),\n icon: LR.Ruler,\n cursor: 'crosshair',\n stayActive: true,\n component: MeasureMapTool,\n },\n { id: 'map-share',\n title: t('shareTitle'),\n icon: LR.Share2,\n component: ShareMapTool,\n },\n // Plugin-contributed tools come last, after everything core ships.\n ...pluginTools,\n ]\n}\n\n/** @deprecated Renamed to useMapToolbarTools; it is a hook and must be called during render. */\nexport const mapToolbarTools = useMapToolbarTools\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,YAAY,QAAQ;AACpB,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAE7B,OAAO,aAAa;AAEpB,OAAO,cAAc;AACrB,OAAO,oBAAoB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/tools/mapTools.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as LR from 'lucide-react'\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\n\nimport { usePluginToolbarTools } from '../../../../../plugins/host/usePluginToolbarTools'\nimport { useMapViewer } from '../../../../../plugins/sdk/mapViewer'\n// Utilities\nimport Compare from '../compare'\n\nimport AddToMap from './AddTools/AddToMap'\nimport DatasetMapTool from './DatasetMapTool'\nimport { MeasureMapTool } from './measureMapTool'\nimport { ShareMapTool } from './shareMapTool'\n\nimport type { Organization } from '../../../../../types/dbTypes'\nimport type { Tool } from '../../../../../types/tools'\n\n// Icons\n\n// Custom toolbar buttons\n\n\nexport type MapToolbarToolType =\n'map-dimensions' |\n'map-media' |\n'map-compare' |\n'map-database' |\n'map-add' |\n'map-add-comment' |\n'map-add-dataset' |\n'map-add-site' |\n'map-add-building' |\n'map-add-sensor' |\n'map-add-file' |\n'map-measure' |\n'map-share' |\n'map-compare-buildings' |\n'open-building-page' |\n'open-bim-viewer' |\n'map-edit-footprint'\n\ntype MapToolsConfig = {\n martinBaseUrl?: string\n minioBaseUrl?: string\n organization?: Organization\n geocodeEarthApiKey?: string\n geocoderUrl?: string\n}\n\n// Export toolbar configuration\nexport function useMapToolbarTools(config?: MapToolsConfig): Tool[] {\n // Translation\n const t = useTranslations('mapToolbarTools')\n\n const extraProps = (config ?? {}) as unknown as Record<string, unknown>\n\n // Map plugin tools get the MapLibre handle as `MapToolProps`, alongside the\n // same config core tools receive. Imported from `sdk/mapViewer`, not the\n // `sdk/viewer` barrel, so the BIM engine stays out of this eager bundle.\n // Memoized: a fresh object every render would recompute the tool list each time.\n const viewer = useMapViewer()\n const pluginProps = React.useMemo(\n () => ({ ...extraProps, ...viewer }),\n [extraProps, viewer],\n )\n const pluginTools = usePluginToolbarTools('map.tools', pluginProps)\n\n return [\n { id: 'map-compare', title: t('compareTitle'), url: '/', icon: LR.Columns3, component: Compare },\n { id: 'map-database', title: t('datasetsTitle'), url: '/', icon: LR.Database, component: DatasetMapTool, extraProps },\n {\n id: 'map-add',\n title: t('addTitle'),\n icon: LR.Plus,\n component: AddToMap,\n extraProps,\n },\n {\n id: 'map-measure',\n title: t('measureTitle'),\n icon: LR.Ruler,\n cursor: 'crosshair',\n stayActive: true,\n component: MeasureMapTool,\n },\n { id: 'map-share',\n title: t('shareTitle'),\n icon: LR.Share2,\n component: ShareMapTool,\n },\n // Plugin-contributed tools come last, after everything core ships.\n ...pluginTools,\n ]\n}\n\n/** @deprecated Renamed to useMapToolbarTools; it is a hook and must be called during render. */\nexport const mapToolbarTools = useMapToolbarTools\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,YAAY,QAAQ;AACpB,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAE7B,OAAO,aAAa;AAEpB,OAAO,cAAc;AACrB,OAAO,oBAAoB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAsCtB,SAAS,mBAAmB,QAAiC;AAElE,QAAM,IAAI,gBAAgB,iBAAiB;AAE3C,QAAM,aAAc,0BAAU,CAAC;AAM/B,QAAM,SAAS,aAAa;AAC5B,QAAM,cAAc,MAAM;AAAA,IACxB,MAAO,kCAAK,aAAe;AAAA,IAC3B,CAAC,YAAY,MAAM;AAAA,EACrB;AACA,QAAM,cAAc,sBAAsB,aAAa,WAAW;AAElE,SAAO;AAAA,IACL,EAAE,IAAI,eAAe,OAAO,EAAE,cAAc,GAAG,KAAK,KAAK,MAAM,GAAG,UAAU,WAAW,QAAQ;AAAA,IAC/F,EAAE,IAAI,gBAAgB,OAAO,EAAE,eAAe,GAAG,KAAK,KAAK,MAAM,GAAG,UAAU,WAAW,gBAAgB,WAAW;AAAA,IACpH;AAAA,MACE,IAAI;AAAA,MACJ,OAAO,EAAE,UAAU;AAAA,MACnB,MAAM,GAAG;AAAA,MACT,WAAW;AAAA,MACX;AAAA,IACF;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,OAAO,EAAE,cAAc;AAAA,MACvB,MAAM,GAAG;AAAA,MACT,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,WAAW;AAAA,IACb;AAAA,IACA;AAAA,MAAE,IAAI;AAAA,MACJ,OAAO,EAAE,YAAY;AAAA,MACrB,MAAM,GAAG;AAAA,MACT,WAAW;AAAA,IACb;AAAA;AAAA,IAEA,GAAG;AAAA,EACL;AACF;AAGO,MAAM,kBAAkB;","names":[]}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import type { Building } from '../../../../types/dbTypes';
|
|
1
2
|
import type { Feature } from 'geojson';
|
|
3
|
+
export type AddressFields = Partial<Pick<Building, 'buildingAddress' | 'buildingStreetName' | 'buildingCountrySubdivision' | 'buildingMunicipality' | 'buildingPostalCode'>>;
|
|
4
|
+
/** Maps a geocoder place (forward or reverse) onto a building's address columns. */
|
|
5
|
+
export declare function addressFieldsFromPlace(properties: Record<string, unknown> | null | undefined, label: string): AddressFields;
|
|
2
6
|
export declare const getMunicipalityAndProvince: (latitude: string, longitude: string, countryCode?: string) => Promise<{
|
|
3
7
|
municipality: any;
|
|
4
8
|
countrySubdivision: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geocoder.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/map/utils/geocoder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"geocoder.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/map/utils/geocoder.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAS,MAAM,SAAS,CAAA;AAE7C,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,EAC/C,iBAAiB,GAAG,oBAAoB,GAAG,4BAA4B,GAAG,sBAAsB,GAAG,oBAAoB,CAAC,CAAC,CAAA;AAK3H,oFAAoF;AACpF,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAS3H;AAcD,eAAO,MAAM,0BAA0B,GAAU,UAAU,MAAM,EAAE,WAAW,MAAM,EAAE,cAAc,MAAM;;;EAmBzG,CAAA;AAGD,eAAO,MAAM,gBAAgB,GAAU,OAAO,MAAM,EAAE,cAAc,MAAM;;KAYzE,CAAA;AAGD,eAAO,MAAM,aAAa,GAAI,SAAS,OAAO;;;;CAoC7C,CAAA;AAGD,eAAO,MAAM,oBAAoB,GAAI,SAAS,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,EAAE,UAAU;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwFrI,CAAA;AAGD,eAAO,MAAM,kBAAkB,GAAU,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc,MAAM;;GAc3F,CAAA;AAGD,eAAO,MAAM,iBAAiB,GAAI,aAAQ;;;;;;;;;;;;;;;CAgCzC,CAAA"}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
+
import { withoutUndefined } from "../../../../utils/utils";
|
|
1
2
|
import { autocompleteGeocode, reverseGeocode } from "./geocoding";
|
|
2
3
|
import { MarkerManager } from "./MarkerManager";
|
|
4
|
+
const text = (value) => typeof value === "string" && value.trim() ? value : void 0;
|
|
5
|
+
function addressFieldsFromPlace(properties, label) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const place = properties != null ? properties : {};
|
|
8
|
+
return withoutUndefined({
|
|
9
|
+
buildingAddress: text(label),
|
|
10
|
+
buildingStreetName: text(place.street),
|
|
11
|
+
buildingCountrySubdivision: (_a = text(place.region_a)) != null ? _a : text(place.region),
|
|
12
|
+
buildingMunicipality: (_b = text(place.locality)) != null ? _b : text(place.county),
|
|
13
|
+
buildingPostalCode: text(place.postalcode)
|
|
14
|
+
});
|
|
15
|
+
}
|
|
3
16
|
let geocoderMarkerManager = null;
|
|
4
17
|
const getGeocoderMarkerManager = () => {
|
|
5
18
|
if (!geocoderMarkerManager) {
|
|
@@ -179,6 +192,7 @@ const buildingToFeature = (building) => {
|
|
|
179
192
|
};
|
|
180
193
|
};
|
|
181
194
|
export {
|
|
195
|
+
addressFieldsFromPlace,
|
|
182
196
|
buildingToFeature,
|
|
183
197
|
fetchSuggestions,
|
|
184
198
|
getDetailedAddress,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/core/components/viewers/map/utils/geocoder.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { autocompleteGeocode, reverseGeocode } from './geocoding'\nimport { MarkerManager } from './MarkerManager'\n\nimport type { Feature, Point } from 'geojson'\n\n// Global marker manager instance for geocoder\nlet geocoderMarkerManager: MarkerManager | null = null\n\n// Helper function to get or create the marker manager\nconst getGeocoderMarkerManager = (): MarkerManager => {\n if (!geocoderMarkerManager) {\n geocoderMarkerManager = new MarkerManager()\n }\n return geocoderMarkerManager\n}\n\n// Convert longitude and latitude into Municipality and Country Subdivision\nexport const getMunicipalityAndProvince = async (latitude: string, longitude: string, countryCode?: string) => {\n try {\n const features = await reverseGeocode(latitude, longitude, countryCode, { size: 1, coarse: true })\n\n if (features.length > 0) {\n const properties = features[0].properties as any\n\n const municipality = properties.locality || properties.neighbourhood || properties.county || ''\n const countrySubdivision = properties.region_a || properties.region || '' // region_a gives abbreviation like \"ON\", \"BC\"\n\n return { municipality, countrySubdivision }\n }\n\n return { municipality: '', countrySubdivision: '' }\n }\n catch (error) {\n console.error('Error fetching municipality and country subdivision:', error)\n return { municipality: '', countrySubdivision: '' }\n }\n}\n\n// Fetch address suggestions from the active autocomplete provider\nexport const fetchSuggestions = async (input: string, countryCode?: string) => {\n if (!input || input.length < 3) {\n return []\n }\n\n try {\n return await autocompleteGeocode(input, countryCode, 5)\n }\n catch (error) {\n console.error('Error fetching address suggestions:', error)\n return []\n }\n}\n\n// Parse location details for better display\nexport const parseLocation = (feature: Feature) => {\n const locationName = feature.properties?.name || ''\n const fullLabel = feature.properties?.label || ''\n\n // Try to extract location details from properties\n const properties = feature.properties\n let regionDetails = ''\n\n if (properties) {\n const locality = properties.locality\n const region = properties.region // Full countrySubdivision name\n const region_a = properties.region_a // CountrySubdivision abbreviation (ON, BC, etc.)\n const country = properties.country\n const country_a = properties.country_a // Country abbreviation (CA)\n\n // Build region details similar to your original format\n if (locality && region_a && country_a) {\n regionDetails = `${locality}, ${region_a}, ${country_a}`\n }\n else if (locality && region && country) {\n regionDetails = `${locality}, ${region}, ${country}`\n }\n else {\n // Fallback: try to extract from the full label\n const parts = fullLabel.split(', ')\n if (parts.length > 1) {\n regionDetails = parts.slice(1, 3).join(', ')\n }\n }\n }\n\n return {\n name: locationName,\n region: regionDetails,\n fullLabel: fullLabel,\n }\n}\n\n// Handle suggestion selection and map movement\nexport const handleLocationSelect = (feature: Feature, map: any, type: string, options?: { editing?: boolean; onMoveEnd?: () => void }) => {\n const editing = options?.editing || false\n const listenForMoveEnd = () => { if (options?.onMoveEnd) map.once('moveend', options.onMoveEnd) }\n const markerManager = getGeocoderMarkerManager()\n\n // Handle feature with is_database_building flag\n if (type === 'dbBuilding') {\n const geometry = feature.geometry as Point\n const center = geometry.coordinates\n const addressData = {\n formatted_address: feature.properties?.label || '',\n coordinates: center,\n properties: feature.properties,\n building_id: feature.properties.gid?.replace('building-', ''),\n is_database_building: true,\n }\n\n if (map && center) {\n // Add marker to the center with editing capability\n // markerManager.create(center as [number, number], map)\n\n listenForMoveEnd()\n map.flyTo({\n center: addressData.coordinates,\n zoom: 18,\n speed: 1.5,\n })\n }\n\n return addressData\n }\n\n // Calculate center coordinates\n let center\n\n // Use bbox if available (more precise for areas)\n if (feature.bbox) {\n center = [\n feature.bbox[0] + (feature.bbox[2] - feature.bbox[0]) / 2,\n feature.bbox[1] + (feature.bbox[3] - feature.bbox[1]) / 2,\n ]\n }\n // Otherwise extract coordinates based on geometry type\n else if (feature.geometry?.type === 'Point') {\n center = (feature.geometry as any).coordinates\n }\n\n const addressData = {\n formatted_address: feature.properties?.label || feature.properties?.name || '',\n coordinates: center,\n properties: feature.properties,\n address_details: {\n name: feature.properties?.name,\n label: feature.properties?.label,\n locality: feature.properties?.locality,\n neighbourhood: feature.properties?.neighbourhood,\n region: feature.properties?.region,\n region_a: feature.properties?.region_a,\n country: feature.properties?.country,\n country_a: feature.properties?.country_a,\n postalcode: feature.properties?.postalcode,\n housenumber: feature.properties?.housenumber,\n street: feature.properties?.street,\n },\n geocode_earth_id: feature.properties?.gid, // Geocode Earth's unique id\n layer: feature.properties?.layer, // Type of place (address, venue, locality, etc.)\n confidence: feature.properties?.confidence, // Geocode Earth's confidence score\n match_type: feature.properties?.match_type, // How well the result matches the query\n }\n\n if (map && center) {\n // Add marker to the center with editing capability\n // markerManager.create(center as [number, number], map, { editing })\n\n listenForMoveEnd()\n if (feature.bbox) {\n map.fitBounds(feature.bbox, { speed: 2 })\n }\n else {\n map.flyTo({\n center: addressData.coordinates,\n zoom: 14, // Might be good idea to set zoom level depending on layer / type of place\n speed: 2,\n })\n }\n }\n\n return addressData\n}\n\n// Util function to get detailed address information\nexport const getDetailedAddress = async (coordinates: [number, number], countryCode?: string) => {\n const [longitude, latitude] = coordinates\n\n try {\n // Restrict to address-layer results (the original popover used layers=address) so\n // callers get a street address rather than the nearest venue/POI. Nominatim's zoom-18\n // reverse is already building-level, so this only refines the Pelias path.\n const features = await reverseGeocode(latitude.toString(), longitude.toString(), countryCode, { size: 1, layers: 'address' })\n return features.length > 0 ? features[0] : null\n }\n catch (error) {\n console.error('Error fetching detailed address:', error)\n return null\n }\n}\n\n// Convert a building object to a GeoJSON feature format compatible with handleLocationSelect\nexport const buildingToFeature = (building) => {\n const name = building.buildingName || ''\n\n // Validate coordinates - use the correct property names\n const longitude = Number.parseFloat(building.buildingLongitude)\n const latitude = Number.parseFloat(building.buildingLatitude)\n\n if (isNaN(longitude) || isNaN(latitude)) {\n console.error('Invalid building coordinates:', {\n longitude: building.buildingLongitude,\n latitude: building.buildingLatitude,\n buildingId: building.id,\n })\n return null\n }\n\n return {\n properties: {\n name: name,\n label: `${name}, ${[building.buildingAddress, building.buildingMunicipality, building.buildingCountrySubdivision].filter(Boolean).join(', ')}`,\n address: building.buildingAddress,\n municipality: building.buildingMunicipality,\n countrySubdivision: building.buildingCountrySubdivision,\n postalCode: building.buildingPostalCode,\n gid: `building-${building.id}`,\n },\n geometry: {\n type: 'Point',\n coordinates: [longitude, latitude],\n },\n is_database_building: true,\n }\n}\n\n// // Enhanced marker creation with editing capabilities\n// export const createGeocoderMarker = (coordinates: [number, number], map: any, options?: { editing?: boolean }) => {\n// const editing = options?.editing || false\n// const markerManager = getGeocoderMarkerManager()\n// markerManager.create(coordinates, map, { editing })\n// return markerManager\n// }\n\n// Helper function to remove the current marker\n// export const removeGeocoderMarker = (): void => {\n// const markerManager = getGeocoderMarkerManager()\n// markerManager.remove()\n// }\n"],"mappings":"AAGA,SAAS,qBAAqB,sBAAsB;AACpD,SAAS,qBAAqB;AAK9B,IAAI,wBAA8C;AAGlD,MAAM,2BAA2B,MAAqB;AACpD,MAAI,CAAC,uBAAuB;AAC1B,4BAAwB,IAAI,cAAc;AAAA,EAC5C;AACA,SAAO;AACT;AAGO,MAAM,6BAA6B,OAAO,UAAkB,WAAmB,gBAAyB;AAC7G,MAAI;AACF,UAAM,WAAW,MAAM,eAAe,UAAU,WAAW,aAAa,EAAE,MAAM,GAAG,QAAQ,KAAK,CAAC;AAEjG,QAAI,SAAS,SAAS,GAAG;AACvB,YAAM,aAAa,SAAS,CAAC,EAAE;AAE/B,YAAM,eAAe,WAAW,YAAY,WAAW,iBAAiB,WAAW,UAAU;AAC7F,YAAM,qBAAqB,WAAW,YAAY,WAAW,UAAU;AAEvE,aAAO,EAAE,cAAc,mBAAmB;AAAA,IAC5C;AAEA,WAAO,EAAE,cAAc,IAAI,oBAAoB,GAAG;AAAA,EACpD,SACO,OAAO;AACZ,YAAQ,MAAM,wDAAwD,KAAK;AAC3E,WAAO,EAAE,cAAc,IAAI,oBAAoB,GAAG;AAAA,EACpD;AACF;AAGO,MAAM,mBAAmB,OAAO,OAAe,gBAAyB;AAC7E,MAAI,CAAC,SAAS,MAAM,SAAS,GAAG;AAC9B,WAAO,CAAC;AAAA,EACV;AAEA,MAAI;AACF,WAAO,MAAM,oBAAoB,OAAO,aAAa,CAAC;AAAA,EACxD,SACO,OAAO;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BAAsB,SAAS,0BAA0B,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI,CAAC;AAAA,MAC5I,SAAS,SAAS;AAAA,MAClB,cAAc,SAAS;AAAA,MACvB,oBAAoB,SAAS;AAAA,MAC7B,YAAY,SAAS;AAAA,MACrB,KAAK,YAAY,SAAS,EAAE;AAAA,IAC9B;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa,CAAC,WAAW,QAAQ;AAAA,IACnC;AAAA,IACA,sBAAsB;AAAA,EACxB;AACF;","names":["center","addressData"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/components/viewers/map/utils/geocoder.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { withoutUndefined } from '../../../../utils/utils'\n\nimport { autocompleteGeocode, reverseGeocode } from './geocoding'\nimport { MarkerManager } from './MarkerManager'\n\nimport type { Building } from '../../../../types/dbTypes'\nimport type { Feature, Point } from 'geojson'\n\nexport type AddressFields = Partial<Pick<Building,\n 'buildingAddress' | 'buildingStreetName' | 'buildingCountrySubdivision' | 'buildingMunicipality' | 'buildingPostalCode'>>\n\nconst text = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() ? value : undefined\n\n/** Maps a geocoder place (forward or reverse) onto a building's address columns. */\nexport function addressFieldsFromPlace(properties: Record<string, unknown> | null | undefined, label: string): AddressFields {\n const place = properties ?? {}\n return withoutUndefined({\n buildingAddress: text(label),\n buildingStreetName: text(place.street),\n buildingCountrySubdivision: text(place.region_a) ?? text(place.region),\n buildingMunicipality: text(place.locality) ?? text(place.county),\n buildingPostalCode: text(place.postalcode),\n })\n}\n\n// Global marker manager instance for geocoder\nlet geocoderMarkerManager: MarkerManager | null = null\n\n// Helper function to get or create the marker manager\nconst getGeocoderMarkerManager = (): MarkerManager => {\n if (!geocoderMarkerManager) {\n geocoderMarkerManager = new MarkerManager()\n }\n return geocoderMarkerManager\n}\n\n// Convert longitude and latitude into Municipality and Country Subdivision\nexport const getMunicipalityAndProvince = async (latitude: string, longitude: string, countryCode?: string) => {\n try {\n const features = await reverseGeocode(latitude, longitude, countryCode, { size: 1, coarse: true })\n\n if (features.length > 0) {\n const properties = features[0].properties as any\n\n const municipality = properties.locality || properties.neighbourhood || properties.county || ''\n const countrySubdivision = properties.region_a || properties.region || '' // region_a gives abbreviation like \"ON\", \"BC\"\n\n return { municipality, countrySubdivision }\n }\n\n return { municipality: '', countrySubdivision: '' }\n }\n catch (error) {\n console.error('Error fetching municipality and country subdivision:', error)\n return { municipality: '', countrySubdivision: '' }\n }\n}\n\n// Fetch address suggestions from the active autocomplete provider\nexport const fetchSuggestions = async (input: string, countryCode?: string) => {\n if (!input || input.length < 3) {\n return []\n }\n\n try {\n return await autocompleteGeocode(input, countryCode, 5)\n }\n catch (error) {\n console.error('Error fetching address suggestions:', error)\n return []\n }\n}\n\n// Parse location details for better display\nexport const parseLocation = (feature: Feature) => {\n const locationName = feature.properties?.name || ''\n const fullLabel = feature.properties?.label || ''\n\n // Try to extract location details from properties\n const properties = feature.properties\n let regionDetails = ''\n\n if (properties) {\n const locality = properties.locality\n const region = properties.region // Full countrySubdivision name\n const region_a = properties.region_a // CountrySubdivision abbreviation (ON, BC, etc.)\n const country = properties.country\n const country_a = properties.country_a // Country abbreviation (CA)\n\n // Build region details similar to your original format\n if (locality && region_a && country_a) {\n regionDetails = `${locality}, ${region_a}, ${country_a}`\n }\n else if (locality && region && country) {\n regionDetails = `${locality}, ${region}, ${country}`\n }\n else {\n // Fallback: try to extract from the full label\n const parts = fullLabel.split(', ')\n if (parts.length > 1) {\n regionDetails = parts.slice(1, 3).join(', ')\n }\n }\n }\n\n return {\n name: locationName,\n region: regionDetails,\n fullLabel: fullLabel,\n }\n}\n\n// Handle suggestion selection and map movement\nexport const handleLocationSelect = (feature: Feature, map: any, type: string, options?: { editing?: boolean; onMoveEnd?: () => void }) => {\n const editing = options?.editing || false\n const listenForMoveEnd = () => { if (options?.onMoveEnd) map.once('moveend', options.onMoveEnd) }\n const markerManager = getGeocoderMarkerManager()\n\n // Handle feature with is_database_building flag\n if (type === 'dbBuilding') {\n const geometry = feature.geometry as Point\n const center = geometry.coordinates\n const addressData = {\n formatted_address: feature.properties?.label || '',\n coordinates: center,\n properties: feature.properties,\n building_id: feature.properties.gid?.replace('building-', ''),\n is_database_building: true,\n }\n\n if (map && center) {\n // Add marker to the center with editing capability\n // markerManager.create(center as [number, number], map)\n\n listenForMoveEnd()\n map.flyTo({\n center: addressData.coordinates,\n zoom: 18,\n speed: 1.5,\n })\n }\n\n return addressData\n }\n\n // Calculate center coordinates\n let center\n\n // Use bbox if available (more precise for areas)\n if (feature.bbox) {\n center = [\n feature.bbox[0] + (feature.bbox[2] - feature.bbox[0]) / 2,\n feature.bbox[1] + (feature.bbox[3] - feature.bbox[1]) / 2,\n ]\n }\n // Otherwise extract coordinates based on geometry type\n else if (feature.geometry?.type === 'Point') {\n center = (feature.geometry as any).coordinates\n }\n\n const addressData = {\n formatted_address: feature.properties?.label || feature.properties?.name || '',\n coordinates: center,\n properties: feature.properties,\n address_details: {\n name: feature.properties?.name,\n label: feature.properties?.label,\n locality: feature.properties?.locality,\n neighbourhood: feature.properties?.neighbourhood,\n region: feature.properties?.region,\n region_a: feature.properties?.region_a,\n country: feature.properties?.country,\n country_a: feature.properties?.country_a,\n postalcode: feature.properties?.postalcode,\n housenumber: feature.properties?.housenumber,\n street: feature.properties?.street,\n },\n geocode_earth_id: feature.properties?.gid, // Geocode Earth's unique id\n layer: feature.properties?.layer, // Type of place (address, venue, locality, etc.)\n confidence: feature.properties?.confidence, // Geocode Earth's confidence score\n match_type: feature.properties?.match_type, // How well the result matches the query\n }\n\n if (map && center) {\n // Add marker to the center with editing capability\n // markerManager.create(center as [number, number], map, { editing })\n\n listenForMoveEnd()\n if (feature.bbox) {\n map.fitBounds(feature.bbox, { speed: 2 })\n }\n else {\n map.flyTo({\n center: addressData.coordinates,\n zoom: 14, // Might be good idea to set zoom level depending on layer / type of place\n speed: 2,\n })\n }\n }\n\n return addressData\n}\n\n// Util function to get detailed address information\nexport const getDetailedAddress = async (coordinates: [number, number], countryCode?: string) => {\n const [longitude, latitude] = coordinates\n\n try {\n // Restrict to address-layer results (the original popover used layers=address) so\n // callers get a street address rather than the nearest venue/POI. Nominatim's zoom-18\n // reverse is already building-level, so this only refines the Pelias path.\n const features = await reverseGeocode(latitude.toString(), longitude.toString(), countryCode, { size: 1, layers: 'address' })\n return features.length > 0 ? features[0] : null\n }\n catch (error) {\n console.error('Error fetching detailed address:', error)\n return null\n }\n}\n\n// Convert a building object to a GeoJSON feature format compatible with handleLocationSelect\nexport const buildingToFeature = (building) => {\n const name = building.buildingName || ''\n\n // Validate coordinates - use the correct property names\n const longitude = Number.parseFloat(building.buildingLongitude)\n const latitude = Number.parseFloat(building.buildingLatitude)\n\n if (isNaN(longitude) || isNaN(latitude)) {\n console.error('Invalid building coordinates:', {\n longitude: building.buildingLongitude,\n latitude: building.buildingLatitude,\n buildingId: building.id,\n })\n return null\n }\n\n return {\n properties: {\n name: name,\n label: `${name}, ${[building.buildingAddress, building.buildingMunicipality, building.buildingCountrySubdivision].filter(Boolean).join(', ')}`,\n address: building.buildingAddress,\n municipality: building.buildingMunicipality,\n countrySubdivision: building.buildingCountrySubdivision,\n postalCode: building.buildingPostalCode,\n gid: `building-${building.id}`,\n },\n geometry: {\n type: 'Point',\n coordinates: [longitude, latitude],\n },\n is_database_building: true,\n }\n}\n\n// // Enhanced marker creation with editing capabilities\n// export const createGeocoderMarker = (coordinates: [number, number], map: any, options?: { editing?: boolean }) => {\n// const editing = options?.editing || false\n// const markerManager = getGeocoderMarkerManager()\n// markerManager.create(coordinates, map, { editing })\n// return markerManager\n// }\n\n// Helper function to remove the current marker\n// export const removeGeocoderMarker = (): void => {\n// const markerManager = getGeocoderMarkerManager()\n// markerManager.remove()\n// }\n"],"mappings":"AAGA,SAAS,wBAAwB;AAEjC,SAAS,qBAAqB,sBAA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EA,SAAO;AAAA,IACL,YAAY;AAAA,MACV;AAAA,MACA,OAAO,GAAG,IAAI,KAAK,CAAC,SAAS,iBAAiB,SAAS,sBAAsB,SAAS,0BAA0B,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI,CAAC;AAAA,MAC5I,SAAS,SAAS;AAAA,MAClB,cAAc,SAAS;AAAA,MACvB,oBAAoB,SAAS;AAAA,MAC7B,YAAY,SAAS;AAAA,MACrB,KAAK,YAAY,SAAS,EAAE;AAAA,IAC9B;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aAAa,CAAC,WAAW,QAAQ;AAAA,IACnC;AAAA,IACA,sBAAsB;AAAA,EACxB;AACF;","names":["center","addressData"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type * as maplibregl from 'maplibre-gl';
|
|
2
|
+
/** True once the store's map is a live maplibre instance that sources and layers can be added to. */
|
|
3
|
+
export declare const hasMapApi: (mapInstance: unknown) => mapInstance is maplibregl.Map;
|
|
4
|
+
//# sourceMappingURL=hasMapApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasMapApi.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/map/utils/hasMapApi.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,UAAU,MAAM,aAAa,CAAA;AAI9C,qGAAqG;AACrG,eAAO,MAAM,SAAS,GAAI,aAAa,OAAO,KAAG,WAAW,IAAI,UAAU,CAAC,GAEyB,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const REQUIRED_METHODS = ["getSource", "getLayer", "addSource", "addLayer", "on", "off"];
|
|
2
|
+
const hasMapApi = (mapInstance) => Boolean(mapInstance) && REQUIRED_METHODS.every((method) => typeof mapInstance[method] === "function");
|
|
3
|
+
export {
|
|
4
|
+
hasMapApi
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=hasMapApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/components/viewers/map/utils/hasMapApi.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport type * as maplibregl from 'maplibre-gl'\n\nconst REQUIRED_METHODS = ['getSource', 'getLayer', 'addSource', 'addLayer', 'on', 'off'] as const\n\n/** True once the store's map is a live maplibre instance that sources and layers can be added to. */\nexport const hasMapApi = (mapInstance: unknown): mapInstance is maplibregl.Map =>\n Boolean(mapInstance)\n && REQUIRED_METHODS.every(method => typeof (mapInstance as maplibregl.Map)[method] === 'function')\n"],"mappings":"AAKA,MAAM,mBAAmB,CAAC,aAAa,YAAY,aAAa,YAAY,MAAM,KAAK;AAGhF,MAAM,YAAY,CAAC,gBACxB,QAAQ,WAAW,KAChB,iBAAiB,MAAM,YAAU,OAAQ,YAA+B,MAAM,MAAM,UAAU;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locationParams.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/urlLocation/locationParams.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"locationParams.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/urlLocation/locationParams.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,KAAK,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,aAAa,CAAA;AAErD,eAAO,MAAM,UAAU,6FAA8F,CAAA;AAErH,MAAM,MAAM,QAAQ,GAAG,OAAO,UAAU,CAAC,MAAM,CAAC,CAAA;AAEhD,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;AAK9D,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAA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W,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAKrH"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mapBbox } from "../validateBounds";
|
|
1
2
|
import { LOCATION_LEVELS } from "./locationTarget";
|
|
2
3
|
const LABEL_KEYS = ["country", "countrySubdivision", "municipality", "site", "address", "buildingId"];
|
|
3
4
|
const MAP_LABEL_KEYS = ["country", "countrySubdivision", "municipality", "address"];
|
|
@@ -44,14 +45,13 @@ function withLocationParams(params, camera, labels) {
|
|
|
44
45
|
}
|
|
45
46
|
function cameraSnapshot(map) {
|
|
46
47
|
const center = map.getCenter();
|
|
47
|
-
const bounds = map.getBounds();
|
|
48
48
|
return {
|
|
49
49
|
lat: center.lat,
|
|
50
50
|
lng: center.lng,
|
|
51
51
|
zoom: map.getZoom(),
|
|
52
52
|
bearing: map.getBearing(),
|
|
53
53
|
pitch: map.getPitch(),
|
|
54
|
-
bounds:
|
|
54
|
+
bounds: mapBbox(map)
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
const toQueryString = (params) => params.toString().replace(/%2C/gi, ",");
|