|
@@ -1,12 +1,12 @@
|
|
|
/**
|
|
/**
|
|
|
- * 屏幕拥挤聚合:未关联设备(03)与监测点(04)共用一套分组/成员表/缩放接缝。
|
|
|
|
|
|
|
+ * 屏幕拥挤聚合:未关联设备(03)、监测点(04)、设施点(05)共用一套分组/成员表/缩放接缝。
|
|
|
*
|
|
*
|
|
|
* 纯函数、不 import Vue/Cesium/DOM:输入是**已经投影到窗口坐标**的对象行
|
|
* 纯函数、不 import Vue/Cesium/DOM:输入是**已经投影到窗口坐标**的对象行
|
|
|
* (服务层/overlay 每帧用同一枚 projectToWindow 投影),输出是稳定的聚合组与成员表。
|
|
* (服务层/overlay 每帧用同一枚 projectToWindow 投影),输出是稳定的聚合组与成员表。
|
|
|
*
|
|
*
|
|
|
* 第一性原理:
|
|
* 第一性原理:
|
|
|
* · 聚合只表达**显示拥挤**,不改变成员的真实坐标、身份、状态或统计口径;
|
|
* · 聚合只表达**显示拥挤**,不改变成员的真实坐标、身份、状态或统计口径;
|
|
|
- * · 三类对象各有独立命名空间,本文件只聚设备与监测点,绝不跨类合并;
|
|
|
|
|
|
|
+ * · 三类对象各有独立命名空间,绝不跨类合并;
|
|
|
* · 组身份 = 类别命名空间 + 成员编码集合(排序后拼接),成员不变 groupKey 稳定;
|
|
* · 组身份 = 类别命名空间 + 成员编码集合(排序后拼接),成员不变 groupKey 稳定;
|
|
|
* · 状态优先级按类别原生词表:设备五态(报警>工单>预警)与点位六态(报警>预警>工单)
|
|
* · 状态优先级按类别原生词表:设备五态(报警>工单>预警)与点位六态(报警>预警>工单)
|
|
|
* 不共用一张表;
|
|
* 不共用一张表;
|
|
@@ -17,6 +17,8 @@
|
|
|
// 未关联设备的“原生状态”是设备五态(不是点位六态):色/词/优先级都走设备表,
|
|
// 未关联设备的“原生状态”是设备五态(不是点位六态):色/词/优先级都走设备表,
|
|
|
// 否则工单处置与预警的先后会被点位表带反(设备规则:报警 > 工单处置 > 预警)。
|
|
// 否则工单处置与预警的先后会被点位表带反(设备规则:报警 > 工单处置 > 预警)。
|
|
|
import { deviceVisualForStatus } from './deviceStatus.js'
|
|
import { deviceVisualForStatus } from './deviceStatus.js'
|
|
|
|
|
+import { facilityTypeMeta } from './facilityPoints.js'
|
|
|
|
|
+import { facilityVisualStatus } from './facilityStatus.js'
|
|
|
import { industryLabel } from './filterOptions.js'
|
|
import { industryLabel } from './filterOptions.js'
|
|
|
import { ringEffectFor } from './markerMetrics.js'
|
|
import { ringEffectFor } from './markerMetrics.js'
|
|
|
import { PIPE_PALETTE } from './pipeVisual.js'
|
|
import { PIPE_PALETTE } from './pipeVisual.js'
|
|
@@ -26,6 +28,8 @@ import { visualForStatus } from './pointStatus.js'
|
|
|
export const AGGREGATE_KIND = 'unassociated-equipment-aggregate'
|
|
export const AGGREGATE_KIND = 'unassociated-equipment-aggregate'
|
|
|
/** 监测点聚合符号的 kind:与设备聚合**独立命名空间**,同位置也不跨类合并。 */
|
|
/** 监测点聚合符号的 kind:与设备聚合**独立命名空间**,同位置也不跨类合并。 */
|
|
|
export const POINT_AGGREGATE_KIND = 'monitoring-point-aggregate'
|
|
export const POINT_AGGREGATE_KIND = 'monitoring-point-aggregate'
|
|
|
|
|
+/** 设施点聚合符号的 kind:第三类独立命名空间。 */
|
|
|
|
|
+export const FACILITY_AGGREGATE_KIND = 'facility-point-aggregate'
|
|
|
|
|
|
|
|
/** 默认屏幕合并阈值(px):小于该距离视为拥挤。 */
|
|
/** 默认屏幕合并阈值(px):小于该距离视为拥挤。 */
|
|
|
export const DEFAULT_MIN_SEPARATION_PX = 22
|
|
export const DEFAULT_MIN_SEPARATION_PX = 22
|
|
@@ -71,6 +75,29 @@ const TYPE_CHAR = {
|
|
|
MANHOLE: '井',
|
|
MANHOLE: '井',
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/** 设施类型短字(同质单一类型时用;混合用「混」)。 */
|
|
|
|
|
+const FACILITY_TYPE_CHAR = {
|
|
|
|
|
+ WATER_PLANT: '厂',
|
|
|
|
|
+ PUMP_STATION: '泵',
|
|
|
|
|
+ WATER_SOURCE: '源',
|
|
|
|
|
+ WATER_USER: '户',
|
|
|
|
|
+ WATER_FIRE_HYDRANT: '消',
|
|
|
|
|
+ DRAINAGE_GATE: '闸',
|
|
|
|
|
+ DRAINAGE_STORAGE: '蓄',
|
|
|
|
|
+ MANHOLE: '井',
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 设施状态视觉:设施只有 0 正常 / 1 异常(后端统一码值),不得借用设备工单/预警/离线词表;
|
|
|
|
|
+ * 异常文案是「异常」而不是设备「报警」。
|
|
|
|
|
+ */
|
|
|
|
|
+function facilityStatusVisual(status) {
|
|
|
|
|
+ const key = facilityVisualStatus(status)
|
|
|
|
|
+ if (key === 'ALARM') return { key, priority: 1, tone: 'lv1', label: '异常' }
|
|
|
|
|
+ if (key === 'NORMAL') return { key, priority: 2, tone: 'lv4', label: '正常' }
|
|
|
|
|
+ return { key: 'UNKNOWN', priority: 3, tone: 'neutral', label: '状态未发布' }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 单体标签是否被聚合徽章覆盖(标签避让判据)。
|
|
* 单体标签是否被聚合徽章覆盖(标签避让判据)。
|
|
|
* @param {{x:number,y:number}} pos 单体标签锚点(宿主相对窗口坐标)
|
|
* @param {{x:number,y:number}} pos 单体标签锚点(宿主相对窗口坐标)
|
|
@@ -158,6 +185,10 @@ const CATEGORY_PROFILE = {
|
|
|
toneFallback: 'point-unassociated',
|
|
toneFallback: 'point-unassociated',
|
|
|
visualOf: deviceVisualForStatus,
|
|
visualOf: deviceVisualForStatus,
|
|
|
effectOf: (status) => deviceVisualForStatus(status).effect || '',
|
|
effectOf: (status) => deviceVisualForStatus(status).effect || '',
|
|
|
|
|
+ typeKeyOf: (member) => member.industry || '',
|
|
|
|
|
+ typeLabelOf: (key) => industryLabel(key) || (key || '未标注'),
|
|
|
|
|
+ typeCharOf: (key) => typeCharOf(key, '设'),
|
|
|
|
|
+ typeColorOf: (key) => typeColorOf(key),
|
|
|
},
|
|
},
|
|
|
'monitoring-point': {
|
|
'monitoring-point': {
|
|
|
key: 'monitoring-point',
|
|
key: 'monitoring-point',
|
|
@@ -175,6 +206,32 @@ const CATEGORY_PROFILE = {
|
|
|
const ring = ringEffectFor(status)
|
|
const ring = ringEffectFor(status)
|
|
|
return ring ? ring.effect : ''
|
|
return ring ? ring.effect : ''
|
|
|
},
|
|
},
|
|
|
|
|
+ typeKeyOf: (member) => member.industry || '',
|
|
|
|
|
+ typeLabelOf: (key) => industryLabel(key) || (key || '未标注'),
|
|
|
|
|
+ typeCharOf: (key) => typeCharOf(key, '点'),
|
|
|
|
|
+ typeColorOf: (key) => typeColorOf(key),
|
|
|
|
|
+ },
|
|
|
|
|
+ 'facility-point': {
|
|
|
|
|
+ key: 'facility-point',
|
|
|
|
|
+ memberKind: 'facility-point',
|
|
|
|
|
+ aggregateKind: FACILITY_AGGREGATE_KIND,
|
|
|
|
|
+ category: '设施点',
|
|
|
|
|
+ noun: '个设施点',
|
|
|
|
|
+ fallbackTypeChar: '设',
|
|
|
|
|
+ fallbackTypeLabel: '设施',
|
|
|
|
|
+ toneFallback: 'neutral',
|
|
|
|
|
+ // 设施状态不借用设备词表:1=异常、0=正常,未发布保持未知。
|
|
|
|
|
+ visualOf: facilityStatusVisual,
|
|
|
|
|
+ // 单体设施异常在现有渲染里是 pulse;聚合组同样只挂一套,文案仍是「异常」。
|
|
|
|
|
+ effectOf: (status) => (facilityVisualStatus(status) === 'ALARM' ? 'pulse' : ''),
|
|
|
|
|
+ typeKeyOf: (member) => member.type || '',
|
|
|
|
|
+ typeLabelOf: (key) => {
|
|
|
|
|
+ const meta = facilityTypeMeta(key)
|
|
|
|
|
+ return meta ? meta.label : (key || '设施')
|
|
|
|
|
+ },
|
|
|
|
|
+ typeCharOf: (key) => FACILITY_TYPE_CHAR[key] || '设',
|
|
|
|
|
+ // 设施没有行业色语义,统一用系统青色;混合类型回中性灰(不冒充某一类)。
|
|
|
|
|
+ typeColorOf: () => '#01abea',
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -200,20 +257,25 @@ function isCandidate(item, profile) {
|
|
|
* 点位:报警 > 预警 > 工单处置 > 正常 > 离线 > 无设备 > 未发布。
|
|
* 点位:报警 > 预警 > 工单处置 > 正常 > 离线 > 无设备 > 未发布。
|
|
|
*/
|
|
*/
|
|
|
export function statusPriority(status, profile = EQUIPMENT_PROFILE) {
|
|
export function statusPriority(status, profile = EQUIPMENT_PROFILE) {
|
|
|
- const visual = profile.visualOf(status || '')
|
|
|
|
|
|
|
+ const value = status === undefined || status === null ? '' : status
|
|
|
|
|
+ const visual = profile.visualOf(value)
|
|
|
return Number.isFinite(visual.priority) ? visual.priority : 999
|
|
return Number.isFinite(visual.priority) ? visual.priority : 999
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function statusSummaryOf(members, profile) {
|
|
function statusSummaryOf(members, profile) {
|
|
|
const counts = {}
|
|
const counts = {}
|
|
|
for (const member of members) {
|
|
for (const member of members) {
|
|
|
- const key = member.status || 'UNKNOWN'
|
|
|
|
|
|
|
+ // 0 是设施的合法状态码,不能用 `|| 'UNKNOWN'` 把数字 0 吃掉。
|
|
|
|
|
+ const raw = member.status
|
|
|
|
|
+ const key = raw === undefined || raw === null || raw === '' ? 'UNKNOWN' : String(raw)
|
|
|
counts[key] = (counts[key] || 0) + 1
|
|
counts[key] = (counts[key] || 0) + 1
|
|
|
}
|
|
}
|
|
|
const statuses = Object.keys(counts).map((status) => {
|
|
const statuses = Object.keys(counts).map((status) => {
|
|
|
const visual = profile.visualOf(status)
|
|
const visual = profile.visualOf(status)
|
|
|
return {
|
|
return {
|
|
|
status,
|
|
status,
|
|
|
|
|
+ // 视觉词(设施 1→ALARM)供角标/特效取 profile;文案仍是设施「异常」,不写成设备「报警」。
|
|
|
|
|
+ visualKey: visual.key || status,
|
|
|
count: counts[status],
|
|
count: counts[status],
|
|
|
priority: Number.isFinite(visual.priority) ? visual.priority : 999,
|
|
priority: Number.isFinite(visual.priority) ? visual.priority : 999,
|
|
|
tone: visual.tone,
|
|
tone: visual.tone,
|
|
@@ -265,30 +327,32 @@ export function worldSpanMeters(bounds) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function buildGroup(rawMembers, profile) {
|
|
function buildGroup(rawMembers, profile) {
|
|
|
- const members = rawMembers.slice().sort((a, b) => String(a.code).localeCompare(String(b.code)))
|
|
|
|
|
|
|
+ // 设施编码可重复(真实身份是 type+entityId 的 key);排序与组身份都用 key 兜底。
|
|
|
|
|
+ const members = rawMembers.slice().sort((a, b) => String(a.code).localeCompare(String(b.code))
|
|
|
|
|
+ || String(a.key || '').localeCompare(String(b.key || '')))
|
|
|
const screen = {
|
|
const screen = {
|
|
|
x: members.reduce((sum, item) => sum + item.screen.x, 0) / members.length,
|
|
x: members.reduce((sum, item) => sum + item.screen.x, 0) / members.length,
|
|
|
y: members.reduce((sum, item) => sum + item.screen.y, 0) / members.length,
|
|
y: members.reduce((sum, item) => sum + item.screen.y, 0) / members.length,
|
|
|
}
|
|
}
|
|
|
const screenBox = screenBounds(members)
|
|
const screenBox = screenBounds(members)
|
|
|
const boundsWorld = worldBounds(members)
|
|
const boundsWorld = worldBounds(members)
|
|
|
- const codes = members.map((item) => String(item.code || ''))
|
|
|
|
|
- // 类型维度:未关联设备的“类型”就是它的行业(燃气/供水/排水/窨井);同质用该类型图案,
|
|
|
|
|
- // 混合则用通用图案(规格:不得长期显示过期类别语义)。
|
|
|
|
|
- const industryCounts = new Map()
|
|
|
|
|
|
|
+ const identities = members.map((item) => String(item.key || item.code || ''))
|
|
|
|
|
+ // 类型维度:设备/监测点看行业(燃气/供水/排水/窨井),设施点看设施类型(水厂/泵站/…);
|
|
|
|
|
+ // 同质用该类型短字/图案,混合用通用(规格:不得长期显示过期类别语义)。
|
|
|
|
|
+ const typeCounts = new Map()
|
|
|
for (const member of members) {
|
|
for (const member of members) {
|
|
|
- const key = member.industry || ''
|
|
|
|
|
- industryCounts.set(key, (industryCounts.get(key) || 0) + 1)
|
|
|
|
|
|
|
+ const key = profile.typeKeyOf(member) || ''
|
|
|
|
|
+ typeCounts.set(key, (typeCounts.get(key) || 0) + 1)
|
|
|
}
|
|
}
|
|
|
- const industrySummary = [...industryCounts.entries()]
|
|
|
|
|
- .map(([key, count]) => ({ key, count, label: industryLabel(key) || (key || '未标注') }))
|
|
|
|
|
|
|
+ const industrySummary = [...typeCounts.entries()]
|
|
|
|
|
+ .map(([key, count]) => ({ key, count, label: profile.typeLabelOf(key) || (key || '未标注') }))
|
|
|
.sort((a, b) => b.count - a.count || a.key.localeCompare(b.key))
|
|
.sort((a, b) => b.count - a.count || a.key.localeCompare(b.key))
|
|
|
const mixedIndustry = industrySummary.length > 1
|
|
const mixedIndustry = industrySummary.length > 1
|
|
|
const statusSummary = statusSummaryOf(members, profile)
|
|
const statusSummary = statusSummaryOf(members, profile)
|
|
|
return {
|
|
return {
|
|
|
kind: profile.aggregateKind,
|
|
kind: profile.aggregateKind,
|
|
|
- // 组身份 = 类别命名空间 + 成员编码集合(成员不变则稳定,相机微移不抖)。
|
|
|
|
|
- groupKey: profile.aggregateKind + '|' + codes.join(','),
|
|
|
|
|
|
|
+ // 组身份 = 类别命名空间 + 成员身份集合(设施用 key,设备/点位用 code;成员不变则稳定)。
|
|
|
|
|
+ groupKey: profile.aggregateKind + '|' + identities.join(','),
|
|
|
statusProfile: profile.key,
|
|
statusProfile: profile.key,
|
|
|
memberKind: profile.memberKind,
|
|
memberKind: profile.memberKind,
|
|
|
category: profile.category,
|
|
category: profile.category,
|
|
@@ -314,10 +378,10 @@ function buildGroup(rawMembers, profile) {
|
|
|
mixedIndustry,
|
|
mixedIndustry,
|
|
|
primaryIndustry: industrySummary.length ? industrySummary[0].key : '',
|
|
primaryIndustry: industrySummary.length ? industrySummary[0].key : '',
|
|
|
typeLabel: mixedIndustry ? '混合' : (industrySummary.length ? industrySummary[0].label : profile.fallbackTypeLabel),
|
|
typeLabel: mixedIndustry ? '混合' : (industrySummary.length ? industrySummary[0].label : profile.fallbackTypeLabel),
|
|
|
- // 徽章中央大字:混合=混、同质=行业短字(燃/水/排/井),认不出=类别兜底(设备「设」/点位「点」)。
|
|
|
|
|
- typeChar: mixedIndustry ? '混' : typeCharOf(industrySummary.length ? industrySummary[0].key : '', profile.fallbackTypeChar),
|
|
|
|
|
- // 类型色语义:同质用行业色;混合用中性色(避免冒充某一行业)。
|
|
|
|
|
- typeColor: mixedIndustry ? PIPE_PALETTE.UNKNOWN.color : typeColorOf(industrySummary.length ? industrySummary[0].key : ''),
|
|
|
|
|
|
|
+ // 徽章中央大字:混合=混、同质=类型短字(燃/水/排/井,设施为厂/泵/源/户/…)。
|
|
|
|
|
+ typeChar: mixedIndustry ? '混' : profile.typeCharOf(industrySummary.length ? industrySummary[0].key : ''),
|
|
|
|
|
+ // 类型色语义:同质按类别(行业色/设施青);混合用中性色。
|
|
|
|
|
+ typeColor: mixedIndustry ? PIPE_PALETTE.UNKNOWN.color : profile.typeColorOf(industrySummary.length ? industrySummary[0].key : ''),
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -336,8 +400,10 @@ function groupByScreen(items, categoryKey, { minSeparationPx = DEFAULT_MIN_SEPAR
|
|
|
const profile = CATEGORY_PROFILE[categoryKey] || EQUIPMENT_PROFILE
|
|
const profile = CATEGORY_PROFILE[categoryKey] || EQUIPMENT_PROFILE
|
|
|
const list = (Array.isArray(items) ? items : []).filter((item) => isCandidate(item, profile))
|
|
const list = (Array.isArray(items) ? items : []).filter((item) => isCandidate(item, profile))
|
|
|
const selected = typeof selectedCode === 'string' ? selectedCode : ''
|
|
const selected = typeof selectedCode === 'string' ? selectedCode : ''
|
|
|
- const pool = list.filter((item) => String(item.code || '') !== selected)
|
|
|
|
|
- const selectedRow = selected ? (list.find((item) => String(item.code) === selected) || null) : null
|
|
|
|
|
|
|
+ // 设施点的选中身份是完整 key(类型+实体 id),设备/点位用 code;两者都认。
|
|
|
|
|
+ const isSelected = (item) => String(item.code || '') === selected || (item.key !== undefined && String(item.key) === selected)
|
|
|
|
|
+ const pool = list.filter((item) => !isSelected(item))
|
|
|
|
|
+ const selectedRow = selected ? (list.find(isSelected) || null) : null
|
|
|
if (!pool.length) return { groups: [], selected: selectedRow }
|
|
if (!pool.length) return { groups: [], selected: selectedRow }
|
|
|
|
|
|
|
|
const threshold = Number.isFinite(minSeparationPx) && minSeparationPx > 0 ? minSeparationPx : DEFAULT_MIN_SEPARATION_PX
|
|
const threshold = Number.isFinite(minSeparationPx) && minSeparationPx > 0 ? minSeparationPx : DEFAULT_MIN_SEPARATION_PX
|
|
@@ -412,6 +478,13 @@ export function groupMonitoringPointsByScreen(items, options = {}) {
|
|
|
return groupByScreen(items, 'monitoring-point', options)
|
|
return groupByScreen(items, 'monitoring-point', options)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 设施点的屏幕聚合(05):独立命名空间;状态走设施 0/1 词表,类型走设施类型表。
|
|
|
|
|
+ */
|
|
|
|
|
+export function groupFacilityPointsByScreen(items, options = {}) {
|
|
|
|
|
+ return groupByScreen(items, 'facility-point', options)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 聚合徽章的可显示描述(规格 69–72)。
|
|
* 聚合徽章的可显示描述(规格 69–72)。
|
|
|
*
|
|
*
|
|
@@ -446,7 +519,7 @@ export function aggregateBadge(group) {
|
|
|
abnormal,
|
|
abnormal,
|
|
|
otherAbnormalCount: summary.otherAbnormalCount || 0,
|
|
otherAbnormalCount: summary.otherAbnormalCount || 0,
|
|
|
// 特效:与最高优先级异常一致;无异常不挂特效。每组最多一套(由徽章节点承载,不叠加成员环)。
|
|
// 特效:与最高优先级异常一致;无异常不挂特效。每组最多一套(由徽章节点承载,不叠加成员环)。
|
|
|
- effectStatus: abnormal ? abnormal.status : '',
|
|
|
|
|
|
|
+ effectStatus: abnormal ? (abnormal.visualKey || abnormal.status) : '',
|
|
|
effect: abnormal ? abnormal.effect : '',
|
|
effect: abnormal ? abnormal.effect : '',
|
|
|
// 类型:同质给具体行业(图案),混合给通用(typeLabel=混合、industryKey 为空)。
|
|
// 类型:同质给具体行业(图案),混合给通用(typeLabel=混合、industryKey 为空)。
|
|
|
mixedIndustry: Boolean(group.mixedIndustry),
|
|
mixedIndustry: Boolean(group.mixedIndustry),
|
|
@@ -465,6 +538,70 @@ export function aggregateBadge(group) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/** 三类徽章的固定顺序(跨类避让角度按它取,缺类也不会让其它类换角度)。 */
|
|
|
|
|
+export const BADGE_CLASS_ORDER = Object.freeze(['unassociated-equipment', 'monitoring-point', 'facility-point'])
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 三类徽章同位置避让:同一锚点附近的不同类徽章做固定小三角偏移,并用细引线指回真实锚点。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 第一性原理:三类对象是**独立命名空间**,不能合并;但同一个屏幕位置最多呈现三个徽章,
|
|
|
|
|
+ * 否则会互相压住。偏移角按类固定(设备上、监测点右下、设施左下),缺类不改变其它类的角度;
|
|
|
|
|
+ * 进入用紧阈值、离开用缓冲(previousKeys),避免边界来回摆动。
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {Array} groups 徽章组(需 memberKind / groupKey / screen)
|
|
|
|
|
+ * @param {{radius?:number, enterPx?:number, exitPx?:number, previousKeys?:Set<string>}} [options]
|
|
|
|
|
+ * @returns {Map<string,{dx:number,dy:number,x:number,y:number,anchorX:number,anchorY:number,offset:boolean,leader:boolean}>}
|
|
|
|
|
+ */
|
|
|
|
|
+export function planBadgeOffsets(groups, { radius = 24, enterPx = 14, exitPx = 20, previousKeys = new Set() } = {}) {
|
|
|
|
|
+ const list = (Array.isArray(groups) ? groups : []).filter((group) => group && group.groupKey
|
|
|
|
|
+ && group.screen && Number.isFinite(group.screen.x) && Number.isFinite(group.screen.y))
|
|
|
|
|
+ const classIndex = (group) => {
|
|
|
|
|
+ const index = BADGE_CLASS_ORDER.indexOf(group.memberKind)
|
|
|
|
|
+ return index >= 0 ? index : BADGE_CLASS_ORDER.length
|
|
|
|
|
+ }
|
|
|
|
|
+ list.sort((a, b) => classIndex(a) - classIndex(b) || String(a.groupKey).localeCompare(String(b.groupKey)))
|
|
|
|
|
+ const clusters = []
|
|
|
|
|
+ for (const group of list) {
|
|
|
|
|
+ let target = null
|
|
|
|
|
+ let best = Number.POSITIVE_INFINITY
|
|
|
|
|
+ for (const cluster of clusters) {
|
|
|
|
|
+ const distance = Math.hypot(group.screen.x - cluster.anchor.x, group.screen.y - cluster.anchor.y)
|
|
|
|
|
+ const wasOffset = previousKeys.has(group.groupKey) || cluster.keys.some((key) => previousKeys.has(key))
|
|
|
|
|
+ const limit = wasOffset ? exitPx : enterPx
|
|
|
|
|
+ if (distance <= limit && distance < best) {
|
|
|
|
|
+ target = cluster
|
|
|
|
|
+ best = distance
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!target) {
|
|
|
|
|
+ target = { anchor: { x: group.screen.x, y: group.screen.y }, groups: [], keys: [] }
|
|
|
|
|
+ clusters.push(target)
|
|
|
|
|
+ }
|
|
|
|
|
+ target.groups.push(group)
|
|
|
|
|
+ target.keys.push(group.groupKey)
|
|
|
|
|
+ }
|
|
|
|
|
+ const layout = new Map()
|
|
|
|
|
+ for (const cluster of clusters) {
|
|
|
|
|
+ const single = cluster.groups.length === 1
|
|
|
|
|
+ for (const group of cluster.groups) {
|
|
|
|
|
+ const angle = single ? 0 : (-90 + classIndex(group) * 120) * Math.PI / 180
|
|
|
|
|
+ const dx = single ? 0 : Math.cos(angle) * radius
|
|
|
|
|
+ const dy = single ? 0 : Math.sin(angle) * radius
|
|
|
|
|
+ layout.set(group.groupKey, {
|
|
|
|
|
+ dx,
|
|
|
|
|
+ dy,
|
|
|
|
|
+ x: cluster.anchor.x + dx,
|
|
|
|
|
+ y: cluster.anchor.y + dy,
|
|
|
|
|
+ anchorX: cluster.anchor.x,
|
|
|
|
|
+ anchorY: cluster.anchor.y,
|
|
|
|
|
+ offset: !single,
|
|
|
|
|
+ leader: !single,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return layout
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/** 该组是否还能靠缩放拆开:屏幕离散且真实跨度都够大。 */
|
|
/** 该组是否还能靠缩放拆开:屏幕离散且真实跨度都够大。 */
|
|
|
export function canZoomAggregate(group, { minSpreadPx = DEFAULT_MIN_SPREAD_PX, minSpanMeters = DEFAULT_MIN_SPAN_METERS } = {}) {
|
|
export function canZoomAggregate(group, { minSpreadPx = DEFAULT_MIN_SPREAD_PX, minSpanMeters = DEFAULT_MIN_SPAN_METERS } = {}) {
|
|
|
if (!group || group.count < 2) return false
|
|
if (!group || group.count < 2) return false
|
|
@@ -496,11 +633,14 @@ export function planMemberList(group, { query = '', sort = 'risk' } = {}) {
|
|
|
const profile = CATEGORY_PROFILE[group && group.statusProfile] || EQUIPMENT_PROFILE
|
|
const profile = CATEGORY_PROFILE[group && group.statusProfile] || EQUIPMENT_PROFILE
|
|
|
const priorities = (group && group.statusPriorities) || {}
|
|
const priorities = (group && group.statusPriorities) || {}
|
|
|
const rows = filtered.map((item) => {
|
|
const rows = filtered.map((item) => {
|
|
|
- const visual = profile.visualOf(item.status || '')
|
|
|
|
|
|
|
+ // 0 是设施合法状态码,不能用 `|| ''` 吃掉。
|
|
|
|
|
+ const visual = profile.visualOf(item.status === undefined || item.status === null ? '' : item.status)
|
|
|
return {
|
|
return {
|
|
|
...item,
|
|
...item,
|
|
|
statusLabel: visual.label,
|
|
statusLabel: visual.label,
|
|
|
statusTone: visual.tone,
|
|
statusTone: visual.tone,
|
|
|
|
|
+ // 设备/监测点给行业词;设施点给设施类型词(水厂/泵站/…)。
|
|
|
|
|
+ typeLabel: profile.typeLabelOf(profile.typeKeyOf(item)),
|
|
|
industryLabel: industryLabel(item.industry) || (item.industry || '未标注'),
|
|
industryLabel: industryLabel(item.industry) || (item.industry || '未标注'),
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|