diff --git a/src/modules/cockpit/domain/pipeNetwork.js b/src/modules/cockpit/domain/pipeNetwork.js --- a/src/modules/cockpit/domain/pipeNetwork.js +++ b/src/modules/cockpit/domain/pipeNetwork.js @@ -110,13 +110,16 @@ function diameterOf(value) { -/** 管段几何:两点 `[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 } *** Update File: src/modules/cockpit/services/cesiumEngine.js @@ function overlapTargetAt(viewer, windowX, windowY) { @@ } + +/** 仅穿过本管线图层;其它场景对象仍按 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 +} @@ - 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 picked = viewer.scene.pick(new Cartesian2(windowX - rect.left, windowY - rect.top)) + const picked = pickThroughPipelines(viewer, new Cartesian2(windowX - rect.left, windowY - rect.top)) *** Update File: .scratch/cockpit-shell-panel-layout/verify/t41-point-locate-anchor.mjs @@ - const privateRead = /\._entity|\._billboard|\._position|drillPick|\._id\b|\._show\b/.test(engine) + const privateRead = /\._entity|\._billboard|\._position|\._id\b|\._show\b/.test(engine) *** Update File: .scratch/cockpit-shell-panel-layout/verify/t45-selection-continuity.mjs @@ - 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:{}}) @@ vm.runInContext(extract(engine,'mapTextLabel'),pctx) + vm.runInContext(extract(engine,'markerFingerprint'),pctx) @@ -for (const name of ['readOverlapTargets', 'overlapTargetAt', 'pickDeviceMarkerAt']) { +for (const name of ['readOverlapTargets', 'overlapTargetAt', 'pipelineSource', 'pickThroughPipelines', 'pickDeviceMarkerAt']) { *** End Patch