@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
|
@@ -20,7 +20,7 @@ var __spreadValues = (a, b) => {
|
|
|
20
20
|
return a;
|
|
21
21
|
};
|
|
22
22
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
23
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
24
24
|
import { useTranslations } from "next-intl";
|
|
25
25
|
import * as React from "react";
|
|
26
26
|
import { useBuildings } from "../../../../../../../hooks/buildings/buildings";
|
|
@@ -31,34 +31,30 @@ import { ViewerNames } from "../../../../../../../types/dbTypes";
|
|
|
31
31
|
import { useBuildingSensorColours } from "../../../../../../ui/Sensors/useBuildingSensorColours";
|
|
32
32
|
import { MapLayerClickPriority } from "../../../../utils/MapEventManager/MapClickManager";
|
|
33
33
|
import { maptilerKeyForRequest } from "../../../../utils/mapStyleSpec";
|
|
34
|
-
import MapFeaturePopoverMenu from "../../../MapFeaturePopoverMenu";
|
|
35
34
|
import {
|
|
36
35
|
buildingColourExpression,
|
|
37
|
-
DEFAULT_COLOUR_EXPRESSION,
|
|
38
36
|
osmColourEntries
|
|
39
37
|
} from "./buildingColourExpression";
|
|
38
|
+
import { buildingPopupEntry } from "./buildingPopupEntry";
|
|
39
|
+
import { osmStoreyHeights, overriddenOsmIds } from "./drawnFootprints";
|
|
40
|
+
import { matchByOsmId, matchesAnyOsmId } from "./osmIdExpression";
|
|
40
41
|
import { BuildingSensorMarkers } from "./src/BuildingSensorMarkers";
|
|
42
|
+
import { DrawnBuildingsLayer } from "./src/DrawnBuildingsLayer";
|
|
43
|
+
import { FootprintEditor } from "./src/FootprintEditor";
|
|
41
44
|
const LAYER_ID = "maptiler-3d-buildings";
|
|
42
45
|
const OWN_SOURCE_ID = "cdt-buildings";
|
|
43
46
|
const REUSABLE_SOURCE_IDS = ["openmaptiles", "maptiler_planet", "carto"];
|
|
44
|
-
function buildLayerFilter() {
|
|
47
|
+
function buildLayerFilter(replacedOsmIds) {
|
|
45
48
|
return [
|
|
46
49
|
"all",
|
|
47
50
|
["!=", ["get", "hide_3d"], true],
|
|
48
|
-
["!=", ["get", "hide_3d"], "true"]
|
|
51
|
+
["!=", ["get", "hide_3d"], "true"],
|
|
52
|
+
["!", matchesAnyOsmId(replacedOsmIds)]
|
|
49
53
|
];
|
|
50
54
|
}
|
|
51
|
-
function buildHeightExpression(hiddenBimOsmIds) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
[
|
|
55
|
-
"any",
|
|
56
|
-
["in", ["to-string", ["id"]], ["literal", hiddenBimOsmIds]],
|
|
57
|
-
["in", ["to-string", ["coalesce", ["get", "osm_id"], ""]], ["literal", hiddenBimOsmIds]]
|
|
58
|
-
],
|
|
59
|
-
0.1,
|
|
60
|
-
["coalesce", ["get", "height"], 5]
|
|
61
|
-
];
|
|
55
|
+
function buildHeightExpression(hiddenBimOsmIds, storeyHeights) {
|
|
56
|
+
const tileHeight = ["coalesce", ["get", "height"], 5];
|
|
57
|
+
return ["case", matchesAnyOsmId(hiddenBimOsmIds), 0.1, matchByOsmId(storeyHeights.flat(), tileHeight)];
|
|
62
58
|
}
|
|
63
59
|
function resolveBuildingSource(map, maptilerKey) {
|
|
64
60
|
if (maptilerKey == null ? void 0 : maptilerKey.trim()) return addOwnBuildingSource(map, maptilerKey);
|
|
@@ -84,7 +80,7 @@ function removeBasemapBuildingLayers(map, sourceId) {
|
|
|
84
80
|
if (isDuplicate) map.removeLayer(layer.id);
|
|
85
81
|
}
|
|
86
82
|
}
|
|
87
|
-
function addBuildingLayer(map, hiddenBimOsmIds, colourExpr, maptilerKey) {
|
|
83
|
+
function addBuildingLayer(map, hiddenBimOsmIds, { replacedOsmIds, storeyHeights, colourExpr }, maptilerKey) {
|
|
88
84
|
try {
|
|
89
85
|
if (map.getLayer(LAYER_ID)) return;
|
|
90
86
|
const sourceId = resolveBuildingSource(map, maptilerKey);
|
|
@@ -97,12 +93,11 @@ function addBuildingLayer(map, hiddenBimOsmIds, colourExpr, maptilerKey) {
|
|
|
97
93
|
source: sourceId,
|
|
98
94
|
"source-layer": "building",
|
|
99
95
|
minzoom: 14,
|
|
100
|
-
filter: buildLayerFilter(),
|
|
96
|
+
filter: buildLayerFilter(replacedOsmIds),
|
|
101
97
|
paint: {
|
|
102
|
-
// Seeded
|
|
103
|
-
// the paint effect below will not re-run for it, so the colours would be lost.
|
|
98
|
+
// Seeded: `styledata` re-adds this layer after setStyle and the paint effect will not re-run.
|
|
104
99
|
"fill-extrusion-color": colourExpr,
|
|
105
|
-
"fill-extrusion-height": buildHeightExpression(hiddenBimOsmIds),
|
|
100
|
+
"fill-extrusion-height": buildHeightExpression(hiddenBimOsmIds, storeyHeights),
|
|
106
101
|
"fill-extrusion-base": ["coalesce", ["get", "render_min_height"], 0],
|
|
107
102
|
"fill-extrusion-opacity": [
|
|
108
103
|
"interpolate",
|
|
@@ -121,7 +116,7 @@ function addBuildingLayer(map, hiddenBimOsmIds, colourExpr, maptilerKey) {
|
|
|
121
116
|
function BuildingLayer({ maptilerKey }) {
|
|
122
117
|
var _a, _b;
|
|
123
118
|
const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext);
|
|
124
|
-
const { map, mapClickManager, show3dBuildings, popupStack } = mapState.map;
|
|
119
|
+
const { map, mapClickManager, show3dBuildings, popupStack, editingFootprint } = mapState.map;
|
|
125
120
|
const t = useTranslations("DatabaseBuildingPopover");
|
|
126
121
|
const { setCompareItems } = useBuildingsContext();
|
|
127
122
|
const { buildings } = useBuildings();
|
|
@@ -142,16 +137,16 @@ function BuildingLayer({ maptilerKey }) {
|
|
|
142
137
|
);
|
|
143
138
|
const activeEntry = popupStack ? popupStack.entries[popupStack.activeIndex] : null;
|
|
144
139
|
const clickedKey = (activeEntry == null ? void 0 : activeEntry.layerId) === LAYER_ID ? (_b = (_a = entryFeaturesRef.current[activeEntry.id]) == null ? void 0 : _a.id) != null ? _b : null : null;
|
|
140
|
+
const assignedOsmIds = React.useMemo(() => Object.keys(buildingByOsmId).sort(), [buildingByOsmId]);
|
|
145
141
|
const colourExpr = React.useMemo(
|
|
146
142
|
() => buildingColourExpression({
|
|
147
143
|
osmColours,
|
|
144
|
+
assignedOsmIds,
|
|
148
145
|
clickedKey,
|
|
149
146
|
hoveredKey: hoveredFeature
|
|
150
147
|
}),
|
|
151
|
-
[osmColours, clickedKey, hoveredFeature]
|
|
148
|
+
[osmColours, assignedOsmIds, clickedKey, hoveredFeature]
|
|
152
149
|
);
|
|
153
|
-
const colourExprRef = React.useRef(DEFAULT_COLOUR_EXPRESSION);
|
|
154
|
-
colourExprRef.current = colourExpr;
|
|
155
150
|
const hiddenBimOsmIds = React.useMemo(
|
|
156
151
|
() => Array.from(new Set(
|
|
157
152
|
(bimModelsAddedToMap || []).map((model) => {
|
|
@@ -185,12 +180,19 @@ function BuildingLayer({ maptilerKey }) {
|
|
|
185
180
|
return hasChanges ? mapping : prevMapping;
|
|
186
181
|
});
|
|
187
182
|
}, [buildings]);
|
|
183
|
+
const replacedOsmIds = React.useMemo(() => {
|
|
184
|
+
var _a2;
|
|
185
|
+
const editedOsmId = (_a2 = buildings.find((building) => building.id === (editingFootprint == null ? void 0 : editingFootprint.buildingId))) == null ? void 0 : _a2.buildingOsmId;
|
|
186
|
+
const ids = overriddenOsmIds(buildings);
|
|
187
|
+
return editedOsmId == null ? ids : [...ids, String(editedOsmId)];
|
|
188
|
+
}, [buildings, editingFootprint == null ? void 0 : editingFootprint.buildingId]);
|
|
189
|
+
const storeyHeights = React.useMemo(() => osmStoreyHeights(buildings), [buildings]);
|
|
190
|
+
const layerInputsRef = React.useRef({ replacedOsmIds, storeyHeights, colourExpr });
|
|
191
|
+
layerInputsRef.current = { replacedOsmIds, storeyHeights, colourExpr };
|
|
188
192
|
React.useEffect(() => {
|
|
189
193
|
if (!map) return;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
const onStyleLoad = () => addBuildingLayer(map, hiddenBimOsmIds, colourExprRef.current, maptilerKey);
|
|
194
|
+
const onStyleLoad = () => addBuildingLayer(map, hiddenBimOsmIds, layerInputsRef.current, maptilerKey);
|
|
195
|
+
if (map.isStyleLoaded()) onStyleLoad();
|
|
194
196
|
map.on("styledata", onStyleLoad);
|
|
195
197
|
return () => {
|
|
196
198
|
try {
|
|
@@ -207,9 +209,9 @@ function BuildingLayer({ maptilerKey }) {
|
|
|
207
209
|
}, [map, hiddenBimOsmIds, maptilerKey]);
|
|
208
210
|
React.useEffect(() => {
|
|
209
211
|
if (!map || !map.getLayer(LAYER_ID)) return;
|
|
210
|
-
map.setFilter(LAYER_ID, buildLayerFilter());
|
|
211
|
-
map.setPaintProperty(LAYER_ID, "fill-extrusion-height", buildHeightExpression(hiddenBimOsmIds));
|
|
212
|
-
}, [map, hiddenBimOsmIds]);
|
|
212
|
+
map.setFilter(LAYER_ID, buildLayerFilter(replacedOsmIds));
|
|
213
|
+
map.setPaintProperty(LAYER_ID, "fill-extrusion-height", buildHeightExpression(hiddenBimOsmIds, storeyHeights));
|
|
214
|
+
}, [map, hiddenBimOsmIds, replacedOsmIds, storeyHeights]);
|
|
213
215
|
React.useEffect(() => {
|
|
214
216
|
if (!map) return;
|
|
215
217
|
const applyVisibility = () => {
|
|
@@ -249,24 +251,17 @@ function BuildingLayer({ maptilerKey }) {
|
|
|
249
251
|
});
|
|
250
252
|
const id = `${LAYER_ID}:${normalizedOsmId}`;
|
|
251
253
|
entryFeaturesRef.current[id] = featureClone;
|
|
252
|
-
return {
|
|
253
|
-
id,
|
|
254
|
+
return buildingPopupEntry({
|
|
254
255
|
layerId: LAYER_ID,
|
|
255
|
-
|
|
256
|
+
key: normalizedOsmId,
|
|
256
257
|
title: _name || t("fallbackName"),
|
|
257
258
|
coordinates,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
closePopups();
|
|
265
|
-
setCompareItems([]);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
)
|
|
269
|
-
};
|
|
259
|
+
feature: featureClone,
|
|
260
|
+
onClose: () => {
|
|
261
|
+
closePopups();
|
|
262
|
+
setCompareItems([]);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
270
265
|
});
|
|
271
266
|
};
|
|
272
267
|
const handleHover = (e) => {
|
|
@@ -307,7 +302,11 @@ function BuildingLayer({ maptilerKey }) {
|
|
|
307
302
|
colourExpr
|
|
308
303
|
);
|
|
309
304
|
}, [map, colourExpr]);
|
|
310
|
-
return /* @__PURE__ */
|
|
305
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
306
|
+
/* @__PURE__ */ jsx(BuildingSensorMarkers, { buildings: buildings != null ? buildings : [], sensorColours }),
|
|
307
|
+
/* @__PURE__ */ jsx(DrawnBuildingsLayer, { buildings, fallbackName: t("fallbackName"), onClosePopup: closePopups }),
|
|
308
|
+
/* @__PURE__ */ jsx(FootprintEditor, {})
|
|
309
|
+
] });
|
|
311
310
|
}
|
|
312
311
|
export {
|
|
313
312
|
BuildingLayer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.tsx"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n\nimport { useTranslations } from \"next-intl\";\nimport * as React from \"react\";\n\nimport { useBuildings } from \"../../../../../../../hooks/buildings/buildings\";\nimport { useBuildingsContext } from \"../../../../../../../store\";\nimport { useBimContext } from \"../../../../../../../store/BIM/context\";\nimport { MapContext } from \"../../../../../../../store/Map/context\";\nimport { ViewerNames } from \"../../../../../../../types/dbTypes\";\nimport { useBuildingSensorColours } from \"../../../../../../ui/Sensors/useBuildingSensorColours\";\nimport { MapLayerClickPriority } from \"../../../../utils/MapEventManager/MapClickManager\";\nimport { maptilerKeyForRequest } from \"../../../../utils/mapStyleSpec\";\nimport MapFeaturePopoverMenu from \"../../../MapFeaturePopoverMenu\";\n\nimport {\n buildingColourExpression,\n DEFAULT_COLOUR_EXPRESSION,\n osmColourEntries,\n type PaintExpression,\n} from \"./buildingColourExpression\";\nimport { BuildingSensorMarkers } from \"./src/BuildingSensorMarkers\";\n\nimport type { PopupEntry } from \"../../../../../../../types/map\";\nimport type { DataDrivenPropertyValueSpecification, MapGeoJSONFeature, MapMouseEvent } from \"maplibre-gl\";\n\nconst LAYER_ID = \"maptiler-3d-buildings\";\nconst OWN_SOURCE_ID = \"cdt-buildings\";\nconst REUSABLE_SOURCE_IDS = [\"openmaptiles\", \"maptiler_planet\", \"carto\"] as const;\n\nfunction buildLayerFilter() {\n return [\n \"all\",\n [\"!=\", [\"get\", \"hide_3d\"], true],\n [\"!=\", [\"get\", \"hide_3d\"], \"true\"],\n ];\n}\n\nfunction buildHeightExpression(hiddenBimOsmIds: string[]) {\n return [\n \"case\",\n [\n \"any\",\n [\"in\", [\"to-string\", [\"id\"]], [\"literal\", hiddenBimOsmIds]],\n [\"in\", [\"to-string\", [\"coalesce\", [\"get\", \"osm_id\"], \"\"]], [\"literal\", hiddenBimOsmIds]],\n ],\n 0.1,\n [\"coalesce\", [\"get\", \"height\"], 5],\n ];\n}\n\n// Null when there is nothing to draw buildings from so the layer is skipped rather than 403ing.\nfunction resolveBuildingSource(map: any, maptilerKey?: string): string | null {\n if (maptilerKey?.trim()) return addOwnBuildingSource(map, maptilerKey);\n\n const reusable = REUSABLE_SOURCE_IDS.find((id) => map.getSource(id));\n if (reusable) return reusable;\n\n const key = maptilerKeyForRequest(maptilerKey);\n return key ? addOwnBuildingSource(map, key) : null;\n}\n\nfunction addOwnBuildingSource(map: any, key: string): string {\n if (!map.getSource(OWN_SOURCE_ID)) {\n map.addSource(OWN_SOURCE_ID, {\n type: \"vector\",\n url: `https://api.maptiler.com/tiles/buildings/tiles.json?key=${key}`,\n });\n }\n return OWN_SOURCE_ID;\n}\n\n// Basemaps such as maptiler streets-v2 extrude buildings themselves, which double-draws ours.\nfunction removeBasemapBuildingLayers(map: any, sourceId: string) {\n const basemapSources = new Set<string>([...REUSABLE_SOURCE_IDS, sourceId]);\n\n for (const layer of map.getStyle()?.layers ?? []) {\n const isDuplicate =\n layer.id !== LAYER_ID &&\n layer.type === \"fill-extrusion\" &&\n layer[\"source-layer\"] === \"building\" &&\n basemapSources.has(layer.source);\n\n if (isDuplicate) map.removeLayer(layer.id);\n }\n}\n\nfunction addBuildingLayer(map: any, hiddenBimOsmIds: string[], colourExpr: PaintExpression, maptilerKey?: string) {\n try {\n if (map.getLayer(LAYER_ID)) return;\n\n const sourceId = resolveBuildingSource(map, maptilerKey);\n if (!sourceId) return;\n\n removeBasemapBuildingLayers(map, sourceId);\n\n // Insert below road labels so buildings don't cover text\n const beforeId = map.getLayer(\"road_label\") ? \"road_label\" : undefined;\n\n map.addLayer({\n id: LAYER_ID,\n type: \"fill-extrusion\",\n source: sourceId,\n \"source-layer\": \"building\",\n minzoom: 14,\n filter: buildLayerFilter(),\n paint: {\n // Seeded rather than hardcoded: `styledata` re-adds this layer after any setStyle, and\n // the paint effect below will not re-run for it, so the colours would be lost.\n \"fill-extrusion-color\": colourExpr,\n \"fill-extrusion-height\": buildHeightExpression(hiddenBimOsmIds),\n \"fill-extrusion-base\": [\"coalesce\", [\"get\", \"render_min_height\"], 0],\n \"fill-extrusion-opacity\": [\n \"interpolate\", [\"linear\"], [\"zoom\"],\n 14, 0.6,\n 16, 0.8,\n ],\n },\n }, beforeId);\n } catch {\n // Map style may be in a transitional state during layer addition\n }\n}\n\nexport function BuildingLayer({ maptilerKey }: { maptilerKey?: string }) {\n const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext);\n const { map, mapClickManager, show3dBuildings, popupStack } = mapState.map;\n const t = useTranslations(\"DatabaseBuildingPopover\");\n const { setCompareItems } = useBuildingsContext();\n const { buildings } = useBuildings();\n const { state: bimState } = useBimContext();\n const { bimModelsAddedToMap } = bimState.bim;\n\n const [hoveredFeature, setHoveredFeature] = React.useState<string | number | null>(null);\n const entryFeaturesRef = React.useRef<Record<string, any>>({});\n\n const closePopups = React.useCallback(\n () => mapDispatch({ type: \"SET_POPUP_STACK\", payload: null }),\n [mapDispatch],\n );\n const [buildingByOsmId, setBuildingByOsmId] = React.useState<Record<string, { id: number }>>({});\n\n // Footprints are tinted by the average reading of the legend's sensor type. Nothing is polled\n // and nothing changes colour until a type is pinned in the legend and switched on.\n const sensorColours = useBuildingSensorColours(ViewerNames.map);\n const { averages, colourKey } = sensorColours;\n\n const osmColours = React.useMemo(\n () => osmColourEntries(averages, buildings ?? []),\n [averages, buildings],\n );\n\n const activeEntry = popupStack ? popupStack.entries[popupStack.activeIndex] : null;\n const clickedKey = activeEntry?.layerId === LAYER_ID\n ? entryFeaturesRef.current[activeEntry.id]?.id ?? null\n : null;\n\n const colourExpr = React.useMemo(\n () => buildingColourExpression({\n osmColours,\n clickedKey,\n hoveredKey: hoveredFeature,\n }),\n [osmColours, clickedKey, hoveredFeature],\n );\n\n // Read by the add-layer effect, which must not re-run when only the colours change.\n const colourExprRef = React.useRef<PaintExpression>(DEFAULT_COLOUR_EXPRESSION);\n colourExprRef.current = colourExpr;\n\n const hiddenBimOsmIds = React.useMemo(\n () => Array.from(new Set(\n (bimModelsAddedToMap || [])\n .map((model: any) => model?.building?.buildingOsmId)\n .filter((value: unknown): value is string | number => value !== null && value !== undefined)\n .map((value) => String(value))\n )),\n [bimModelsAddedToMap],\n );\n\n React.useEffect(() => {\n if (!buildings || !Array.isArray(buildings) || buildings.length === 0) {\n setBuildingByOsmId({});\n return;\n }\n\n const mapping: Record<string, { id: number }> = {};\n buildings.forEach((building: any) => {\n if (building.buildingOsmId != null) {\n mapping[String(building.buildingOsmId)] = { id: building.id };\n }\n });\n\n setBuildingByOsmId((prevMapping) => {\n const newKeys = Object.keys(mapping);\n const prevKeys = Object.keys(prevMapping);\n\n if (newKeys.length !== prevKeys.length) {\n return mapping;\n }\n\n const hasChanges = newKeys.some((key) => mapping[key]?.id !== prevMapping[key]?.id);\n return hasChanges ? mapping : prevMapping;\n });\n }, [buildings]);\n\n // Add the layer imperatively\n React.useEffect(() => {\n if (!map) return;\n\n if (map.isStyleLoaded()) {\n addBuildingLayer(map, hiddenBimOsmIds, colourExprRef.current, maptilerKey);\n }\n\n const onStyleLoad = () => addBuildingLayer(map, hiddenBimOsmIds, colourExprRef.current, maptilerKey);\n map.on(\"styledata\", onStyleLoad);\n\n return () => {\n try {\n map.off(\"styledata\", onStyleLoad);\n if (map.getLayer(LAYER_ID)) {\n map.removeLayer(LAYER_ID);\n }\n if (map.getSource(OWN_SOURCE_ID)) {\n map.removeSource(OWN_SOURCE_ID);\n }\n } catch {\n // Map may have been destroyed before cleanup runs\n }\n };\n }, [map, hiddenBimOsmIds, maptilerKey]);\n\n React.useEffect(() => {\n if (!map || !map.getLayer(LAYER_ID)) return;\n\n map.setFilter(LAYER_ID, buildLayerFilter() as any);\n map.setPaintProperty(LAYER_ID, \"fill-extrusion-height\", buildHeightExpression(hiddenBimOsmIds) as any);\n }, [map, hiddenBimOsmIds]);\n\n React.useEffect(() => {\n if (!map) return;\n\n const applyVisibility = () => {\n if (!map.getLayer(LAYER_ID)) return;\n map.setLayoutProperty(LAYER_ID, \"visibility\", show3dBuildings ? \"visible\" : \"none\");\n };\n\n applyVisibility();\n map.on(\"styledata\", applyVisibility);\n\n return () => {\n map.off(\"styledata\", applyVisibility);\n };\n }, [map, show3dBuildings]);\n\n // Register click, hover, and mouse leave handlers\n React.useEffect(() => {\n if (!map || !mapClickManager) return;\n\n const resolvePopups = (e: MapMouseEvent, hits: MapGeoJSONFeature[]): PopupEntry[] => {\n entryFeaturesRef.current = {};\n const coordinates: [number, number] = [e.lngLat.lng, e.lngLat.lat];\n\n return hits.map((feature) => {\n const properties = feature.properties || {};\n\n // Use MVT feature.id (OSM ID) or fall back to properties\n const featureId = feature.id || properties.osm_id || `temp-${Date.now()}`;\n const normalizedOsmId = String(featureId);\n const dbId = buildingByOsmId[normalizedOsmId]?.id || null;\n const _name = Object.entries(properties).find(\n ([key]) => key.toLowerCase().includes(\"name\")\n )?.[1] || undefined;\n\n const featureClone: any = {\n ...feature,\n id: featureId,\n properties: {\n ...properties,\n coordinates,\n _name,\n osm_id: normalizedOsmId,\n isBuilding: true,\n isDbBuilding: Boolean(dbId),\n dbId,\n },\n };\n\n const id = `${LAYER_ID}:${normalizedOsmId}`;\n entryFeaturesRef.current[id] = featureClone;\n\n return {\n id,\n layerId: LAYER_ID,\n priority: MapLayerClickPriority.BuildingLayersClickPriority,\n title: (_name as string) || t(\"fallbackName\"),\n coordinates,\n render: (header) => (\n <MapFeaturePopoverMenu\n header={header}\n feature={featureClone}\n onCloseAction={() => {\n closePopups();\n setCompareItems([]);\n }}\n />\n ),\n };\n });\n };\n\n const handleHover = (e: MapMouseEvent) => {\n if (!map.getLayer(LAYER_ID)) return;\n const hovered = map.queryRenderedFeatures(e.point, { layers: [LAYER_ID] });\n\n if (hovered[0]) {\n map.getCanvas().style.cursor = \"pointer\";\n const hoveredId = hovered[0].id || hovered[0].properties?.osm_id || null;\n setHoveredFeature(hoveredId);\n } else {\n map.getCanvas().style.cursor = \"\";\n setHoveredFeature(null);\n }\n };\n\n const handleMouseLeave = () => {\n map.getCanvas().style.cursor = \"\";\n setHoveredFeature(null);\n };\n\n mapClickManager.register(\n LAYER_ID,\n MapLayerClickPriority.BuildingLayersClickPriority,\n resolvePopups\n );\n map.on(\"mousemove\", LAYER_ID, handleHover);\n map.on(\"mouseleave\", LAYER_ID, handleMouseLeave);\n\n return () => {\n mapClickManager.unregister(LAYER_ID);\n map.off(\"mousemove\", LAYER_ID, handleHover);\n map.off(\"mouseleave\", LAYER_ID, handleMouseLeave);\n };\n }, [map, mapClickManager, buildingByOsmId, hiddenBimOsmIds, t, closePopups, setCompareItems]);\n\n // Single writer for fill-extrusion-color: hover, click and sensor colours are merged into one\n // expression upstream, so there is no second effect to race with. `colourExpr` only changes\n // when a highlight moves or a sensor colour actually differs, not on every 15s poll.\n React.useEffect(() => {\n if (!map || !map.getLayer(LAYER_ID)) return;\n // The spec union cannot describe an expression assembled at runtime, so the structural type is asserted here.\n map.setPaintProperty(\n LAYER_ID,\n \"fill-extrusion-color\",\n colourExpr as DataDrivenPropertyValueSpecification<string>,\n );\n }, [map, colourExpr]);\n\n return (\n <>\n <BuildingSensorMarkers buildings={buildings ?? []} sensorColours={sensorColours} />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8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AQ,CAAC,EAAE,QAAMA,MAAA,QAAQ,CAAC,EAAE,eAAX,gBAAAA,IAAuB,WAAU;AACpE,0BAAkB,SAAS;AAAA,MAC7B,OAAO;AACL,YAAI,UAAU,EAAE,MAAM,SAAS;AAC/B,0BAAkB,IAAI;AAAA,MACxB;AAAA,IACF;AAEA,UAAM,mBAAmB,MAAM;AAC7B,UAAI,UAAU,EAAE,MAAM,SAAS;AAC/B,wBAAkB,IAAI;AAAA,IACxB;AAEA,oBAAgB;AAAA,MACd;AAAA,MACA,sBAAsB;AAAA,MACtB;AAAA,IACF;AACA,QAAI,GAAG,aAAa,UAAU,WAAW;AACzC,QAAI,GAAG,cAAc,UAAU,gBAAgB;AAE/C,WAAO,MAAM;AACX,sBAAgB,WAAW,QAAQ;AACnC,UAAI,IAAI,aAAa,UAAU,WAAW;AAC1C,UAAI,IAAI,cAAc,UAAU,gBAAgB;AAAA,IAClD;AAAA,EACF,GAAG,CAAC,KAAK,iBAAiB,iBAAiB,iBAAiB,GAAG,aAAa,eAAe,CAAC;AAK5F,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,OAAO,CAAC,IAAI,SAAS,QAAQ,EAAG;AAErC,QAAI;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAAG,CAAC,KAAK,UAAU,CAAC;AAEpB,SACE,gCACE,8BAAC,yBAAsB,WAAW,gCAAa,CAAC,GAAG,eAA8B,GACnF;AAEJ;","names":["_a","_b"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.tsx"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n\nimport { useTranslations } from \"next-intl\";\nimport * as React from \"react\";\n\nimport { useBuildings } from \"../../../../../../../hooks/buildings/buildings\";\nimport { useBuildingsContext } from \"../../../../../../../store\";\nimport { useBimContext } from \"../../../../../../../store/BIM/context\";\nimport { MapContext } from \"../../../../../../../store/Map/context\";\nimport { ViewerNames } from \"../../../../../../../types/dbTypes\";\nimport { useBuildingSensorColours } from \"../../../../../../ui/Sensors/useBuildingSensorColours\";\nimport { MapLayerClickPriority } from \"../../../../utils/MapEventManager/MapClickManager\";\nimport { maptilerKeyForRequest } from \"../../../../utils/mapStyleSpec\";\n\nimport {\n buildingColourExpression,\n osmColourEntries,\n type PaintExpression,\n} from \"./buildingColourExpression\";\nimport { buildingPopupEntry } from \"./buildingPopupEntry\";\nimport { osmStoreyHeights, overriddenOsmIds } from \"./drawnFootprints\";\nimport { matchByOsmId, matchesAnyOsmId } from \"./osmIdExpression\";\nimport { BuildingSensorMarkers } from \"./src/BuildingSensorMarkers\";\nimport { DrawnBuildingsLayer } from \"./src/DrawnBuildingsLayer\";\nimport { FootprintEditor } from \"./src/FootprintEditor\";\n\nimport type { PopupEntry } from \"../../../../../../../types/map\";\nimport type { DataDrivenPropertyValueSpecification, MapGeoJSONFeature, MapMouseEvent } from \"maplibre-gl\";\n\nconst LAYER_ID = \"maptiler-3d-buildings\";\nconst OWN_SOURCE_ID = \"cdt-buildings\";\nconst REUSABLE_SOURCE_IDS = [\"openmaptiles\", \"maptiler_planet\", \"carto\"] as const;\n\ninterface LayerInputs {\n replacedOsmIds: string[];\n storeyHeights: [string, number][];\n colourExpr: PaintExpression;\n}\n\nfunction buildLayerFilter(replacedOsmIds: string[]) {\n return [\n \"all\",\n [\"!=\", [\"get\", \"hide_3d\"], true],\n [\"!=\", [\"get\", \"hide_3d\"], \"true\"],\n [\"!\", matchesAnyOsmId(replacedOsmIds)],\n ];\n}\n\nfunction buildHeightExpression(hiddenBimOsmIds: string[], storeyHeights: [string, number][]) {\n const tileHeight: PaintExpression = [\"coalesce\", [\"get\", \"height\"], 5];\n return [\"case\", matchesAnyOsmId(hiddenBimOsmIds), 0.1, matchByOsmId(storeyHeights.flat(), tileHeight)];\n}\n\n// Null when there is nothing to draw buildings from so the layer is skipped rather than 403ing.\nfunction resolveBuildingSource(map: any, maptilerKey?: string): string | null {\n if (maptilerKey?.trim()) return addOwnBuildingSource(map, maptilerKey);\n\n const reusable = REUSABLE_SOURCE_IDS.find((id) => map.getSource(id));\n if (reusable) return reusable;\n\n const key = maptilerKeyForRequest(maptilerKey);\n return key ? addOwnBuildingSource(map, key) : null;\n}\n\nfunction addOwnBuildingSource(map: any, key: string): string {\n if (!map.getSource(OWN_SOURCE_ID)) {\n map.addSource(OWN_SOURCE_ID, {\n type: \"vector\",\n url: `https://api.maptiler.com/tiles/buildings/tiles.json?key=${key}`,\n });\n }\n return OWN_SOURCE_ID;\n}\n\n// Basemaps such as maptiler streets-v2 extrude buildings themselves, which double-draws ours.\nfunction removeBasemapBuildingLayers(map: any, sourceId: string) {\n const basemapSources = new Set<string>([...REUSABLE_SOURCE_IDS, sourceId]);\n\n for (const layer of map.getStyle()?.layers ?? []) {\n const isDuplicate =\n layer.id !== LAYER_ID &&\n layer.type === \"fill-extrusion\" &&\n layer[\"source-layer\"] === \"building\" &&\n basemapSources.has(layer.source);\n\n if (isDuplicate) map.removeLayer(layer.id);\n }\n}\n\nfunction addBuildingLayer(map: any, hiddenBimOsmIds: string[], { replacedOsmIds, storeyHeights, colourExpr }: LayerInputs, maptilerKey?: string) {\n try {\n if (map.getLayer(LAYER_ID)) return;\n\n const sourceId = resolveBuildingSource(map, maptilerKey);\n if (!sourceId) return;\n\n removeBasemapBuildingLayers(map, sourceId);\n\n // Insert below road labels so buildings don't cover text\n const beforeId = map.getLayer(\"road_label\") ? \"road_label\" : undefined;\n\n map.addLayer({\n id: LAYER_ID,\n type: \"fill-extrusion\",\n source: sourceId,\n \"source-layer\": \"building\",\n minzoom: 14,\n filter: buildLayerFilter(replacedOsmIds),\n paint: {\n // Seeded: `styledata` re-adds this layer after setStyle and the paint effect will not re-run.\n \"fill-extrusion-color\": colourExpr,\n \"fill-extrusion-height\": buildHeightExpression(hiddenBimOsmIds, storeyHeights),\n \"fill-extrusion-base\": [\"coalesce\", [\"get\", \"render_min_height\"], 0],\n \"fill-extrusion-opacity\": [\n \"interpolate\", [\"linear\"], [\"zoom\"],\n 14, 0.6,\n 16, 0.8,\n ],\n },\n }, beforeId);\n } catch {\n // Map style may be in a transitional state during layer addition\n }\n}\n\nexport function BuildingLayer({ maptilerKey }: { maptilerKey?: string }) {\n const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext);\n const { map, mapClickManager, show3dBuildings, popupStack, editingFootprint } = mapState.map;\n const t = useTranslations(\"DatabaseBuildingPopover\");\n const { setCompareItems } = useBuildingsContext();\n const { buildings } = useBuildings();\n const { state: bimState } = useBimContext();\n const { bimModelsAddedToMap } = bimState.bim;\n\n const [hoveredFeature, setHoveredFeature] = React.useState<string | number | null>(null);\n const entryFeaturesRef = React.useRef<Record<string, any>>({});\n\n const closePopups = React.useCallback(\n () => mapDispatch({ type: \"SET_POPUP_STACK\", payload: null }),\n [mapDispatch],\n );\n const [buildingByOsmId, setBuildingByOsmId] = React.useState<Record<string, { id: number }>>({});\n\n // Nothing is polled until a sensor type is pinned in the legend and switched on.\n const sensorColours = useBuildingSensorColours(ViewerNames.map);\n const { averages, colourKey } = sensorColours;\n\n const osmColours = React.useMemo(\n () => osmColourEntries(averages, buildings ?? []),\n [averages, buildings],\n );\n\n const activeEntry = popupStack ? popupStack.entries[popupStack.activeIndex] : null;\n const clickedKey = activeEntry?.layerId === LAYER_ID\n ? entryFeaturesRef.current[activeEntry.id]?.id ?? null\n : null;\n\n const assignedOsmIds = React.useMemo(() => Object.keys(buildingByOsmId).sort(), [buildingByOsmId]);\n\n const colourExpr = React.useMemo(\n () => buildingColourExpression({\n osmColours,\n assignedOsmIds,\n clickedKey,\n hoveredKey: hoveredFeature,\n }),\n [osmColours, assignedOsmIds, clickedKey, hoveredFeature],\n );\n\n const hiddenBimOsmIds = React.useMemo(\n () => Array.from(new Set(\n (bimModelsAddedToMap || [])\n .map((model: any) => model?.building?.buildingOsmId)\n .filter((value: unknown): value is string | number => value !== null && value !== undefined)\n .map((value) => String(value))\n )),\n [bimModelsAddedToMap],\n );\n\n React.useEffect(() => {\n if (!buildings || !Array.isArray(buildings) || buildings.length === 0) {\n setBuildingByOsmId({});\n return;\n }\n\n const mapping: Record<string, { id: number }> = {};\n buildings.forEach((building: any) => {\n if (building.buildingOsmId != null) {\n mapping[String(building.buildingOsmId)] = { id: building.id };\n }\n });\n\n setBuildingByOsmId((prevMapping) => {\n const newKeys = Object.keys(mapping);\n const prevKeys = Object.keys(prevMapping);\n\n if (newKeys.length !== prevKeys.length) {\n return mapping;\n }\n\n const hasChanges = newKeys.some((key) => mapping[key]?.id !== prevMapping[key]?.id);\n return hasChanges ? mapping : prevMapping;\n });\n }, [buildings]);\n\n const replacedOsmIds = React.useMemo(() => {\n const editedOsmId = buildings.find(building => building.id === editingFootprint?.buildingId)?.buildingOsmId;\n const ids = overriddenOsmIds(buildings);\n return editedOsmId == null ? ids : [...ids, String(editedOsmId)];\n }, [buildings, editingFootprint?.buildingId]);\n\n const storeyHeights = React.useMemo(() => osmStoreyHeights(buildings), [buildings]);\n\n // Read by the add-layer effect, which must not re-run when only these change.\n const layerInputsRef = React.useRef<LayerInputs>({ replacedOsmIds, storeyHeights, colourExpr });\n layerInputsRef.current = { replacedOsmIds, storeyHeights, colourExpr };\n\n // Add the layer imperatively\n React.useEffect(() => {\n if (!map) return;\n\n const onStyleLoad = () => addBuildingLayer(map, hiddenBimOsmIds, layerInputsRef.current, maptilerKey);\n if (map.isStyleLoaded()) onStyleLoad();\n map.on(\"styledata\", onStyleLoad);\n\n return () => {\n try {\n map.off(\"styledata\", onStyleLoad);\n if (map.getLayer(LAYER_ID)) {\n map.removeLayer(LAYER_ID);\n }\n if (map.getSource(OWN_SOURCE_ID)) {\n map.removeSource(OWN_SOURCE_ID);\n }\n } catch {\n // Map may have been destroyed before cleanup runs\n }\n };\n }, [map, hiddenBimOsmIds, maptilerKey]);\n\n React.useEffect(() => {\n if (!map || !map.getLayer(LAYER_ID)) return;\n\n map.setFilter(LAYER_ID, buildLayerFilter(replacedOsmIds) as any);\n map.setPaintProperty(LAYER_ID, \"fill-extrusion-height\", buildHeightExpression(hiddenBimOsmIds, storeyHeights) as any);\n }, [map, hiddenBimOsmIds, replacedOsmIds, storeyHeights]);\n\n React.useEffect(() => {\n if (!map) return;\n\n const applyVisibility = () => {\n if (!map.getLayer(LAYER_ID)) return;\n map.setLayoutProperty(LAYER_ID, \"visibility\", show3dBuildings ? \"visible\" : \"none\");\n };\n\n applyVisibility();\n map.on(\"styledata\", applyVisibility);\n\n return () => {\n map.off(\"styledata\", applyVisibility);\n };\n }, [map, show3dBuildings]);\n\n // Register click, hover, and mouse leave handlers\n React.useEffect(() => {\n if (!map || !mapClickManager) return;\n\n const resolvePopups = (e: MapMouseEvent, hits: MapGeoJSONFeature[]): PopupEntry[] => {\n entryFeaturesRef.current = {};\n const coordinates: [number, number] = [e.lngLat.lng, e.lngLat.lat];\n\n return hits.map((feature) => {\n const properties = feature.properties || {};\n\n // Use MVT feature.id (OSM ID) or fall back to properties\n const featureId = feature.id || properties.osm_id || `temp-${Date.now()}`;\n const normalizedOsmId = String(featureId);\n const dbId = buildingByOsmId[normalizedOsmId]?.id || null;\n const _name = Object.entries(properties).find(\n ([key]) => key.toLowerCase().includes(\"name\")\n )?.[1] || undefined;\n\n const featureClone: any = {\n ...feature,\n id: featureId,\n properties: {\n ...properties,\n coordinates,\n _name,\n osm_id: normalizedOsmId,\n isBuilding: true,\n isDbBuilding: Boolean(dbId),\n dbId,\n },\n };\n\n const id = `${LAYER_ID}:${normalizedOsmId}`;\n entryFeaturesRef.current[id] = featureClone;\n\n return buildingPopupEntry({\n layerId: LAYER_ID,\n key: normalizedOsmId,\n title: (_name as string) || t(\"fallbackName\"),\n coordinates,\n feature: featureClone,\n onClose: () => {\n closePopups();\n setCompareItems([]);\n },\n });\n });\n };\n\n const handleHover = (e: MapMouseEvent) => {\n if (!map.getLayer(LAYER_ID)) return;\n const hovered = map.queryRenderedFeatures(e.point, { layers: [LAYER_ID] });\n\n if (hovered[0]) {\n map.getCanvas().style.cursor = \"pointer\";\n const hoveredId = hovered[0].id || hovered[0].properties?.osm_id || null;\n setHoveredFeature(hoveredId);\n } else {\n map.getCanvas().style.cursor = \"\";\n setHoveredFeature(null);\n }\n };\n\n const handleMouseLeave = () => {\n map.getCanvas().style.cursor = \"\";\n setHoveredFeature(null);\n };\n\n mapClickManager.register(\n LAYER_ID,\n MapLayerClickPriority.BuildingLayersClickPriority,\n resolvePopups\n );\n map.on(\"mousemove\", LAYER_ID, handleHover);\n map.on(\"mouseleave\", LAYER_ID, handleMouseLeave);\n\n return () => {\n mapClickManager.unregister(LAYER_ID);\n map.off(\"mousemove\", LAYER_ID, handleHover);\n map.off(\"mouseleave\", LAYER_ID, handleMouseLeave);\n };\n }, [map, mapClickManager, buildingByOsmId, hiddenBimOsmIds, t, closePopups, setCompareItems]);\n\n // Sole writer of fill-extrusion-color; every highlight is merged into `colourExpr` upstream.\n React.useEffect(() => {\n if (!map || !map.getLayer(LAYER_ID)) return;\n // The spec union cannot describe an expression assembled at runtime, so the structural type is asserted here.\n map.setPaintProperty(\n LAYER_ID,\n \"fill-extrusion-color\",\n colourExpr as DataDrivenPropertyValueSpecification<string>,\n );\n }, [map, colourExpr]);\n\n return (\n <>\n <BuildingSensorMarkers buildings={buildings ?? []} sensorColours={sensorColours} />\n <DrawnBuildingsLayer buildings={buildings} fallbackName={t(\"fallbackName\")} onClosePopup={closePopups} />\n <FootprintEditor />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2WI,mBACE,KADF;AArWJ,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AAEtC;AAAA,EACE;AAAA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dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/osmIdExpression.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PaintExpression } from "./buildingColourExpression";
|
|
2
|
+
import type { Building } from "../../../../../../../types/dbTypes";
|
|
3
|
+
export declare function matchesOsmId(osmId: string): PaintExpression;
|
|
4
|
+
export declare function matchesAnyOsmId(osmIds: readonly string[]): PaintExpression;
|
|
5
|
+
/** A `match` on either OSM key over flattened `[osmId, output]` pairs; `fallback` alone when there are none. */
|
|
6
|
+
export declare function matchByOsmId(pairs: readonly (string | number)[], fallback: PaintExpression): PaintExpression;
|
|
7
|
+
/** The building's OSM id as a `match` label; empty when it has none. */
|
|
8
|
+
export declare const osmLabel: (building: Pick<Building, "buildingOsmId">) => string;
|
|
9
|
+
export declare const byOsmLabel: ([a]: readonly [string, unknown], [b]: readonly [string, unknown]) => 0 | 1 | -1;
|
|
10
|
+
//# sourceMappingURL=osmIdExpression.d.ts.map
|
package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/osmIdExpression.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"osmIdExpression.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/BuildingLayers/osmIdExpression.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAMnE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAE3D;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,eAAe,CAE1E;AAED,gHAAgH;AAChH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,eAAe,GAAG,eAAe,CAG5G;AAED,wEAAwE;AACxE,eAAO,MAAM,QAAQ,GAAI,UAAU,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,WAAgD,CAAC;AAEnH,eAAO,MAAM,UAAU,GAAI,KAAK,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,eAAiC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const ID_KEY = ["to-string", ["id"]];
|
|
2
|
+
const PROP_KEY = ["to-string", ["coalesce", ["get", "osm_id"], ""]];
|
|
3
|
+
function matchesOsmId(osmId) {
|
|
4
|
+
return ["any", ["==", ID_KEY, osmId], ["==", PROP_KEY, osmId]];
|
|
5
|
+
}
|
|
6
|
+
function matchesAnyOsmId(osmIds) {
|
|
7
|
+
return ["any", ["in", ID_KEY, ["literal", [...osmIds]]], ["in", PROP_KEY, ["literal", [...osmIds]]]];
|
|
8
|
+
}
|
|
9
|
+
function matchByOsmId(pairs, fallback) {
|
|
10
|
+
if (pairs.length === 0) return fallback;
|
|
11
|
+
return ["match", ID_KEY, ...pairs, ["match", PROP_KEY, ...pairs, fallback]];
|
|
12
|
+
}
|
|
13
|
+
const osmLabel = (building) => {
|
|
14
|
+
var _a;
|
|
15
|
+
return String((_a = building.buildingOsmId) != null ? _a : "").trim();
|
|
16
|
+
};
|
|
17
|
+
const byOsmLabel = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
|
|
18
|
+
export {
|
|
19
|
+
byOsmLabel,
|
|
20
|
+
matchByOsmId,
|
|
21
|
+
matchesAnyOsmId,
|
|
22
|
+
matchesOsmId,
|
|
23
|
+
osmLabel
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=osmIdExpression.js.map
|
package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/osmIdExpression.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/BuildingLayers/osmIdExpression.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport type { PaintExpression } from \"./buildingColourExpression\";\nimport type { Building } from \"../../../../../../../types/dbTypes\";\n\n// Some tiles carry the OSM id only as a property rather than as the MVT feature id, so both are tried.\nconst ID_KEY: PaintExpression = [\"to-string\", [\"id\"]];\nconst PROP_KEY: PaintExpression = [\"to-string\", [\"coalesce\", [\"get\", \"osm_id\"], \"\"]];\n\nexport function matchesOsmId(osmId: string): PaintExpression {\n return [\"any\", [\"==\", ID_KEY, osmId], [\"==\", PROP_KEY, osmId]];\n}\n\nexport function matchesAnyOsmId(osmIds: readonly string[]): PaintExpression {\n return [\"any\", [\"in\", ID_KEY, [\"literal\", [...osmIds]]], [\"in\", PROP_KEY, [\"literal\", [...osmIds]]]];\n}\n\n/** A `match` on either OSM key over flattened `[osmId, output]` pairs; `fallback` alone when there are none. */\nexport function matchByOsmId(pairs: readonly (string | number)[], fallback: PaintExpression): PaintExpression {\n if (pairs.length === 0) return fallback;\n return [\"match\", ID_KEY, ...pairs, [\"match\", PROP_KEY, ...pairs, fallback]];\n}\n\n/** The building's OSM id as a `match` label; empty when it has none. */\nexport const osmLabel = (building: Pick<Building, \"buildingOsmId\">) => String(building.buildingOsmId ?? \"\").trim();\n\nexport const byOsmLabel = ([a]: readonly [string, unknown], [b]: readonly [string, unknown]) => (a < b ? -1 : a > b ? 1 : 0);\n"],"mappings":"AAOA,MAAM,SAA0B,CAAC,aAAa,CAAC,IAAI,CAAC;AACpD,MAAM,WAA4B,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,QAAQ,GAAG,EAAE,CAAC;AAE5E,SAAS,aAAa,OAAgC;AAC3D,SAAO,CAAC,OAAO,CAAC,MAAM,QAAQ,KAAK,GAAG,CAAC,MAAM,UAAU,KAAK,CAAC;AAC/D;AAEO,SAAS,gBAAgB,QAA4C;AAC1E,SAAO,CAAC,OAAO,CAAC,MAAM,QAAQ,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,UAAU,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;AACrG;AAGO,SAAS,aAAa,OAAqC,UAA4C;AAC5G,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,SAAO,CAAC,SAAS,QAAQ,GAAG,OAAO,CAAC,SAAS,UAAU,GAAG,OAAO,QAAQ,CAAC;AAC5E;AAGO,MAAM,WAAW,CAAC,aAA2C;AAzBpE;AAyBuE,iBAAO,cAAS,kBAAT,YAA0B,EAAE,EAAE,KAAK;AAAA;AAE1G,MAAM,aAAa,CAAC,CAAC,CAAC,GAA+B,CAAC,CAAC,MAAmC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Building } from "../../../../../../../../types/dbTypes";
|
|
2
|
+
interface DrawnBuildingsLayerProps {
|
|
3
|
+
buildings: Building[];
|
|
4
|
+
fallbackName: string;
|
|
5
|
+
onClosePopup: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function DrawnBuildingsLayer({ buildings, fallbackName, onClosePopup }: DrawnBuildingsLayerProps): any;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=DrawnBuildingsLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawnBuildingsLayer.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/DrawnBuildingsLayer.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAOtE,UAAU,wBAAwB;IAChC,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,wBAAgB,mBAAmB,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,wBAAwB,OAyFtG"}
|
package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/DrawnBuildingsLayer.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
import * as React from "react";
|
|
24
|
+
import { MapContext } from "../../../../../../../../store/Map/context";
|
|
25
|
+
import { MapLayerClickPriority } from "../../../../../utils/MapEventManager/MapClickManager";
|
|
26
|
+
import { ASSIGNED_COLOUR } from "../buildingColourExpression";
|
|
27
|
+
import { buildingPopupEntry } from "../buildingPopupEntry";
|
|
28
|
+
import { drawnFootprints, footprintsInBounds } from "../drawnFootprints";
|
|
29
|
+
import { useViewBounds } from "./useViewBounds";
|
|
30
|
+
const DRAWN_BUILDINGS_ID = "cdt-drawn-buildings";
|
|
31
|
+
const MIN_ZOOM = 14;
|
|
32
|
+
function DrawnBuildingsLayer({ buildings, fallbackName, onClosePopup }) {
|
|
33
|
+
const { state: mapState } = React.useContext(MapContext);
|
|
34
|
+
const { map, mapClickManager, show3dBuildings, editingFootprint } = mapState.map;
|
|
35
|
+
const editingId = editingFootprint == null ? void 0 : editingFootprint.buildingId;
|
|
36
|
+
const viewBounds = useViewBounds(map, MIN_ZOOM);
|
|
37
|
+
const allFootprints = React.useMemo(
|
|
38
|
+
() => drawnFootprints(buildings.filter((building) => building.id !== editingId)),
|
|
39
|
+
[buildings, editingId]
|
|
40
|
+
);
|
|
41
|
+
const footprints = React.useMemo(() => footprintsInBounds(allFootprints, viewBounds), [allFootprints, viewBounds]);
|
|
42
|
+
const latest = React.useRef({ footprints, show3dBuildings });
|
|
43
|
+
latest.current = { footprints, show3dBuildings };
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
if (!map) return;
|
|
46
|
+
const addLayer = () => {
|
|
47
|
+
if (map.getLayer(DRAWN_BUILDINGS_ID)) return;
|
|
48
|
+
try {
|
|
49
|
+
if (!map.getSource(DRAWN_BUILDINGS_ID)) {
|
|
50
|
+
map.addSource(DRAWN_BUILDINGS_ID, { type: "geojson", data: latest.current.footprints });
|
|
51
|
+
}
|
|
52
|
+
map.addLayer({
|
|
53
|
+
id: DRAWN_BUILDINGS_ID,
|
|
54
|
+
type: "fill-extrusion",
|
|
55
|
+
source: DRAWN_BUILDINGS_ID,
|
|
56
|
+
minzoom: MIN_ZOOM,
|
|
57
|
+
layout: { visibility: latest.current.show3dBuildings ? "visible" : "none" },
|
|
58
|
+
paint: {
|
|
59
|
+
"fill-extrusion-color": ASSIGNED_COLOUR,
|
|
60
|
+
"fill-extrusion-height": ["get", "height"],
|
|
61
|
+
"fill-extrusion-opacity": 0.85
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
} catch (e) {
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
addLayer();
|
|
68
|
+
map.on("styledata", addLayer);
|
|
69
|
+
map.on("idle", addLayer);
|
|
70
|
+
return () => {
|
|
71
|
+
map.off("styledata", addLayer);
|
|
72
|
+
map.off("idle", addLayer);
|
|
73
|
+
try {
|
|
74
|
+
if (map.getLayer(DRAWN_BUILDINGS_ID)) map.removeLayer(DRAWN_BUILDINGS_ID);
|
|
75
|
+
if (map.getSource(DRAWN_BUILDINGS_ID)) map.removeSource(DRAWN_BUILDINGS_ID);
|
|
76
|
+
} catch (e) {
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}, [map]);
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
var _a;
|
|
82
|
+
void ((_a = map == null ? void 0 : map.getSource(DRAWN_BUILDINGS_ID)) == null ? void 0 : _a.setData(footprints));
|
|
83
|
+
}, [map, footprints]);
|
|
84
|
+
React.useEffect(() => {
|
|
85
|
+
if (!(map == null ? void 0 : map.getLayer(DRAWN_BUILDINGS_ID))) return;
|
|
86
|
+
map.setLayoutProperty(DRAWN_BUILDINGS_ID, "visibility", show3dBuildings ? "visible" : "none");
|
|
87
|
+
}, [map, show3dBuildings]);
|
|
88
|
+
React.useEffect(() => {
|
|
89
|
+
if (!mapClickManager) return;
|
|
90
|
+
const resolvePopups = (e, hits) => {
|
|
91
|
+
const coordinates = [e.lngLat.lng, e.lngLat.lat];
|
|
92
|
+
return hits.map((hit) => {
|
|
93
|
+
var _a;
|
|
94
|
+
const { dbId, name } = (_a = hit.properties) != null ? _a : {};
|
|
95
|
+
const feature = Object.assign(hit, { properties: __spreadProps(__spreadValues({}, hit.properties), { coordinates, isBuilding: true, isDbBuilding: true }) });
|
|
96
|
+
return buildingPopupEntry({
|
|
97
|
+
layerId: DRAWN_BUILDINGS_ID,
|
|
98
|
+
key: String(dbId),
|
|
99
|
+
title: name || fallbackName,
|
|
100
|
+
coordinates,
|
|
101
|
+
feature,
|
|
102
|
+
onClose: onClosePopup
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
mapClickManager.register(DRAWN_BUILDINGS_ID, MapLayerClickPriority.BuildingLayersClickPriority, resolvePopups);
|
|
107
|
+
return () => mapClickManager.unregister(DRAWN_BUILDINGS_ID);
|
|
108
|
+
}, [mapClickManager, fallbackName, onClosePopup]);
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
export {
|
|
112
|
+
DrawnBuildingsLayer
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=DrawnBuildingsLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/DrawnBuildingsLayer.tsx"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from \"react\";\n\nimport { MapContext } from \"../../../../../../../../store/Map/context\";\nimport { MapLayerClickPriority } from \"../../../../../utils/MapEventManager/MapClickManager\";\nimport { ASSIGNED_COLOUR } from \"../buildingColourExpression\";\nimport { buildingPopupEntry } from \"../buildingPopupEntry\";\nimport { drawnFootprints, footprintsInBounds } from \"../drawnFootprints\";\n\nimport { useViewBounds } from \"./useViewBounds\";\n\nimport type { Building } from \"../../../../../../../../types/dbTypes\";\nimport type { PopupEntry } from \"../../../../../../../../types/map\";\nimport type { GeoJSONSource, MapGeoJSONFeature, MapMouseEvent } from \"maplibre-gl\";\n\nconst DRAWN_BUILDINGS_ID = \"cdt-drawn-buildings\";\nconst MIN_ZOOM = 14;\n\ninterface DrawnBuildingsLayerProps {\n buildings: Building[];\n fallbackName: string;\n onClosePopup: () => void;\n}\n\nexport function DrawnBuildingsLayer({ buildings, fallbackName, onClosePopup }: DrawnBuildingsLayerProps) {\n const { state: mapState } = React.useContext(MapContext);\n const { map, mapClickManager, show3dBuildings, editingFootprint } = mapState.map;\n const editingId = editingFootprint?.buildingId;\n const viewBounds = useViewBounds(map, MIN_ZOOM);\n\n const allFootprints = React.useMemo(\n () => drawnFootprints(buildings.filter(building => building.id !== editingId)),\n [buildings, editingId],\n );\n const footprints = React.useMemo(() => footprintsInBounds(allFootprints, viewBounds), [allFootprints, viewBounds]);\n const latest = React.useRef({ footprints, show3dBuildings });\n latest.current = { footprints, show3dBuildings };\n\n React.useEffect(() => {\n if (!map) return;\n\n // isStyleLoaded() stays false while any tile source is loading, so it cannot gate this.\n const addLayer = () => {\n if (map.getLayer(DRAWN_BUILDINGS_ID)) return;\n try {\n if (!map.getSource(DRAWN_BUILDINGS_ID)) {\n map.addSource(DRAWN_BUILDINGS_ID, { type: \"geojson\", data: latest.current.footprints });\n }\n map.addLayer({\n id: DRAWN_BUILDINGS_ID,\n type: \"fill-extrusion\",\n source: DRAWN_BUILDINGS_ID,\n minzoom: MIN_ZOOM,\n layout: { visibility: latest.current.show3dBuildings ? \"visible\" : \"none\" },\n paint: {\n \"fill-extrusion-color\": ASSIGNED_COLOUR,\n \"fill-extrusion-height\": [\"get\", \"height\"],\n \"fill-extrusion-opacity\": 0.85,\n },\n });\n } catch {\n // The style is mid-swap; the next styledata or idle event retries.\n }\n };\n\n addLayer();\n map.on(\"styledata\", addLayer);\n map.on(\"idle\", addLayer);\n return () => {\n map.off(\"styledata\", addLayer);\n map.off(\"idle\", addLayer);\n try {\n if (map.getLayer(DRAWN_BUILDINGS_ID)) map.removeLayer(DRAWN_BUILDINGS_ID);\n if (map.getSource(DRAWN_BUILDINGS_ID)) map.removeSource(DRAWN_BUILDINGS_ID);\n } catch {\n // The map may already be destroyed when the layer unmounts.\n }\n };\n }, [map]);\n\n React.useEffect(() => {\n void (map?.getSource(DRAWN_BUILDINGS_ID) as GeoJSONSource | undefined)?.setData(footprints);\n }, [map, footprints]);\n\n React.useEffect(() => {\n if (!map?.getLayer(DRAWN_BUILDINGS_ID)) return;\n map.setLayoutProperty(DRAWN_BUILDINGS_ID, \"visibility\", show3dBuildings ? \"visible\" : \"none\");\n }, [map, show3dBuildings]);\n\n React.useEffect(() => {\n if (!mapClickManager) return;\n\n const resolvePopups = (e: MapMouseEvent, hits: MapGeoJSONFeature[]): PopupEntry[] => {\n const coordinates: [number, number] = [e.lngLat.lng, e.lngLat.lat];\n return hits.map((hit) => {\n const { dbId, name } = hit.properties ?? {};\n const feature = Object.assign(hit, { properties: { ...hit.properties, coordinates, isBuilding: true, isDbBuilding: true } });\n return buildingPopupEntry({\n layerId: DRAWN_BUILDINGS_ID,\n key: String(dbId),\n title: (name as string | null) || fallbackName,\n coordinates,\n feature,\n onClose: onClosePopup,\n });\n });\n };\n\n mapClickManager.register(DRAWN_BUILDINGS_ID, MapLayerClickPriority.BuildingLayersClickPriority, resolvePopups);\n return () => mapClickManager.unregister(DRAWN_BUILDINGS_ID);\n }, [mapClickManager, fallbackName, onClosePopup]);\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAKA,YAAY,WAAW;AAEvB,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,iBAAiB,0BAA0B;AAEpD,SAAS,qBAAqB;AAM9B,MAAM,qBAAqB;AAC3B,MAAM,WAAW;AAQV,SAAS,oBAAoB,EAAE,WAAW,cAAc,aAAa,GAA6B;AACvG,QAAM,EAAE,OAAO,SAAS,IAAI,MAAM,WAAW,UAAU;AACvD,QAAM,EAAE,KAAK,iBAAiB,iBAAiB,iBAAiB,IAAI,SAAS;AAC7E,QAAM,YAAY,qDAAkB;AACpC,QAAM,aAAa,cAAc,KAAK,QAAQ;AAE9C,QAAM,gBAAgB,MAAM;AAAA,IAC1B,MAAM,gBAAgB,UAAU,OAAO,cAAY,SAAS,OAAO,SAAS,CAAC;AAAA,IAC7E,CAAC,WAAW,SAAS;AAAA,EACvB;AACA,QAAM,aAAa,MAAM,QAAQ,MAAM,mBAAmB,eAAe,UAAU,GAAG,CAAC,eAAe,UAAU,CAAC;AACjH,QA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oBAAoB,cAAc,kBAAkB,YAAY,MAAM;AAAA,EAC9F,GAAG,CAAC,KAAK,eAAe,CAAC;AAEzB,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,gBAAiB;AAEtB,UAAM,gBAAgB,CAAC,GAAkB,SAA4C;AACnF,YAAM,cAAgC,CAAC,EAAE,OAAO,KAAK,EAAE,OAAO,GAAG;AACjE,aAAO,KAAK,IAAI,CAAC,QAAQ;AAlG/B;AAmGQ,cAAM,EAAE,MAAM,KAAK,KAAI,SAAI,eAAJ,YAAkB,CAAC;AAC1C,cAAM,UAAU,OAAO,OAAO,KAAK,EAAE,YAAY,iCAAK,IAAI,aAAT,EAAqB,aAAa,YAAY,MAAM,cAAc,KAAK,GAAE,CAAC;AAC3H,eAAO,mBAAmB;AAAA,UACxB,SAAS;AAAA,UACT,KAAK,OAAO,IAAI;AAAA,UAChB,OAAQ,QAA0B;AAAA,UAClC;AAAA,UACA;AAAA,UACA,SAAS;AAAA,QACX,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAEA,oBAAgB,SAAS,oBAAoB,sBAAsB,6BAA6B,aAAa;AAC7G,WAAO,MAAM,gBAAgB,WAAW,kBAAkB;AAAA,EAC5D,GAAG,CAAC,iBAAiB,cAAc,YAAY,CAAC;AAEhD,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FootprintEditor.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/FootprintEditor.tsx"],"names":[],"mappings":"AAmBA,0FAA0F;AAC1F,wBAAgB,eAAe,QAyD9B"}
|
package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/FootprintEditor.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
import { useTranslations } from "next-intl";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { toast } from "sonner";
|
|
7
|
+
import { useBuilding } from "../../../../../../../../hooks/buildings/buildings";
|
|
8
|
+
import { MapContext } from "../../../../../../../../store/Map/context";
|
|
9
|
+
import { usePolygonDraw } from "../../../../tools/AddTools/shared/usePolygonDraw";
|
|
10
|
+
import { polygonCentroid } from "../../SiteLayer/siteGeometry";
|
|
11
|
+
import { buildingGeometryToRing, ringToBuildingGeometry } from "../buildingGeometry";
|
|
12
|
+
const EDIT_TOAST_ID = "footprint-editor";
|
|
13
|
+
function FootprintEditor() {
|
|
14
|
+
var _a;
|
|
15
|
+
const t = useTranslations("FootprintEditor");
|
|
16
|
+
const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext);
|
|
17
|
+
const { map, mapClickManager, editingFootprint } = mapState.map;
|
|
18
|
+
const buildingId = (_a = editingFootprint == null ? void 0 : editingFootprint.buildingId) != null ? _a : null;
|
|
19
|
+
const { building, updateBuilding } = useBuilding(buildingId);
|
|
20
|
+
const startedForRef = React.useRef(null);
|
|
21
|
+
const stopEditing = React.useCallback(() => {
|
|
22
|
+
mapDispatch({ type: "SET_EDITING_FOOTPRINT", payload: { editingFootprint: null } });
|
|
23
|
+
}, [mapDispatch]);
|
|
24
|
+
const save = async (ring) => {
|
|
25
|
+
const toastId = toast.loading(t("saving"));
|
|
26
|
+
try {
|
|
27
|
+
const [lng, lat] = polygonCentroid(ring);
|
|
28
|
+
await updateBuilding({ buildingGeometry: ringToBuildingGeometry(ring), buildingLongitude: lng, buildingLatitude: lat });
|
|
29
|
+
toast.success(t("saved"), { id: toastId });
|
|
30
|
+
stopEditing();
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error("Failed to save the building footprint:", error);
|
|
33
|
+
toast.error(t("saveFailed"), { id: toastId });
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const { start } = usePolygonDraw({
|
|
38
|
+
map,
|
|
39
|
+
mapClickManager,
|
|
40
|
+
enabled: buildingId != null,
|
|
41
|
+
toastId: EDIT_TOAST_ID,
|
|
42
|
+
onFinish: save,
|
|
43
|
+
onCancel: stopEditing,
|
|
44
|
+
labels: {
|
|
45
|
+
mapNotReady: t("mapNotReady"),
|
|
46
|
+
cancelled: t("cancelled"),
|
|
47
|
+
needThreePoints: t("needThreePoints"),
|
|
48
|
+
title: t("title"),
|
|
49
|
+
hint: (count) => t("hint", { count }),
|
|
50
|
+
finish: t("save"),
|
|
51
|
+
cancel: t("cancel")
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
var _a2, _b;
|
|
56
|
+
if (buildingId == null) {
|
|
57
|
+
startedForRef.current = null;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (startedForRef.current === buildingId || (building == null ? void 0 : building.id) !== buildingId) return;
|
|
61
|
+
startedForRef.current = buildingId;
|
|
62
|
+
const ring = (_b = (_a2 = buildingGeometryToRing(building.buildingGeometry)) != null ? _a2 : editingFootprint == null ? void 0 : editingFootprint.seedRing) != null ? _b : [];
|
|
63
|
+
if (!start(ring)) stopEditing();
|
|
64
|
+
}, [buildingId, building, editingFootprint, start, stopEditing]);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
FootprintEditor
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=FootprintEditor.js.map
|
package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/FootprintEditor.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/FootprintEditor.tsx"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useTranslations } from \"next-intl\";\nimport * as React from \"react\";\nimport { toast } from \"sonner\";\n\nimport { useBuilding } from \"../../../../../../../../hooks/buildings/buildings\";\nimport { MapContext } from \"../../../../../../../../store/Map/context\";\nimport { usePolygonDraw } from \"../../../../tools/AddTools/shared/usePolygonDraw\";\nimport { polygonCentroid } from \"../../SiteLayer/siteGeometry\";\nimport { buildingGeometryToRing, ringToBuildingGeometry } from \"../buildingGeometry\";\n\nimport type { Ring } from \"../../SiteLayer/siteGeometry\";\n\nconst EDIT_TOAST_ID = \"footprint-editor\";\n\n/** Reshapes the footprint of the building named by the map store's `editingFootprint`. */\nexport function FootprintEditor() {\n const t = useTranslations(\"FootprintEditor\");\n const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext);\n const { map, mapClickManager, editingFootprint } = mapState.map;\n const buildingId = editingFootprint?.buildingId ?? null;\n const { building, updateBuilding } = useBuilding(buildingId);\n const startedForRef = React.useRef<number | null>(null);\n\n const stopEditing = React.useCallback(() => {\n mapDispatch({ type: \"SET_EDITING_FOOTPRINT\", payload: { editingFootprint: null } });\n }, [mapDispatch]);\n\n const save = async (ring: Ring) => {\n const toastId = toast.loading(t(\"saving\"));\n try {\n const [lng, lat] = polygonCentroid(ring);\n await updateBuilding({ buildingGeometry: ringToBuildingGeometry(ring), buildingLongitude: lng, buildingLatitude: lat });\n toast.success(t(\"saved\"), { id: toastId });\n stopEditing();\n }\n catch (error) {\n console.error(\"Failed to save the building footprint:\", error);\n toast.error(t(\"saveFailed\"), { id: toastId });\n throw error;\n }\n };\n\n const { start } = usePolygonDraw({\n map,\n mapClickManager,\n enabled: buildingId != null,\n toastId: EDIT_TOAST_ID,\n onFinish: save,\n onCancel: stopEditing,\n labels: {\n mapNotReady: t(\"mapNotReady\"),\n cancelled: t(\"cancelled\"),\n needThreePoints: t(\"needThreePoints\"),\n title: t(\"title\"),\n hint: count => t(\"hint\", { count }),\n finish: t(\"save\"),\n cancel: t(\"cancel\"),\n },\n });\n\n React.useEffect(() => {\n if (buildingId == null) {\n startedForRef.current = null;\n return;\n }\n if (startedForRef.current === buildingId || building?.id !== buildingId) return;\n startedForRef.current = buildingId;\n const ring = buildingGeometryToRing(building.buildingGeometry)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AAE,MAAM,IAAI,eAAe;AAAA,IAC/B;AAAA,IACA;AAAA,IACA,SAAS,cAAc;AAAA,IACvB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,UAAU;AAAA,IACV,QAAQ;AAAA,MACN,aAAa,EAAE,aAAa;AAAA,MAC5B,WAAW,EAAE,WAAW;AAAA,MACxB,iBAAiB,EAAE,iBAAiB;AAAA,MACpC,OAAO,EAAE,OAAO;AAAA,MAChB,MAAM,WAAS,EAAE,QAAQ,EAAE,MAAM,CAAC;AAAA,MAClC,QAAQ,EAAE,MAAM;AAAA,MAChB,QAAQ,EAAE,QAAQ;AAAA,IACpB;AAAA,EACF,CAAC;AAED,QAAM,UAAU,MAAM;AAjExB,QAAAA,KAAA;AAkEI,QAAI,cAAc,MAAM;AACtB,oBAAc,UAAU;AACxB;AAAA,IACF;AACA,QAAI,cAAc,YAAY,eAAc,qCAAU,QAAO,WAAY;AACzE,kBAAc,UAAU;AACxB,UAAM,QAAO,MAAAA,MAAA,uBAAuB,SAAS,gBAAgB,MAAhD,OAAAA,MAAqD,qDAAkB,aAAvE,YAAmF,CAAC;AACjG,QAAI,CAAC,MAAM,IAAI,EAAG,aAAY;AAAA,EAChC,GAAG,CAAC,YAAY,UAAU,kBAAkB,OAAO,WAAW,CAAC;AAE/D,SAAO;AACT;","names":["_a"]}
|
package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/useViewBounds.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type FlatBounds } from "../../../../../utils/validateBounds";
|
|
2
|
+
import type { Map } from "maplibre-gl";
|
|
3
|
+
/** The camera's bounds padded by half a screen, refreshed when the camera settles; null below `minZoom`. */
|
|
4
|
+
export declare function useViewBounds(map: Map | null | undefined, minZoom: number): FlatBounds | null;
|
|
5
|
+
//# sourceMappingURL=useViewBounds.d.ts.map
|
package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/useViewBounds.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useViewBounds.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/useViewBounds.ts"],"names":[],"mappings":"AAKA,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAE/E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAWvC,4GAA4G;AAC5G,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAY7F"}
|
package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/src/useViewBounds.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { mapBbox } from "../../../../../utils/validateBounds";
|
|
3
|
+
const PADDING_RATIO = 0.5;
|
|
4
|
+
function paddedBounds(map) {
|
|
5
|
+
const [west, south, east, north] = mapBbox(map);
|
|
6
|
+
const padLng = (east - west) * PADDING_RATIO;
|
|
7
|
+
const padLat = (north - south) * PADDING_RATIO;
|
|
8
|
+
return [west - padLng, south - padLat, east + padLng, north + padLat];
|
|
9
|
+
}
|
|
10
|
+
function useViewBounds(map, minZoom) {
|
|
11
|
+
const [bounds, setBounds] = React.useState(null);
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
if (!map) return;
|
|
14
|
+
const update = () => setBounds(map.getZoom() >= minZoom ? paddedBounds(map) : null);
|
|
15
|
+
update();
|
|
16
|
+
map.on("moveend", update);
|
|
17
|
+
return () => {
|
|
18
|
+
map.off("moveend", update);
|
|
19
|
+
};
|
|
20
|
+
}, [map, minZoom]);
|
|
21
|
+
return bounds;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
useViewBounds
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=useViewBounds.js.map
|