gis-view-webgl2 0.1.4 → 0.1.5

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.
Files changed (30) hide show
  1. package/README.md +7 -7
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.d.ts +140 -20
  4. package/dist/index.js +1 -1
  5. package/docs/AI/345/257/271/350/257/235/346/261/207/346/200/273.md +45 -0
  6. package/docs/GisView.md +53 -53
  7. 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 +36 -0
  8. package/docs/demos/ConnectDemo.vue +114 -3
  9. package/docs/demos/MinimapDemo.vue +62 -16
  10. package/docs/demos/api-index.js +15 -14
  11. package/docs/demos/gis-view-demo/GisViewDemoStage.vue +25 -16
  12. package/docs/demos/gis-view-demo/useGisViewDemo.js +27 -16
  13. package/docs/index.html +3 -3
  14. package/docs/internals/13-/351/271/260/347/234/274/345/233/276.md +6 -5
  15. package/docs/internals/16-01-/344/274/230/345/214/226/344/270/216/345/217/226/350/210/215-/344/270/212.md +5 -3
  16. package/docs/internals/18-/346/200/247/350/203/275/345/256/236/346/265/213/344/270/216WebGPU/350/257/204/344/274/260.md +12 -0
  17. package/docs/manual/03-/351/205/215/347/275/256/351/241/271.md +11 -3
  18. package/docs/manual/09-/351/200/232/351/201/223/344/270/216/345/244/232/345/233/236/347/272/277.md +1 -1
  19. 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 +423 -3
  20. package/docs/manual/14-/350/247/206/345/233/276/344/270/216/347/255/233/351/200/211.md +79 -28
  21. package/docs/manual/16-/345/256/236/344/276/213/346/226/271/346/263/225/346/200/273/350/241/250.md +6 -5
  22. package/docs/manual/17-/345/217/202/346/225/260/351/200/237/346/237/245.md +5 -4
  23. package/docs/manual/18-/351/200/220/346/226/271/346/263/225/347/244/272/344/276/213.md +117 -5
  24. 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 +5 -2
  25. package/docs/steps/README.md +5 -5
  26. package/docs/steps/selftest-demos.html +149 -5
  27. package/docs/steps/selftest-docs.html +3 -3
  28. package/docs/steps/selftest-full.html +315 -12
  29. package/docs/steps/selftest-perf.html +39 -1
  30. package/package.json +1 -1
@@ -192,8 +192,8 @@
192
192
  await settleFrames()
193
193
  const fillAuto = minimapFill()
194
194
  check('鹰眼图 extent: auto 把远离数据的 GeoJSON 一起框进来', fillAuto > 100 && fillAuto > fillData + 100, `data=${fillData} auto=${fillAuto}`)
195
- // 反过来:底图小到在合并范围里只剩一两个像素、而相机正好落在里面时,auto 以它为准 ——
196
- // 正在看的主体不该因为另一套坐标离得远就被压成一个点(数据还没映射到底图时常是这种情况)
195
+ // 反过来:底图小到在合并范围里只剩一两个像素、而相机正好落在里面时,默认仍按并集铺;
196
+ // 显式打开 extentFollowCamera 后,auto 才以正在看的那一份为准。
197
197
  const tinyHost = document.createElement('div')
198
198
  tinyHost.style.cssText = 'position:fixed;left:-9999px;top:0;width:420px;height:320px'
199
199
  document.body.appendChild(tinyHost)
@@ -210,12 +210,20 @@
210
210
  minimap: { width: 200, height: 160, extent: 'auto' }
211
211
  })
212
212
  await settleFrames()
213
- const fillSquashed = minimapFill(tinyHost)
214
- tinyView.zoomToBounds({ minX: 100, minY: 20, maxX: 101, maxY: 21 })
215
- await settleFrames()
216
- const fillFocused = minimapFill(tinyHost)
217
- check('鹰眼图 extent: auto 在相机落进小范围时以它为准', fillFocused > 200 && fillFocused > fillSquashed + 200, `squashed=${fillSquashed} focused=${fillFocused}`)
218
- // 这一轮:沿用主图规则取描边色(不再是白点)、小图尺寸跟随主视图地图倍数、框与框选矩形的样式
213
+ const fillSquashed = minimapFill(tinyHost)
214
+ tinyView.zoomToBounds({ minX: 100, minY: 20, maxX: 101, maxY: 21 })
215
+ await settleFrames()
216
+ const fillDefault = minimapFill(tinyHost)
217
+ check('鹰眼图 extent: auto 默认不随相机收窄(外围内容消失后包围盒保持并集)',
218
+ (tinyView.getOptions().minimap.extentFollowCamera ?? false) === false && fillDefault > 0 && Math.abs(fillDefault - fillSquashed) < 40,
219
+ `squashed=${fillSquashed} default=${fillDefault}`)
220
+ tinyView.updateOptions({ minimap: { ...tinyView.getOptions().minimap, extentFollowCamera: true } })
221
+ await settleFrames()
222
+ const fillFocused = minimapFill(tinyHost)
223
+ check('鹰眼图 extent: 打开 extentFollowCamera 后,相机落进小范围时 auto 以它为准',
224
+ tinyView.getOptions().minimap.extentFollowCamera === true && fillFocused > 200 && fillFocused > fillSquashed + 200,
225
+ `squashed=${fillSquashed} focused=${fillFocused}`)
226
+ // 这一轮:沿用主图规则取描边色(不再是白点)、继承尺寸不受主视图地图倍数影响、框与框选矩形的样式
219
227
  const ruleHost = document.createElement('div')
220
228
  ruleHost.style.cssText = 'position:fixed;left:-9999px;top:0;width:420px;height:320px'
221
229
  document.body.appendChild(ruleHost)
@@ -254,7 +262,11 @@
254
262
  ruleView.zoomTo(ruleView.getCamera().scale * 3, [210, 160])
255
263
  await settleFrames()
256
264
  const redZoomed = minimapRed()
257
- check('鹰眼图节点跟随主视图地图倍数放大', redZoomed > redBefore * 2, `${redBefore} → ${redZoomed}`)
265
+ check(
266
+ '鹰眼图沿用主图规则时主图放大不改变节点尺寸(pointMapZoomScale 也不参与继承)',
267
+ redBefore > 0 && Math.abs(redZoomed - redBefore) <= 2,
268
+ `${redBefore} → ${redZoomed}`
269
+ )
258
270
  const boxElement = ruleHost.querySelector('.gis-view__minimap-box')
259
271
  const boxComputed = getComputedStyle(boxElement)
260
272
  check(
@@ -319,9 +331,113 @@
319
331
  bgRedBefore > 0 && Math.abs(bgRedAfter - bgRedBefore) <= Math.max(bgRedBefore * 0.2, 2),
320
332
  `主图放大 3 倍前后小图红点像素 ${bgRedBefore} → ${bgRedAfter}`
321
333
  )
322
- bgView.destroy()
323
- bgHost.remove()
324
- // 这一轮:小图自身倍数的联动指数(pointZoomScale)真的生效 —— 放大鹰眼图 6 倍,节点半径按 6^指数 长
334
+ bgView.destroy()
335
+ bgHost.remove()
336
+ // 这一轮:沿用主图规则时线路线宽也只跟视口比例走 —— 主图放大不变,小图自身放大才按 lineZoomScale 变
337
+ const lineHost = document.createElement('div')
338
+ lineHost.style.cssText = 'position:fixed;left:-9999px;top:0;width:420px;height:320px'
339
+ document.body.appendChild(lineHost)
340
+ const lineView = createGisView(lineHost, {
341
+ points: [{ id: 'a', x: 0, y: 50 }, { id: 'b', x: 100, y: 50 }],
342
+ lines: [{ id: 'l', from: 'a', to: 'b' }],
343
+ background: false,
344
+ pointStyle: { size: 1, color: '#00aa00' },
345
+ lineStyle: { width: 8, color: '#ff3200', opacity: 1 },
346
+ minimap: {
347
+ width: 200,
348
+ height: 160,
349
+ background: false,
350
+ lineStyle: { color: '#ff3200', width: 1, opacity: 1 },
351
+ inheritRules: true,
352
+ pointMapZoomScale: 1,
353
+ lineMapZoomScale: 1,
354
+ lineZoomScale: 1,
355
+ maxZoom: 8
356
+ }
357
+ })
358
+ await settleFrames()
359
+ const lineBefore = minimapRedIn(lineHost)
360
+ lineView.zoomTo(lineView.getCamera().scale * 3, [210, 160])
361
+ await settleFrames()
362
+ const lineAfterMainZoom = minimapRedIn(lineHost)
363
+ check(
364
+ '鹰眼图沿用主图线宽时主图放大不改变线路宽度(lineMapZoomScale 也不参与继承)',
365
+ lineBefore > 20 && Math.abs(lineAfterMainZoom - lineBefore) <= 2,
366
+ `${lineBefore} → ${lineAfterMainZoom}`
367
+ )
368
+ lineView.updateOptions({ minimap: { ...lineView.getOptions().minimap, lineWidthScale: 2 } })
369
+ await settleFrames()
370
+ const lineWidthScaled = minimapRedIn(lineHost)
371
+ check(
372
+ '鹰眼图线路整体倍数 lineWidthScale 对继承线路生效',
373
+ lineWidthScaled > lineAfterMainZoom * 1.5,
374
+ `${lineAfterMainZoom} → ${lineWidthScaled}`
375
+ )
376
+ lineView.updateOptions({ minimap: { ...lineView.getOptions().minimap, lineWidthScale: 1 } })
377
+ await settleFrames()
378
+ lineView.setMinimapZoom(2)
379
+ await settleFrames()
380
+ const lineAfterMiniZoom = minimapRedIn(lineHost)
381
+ check(
382
+ '鹰眼图自身放大时沿用主图的线路按 lineZoomScale 变粗',
383
+ lineAfterMiniZoom > lineAfterMainZoom * 1.6,
384
+ `${lineAfterMainZoom} → ${lineAfterMiniZoom}`
385
+ )
386
+ lineView.destroy()
387
+ lineHost.remove()
388
+ // 沿用主图的节点:主图放大不变,小图自身放大时按 pointZoomScale 变大(pointMapZoomScale 不参与继承)
389
+ const inheritedPointHost = document.createElement('div')
390
+ inheritedPointHost.style.cssText = 'position:fixed;left:-9999px;top:0;width:420px;height:320px'
391
+ document.body.appendChild(inheritedPointHost)
392
+ const inheritedPointView = createGisView(inheritedPointHost, {
393
+ points: [{ id: 'a', x: 45, y: 50 }, { id: 'b', x: 55, y: 50 }],
394
+ lines: [{ id: 'l', from: 'a', to: 'b' }],
395
+ background: false,
396
+ pointStyle: { size: 10, color: '#ff3200' },
397
+ lineStyle: { width: 1.5, color: '#00aa00' },
398
+ minimap: {
399
+ width: 200,
400
+ height: 160,
401
+ background: false,
402
+ extent: { minX: 0, minY: 0, maxX: 100, maxY: 100 },
403
+ inheritRules: true,
404
+ pointZoomScale: 1,
405
+ pointMapZoomScale: 1,
406
+ zoomable: true,
407
+ maxZoom: 8
408
+ }
409
+ })
410
+ await settleFrames()
411
+ const inheritedPointBefore = minimapRedIn(inheritedPointHost)
412
+ inheritedPointView.zoomTo(inheritedPointView.getCamera().scale * 3, [210, 160])
413
+ await settleFrames()
414
+ const inheritedPointAfterMainZoom = minimapRedIn(inheritedPointHost)
415
+ check(
416
+ '鹰眼图沿用主图节点时主图放大不改变节点大小(pointMapZoomScale 也不参与继承)',
417
+ inheritedPointBefore > 10 && Math.abs(inheritedPointAfterMainZoom - inheritedPointBefore) <= 2,
418
+ `${inheritedPointBefore} → ${inheritedPointAfterMainZoom}`
419
+ )
420
+ inheritedPointView.updateOptions({ minimap: { ...inheritedPointView.getOptions().minimap, pointSizeScale: 2 } })
421
+ await settleFrames()
422
+ const inheritedPointSizeScaled = minimapRedIn(inheritedPointHost)
423
+ check(
424
+ '鹰眼图节点整体倍数 pointSizeScale 对继承节点生效',
425
+ inheritedPointSizeScaled > inheritedPointAfterMainZoom * 2,
426
+ `${inheritedPointAfterMainZoom} → ${inheritedPointSizeScaled}`
427
+ )
428
+ inheritedPointView.updateOptions({ minimap: { ...inheritedPointView.getOptions().minimap, pointSizeScale: 1 } })
429
+ await settleFrames()
430
+ inheritedPointView.setMinimapZoom(2)
431
+ await settleFrames()
432
+ const inheritedPointAfterMiniZoom = minimapRedIn(inheritedPointHost)
433
+ check(
434
+ '鹰眼图自身放大时沿用主图的节点按 pointZoomScale 变大',
435
+ inheritedPointAfterMiniZoom > inheritedPointAfterMainZoom * 2,
436
+ `${inheritedPointAfterMainZoom} → ${inheritedPointAfterMiniZoom}`
437
+ )
438
+ inheritedPointView.destroy()
439
+ inheritedPointHost.remove()
440
+ // 这一轮:小图自身倍数的联动指数(pointZoomScale)真的生效 —— 放大鹰眼图 6 倍,节点半径按 6^指数 长
325
441
  const zoomHost = document.createElement('div')
326
442
  zoomHost.style.cssText = 'position:fixed;left:-9999px;top:0;width:420px;height:320px'
327
443
  document.body.appendChild(zoomHost)
@@ -458,6 +574,193 @@
458
574
  )
459
575
  extraView.destroy()
460
576
  extraHost.remove()
577
+ // 本轮鹰眼图五项:回线居中、动态位移、backgroundStyle、主图尺寸 / 图标、外部挂载
578
+ const circuitHost = document.createElement('div')
579
+ circuitHost.style.cssText = 'position:fixed;left:-9999px;top:0;width:420px;height:320px'
580
+ document.body.appendChild(circuitHost)
581
+ let circuitLines = []
582
+ const circuitView = createGisView(circuitHost, {
583
+ points: [{ id: 'ca', x: 0, y: 0 }, { id: 'cb', x: 100, y: 0 }],
584
+ lines: [
585
+ { id: 'cl1', from: 'ca', to: 'cb' },
586
+ { id: 'cl2', from: 'ca', to: 'cb' }
587
+ ],
588
+ channels: [{ id: 'cch', from: 'ca', to: 'cb', lineIds: ['cl1', 'cl2'] }],
589
+ background: false,
590
+ minimap: {
591
+ width: 200,
592
+ height: 150,
593
+ background: false,
594
+ channelCircuits: true,
595
+ boxStyle: { fillOpacity: 0, strokeWidth: 0 },
596
+ draw: info => { circuitLines = info.data.lines }
597
+ }
598
+ })
599
+ await settleFrames()
600
+ const allCircuitPaths = circuitLines.map(line => line.path)
601
+ circuitLines = []
602
+ circuitView.updateOptions({ minimap: { ...circuitView.getOptions().minimap, channelCircuits: false } })
603
+ await settleFrames()
604
+ const representativePath = circuitLines[0]?.path ?? []
605
+ const expectedCenter = allCircuitPaths.length === 2
606
+ ? allCircuitPaths[0].map((coordinate, index) => [
607
+ (coordinate[0] + allCircuitPaths[1][index][0]) / 2,
608
+ (coordinate[1] + allCircuitPaths[1][index][1]) / 2
609
+ ])
610
+ : []
611
+ const centeredRepresentative = representativePath.length === expectedCenter.length && representativePath.every((coordinate, index) =>
612
+ Math.abs(coordinate[0] - expectedCenter[index][0]) < 1e-6 && Math.abs(coordinate[1] - expectedCenter[index][1]) < 1e-6
613
+ )
614
+ check(
615
+ '鹰眼图关闭回线后双回线取居中代表线',
616
+ allCircuitPaths.length === 2 && circuitLines.length === 1 && centeredRepresentative,
617
+ `原回线 ${allCircuitPaths.length} 条,代表线 ${circuitLines.length} 条,路径 ${JSON.stringify(representativePath)}`
618
+ )
619
+ circuitView.destroy()
620
+ circuitHost.remove()
621
+ const styleHost = document.createElement('div')
622
+ styleHost.style.cssText = 'position:fixed;left:-9999px;top:0;width:360px;height:260px'
623
+ document.body.appendChild(styleHost)
624
+ const styleView = createGisView(styleHost, {
625
+ points: [],
626
+ lines: [],
627
+ background: { color: '#ffffff' },
628
+ minimap: {
629
+ width: 140,
630
+ height: 90,
631
+ background: 'inherit',
632
+ backgroundStyle: 'rgb(20, 40, 60)',
633
+ boxStyle: { fillOpacity: 0, strokeWidth: 0 }
634
+ }
635
+ })
636
+ await settleFrames()
637
+ const styledRoot = styleView.getMinimapElement()
638
+ const styledCanvas = styledRoot?.querySelector('.gis-view__minimap-canvas')
639
+ const styledPixels = styledCanvas?.getContext('2d').getImageData(0, 0, styledCanvas.width, styledCanvas.height).data ?? []
640
+ let opaqueBackgroundPixels = 0
641
+ for (let index = 3; index < styledPixels.length; index += 4) {
642
+ if (styledPixels[index] > 0) {
643
+ opaqueBackgroundPixels += 1
644
+ }
645
+ }
646
+ const styledColor = styledRoot ? getComputedStyle(styledRoot).backgroundColor : ''
647
+ check(
648
+ '鹰眼图显式 backgroundStyle 接管容器底色且画布让出底色',
649
+ styledColor === 'rgb(20, 40, 60)' && opaqueBackgroundPixels === 0,
650
+ `容器=${styledColor},画布不透明像素 ${opaqueBackgroundPixels}`
651
+ )
652
+ styleView.destroy()
653
+ styleHost.remove()
654
+ const minimapErrors = []
655
+ const captureMinimapError = event => minimapErrors.push(String(event.error?.stack ?? event.message))
656
+ window.addEventListener('error', captureMinimapError)
657
+ const pointHost = document.createElement('div')
658
+ pointHost.style.cssText = 'position:fixed;left:-9999px;top:0;width:360px;height:260px'
659
+ document.body.appendChild(pointHost)
660
+ const pointView = createGisView(pointHost, {
661
+ points: [
662
+ { id: 'square-node', x: 0, y: 0 },
663
+ { id: 'circle-node', x: 100, y: 0 },
664
+ { id: 'icon-node', x: 200, y: 0 }
665
+ ],
666
+ lines: [],
667
+ pointRules: [
668
+ { name: '小图方点', when: { id: 'square-node' }, style: { size: 64, symbol: 'square', color: '#0088ff', strokeColor: '#0088ff' } },
669
+ { name: '小图圆点', when: { id: 'circle-node' }, style: { size: 64, symbol: 'circle', color: '#00cc66', strokeColor: '#00cc66' } },
670
+ { name: '小图图标', when: { id: 'icon-node' }, style: { size: 64, symbol: { type: 'svg', path: 'M0 0H20V20H0Z', viewBox: [0, 0, 20, 20], fill: '#ff00ff' }, color: '#0088ff', strokeColor: '#0088ff' } }
671
+ ],
672
+ background: false,
673
+ minimap: {
674
+ width: 220,
675
+ height: 120,
676
+ background: false,
677
+ extent: { minX: -20, minY: -20, maxX: 220, maxY: 20 },
678
+ boxStyle: { fillOpacity: 0, strokeWidth: 0 }
679
+ }
680
+ })
681
+ let pointInk = { blue: 0, green: 0, magenta: 0 }
682
+ for (let attempt = 0; attempt < 15; attempt += 1) {
683
+ await new Promise(resolve => setTimeout(resolve, 60))
684
+ const pointCanvas = pointView.getMinimapElement()?.querySelector('.gis-view__minimap-canvas')
685
+ const pointPixels = pointCanvas?.getContext('2d').getImageData(0, 0, pointCanvas.width, pointCanvas.height).data ?? []
686
+ pointInk = { blue: 0, green: 0, magenta: 0 }
687
+ for (let index = 0; index < pointPixels.length; index += 4) {
688
+ const red = pointPixels[index]
689
+ const green = pointPixels[index + 1]
690
+ const blue = pointPixels[index + 2]
691
+ if (red < 60 && green > 80 && green < 190 && blue > 200) {
692
+ pointInk.blue += 1
693
+ }
694
+ if (red < 60 && green > 150 && blue < 140) {
695
+ pointInk.green += 1
696
+ }
697
+ if (red > 220 && green < 50 && blue > 220) {
698
+ pointInk.magenta += 1
699
+ }
700
+ }
701
+ if (pointInk.magenta > 500 && pointInk.blue > 500 && pointInk.green > 500) {
702
+ break
703
+ }
704
+ }
705
+ const circleSquareRatio = pointInk.blue ? pointInk.green / pointInk.blue : 0
706
+ check(
707
+ '鹰眼图沿用主图规则后尺寸与 SVG 图标一致',
708
+ pointInk.blue > 500 && pointInk.green > 500 && pointInk.magenta > 500 && circleSquareRatio > 0.85 && circleSquareRatio < 1.15 && minimapErrors.length === 0,
709
+ '方点 ' + pointInk.blue + 'px,圆点 ' + pointInk.green + 'px(比值 ' + circleSquareRatio.toFixed(2) + '),图标 ' + pointInk.magenta + 'px,错误 ' + (minimapErrors[0] ?? '无')
710
+ )
711
+ pointView.destroy()
712
+ pointHost.remove()
713
+ window.removeEventListener('error', captureMinimapError)
714
+ const externalHostId = 'minimap-ext-' + Math.random().toString(36).slice(2)
715
+ const alternateHostId = 'minimap-alt-' + Math.random().toString(36).slice(2)
716
+ const externalHost = document.createElement('div')
717
+ externalHost.id = externalHostId
718
+ externalHost.style.cssText = 'position:fixed;left:-9999px;top:340px;width:280px;height:200px;background:#eef4fb'
719
+ const alternateHost = document.createElement('div')
720
+ alternateHost.id = alternateHostId
721
+ alternateHost.style.cssText = 'position:fixed;left:-9999px;top:560px;width:280px;height:200px;background:#f7eefb'
722
+ const externalViewHost = document.createElement('div')
723
+ externalViewHost.style.cssText = 'position:fixed;left:-9999px;top:0;width:360px;height:260px'
724
+ document.body.append(externalHost, alternateHost, externalViewHost)
725
+ const externalView = createGisView(externalViewHost, {
726
+ points: [{ id: 'ext-a', x: 0, y: 0 }, { id: 'ext-b', x: 30, y: 20 }],
727
+ lines: [{ id: 'ext-l', from: 'ext-a', to: 'ext-b' }],
728
+ background: false,
729
+ minimap: {
730
+ width: 140,
731
+ height: 90,
732
+ margin: 10,
733
+ background: false,
734
+ container: externalHost,
735
+ boxStyle: { fillOpacity: 0, strokeWidth: 0 }
736
+ }
737
+ })
738
+ await settleFrames()
739
+ const externalRoot = externalView.getMinimapElement()
740
+ const beforeMoveRect = externalRoot?.getBoundingClientRect()
741
+ externalView.updateOptions({ minimap: { ...externalView.getOptions().minimap, offset: [30, 20] } })
742
+ await settleFrames()
743
+ const afterMoveRect = externalRoot?.getBoundingClientRect()
744
+ const moved = Boolean(beforeMoveRect && afterMoveRect &&
745
+ Math.abs(afterMoveRect.left - beforeMoveRect.left - 30) < 0.75 &&
746
+ Math.abs(afterMoveRect.top - beforeMoveRect.top - 20) < 0.75)
747
+ check(
748
+ '鹰眼图能挂到外部 div,并用 offset 动态移动整张图',
749
+ externalRoot?.parentElement === externalHost && externalViewHost.querySelector('.gis-view__minimap') === null && moved,
750
+ '父元素 ' + (externalRoot?.parentElement?.id ?? 'null') + ',位移 ' + (beforeMoveRect ? Math.round(afterMoveRect.left - beforeMoveRect.left) + ',' + Math.round(afterMoveRect.top - beforeMoveRect.top) : 'null')
751
+ )
752
+ externalView.updateOptions({ minimap: { ...externalView.getOptions().minimap, container: '#' + alternateHostId } })
753
+ await settleFrames()
754
+ const movedHost = externalView.getMinimapElement() === externalRoot && externalRoot?.parentElement === alternateHost
755
+ externalView.destroy()
756
+ check(
757
+ '鹰眼图换外部容器复用同一根节点,destroy 后一并清理',
758
+ movedHost && !externalRoot?.isConnected && !alternateHost.querySelector('.gis-view__minimap'),
759
+ '换容器 ' + movedHost + ',销毁后 connected=' + (externalRoot?.isConnected ?? false)
760
+ )
761
+ externalHost.remove()
762
+ alternateHost.remove()
763
+ externalViewHost.remove()
461
764
  // 宿主缩放(CSS zoom / 祖先的 transform: scale):引擎的 CSS 像素按布局像素算、画布备份仍是设备像素、
462
765
  // DOM 标签与指针换算同除显示比例;三样对不上时,标签会飞出节点、指针也点不中
463
766
  const plainScaleHost = document.createElement('div')
@@ -2178,8 +2178,46 @@
2178
2178
  clusterView.destroy()
2179
2179
  clusterHost.remove()
2180
2180
 
2181
+ /* ---------------- 同一批点线数据原样回灌:两半都没换时别白解析 ---------------- */
2182
+ // 组件把同一批对象原样再交一次是常规写法(刷新配置 / 只换别的选项时顺带带上 data)。
2183
+ // 这里量 5 次取中位;每次回灌之后数据、线路实例数与相机都必须原样。
2184
+ big.fitView(0)
2185
+ big.refresh()
2186
+ big.refresh()
2187
+ const refeedPoints = big.getData().points
2188
+ const refeedLines = big.getData().lines
2189
+ const refeedInstances = big.getStats().lineInstances
2190
+ const refeedStarted = now()
2191
+ const refeedSamples = []
2192
+ for (let round = 0; round < 5; round += 1) {
2193
+ const started = now()
2194
+ big.updateOptions({ points: refeedPoints, lines: refeedLines })
2195
+ refeedSamples.push(now() - started)
2196
+ }
2197
+ refeedSamples.sort((left, right) => left - right)
2198
+ const refeedMs = refeedSamples[Math.floor(refeedSamples.length / 2)]
2199
+ const refeedData = big.getData()
2200
+ check('同一批点线原样回灌:条数 / 线路实例数都不变(解析结果可以整半沿用)',
2201
+ refeedData.points.length === pointCount && refeedData.lines.length === lineCount && big.getStats().lineInstances === refeedInstances,
2202
+ JSON.stringify({ points: refeedData.points.length, lines: refeedData.lines.length, instances: big.getStats().lineInstances, expected: refeedInstances }))
2203
+ diag(`同一批点线原样回灌(${pointCount} 点 / ${lineCount} 线)`, `中位 ${refeedMs.toFixed(1)} ms(5 次:${refeedSamples.map(value => value.toFixed(1)).join(' / ')};总观测 ${(now() - refeedStarted).toFixed(1)} ms)`)
2204
+ // 同一批数据回灌不能让通道几何停在上一轮:声明没换时沿用,换了骨架必须照常重推
2205
+ big.updateOptions({ channels: [{ id: 'reuse-guard', from: 'p0', to: 'p1', lineIds: ['l0', 'l1'], path: [[20, 20]] }] })
2206
+ const guardBefore = big.getChannelGroupWaypoints('reuse-guard')
2207
+ big.updateOptions({ points: refeedPoints, lines: refeedLines })
2208
+ const guardAfter = big.getChannelGroupWaypoints('reuse-guard')
2209
+ check('同一批点线回灌:通道声明没换时,回线派生折线原样保留',
2210
+ JSON.stringify(guardBefore?.lines?.map(line => line.path)) === JSON.stringify(guardAfter?.lines?.map(line => line.path)),
2211
+ JSON.stringify({ before: guardBefore?.lines?.map(line => line.waypoints), after: guardAfter?.lines?.map(line => line.waypoints) }))
2212
+ big.updateOptions({ channels: [{ id: 'reuse-guard', from: 'p0', to: 'p1', lineIds: ['l0', 'l1'], path: [[80, 80]] }] })
2213
+ const guardChanged = big.getChannelGroupWaypoints('reuse-guard')
2214
+ check('同一批点线回灌:换通道骨架时线路那一半不能沿用旧几何',
2215
+ JSON.stringify(guardChanged?.lines?.map(line => line.waypoints)) !== JSON.stringify(guardAfter?.lines?.map(line => line.waypoints)),
2216
+ JSON.stringify({ before: guardAfter?.lines?.map(line => line.waypoints), after: guardChanged?.lines?.map(line => line.waypoints) }))
2217
+ big.updateOptions({ channels: [] })
2218
+
2181
2219
  thinView.destroy()
2182
- thinHost.remove()
2220
+ thinHost.remove()
2183
2221
  big.destroy()
2184
2222
  bigHost.remove()
2185
2223
  small.destroy()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gis-view-webgl2",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "WebGL2 矢量视图:点、线与 GeoJSON / 图片背景层,无内置界面,点击 / 双击 / 拖拽可配置",
5
5
  "type": "module",
6
6
  "scripts": {