@collabdt/core 0.11.2 → 0.12.1
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/FilesManager/src/FileItemComponent.js.map +1 -1
- package/dist/core/components/ui/uploadFile.d.ts +3 -2
- package/dist/core/components/ui/uploadFile.d.ts.map +1 -1
- package/dist/core/components/ui/uploadFile.js +8 -7
- package/dist/core/components/ui/uploadFile.js.map +1 -1
- package/dist/core/components/viewers/Viewer.d.ts.map +1 -1
- package/dist/core/components/viewers/Viewer.js +7 -10
- package/dist/core/components/viewers/Viewer.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimLoadingState/index.js +1 -1
- package/dist/core/components/viewers/bim/src/BimLoadingState/index.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/usePlaceableFileRows.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/usePlaceableFileRows.js +12 -13
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/usePlaceableFileRows.js.map +1 -1
- package/dist/core/components/viewers/bim/src/Splats/splatPlacementStore.d.ts +3 -3
- package/dist/core/components/viewers/bim/src/Splats/splatPlacementStore.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/Splats/splatPlacementStore.js +2 -18
- package/dist/core/components/viewers/bim/src/Splats/splatPlacementStore.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/applyModelPlacement.d.ts +1 -1
- package/dist/core/components/viewers/bim/src/lib/applyModelPlacement.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/applyModelPlacement.js +2 -2
- package/dist/core/components/viewers/bim/src/lib/applyModelPlacement.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/buildingLocationParams.d.ts +1 -0
- package/dist/core/components/viewers/bim/src/lib/buildingLocationParams.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/buildingLocationParams.js +10 -2
- package/dist/core/components/viewers/bim/src/lib/buildingLocationParams.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/useViewerLocation.d.ts +1 -1
- package/dist/core/components/viewers/bim/src/lib/useViewerLocation.js.map +1 -1
- package/dist/core/components/viewers/bim/utils/setCameraLookAt.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/utils/setCameraLookAt.js +13 -14
- package/dist/core/components/viewers/bim/utils/setCameraLookAt.js.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.js +11 -8
- package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/minioDatasets.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/minioDatasets.js +16 -8
- package/dist/core/components/viewers/map/datasets/src/minioDatasets.js.map +1 -1
- package/dist/core/components/viewers/map/src/Geocoder.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/Geocoder.js +23 -20
- package/dist/core/components/viewers/map/src/Geocoder.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.js +7 -6
- package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/FileModelLayer/FileModelLayer.js +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/FileModelLayer/FileModelLayer.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/utils/CustomModelLayer.js +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/utils/CustomModelLayer.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.js +12 -23
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/useDatasetFeatures.d.ts +23 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/useDatasetFeatures.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/useDatasetFeatures.js +67 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/useDatasetFeatures.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/useViewportDatasetToast.d.ts +4 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/useViewportDatasetToast.d.ts.map +1 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/useViewportDatasetToast.js +24 -0
- package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/useViewportDatasetToast.js.map +1 -0
- package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.js +12 -32
- package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/LocationSettings.js.map +1 -1
- package/dist/core/components/viewers/map/src/Placement/MapPlacementHost.js +1 -1
- package/dist/core/components/viewers/map/src/Placement/MapPlacementHost.js.map +1 -1
- package/dist/core/components/viewers/map/src/Placement/mapPlacementGeo.d.ts +1 -1
- package/dist/core/components/viewers/map/src/Placement/mapPlacementGeo.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/Placement/mapPlacementGeo.js +2 -2
- package/dist/core/components/viewers/map/src/Placement/mapPlacementGeo.js.map +1 -1
- package/dist/core/components/viewers/map/src/Placement/mapPlacementTarget.js +1 -1
- package/dist/core/components/viewers/map/src/Placement/mapPlacementTarget.js.map +1 -1
- package/dist/core/components/viewers/map/src/Placement/useMapPlacementTarget.js +1 -1
- package/dist/core/components/viewers/map/src/Placement/useMapPlacementTarget.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/shareMapTool.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/tools/shareMapTool.js +24 -14
- package/dist/core/components/viewers/map/src/tools/shareMapTool.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoder.d.ts +1 -0
- package/dist/core/components/viewers/map/utils/geocoder.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoder.js +5 -0
- package/dist/core/components/viewers/map/utils/geocoder.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/adapters.d.ts +2 -0
- package/dist/core/components/viewers/map/utils/geocoding/adapters.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/adapters.js +8 -1
- package/dist/core/components/viewers/map/utils/geocoding/adapters.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/index.d.ts +3 -0
- package/dist/core/components/viewers/map/utils/geocoding/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/index.js +20 -3
- package/dist/core/components/viewers/map/utils/geocoding/index.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/osm.d.ts +2 -0
- package/dist/core/components/viewers/map/utils/geocoding/osm.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/osm.js +32 -1
- package/dist/core/components/viewers/map/utils/geocoding/osm.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/pelias.d.ts +2 -0
- package/dist/core/components/viewers/map/utils/geocoding/pelias.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/pelias.js +30 -1
- package/dist/core/components/viewers/map/utils/geocoding/pelias.js.map +1 -1
- package/dist/core/components/viewers/map/utils/geocoding/placeSearch.d.ts +17 -0
- package/dist/core/components/viewers/map/utils/geocoding/placeSearch.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/geocoding/placeSearch.js +26 -0
- package/dist/core/components/viewers/map/utils/geocoding/placeSearch.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.d.ts +38 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.js +91 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationParams.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationTarget.d.ts +25 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationTarget.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationTarget.js +71 -0
- package/dist/core/components/viewers/map/utils/urlLocation/locationTarget.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.d.ts +20 -0
- package/dist/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.js +103 -0
- package/dist/core/components/viewers/map/utils/urlLocation/resolveLocationTarget.js.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/useUrlFlyTo.d.ts +4 -0
- package/dist/core/components/viewers/map/utils/urlLocation/useUrlFlyTo.d.ts.map +1 -0
- package/dist/core/components/viewers/map/utils/urlLocation/useUrlFlyTo.js +72 -0
- package/dist/core/components/viewers/map/utils/urlLocation/useUrlFlyTo.js.map +1 -0
- package/dist/core/components/viewers/shared/intake/useFileIntake.d.ts.map +1 -1
- package/dist/core/components/viewers/shared/intake/useFileIntake.js +3 -26
- package/dist/core/components/viewers/shared/intake/useFileIntake.js.map +1 -1
- package/dist/core/components/viewers/shared/placement/fileTransform.d.ts +9 -0
- package/dist/core/components/viewers/shared/placement/fileTransform.d.ts.map +1 -0
- package/dist/core/components/viewers/shared/placement/fileTransform.js +32 -0
- package/dist/core/components/viewers/shared/placement/fileTransform.js.map +1 -0
- package/dist/core/components/viewers/shared/placement/objectTarget.js +2 -2
- package/dist/core/components/viewers/shared/placement/objectTarget.js.map +1 -1
- package/dist/core/components/viewers/shared/pointcloud/pointCloudPlacementStore.d.ts +2 -3
- package/dist/core/components/viewers/shared/pointcloud/pointCloudPlacementStore.d.ts.map +1 -1
- package/dist/core/components/viewers/shared/pointcloud/pointCloudPlacementStore.js +4 -14
- package/dist/core/components/viewers/shared/pointcloud/pointCloudPlacementStore.js.map +1 -1
- package/dist/core/hooks/useShareUrl.d.ts.map +1 -1
- package/dist/core/hooks/useShareUrl.js +5 -9
- package/dist/core/hooks/useShareUrl.js.map +1 -1
- package/dist/core/i18n/messages/en.json +4 -0
- package/dist/core/i18n/messages/es.json +4 -0
- package/dist/core/i18n/messages/fr.json +4 -0
- package/dist/core/types/datasetTypes.d.ts +5 -0
- package/dist/core/types/datasetTypes.d.ts.map +1 -1
- package/dist/core/types/dbTypes.d.ts +40 -0
- package/dist/core/types/dbTypes.d.ts.map +1 -1
- package/dist/core/types/dbTypes.js +18 -0
- package/dist/core/types/dbTypes.js.map +1 -1
- package/dist/core/types/index.d.ts +2 -2
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/core/types/index.js +7 -1
- package/dist/core/types/index.js.map +1 -1
- package/dist/core/utils/geo/reprojectGeometry.d.ts +14 -0
- package/dist/core/utils/geo/reprojectGeometry.d.ts.map +1 -0
- package/dist/core/utils/geo/reprojectGeometry.js +58 -0
- package/dist/core/utils/geo/reprojectGeometry.js.map +1 -0
- package/dist/core/utils/geo/wktToGeometry.d.ts +5 -0
- package/dist/core/utils/geo/wktToGeometry.d.ts.map +1 -0
- package/dist/core/utils/geo/wktToGeometry.js +34 -0
- package/dist/core/utils/geo/wktToGeometry.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/Placement/MapPlacementHost.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'\n\nimport { MapContext, ToolsContext } from '../../../../../store'\nimport { PlacementPanel } from '../../../shared/placement/PlacementPanel'\nimport { usePlacementCommitToasts } from '../../../shared/placement/usePlacementCommitToasts'\n\nimport { createMapGizmoLayer, MAP_GIZMO_LAYER_ID } from './MapGizmoLayer'\nimport { mapCapabilitiesForFile } from './mapPlacementTarget'\nimport { createMapGizmoFactory, mapToolCoordinator, rollbackOnFailure, useMapPlacementSession } from './useMapPlacementSession'\nimport { useMapPlacementTarget } from './useMapPlacementTarget'\n\nimport type { MapAnchor } from './mapPlacementGeo'\nimport type { DbFile } from '../../../../../types/dbTypes'\nimport type { PlacementMode } from '../../../shared/placement/placementTarget'\n\nconst POSITION_LABELS = ['lng', 'lat', 'elev'] as const\nconst POSITION_STEPS: [number, number, number] = [0.000_01, 0.000_01, 0.1]\nconst POSITION_DECIMALS = 6\nconst DEG_TO_RAD = Math.PI / 180\n\nexport interface MapPlacementHostProps {\n file: DbFile | null\n mode: PlacementMode\n is3D: boolean\n anchor: () => MapAnchor\n /** Degrees the file already stands at, for a caller whose fallback is not the file's own column. */\n rotation?: number\n preview: (anchor: MapAnchor, rotation: number, scale: number) => void\n onRepaint: () => void\n onDone: () => void\n}\n\nexport function MapPlacementHost({ file, mode, is3D, anchor, rotation, preview, onRepaint, onDone }: MapPlacementHostProps) {\n const t = useTranslations('Placement')\n const { state: mapState } = React.useContext(MapContext)\n const { state: toolsState, dispatch: toolsDispatch } = React.useContext(ToolsContext)\n const { map } = mapState.map\n const { currentToolId } = toolsState.tools\n\n const layerRef = React.useRef<ReturnType<typeof createMapGizmoLayer> | null>(null)\n const [layerReady, setLayerReady] = React.useState(false)\n const { targetFor } = useMapPlacementTarget()\n\n const live = React.useRef({ anchor, preview, onRepaint })\n live.current = { anchor, preview, onRepaint }\n\n const readAnchor = React.useCallback(() => live.current.anchor(), [])\n\n React.useEffect(() => {\n if (!map) return\n const layer = createMapGizmoLayer(readAnchor)\n layerRef.current = layer\n map.addLayer(layer)\n setLayerReady(true)\n\n return () => {\n if (map.getLayer(MAP_GIZMO_LAYER_ID)) map.removeLayer(MAP_GIZMO_LAYER_ID)\n layerRef.current = null\n setLayerReady(false)\n }\n }, [map, readAnchor])\n\n const { core, state } = useMapPlacementSession(layerReady ? layerRef.current : null)\n\n const previewAndRepaint = React.useCallback((next: MapAnchor, rotation: number, scale: number) => {\n live.current.preview(next, rotation, scale)\n live.current.onRepaint()\n }, [])\n\n usePlacementCommitToasts(core.onCommitted)\n\n const snapshot = React.useRef<MapAnchor | null>(null)\n const stored = React.useRef({ rotation: 0, scale: 1 })\n stored.current = {\n rotation: (rotation ?? file?.rotation ?? 0) * DEG_TO_RAD,\n scale: file?.
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/Placement/MapPlacementHost.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'\n\nimport { MapContext, ToolsContext } from '../../../../../store'\nimport { PlacementPanel } from '../../../shared/placement/PlacementPanel'\nimport { usePlacementCommitToasts } from '../../../shared/placement/usePlacementCommitToasts'\n\nimport { createMapGizmoLayer, MAP_GIZMO_LAYER_ID } from './MapGizmoLayer'\nimport { mapCapabilitiesForFile } from './mapPlacementTarget'\nimport { createMapGizmoFactory, mapToolCoordinator, rollbackOnFailure, useMapPlacementSession } from './useMapPlacementSession'\nimport { useMapPlacementTarget } from './useMapPlacementTarget'\n\nimport type { MapAnchor } from './mapPlacementGeo'\nimport type { DbFile } from '../../../../../types/dbTypes'\nimport type { PlacementMode } from '../../../shared/placement/placementTarget'\n\nconst POSITION_LABELS = ['lng', 'lat', 'elev'] as const\nconst POSITION_STEPS: [number, number, number] = [0.000_01, 0.000_01, 0.1]\nconst POSITION_DECIMALS = 6\nconst DEG_TO_RAD = Math.PI / 180\n\nexport interface MapPlacementHostProps {\n file: DbFile | null\n mode: PlacementMode\n is3D: boolean\n anchor: () => MapAnchor\n /** Degrees the file already stands at, for a caller whose fallback is not the file's own column. */\n rotation?: number\n preview: (anchor: MapAnchor, rotation: number, scale: number) => void\n onRepaint: () => void\n onDone: () => void\n}\n\nexport function MapPlacementHost({ file, mode, is3D, anchor, rotation, preview, onRepaint, onDone }: MapPlacementHostProps) {\n const t = useTranslations('Placement')\n const { state: mapState } = React.useContext(MapContext)\n const { state: toolsState, dispatch: toolsDispatch } = React.useContext(ToolsContext)\n const { map } = mapState.map\n const { currentToolId } = toolsState.tools\n\n const layerRef = React.useRef<ReturnType<typeof createMapGizmoLayer> | null>(null)\n const [layerReady, setLayerReady] = React.useState(false)\n const { targetFor } = useMapPlacementTarget()\n\n const live = React.useRef({ anchor, preview, onRepaint })\n live.current = { anchor, preview, onRepaint }\n\n const readAnchor = React.useCallback(() => live.current.anchor(), [])\n\n React.useEffect(() => {\n if (!map) return\n const layer = createMapGizmoLayer(readAnchor)\n layerRef.current = layer\n map.addLayer(layer)\n setLayerReady(true)\n\n return () => {\n if (map.getLayer(MAP_GIZMO_LAYER_ID)) map.removeLayer(MAP_GIZMO_LAYER_ID)\n layerRef.current = null\n setLayerReady(false)\n }\n }, [map, readAnchor])\n\n const { core, state } = useMapPlacementSession(layerReady ? layerRef.current : null)\n\n const previewAndRepaint = React.useCallback((next: MapAnchor, rotation: number, scale: number) => {\n live.current.preview(next, rotation, scale)\n live.current.onRepaint()\n }, [])\n\n usePlacementCommitToasts(core.onCommitted)\n\n const snapshot = React.useRef<MapAnchor | null>(null)\n const stored = React.useRef({ rotation: 0, scale: 1 })\n stored.current = {\n rotation: (rotation ?? file?.rotation ?? 0) * DEG_TO_RAD,\n scale: file?.fileScale ?? 1,\n }\n\n React.useEffect(() => rollbackOnFailure(core, () => {\n if (snapshot.current) previewAndRepaint(snapshot.current, stored.current.rotation, stored.current.scale)\n }), [core, previewAndRepaint])\n\n React.useEffect(() => {\n const layer = layerRef.current\n if (!file || !map || !layer || !layerReady) return\n\n snapshot.current = readAnchor()\n core.setup({\n coordinator: mapToolCoordinator(toolsDispatch),\n createGizmo: createMapGizmoFactory({\n layer,\n map,\n anchor: readAnchor,\n onDragTo: next => previewAndRepaint(next, 0, 1),\n capabilities: () => mapCapabilitiesForFile(file, is3D),\n }),\n })\n void core.begin(\n targetFor({ file, object: () => layer.subject(), anchor: readAnchor, preview: previewAndRepaint, rotation }),\n mode,\n )\n }, [file, mode, map, layerReady, core, readAnchor, previewAndRepaint, targetFor, is3D, rotation, toolsDispatch])\n\n // A toolbar tool taking the cursor ends the edit rather than fighting it for pointer events.\n React.useEffect(() => {\n if (currentToolId) core.deactivate()\n }, [currentToolId, core])\n\n const labels = React.useMemo(() => ({\n title: t('title'),\n position: t('position'),\n rotation: t('rotation'),\n yaw: t('yaw'),\n scale: t('scale'),\n translate: t('modeTranslate'),\n rotate: t('modeRotate'),\n reset: t('reset'),\n done: t('done'),\n centre: t('centre'),\n pickPivot: t('pickPivot'),\n pivotSet: t('pivotSet'),\n pivotOrigin: t('pivotOrigin'),\n unit_mm: t('unit_mm'),\n unit_cm: t('unit_cm'),\n unit_m: t('unit_m'),\n unit_in: t('unit_in'),\n }), [t])\n\n if (!file || !state) return null\n\n return (\n <PlacementPanel\n name={state.name}\n capabilities={state.capabilities}\n placement={state.placement}\n mode={state.mode}\n labels={labels}\n positionLabels={POSITION_LABELS}\n positionSteps={POSITION_STEPS}\n positionDecimals={POSITION_DECIMALS}\n allowPivot={false}\n onModeChange={next => core.setMode(next)}\n onPlacementChange={placement => core.setPlacement(placement)}\n onCentre={() => {}}\n onPickPivot={() => {}}\n onClearPivot={() => {}}\n hasPivot={false}\n onDone={() => { void core.accept().then(onDone) }}\n onReset={() => { void core.cancel().then(onDone) }}\n />\n )\n}\n"],"mappings":";AAyII;AApIJ,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB,SAAS,YAAY,oBAAoB;AACzC,SAAS,sBAAsB;AAC/B,SAAS,gCAAgC;AAEzC,SAAS,qBAAqB,0BAA0B;AACxD,SAAS,8BAA8B;AACvC,SAAS,uBAAuB,oBAAoB,mBAAmB,8BAA8B;AAC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;AAAA,MAAE;AAAA;AAAA,EACnD;AAEJ;","names":["rotation"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapPlacementGeo.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/src/Placement/mapPlacementGeo.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AAKzF,oGAAoG;AACpG,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,6FAA6F;AAC7F,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,
|
|
1
|
+
{"version":3,"file":"mapPlacementGeo.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/src/Placement/mapPlacementGeo.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AAKzF,oGAAoG;AACpG,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,6FAA6F;AAC7F,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB;AAeD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAMpG;AAED,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,GAAG,kBAAkB,CAWvG;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,GAAG,mBAAmB,CAcpG;AAED,6FAA6F;AAC7F,eAAO,MAAM,0BAA0B,GAAI,SAAS,MAAM,EAAE,WAAW,QAAQ;;;;;CAK7E,CAAA"}
|
|
@@ -19,7 +19,7 @@ function placementToRecord(anchor, placement) {
|
|
|
19
19
|
lat: moved.lat,
|
|
20
20
|
elevation: moved.elevation,
|
|
21
21
|
rotation: placement.rotation[1] * RAD_TO_DEG,
|
|
22
|
-
|
|
22
|
+
fileScale: placement.scale
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
function recordToPlacement(anchor, record) {
|
|
@@ -32,7 +32,7 @@ function recordToPlacement(anchor, record) {
|
|
|
32
32
|
(target.y - frame.y) / frame.unit
|
|
33
33
|
],
|
|
34
34
|
rotation: [0, record.rotation * DEG_TO_RAD, 0],
|
|
35
|
-
scale: record.
|
|
35
|
+
scale: record.fileScale,
|
|
36
36
|
sourceUp: "y"
|
|
37
37
|
};
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/Placement/mapPlacementGeo.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { MercatorCoordinate } from 'maplibre-gl'\n\nimport type { Building, DbFile } from '../../../../../types/dbTypes'\nimport type { PointCloudPlacement } from '../../../shared/pointcloud/pointCloudPlacement'\n\nconst RAD_TO_DEG = 180 / Math.PI\nconst DEG_TO_RAD = Math.PI / 180\n\n/** Where a map file sits: its own lng/lat/elevation, which the custom layer's model matrix uses. */\nexport interface MapAnchor {\n lng: number\n lat: number\n elevation: number\n}\n\n/** The columns a placed map file stores. `rotation` is DEGREES, matching DbFile.rotation. */\nexport interface MapPlacementRecord {\n lng: number\n lat: number\n elevation: number\n rotation: number\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/Placement/mapPlacementGeo.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { MercatorCoordinate } from 'maplibre-gl'\n\nimport type { Building, DbFile } from '../../../../../types/dbTypes'\nimport type { PointCloudPlacement } from '../../../shared/pointcloud/pointCloudPlacement'\n\nconst RAD_TO_DEG = 180 / Math.PI\nconst DEG_TO_RAD = Math.PI / 180\n\n/** Where a map file sits: its own lng/lat/elevation, which the custom layer's model matrix uses. */\nexport interface MapAnchor {\n lng: number\n lat: number\n elevation: number\n}\n\n/** The columns a placed map file stores. `rotation` is DEGREES, matching DbFile.rotation. */\nexport interface MapPlacementRecord {\n lng: number\n lat: number\n elevation: number\n rotation: number\n fileScale: number\n}\n\ninterface MercatorFrame {\n x: number\n y: number\n z: number\n unit: number\n}\n\nfunction frameOf(anchor: MapAnchor): MercatorFrame {\n const origin = MercatorCoordinate.fromLngLat([anchor.lng, anchor.lat], anchor.elevation)\n\n return { x: origin.x, y: origin.y, z: origin.z, unit: origin.meterInMercatorCoordinateUnits() }\n}\n\n/**\n * Moves an anchor by scene-space metres (+east, +up, +south). Metres-per-mercator-unit is\n * latitude-dependent, so this is exact at the anchor and sub-millimetre off by 200 m.\n */\nexport function metresToAnchor(anchor: MapAnchor, east: number, up: number, south: number): MapAnchor {\n const frame = frameOf(anchor)\n const moved = new MercatorCoordinate(frame.x + east * frame.unit, frame.y + south * frame.unit, frame.z)\n const { lng, lat } = moved.toLngLat()\n\n return { lng, lat, elevation: anchor.elevation + up }\n}\n\n/** Scene-space placement to the geographic columns, relative to the file's current anchor. */\nexport function placementToRecord(anchor: MapAnchor, placement: PointCloudPlacement): MapPlacementRecord {\n const [east, up, south] = placement.position\n const moved = metresToAnchor(anchor, east, up, south)\n\n return {\n lng: moved.lng,\n lat: moved.lat,\n elevation: moved.elevation,\n rotation: placement.rotation[1] * RAD_TO_DEG,\n fileScale: placement.scale,\n }\n}\n\n/** Stored columns back to a scene-space placement; the map stores yaw only. */\nexport function recordToPlacement(anchor: MapAnchor, record: MapPlacementRecord): PointCloudPlacement {\n const frame = frameOf(anchor)\n const target = MercatorCoordinate.fromLngLat([record.lng, record.lat], record.elevation)\n\n return {\n position: [\n (target.x - frame.x) / frame.unit,\n record.elevation - anchor.elevation,\n (target.y - frame.y) / frame.unit,\n ],\n rotation: [0, record.rotation * DEG_TO_RAD, 0],\n scale: record.fileScale,\n sourceUp: 'y',\n }\n}\n\n/** Position, rotation and elevation of a BIM file, falling back to its building's values. */\nexport const extractPositionAndRotation = (bimFile: DbFile, building?: Building) => ({\n lng: bimFile.lng ?? building?.buildingLongitude ?? null,\n lat: bimFile.lat ?? building?.buildingLatitude ?? null,\n rotation: bimFile.rotation ?? building?.rotation ?? 0,\n elevation: bimFile.elevation ?? building?.buildingElevation ?? 0,\n})\n"],"mappings":"AAGA,SAAS,0BAA0B;AAKnC,MAAM,aAAa,MAAM,KAAK;AAC9B,MAAM,aAAa,KAAK,KAAK;AAyB7B,SAAS,QAAQ,QAAkC;AACjD,QAAM,SAAS,mBAAmB,WAAW,CAAC,OAAO,KAAK,OAAO,GAAG,GAAG,OAAO,SAAS;AAEvF,SAAO,EAAE,GAAG,OAAO,GAAG,GAAG,OAAO,GAAG,GAAG,OAAO,GAAG,MAAM,OAAO,+BAA+B,EAAE;AAChG;AAMO,SAAS,eAAe,QAAmB,MAAc,IAAY,OAA0B;AACpG,QAAM,QAAQ,QAAQ,MAAM;AAC5B,QAAM,QAAQ,IAAI,mBAAmB,MAAM,IAAI,OAAO,MAAM,MA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lacementTarget({
|
|
|
85
85
|
elevation: next.elevation,
|
|
86
86
|
rotation: placement.rotation[1] * (180 / Math.PI)
|
|
87
87
|
};
|
|
88
|
-
if (capabilities.scale) patch.
|
|
88
|
+
if (capabilities.scale) patch.fileScale = placement.scale;
|
|
89
89
|
await updateFile(patch);
|
|
90
90
|
}
|
|
91
91
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/Placement/mapPlacementTarget.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n\nimport { markerActionsFor } from '../../../shared/placement/markerActions'\nimport { capabilitiesForFile } from '../../../shared/placement/placementCapabilities'\nimport { DEFAULT_PLACEMENT } from '../../../shared/pointcloud/pointCloudPlacement'\n\nimport { metresToAnchor } from './mapPlacementGeo'\n\nimport type { MapAnchor } from './mapPlacementGeo'\nimport type { MapCapabilities } from './useMapPlacementSession'\nimport type { DbFile } from '../../../../../types/dbTypes'\nimport type { FileMarkerAction } from '../../../../ui/FilesManager/src/PlacementActionsCard'\nimport type { MarkerActionContext } from '../../../shared/placement/markerActions'\nimport type { PlacementCapabilities, PlacementTarget } from '../../../shared/placement/placementTarget'\nimport type { PointCloudPlacement } from '../../../shared/pointcloud/pointCloudPlacement'\nimport type * as THREE from 'three'\n\n/** A map file with no geometry moves and nothing else; rotating a flat overlay is not stored yet. */\nexport function mapCapabilitiesForFile(file: Parameters<typeof capabilitiesForFile>[0], is3D: boolean) {\n const capabilities = capabilitiesForFile(file)\n return is3D ? capabilities : { ...capabilities, rotation: 'yaw' as const, scale: false, moveOnly: true }\n}\n\n/** The map's menu, narrowed: a file with no geometry has only a drag handle, so it only moves. */\nexport function mapMarkerActionsFor(\n capabilities: MapCapabilities,\n context?: MarkerActionContext,\n): FileMarkerAction[] {\n const actions = markerActionsFor(capabilities, context)\n return capabilities.moveOnly ? actions.filter(action => action === 'move') : actions\n}\n\nexport interface MapPlacementTargetSetup {\n id: string\n name: string\n /** The subject the gizmo attaches to. It stays at the scene origin; the anchor is what moves. */\n object: () => THREE.Object3D | null\n anchor: () => MapAnchor\n /** Publishes a live anchor into the layer so the next frame draws it, before anything is saved. */\n preview: (anchor: MapAnchor, rotation: number, scale: number) => void\n updateFile: (patch: Partial<DbFile>) => Promise<unknown>\n capabilities: PlacementCapabilities\n /** Where the file already stands, so re-opening the card does not report a fresh zero. */\n rotation?: number\n scale?: number\n}\n\n/** The map's placement is geography: `position` is [lng, elevation, lat], so the card reads degrees. */\nexport const anchorToPosition = (anchor: MapAnchor): [number, number, number] =>\n [anchor.lng, anchor.elevation, anchor.lat]\n\nexport const positionToAnchor = (position: [number, number, number]): MapAnchor =>\n ({ lng: position[0], elevation: position[1], lat: position[2] })\n\n/**\n * Placement for a file drawn in a maplibre custom layer. Dragging moves the layer's own anchor\n * rather than the object inside it, because the anchor is what the file's columns store.\n */\nexport function mapPlacementTarget({\n id,\n name,\n object,\n anchor,\n preview,\n updateFile,\n capabilities,\n rotation: storedRotation = 0,\n scale: storedScale = 1,\n}: MapPlacementTargetSetup): PlacementTarget {\n let rotation = storedRotation\n let scale = storedScale\n // What the subject's own turn and scale are measured from: the gizmo never zeroes them mid-drag.\n let baseRotation = storedRotation\n let baseScale = storedScale\n\n const read = (): PointCloudPlacement => ({\n ...DEFAULT_PLACEMENT,\n position: anchorToPosition(anchor()),\n rotation: [0, rotation, 0],\n scale: capabilities.scale ? scale : DEFAULT_PLACEMENT.scale,\n })\n\n return {\n id,\n name,\n capabilities,\n object,\n read,\n apply: (placement) => {\n rotation = placement.rotation[1]\n if (capabilities.scale) scale = placement.scale\n preview(positionToAnchor(placement.position), rotation, scale)\n // The gizmo measures its next drag from here, so the subject never carries an offset.\n const root = object()\n if (root) {\n root.position.set(0, 0, 0)\n baseRotation = rotation - root.rotation.y\n baseScale = scale / (root.scale.x || 1)\n root.updateMatrixWorld(true)\n }\n },\n applyDrag: (object) => {\n rotation = baseRotation + object.rotation.y\n if (capabilities.scale) scale = baseScale * object.scale.x\n preview(anchorAfterDrag(anchor(), object.position), rotation, scale)\n // Only the position resets: the anchor moved under the subject, so the drag is spent.\n object.position.set(0, 0, 0)\n object.updateMatrixWorld(true)\n },\n bounds: () => null,\n commit: async (placement) => {\n const next = positionToAnchor(placement.position)\n const patch: Partial<DbFile> = {\n lng: next.lng,\n lat: next.lat,\n elevation: next.elevation,\n rotation: placement.rotation[1] * (180 / Math.PI),\n }\n if (capabilities.scale) patch.
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/Placement/mapPlacementTarget.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\n\nimport { markerActionsFor } from '../../../shared/placement/markerActions'\nimport { capabilitiesForFile } from '../../../shared/placement/placementCapabilities'\nimport { DEFAULT_PLACEMENT } from '../../../shared/pointcloud/pointCloudPlacement'\n\nimport { metresToAnchor } from './mapPlacementGeo'\n\nimport type { MapAnchor } from './mapPlacementGeo'\nimport type { MapCapabilities } from './useMapPlacementSession'\nimport type { DbFile } from '../../../../../types/dbTypes'\nimport type { FileMarkerAction } from '../../../../ui/FilesManager/src/PlacementActionsCard'\nimport type { MarkerActionContext } from '../../../shared/placement/markerActions'\nimport type { PlacementCapabilities, PlacementTarget } from '../../../shared/placement/placementTarget'\nimport type { PointCloudPlacement } from '../../../shared/pointcloud/pointCloudPlacement'\nimport type * as THREE from 'three'\n\n/** A map file with no geometry moves and nothing else; rotating a flat overlay is not stored yet. */\nexport function mapCapabilitiesForFile(file: Parameters<typeof capabilitiesForFile>[0], is3D: boolean) {\n const capabilities = capabilitiesForFile(file)\n return is3D ? capabilities : { ...capabilities, rotation: 'yaw' as const, scale: false, moveOnly: true }\n}\n\n/** The map's menu, narrowed: a file with no geometry has only a drag handle, so it only moves. */\nexport function mapMarkerActionsFor(\n capabilities: MapCapabilities,\n context?: MarkerActionContext,\n): FileMarkerAction[] {\n const actions = markerActionsFor(capabilities, context)\n return capabilities.moveOnly ? actions.filter(action => action === 'move') : actions\n}\n\nexport interface MapPlacementTargetSetup {\n id: string\n name: string\n /** The subject the gizmo attaches to. It stays at the scene origin; the anchor is what moves. */\n object: () => THREE.Object3D | null\n anchor: () => MapAnchor\n /** Publishes a live anchor into the layer so the next frame draws it, before anything is saved. */\n preview: (anchor: MapAnchor, rotation: number, scale: number) => void\n updateFile: (patch: Partial<DbFile>) => Promise<unknown>\n capabilities: PlacementCapabilities\n /** Where the file already stands, so re-opening the card does not report a fresh zero. */\n rotation?: number\n scale?: number\n}\n\n/** The map's placement is geography: `position` is [lng, elevation, lat], so the card reads degrees. */\nexport const anchorToPosition = (anchor: MapAnchor): [number, number, number] =>\n [anchor.lng, anchor.elevation, anchor.lat]\n\nexport const positionToAnchor = (position: [number, number, number]): MapAnchor =>\n ({ lng: position[0], elevation: position[1], lat: position[2] })\n\n/**\n * Placement for a file drawn in a maplibre custom layer. Dragging moves the layer's own anchor\n * rather than the object inside it, because the anchor is what the file's columns store.\n */\nexport function mapPlacementTarget({\n id,\n name,\n object,\n anchor,\n preview,\n updateFile,\n capabilities,\n rotation: storedRotation = 0,\n scale: storedScale = 1,\n}: MapPlacementTargetSetup): PlacementTarget {\n let rotation = storedRotation\n let scale = storedScale\n // What the subject's own turn and scale are measured from: the gizmo never zeroes them mid-drag.\n let baseRotation = storedRotation\n let baseScale = storedScale\n\n const read = (): PointCloudPlacement => ({\n ...DEFAULT_PLACEMENT,\n position: anchorToPosition(anchor()),\n rotation: [0, rotation, 0],\n scale: capabilities.scale ? scale : DEFAULT_PLACEMENT.scale,\n })\n\n return {\n id,\n name,\n capabilities,\n object,\n read,\n apply: (placement) => {\n rotation = placement.rotation[1]\n if (capabilities.scale) scale = placement.scale\n preview(positionToAnchor(placement.position), rotation, scale)\n // The gizmo measures its next drag from here, so the subject never carries an offset.\n const root = object()\n if (root) {\n root.position.set(0, 0, 0)\n baseRotation = rotation - root.rotation.y\n baseScale = scale / (root.scale.x || 1)\n root.updateMatrixWorld(true)\n }\n },\n applyDrag: (object) => {\n rotation = baseRotation + object.rotation.y\n if (capabilities.scale) scale = baseScale * object.scale.x\n preview(anchorAfterDrag(anchor(), object.position), rotation, scale)\n // Only the position resets: the anchor moved under the subject, so the drag is spent.\n object.position.set(0, 0, 0)\n object.updateMatrixWorld(true)\n },\n bounds: () => null,\n commit: async (placement) => {\n const next = positionToAnchor(placement.position)\n const patch: Partial<DbFile> = {\n lng: next.lng,\n lat: next.lat,\n elevation: next.elevation,\n rotation: placement.rotation[1] * (180 / Math.PI),\n }\n if (capabilities.scale) patch.fileScale = placement.scale\n await updateFile(patch)\n },\n }\n}\n\n/** Turns a gizmo drag, which is metres in the layer's scene, into the anchor it should land on. */\nexport function anchorAfterDrag(anchor: MapAnchor, dragged: THREE.Vector3): MapAnchor {\n return metresToAnchor(anchor, dragged.x, dragged.y, dragged.z)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAIA,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;AAElC,SAAS,sBAAsB;AAYxB,SAAS,uBAAuB,MAAiD,MAAe;AACrG,QAAM,eAAe,oBAAoB,IAAI;AAC7C,SAAO,OAAO,eAAe,iCAAK,eAAL,EAAmB,UAAU,OAAgB,OAAO,OAAO,UAAU,KAAK;AACzG;AAGO,SAAS,oBACd,cACA,SACoB;AACpB,QAAM,UAAU,iBAAiB,cAAc,OAAO;AACtD,SAAO,aAAa,WAAW,QAAQ,OAAO,YAAU,WAAW,MAAM,IAAI;AAC/E;AAkBO,MAAM,mBAAmB,CAAC,WAC/B,CAAC,OAAO,KAAK,OAAO,WAAW,OAAO,GAAG;AAEpC,MAAM,mBAAmB,CAAC,cAC9B,EAAE,KAAK,SAAS,CAAC,GAAG,WAAW,SAAS,CAAC,GAAG,KAAK,SAAS,CAAC,EAAE;AAMzD,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;A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ACV,WAAW,KAAK;AAAA,QAChB,UAAU,UAAU,SAAS,CAAC,KAAK,MAAM,KAAK;AAAA,MAChD;AACA,UAAI,aAAa,MAAO,OAAM,YAAY,UAAU;AACpD,YAAM,WAAW,KAAK;AAAA,IACxB;AAAA,EACF;AACF;AAGO,SAAS,gBAAgB,QAAmB,SAAmC;AACpF,SAAO,eAAe,QAAQ,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC/D;","names":["object"]}
|
|
@@ -25,7 +25,7 @@ function useMapPlacementTarget() {
|
|
|
25
25
|
preview,
|
|
26
26
|
capabilities: capabilitiesForFile(file),
|
|
27
27
|
rotation: ((_a = rotation != null ? rotation : file.rotation) != null ? _a : 0) * DEG_TO_RAD,
|
|
28
|
-
scale: (_b = file.
|
|
28
|
+
scale: (_b = file.fileScale) != null ? _b : 1,
|
|
29
29
|
updateFile: async (patch) => {
|
|
30
30
|
Object.assign(file, patch);
|
|
31
31
|
await updateFileRef.current(patch);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/Placement/useMapPlacementTarget.ts"],"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 { useFile } from '../../../../../hooks/files/files'\nimport { capabilitiesForFile } from '../../../shared/placement/placementCapabilities'\n\nimport { mapPlacementTarget } from './mapPlacementTarget'\n\nimport type { MapAnchor } from './mapPlacementGeo'\nimport type { DbFile } from '../../../../../types/dbTypes'\nimport type { PlacementTarget } from '../../../shared/placement/placementTarget'\nimport type * as THREE from 'three'\n\nconst DEG_TO_RAD = Math.PI / 180\n\nexport interface MapTargetSetup {\n file: DbFile\n object: () => THREE.Object3D | null\n anchor: () => MapAnchor\n preview: (anchor: MapAnchor, rotation: number, scale: number) => void\n /** Degrees the file already stands at, when the caller knows better than its own column. */\n rotation?: number\n}\n\n/** Binds a map file's row to a placement target, so a finished edit writes its geographic columns. */\nexport function useMapPlacementTarget() {\n const [movingId, setMovingId] = React.useState<number | null>(null)\n const { updateFile } = useFile(movingId)\n const updateFileRef = React.useRef(updateFile)\n React.useEffect(() => { updateFileRef.current = updateFile }, [updateFile])\n\n const targetFor = React.useCallback(\n ({ file, object, anchor, preview, rotation }: MapTargetSetup): PlacementTarget => {\n setMovingId(file.id)\n\n return mapPlacementTarget({\n id: String(file.id),\n name: file.name,\n object,\n anchor,\n preview,\n capabilities: capabilitiesForFile(file),\n rotation: (rotation ?? file.rotation ?? 0) * DEG_TO_RAD,\n scale: file.
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/Placement/useMapPlacementTarget.ts"],"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 { useFile } from '../../../../../hooks/files/files'\nimport { capabilitiesForFile } from '../../../shared/placement/placementCapabilities'\n\nimport { mapPlacementTarget } from './mapPlacementTarget'\n\nimport type { MapAnchor } from './mapPlacementGeo'\nimport type { DbFile } from '../../../../../types/dbTypes'\nimport type { PlacementTarget } from '../../../shared/placement/placementTarget'\nimport type * as THREE from 'three'\n\nconst DEG_TO_RAD = Math.PI / 180\n\nexport interface MapTargetSetup {\n file: DbFile\n object: () => THREE.Object3D | null\n anchor: () => MapAnchor\n preview: (anchor: MapAnchor, rotation: number, scale: number) => void\n /** Degrees the file already stands at, when the caller knows better than its own column. */\n rotation?: number\n}\n\n/** Binds a map file's row to a placement target, so a finished edit writes its geographic columns. */\nexport function useMapPlacementTarget() {\n const [movingId, setMovingId] = React.useState<number | null>(null)\n const { updateFile } = useFile(movingId)\n const updateFileRef = React.useRef(updateFile)\n React.useEffect(() => { updateFileRef.current = updateFile }, [updateFile])\n\n const targetFor = React.useCallback(\n ({ file, object, anchor, preview, rotation }: MapTargetSetup): PlacementTarget => {\n setMovingId(file.id)\n\n return mapPlacementTarget({\n id: String(file.id),\n name: file.name,\n object,\n anchor,\n preview,\n capabilities: capabilitiesForFile(file),\n rotation: (rotation ?? file.rotation ?? 0) * DEG_TO_RAD,\n scale: file.fileScale ?? 1,\n updateFile: async (patch) => {\n // Keeps the row in step, so it does not flicker back before the refetch lands.\n Object.assign(file, patch)\n await updateFileRef.current(patch as never)\n },\n })\n },\n [],\n )\n\n return { targetFor }\n}\n"],"mappings":";AAKA,YAAY,WAAW;AAEvB,SAAS,eAAe;AACxB,SAAS,2BAA2B;AAEpC,SAAS,0BAA0B;AAOnC,MAAM,aAAa,KAAK,KAAK;AAYtB,SAAS,wBAAwB;AACtC,QAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAwB,IAAI;AAClE,QAAM,EAAE,WAAW,IAAI,QAAQ,QAAQ;AACvC,QAAM,gBAAgB,MAAM,OAAO,UAAU;AAC7C,QAAM,UAAU,MAAM;AAAE,kBAAc,UAAU;AAAA,EAAW,GAAG,CAAC,UAAU,CAAC;AAE1E,QAAM,YAAY,MAAM;AAAA,IACtB,CAAC,EAAE,MAAM,QAAQ,QAAQ,SAAS,SAAS,MAAuC;AApCtF;AAqCM,kBAAY,KAAK,EAAE;AAEnB,aAAO,mBAAmB;AAAA,QACxB,IAAI,OAAO,KAAK,EAAE;AAAA,QAClB,MAAM,KAAK;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAc,oBAAoB,IAAI;AAAA,QACtC,YAAW,mCAAY,KAAK,aAAjB,YAA6B,KAAK;AAAA,QAC7C,QAAO,UAAK,cAAL,YAAkB;AAAA,QACzB,YAAY,OAAO,UAAU;AAE3B,iBAAO,OAAO,MAAM,KAAK;AACzB,gBAAM,cAAc,QAAQ,KAAc;AAAA,QAC5C;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,UAAU;AACrB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shareMapTool.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/src/tools/shareMapTool.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"shareMapTool.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/src/tools/shareMapTool.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AAGtD,UAAU,cAAc;IACtB,IAAI,EAAE,IAAI,CAAA;CACX;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAiCjD,CAAA"}
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
4
20
|
import { jsx } from "react/jsx-runtime";
|
|
5
21
|
import * as React from "react";
|
|
6
22
|
import { MapContext } from "../../../../../store";
|
|
7
23
|
import { ShareToolSubmenu } from "../../../../ui/ShareFeature";
|
|
8
24
|
import { getMunicipalityAndProvince } from "../../utils/geocoder";
|
|
25
|
+
import { cameraSnapshot, labelsFromParams, toQueryString, withLocationParams } from "../../utils/urlLocation/locationParams";
|
|
9
26
|
const ShareMapTool = ({ tool }) => {
|
|
10
27
|
const { state: mapState } = React.useContext(MapContext);
|
|
11
28
|
const { map, organizationCountry } = mapState.map;
|
|
@@ -15,20 +32,13 @@ const ShareMapTool = ({ tool }) => {
|
|
|
15
32
|
if (map == null) {
|
|
16
33
|
return origin + pathname;
|
|
17
34
|
} else {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
zoom: map.getZoom().toFixed(3),
|
|
26
|
-
bearing: map.getBearing().toFixed(1),
|
|
27
|
-
pitch: map.getPitch().toFixed(1),
|
|
28
|
-
municipality: shareLocation.municipality,
|
|
29
|
-
countrySubdivision: shareLocation.countrySubdivision
|
|
30
|
-
});
|
|
31
|
-
const shareUrl = `${origin}${pathname}?${params.toString()}`;
|
|
35
|
+
const camera = cameraSnapshot(map);
|
|
36
|
+
const shareLocation = await getMunicipalityAndProvince(camera.lat.toFixed(7), camera.lng.toFixed(7), organizationCountry);
|
|
37
|
+
const current = new URLSearchParams(window.location.search);
|
|
38
|
+
const { country } = labelsFromParams(current);
|
|
39
|
+
const params = withLocationParams(current, camera, __spreadValues({ country }, shareLocation));
|
|
40
|
+
params.set("viewer", "map");
|
|
41
|
+
const shareUrl = `${origin}${pathname}?${toQueryString(params)}`;
|
|
32
42
|
return shareUrl;
|
|
33
43
|
}
|
|
34
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/tools/shareMapTool.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\n\n// Utilities\nimport { MapContext } from '../../../../../store'\n\n\n// Custom components\nimport { ShareToolSubmenu } from '../../../../ui/ShareFeature'\nimport { getMunicipalityAndProvince } from '../../utils/geocoder'\n\nimport type { Tool } from '../../../../../types/tools'\nimport type { Map } from 'maplibre-gl'\n\ninterface ShareToolProps {\n tool: Tool\n}\n\nexport const ShareMapTool: React.FC<ShareToolProps> = ({ tool }) => {\n const { state: mapState } = React.useContext(MapContext)\n const { map, organizationCountry } = mapState.map as { map: Map | null, organizationCountry?: string }\n\n const constructShareUrl = async (): Promise<string> => {\n const origin = window.location.origin\n const pathname = window.location.pathname\n\n if (map == null) {\n return origin + pathname\n }\n else {\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/src/tools/shareMapTool.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\n\n// Utilities\nimport { MapContext } from '../../../../../store'\n\n\n// Custom components\nimport { ShareToolSubmenu } from '../../../../ui/ShareFeature'\nimport { getMunicipalityAndProvince } from '../../utils/geocoder'\nimport { cameraSnapshot, labelsFromParams, toQueryString, withLocationParams } from '../../utils/urlLocation/locationParams'\n\nimport type { Tool } from '../../../../../types/tools'\nimport type { Map } from 'maplibre-gl'\n\ninterface ShareToolProps {\n tool: Tool\n}\n\nexport const ShareMapTool: React.FC<ShareToolProps> = ({ tool }) => {\n const { state: mapState } = React.useContext(MapContext)\n const { map, organizationCountry } = mapState.map as { map: Map | null, organizationCountry?: string }\n\n const constructShareUrl = async (): Promise<string> => {\n const origin = window.location.origin\n const pathname = window.location.pathname\n\n if (map == null) {\n return origin + pathname\n }\n else {\n const camera = cameraSnapshot(map)\n const shareLocation = await getMunicipalityAndProvince(camera.lat.toFixed(7), camera.lng.toFixed(7), organizationCountry)\n\n const current = new URLSearchParams(window.location.search)\n const { country } = labelsFromParams(current)\n const params = withLocationParams(current, camera, { country, ...shareLocation })\n params.set('viewer', 'map')\n\n const shareUrl = `${origin}${pathname}?${toQueryString(params)}`\n return shareUrl\n }\n }\n\n return (\n <ShareToolSubmenu\n tool={tool}\n constructShareUrl={constructShareUrl}\n translationKey=\"ShareTool\"\n dialogTitleKey=\"map\"\n />\n )\n}"],"mappings":";;;;;;;;;;;;;;;;;AAkDI;AA7CJ,YAAY,WAAW;AAIvB,SAAS,kBAAkB;AAI3B,SAAS,wBAAwB;AACjC,SAAS,kCAAkC;AAC3C,SAAS,gBAAgB,kBAAkB,eAAe,0BAA0B;AAS7E,MAAM,eAAyC,CAAC,EAAE,KAAK,MAAM;AAClE,QAAM,EAAE,OAAO,SAAS,IAAI,MAAM,WAAW,UAAU;AACvD,QAAM,EAAE,KAAK,oBAAoB,IAAI,SAAS;AAE9C,QAAM,oBAAoB,YAA6B;AACrD,UAAM,SAAS,OAAO,SAAS;AAC/B,UAAM,WAAW,OAAO,SAAS;AAEjC,QAAI,OAAO,MAAM;AACf,aAAO,SAAS;AAAA,IAClB,OACK;AACH,YAAM,SAAS,eAAe,GAAG;AACjC,YAAM,gBAAgB,MAAM,2BAA2B,OAAO,IAAI,QAAQ,CAAC,GAAG,OAAO,IAAI,QAAQ,CAAC,GAAG,mBAAmB;AAExH,YAAM,UAAU,IAAI,gBAAgB,OAAO,SAAS,MAAM;AAC1D,YAAM,EAAE,QAAQ,IAAI,iBAAiB,OAAO;AAC5C,YAAM,SAAS,mBAAmB,SAAS,QAAQ,iBAAE,WAAY,cAAe;AAChF,aAAO,IAAI,UAAU,KAAK;AAE1B,YAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,IAAI,cAAc,MAAM,CAAC;AAC9D,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,gBAAe;AAAA,MACf,gBAAe;AAAA;AAAA,EACjB;AAEJ;","names":[]}
|
|
@@ -13,6 +13,7 @@ export declare const parseLocation: (feature: Feature) => {
|
|
|
13
13
|
};
|
|
14
14
|
export declare const handleLocationSelect: (feature: Feature, map: any, type: string, options?: {
|
|
15
15
|
editing?: boolean;
|
|
16
|
+
onMoveEnd?: () => void;
|
|
16
17
|
}) => {
|
|
17
18
|
formatted_address: any;
|
|
18
19
|
coordinates: import("geojson").Position;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geocoder.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/map/utils/geocoder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAS,MAAM,SAAS,CAAA;AAc7C,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,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"geocoder.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/map/utils/geocoder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAS,MAAM,SAAS,CAAA;AAc7C,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"}
|
|
@@ -65,6 +65,9 @@ const parseLocation = (feature) => {
|
|
|
65
65
|
const handleLocationSelect = (feature, map, type, options) => {
|
|
66
66
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
67
67
|
const editing = (options == null ? void 0 : options.editing) || false;
|
|
68
|
+
const listenForMoveEnd = () => {
|
|
69
|
+
if (options == null ? void 0 : options.onMoveEnd) map.once("moveend", options.onMoveEnd);
|
|
70
|
+
};
|
|
68
71
|
const markerManager = getGeocoderMarkerManager();
|
|
69
72
|
if (type === "dbBuilding") {
|
|
70
73
|
const geometry = feature.geometry;
|
|
@@ -77,6 +80,7 @@ const handleLocationSelect = (feature, map, type, options) => {
|
|
|
77
80
|
is_database_building: true
|
|
78
81
|
};
|
|
79
82
|
if (map && center2) {
|
|
83
|
+
listenForMoveEnd();
|
|
80
84
|
map.flyTo({
|
|
81
85
|
center: addressData2.coordinates,
|
|
82
86
|
zoom: 18,
|
|
@@ -121,6 +125,7 @@ const handleLocationSelect = (feature, map, type, options) => {
|
|
|
121
125
|
// How well the result matches the query
|
|
122
126
|
};
|
|
123
127
|
if (map && center) {
|
|
128
|
+
listenForMoveEnd();
|
|
124
129
|
if (feature.bbox) {
|
|
125
130
|
map.fitBounds(feature.bbox, { speed: 2 });
|
|
126
131
|
} else {
|
|
@@ -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 }) => {\n const editing = options?.editing || false\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 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 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;AACZ,YAAQ,MAAM,uCAAuC,KAAK;AAC1D,WAAO,CAAC;AAAA,EACV;AACF;AAGO,MAAM,gBAAgB,CAAC,YAAqB;AAzDnD;AA0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ACR,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 { 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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AA,IACvB,CAAC;AACD,WAAO;AAAA,EACT;AAEA,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"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Feature } from 'geojson';
|
|
2
2
|
export declare const osmCategoryToLayer: (category?: string) => string;
|
|
3
|
+
/** Full subdivision name for a Pelias-style code (`QC` → `quebec`), or '' when unknown. */
|
|
4
|
+
export declare const subdivisionName: (countryCode: string, code: string) => string;
|
|
3
5
|
export declare const normalizePhotonFeature: (feature: any) => Feature;
|
|
4
6
|
export declare const normalizeNominatimResult: (data: any) => Feature;
|
|
5
7
|
//# sourceMappingURL=adapters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/adapters.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAGtC,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,KAAG,MAoBtD,CAAA;
|
|
1
|
+
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/adapters.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAGtC,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,KAAG,MAoBtD,CAAA;AAiCD,2FAA2F;AAC3F,eAAO,MAAM,eAAe,GAAI,aAAa,MAAM,EAAE,MAAM,MAAM,KAAG,MAInE,CAAA;AAGD,eAAO,MAAM,sBAAsB,GAAI,SAAS,GAAG,KAAG,OAuCrD,CAAA;AAGD,eAAO,MAAM,wBAAwB,GAAI,MAAM,GAAG,KAAG,OAkCpD,CAAA"}
|
|
@@ -122,6 +122,12 @@ const subdivisionAbbreviation = (countryCode, state) => {
|
|
|
122
122
|
const table = SUBDIVISION_ABBREVIATIONS[(countryCode || "").toUpperCase()];
|
|
123
123
|
return table && table[state.trim().toLowerCase()] || "";
|
|
124
124
|
};
|
|
125
|
+
const subdivisionName = (countryCode, code) => {
|
|
126
|
+
var _a, _b;
|
|
127
|
+
const table = (_a = SUBDIVISION_ABBREVIATIONS[(countryCode || "").toUpperCase()]) != null ? _a : {};
|
|
128
|
+
const upper = code.trim().toUpperCase();
|
|
129
|
+
return (_b = Object.keys(table).find((name) => table[name] === upper)) != null ? _b : "";
|
|
130
|
+
};
|
|
125
131
|
const normalizePhotonFeature = (feature) => {
|
|
126
132
|
const p = feature.properties || {};
|
|
127
133
|
const region = p.state || "";
|
|
@@ -187,6 +193,7 @@ const normalizeNominatimResult = (data) => {
|
|
|
187
193
|
export {
|
|
188
194
|
normalizeNominatimResult,
|
|
189
195
|
normalizePhotonFeature,
|
|
190
|
-
osmCategoryToLayer
|
|
196
|
+
osmCategoryToLayer,
|
|
197
|
+
subdivisionName
|
|
191
198
|
};
|
|
192
199
|
//# sourceMappingURL=adapters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/adapters.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport type { Feature } from 'geojson'\n\n// Map OSM place categories onto Pelias-style layer names (best effort, display-only).\nexport const osmCategoryToLayer = (category?: string): string => {\n switch (category) {\n case 'house':\n case 'building': return 'address'\n case 'street':\n case 'road': return 'street'\n case 'city':\n case 'town':\n case 'village':\n case 'hamlet':\n case 'locality': return 'locality'\n case 'district':\n case 'suburb':\n case 'neighbourhood': return 'neighbourhood'\n case 'county': return 'county'\n case 'state':\n case 'region': return 'region'\n case 'country': return 'country'\n default: return category || 'venue'\n }\n}\n\n// Photon (OSM) returns full subdivision names (\"Ontario\"); the rest of the app expects\n// Pelias-style abbreviations (\"ON\"). Map common North American ones so the public\n// fallback populates region_a the way Geocode Earth / Pelias do.\nconst SUBDIVISION_ABBREVIATIONS: Record<string, Record<string, string>> = {\n CA: {\n 'alberta': 'AB', 'british columbia': 'BC', 'manitoba': 'MB', 'new brunswick': 'NB',\n 'newfoundland and labrador': 'NL', 'northwest territories': 'NT', 'nova scotia': 'NS',\n 'nunavut': 'NU', 'ontario': 'ON', 'prince edward island': 'PE', 'quebec': 'QC',\n 'québec': 'QC', 'saskatchewan': 'SK', 'yukon': 'YT',\n },\n US: {\n 'alabama': 'AL', 'alaska': 'AK', 'arizona': 'AZ', 'arkansas': 'AR', 'california': 'CA',\n 'colorado': 'CO', 'connecticut': 'CT', 'delaware': 'DE', 'district of columbia': 'DC',\n 'florida': 'FL', 'georgia': 'GA', 'hawaii': 'HI', 'idaho': 'ID', 'illinois': 'IL',\n 'indiana': 'IN', 'iowa': 'IA', 'kansas': 'KS', 'kentucky': 'KY', 'louisiana': 'LA',\n 'maine': 'ME', 'maryland': 'MD', 'massachusetts': 'MA', 'michigan': 'MI', 'minnesota': 'MN',\n 'mississippi': 'MS', 'missouri': 'MO', 'montana': 'MT', 'nebraska': 'NE', 'nevada': 'NV',\n 'new hampshire': 'NH', 'new jersey': 'NJ', 'new mexico': 'NM', 'new york': 'NY',\n 'north carolina': 'NC', 'north dakota': 'ND', 'ohio': 'OH', 'oklahoma': 'OK', 'oregon': 'OR',\n 'pennsylvania': 'PA', 'rhode island': 'RI', 'south carolina': 'SC', 'south dakota': 'SD',\n 'tennessee': 'TN', 'texas': 'TX', 'utah': 'UT', 'vermont': 'VT', 'virginia': 'VA',\n 'washington': 'WA', 'west virginia': 'WV', 'wisconsin': 'WI', 'wyoming': 'WY',\n },\n}\n\nconst subdivisionAbbreviation = (countryCode: string, state?: string): string => {\n if (!state) return ''\n const table = SUBDIVISION_ABBREVIATIONS[(countryCode || '').toUpperCase()]\n return (table && table[state.trim().toLowerCase()]) || ''\n}\n\n// Normalize a Photon autocomplete feature into the Pelias feature shape.\nexport const normalizePhotonFeature = (feature: any): Feature => {\n const p = feature.properties || {}\n const region = p.state || ''\n const country = p.country || ''\n const country_a = (p.countrycode || '').toUpperCase()\n const region_a = subdivisionAbbreviation(country_a, region)\n const locality = p.city || p.town || p.village || p.district || ''\n const name = p.name || [p.housenumber, p.street].filter(Boolean).join(' ') || locality\n // Match the Pelias label shape (\"Name, City, ON, Country\") so label-parsing consumers work.\n const label = [name, locality && locality !== name ? locality : null, region_a || region, country]\n .filter(Boolean)\n .join(', ')\n\n // Photon `extent` is [west, north, east, south]; Pelias bbox is [west, south, east, north].\n const bbox: [number, number, number, number] | undefined = Array.isArray(p.extent) && p.extent.length === 4\n ? [p.extent[0], p.extent[3], p.extent[2], p.extent[1]]\n : undefined\n\n return {\n type: 'Feature',\n geometry: feature.geometry,\n ...(bbox ? { bbox } : {}),\n properties: {\n name,\n label,\n housenumber: p.housenumber,\n street: p.street,\n locality,\n neighbourhood: p.district,\n county: p.county,\n region,\n region_a, // mapped from the full subdivision name where known (SUBDIVISION_ABBREVIATIONS)\n country,\n country_a,\n postalcode: p.postcode,\n gid: p.osm_id != null ? `osm:${p.osm_type}:${p.osm_id}` : undefined,\n layer: osmCategoryToLayer(p.type),\n },\n } as Feature\n}\n\n// Normalize a Nominatim reverse result into the Pelias feature shape.\nexport const normalizeNominatimResult = (data: any): Feature => {\n const a = data.address || {}\n // ISO3166-2-lvl4 looks like \"CA-ON\"; the suffix is the Pelias region_a abbreviation.\n const region_a = (a['ISO3166-2-lvl4'] || '').split('-')[1] || ''\n const locality = a.city || a.town || a.village || a.municipality || a.suburb || a.neighbourhood || a.county || ''\n const name = a.road ? [a.house_number, a.road].filter(Boolean).join(' ') : (locality || (data.display_name || '').split(',')[0])\n\n // Nominatim boundingbox is [minlat, maxlat, minlon, maxlon]; Pelias bbox is [west, south, east, north].\n const bb = data.boundingbox\n const bbox: [number, number, number, number] | undefined = Array.isArray(bb) && bb.length === 4\n ? [Number(bb[2]), Number(bb[0]), Number(bb[3]), Number(bb[1])]\n : undefined\n\n return {\n type: 'Feature',\n geometry: { type: 'Point', coordinates: [Number(data.lon), Number(data.lat)] },\n ...(bbox ? { bbox } : {}),\n properties: {\n name,\n label: data.display_name || '',\n housenumber: a.house_number,\n street: a.road,\n locality,\n neighbourhood: a.neighbourhood || a.suburb,\n county: a.county,\n region: a.state,\n region_a,\n country: a.country,\n country_a: (a.country_code || '').toUpperCase(),\n postalcode: a.postcode,\n gid: data.osm_id != null ? `osm:${data.osm_type}:${data.osm_id}` : undefined,\n layer: osmCategoryToLayer(data.addresstype || data.type),\n },\n } as Feature\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAMO,MAAM,qBAAqB,CAAC,aAA8B;AAC/D,UAAQ,UAAU;AAAA,IAChB,KAAK;AAAA,IACL,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAA,IACL,KAAK;AAAQ,aAAO;AAAA,IACpB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAiB,aAAO;AAAA,IAC7B,KAAK;AAAU,aAAO;AAAA,IACtB,KAAK;AAAA,IACL,KAAK;AAAU,aAAO;AAAA,IACtB,KAAK;AAAW,aAAO;AAAA,IACvB;AAAS,aAAO,YAAY;AAAA,EAC9B;AACF;AAKA,MAAM,4BA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A,MACX,YAAY,EAAE,gBAAgB,IAAI,YAAY;AAAA,MAC9C,YAAY,EAAE;AAAA,MACd,KAAK,KAAK,UAAU,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,MAAM,KAAK;AAAA,MACnE,OAAO,mBAAmB,KAAK,eAAe,KAAK,IAAI;AAAA,IACzD;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/adapters.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport type { Feature } from 'geojson'\n\n// Map OSM place categories onto Pelias-style layer names (best effort, display-only).\nexport const osmCategoryToLayer = (category?: string): string => {\n switch (category) {\n case 'house':\n case 'building': return 'address'\n case 'street':\n case 'road': return 'street'\n case 'city':\n case 'town':\n case 'village':\n case 'hamlet':\n case 'locality': return 'locality'\n case 'district':\n case 'suburb':\n case 'neighbourhood': return 'neighbourhood'\n case 'county': return 'county'\n case 'state':\n case 'region': return 'region'\n case 'country': return 'country'\n default: return category || 'venue'\n }\n}\n\n// Photon (OSM) returns full subdivision names (\"Ontario\"); the rest of the app expects\n// Pelias-style abbreviations (\"ON\"). Map common North American ones so the public\n// fallback populates region_a the way Geocode Earth / Pelias do.\nconst SUBDIVISION_ABBREVIATIONS: Record<string, Record<string, string>> = {\n CA: {\n 'alberta': 'AB', 'british columbia': 'BC', 'manitoba': 'MB', 'new brunswick': 'NB',\n 'newfoundland and labrador': 'NL', 'northwest territories': 'NT', 'nova scotia': 'NS',\n 'nunavut': 'NU', 'ontario': 'ON', 'prince edward island': 'PE', 'quebec': 'QC',\n 'québec': 'QC', 'saskatchewan': 'SK', 'yukon': 'YT',\n },\n US: {\n 'alabama': 'AL', 'alaska': 'AK', 'arizona': 'AZ', 'arkansas': 'AR', 'california': 'CA',\n 'colorado': 'CO', 'connecticut': 'CT', 'delaware': 'DE', 'district of columbia': 'DC',\n 'florida': 'FL', 'georgia': 'GA', 'hawaii': 'HI', 'idaho': 'ID', 'illinois': 'IL',\n 'indiana': 'IN', 'iowa': 'IA', 'kansas': 'KS', 'kentucky': 'KY', 'louisiana': 'LA',\n 'maine': 'ME', 'maryland': 'MD', 'massachusetts': 'MA', 'michigan': 'MI', 'minnesota': 'MN',\n 'mississippi': 'MS', 'missouri': 'MO', 'montana': 'MT', 'nebraska': 'NE', 'nevada': 'NV',\n 'new hampshire': 'NH', 'new jersey': 'NJ', 'new mexico': 'NM', 'new york': 'NY',\n 'north carolina': 'NC', 'north dakota': 'ND', 'ohio': 'OH', 'oklahoma': 'OK', 'oregon': 'OR',\n 'pennsylvania': 'PA', 'rhode island': 'RI', 'south carolina': 'SC', 'south dakota': 'SD',\n 'tennessee': 'TN', 'texas': 'TX', 'utah': 'UT', 'vermont': 'VT', 'virginia': 'VA',\n 'washington': 'WA', 'west virginia': 'WV', 'wisconsin': 'WI', 'wyoming': 'WY',\n },\n}\n\nconst subdivisionAbbreviation = (countryCode: string, state?: string): string => {\n if (!state) return ''\n const table = SUBDIVISION_ABBREVIATIONS[(countryCode || '').toUpperCase()]\n return (table && table[state.trim().toLowerCase()]) || ''\n}\n\n/** Full subdivision name for a Pelias-style code (`QC` → `quebec`), or '' when unknown. */\nexport const subdivisionName = (countryCode: string, code: string): string => {\n const table = SUBDIVISION_ABBREVIATIONS[(countryCode || '').toUpperCase()] ?? {}\n const upper = code.trim().toUpperCase()\n return Object.keys(table).find(name => table[name] === upper) ?? ''\n}\n\n// Normalize a Photon autocomplete feature into the Pelias feature shape.\nexport const normalizePhotonFeature = (feature: any): Feature => {\n const p = feature.properties || {}\n const region = p.state || ''\n const country = p.country || ''\n const country_a = (p.countrycode || '').toUpperCase()\n const region_a = subdivisionAbbreviation(country_a, region)\n const locality = p.city || p.town || p.village || p.district || ''\n const name = p.name || [p.housenumber, p.street].filter(Boolean).join(' ') || locality\n // Match the Pelias label shape (\"Name, City, ON, Country\") so label-parsing consumers work.\n const label = [name, locality && locality !== name ? locality : null, region_a || region, country]\n .filter(Boolean)\n .join(', ')\n\n // Photon `extent` is [west, north, east, south]; Pelias bbox is [west, south, east, north].\n const bbox: [number, number, number, number] | undefined = Array.isArray(p.extent) && p.extent.length === 4\n ? [p.extent[0], p.extent[3], p.extent[2], p.extent[1]]\n : undefined\n\n return {\n type: 'Feature',\n geometry: feature.geometry,\n ...(bbox ? { bbox } : {}),\n properties: {\n name,\n label,\n housenumber: p.housenumber,\n street: p.street,\n locality,\n neighbourhood: p.district,\n county: p.county,\n region,\n region_a, // mapped from the full subdivision name where known (SUBDIVISION_ABBREVIATIONS)\n country,\n country_a,\n postalcode: p.postcode,\n gid: p.osm_id != null ? `osm:${p.osm_type}:${p.osm_id}` : undefined,\n layer: osmCategoryToLayer(p.type),\n },\n } as Feature\n}\n\n// Normalize a Nominatim reverse result into the Pelias feature shape.\nexport const normalizeNominatimResult = (data: any): Feature => {\n const a = data.address || {}\n // ISO3166-2-lvl4 looks like \"CA-ON\"; the suffix is the Pelias region_a abbreviation.\n const region_a = (a['ISO3166-2-lvl4'] || '').split('-')[1] || ''\n const locality = a.city || a.town || a.village || a.municipality || a.suburb || a.neighbourhood || a.county || ''\n const name = a.road ? [a.house_number, a.road].filter(Boolean).join(' ') : (locality || (data.display_name || '').split(',')[0])\n\n // Nominatim boundingbox is [minlat, maxlat, minlon, maxlon]; Pelias bbox is [west, south, east, north].\n const bb = data.boundingbox\n const bbox: [number, number, number, number] | undefined = Array.isArray(bb) && bb.length === 4\n ? [Number(bb[2]), Number(bb[0]), Number(bb[3]), Number(bb[1])]\n : undefined\n\n return {\n type: 'Feature',\n geometry: { type: 'Point', coordinates: [Number(data.lon), Number(data.lat)] },\n ...(bbox ? { bbox } : {}),\n properties: {\n name,\n label: data.display_name || '',\n housenumber: a.house_number,\n street: a.road,\n locality,\n neighbourhood: a.neighbourhood || a.suburb,\n county: a.county,\n region: a.state,\n region_a,\n country: a.country,\n country_a: (a.country_code || '').toUpperCase(),\n postalcode: a.postcode,\n gid: data.osm_id != null ? `osm:${data.osm_type}:${data.osm_id}` : undefined,\n layer: osmCategoryToLayer(data.addresstype || data.type),\n },\n } as Feature\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAMO,MAAM,qBAAqB,CAAC,aAA8B;AAC/D,UAAQ,UAAU;AAAA,IAChB,KAAK;AAAA,IACL,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAA,IACL,KAAK;AAAQ,aAAO;AAAA,IACpB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAiB,aAAO;AAAA,IAC7B,KAAK;AAAU,aAAO;AAAA,IACtB,KAAK;AAAA,IACL,KAAK;AAAU,aAAO;AAAA,IACtB,KAAK;AAAW,aAAO;AAAA,IACvB;AAAS,aAAO,YAAY;AAAA,EAC9B;AACF;AAKA,MAAM,4BAAoE;AAAA,EACxE,IAAI;AAAA,IACF,WAAW;AAAA,IAAM,oBAAoB;AAAA,IAAM,YAAY;AAAA,IAAM,iBAAiB;AAAA,IAC9E,6BAA6B;AAAA,IAAM,yBAAyB;AAAA,IAAM,eAAe;AAAA,IACjF,WAAW;AAAA,IAAM,WAAW;AAAA,IAAM,wBAAwB;AAAA,IAAM,UAAU;AAAA,IAC1E,aAAU;AAAA,IAAM,gBAAgB;AAAA,IAAM,SAAS;AAAA,EACjD;AAAA,EACA,IAAI;AAAA,IACF,WAAW;AAAA,IAAM,UAAU;AAAA,IAAM,WAAW;AAAA,IAAM,YAAY;AAAA,IAAM,cAAc;AAAA,IAClF,YAAY;AAAA,IAAM,eAAe;AAAA,IAAM,YAAY;AAAA,IAAM,wBAAwB;AAAA,IACjF,WAAW;AAAA,IAAM,WAAW;AAAA,IAAM,UAAU;AAAA,IAAM,SAAS;AAAA,IAAM,YAAY;AAAA,IAC7E,WAAW;AAAA,IAAM,QAAQ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ompleteGeocode: (text: string, countryCode: string, size: number) => Promise<Feature[]>;
|
|
3
4
|
export declare const reverseGeocode: (latitude: string, longitude: string, countryCode: string, { size, coarse, layers }?: {
|
|
@@ -5,4 +6,6 @@ export declare const reverseGeocode: (latitude: string, longitude: string, count
|
|
|
5
6
|
coarse?: boolean;
|
|
6
7
|
layers?: string;
|
|
7
8
|
}) => Promise<Feature[]>;
|
|
9
|
+
/** First result in `level`'s category that lies inside the parent subdivision, or null to go up a level. */
|
|
10
|
+
export declare const searchPlace: (level: PlaceLevel, name: string, context?: PlaceContext) => Promise<Feature | null>;
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AA+BtC,eAAO,MAAM,mBAAmB,GAAU,MAAM,MAAM,EAAE,aAAa,MAAM,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,OAAO,EAAE,CAU5G,CAAA;AAED,eAAO,MAAM,cAAc,GACzB,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,aAAa,MAAM,EACnB,2BAAsC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,KAC9F,OAAO,CAAC,OAAO,EAAE,CAUnB,CAAA;AAcD,4GAA4G;AAC5G,eAAO,MAAM,WAAW,GAAU,OAAO,UAAU,EAAE,MAAM,MAAM,EAAE,UAAS,YAAiB,KAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAGrH,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { toDisplayString } from "../../../../../utils/utils";
|
|
2
2
|
import { getGeocodingConfig } from "./config";
|
|
3
|
-
import { photonAutocomplete, nominatimReverse } from "./osm";
|
|
4
|
-
import { peliasAutocomplete, peliasReverse } from "./pelias";
|
|
3
|
+
import { photonAutocomplete, nominatimReverse, nominatimSearchPlace } from "./osm";
|
|
4
|
+
import { peliasAutocomplete, peliasReverse, peliasSearchPlace } from "./pelias";
|
|
5
|
+
import { matchesContext } from "./placeSearch";
|
|
5
6
|
let peliasAuthFailed = false;
|
|
6
7
|
const peliasActive = () => getGeocodingConfig().usePelias && !peliasAuthFailed;
|
|
7
8
|
const isAuthError = (error) => {
|
|
@@ -38,8 +39,24 @@ const reverseGeocode = async (latitude, longitude, countryCode, { size = 1, coar
|
|
|
38
39
|
}
|
|
39
40
|
return nominatimReverse(latitude, longitude, { coarse });
|
|
40
41
|
};
|
|
42
|
+
const searchPlaceCandidates = async (level, name, context) => {
|
|
43
|
+
if (peliasActive()) {
|
|
44
|
+
try {
|
|
45
|
+
return await peliasSearchPlace(level, name, context);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
handlePeliasFailure(error, "Nominatim");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return nominatimSearchPlace(level, name, context);
|
|
51
|
+
};
|
|
52
|
+
const searchPlace = async (level, name, context = {}) => {
|
|
53
|
+
var _a;
|
|
54
|
+
const candidates = await searchPlaceCandidates(level, name, context);
|
|
55
|
+
return (_a = candidates.find((feature) => matchesContext(feature.properties, context))) != null ? _a : null;
|
|
56
|
+
};
|
|
41
57
|
export {
|
|
42
58
|
autocompleteGeocode,
|
|
43
|
-
reverseGeocode
|
|
59
|
+
reverseGeocode,
|
|
60
|
+
searchPlace
|
|
44
61
|
};
|
|
45
62
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/index.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { toDisplayString } from '../../../../../utils/utils'\n\nimport { getGeocodingConfig } from './config'\nimport { photonAutocomplete, nominatimReverse } from './osm'\nimport { peliasAutocomplete, peliasReverse } from './pelias'\n\nimport type { Feature } from 'geojson'\n\n// Provider-agnostic entry points. The preferred provider (Geocode Earth or a\n// self-hosted Pelias) is resolved in ./config from runtime-injected values;\n// if it fails we fall back to the free public OSM services so address search\n// keeps working.\n//\n// A bad/expired/origin-restricted key surfaces as a 401/403. Autocomplete fires\n// on every keystroke, so once we see an auth failure we stop retrying the keyed\n// provider for the rest of the session and serve results directly from public OSM.\nlet peliasAuthFailed = false\n\nconst peliasActive = (): boolean => getGeocodingConfig().usePelias && !peliasAuthFailed\n\nconst isAuthError = (error: unknown): boolean => {\n const message = error instanceof Error ? error.message : toDisplayString(error)\n return message.includes('401') || message.includes('403')\n}\n\nconst handlePeliasFailure = (error: unknown, fallbackName: string): void => {\n if (isAuthError(error)) {\n peliasAuthFailed = true\n console.warn(\n `Geocoder: the configured provider rejected the API key (auth error). ` +\n `Falling back to public OSM services (Photon/Nominatim) for the rest of this session.`,\n )\n } else {\n console.warn(`Geocoder: provider request failed; falling back to ${fallbackName}.`, error)\n }\n}\n\nexport const autocompleteGeocode = async (text: string, countryCode: string, size: number): Promise<Feature[]> => {\n if (peliasActive()) {\n try {\n return await peliasAutocomplete(text, countryCode, size)\n }\n catch (error) {\n handlePeliasFailure(error, 'Photon')\n }\n }\n return photonAutocomplete(text, countryCode, size)\n}\n\nexport const reverseGeocode = async (\n latitude: string,\n longitude: string,\n countryCode: string,\n { size = 1, coarse = false, layers }: { size?: number; coarse?: boolean; layers?: string } = {},\n): Promise<Feature[]> => {\n if (peliasActive()) {\n try {\n return await peliasReverse(latitude, longitude, countryCode, { size, coarse, layers })\n }\n catch (error) {\n handlePeliasFailure(error, 'Nominatim')\n }\n }\n return nominatimReverse(latitude, longitude, { coarse })\n}\n"],"mappings":"AAGA,SAAS,uBAAuB;AAEhC,SAAS,0BAA0B;AACnC,SAAS,oBAAoB,
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/index.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { toDisplayString } from '../../../../../utils/utils'\n\nimport { getGeocodingConfig } from './config'\nimport { photonAutocomplete, nominatimReverse, nominatimSearchPlace } from './osm'\nimport { peliasAutocomplete, peliasReverse, peliasSearchPlace } from './pelias'\n\nimport { matchesContext } from './placeSearch'\n\nimport type { PlaceContext, PlaceLevel } from './placeSearch'\nimport type { Feature } from 'geojson'\n\n// Provider-agnostic entry points. The preferred provider (Geocode Earth or a\n// self-hosted Pelias) is resolved in ./config from runtime-injected values;\n// if it fails we fall back to the free public OSM services so address search\n// keeps working.\n//\n// A bad/expired/origin-restricted key surfaces as a 401/403. Autocomplete fires\n// on every keystroke, so once we see an auth failure we stop retrying the keyed\n// provider for the rest of the session and serve results directly from public OSM.\nlet peliasAuthFailed = false\n\nconst peliasActive = (): boolean => getGeocodingConfig().usePelias && !peliasAuthFailed\n\nconst isAuthError = (error: unknown): boolean => {\n const message = error instanceof Error ? error.message : toDisplayString(error)\n return message.includes('401') || message.includes('403')\n}\n\nconst handlePeliasFailure = (error: unknown, fallbackName: string): void => {\n if (isAuthError(error)) {\n peliasAuthFailed = true\n console.warn(\n `Geocoder: the configured provider rejected the API key (auth error). ` +\n `Falling back to public OSM services (Photon/Nominatim) for the rest of this session.`,\n )\n } else {\n console.warn(`Geocoder: provider request failed; falling back to ${fallbackName}.`, error)\n }\n}\n\nexport const autocompleteGeocode = async (text: string, countryCode: string, size: number): Promise<Feature[]> => {\n if (peliasActive()) {\n try {\n return await peliasAutocomplete(text, countryCode, size)\n }\n catch (error) {\n handlePeliasFailure(error, 'Photon')\n }\n }\n return photonAutocomplete(text, countryCode, size)\n}\n\nexport const reverseGeocode = async (\n latitude: string,\n longitude: string,\n countryCode: string,\n { size = 1, coarse = false, layers }: { size?: number; coarse?: boolean; layers?: string } = {},\n): Promise<Feature[]> => {\n if (peliasActive()) {\n try {\n return await peliasReverse(latitude, longitude, countryCode, { size, coarse, layers })\n }\n catch (error) {\n handlePeliasFailure(error, 'Nominatim')\n }\n }\n return nominatimReverse(latitude, longitude, { coarse })\n}\n\nconst searchPlaceCandidates = async (level: PlaceLevel, name: string, context: PlaceContext): Promise<Feature[]> => {\n if (peliasActive()) {\n try {\n return await peliasSearchPlace(level, name, context)\n }\n catch (error) {\n handlePeliasFailure(error, 'Nominatim')\n }\n }\n return nominatimSearchPlace(level, name, context)\n}\n\n/** First result in `level`'s category that lies inside the parent subdivision, or null to go up a level. */\nexport const searchPlace = async (level: PlaceLevel, name: string, context: PlaceContext = {}): Promise<Feature | null> => {\n const candidates = await searchPlaceCandidates(level, name, context)\n return candidates.find(feature => matchesContext(feature.properties, context)) ?? null\n}\n"],"mappings":"AAGA,SAAS,uBAAuB;AAEhC,SAAS,0BAA0B;AACnC,SAAS,oBAAoB,kBAAkB,4BAA4B;AAC3E,SAAS,oBAAoB,eAAe,yBAAyB;AAErE,SAAS,sBAAsB;AAa/B,IAAI,mBAAmB;AAEvB,MAAM,eAAe,MAAe,mBAAmB,EAAE,aAAa,CAAC;AAEvE,MAAM,cAAc,CAAC,UAA4B;AAC/C,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,gBAAgB,KAAK;AAC9E,SAAO,QAAQ,SAAS,KAAK,KAAK,QAAQ,SAAS,KAAK;AAC1D;AAEA,MAAM,sBAAsB,CAAC,OAAgB,iBAA+B;AAC1E,MAAI,YAAY,KAAK,GAAG;AACtB,uBAAmB;AACnB,YAAQ;AAAA,MACN;AAAA,IAEF;AAAA,EACF,OAAO;AACL,YAAQ,KAAK,sDAAsD,YAAY,KAAK,KAAK;AAAA,EAC3F;AACF;AAEO,MAAM,sBAAsB,OAAO,MAAc,aAAqB,SAAqC;AAChH,MAAI,aAAa,GAAG;AAClB,QAAI;AACF,aAAO,MAAM,mBAAmB,MAAM,aAAa,IAAI;AAAA,IACzD,SACO,OAAO;AACZ,0BAAoB,OAAO,QAAQ;AAAA,IACrC;AAAA,EACF;AACA,SAAO,mBAAmB,MAAM,aAAa,IAAI;AACnD;AAEO,MAAM,iBAAiB,OAC5B,UACA,WACA,aACA,EAAE,OAAO,GAAG,SAAS,OAAO,OAAO,IAA0D,CAAC,MACvE;AACvB,MAAI,aAAa,GAAG;AAClB,QAAI;AACF,aAAO,MAAM,cAAc,UAAU,WAAW,aAAa,EAAE,MAAM,QAAQ,OAAO,CAAC;AAAA,IACvF,SACO,OAAO;AACZ,0BAAoB,OAAO,WAAW;AAAA,IACxC;AAAA,EACF;AACA,SAAO,iBAAiB,UAAU,WAAW,EAAE,OAAO,CAAC;AACzD;AAEA,MAAM,wBAAwB,OAAO,OAAmB,MAAc,YAA8C;AAClH,MAAI,aAAa,GAAG;AAClB,QAAI;AACF,aAAO,MAAM,kBAAkB,OAAO,MAAM,OAAO;AAAA,IACrD,SACO,OAAO;AACZ,0BAAoB,OAAO,WAAW;AAAA,IACxC;AAAA,EACF;AACA,SAAO,qBAAqB,OAAO,MAAM,OAAO;AAClD;AAGO,MAAM,cAAc,OAAO,OAAmB,MAAc,UAAwB,CAAC,MAA+B;AArF3H;AAsFE,QAAM,aAAa,MAAM,sBAAsB,OAAO,MAAM,OAAO;AACnE,UAAO,gBAAW,KAAK,aAAW,eAAe,QAAQ,YAAY,OAAO,CAAC,MAAtE,YAA2E;AACpF;","names":[]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { PlaceContext, PlaceLevel } from './placeSearch';
|
|
1
2
|
import type { Feature } from 'geojson';
|
|
2
3
|
export declare const photonAutocomplete: (text: string, countryCode: string | undefined, size: number) => Promise<Feature[]>;
|
|
3
4
|
export declare const nominatimReverse: (latitude: string, longitude: string, { coarse }: {
|
|
4
5
|
coarse: boolean;
|
|
5
6
|
}) => Promise<Feature[]>;
|
|
7
|
+
export declare const nominatimSearchPlace: (level: PlaceLevel, name: string, context: PlaceContext) => Promise<Feature[]>;
|
|
6
8
|
//# sourceMappingURL=osm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"osm.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/osm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"osm.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/map/utils/geocoding/osm.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAKtC,eAAO,MAAM,kBAAkB,GAAU,MAAM,MAAM,EAAE,aAAa,MAAM,GAAG,SAAS,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,OAAO,EAAE,CAsBvH,CAAA;AAED,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,YAAY;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,KAC9B,OAAO,CAAC,OAAO,EAAE,CAiBnB,CAAA;AAmBD,eAAO,MAAM,oBAAoB,GAAU,OAAO,UAAU,EAAE,MAAM,MAAM,EAAE,SAAS,YAAY,KAAG,OAAO,CAAC,OAAO,EAAE,CAoBpH,CAAA"}
|