| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import assert from 'node:assert/strict'
- import { test } from 'node:test'
- import { resolveFacilityPoint } from '../src/modules/cockpit/domain/facilitySelection.js'
- // 真实几何形状(2026-12-01 线上 /infrastructure/geometry 的 properties):
- // 业务编码在 `code`,sourceId/networkId 是内部主键(raw_* 形)。
- const PIPE = {
- code: 'TCRQ202609080001',
- sourceId: 'raw_P11920',
- networkId: 'raw_P11920',
- name: '太常片区燃气',
- industry: 'GAS',
- positions: [[110.3621848838, 28.4517546414], [110.3621946507, 28.4517581805]],
- }
- const networkOf = (pipes) => ({ pipes, components: [], blocked: [] })
- test('按管网业务编码聚焦:命中 pipe.code,落成可定位的一段', () => {
- const point = resolveFacilityPoint({
- identity: { kind: 'facility', id: 'TCRQ202609080001', category: 'PIPE_NETWORK' },
- network: networkOf([PIPE]),
- })
- assert.equal(point.placement, 'drawn')
- assert.equal(point.code, 'TCRQ202609080001')
- assert.equal(point.name, '太常片区燃气')
- assert.ok(Number.isFinite(point.longitude) && Number.isFinite(point.latitude))
- assert.match(point.locationHint, /中点/)
- })
- test('按内部主键定位的既有调用方不受影响', () => {
- const point = resolveFacilityPoint({
- identity: { kind: 'facility', id: 'raw_P11920', category: 'PIPE_NETWORK' },
- network: networkOf([PIPE]),
- })
- assert.equal(point.placement, 'drawn')
- })
- test('图层里没有这段管网时如实说没取到几何,不编坐标', () => {
- const point = resolveFacilityPoint({
- identity: { kind: 'facility', id: 'TCRQ209912319999', category: 'PIPE_NETWORK' },
- network: networkOf([PIPE]),
- })
- assert.equal(point.placement, 'pending')
- assert.equal(point.longitude, null)
- assert.match(point.reasonText, /几何|管段/)
- })
- test('同一编码命中多段时不乱挑一段', () => {
- const point = resolveFacilityPoint({
- identity: { kind: 'facility', id: 'TCRQ202609080001', category: 'PIPE_NETWORK' },
- network: networkOf([PIPE, { ...PIPE, sourceId: 'raw_P11921' }]),
- })
- assert.equal(point.placement, 'pending')
- })
|