|
@@ -23,12 +23,14 @@ import {
|
|
|
getAssociatedDeviceState,
|
|
getAssociatedDeviceState,
|
|
|
getCameraState,
|
|
getCameraState,
|
|
|
highlightMapObject,
|
|
highlightMapObject,
|
|
|
|
|
+ locateFacilityPoint,
|
|
|
locateMonitoringPoint,
|
|
locateMonitoringPoint,
|
|
|
} from '../services/mapService.js'
|
|
} from '../services/mapService.js'
|
|
|
import { LOCATE_RESULT, locateFailureText, planLocate } from '../domain/mapLocate.js'
|
|
import { LOCATE_RESULT, locateFailureText, planLocate } from '../domain/mapLocate.js'
|
|
|
import { EVENT_DETAIL_RESULT, planEventLocate } from '../domain/eventDetail.js'
|
|
import { EVENT_DETAIL_RESULT, planEventLocate } from '../domain/eventDetail.js'
|
|
|
import { TERRAIN_LOCATE_REASON } from '../domain/pointLocate.js'
|
|
import { TERRAIN_LOCATE_REASON } from '../domain/pointLocate.js'
|
|
|
import { MAP_OBJECT_KIND } from '../domain/mapSummary.js'
|
|
import { MAP_OBJECT_KIND } from '../domain/mapSummary.js'
|
|
|
|
|
+import { facilityIdentity, resolveFacilityPoint } from '../domain/facilitySelection.js'
|
|
|
|
|
|
|
|
const EMPTY_RESULT = { result: '', code: '', pointCode: '', deviceCode: '', reasonText: '', at: 0 }
|
|
const EMPTY_RESULT = { result: '', code: '', pointCode: '', deviceCode: '', reasonText: '', at: 0 }
|
|
|
|
|
|
|
@@ -213,6 +215,43 @@ export const usePointLocateStore = defineStore('pointLocateStore', () => {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 只把相机飞到某个设施/线段对象,**不开详情**。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 为什么不复用 `locateFacility`:那条路走 `facilityPointStore.select` 的竞态令牌,
|
|
|
|
|
+ * 详情关闭或其它选择会让本次调用被判成过期而返回 false(界面表现为「设施定位未完成」)。
|
|
|
|
|
+ * 关联管网聚焦只需要「解析点位 + 飞行」,单开一条不参与令牌的入口最稳。
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {object} identityInput `{ kind: 'facility', id, category }`
|
|
|
|
|
+ * @param {{ network?: object }} [options] `network` 是管线图层数据(算线段中点用)
|
|
|
|
|
+ */
|
|
|
|
|
+ async function focusFacilityPoint(identityInput, options = {}) {
|
|
|
|
|
+ const identity = facilityIdentity(identityInput)
|
|
|
|
|
+ if (!identity.valid) {
|
|
|
|
|
+ return setLocate({ result: LOCATE_RESULT.UNAVAILABLE, code: (identityInput && identityInput.id) || '', reasonText: '该对象没有可定位的类型' })
|
|
|
|
|
+ }
|
|
|
|
|
+ const point = resolveFacilityPoint({ identity, network: options.network })
|
|
|
|
|
+ if (!point || point.placement === 'pending') {
|
|
|
|
|
+ return setLocate({ result: LOCATE_RESULT.UNAVAILABLE, code: identity.id, reasonText: point?.reasonText || '尚未取到该对象的可定位几何' })
|
|
|
|
|
+ }
|
|
|
|
|
+ if (point.placement !== 'drawn') {
|
|
|
|
|
+ return setLocate({ result: LOCATE_RESULT.BLOCKED, code: identity.id, reasonText: point.reasonText || '该对象没有可定位的地图位置' })
|
|
|
|
|
+ }
|
|
|
|
|
+ let failure = TERRAIN_LOCATE_REASON.MAP
|
|
|
|
|
+ let applied = false
|
|
|
|
|
+ try {
|
|
|
|
|
+ applied = await locateFacilityPoint(point, { tier: 'device', onFailure: (reason) => { failure = reason } })
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ applied = false
|
|
|
|
|
+ }
|
|
|
|
|
+ return setLocate({
|
|
|
|
|
+ result: applied === true ? LOCATE_RESULT.OK : LOCATE_RESULT.UNAVAILABLE,
|
|
|
|
|
+ code: identity.id,
|
|
|
|
|
+ pointCode: point.code || identity.id,
|
|
|
|
|
+ reasonText: applied === true ? '' : locateFailureText(failure),
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 唯一入口:按目标身份定位。`options` 只给测试/特殊链路注入(objects / flyPoint / openPoint…),
|
|
* 唯一入口:按目标身份定位。`options` 只给测试/特殊链路注入(objects / flyPoint / openPoint…),
|
|
|
* 业务调用方不传。
|
|
* 业务调用方不传。
|
|
@@ -224,5 +263,5 @@ export const usePointLocateStore = defineStore('pointLocateStore', () => {
|
|
|
return locateMapObject(target.code, options)
|
|
return locateMapObject(target.code, options)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return { locate, locateTarget, clearLocate }
|
|
|
|
|
|
|
+ return { locate, locateTarget, focusFacilityPoint, clearLocate }
|
|
|
})
|
|
})
|