gis-view-webgl2 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -8
- package/dist/gis-view.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +781 -246
- package/dist/index.js +1 -1
- package/docs/AI/345/257/271/350/257/235/346/261/207/346/200/273.md +129 -0
- package/docs/GisView.md +9 -8
- package/docs/GisView/345/256/236/347/216/260/345/216/237/347/220/206.md +2 -2
- package/docs/ai/06-/344/274/232/350/257/235/347/264/242/345/274/225/344/270/216/345/244/215/346/237/245/346/226/271/346/263/225.md +114 -0
- package/docs/api/index.html +545 -59
- package/docs/demos/BackendSyncDemo.vue +10 -8
- package/docs/demos/BasicDemo.vue +101 -101
- package/docs/demos/BatchAddDemo.vue +5 -5
- package/docs/demos/ChannelDemo.vue +51 -4
- package/docs/demos/ConnectDemo.vue +392 -0
- package/docs/demos/CopyMergeDemo.vue +936 -936
- package/docs/demos/DecorationDraftDemo.vue +1300 -0
- package/docs/demos/DemoShell.vue +569 -240
- package/docs/demos/DragDropDemo.vue +11 -11
- package/docs/demos/EffectsDemo.vue +6 -6
- package/docs/demos/EventDemo.vue +327 -327
- package/docs/demos/ExtensionDemo.vue +458 -0
- package/docs/demos/GisViewDemo.vue +61 -48
- package/docs/demos/GraphicDemo.vue +338 -0
- package/docs/demos/LabelDemo.vue +509 -509
- package/docs/demos/MinimapDemo.vue +358 -0
- package/docs/demos/PerfDemo.vue +29 -0
- package/docs/demos/SearchFilterDemo.vue +412 -0
- package/docs/demos/StyleDemo.vue +121 -121
- package/docs/demos/api-index.js +87 -76
- package/docs/demos/demos.js +159 -135
- package/docs/demos/shared/demoData.js +107 -107
- package/docs/demos/shared/demoStyle.css +249 -249
- package/docs/demos/shared/fakeBackend.js +93 -6
- package/docs/format/03-/346/213/220/347/202/271/350/243/205/351/245/260/344/270/216/346/240/267/345/274/217.md +24 -6
- package/docs/format/06-/345/257/274/345/205/245/345/257/274/345/207/272/344/270/216/346/240/207/345/207/206/346/226/207/346/241/243.md +8 -6
- package/docs/format/07-/344/272/213/344/273/266/350/275/275/350/215/267/344/270/216/347/244/272/344/276/213/346/225/260/346/215/256.md +6 -6
- package/docs/guide/sample-document.html +4 -4
- package/docs/index.html +180 -9
- package/docs/internals/11-/350/246/206/347/233/226/345/261/202/346/240/207/347/255/276/344/270/216/346/217/220/347/244/272.md +1 -1
- package/docs/internals/13-/351/271/260/347/234/274/345/233/276.md +3 -2
- package/docs/internals/15-03-/351/200/220/350/275/256/350/256/260/345/275/225-/346/200/247/350/203/275/344/270/216/344/277/256/345/244/215-/344/270/213.md +16 -0
- package/docs/internals/16-03-/344/274/230/345/214/226/344/270/216/345/217/226/350/210/215-/344/270/213.md +11 -0
- package/docs/internals/17-/350/260/203/350/257/225/344/270/216/346/211/251/345/261/225/345/273/272/350/256/256.md +1 -1
- package/docs/manual/02-/345/235/220/346/240/207/344/270/216/346/225/260/346/215/256.md +11 -2
- package/docs/manual/03-/351/205/215/347/275/256/351/241/271.md +89 -20
- package/docs/manual/04-/344/272/213/344/273/266/344/270/216/345/233/236/350/260/203.md +13 -8
- package/docs/manual/06-/346/225/260/346/215/256/344/270/216/345/234/272/346/231/257/346/233/264/346/226/260.md +11 -10
- package/docs/manual/07-/346/214/207/351/222/210/344/270/216/350/246/201/347/264/240/347/274/226/350/276/221.md +9 -9
- package/docs/manual/08-/351/200/211/344/270/255/344/270/216/346/213/220/347/202/271.md +13 -11
- package/docs/manual/09-/351/200/232/351/201/223/344/270/216/345/244/232/345/233/236/347/272/277.md +3 -3
- package/docs/manual/10-/351/200/232/351/201/223/347/274/226/350/276/221/344/270/216/346/226/260/345/242/236.md +47 -5
- package/docs/manual/11-/346/240/267/345/274/217/344/270/216/350/247/204/345/210/231.md +3 -2
- package/docs/manual/12-/346/240/207/347/255/276/344/270/216/350/243/205/351/245/260.md +215 -2
- package/docs/manual/13-/345/212/250/346/225/210/344/270/216/345/233/276/345/205/203.md +6 -5
- package/docs/manual/14-/350/247/206/345/233/276/344/270/216/347/255/233/351/200/211.md +27 -14
- package/docs/manual/15-/345/257/274/345/207/272/344/270/216/351/233/206/346/210/220.md +142 -49
- package/docs/manual/16-/345/256/236/344/276/213/346/226/271/346/263/225/346/200/273/350/241/250.md +25 -29
- package/docs/manual/17-/345/217/202/346/225/260/351/200/237/346/237/245.md +47 -39
- package/docs/manual/18-/351/200/220/346/226/271/346/263/225/347/244/272/344/276/213.md +161 -64
- package/docs/manual/19-/350/257/273/346/225/260/344/270/216/346/213/226/346/213/275/351/242/204/350/247/210.md +4 -4
- package/docs/manual/20-/346/200/247/350/203/275/344/270/216/345/244/247/346/225/260/346/215/256.md +39 -2
- package/docs/manual/21-/350/257/264/346/230/216/344/270/216/345/270/270/350/247/201/351/227/256/351/242/230.md +21 -5
- package/docs/playground/index.html +5 -5
- package/docs/steps/README.md +12 -10
- package/docs/steps/check-doc-truth.mjs +1 -1
- package/docs/steps/selftest-actions.html +10 -10
- package/docs/steps/selftest-data.html +96 -14
- package/docs/steps/selftest-decoration.html +577 -0
- package/docs/steps/selftest-demo.html +6 -5
- package/docs/steps/selftest-demos.html +2048 -1624
- package/docs/steps/selftest-docs.html +86 -14
- package/docs/steps/selftest-effects.html +5 -5
- package/docs/steps/selftest-features.html +544 -85
- package/docs/steps/selftest-full.html +583 -583
- package/docs/steps/selftest-labels.html +797 -660
- package/docs/steps/selftest-perf.html +1899 -1844
- package/docs/steps/selftest-scale.html +117 -7
- package/docs/steps/selftest-select.html +24 -17
- package/docs/steps/step-10-full.js +1 -1
- package/docs//346/216/245/345/217/243/345/215/217/350/256/256.md +151 -7
- package/docs//346/225/260/346/215/256/346/240/274/345/274/217.md +1 -1
- package/package.json +42 -42
- package/docs/demos/HistoryDemo.vue +0 -230
- package/docs/demos/InterfaceDemo.vue +0 -309
- package/docs/demos/SampleDemo.vue +0 -283
|
@@ -983,7 +983,7 @@
|
|
|
983
983
|
|
|
984
984
|
/* 快捷键:Ctrl+C / Ctrl+V 与默认框选键 */
|
|
985
985
|
cmEvents.length = 0
|
|
986
|
-
cmView.
|
|
986
|
+
cmView.selectFeatures('a')
|
|
987
987
|
cmView.el.dispatchEvent(new KeyboardEvent('keydown', { key: 'c', ctrlKey: true, bubbles: true }))
|
|
988
988
|
check('Ctrl+C 把选中的节点收进剪贴板(默认快捷键)', cmView.getPointClipboard()?.item.id === 'a', cmView.getPointClipboard()?.item.id)
|
|
989
989
|
check('Ctrl+C 命中 onPointCopy 的 clipboard 载荷(copy + keyboard + shortcuts 三件套)', cmShortcutClipboard?.phase === 'clipboard' && cmShortcutClipboard?.via === 'shortcut' && cmShortcutClipboard?.count === 1 && cmShortcutClipboard?.item?.id === 'a', JSON.stringify({ phase: cmShortcutClipboard?.phase, via: cmShortcutClipboard?.via, count: cmShortcutClipboard?.count, item: cmShortcutClipboard?.item?.id }))
|
|
@@ -998,13 +998,13 @@
|
|
|
998
998
|
cmView.fitView()
|
|
999
999
|
await settle(30)
|
|
1000
1000
|
const cmAnchor = cmView.project(0, 0)
|
|
1001
|
-
cmView.
|
|
1001
|
+
cmView.selectFeatures(null)
|
|
1002
1002
|
await cmDrag(cmView, [cmAnchor[0] - 26, cmAnchor[1] - 26], [cmAnchor[0] + 26, cmAnchor[1] + 26], { ctrlKey: true })
|
|
1003
1003
|
check('默认框选键是 Shift 时 Ctrl 拖动不再框选', cmView.getSelections().length === 0, `选中 ${cmView.getSelections().length}`)
|
|
1004
1004
|
cmView.fitView()
|
|
1005
1005
|
await settle(30)
|
|
1006
1006
|
const cmAnchor2 = cmView.project(0, 0)
|
|
1007
|
-
cmView.
|
|
1007
|
+
cmView.selectFeatures(null)
|
|
1008
1008
|
await cmDrag(cmView, [cmAnchor2[0] - 26, cmAnchor2[1] - 26], [cmAnchor2[0] + 26, cmAnchor2[1] + 26], { shiftKey: true })
|
|
1009
1009
|
check('按住新的框选键(Shift)拖动出选框并选中节点', cmView.getSelections().length >= 1 && cmView.getSelections().some(item => item.item.id === 'a'), `选中 ${cmView.getSelections().map(item => item.item.id).join(',')}`)
|
|
1010
1010
|
cmView.updateOptions({ shortcuts: { boxSelect: 'ctrl' } })
|
|
@@ -1249,6 +1249,47 @@
|
|
|
1249
1249
|
check('mergePoints 找不到节点:ok: false + 一条失败事件', cmFail.ok === false && cmMergeEvents5[cmMergeEvents5.length - 1].phase === 'merge' && cmMergeEvents5[cmMergeEvents5.length - 1].ok === false && cmView5.getPointMerge() === null, JSON.stringify(cmFail).slice(0, 160))
|
|
1250
1250
|
cmView5.destroy()
|
|
1251
1251
|
cmHost5.remove()
|
|
1252
|
+
|
|
1253
|
+
/* 合并触发时机:碰撞(两个半径相碰)/ 中心点进入目标节点区域 */
|
|
1254
|
+
const triggerHost = document.createElement('div')
|
|
1255
|
+
triggerHost.style.cssText = 'width:520px;height:300px'
|
|
1256
|
+
document.body.appendChild(triggerHost)
|
|
1257
|
+
const triggerEvents = []
|
|
1258
|
+
const triggerView = createGisView(triggerHost, {
|
|
1259
|
+
points: [{ id: 'source', x: 0, y: 0, size: 12 }, { id: 'target', x: 140, y: 0, size: 12 }],
|
|
1260
|
+
fitPadding: 70,
|
|
1261
|
+
showGrid: false,
|
|
1262
|
+
merge: { trigger: 'center', confirm: false },
|
|
1263
|
+
draggable: true,
|
|
1264
|
+
onPointMerge: payload => triggerEvents.push(payload)
|
|
1265
|
+
})
|
|
1266
|
+
await settle(120)
|
|
1267
|
+
const triggerTarget = triggerView.project(140, 0)
|
|
1268
|
+
await cmDrag(triggerView, triggerView.project(0, 0), [triggerTarget[0] - 10, triggerTarget[1]])
|
|
1269
|
+
check('merge.trigger=center:中心还差 10px 没进入目标区域时不触发(同样距离下碰撞档会触发)', triggerEvents.length === 0 && triggerView.getData().points.length === 2, JSON.stringify({ events: triggerEvents.map(item => item.phase), points: triggerView.getData().points.map(item => item.id) }))
|
|
1270
|
+
const triggerSource = triggerView.getData().points.find(point => point.id === 'source')
|
|
1271
|
+
await cmDrag(triggerView, triggerView.project(triggerSource.x, triggerSource.y), triggerTarget)
|
|
1272
|
+
check('merge.trigger=center:中心进入目标区域后触发,载荷带 trigger=center', triggerView.getData().points.length === 1 && triggerView.getData().points[0].id === 'target' && triggerEvents[0]?.trigger === 'center', JSON.stringify({ points: triggerView.getData().points.map(item => item.id), trigger: triggerEvents[0]?.trigger }))
|
|
1273
|
+
triggerView.destroy()
|
|
1274
|
+
triggerHost.remove()
|
|
1275
|
+
|
|
1276
|
+
const collisionHost = document.createElement('div')
|
|
1277
|
+
collisionHost.style.cssText = 'width:520px;height:300px'
|
|
1278
|
+
document.body.appendChild(collisionHost)
|
|
1279
|
+
const collisionView = createGisView(collisionHost, {
|
|
1280
|
+
points: [{ id: 'source', x: 0, y: 0, size: 12 }, { id: 'target', x: 140, y: 0, size: 12 }],
|
|
1281
|
+
fitPadding: 70,
|
|
1282
|
+
showGrid: false,
|
|
1283
|
+
merge: { trigger: 'collision', confirm: false },
|
|
1284
|
+
draggable: true
|
|
1285
|
+
})
|
|
1286
|
+
await settle(120)
|
|
1287
|
+
const collisionTarget = collisionView.project(140, 0)
|
|
1288
|
+
await cmDrag(collisionView, collisionView.project(0, 0), [collisionTarget[0] - 10, collisionTarget[1]])
|
|
1289
|
+
check('merge.trigger=collision:中心还差 10px 时两个节点半径已经相碰,照旧触发', collisionView.getData().points.length === 1 && collisionView.getData().points[0].id === 'target', JSON.stringify(collisionView.getData().points.map(item => item.id)))
|
|
1290
|
+
collisionView.destroy()
|
|
1291
|
+
collisionHost.remove()
|
|
1292
|
+
|
|
1252
1293
|
/* 合并 ④:框选 / 多选之后按接口一次并完(mergeSelectedPoints) */
|
|
1253
1294
|
const msHost = document.createElement('div')
|
|
1254
1295
|
msHost.style.cssText = 'width:560px;height:360px'
|
|
@@ -1288,7 +1329,7 @@
|
|
|
1288
1329
|
})
|
|
1289
1330
|
await settle(140)
|
|
1290
1331
|
const msIds = () => msView.getData().points.map(point => point.id ?? '(无id)').join(',')
|
|
1291
|
-
msView.
|
|
1332
|
+
msView.selectFeatures(['h', 'a', 'b', 'c'])
|
|
1292
1333
|
await settle(30)
|
|
1293
1334
|
const msBulk = msView.mergeSelectedPoints()
|
|
1294
1335
|
check('框选 / 多选之后一步并完:自动挑「绑定线路最多」的节点当目标', msBulk.ok === true && msBulk.phase === 'mergeSelected' && msBulk.target.item.id === 'h' && msBulk.sourcesMerged === 3 && msBulk.skipped.length === 0, JSON.stringify({ target: msBulk.target?.item?.id, merged: msBulk.sourcesMerged, skipped: msBulk.skipped }))
|
|
@@ -1304,7 +1345,7 @@
|
|
|
1304
1345
|
/* 相机移动不该收掉待确认的合并(小图拖动 / moveCenter 走的是同一条路) */
|
|
1305
1346
|
msView.fitView()
|
|
1306
1347
|
await settle(60)
|
|
1307
|
-
msView.
|
|
1348
|
+
msView.selectFeatures(null)
|
|
1308
1349
|
await cmDrag(msView, msView.project(100, 0), msView.project(0, 0))
|
|
1309
1350
|
const msPend = msView.getPointMerge()
|
|
1310
1351
|
check('把节点拖到目标上:进入待确认(读得到 pending 载荷)', msPend !== null && msPend.phase === 'state' && msPend.confirmed === false, JSON.stringify(msPend?.phase))
|
|
@@ -1319,16 +1360,16 @@
|
|
|
1319
1360
|
const msWrapped = msView.batch(() => msView.mergeSelectedPoints({ target: 'h', sources: ['b', 'c'] }), { label: '批量合并' })
|
|
1320
1361
|
const msWrappedUndo = msView.undo()
|
|
1321
1362
|
check('batch 里调 mergeSelectedPoints:整批只占一步历史(撤销一次全回去)', msWrapped?.ok === true && msWrapped.sourcesMerged === 2 && msWrappedUndo?.label === '批量合并' && msIds() === 'h,a,b,c,lock,(无id)', JSON.stringify({ merged: msWrapped?.sourcesMerged, label: msWrappedUndo?.label }))
|
|
1322
|
-
msView.
|
|
1363
|
+
msView.selectFeatures(null)
|
|
1323
1364
|
const msEmpty = msView.mergeSelectedPoints()
|
|
1324
1365
|
check('没选中节点:ok: false 并带回原因', msEmpty.ok === false && msEmpty.phase === 'mergeSelected' && msEmpty.reason === '没有选中的节点' && msEmpty.target === null, msEmpty.reason)
|
|
1325
|
-
msView.
|
|
1366
|
+
msView.selectFeatures('h')
|
|
1326
1367
|
const msOne = msView.mergeSelectedPoints()
|
|
1327
1368
|
check('只选中一个节点:自动挑目标时要两个以上', msOne.ok === false && msOne.reason === '选中的节点不足两个', msOne.reason)
|
|
1328
|
-
msView.
|
|
1369
|
+
msView.selectFeatures(['h', 'lock'])
|
|
1329
1370
|
const msAllLocked = msView.mergeSelectedPoints()
|
|
1330
1371
|
check('选中里只剩 mergeable: false 的节点:一个都并不了', msAllLocked.ok === false && msAllLocked.reason === '可以合并的节点不足两个', msAllLocked.reason)
|
|
1331
|
-
msView.
|
|
1372
|
+
msView.selectFeatures(['h', 'a', 'lock'])
|
|
1332
1373
|
const msSelective = msView.mergeSelectedPoints()
|
|
1333
1374
|
check('多选里混着 mergeable: false:跳过它、其余照并(skipped 说明原因)', msSelective.ok === true && msSelective.sourcesMerged === 1 && msSelective.merged[0].source.item.id === 'a' && msSelective.skipped.length === 1 && msSelective.skipped[0].id === 'lock' && msSelective.skipped[0].reason === '标记了 mergeable: false', JSON.stringify({ merged: msSelective.sourcesMerged, skipped: msSelective.skipped }))
|
|
1334
1375
|
check('只有一个来源时走普通的一次合并(数据变更不是 batch)', msChanges[msChanges.length - 1].type === 'mergePoints', msChanges[msChanges.length - 1].type)
|
|
@@ -1401,14 +1442,14 @@
|
|
|
1401
1442
|
const cmCenter = cmLayerView.project(0, 0)
|
|
1402
1443
|
const cmOverPixel = await cmPixelAt(cmLayerView, cmCenter)
|
|
1403
1444
|
check('没选中时上层节点压在下面那个之上(按数据顺序画)', cmIsBlue(cmOverPixel), JSON.stringify(cmOverPixel))
|
|
1404
|
-
cmLayerView.
|
|
1445
|
+
cmLayerView.selectFeatures('under')
|
|
1405
1446
|
await settle(60)
|
|
1406
1447
|
const cmRaisedPixel = await cmPixelAt(cmLayerView, cmCenter)
|
|
1407
1448
|
check('选中的节点抬到最上层(与 zIndex / 数据顺序无关)', cmIsRed(cmRaisedPixel), JSON.stringify(cmRaisedPixel))
|
|
1408
|
-
cmLayerView.
|
|
1449
|
+
cmLayerView.selectFeatures(null)
|
|
1409
1450
|
cmLayerView.updateOptions({ selectionOnTop: false })
|
|
1410
1451
|
await settle(60)
|
|
1411
|
-
cmLayerView.
|
|
1452
|
+
cmLayerView.selectFeatures('under')
|
|
1412
1453
|
await settle(60)
|
|
1413
1454
|
const cmFlatPixel = await cmPixelAt(cmLayerView, cmCenter)
|
|
1414
1455
|
check('selectionOnTop: false 时不抬层(仍然按数据顺序画)', cmIsBlue(cmFlatPixel), JSON.stringify(cmFlatPixel))
|
|
@@ -1464,11 +1505,11 @@
|
|
|
1464
1505
|
const cmLineSpot = cmRaiseLineView.project(0, 0.6)
|
|
1465
1506
|
const cmLineStillPixel = await cmPixelAt(cmRaiseLineView, cmLineSpot)
|
|
1466
1507
|
check('两条线重叠处:后画的那条压在上面', cmIsBlue(cmLineStillPixel), JSON.stringify(cmLineStillPixel))
|
|
1467
|
-
cmRaiseLineView.
|
|
1508
|
+
cmRaiseLineView.selectFeatures('line-low')
|
|
1468
1509
|
await settle(90)
|
|
1469
1510
|
const cmLineRaisePixel = await cmPixelAt(cmRaiseLineView, cmLineSpot)
|
|
1470
1511
|
check('选中线路:抬到最上层(与数据顺序无关)', cmIsRed(cmLineRaisePixel), JSON.stringify(cmLineRaisePixel))
|
|
1471
|
-
cmRaiseLineView.
|
|
1512
|
+
cmRaiseLineView.selectFeatures(null)
|
|
1472
1513
|
await settle(90)
|
|
1473
1514
|
const cmLineBackPixel = await cmPixelAt(cmRaiseLineView, cmLineSpot)
|
|
1474
1515
|
check('取消选中:线路恢复原来的次序', cmIsBlue(cmLineBackPixel), JSON.stringify(cmLineBackPixel))
|
|
@@ -1504,7 +1545,7 @@
|
|
|
1504
1545
|
cmChannelStillPixels.push(await cmPixelAt(cmRaiseChannelView, spot))
|
|
1505
1546
|
}
|
|
1506
1547
|
check('通道回线与另一条线交叉处:后画的普通线压在上面', cmChannelStillPixels.every(cmIsBlue), JSON.stringify(cmChannelStillPixels))
|
|
1507
|
-
cmRaiseChannelView.
|
|
1548
|
+
cmRaiseChannelView.selectFeatures('ch-c1')
|
|
1508
1549
|
await settle(120)
|
|
1509
1550
|
const cmChannelRaisePixels = []
|
|
1510
1551
|
for (const spot of cmChannelSpots) {
|
|
@@ -1747,7 +1788,7 @@
|
|
|
1747
1788
|
// ② 整份换成新对象(等价于撤销 / 重新拉一份数据):收掉并补一条 cancel,载荷带 invalidated
|
|
1748
1789
|
const pendSourceBefore = pendView.getData().points.find(point => point.id === 'a')
|
|
1749
1790
|
const pendSourceX = pendSourceBefore.x
|
|
1750
|
-
pendView.
|
|
1791
|
+
pendView.updateData({ points: pendView.getData().points.map(point => ({ ...point })) })
|
|
1751
1792
|
await settle(80)
|
|
1752
1793
|
const pendCancel = pendMergeEvents[pendMergeEvents.length - 1]
|
|
1753
1794
|
const pendSourceAfter = pendView.getData().points.find(point => point.id === 'a')
|
|
@@ -1859,11 +1900,11 @@
|
|
|
1859
1900
|
check('updateOptions 发 onDataChange(changed 标出改的是哪一类)', evLog.data.length === 1 && evLog.data[0].type === 'updateOptions' && evLog.data[0].changed.points === false && evLog.data[0].changed.channels === true, evTypes())
|
|
1860
1901
|
|
|
1861
1902
|
evLog.select.length = 0
|
|
1862
|
-
evView.
|
|
1903
|
+
evView.selectFeatures('a')
|
|
1863
1904
|
check('接口选中发 onSelectChange(cause 为 api)', evLog.select.length === 1 && evLog.select[0].cause === 'api' && evLog.select[0].count === 1 && evLog.select[0].ids[0] === 'a' && evLog.select[0].points === 1, JSON.stringify(evLog.select.map(entry => `${entry.cause}:${entry.count}`)))
|
|
1864
|
-
evView.
|
|
1905
|
+
evView.selectFeatures('a')
|
|
1865
1906
|
check('选中集没变就不再发 onSelectChange', evLog.select.length === 1, `次数 ${evLog.select.length}`)
|
|
1866
|
-
evView.
|
|
1907
|
+
evView.selectFeatures(null)
|
|
1867
1908
|
check('清空选中也发一条(count: 0 / cause: api)', evLog.select.length === 2 && evLog.select[1].count === 0 && evLog.select[1].cause === 'api', JSON.stringify(evLog.select.map(entry => entry.count)))
|
|
1868
1909
|
|
|
1869
1910
|
evLog.shortcut.length = 0
|
|
@@ -1937,7 +1978,7 @@
|
|
|
1937
1978
|
check('onChannelGroupChange 回调和事件总线收到同一份载荷', cgOption.length === 1 && cgOption[0] === cgBus[0])
|
|
1938
1979
|
|
|
1939
1980
|
// 选中一条回线再合并:选中镜像里的 groupId / groupIndex 要跟着真值走(本轮修复的回归守卫)
|
|
1940
|
-
cgView.
|
|
1981
|
+
cgView.selectFeatures('c2')
|
|
1941
1982
|
await settle(60)
|
|
1942
1983
|
const cgTruth = () => {
|
|
1943
1984
|
const groups = cgView.getChannelGroups('ch-1')
|
|
@@ -2005,8 +2046,8 @@
|
|
|
2005
2046
|
ulHost.remove()
|
|
2006
2047
|
/* 这一轮新增:通道改名 / 通道下增减回线 / 删除分组(问题.txt 第 2 条那几个「方法有吗」) */
|
|
2007
2048
|
const cgNameBefore = cgData.length
|
|
2008
|
-
cgView.
|
|
2009
|
-
check('
|
|
2049
|
+
cgView.updateChannel('ch-1', { name: '甲通道' })
|
|
2050
|
+
check('updateChannel({ name }) 改通道名称:数据副本落地 + 一条 updateChannel 变更', cgView.getOptions().channels[0].name === '甲通道' && cgData.length === cgNameBefore + 1 && cgData[cgData.length - 1].type === 'updateChannel', JSON.stringify({ name: cgView.getOptions().channels[0].name, type: cgData[cgData.length - 1]?.type }))
|
|
2010
2051
|
|
|
2011
2052
|
cgView.addLine({ id: 'c3', from: 'ca', to: 'cb', color: '#8a5cf6' })
|
|
2012
2053
|
const cgMemberCount = () => cgView.getChannels().reduce((total, state) => total + state.lineIndexes.length, 0)
|
|
@@ -2143,7 +2184,7 @@
|
|
|
2143
2184
|
ucView.destroy()
|
|
2144
2185
|
ucHost.remove()
|
|
2145
2186
|
|
|
2146
|
-
/* 这一轮新增:改 lineIds 增删线路(有 groups 也生效)+
|
|
2187
|
+
/* 这一轮新增:改 lineIds 增删线路(有 groups 也生效)+ updateData({ channels }) 写回分组 id + 声明校验 warning */
|
|
2147
2188
|
const chHost = document.createElement('div')
|
|
2148
2189
|
chHost.style.cssText = 'width:420px;height:280px'
|
|
2149
2190
|
document.body.appendChild(chHost)
|
|
@@ -2164,6 +2205,10 @@
|
|
|
2164
2205
|
await settle(150)
|
|
2165
2206
|
const chGroups = () => chView.getChannelGroups('chA').map(group => ({ id: group.id, lineIds: group.lineIds }))
|
|
2166
2207
|
const chMemberCount = () => chView.getChannels().reduce((total, state) => total + state.lineIndexes.length, 0)
|
|
2208
|
+
const chInView = chView.getChannelsInView()
|
|
2209
|
+
check('getChannelsInView 按视口单遍归并通道,回线与分组 id 都去重',
|
|
2210
|
+
chInView.length === 1 && chInView[0].channelId === 'chA' && chInView[0].lineIndexes.length === 2 && chInView[0].groupIds.length === 1,
|
|
2211
|
+
JSON.stringify(chInView))
|
|
2167
2212
|
|
|
2168
2213
|
chView.updateChannel('chA', { groups: [{ id: 'ga', lineIds: ['k1'] }, { id: 'gb', lineIds: ['k2'] }] })
|
|
2169
2214
|
await settle(60)
|
|
@@ -2191,16 +2236,16 @@
|
|
|
2191
2236
|
check('updateChannel 找不到通道 / 没给补丁各报一句 warning,不静默空操作', chWarn.length === 2, JSON.stringify(chWarn))
|
|
2192
2237
|
|
|
2193
2238
|
chWarn.length = 0
|
|
2194
|
-
chView.
|
|
2239
|
+
chView.updateData({ channels: [{ id: 'chA', name: 'A 通道', groups: [{ lineIds: ['k3'] }, { lineIds: ['nope2'] }] }] })
|
|
2195
2240
|
await settle(60)
|
|
2196
2241
|
const chDeclared = chView.getOptions().channels[0].groups ?? []
|
|
2197
|
-
check('
|
|
2198
|
-
check('
|
|
2242
|
+
check('updateData({ channels }) 把引擎补好的分组 id / 拐点路径写回声明(缺省 id 不再留在数据里)', chDeclared.length === 1 && typeof chDeclared[0].id === 'string' && chDeclared[0].id.length > 0 && Array.isArray(chDeclared[0].path) && JSON.stringify(chDeclared[0].lineIds) === JSON.stringify(['k3']), JSON.stringify(chDeclared))
|
|
2243
|
+
check('updateData({ channels }) 里认不出的成员也报一句 warning', chWarn.length === 1 && String(chWarn[0]).includes('nope2'), JSON.stringify(chWarn))
|
|
2199
2244
|
/* 这一轮新增:整份提交的几个入口也走同一份调和(lineIds 是成员整表),写回时成员表对齐到分组 */
|
|
2200
|
-
chView.
|
|
2245
|
+
chView.updateData({ channels: [{ id: 'chA', lineIds: ['k1', 'k2'], groups: [{ id: 'ga', lineIds: ['k1'] }, { id: 'gb', lineIds: ['k2'] }, { id: 'gc', lineIds: ['k9'] }] }] })
|
|
2201
2246
|
await settle()
|
|
2202
2247
|
const chWhole = chGroups()
|
|
2203
|
-
check('
|
|
2248
|
+
check('updateData({ channels }) 整份提交也调和:声明里 lineIds 与 groups 冲突时按 lineIds 收窄(多出的组丢掉)', JSON.stringify(chWhole.map(group => group.lineIds)) === JSON.stringify([['k1'], ['k2']]) && chMemberCount() === 2, JSON.stringify({ groups: chWhole, members: chMemberCount() }))
|
|
2204
2249
|
|
|
2205
2250
|
chView.updateOptions({ channels: [{ id: 'chA', lineIds: ['k9'] }] })
|
|
2206
2251
|
await settle()
|
|
@@ -2214,18 +2259,18 @@
|
|
|
2214
2259
|
await settle()
|
|
2215
2260
|
check('importData({ channels }) 导入的声明同样过调和(applied.channels 为真)', chImported.ok === true && chImported.applied.channels === true && chMemberCount() === 2, JSON.stringify({ ok: chImported.ok, applied: chImported.applied, members: chMemberCount() }))
|
|
2216
2261
|
|
|
2217
|
-
chView.
|
|
2262
|
+
chView.updateData({ channels: [{ id: 'chA', groups: [{ id: 'ga', lineIds: ['k1'] }, { id: 'gb', lineIds: ['k9'] }] }] })
|
|
2218
2263
|
await settle()
|
|
2219
2264
|
const chOnlyGroups = chView.getOptions().channels[0]
|
|
2220
2265
|
check('只写 groups 的声明原样保留(不补 lineIds,成员由 groups 决定)', chOnlyGroups.lineIds === undefined && chMemberCount() === 2 && chGroups().length === 2, JSON.stringify({ lineIds: chOnlyGroups.lineIds, members: chMemberCount(), groups: chGroups() }))
|
|
2221
2266
|
|
|
2222
|
-
chView.
|
|
2267
|
+
chView.updateData({ channels: [{ id: 'chA', lineIds: ['k1'], groups: [{ id: 'ga', lineIds: ['k1'] }] }] })
|
|
2223
2268
|
await settle()
|
|
2224
2269
|
chView.updateChannel('chA', { groups: [{ id: 'ga', lineIds: ['k1'] }, { id: 'gb', lineIds: ['k9'] }] })
|
|
2225
2270
|
await settle()
|
|
2226
2271
|
check('写回时成员表跟着分组对齐:挪进分组的回线补进 lineIds(下一轮整份提交不会被收窄剔掉)', chMemberCount() === 2 && JSON.stringify(chView.getOptions().channels[0].lineIds) === JSON.stringify(['k1', 'k9']), JSON.stringify(chView.getOptions().channels[0]))
|
|
2227
2272
|
|
|
2228
|
-
chView.
|
|
2273
|
+
chView.updateData({ channels: [JSON.parse(JSON.stringify(chView.getOptions().channels[0]))] })
|
|
2229
2274
|
await settle()
|
|
2230
2275
|
check('拆分 / 挪组之后把声明原样整份重提交:成员与分组一个都不丢', chMemberCount() === 2 && chGroups().length === 2, JSON.stringify({ groups: chGroups(), members: chMemberCount() }))
|
|
2231
2276
|
|
|
@@ -2471,8 +2516,8 @@
|
|
|
2471
2516
|
mvView.undo()
|
|
2472
2517
|
check('位置对账:撤销回到基线之后不再算「位置变过」', mvView.getMovedPoints().length === 0, JSON.stringify(mvView.getMovedPoints().map(item => item.id)))
|
|
2473
2518
|
mvView.updatePoint('mc', { x: 900, y: 0 })
|
|
2474
|
-
mvView.
|
|
2475
|
-
check('位置对账:整份换节点数据(
|
|
2519
|
+
mvView.updateData({ points: mvView.getData().points })
|
|
2520
|
+
check('位置对账:整份换节点数据(updateData({ points }))按新数据对齐', mvView.getMovedPoints().length === 0, JSON.stringify(mvView.getMovedPoints().map(item => item.id)))
|
|
2476
2521
|
mvView.addPoints({ id: 'me', x: 600, y: 0 })
|
|
2477
2522
|
const mvAfterAdd = mvView.getMovedPoints().length
|
|
2478
2523
|
mvView.updatePoint('me', { x: 620, y: 20 })
|
|
@@ -2580,6 +2625,42 @@
|
|
|
2580
2625
|
ftView.destroy()
|
|
2581
2626
|
ftHost.remove()
|
|
2582
2627
|
|
|
2628
|
+
// 拐点只有一道总闸:waypoint / waypointEditable 关闭时新增、移动与删除一起停
|
|
2629
|
+
const waHost = document.createElement('div')
|
|
2630
|
+
waHost.style.cssText = 'width:320px;height:200px'
|
|
2631
|
+
document.body.appendChild(waHost)
|
|
2632
|
+
const waLog = []
|
|
2633
|
+
const waView = createGisView(waHost, {
|
|
2634
|
+
points: [{ id: 'a', x: 0, y: 0 }, { id: 'b', x: 100, y: 0 }],
|
|
2635
|
+
lines: [{ id: 'wa-line', from: 'a', to: 'b' }],
|
|
2636
|
+
showGrid: false,
|
|
2637
|
+
features: { waypoint: false },
|
|
2638
|
+
onWaypointChange: payload => waLog.push(payload)
|
|
2639
|
+
})
|
|
2640
|
+
await settle(120)
|
|
2641
|
+
const waState = waView.getFeatures()
|
|
2642
|
+
waView.addWaypoint('wa-line', [50, 10])
|
|
2643
|
+
await settle(60)
|
|
2644
|
+
check('waypoint:false 总闸关闭新增、且不再有 waypointAdd 细分开关',
|
|
2645
|
+
waState.waypoint === false && !Object.prototype.hasOwnProperty.call(waState, 'waypointAdd') && (waView.getData().lines[0].path ?? null) === null && waLog.length === 0,
|
|
2646
|
+
JSON.stringify({ waypoint: waState.waypoint, keys: Object.keys(waState), path: waView.getData().lines[0].path, events: waLog.length }))
|
|
2647
|
+
waView.setFeatures({ waypoint: true })
|
|
2648
|
+
await settle(60)
|
|
2649
|
+
waView.addWaypoint('wa-line', [50, 10])
|
|
2650
|
+
await settle(60)
|
|
2651
|
+
const waPath = waView.getData().lines[0].path
|
|
2652
|
+
check('打开 waypoint 之后 addWaypoint 正常插入并发 add',
|
|
2653
|
+
waView.getFeatures().waypoint === true && waPath?.length === 3 && waLog.length === 1 && waLog[0].phase === 'add',
|
|
2654
|
+
JSON.stringify({ waypoint: waView.getFeatures().waypoint, path: waPath, events: waLog.map(item => item.phase) }))
|
|
2655
|
+
waView.setFeatures({ waypoint: false })
|
|
2656
|
+
const waRemoved = waView.removeWaypoint('wa-line', 1)
|
|
2657
|
+
await settle(60)
|
|
2658
|
+
check('waypoint:false 同时关闭已有拐点的删除(接口空操作、数据不动)',
|
|
2659
|
+
waRemoved === waView && waView.getData().lines[0].path?.length === 3 && waLog.length === 1,
|
|
2660
|
+
JSON.stringify({ removed: waRemoved, path: waView.getData().lines[0].path, events: waLog.length }))
|
|
2661
|
+
waView.destroy()
|
|
2662
|
+
waHost.remove()
|
|
2663
|
+
|
|
2583
2664
|
// 缺省不记历史:一个开关都不开时与从前完全一样
|
|
2584
2665
|
const nhHost = document.createElement('div')
|
|
2585
2666
|
nhHost.style.cssText = 'width:320px;height:200px'
|
|
@@ -2600,7 +2681,7 @@
|
|
|
2600
2681
|
const stHost = document.createElement('div')
|
|
2601
2682
|
stHost.style.cssText = 'width:320px;height:200px'
|
|
2602
2683
|
document.body.appendChild(stHost)
|
|
2603
|
-
const stView = createGisView(stHost, { points: [{ id: 'a', x: 0, y: 0 }, { id: 'b', x: 100, y: 40 }], features: 'static', showGrid: false })
|
|
2684
|
+
const stView = createGisView(stHost, { points: [{ id: 'a', x: 0, y: 0, name: '甲' }, { id: 'b', x: 100, y: 40 }], features: 'static', showGrid: false, label: { content: '{name}' } })
|
|
2604
2685
|
await settle(150)
|
|
2605
2686
|
const stScale = stView.getCamera().scale
|
|
2606
2687
|
const stBox = stView.canvas.getBoundingClientRect()
|
|
@@ -2608,6 +2689,9 @@
|
|
|
2608
2689
|
await settle(80)
|
|
2609
2690
|
check('features 预设 static:滚轮不缩放', stView.getCamera().scale === stScale, `${stScale} -> ${stView.getCamera().scale}`)
|
|
2610
2691
|
check('features 预设 static:指针事件照旧(getFeatures 里 pan / zoom / hover / select 全是 false)', stView.getFeatures().pan === false && stView.getFeatures().zoom === false && stView.getFeatures().hover === false && stView.getFeatures().select === false, JSON.stringify(stView.getFeatures()))
|
|
2692
|
+
check('features 预设 static:全部开关为 false,配了标签也不产生 DOM',
|
|
2693
|
+
Object.values(stView.getFeatures()).every(value => value === false) && stView.el.querySelectorAll('.gis-view__label-layer--point .gis-view__label').length === 0,
|
|
2694
|
+
JSON.stringify({ state: stView.getFeatures(), labels: stView.el.querySelectorAll('.gis-view__label-layer--point .gis-view__label').length }))
|
|
2611
2695
|
stView.destroy()
|
|
2612
2696
|
stHost.remove()
|
|
2613
2697
|
|
|
@@ -2753,7 +2837,7 @@
|
|
|
2753
2837
|
const exEmpty = await exView.exportSelection({ format: 'data' })
|
|
2754
2838
|
check('没选中节点就导出:ok: false + 原因,不抛异常', exEmpty.ok === false && /没有要导出的节点/.test(String(exEmpty.reason)) && exEmpty.points.length === 0 && exEmpty.image === null, exEmpty.reason)
|
|
2755
2839
|
check('导出失败时点 / 线 / 下标都回空数组', exEmpty.pointIndexes.length === 0 && exEmpty.lineIndexes.length === 0 && exEmpty.box === null, JSON.stringify({ points: exEmpty.pointIndexes, lines: exEmpty.lineIndexes, box: exEmpty.box }))
|
|
2756
|
-
exView.
|
|
2840
|
+
exView.selectFeatures(['ex-a', 'ex-b'])
|
|
2757
2841
|
const exCamera = exView.getCamera()
|
|
2758
2842
|
const exVisible = exView.listPoints({ visibleOnly: true }).length
|
|
2759
2843
|
const exData = await exView.exportSelection({ format: 'data', withLines: true })
|
|
@@ -2922,14 +3006,14 @@
|
|
|
2922
3006
|
rdView.on('selectChange', payload => rdSelects.push(payload))
|
|
2923
3007
|
await rdClick(rdView.project(0, 0), { ctrlKey: true })
|
|
2924
3008
|
check('Ctrl + 点已选中的节点:多选取反走 onSelectChange(count 0),不经过 onClick', rdSelects.length === 1 && rdSelects[0].count === 0 && rdSelects[0].items.length === 0 && rdClicks.length === 2 && rdView.getSelectionData().count === 0, JSON.stringify({ selects: rdSelects.length, clicks: rdClicks.length, count: rdSelects[0]?.count }))
|
|
2925
|
-
rdView.
|
|
3009
|
+
rdView.selectFeatures(['rd-a', 'rd-b'])
|
|
2926
3010
|
await rdRightClick(rdView.project(320, 0))
|
|
2927
3011
|
check('右键落在没选中的节点上:selected / wasSelected 都是 false,selection 照旧给整份选中集', rdMenus[0]?.type === 'point' && rdMenus[0]?.item?.id === 'rd-c' && rdMenus[0]?.selected === false && rdMenus[0]?.wasSelected === false && rdMenus[0]?.selection?.count === 2, JSON.stringify({ id: rdMenus[0]?.item?.id, selected: rdMenus[0]?.selected, count: rdMenus[0]?.selection?.count }))
|
|
2928
3012
|
await rdRightClick(rdView.project(0, 0))
|
|
2929
3013
|
check('右键落在已选中的节点上:wasSelected true(据此决定要不要保住整份多选)', rdMenus[1]?.selected === true && rdMenus[1]?.wasSelected === true && rdMenus[1]?.selection?.count === 2, JSON.stringify({ selected: rdMenus[1]?.selected, was: rdMenus[1]?.wasSelected }))
|
|
2930
3014
|
const rdPointInfo = rdView.getSelectionData()
|
|
2931
3015
|
check('getSelectionData 给读数(ids / count / 各类型条数)', rdPointInfo.count === 2 && rdPointInfo.pointCount === 2 && rdPointInfo.lineCount === 0 && rdPointInfo.channelCount === 0 && rdPointInfo.ids.join(',') === 'rd-a,rd-b', JSON.stringify(rdPointInfo))
|
|
2932
|
-
rdView.
|
|
3016
|
+
rdView.selectFeatures(['rd-1', 'rd-2'])
|
|
2933
3017
|
const rdInfo = rdView.getSelectionData()
|
|
2934
3018
|
check('getSelectionData:选中一条通道的两回线时 lines 两条、channels 去重成一个', rdInfo.count === 2 && rdInfo.lineCount === 2 && rdInfo.channelCount === 1 && rdInfo.lines.length === 2 && rdInfo.channels.length === 1 && rdInfo.channels[0].id === 'rd-ch' && rdInfo.lineIndexes.length === 2 && rdInfo.items.length === 2 && rdInfo.items[0].item === rdInfo.lines[0], JSON.stringify({ channels: rdInfo.channels.map(item => item.id), lineIndexes: rdInfo.lineIndexes }))
|
|
2935
3019
|
|
|
@@ -3039,7 +3123,7 @@
|
|
|
3039
3123
|
const rmKey = (key, extra = {}) => {
|
|
3040
3124
|
rmView.el.dispatchEvent(new KeyboardEvent('keydown', { key, bubbles: true, cancelable: true, ...extra }))
|
|
3041
3125
|
}
|
|
3042
|
-
rmView.
|
|
3126
|
+
rmView.selectFeatures(['rm-2'])
|
|
3043
3127
|
rmKey('Delete')
|
|
3044
3128
|
await settle(40)
|
|
3045
3129
|
const rmPlan = rmView.getRemoveRequest()
|
|
@@ -3050,13 +3134,13 @@
|
|
|
3050
3134
|
rmView.cancelRemove()
|
|
3051
3135
|
await settle(40)
|
|
3052
3136
|
check('取消删除:数据不动、事件给 phase: cancel、待确认的载荷收掉', rmView.getData().lines.length === 4 && rmEvents.length === 2 && rmEvents[1].phase === 'cancel' && rmEvents[1].cancelled === true && rmView.getRemoveRequest() === null, JSON.stringify(rmEvents.map(item => item.phase)))
|
|
3053
|
-
rmView.
|
|
3137
|
+
rmView.selectFeatures(['rm-2'])
|
|
3054
3138
|
rmKey('Delete')
|
|
3055
3139
|
await settle(40)
|
|
3056
3140
|
rmView.resolveRemove('channels')
|
|
3057
3141
|
await settle(80)
|
|
3058
3142
|
check('按「整条通道」确认:三条回线一起删、通道声明也摘掉,通道外的线路留着', rmView.getData().lines.length === 1 && rmView.getData().lines[0].id === 'rm-solo' && rmView.getOptions().channels.length === 0 && rmEvents.at(-1).phase === 'remove' && rmEvents.at(-1).scope === 'channels' && rmEvents.at(-1).result.lineIds.length === 3, JSON.stringify({ lines: rmView.getData().lines.map(item => item.id), channels: rmView.getOptions().channels.length }))
|
|
3059
|
-
rmView.
|
|
3143
|
+
rmView.selectFeatures(['rm-a'])
|
|
3060
3144
|
rmKey('Delete')
|
|
3061
3145
|
await settle(40)
|
|
3062
3146
|
const rmPointPlan = rmView.getRemoveRequest()
|
|
@@ -3068,7 +3152,7 @@
|
|
|
3068
3152
|
await settle(80)
|
|
3069
3153
|
check('撤销一步:节点与连带删掉的线路一起回来', rmView.getData().points.length === 3 && rmView.getData().lines.length === 1 && rmView.getData().lines[0].id === 'rm-solo', JSON.stringify({ points: rmView.getData().points.length, lines: rmView.getData().lines.map(item => item.id) }))
|
|
3070
3154
|
rmView.updateOptions({ shortcuts: { remove: 'shift+delete' } })
|
|
3071
|
-
rmView.
|
|
3155
|
+
rmView.selectFeatures(['rm-solo'])
|
|
3072
3156
|
rmKey('Delete')
|
|
3073
3157
|
await settle(40)
|
|
3074
3158
|
check('快捷键单独配:单独的 Delete 不再触发删除', rmView.getRemoveRequest() === null && rmView.getData().lines.length === 1, JSON.stringify(rmView.getRemoveRequest()))
|
|
@@ -3077,7 +3161,7 @@
|
|
|
3077
3161
|
check('配成 Shift+Delete:按住 Shift 再按才出载荷', Boolean(rmView.getRemoveRequest()) && rmView.getRemoveRequest().counts.lines === 1, JSON.stringify(rmView.getRemoveRequest()?.counts))
|
|
3078
3162
|
rmView.cancelRemove()
|
|
3079
3163
|
/* 待确认期间数据换过:确认时整条请求作废(不按旧下标删),事件给 phase: cancel + invalidated */
|
|
3080
|
-
rmView.
|
|
3164
|
+
rmView.selectFeatures(['rm-solo'])
|
|
3081
3165
|
rmKey('Delete', { shiftKey: true })
|
|
3082
3166
|
await settle(40)
|
|
3083
3167
|
rmView.updateData([{ id: 'rm-a', x: 0, y: 0 }, { id: 'rm-b', x: 200, y: 0 }, { id: 'rm-c', x: 100, y: -80 }, { id: 'rm-d', x: 40, y: 40 }], [{ id: 'rm-solo', from: 'rm-a', to: 'rm-c' }])
|
|
@@ -3099,44 +3183,44 @@
|
|
|
3099
3183
|
showGrid: false
|
|
3100
3184
|
})
|
|
3101
3185
|
await settle(120)
|
|
3102
|
-
rmOffView.
|
|
3186
|
+
rmOffView.selectFeatures(['rm-off-line'])
|
|
3103
3187
|
rmOffView.el.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', bubbles: true, cancelable: true }))
|
|
3104
3188
|
await settle(40)
|
|
3105
3189
|
check('开关关着(features.remove 缺省):Delete 不出删除载荷,数据不动', rmOffView.getRemoveRequest() === null && rmOffView.getData().lines.length === 1, JSON.stringify({ lines: rmOffView.getData().lines.length }))
|
|
3106
3190
|
rmOffView.destroy()
|
|
3107
3191
|
rmOffHost.remove()
|
|
3108
3192
|
|
|
3109
|
-
const rdStations = rdView.
|
|
3110
|
-
check('
|
|
3111
|
-
check('
|
|
3112
|
-
const rdLean = rdView.
|
|
3113
|
-
check('
|
|
3193
|
+
const rdStations = rdView.exportData({ format: 'new', parts: ['station'] })
|
|
3194
|
+
check('exportData(format: new, parts: station):new.json 的 station_data 口径(列名 / 母线清单 / 业务列原样透传)', rdStations.ok === true && rdStations.station_data.length === 3 && rdStations.station_data[0].station_id === 'rd-a' && rdStations.station_data[0].station_name === '甲站' && rdStations.station_data[0].vn_kv === 220 && rdStations.station_data[0].bus_id_list.join(',') === 'b-1,b-2' && Array.isArray(rdStations.station_data[0].trafo_id_list) && rdStations.station_data[0].max_loading_rate === 0.8, JSON.stringify(rdStations.station_data[0]).slice(0, 200))
|
|
3195
|
+
check('exportData(format: new, parts: station):四至范围与 show_station_list / show_station_data 一起给', Number.isFinite(rdStations.max_lat) && Number.isFinite(rdStations.min_lon) && rdStations.show_station_list.join(',') === 'b-1,b-2,b-3' && rdStations.show_station_data[0].join(',') === 'b-1,b-2', JSON.stringify({ box: [rdStations.min_lon, rdStations.min_lat, rdStations.max_lon, rdStations.max_lat], list: rdStations.show_station_list }))
|
|
3196
|
+
const rdLean = rdView.exportData({ format: 'new', parts: ['station'], points: ['rd-a'], box: false, showStation: false })
|
|
3197
|
+
check('exportData(format: new, parts: station):box / showStation 关掉就不带那几列,只留选中的这一个站', rdLean.station_data.length === 1 && !('max_lat' in rdLean) && !('show_station_list' in rdLean), JSON.stringify(Object.keys(rdLean)))
|
|
3114
3198
|
const rdCopyRow = rdStations.station_data[0]
|
|
3115
3199
|
rdCopyRow.bus_id_list.push('改一改')
|
|
3116
3200
|
check('导出的是拷贝:改导出结果不动组件里的那一份', rdView.getData().points[0].bus_id_list.length === 2, `组件里 ${rdView.getData().points[0].bus_id_list.length} 个`)
|
|
3117
|
-
const rdPoints = rdView.
|
|
3118
|
-
check('
|
|
3119
|
-
check('
|
|
3120
|
-
const rdLines = rdView.
|
|
3201
|
+
const rdPoints = rdView.exportData({ format: 'test', parts: ['station'] })
|
|
3202
|
+
check('exportData(format: test, parts: station):test.json 的 point_data 口径(同一份数据换列名,带分区列)', rdPoints.ok === true && rdPoints.point_data.length === 3 && rdPoints.point_data[0].station_id === 'rd-a' && rdPoints.point_data[0].station_name === '甲站' && rdPoints.point_data[0].lon === 0 && rdPoints.point_data[0].lat === 0 && rdPoints.counts.points === 3, JSON.stringify({ keys: Object.keys(rdPoints.point_data[0] ?? {}).length, count: rdPoints.counts.points, lon: rdPoints.point_data[0].lon, lat: rdPoints.point_data[0].lat }))
|
|
3203
|
+
check('exportData(format: test, parts: station):zone_id / zone_name 两列在(没给值就是 null)', 'zone_id' in rdPoints.point_data[0] && 'zone_name' in rdPoints.point_data[0] && rdPoints.point_data[0].bus_name_list.length === 2, JSON.stringify({ zone_id: rdPoints.point_data[0].zone_id }))
|
|
3204
|
+
const rdLines = rdView.exportData({ format: 'test', parts: ['line'] })
|
|
3121
3205
|
const rdChannelLine = rdLines.line_data.filter(row => row.channel_id === 'rd-ch')
|
|
3122
|
-
check('
|
|
3123
|
-
check('
|
|
3124
|
-
const rdChannels = rdView.
|
|
3125
|
-
check('
|
|
3126
|
-
const rdChannelLean = rdView.
|
|
3127
|
-
check('
|
|
3128
|
-
const rdGroupsOff = rdView.
|
|
3129
|
-
check('
|
|
3206
|
+
check('exportData(format: test, parts: line):通道回线带上 channel_id / channel_name / parallel_group_id 与第几回', rdLines.ok === true && rdLines.line_data.length === 3 && rdChannelLine.length === 2 && rdChannelLine[0].parallel_group_id !== undefined && rdChannelLine[0].index === 0 && rdChannelLine[1].index === 1 && rdChannelLine.every(row => Array.isArray(row.coords_list) && row.coords_list.length >= 2), JSON.stringify(rdChannelLine.map(row => ({ id: row.line_id, group: row.parallel_group_id, index: row.index }))))
|
|
3207
|
+
check('exportData(format: test, parts: line):不在通道里的线路 channel_id 给 null,折线就是画出来的那一份', rdLines.line_data.some(row => row.line_id === 'rd-solo' && row.channel_id === null && row.coords_list.length === 3), JSON.stringify(rdLines.line_data.map(row => ({ id: row.line_id, channel: row.channel_id, points: row.coords_list.length }))))
|
|
3208
|
+
const rdChannels = rdView.exportData({ format: 'new', parts: ['channel'] })
|
|
3209
|
+
check('exportData(format: new, parts: channel):一条通道一行,回线在 line_data 里、路由在 coords 里', rdChannels.ok === true && rdChannels.channel_data.length === 1 && rdChannels.counts.channels === 1 && rdChannels.counts.lines === 2 && rdChannels.channel_data[0].line_data.length === 2 && Array.isArray(rdChannels.channel_data[0].coords) && rdChannels.channel_data[0].coords.length >= 2, JSON.stringify({ channels: rdChannels.counts.channels, lines: rdChannels.counts.lines, coords: rdChannels.channel_data[0].coords.length }))
|
|
3210
|
+
const rdChannelLean = rdView.exportData({ format: 'new', parts: ['channel'], channels: [0], lines: ['rd-1'] })
|
|
3211
|
+
check('exportData(format: new, parts: channel):options.lines 能把通道里的 line_data 收到这几条回线', rdChannelLean.channel_data[0].line_data.length === 1 && rdChannelLean.channel_data[0].line_data[0].line_id === 'rd-1', JSON.stringify(rdChannelLean.channel_data[0].line_data.map(row => row.line_id)))
|
|
3212
|
+
const rdGroupsOff = rdView.exportData({ format: 'test', parts: ['waypoint'] })
|
|
3213
|
+
check('exportData(format: test, parts: waypoint):没加过拐点时是空的一份(与通道数据各走各的)', rdGroupsOff.ok === true && rdGroupsOff.parallel_groups.length === 0 && rdGroupsOff.counts.parallelGroups === 0, JSON.stringify(rdGroupsOff.counts))
|
|
3130
3214
|
rdView.addWaypoint('rd-1', [80, 40])
|
|
3131
3215
|
await settle(80)
|
|
3132
|
-
const rdGroupsOn = rdView.
|
|
3133
|
-
check('加了拐点之后:parallel_groups 单独给出这一组(group_id / member_line_ids / group_route 对得上)', rdGroupsOn.parallel_groups.length === 1 && rdGroupsOn.counts.parallelGroups === 1 &&
|
|
3134
|
-
const rdGroupsAll = rdView.
|
|
3135
|
-
check('
|
|
3136
|
-
const rdOneGroup = rdView.
|
|
3137
|
-
check('
|
|
3138
|
-
const rdNoGroup = rdView.
|
|
3139
|
-
check('
|
|
3216
|
+
const rdGroupsOn = rdView.exportData({ format: 'test', parts: ['waypoint'] })
|
|
3217
|
+
check('加了拐点之后:parallel_groups 单独给出这一组(group_id / member_line_ids / group_route 对得上)', rdGroupsOn.parallel_groups.length === 1 && rdGroupsOn.counts.parallelGroups === 1 && Array.isArray(rdGroupsOn.parallel_groups[0].group_route) && rdGroupsOn.parallel_groups[0].group_route.length >= 3 && rdGroupsOn.parallel_groups[0].member_line_ids.length >= 1, JSON.stringify(rdGroupsOn.parallel_groups[0]).slice(0, 200))
|
|
3218
|
+
const rdGroupsAll = rdView.exportData({ format: 'test', parts: ['waypoint'], all: true })
|
|
3219
|
+
check('exportData(format: test, parts: waypoint):all 为 true 时把没编辑过的分组 / 带折线的线路也列出来', rdGroupsAll.parallel_groups.some(group => String(group.group_id) === 'rd-solo'), JSON.stringify(rdGroupsAll.parallel_groups.map(group => group.group_id)))
|
|
3220
|
+
const rdOneGroup = rdView.exportData({ format: 'test', parts: ['waypoint'], channels: ['rd-ch'] })
|
|
3221
|
+
check('exportData(format: test, parts: waypoint):channels 只留这条通道那一份', rdOneGroup.parallel_groups.length === 1 && rdOneGroup.parallel_groups[0].group_route.length >= 3, JSON.stringify(rdOneGroup.parallel_groups.map(group => group.group_id)))
|
|
3222
|
+
const rdNoGroup = rdView.exportData({ format: 'test', parts: ['waypoint'], channels: ['没有这条通道'] })
|
|
3223
|
+
check('exportData(format: test, parts: waypoint):通道 id 解不出来时给空表 + 一条 warnings', rdNoGroup.parallel_groups.length === 0 && rdNoGroup.warnings.length === 1, JSON.stringify(rdNoGroup.warnings))
|
|
3140
3224
|
const rdFour = rdView.exportData({ format: 'view' })
|
|
3141
3225
|
check("exportData format: view(缺省):points / lines / channels / parallelGroups 四份分开", rdFour.ok === true && rdFour.points.length === 3 && rdFour.lines.length === 3 && rdFour.channels.length === 1 && Array.isArray(rdFour.parallelGroups) && rdFour.counts.points === 3 && rdFour.counts.lines === 3 && rdFour.counts.channels === 1, JSON.stringify(rdFour.counts))
|
|
3142
3226
|
const rdNew = rdView.exportData({ format: 'new' })
|
|
@@ -3145,6 +3229,32 @@
|
|
|
3145
3229
|
check("exportData format: test:test.json 口径的整份(point_data + line_data + parallel_groups)", rdTest.point_data.length === 3 && rdTest.line_data.length === 3 && Array.isArray(rdTest.switch_data) && rdTest.parallel_groups.length >= 1 && rdTest.counts.points === 3, JSON.stringify(rdTest.counts))
|
|
3146
3230
|
const rdFiltered = rdView.exportData({ format: 'view', points: ['rd-a'], lines: ['rd-solo'], channels: ['rd-ch'] })
|
|
3147
3231
|
check('exportData:三个筛选取一部分时只导这几个(id / 下标 / { id } 都认)', rdFiltered.points.length === 1 && rdFiltered.lines.length === 1 && rdFiltered.channels.length === 1 && rdFiltered.lines[0].line_id === 'rd-solo', JSON.stringify(rdFiltered.counts))
|
|
3232
|
+
const rdStationOnly = rdView.exportData({ format: 'view', parts: ['station'] })
|
|
3233
|
+
check('exportData:parts 只留场站时不生成线路 / 通道 / 拐点', rdStationOnly.points.length === 3 && rdStationOnly.lines === undefined && rdStationOnly.channels === undefined && rdStationOnly.parallelGroups === undefined && rdStationOnly.counts.lines === 0 && rdStationOnly.counts.channels === 0, JSON.stringify(rdStationOnly.counts))
|
|
3234
|
+
const rdViewportUnified = rdView.exportData({ scope: 'viewport', margin: 0 })
|
|
3235
|
+
const rdViewportRepeat = rdView.exportData({ scope: 'viewport' })
|
|
3236
|
+
check('exportData(scope: viewport) 可重复且带 scope / viewRect / margin', JSON.stringify(rdViewportUnified) === JSON.stringify(rdViewportRepeat) && rdViewportUnified.scope === 'viewport' && rdViewportUnified.viewRect && rdViewportUnified.margin === 0, JSON.stringify({ scope: rdViewportUnified.scope, rect: rdViewportUnified.viewRect, margin: rdViewportUnified.margin }))
|
|
3237
|
+
const rdSelectionUnified = rdView.exportData({ scope: 'selection', points: ['rd-a', 'rd-b'], parts: ['station', 'channel'] })
|
|
3238
|
+
const rdSelectionRepeat = rdView.exportData({ scope: 'selection', points: ['rd-a', 'rd-b'], parts: ['station', 'channel'] })
|
|
3239
|
+
check('exportData(scope: selection) 可重复且把下标 / parts 一并回显', JSON.stringify(rdSelectionUnified) === JSON.stringify(rdSelectionRepeat) && rdSelectionUnified.scope === 'selection' && rdSelectionUnified.pointIndexes.length === 2 && Array.isArray(rdSelectionUnified.channelIndexes), JSON.stringify({ scope: rdSelectionUnified.scope, points: rdSelectionUnified.pointIndexes, channels: rdSelectionUnified.channelIndexes }))
|
|
3240
|
+
const rdRemovedAliases = ['exportStationData', 'exportPointData', 'exportLineData', 'exportChannelData', 'exportParallelGroups', 'exportViewportData', 'exportSelectionData']
|
|
3241
|
+
check('七个旧分项导出别名已经从实例上删除,只保留统一 exportData', rdRemovedAliases.every(name => rdView[name] === undefined) && typeof rdView.exportData === 'function', rdRemovedAliases.map(name => `${name}:${typeof rdView[name]}`).join(' / '))
|
|
3242
|
+
const rdRemovedThinWrappers = ['setEffects', 'setPointSize', 'setPointSymbol', 'setPointColor', 'setLineWidth', 'setLineColor', 'setChannelWidth', 'setChannelNodeWidth', 'setChannelInset', 'setChannelTangentInset', 'setChannelName', 'clearFilter', 'clearDropPreview']
|
|
3243
|
+
check('十三个重复的单项 / 清空快捷方法已经从实例上删除,统一走 update* / setFilter(null) / setDropPreview(null)', rdRemovedThinWrappers.every(name => rdView[name] === undefined) && typeof rdView.updatePoint === 'function' && typeof rdView.updateLine === 'function' && typeof rdView.updateChannel === 'function' && typeof rdView.updateOptions === 'function' && typeof rdView.setFilter === 'function' && typeof rdView.setDropPreview === 'function', rdRemovedThinWrappers.map(name => `${name}:${typeof rdView[name]}`).join(' / '))
|
|
3244
|
+
const rdInputViewport = rdView.exportData({ scope: 'viewport', format: 'input' })
|
|
3245
|
+
check('format: input 的视口结果保持回灌形状,不额外夹带 scope / viewRect / margin', Array.isArray(rdInputViewport.points) && !('scope' in rdInputViewport) && !('viewRect' in rdInputViewport) && !('margin' in rdInputViewport), Object.keys(rdInputViewport).join(','))
|
|
3246
|
+
const rdChannelLeanUnified = rdView.exportData({ format: 'new', parts: ['channel'], channels: ['rd-ch'], lines: ['rd-1'] })
|
|
3247
|
+
check('exportData:统一入口下通道的 line_data 仍按 lines 收窄(只留选中的回线)', rdChannelLeanUnified.channel_data.length === 1 && rdChannelLeanUnified.channel_data[0].line_data.length === 1 && rdChannelLeanUnified.channel_data[0].line_data[0].line_id === 'rd-1', JSON.stringify(rdChannelLeanUnified.channel_data[0]?.line_data?.map(row => row.line_id)))
|
|
3248
|
+
const rdFull = rdView.exportData({ format: 'full', scope: 'viewport' })
|
|
3249
|
+
check('exportData:format full 始终返回标准文档本身,不夹带 scope / viewRect 读数', rdFull.format === 'gis-view' && !('scope' in rdFull) && !('viewRect' in rdFull) && !('counts' in rdFull), Object.keys(rdFull).join(','))
|
|
3250
|
+
let rdScopeThrew = ''
|
|
3251
|
+
try {
|
|
3252
|
+
rdView.exportData({ scope: 'window' })
|
|
3253
|
+
}
|
|
3254
|
+
catch (error) {
|
|
3255
|
+
rdScopeThrew = String(error && error.message ? error.message : error)
|
|
3256
|
+
}
|
|
3257
|
+
check('exportData:scope 写错直接抛异常(不静默按全量导)', /viewport/.test(rdScopeThrew) && /selection/.test(rdScopeThrew) && /window/.test(rdScopeThrew), rdScopeThrew)
|
|
3148
3258
|
const rdBad = rdView.exportData({ format: 'test', lines: ['没有这条线'] })
|
|
3149
3259
|
check('解不出的引用记进 warnings,其余照常导出(ok 仍是 true)', rdBad.ok === true && rdBad.line_data.length === 0 && rdBad.warnings.length === 1 && /没找到/.test(String(rdBad.warnings[0])), JSON.stringify(rdBad.warnings))
|
|
3150
3260
|
let rdThrew = ''
|
|
@@ -3229,9 +3339,9 @@
|
|
|
3229
3339
|
check('selectFeatures:拾取载荷(pickAt 的结果)可以直接喂进来', apiIds() === 'api-a', apiIds())
|
|
3230
3340
|
apiView.selectFeatures(apiView.search({ keyword: 'api-l1' }).hits[0])
|
|
3231
3341
|
check('selectFeatures:搜索命中(kind: line)可以直接喂进来', apiIds() === 'api-l1', apiIds())
|
|
3232
|
-
apiView.
|
|
3342
|
+
apiView.selectFeatures(null)
|
|
3233
3343
|
const apiEmpty = apiView.getSelectionData()
|
|
3234
|
-
check('
|
|
3344
|
+
check('selectFeatures(null) 清空选中,getSelectionData 给空的一份(bounds 是 null)', apiEmpty.count === 0 && apiEmpty.ids.length === 0 && apiEmpty.bounds === null, JSON.stringify(apiEmpty.count))
|
|
3235
3345
|
apiSend('pointermove', apiPointScreen)
|
|
3236
3346
|
apiSend('pointerdown', apiPointScreen, { button: 0, buttons: 1 })
|
|
3237
3347
|
apiSend('pointerup', apiPointScreen, { button: 0, buttons: 0 })
|
|
@@ -3282,7 +3392,7 @@
|
|
|
3282
3392
|
check('focusOn(一批, { select: true }):被聚焦的这一批同时选中(整份选中集换成这三个)', apiView.getSelectionData().ids.join(',') === 'api-a,api-b,api-c' && apiBeforeFocusSelect === 'api-a,api-b,api-c' && apiView.getSelectionData().count === 3, `${apiBeforeFocusSelect} -> ${apiView.getSelectionData().ids.join(',')}`)
|
|
3283
3393
|
apiView.focusOn('api-a', { select: true, mode: 'remove' })
|
|
3284
3394
|
check("focusOn(..., { select: true, mode: 'remove' }):只把聚焦的这个从选中集里去掉", apiView.getSelectionData().ids.join(',') === 'api-b,api-c', apiView.getSelectionData().ids.join(','))
|
|
3285
|
-
apiView.
|
|
3395
|
+
apiView.selectFeatures(null)
|
|
3286
3396
|
const apiAreaScale = apiView.getCamera().scale
|
|
3287
3397
|
apiView.focusOn('api-b', { maxZoom: 12 })
|
|
3288
3398
|
const apiZoomCamera = apiView.getCamera()
|
|
@@ -3433,7 +3543,8 @@
|
|
|
3433
3543
|
const pluginLog = []
|
|
3434
3544
|
const pluginWarnings = []
|
|
3435
3545
|
const pluginErrors = []
|
|
3436
|
-
let optionPluginInstance = null
|
|
3546
|
+
let optionPluginInstance = null
|
|
3547
|
+
let optionPluginContext = null
|
|
3437
3548
|
const pluginView = createGisView(pluginHost, {
|
|
3438
3549
|
points: [{ id: 'pg-1', x: 0, y: 0 }],
|
|
3439
3550
|
lines: [],
|
|
@@ -3441,19 +3552,22 @@
|
|
|
3441
3552
|
height: 160,
|
|
3442
3553
|
onWarning: text => pluginWarnings.push(text),
|
|
3443
3554
|
onError: text => pluginErrors.push(text),
|
|
3444
|
-
plugins: [v => {
|
|
3555
|
+
plugins: [(v, context) => {
|
|
3445
3556
|
optionPluginInstance = v
|
|
3557
|
+
optionPluginContext = context
|
|
3446
3558
|
return { destroy: () => pluginLog.push('options') }
|
|
3447
3559
|
}]
|
|
3448
3560
|
})
|
|
3449
|
-
check('options.plugins
|
|
3450
|
-
let usePluginInstance = null
|
|
3561
|
+
check('options.plugins 拿到实例本身与带 apiVersion 的只读上下文', optionPluginInstance === pluginView && optionPluginContext?.apiVersion === 1 && optionPluginContext.view === pluginView && Object.isFrozen(optionPluginContext), JSON.stringify(optionPluginContext ? { apiVersion: optionPluginContext.apiVersion, sameView: optionPluginContext.view === pluginView } : null))
|
|
3562
|
+
let usePluginInstance = null
|
|
3563
|
+
let usePluginContext = null
|
|
3451
3564
|
let useDestroyCount = 0
|
|
3452
|
-
const disposeUse = pluginView.use(v => {
|
|
3565
|
+
const disposeUse = pluginView.use((v, context) => {
|
|
3453
3566
|
usePluginInstance = v
|
|
3567
|
+
usePluginContext = context
|
|
3454
3568
|
return { destroy: () => { useDestroyCount += 1 } }
|
|
3455
3569
|
})
|
|
3456
|
-
check('use()
|
|
3570
|
+
check('use() 立即执行,实例与带版本的上下文都和 options.plugins 一致', usePluginInstance === pluginView && usePluginContext?.apiVersion === 1 && usePluginContext.view === pluginView && Object.isFrozen(usePluginContext))
|
|
3457
3571
|
disposeUse()
|
|
3458
3572
|
disposeUse()
|
|
3459
3573
|
check('use() 返回的卸载函数跑插件的 destroy(重复调用只跑一次)', useDestroyCount === 1, String(useDestroyCount))
|
|
@@ -3664,7 +3778,7 @@
|
|
|
3664
3778
|
await edgeSleep(120)
|
|
3665
3779
|
const shiftDropFrame = await frameOf(shiftView)
|
|
3666
3780
|
check('删掉选中里的那一条:读数只剩 c,b 的位置不留选中色', shiftView.getSelectionData().ids.join(',') === 'sp-c' && !pixelIs(shiftDropFrame, shiftSpotB, 'green') && pixelIs(shiftDropFrame, shiftSpotC, 'green'), JSON.stringify({ ids: shiftView.getSelectionData().ids, b: pixelIs(shiftDropFrame, shiftSpotB, 'green'), c: pixelIs(shiftDropFrame, shiftSpotC, 'green') }))
|
|
3667
|
-
shiftView.
|
|
3781
|
+
shiftView.selectFeatures(null)
|
|
3668
3782
|
await edgeSleep(120)
|
|
3669
3783
|
const shiftClearFrame = await frameOf(shiftView)
|
|
3670
3784
|
check('删点之后取消选中:c 的选中色收掉、回到自己的底色(不会停在别人身上)', !pixelIs(shiftClearFrame, shiftSpotC, 'green') && pixelIsWhite(shiftClearFrame, shiftSpotC), JSON.stringify({ green: pixelIs(shiftClearFrame, shiftSpotC, 'green'), white: pixelIsWhite(shiftClearFrame, shiftSpotC) }))
|
|
@@ -3691,7 +3805,7 @@
|
|
|
3691
3805
|
})
|
|
3692
3806
|
await edgeSleep(120)
|
|
3693
3807
|
const lineSpot = lineShiftView.project(200, 120)
|
|
3694
|
-
lineShiftView.
|
|
3808
|
+
lineShiftView.selectFeatures('ssl2')
|
|
3695
3809
|
lineShiftView.removeLines('ssl1')
|
|
3696
3810
|
await edgeSleep(120)
|
|
3697
3811
|
const lineShiftFrame = await frameOf(lineShiftView)
|
|
@@ -3712,7 +3826,7 @@
|
|
|
3712
3826
|
})
|
|
3713
3827
|
await edgeSleep(120)
|
|
3714
3828
|
const mergeSpotC = mergeShiftView.project(280, 0)
|
|
3715
|
-
mergeShiftView.
|
|
3829
|
+
mergeShiftView.selectFeatures('mp-c')
|
|
3716
3830
|
mergeShiftView.mergePoints('mp-a', 'mp-b')
|
|
3717
3831
|
await edgeSleep(120)
|
|
3718
3832
|
const mergeShiftFrame = await frameOf(mergeShiftView)
|
|
@@ -3734,7 +3848,7 @@
|
|
|
3734
3848
|
await edgeSleep(120)
|
|
3735
3849
|
const fallbackSpotB = fallbackShiftView.project(140, 0)
|
|
3736
3850
|
const fallbackSpotC = fallbackShiftView.project(280, 0)
|
|
3737
|
-
fallbackShiftView.
|
|
3851
|
+
fallbackShiftView.selectFeatures('fp-c')
|
|
3738
3852
|
fallbackShiftView.removePoints('fp-a')
|
|
3739
3853
|
await edgeSleep(120)
|
|
3740
3854
|
const fallbackFrame = await frameOf(fallbackShiftView)
|
|
@@ -3887,11 +4001,37 @@
|
|
|
3887
4001
|
/<image[^>]+href="data:image\/png;base64/.test(symSvg),
|
|
3888
4002
|
(symSvg.match(/<image[^>]*/) ?? ['没有 <image>'])[0].slice(0, 90))
|
|
3889
4003
|
check('自定义图元:listSymbols 报得出注册过的名字', symView.listSymbols().includes('三角'), JSON.stringify(symView.listSymbols()))
|
|
4004
|
+
// 同名覆盖要换一张贴图:画笔从三角形换成整块实心方块,斜角立刻从透明变成实色。
|
|
4005
|
+
// 贴图缓存的来源键没带注册代次时,这里会继续拿旧三角形,画面看起来像「注册没生效」。
|
|
4006
|
+
const symBlockPainter = (context, info) => {
|
|
4007
|
+
context.fillStyle = '#c837d6'
|
|
4008
|
+
context.fillRect(0, 0, info.width, info.height)
|
|
4009
|
+
}
|
|
4010
|
+
symView.registerSymbol('三角', symBlockPainter)
|
|
4011
|
+
await edgeSleep(240)
|
|
4012
|
+
const symReregistered = await symShot(symView)
|
|
4013
|
+
const symReregisteredCorner = symRead(symReregistered, symCorner)
|
|
4014
|
+
check('自定义图元:同名重新注册会重新烘焙贴图(三角形换成整块色块,原来的斜角变实了)',
|
|
4015
|
+
symReregisteredCorner[3] > 200 && symReregisteredCorner[0] > 150 && symReregisteredCorner[1] < 120 && symReregisteredCorner[2] > 150,
|
|
4016
|
+
symReregisteredCorner.join(','))
|
|
3890
4017
|
symView.registerSymbol(' ', trianglePainter)
|
|
3891
4018
|
symView.registerSymbol('空画笔', null)
|
|
3892
4019
|
check('自定义图元:名字空的 / 画笔不是函数只报一条 onWarning,注册表不动',
|
|
3893
4020
|
warnedNames.length === 2 && symView.listSymbols().length === 1 && warnedNames.every(message => message.includes('registerSymbol')),
|
|
3894
4021
|
warnedNames.join(' | '))
|
|
4022
|
+
const scopedSymbolPainter = (context, info) => {
|
|
4023
|
+
context.fillStyle = info.color
|
|
4024
|
+
context.fillRect(0, 0, info.width, info.height)
|
|
4025
|
+
}
|
|
4026
|
+
const scopedSymbolOffA = symView.registerSymbol('作用域图元', scopedSymbolPainter)
|
|
4027
|
+
const scopedSymbolOffB = symView.registerSymbol('作用域图元', scopedSymbolPainter)
|
|
4028
|
+
scopedSymbolOffA()
|
|
4029
|
+
const scopedSymbolSurvived = symView.listSymbols().includes('作用域图元')
|
|
4030
|
+
scopedSymbolOffB()
|
|
4031
|
+
scopedSymbolOffB()
|
|
4032
|
+
check('自定义图元:同名覆盖后旧注销函数不误删新注册(画笔相同也算新注册),新注销函数重复调用安全',
|
|
4033
|
+
scopedSymbolSurvived && !symView.listSymbols().includes('作用域图元'),
|
|
4034
|
+
`旧注销后仍在 ${scopedSymbolSurvived} / 最终 ${JSON.stringify(symView.listSymbols())}`)
|
|
3895
4035
|
symView.unregisterSymbol('三角')
|
|
3896
4036
|
symOff()
|
|
3897
4037
|
await edgeSleep(240)
|
|
@@ -4214,9 +4354,9 @@
|
|
|
4214
4354
|
const auGeometry = id => auView.listLines({}).find(item => item.item?.id === id)?.path ?? null
|
|
4215
4355
|
const auWaypoints = id => auView.getWaypoints(auLineIndex(id)).map(item => item.coordinate)
|
|
4216
4356
|
|
|
4217
|
-
// ① getPointStyle 读的是「样式链定下来的那一份」:
|
|
4218
|
-
auView.
|
|
4219
|
-
check('getPointStyle:
|
|
4357
|
+
// ① getPointStyle 读的是「样式链定下来的那一份」:updatePoint({ size }) 之后必须跟着变
|
|
4358
|
+
auView.updatePoint('a', { size: 34 })
|
|
4359
|
+
check('getPointStyle:updatePoint({ size }) 之后读回来就是新尺寸', auView.getPointStyle(auPointIndex('a'))?.size === 34, JSON.stringify(auView.getPointStyle(auPointIndex('a'))))
|
|
4220
4360
|
auView.updatePoint('a', { size: 26 })
|
|
4221
4361
|
check('getPointStyle:updatePoint({ size }) 之后也跟上(不再停在初次解析的那一份)', auView.getPointStyle(auPointIndex('a'))?.size === 26, JSON.stringify(auView.getPointStyle(auPointIndex('a'))))
|
|
4222
4362
|
|
|
@@ -4229,7 +4369,7 @@
|
|
|
4229
4369
|
auView.cancelPointCopy()
|
|
4230
4370
|
|
|
4231
4371
|
// ③ setCurrentChannelGroup(id, null) = 不选中(不是「选中第一组」)
|
|
4232
|
-
auView.
|
|
4372
|
+
auView.selectFeatures('m1')
|
|
4233
4373
|
const auSelectedBefore = auView.getSelections().filter(entry => entry.type === 'line').length
|
|
4234
4374
|
auView.setCurrentChannelGroup('au-ch', null)
|
|
4235
4375
|
const auSelectedAfter = auView.getSelections().filter(entry => entry.type === 'line').length
|
|
@@ -4344,6 +4484,325 @@
|
|
|
4344
4484
|
JSON.stringify(gwView.getOptions().channels[0]?.groups ?? null))
|
|
4345
4485
|
gwView.destroy()
|
|
4346
4486
|
gwHost.remove()
|
|
4487
|
+
|
|
4488
|
+
/* ⑪ 扩展图形:path / image / canvas 三类,世界坐标跟随相机,DOM 层级在画布与标签之间,导出 PNG / SVG 都包含 */
|
|
4489
|
+
const grHost = document.createElement('div')
|
|
4490
|
+
grHost.style.cssText = 'width:480px;height:300px'
|
|
4491
|
+
document.body.appendChild(grHost)
|
|
4492
|
+
const grImageCanvas = document.createElement('canvas')
|
|
4493
|
+
grImageCanvas.width = 8
|
|
4494
|
+
grImageCanvas.height = 8
|
|
4495
|
+
const grImageContext = grImageCanvas.getContext('2d')
|
|
4496
|
+
grImageContext.fillStyle = '#ffcc00'
|
|
4497
|
+
grImageContext.fillRect(0, 0, 8, 8)
|
|
4498
|
+
const grLiveCanvas = document.createElement('canvas')
|
|
4499
|
+
grLiveCanvas.width = 16
|
|
4500
|
+
grLiveCanvas.height = 16
|
|
4501
|
+
const grLiveContext = grLiveCanvas.getContext('2d')
|
|
4502
|
+
grLiveContext.fillStyle = '#00aa66'
|
|
4503
|
+
grLiveContext.fillRect(0, 0, 16, 16)
|
|
4504
|
+
const grBase = [
|
|
4505
|
+
{ id: 'g-path', type: 'path', x: 0, y: 0, width: 36, height: 36, viewBox: [0, 0, 10, 10], d: 'M0 0H10V10H0Z', fill: '#ff0000', stroke: 'none', anchor: 'center' },
|
|
4506
|
+
{ id: 'g-image', type: 'image', src: grImageCanvas.toDataURL('image/png'), x: 80, y: 0, width: 32, height: 32, anchor: 'center' },
|
|
4507
|
+
{ id: 'g-canvas', type: 'canvas', canvas: grLiveCanvas, x: -80, y: 0, width: 32, height: 32, anchor: 'center', scaleWithView: true }
|
|
4508
|
+
]
|
|
4509
|
+
const grWarns = []
|
|
4510
|
+
const grView = createGisView(grHost, {
|
|
4511
|
+
points: [],
|
|
4512
|
+
lines: [],
|
|
4513
|
+
graphics: grBase,
|
|
4514
|
+
initialView: { scale: 2, center: [0, 0] },
|
|
4515
|
+
showGrid: false,
|
|
4516
|
+
onWarning: message => grWarns.push(message)
|
|
4517
|
+
})
|
|
4518
|
+
await settle(220)
|
|
4519
|
+
const grNode = id => grHost.querySelector(`[data-graphic-id=${id}]`)
|
|
4520
|
+
const grChildren = [...grView.el.children]
|
|
4521
|
+
const grCanvasIndex = grChildren.indexOf(grView.canvas)
|
|
4522
|
+
const grLayerIndex = grChildren.indexOf(grHost.querySelector('.gis-view__graphics'))
|
|
4523
|
+
const grLabelIndex = grChildren.indexOf(grHost.querySelector('.gis-view__labels'))
|
|
4524
|
+
check('扩展图形:初始化同时接受 path / image / canvas 三类,并生成对应 DOM',
|
|
4525
|
+
grNode('g-path')?.dataset.graphicType === 'path' && grNode('g-image')?.querySelector('img') instanceof HTMLImageElement && grNode('g-canvas')?.contains(grLiveCanvas) === true,
|
|
4526
|
+
['g-path', 'g-image', 'g-canvas'].map(id => grNode(id)?.dataset.graphicType ?? 'missing').join(' / '))
|
|
4527
|
+
check('扩展图形:DOM 顺序为 canvas → graphics → labels(图形压在要素上、标签下)',
|
|
4528
|
+
grCanvasIndex >= 0 && grCanvasIndex < grLayerIndex && grLayerIndex < grLabelIndex,
|
|
4529
|
+
JSON.stringify({ canvas: grCanvasIndex, graphics: grLayerIndex, labels: grLabelIndex }))
|
|
4530
|
+
const grPathNode = grNode('g-path')
|
|
4531
|
+
const grCanvasNode = grNode('g-canvas')
|
|
4532
|
+
const grBefore = {
|
|
4533
|
+
left: Number.parseFloat(grPathNode.style.left),
|
|
4534
|
+
width: Number.parseFloat(grPathNode.style.width),
|
|
4535
|
+
canvasWidth: Number.parseFloat(grCanvasNode.style.width)
|
|
4536
|
+
}
|
|
4537
|
+
const grCamera = grView.getCamera()
|
|
4538
|
+
grView.setCamera({ ...grCamera, center: [grCamera.center[0] + 20, grCamera.center[1]], scale: grCamera.scale * 2 })
|
|
4539
|
+
await settle(80)
|
|
4540
|
+
const grAfter = {
|
|
4541
|
+
left: Number.parseFloat(grPathNode.style.left),
|
|
4542
|
+
width: Number.parseFloat(grPathNode.style.width),
|
|
4543
|
+
canvasWidth: Number.parseFloat(grCanvasNode.style.width)
|
|
4544
|
+
}
|
|
4545
|
+
check('扩展图形:相机移动后重投影(屏幕位置跟着变)', grAfter.left !== grBefore.left, `${grBefore.left} → ${grAfter.left}`)
|
|
4546
|
+
check('扩展图形:默认尺寸保持屏幕像素,scaleWithView: true 时宽高随相机缩放',
|
|
4547
|
+
Math.abs(grAfter.width - grBefore.width) < 0.5 && Math.abs(grAfter.canvasWidth - grBefore.canvasWidth * 2) < 0.5,
|
|
4548
|
+
JSON.stringify({ path: [grBefore.width, grAfter.width], canvas: [grBefore.canvasWidth, grAfter.canvasWidth] }))
|
|
4549
|
+
const grScene = grView.snapshotScene({ background: false })
|
|
4550
|
+
check('扩展图形:snapshotScene 带 scene.graphics(屏幕坐标、尺寸、类型齐全)',
|
|
4551
|
+
grScene?.graphics?.length === 3 && grScene.graphics.every(item => typeof item.x === 'number' && typeof item.width === 'number') && grScene.graphics.some(item => item.type === 'path') && grScene.graphics.some(item => item.type === 'image') && grScene.graphics.some(item => item.type === 'canvas'),
|
|
4552
|
+
JSON.stringify(grScene?.graphics?.map(item => ({ id: item.id, type: item.type, width: item.width })) ?? null))
|
|
4553
|
+
const grDecodeSvg = url => {
|
|
4554
|
+
const base64 = String(url).slice('data:image/svg+xml;base64,'.length)
|
|
4555
|
+
return new TextDecoder().decode(Uint8Array.from(atob(base64), char => char.charCodeAt(0)))
|
|
4556
|
+
}
|
|
4557
|
+
const grSvg = grDecodeSvg(await grView.exportImage({ type: 'svg', includeLabels: false, background: 'none' }))
|
|
4558
|
+
check('扩展图形:SVG 导出包含路径与图片 / Canvas 的 <image>',
|
|
4559
|
+
grSvg.includes('M0 0H10V10H0Z') && (grSvg.match(/<image/g) ?? []).length >= 2,
|
|
4560
|
+
`path=${grSvg.includes('M0 0H10V10H0Z')} / image=${(grSvg.match(/<image/g) ?? []).length}`)
|
|
4561
|
+
const grPixelAt = async (url, x, y) => {
|
|
4562
|
+
const image = new Image()
|
|
4563
|
+
await new Promise((resolve, reject) => {
|
|
4564
|
+
image.onload = resolve
|
|
4565
|
+
image.onerror = () => reject(new Error('扩展图形导出图片加载失败'))
|
|
4566
|
+
image.src = url
|
|
4567
|
+
})
|
|
4568
|
+
const buffer = document.createElement('canvas')
|
|
4569
|
+
buffer.width = image.width
|
|
4570
|
+
buffer.height = image.height
|
|
4571
|
+
const context = buffer.getContext('2d')
|
|
4572
|
+
context.drawImage(image, 0, 0)
|
|
4573
|
+
return [...context.getImageData(Math.round(x), Math.round(y), 1, 1).data]
|
|
4574
|
+
}
|
|
4575
|
+
const grPoint = grView.project(0, 0)
|
|
4576
|
+
const grPixel = await grPixelAt(await grView.exportImage({ background: 'none', includeLabels: false, scale: 1 }), grPoint[0], grPoint[1])
|
|
4577
|
+
check('扩展图形:PNG 导出按「画布 → 图形 → 标签」次序合成(路径像素真的进了图)',
|
|
4578
|
+
grPixel[0] > 200 && grPixel[1] < 80 && grPixel[2] < 80 && grPixel[3] > 200,
|
|
4579
|
+
`rgba(${grPixel.join(',')})`)
|
|
4580
|
+
const grAdded = grView.addGraphic({ id: 'g-dyn', type: 'path', x: 0, y: 100, width: 20, height: 20, viewBox: [0, 0, 10, 10], d: 'M0 0H10V10H0Z', fill: '#3355ff', zIndex: 9 })
|
|
4581
|
+
const grBulk = grView.addGraphics([{ id: 'g-low', type: 'path', x: 0, y: -100, width: 20, height: 20, viewBox: [0, 0, 10, 10], d: 'M0 0H10V10H0Z', fill: '#999999', zIndex: -5 }])
|
|
4582
|
+
const grUpdated = grView.updateGraphic('g-dyn', { style: { width: 50, height: 30, fill: '#00aa00' } })
|
|
4583
|
+
const grBadType = grView.addGraphic({ id: 'g-bad', type: 'triangle', x: 0, y: 0, width: 10, height: 10, d: 'M0 0H10V10Z' })
|
|
4584
|
+
const grDuplicate = grView.addGraphics([{ id: 'g-low', type: 'path', x: 0, y: -100, width: 24, height: 20, viewBox: [0, 0, 10, 10], d: 'M0 0H10V10H0Z', fill: '#777777', zIndex: -4 }])
|
|
4585
|
+
const grOrdered = grView.getGraphics()
|
|
4586
|
+
check('扩展图形:addGraphic / addGraphics / updateGraphic / getGraphic 都能用(style.width / height 也能改)',
|
|
4587
|
+
grAdded?.id === 'g-dyn' && grBulk.length === 1 && grUpdated?.width === 50 && grUpdated?.height === 30 && grUpdated?.fill === '#00aa00' && grView.getGraphic('g-image')?.type === 'image' && grView.getGraphic('missing') === null,
|
|
4588
|
+
JSON.stringify({ added: grAdded?.id, bulk: grBulk.length, updated: grUpdated && { width: grUpdated.width, height: grUpdated.height, fill: grUpdated.fill } }))
|
|
4589
|
+
check('扩展图形:显式写错的 type 不静默按 path 处理,跳过并给出 warning', grBadType === null && grView.getGraphic('g-bad') === null && grWarns.some(message => message.includes('triangle') && message.includes('不支持')), grWarns.join(' | '))
|
|
4590
|
+
check('扩展图形:addGraphics 里重复 id 按更新覆盖并点名 warning', grDuplicate.length === 1 && grView.getGraphic('g-low')?.fill === '#777777' && grWarns.some(message => message.includes('addGraphics') && message.includes('g-low')), JSON.stringify({ count: grDuplicate.length, fill: grView.getGraphic('g-low')?.fill }))
|
|
4591
|
+
check('扩展图形:getGraphics 按 zIndex、再按加入顺序排', grOrdered[0]?.id === 'g-low' && grOrdered[grOrdered.length - 1]?.id === 'g-dyn', grOrdered.map(item => `${item.id}:${item.zIndex}`).join(' / '))
|
|
4592
|
+
const grRemoved = grView.removeGraphic('g-dyn')
|
|
4593
|
+
const grRemovedBulk = grView.removeGraphic('g-low')
|
|
4594
|
+
const grMissing = grView.removeGraphic('missing')
|
|
4595
|
+
const grCleared = grView.clearGraphics()
|
|
4596
|
+
check('扩展图形:removeGraphic / clearGraphics 返回值与清空结果一致',
|
|
4597
|
+
grRemoved?.id === 'g-dyn' && grRemovedBulk?.id === 'g-low' && grMissing === null && grCleared === 3 && grView.getGraphics().length === 0,
|
|
4598
|
+
JSON.stringify({ removed: grRemoved?.id, removedBulk: grRemovedBulk?.id, missing: grMissing, cleared: grCleared }))
|
|
4599
|
+
grView.updateOptions({ graphics: grBase })
|
|
4600
|
+
await settle(120)
|
|
4601
|
+
check('扩展图形:运行时清空后再传回同一份初始数组仍能恢复(配置来源不会因同一引用短路)',
|
|
4602
|
+
grView.getGraphics().length === 3 && Boolean(grNode('g-path')) && Boolean(grNode('g-image')) && Boolean(grNode('g-canvas')),
|
|
4603
|
+
`${grView.getGraphics().length} 条 / DOM ${grHost.querySelectorAll('.gis-view__graphic').length} 个`)
|
|
4604
|
+
grView.destroy()
|
|
4605
|
+
grHost.remove()
|
|
4606
|
+
|
|
4607
|
+
/* 这一轮新增:通道草稿样式 / 多回线预览 / 选起点后点空白取消 / WebGL 自定义层 */
|
|
4608
|
+
const { channelDraftArrowPlacement } = await import('../../src/gis-view/engine.js')
|
|
4609
|
+
const arrowQuarter = channelDraftArrowPlacement([[0, 0], [100, 0]], 0.25)
|
|
4610
|
+
const arrowDefault = channelDraftArrowPlacement([[0, 0], [100, 0]])
|
|
4611
|
+
const arrowClamped = channelDraftArrowPlacement([[0, 0], [100, 0]], 2)
|
|
4612
|
+
check('草稿箭头位置按弧长比例取点(25% / 缺省 50% / 越界夹到端点)',
|
|
4613
|
+
Math.abs(arrowQuarter?.center[0] - 25) < 1e-9 && Math.abs(arrowDefault?.center[0] - 50) < 1e-9 && Math.abs(arrowClamped?.center[0] - 100) < 1e-9 && arrowQuarter.unitX === 1,
|
|
4614
|
+
JSON.stringify({ quarter: arrowQuarter?.center, center: arrowDefault?.center, end: arrowClamped?.center }))
|
|
4615
|
+
|
|
4616
|
+
const draftHost = document.createElement('div')
|
|
4617
|
+
draftHost.style.cssText = 'width:520px;height:340px'
|
|
4618
|
+
document.body.appendChild(draftHost)
|
|
4619
|
+
const draftEvents = []
|
|
4620
|
+
const draftClicks = []
|
|
4621
|
+
const draftDraws = []
|
|
4622
|
+
const draftErrors = []
|
|
4623
|
+
const draftCustomDraw = (context) => {
|
|
4624
|
+
draftDraws.push(context)
|
|
4625
|
+
// 故意把 GL 状态改坏:组件应在 customDraw 返回后收回内置绘制依赖的状态
|
|
4626
|
+
context.gl.enable(context.gl.SCISSOR_TEST)
|
|
4627
|
+
context.gl.scissor(0, 0, 1, 1)
|
|
4628
|
+
context.gl.viewport(1, 1, 1, 1)
|
|
4629
|
+
context.gl.disable(context.gl.BLEND)
|
|
4630
|
+
}
|
|
4631
|
+
const draftView = createGisView(draftHost, {
|
|
4632
|
+
points: [{ id: 'd-a', x: 0, y: 0 }, { id: 'd-b', x: 180, y: 0 }, { id: 'd-c', x: 0, y: 140 }],
|
|
4633
|
+
lines: [],
|
|
4634
|
+
fitPadding: 70,
|
|
4635
|
+
showGrid: false,
|
|
4636
|
+
features: { channelDraft: true },
|
|
4637
|
+
onChannelDraft: payload => draftEvents.push(payload),
|
|
4638
|
+
onChannelDraftClick: payload => draftClicks.push(payload),
|
|
4639
|
+
onError: message => draftErrors.push(String(message))
|
|
4640
|
+
})
|
|
4641
|
+
await settle(150)
|
|
4642
|
+
const draftCanvas = draftView.canvas
|
|
4643
|
+
const dispatchDraftPointer = (type, x, y) => {
|
|
4644
|
+
const screen = draftView.project(x, y)
|
|
4645
|
+
const rect = draftCanvas.getBoundingClientRect()
|
|
4646
|
+
draftCanvas.dispatchEvent(new PointerEvent(type, {
|
|
4647
|
+
bubbles: true,
|
|
4648
|
+
cancelable: true,
|
|
4649
|
+
composed: true,
|
|
4650
|
+
pointerId: 19,
|
|
4651
|
+
pointerType: 'mouse',
|
|
4652
|
+
isPrimary: true,
|
|
4653
|
+
button: 0,
|
|
4654
|
+
clientX: rect.left + screen[0],
|
|
4655
|
+
clientY: rect.top + screen[1]
|
|
4656
|
+
}))
|
|
4657
|
+
}
|
|
4658
|
+
const clickDraftWorld = async (x, y) => {
|
|
4659
|
+
dispatchDraftPointer('pointerdown', x, y)
|
|
4660
|
+
dispatchDraftPointer('pointerup', x, y)
|
|
4661
|
+
await settle(40)
|
|
4662
|
+
}
|
|
4663
|
+
draftView.beginAddChannel({
|
|
4664
|
+
circuits: 3,
|
|
4665
|
+
routing: 'orthogonal',
|
|
4666
|
+
channelDraftStyle: {
|
|
4667
|
+
color: '#1456d8',
|
|
4668
|
+
width: 3,
|
|
4669
|
+
dot: 3,
|
|
4670
|
+
dotColor: '#e58a2b',
|
|
4671
|
+
arrow: true,
|
|
4672
|
+
arrowSize: 15,
|
|
4673
|
+
arrowPositions: [0.25, 0.75],
|
|
4674
|
+
arrowReverse: true,
|
|
4675
|
+
arrowColor: '#128457',
|
|
4676
|
+
circuitSpacing: 18,
|
|
4677
|
+
opacity: 0.65,
|
|
4678
|
+
customDraw: draftCustomDraw
|
|
4679
|
+
}
|
|
4680
|
+
})
|
|
4681
|
+
const draftStart = draftView.getAddChannelDraft()
|
|
4682
|
+
check('beginAddChannel 接收本次草稿完整样式,3 回通道与箭头位置都进载荷',
|
|
4683
|
+
draftStart?.phase === 'start' && draftStart.circuits === 3 && draftStart.style?.color === '#1456d8' && draftStart.style?.dotColor === '#e58a2b' && draftStart.style?.arrow === true && draftStart.style?.arrowReverse === true && draftStart.style?.arrowColor === '#128457' && draftStart.style?.circuitSpacing === 18 && draftStart.style?.opacity === 0.65 && draftStart.style?.arrowPositions.join(',') === '0.25,0.75' && draftStart.style?.customDraw === draftCustomDraw,
|
|
4684
|
+
JSON.stringify(draftStart?.style))
|
|
4685
|
+
|
|
4686
|
+
await clickDraftWorld(0, 0)
|
|
4687
|
+
const styleReturn = draftView.updateAddChannelStyle({ arrowPositions: [0.15, 0.5, 0.85], circuitSpacing: 24, opacity: 0.5 })
|
|
4688
|
+
dispatchDraftPointer('pointermove', 110, 100)
|
|
4689
|
+
await settle(30)
|
|
4690
|
+
const draftStyled = draftView.getAddChannelDraft()
|
|
4691
|
+
check('updateAddChannelStyle 字段级合并箭头位置 / 回线间距 / 透明度,并保持链式返回',
|
|
4692
|
+
styleReturn === draftView && draftStyled?.phase === 'from' && draftStyled.style.arrowPositions.join(',') === '0.15,0.5,0.85' && draftStyled.style.circuitSpacing === 24 && draftStyled.style.opacity === 0.5 && draftStyled.style.color === '#1456d8',
|
|
4693
|
+
JSON.stringify(draftStyled?.style))
|
|
4694
|
+
|
|
4695
|
+
draftDraws.length = 0
|
|
4696
|
+
await draftView.exportImage({ background: 'none', includeLabels: false, scale: 1 })
|
|
4697
|
+
const draftDraw = draftDraws.at(-1)
|
|
4698
|
+
const draftStarts = new Set((draftDraw?.circuitPaths ?? []).map(path => `${path[0]?.[0]?.toFixed(3)},${path[0]?.[1]?.toFixed(3)}`))
|
|
4699
|
+
check('customDraw 拿到最终 GL / 相机 / 完整路径与 3 条平行回线,可完全接管预览绘制',
|
|
4700
|
+
draftDraws.length > 0 && draftDraw?.gl === draftView.gl && draftDraw?.canvas === draftCanvas && draftDraw?.circuits === 3 && draftDraw?.circuitPaths.length === 3 && draftStarts.size === 3 && draftDraw?.path.length >= 2 && draftDraw?.kind === 'channel' && draftDraw?.phase === 'from' && draftDraw?.style.arrowPositions.join(',') === '0.15,0.5,0.85' && draftErrors.length === 0,
|
|
4701
|
+
JSON.stringify({ draws: draftDraws.length, circuits: draftDraw?.circuits, starts: [...draftStarts], path: draftDraw?.path?.length, errors: draftErrors }))
|
|
4702
|
+
|
|
4703
|
+
const draftResetReturn = draftView.updateAddChannelStyle(null)
|
|
4704
|
+
const draftReset = draftView.getAddChannelDraft()
|
|
4705
|
+
check('updateAddChannelStyle(null) 回到全局缺省样式(箭头关、单中点位置、间距 10)',
|
|
4706
|
+
draftResetReturn === draftView && draftReset?.style.arrow === false && draftReset.style.arrowPositions.join(',') === '0.5' && draftReset.style.circuitSpacing === 10 && draftReset.style.opacity === 1 && typeof draftReset.style.customDraw === 'undefined',
|
|
4707
|
+
JSON.stringify(draftReset?.style))
|
|
4708
|
+
|
|
4709
|
+
const draftDataBeforeCancel = draftView.getData()
|
|
4710
|
+
draftEvents.length = 0
|
|
4711
|
+
draftClicks.length = 0
|
|
4712
|
+
await clickDraftWorld(110, 100)
|
|
4713
|
+
const draftCancel = draftEvents.find(payload => payload.phase === 'cancel')
|
|
4714
|
+
const draftCancelClick = draftClicks.at(-1)
|
|
4715
|
+
check('已选起点后点节点以外的位置直接取消:草稿清空、cancel 同时给 onChannelDraft 与 onChannelDraftClick',
|
|
4716
|
+
draftView.getAddChannelDraft() === null && draftCancel?.reason === 'click-outside-node' && draftCancel?.hit === false && draftCancelClick?.phase === 'cancel' && draftCancelClick?.reason === 'click-outside-node' && draftView.getData().lines.length === draftDataBeforeCancel.lines.length,
|
|
4717
|
+
JSON.stringify({ draft: draftView.getAddChannelDraft(), event: draftCancel?.reason, click: draftCancelClick?.reason }))
|
|
4718
|
+
|
|
4719
|
+
draftView.beginAddChannel({ circuits: 2 })
|
|
4720
|
+
draftEvents.length = 0
|
|
4721
|
+
draftClicks.length = 0
|
|
4722
|
+
await clickDraftWorld(110, 100)
|
|
4723
|
+
check('还没选起点时点空白仍保持草稿并发送 pick(不会误取消)',
|
|
4724
|
+
draftView.getAddChannelDraft()?.phase === 'start' && draftClicks.at(-1)?.phase === 'pick' && draftClicks.at(-1)?.hit === false && !draftEvents.some(payload => payload.phase === 'cancel'),
|
|
4725
|
+
JSON.stringify({ draft: draftView.getAddChannelDraft()?.phase, click: draftClicks.at(-1)?.phase, events: draftEvents.map(payload => payload.phase) }))
|
|
4726
|
+
draftView.cancelAddChannel()
|
|
4727
|
+
|
|
4728
|
+
/* WebGL 自定义层:最终画布、排序 / 开关 / 卸载,以及每层开画前的状态重置 */
|
|
4729
|
+
let lowLayerCalls = 0
|
|
4730
|
+
let highLayerCalls = 0
|
|
4731
|
+
let highLayerState = null
|
|
4732
|
+
draftView.addWebGLLayer({
|
|
4733
|
+
id: 'test-high',
|
|
4734
|
+
order: 20,
|
|
4735
|
+
draw: ({ gl }) => {
|
|
4736
|
+
highLayerCalls += 1
|
|
4737
|
+
highLayerState = {
|
|
4738
|
+
scissor: gl.isEnabled(gl.SCISSOR_TEST),
|
|
4739
|
+
blend: gl.isEnabled(gl.BLEND),
|
|
4740
|
+
viewport: Array.from(gl.getParameter(gl.VIEWPORT)),
|
|
4741
|
+
framebuffer: gl.getParameter(gl.FRAMEBUFFER_BINDING)
|
|
4742
|
+
}
|
|
4743
|
+
}
|
|
4744
|
+
})
|
|
4745
|
+
draftView.addWebGLLayer({
|
|
4746
|
+
id: 'test-low',
|
|
4747
|
+
order: 10,
|
|
4748
|
+
draw: ({ gl }) => {
|
|
4749
|
+
lowLayerCalls += 1
|
|
4750
|
+
gl.enable(gl.SCISSOR_TEST)
|
|
4751
|
+
gl.scissor(0, 0, 2, 2)
|
|
4752
|
+
gl.viewport(3, 3, 4, 4)
|
|
4753
|
+
gl.disable(gl.BLEND)
|
|
4754
|
+
}
|
|
4755
|
+
})
|
|
4756
|
+
const layerOrder = draftView.getWebGLLayers()
|
|
4757
|
+
check('view.gl / addWebGLLayer / getWebGLLayers 可用,层按 order 排序(同 id 可覆盖)',
|
|
4758
|
+
typeof WebGL2RenderingContext !== 'undefined' && draftView.gl instanceof WebGL2RenderingContext && layerOrder.map(layer => layer.id).join(',') === 'test-low,test-high' && layerOrder.every(layer => typeof layer.draw === 'function') && draftView.getOptions().webglLayers.map(layer => layer.id).join(',') === 'test-low,test-high',
|
|
4759
|
+
JSON.stringify({ gl: Boolean(draftView.gl), order: layerOrder.map(layer => `${layer.id}:${layer.order}`), options: draftView.getOptions().webglLayers?.map(layer => layer.id) }))
|
|
4760
|
+
|
|
4761
|
+
await draftView.exportImage({ background: 'none', includeLabels: false, scale: 1 })
|
|
4762
|
+
check('自定义层在内置内容之后执行;前一层改坏的 scissor / viewport / blend 不会漏给下一层',
|
|
4763
|
+
lowLayerCalls > 0 && highLayerCalls > 0 && highLayerState?.scissor === false && highLayerState?.blend === true && highLayerState?.framebuffer === null && highLayerState?.viewport.join(',') === [0, 0, draftCanvas.width, draftCanvas.height].join(','),
|
|
4764
|
+
JSON.stringify({ low: lowLayerCalls, high: highLayerCalls, state: highLayerState }))
|
|
4765
|
+
|
|
4766
|
+
const lowBeforeDisabled = lowLayerCalls
|
|
4767
|
+
const highBeforeDisabled = highLayerCalls
|
|
4768
|
+
const disabledLayer = draftView.updateWebGLLayer('test-low', { enabled: false })
|
|
4769
|
+
await draftView.exportImage({ background: 'none', includeLabels: false, scale: 1 })
|
|
4770
|
+
check('enabled: false 只跳过这一层,其它层照常绘制',
|
|
4771
|
+
disabledLayer?.enabled === false && lowLayerCalls === lowBeforeDisabled && highLayerCalls > highBeforeDisabled,
|
|
4772
|
+
JSON.stringify({ low: [lowBeforeDisabled, lowLayerCalls], high: [highBeforeDisabled, highLayerCalls] }))
|
|
4773
|
+
|
|
4774
|
+
const reenabled = draftView.updateWebGLLayer('test-low', { enabled: true, order: 40 })
|
|
4775
|
+
await draftView.exportImage({ background: 'none', includeLabels: false, scale: 1 })
|
|
4776
|
+
draftView.updateWebGLLayer('test-high', { order: 50 })
|
|
4777
|
+
check('updateWebGLLayer 可原地改 enabled / order,排序马上反映在 getWebGLLayers',
|
|
4778
|
+
reenabled?.enabled === true && reenabled.order === 40 && draftView.getWebGLLayers().map(layer => `${layer.id}:${layer.order}`).join(',') === 'test-low:40,test-high:50',
|
|
4779
|
+
JSON.stringify(draftView.getWebGLLayers().map(layer => `${layer.id}:${layer.order}`)))
|
|
4780
|
+
|
|
4781
|
+
const removedLow = draftView.removeWebGLLayer('test-low')
|
|
4782
|
+
const missingLayer = draftView.updateWebGLLayer('missing', { order: 1 })
|
|
4783
|
+
const unsubscribe = draftView.addWebGLLayer({ id: 'test-off', order: 5, draw: () => {} })
|
|
4784
|
+
const offAdded = draftView.getWebGLLayers().some(layer => layer.id === 'test-off')
|
|
4785
|
+
unsubscribe()
|
|
4786
|
+
check('removeWebGLLayer / addWebGLLayer 的卸载函数 / 不存在的 id 都按接口约定返回',
|
|
4787
|
+
removedLow?.id === 'test-low' && missingLayer === null && draftView.removeWebGLLayer('missing') === null && offAdded && !draftView.getWebGLLayers().some(layer => layer.id === 'test-off'),
|
|
4788
|
+
JSON.stringify({ removed: removedLow?.id, missing: missingLayer, offAdded, layers: draftView.getWebGLLayers().map(layer => layer.id) }))
|
|
4789
|
+
|
|
4790
|
+
const staleUnload = draftView.addWebGLLayer({ id: 'test-replaced', order: 6, draw: () => {} })
|
|
4791
|
+
const replacementDraw = () => {}
|
|
4792
|
+
draftView.addWebGLLayer({ id: 'test-replaced', order: 6, draw: replacementDraw })
|
|
4793
|
+
staleUnload()
|
|
4794
|
+
const replacedLayer = draftView.getWebGLLayers().find(layer => layer.id === 'test-replaced')
|
|
4795
|
+
check('同 id 的 WebGL 层被覆盖后,旧卸载函数不会误删新层',
|
|
4796
|
+
replacedLayer?.draw === replacementDraw && (draftView.getOptions().webglLayers ?? []).some(layer => layer.id === 'test-replaced'),
|
|
4797
|
+
JSON.stringify({ layers: draftView.getWebGLLayers().map(layer => layer.id), options: draftView.getOptions().webglLayers?.map(layer => layer.id) }))
|
|
4798
|
+
draftView.removeWebGLLayer('test-replaced')
|
|
4799
|
+
|
|
4800
|
+
const clearedLayers = draftView.clearWebGLLayers()
|
|
4801
|
+
check('clearWebGLLayers 清空并同步 getOptions().webglLayers;requestRender 可链式调用',
|
|
4802
|
+
clearedLayers === 1 && draftView.getWebGLLayers().length === 0 && (draftView.getOptions().webglLayers ?? []).length === 0 && draftView.requestRender() === draftView,
|
|
4803
|
+
JSON.stringify({ cleared: clearedLayers, layers: draftView.getWebGLLayers().length, options: draftView.getOptions().webglLayers?.length }))
|
|
4804
|
+
draftView.destroy()
|
|
4805
|
+
draftHost.remove()
|
|
4347
4806
|
auView.destroy()
|
|
4348
4807
|
auHost.remove()
|
|
4349
4808
|
symView.destroy()
|