| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- diff --git a/src/modules/cockpit/domain/pipeNetwork.js b/src/modules/cockpit/domain/pipeNetwork.js
- index 1c5b3b0..bbe6775 100644
- --- a/src/modules/cockpit/domain/pipeNetwork.js
- +++ b/src/modules/cockpit/domain/pipeNetwork.js
- @@ -110,13 +110,16 @@ function diameterOf(value) {
- return Number.isFinite(number) ? number : null
- }
-
- -/** 管段几何:两点 `[lon, lat]`;点数不足 2 一律不可上图(不补点、不截断成一点)。 */
- +/** 管段几何:保留完整路径;任一顶点结构非法就整条拦下,不跳点重连。 */
- function pipePositions(geometry) {
- const raw = geometry && geometry.type === 'LineString' && Array.isArray(geometry.coordinates) ? geometry.coordinates : []
- - const positions = raw
- - .filter((pair) => Array.isArray(pair) && isFiniteNumber(pair[0]) && isFiniteNumber(pair[1]))
- - .map((pair) => [pair[0], pair[1]])
- - return positions.length >= 2 ? positions : []
- + if (raw.length < 2) return []
- + const positions = []
- + for (const pair of raw) {
- + if (!Array.isArray(pair) || !isFiniteNumber(pair[0]) || !isFiniteNumber(pair[1])) return []
- + positions.push([pair[0], pair[1]])
- + }
- + return positions
- }
-
- /** 构件几何:点 `[lon, lat]`。 */
- diff --git a/src/modules/cockpit/services/cesiumEngine.js b/src/modules/cockpit/services/cesiumEngine.js
- index c39a3a5..999472e 100644
- --- a/src/modules/cockpit/services/cesiumEngine.js
- +++ b/src/modules/cockpit/services/cesiumEngine.js
- @@ -1452,6 +1452,21 @@ function overlapTargetAt(viewer, windowX, windowY) {
- return null
- }
-
- +/** 仅穿过本管线图层;其它场景对象仍按 Cesium 的前后顺序遮挡。 */
- +function pickThroughPipelines(viewer, position) {
- + const scene = viewer.scene
- + const picked = scene.pick(position)
- + const source = pipelineSource(viewer)
- + const isPipeline = (hit) => {
- + const id = hit && hit.id
- + return Boolean(id && (id.kind === 'pipe-model-batch' || (source && source.entities.contains(id))))
- + }
- + if (!isPipeline(picked)) return picked
- + // 普通拾取不受影响;只有最上层是管线时才执行多层拾取。
- + if (typeof scene.drillPick !== 'function') return null
- + return scene.drillPick(position).find((hit) => !isPipeline(hit)) || null
- +}
- +
- export function pickDeviceMarkerAt(viewer, windowX, windowY) {
- if (!viewer || !viewer.scene || !viewer.canvas || typeof viewer.scene.pick !== 'function') return null
-
- @@ -1461,7 +1476,7 @@ export function pickDeviceMarkerAt(viewer, windowX, windowY) {
- if (projectedHit) return projectedHit
-
- const rect = viewer.canvas.getBoundingClientRect()
- - const picked = viewer.scene.pick(new Cartesian2(windowX - rect.left, windowY - rect.top))
- + const picked = pickThroughPipelines(viewer, new Cartesian2(windowX - rect.left, windowY - rect.top))
- const entity = picked && picked.id
- const properties = entity && entity.properties
- if (properties) {
- @@ -2099,7 +2114,7 @@ export function pickPointMarkerAt(viewer, windowX, windowY) {
- if (!viewer || !viewer.scene || !viewer.canvas || typeof viewer.scene.pick !== 'function') return null
-
- const rect = viewer.canvas.getBoundingClientRect()
- - const picked = viewer.scene.pick(new Cartesian2(windowX - rect.left, windowY - rect.top))
- + const picked = pickThroughPipelines(viewer, new Cartesian2(windowX - rect.left, windowY - rect.top))
- const entity = picked && picked.id
- const properties = entity && entity.properties
- if (!properties || !properties.pointCode) return null
- diff --git a/.scratch/cockpit-shell-panel-layout/verify/t41-point-locate-anchor.mjs b/.scratch/cockpit-shell-panel-layout/verify/t41-point-locate-anchor.mjs
- index 78048e4..5263204 100644
- --- a/.scratch/cockpit-shell-panel-layout/verify/t41-point-locate-anchor.mjs
- +++ b/.scratch/cockpit-shell-panel-layout/verify/t41-point-locate-anchor.mjs
- @@ -248,7 +248,7 @@ const CANVAS = { left: 0, top: 0, right: 1600, bottom: 900 }
-
- // 验收第 6 条:禁止读取 Cesium 私有实体。
- const engine = read('services/cesiumEngine.js')
- - const privateRead = /\._entity|\._billboard|\._position|drillPick|\._id\b|\._show\b/.test(engine)
- + const privateRead = /\._entity|\._billboard|\._position|\._id\b|\._show\b/.test(engine)
- check('E4-no-private-cesium-members', !privateRead, '不读 Cesium 私有成员(只用公开实体/属性与公开拾取)')
-
- // 锚点的高度回退:**瓦片未加载时按椭球面**,不能因为"配了地形却取不到高度"就判标记离屏。
- diff --git a/.scratch/cockpit-shell-panel-layout/verify/t45-selection-continuity.mjs b/.scratch/cockpit-shell-panel-layout/verify/t45-selection-continuity.mjs
- index 7321ddc..4bb8828 100644
- --- a/.scratch/cockpit-shell-panel-layout/verify/t45-selection-continuity.mjs
- +++ b/.scratch/cockpit-shell-panel-layout/verify/t45-selection-continuity.mjs
- @@ -49,11 +49,12 @@ check('aggregate symbol carries readable quantity and separate identity', () =>
- })
- check('monitoring point creates a visible name label', () => {
- const created = []
- - const pctx=vm.createContext({pointMarkerSource:()=>({entities:{removeAll(){},add(e){created.push(e)}}}),Cartesian3:{fromDegrees(){}},Cartesian2:class{},HeightReference:{},VerticalOrigin:{},Color:{WHITE:{},BLACK:{withAlpha:(alpha)=>({alpha})}},LabelStyle:{},viewer:{}})
- + const pctx=vm.createContext({pointMarkerSource:()=>({entities:{removeAll(){},add(e){created.push(e);return e}}}),markerEntityIndex:new WeakMap(),Cartesian3:{fromDegrees(){}},Cartesian2:class{},HeightReference:{},VerticalOrigin:{},Color:{WHITE:{},BLACK:{withAlpha:(alpha)=>({alpha})}},LabelStyle:{},viewer:{}})
- pctx.MAP_LABEL_STYLE = MAP_LABEL_STYLE
- pctx.mapLabelText = mapLabelText
- pctx.Color.fromCssColorString = () => ({ withAlpha: (alpha) => ({ alpha }) })
- vm.runInContext(extract(engine,'mapTextLabel'),pctx)
- + vm.runInContext(extract(engine,'markerFingerprint'),pctx)
- vm.runInContext(extract(engine,'syncPointMarkers'),pctx)
- vm.runInContext("syncPointMarkers(viewer,[{key:'monitoring-point|P',code:'P',kind:'monitoring-point',name:'城南监测点',longitude:1,latitude:2}],()=>'color',()=>'image')",pctx)
- assert.equal(created[0].label?.text,'⟦ 城南监测点 ⟧')
- @@ -213,7 +214,7 @@ const pickContext = vm.createContext({
- Cartesian2: class { constructor(x, y) { this.x = x; this.y = y } },
- viewer: { scene: { pick: () => ({ id: pickedEntity }) }, canvas: { getBoundingClientRect: () => ({ left: 0, top: 0 }) } },
- })
- -for (const name of ['readOverlapTargets', 'overlapTargetAt', 'pickDeviceMarkerAt']) {
- +for (const name of ['readOverlapTargets', 'overlapTargetAt', 'pipelineSource', 'pickThroughPipelines', 'pickDeviceMarkerAt']) {
- vm.runInContext(extract(engine, name), pickContext)
- }
- check('projected selected-entry pick retains device and group identity', () => {
|