| 123456789101112131415161718192021222324252627282930313233343536373839 |
- /** 详情层级决定空间锚点;设备归属仍由 selection.pointCode 保留。 */
- import { MAP_OBJECT_KIND } from './mapSummary.js'
- import { DEVICE_LAYER_KIND } from './deviceLayer.js'
- import { DETAIL_LEVEL } from './detailFlow.js'
- import { locationVerdict } from './coordinate.js'
- export function resolveDetailAnchor({ selection, objects = [], devices = [] } = {}) {
- const current = selection || {}
- if (current.level === DETAIL_LEVEL.NONE) return null
- if (current.level === DETAIL_LEVEL.EQUIPMENT && current.deviceCode) {
- if (current.pointCode) {
- const device = devices.find((item) => item.code === current.deviceCode && item.pointCode === current.pointCode) || null
- return { kind: DEVICE_LAYER_KIND, code: current.deviceCode, pointCode: current.pointCode, object: device }
- }
- const device = objects.find((item) => item.kind === MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT && item.code === current.deviceCode) || null
- return { kind: MAP_OBJECT_KIND.UNASSOCIATED_EQUIPMENT, code: current.deviceCode, object: device }
- }
- if (!current.pointCode) return null
- const point = objects.find((item) => item.kind === MAP_OBJECT_KIND.MONITORING_POINT && item.code === current.pointCode) || null
- return { kind: MAP_OBJECT_KIND.MONITORING_POINT, code: current.pointCode, object: point }
- }
- /** Facility placement is its own evidence; no fabricated device coordinateValidation. */
- export function resolveFacilityDetailAnchor(point) {
- return point ? { kind: 'facility-point', code: point.code, key: point.key, category: point.detailCategory, id: point.id, object: point } : null
- }
- export function detailAnchorLocation(target) {
- if (target?.kind === 'facility-point') {
- const point = target.object
- return !point || point.placement === 'pending'
- ? { present: false, renderable: false, reasonText: '' }
- : { present: true, renderable: point.placement === 'drawn', reasonText: point.reasonText || '' }
- }
- if (!target || (target.object && target.object.placement === 'pending')) {
- return { present: false, renderable: false, reasonText: '' }
- }
- return locationVerdict(target.object ? [target.object] : [], target.code)
- }
|