| 12345678910111213141516171819202122232425 |
- import assert from 'node:assert/strict'
- import { JulianDate } from 'cesium'
- import { syncPipeLayer, clearPipeLayer } from '../../../src/modules/cockpit/services/cesiumPipeLayer.js'
- const sources=[]
- const viewer={dataSources:{getByName:name=>sources.filter(s=>s.name===name),add:async s=>{sources.push(s);return s}}}
- const pipe=(code,industry,remark='')=>({code,industry,remark,diameter:400,positions:[[110.39,28.44],[110.3901,28.44]]})
- const network={pipes:[pipe('gas','GAS'),pipe('water','WATER_SUPPLY'),pipe('sewage','DRAINAGE','污水'),pipe('rain','DRAINAGE','雨水')],components:[{code:'well',industry:'MANHOLE',kind:'other',position:[110.39,28.44],label:''}]}
- await syncPipeLayer(viewer,network)
- const t=JulianDate.now(),entities=sources[0].entities
- const color=id=>entities.getById(id).polyline.material.color.getValue(t)
- assert.ok(color('pipe:gas').red>color('pipe:gas').green*2,'gas visible guide must be red')
- assert.ok(color('pipe:water').blue>color('pipe:water').red*2)
- assert.ok(color('pipe:sewage').green>color('pipe:sewage').blue*1.5)
- assert.ok(color('pipe:rain').blue>.8&&color('pipe:rain').green>.8)
- const well=entities.getById('component:well')
- const wellColor=well.point.color.getValue(t)
- assert.ok(wellColor.blue>.8&&wellColor.red>.5&&wellColor.green<.6,'manhole is independent purple')
- assert.equal(well.label.text.getValue(t),'窨井')
- const rainBefore=entities.getById('pipe:rain').polyline
- network.pipes[3]={...network.pipes[3],remark:'污水'}
- await syncPipeLayer(viewer,network)
- assert.notStrictEqual(entities.getById('pipe:rain').polyline,rainBefore,'remark-only update must recolor')
- assert.ok(color('pipe:rain').green>color('pipe:rain').blue*1.5)
- await clearPipeLayer(viewer)
- console.log('PASS real Cesium source guide colors, special manhole symbol, and remark-only recolor')
|