gis-view-webgl2 0.1.8 → 0.1.9
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 +7 -5
- package/dist/gis-view.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +214 -14
- package/dist/index.js +1 -1
- package/docs/AI/345/257/271/350/257/235/346/261/207/346/200/273.md +65 -547
- package/docs/GisView.md +1 -1
- package/docs/GisView/345/256/236/347/216/260/345/216/237/347/220/206.md +1 -1
- 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 -526
- package/docs/demos/BasicDemo.vue +142 -25
- package/docs/demos/BatchAddDemo.vue +127 -1
- package/docs/demos/ChannelDemo.vue +61 -0
- package/docs/demos/CopyMergeDemo.vue +125 -36
- package/docs/demos/EventDemo.vue +12 -4
- package/docs/demos/api-index.js +26 -16
- package/docs/format/02-/350/212/202/347/202/271/344/270/216/347/272/277/350/267/257.md +1 -0
- package/docs/format/04-/351/200/232/351/201/223/344/270/216/346/240/207/347/255/276.md +3 -0
- package/docs/index.html +136 -13
- package/docs/internals/15-04-/351/200/220/350/275/256/350/256/260/345/275/225-/347/203/255/345/212/233/345/233/276/344/270/216/346/200/247/350/203/275.md +10 -0
- package/docs/manual/03-/351/205/215/347/275/256/351/241/271.md +82 -14
- package/docs/manual/04-/344/272/213/344/273/266/344/270/216/345/233/236/350/260/203.md +2 -1
- package/docs/manual/05-/347/224/273/350/264/250/344/270/216/346/211/271/351/207/217/346/233/264/346/226/260.md +65 -0
- 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 +48 -11
- package/docs/manual/08-/351/200/211/344/270/255/344/270/216/346/213/220/347/202/271.md +8 -4
- package/docs/manual/09-/351/200/232/351/201/223/344/270/216/345/244/232/345/233/236/347/272/277.md +57 -0
- package/docs/manual/12-/346/240/207/347/255/276/344/270/216/350/243/205/351/245/260.md +26 -3
- package/docs/manual/14-/350/247/206/345/233/276/344/270/216/347/255/233/351/200/211.md +34 -1
- package/docs/manual/15-/345/257/274/345/207/272/344/270/216/351/233/206/346/210/220.md +5 -2
- package/docs/manual/16-/345/256/236/344/276/213/346/226/271/346/263/225/346/200/273/350/241/250.md +13 -10
- package/docs/manual/17-/345/217/202/346/225/260/351/200/237/346/237/245.md +14 -8
- package/docs/manual/18-/351/200/220/346/226/271/346/263/225/347/244/272/344/276/213.md +43 -3
- package/docs/manual/20-/346/200/247/350/203/275/344/270/216/345/244/247/346/225/260/346/215/256.md +3 -1
- 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
- package/docs/steps/README.md +200 -121
- package/docs/steps/index.html +216 -0
- package/docs/steps/selftest-demos.html +209 -31
- package/docs/steps/selftest-docs.html +17 -6
- package/docs/steps/selftest-features.html +311 -3
- package/docs/steps/selftest-labels.html +81 -0
- package/docs/steps/selftest-perf.html +31 -3
- package/docs/steps/selftest-select.html +51 -1
- package/docs//344/273/2160/345/210/260/345/256/214/346/225/264/347/232/204/345/256/236/347/216/260.md +1 -0
- package/package.json +1 -1
- package/docs/ai/01-/350/265/267/346/272/220/344/270/216/350/277/231/344/273/275/346/261/207/346/200/273/347/232/204/347/224/261/346/235/245.md +0 -29
- package/docs/ai/02-/346/214/211/345/206/205/345/256/271/345/210/206/347/261/273-/350/277/231/344/270/200/350/267/257/351/203/275/345/234/250/346/224/271/344/273/200/344/271/210.md +0 -66
- package/docs/ai/03-/351/207/215/350/246/201/351/227/256/347/255/224/351/200/211/357/274/210/344/270/200/357/274/211/357/274/232/351/200/211/345/236/213/351/200/232/351/201/223/344/270/216/346/240/267/345/274/217.md +0 -178
- package/docs/ai/04-/351/207/215/350/246/201/351/227/256/347/255/224/351/200/211/357/274/210/344/272/214/357/274/211/357/274/232/344/272/244/344/272/222/346/200/247/350/203/275/344/270/216/346/225/260/346/215/256.md +0 -140
- package/docs/ai/05-/351/207/215/350/246/201/351/227/256/347/255/224/351/200/211/357/274/210/344/270/211/357/274/211/357/274/232/345/256/277/344/270/273/346/227/201/346/224/257/344/270/216/346/224/266/345/217/243.md +0 -43
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 17 参数速查(逐个方法)
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> 273 个成员逐个列全:参数、默认值与返回。
|
|
4
4
|
|
|
5
5
|
### 参数速查(逐个方法)
|
|
6
6
|
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
| `updateBackground(background?)` | `background?: GisViewBackground` 新的背景层(底色 / 图片 / GeoJSON);不传等于清掉 | `this` |
|
|
39
39
|
| `getResolvedBackground()` | 无 | `GisViewResolvedBackground` |
|
|
40
40
|
| `getBackgroundLabels()` | 无 | `GisViewResolvedBackgroundLabel[] \| null` |
|
|
41
|
-
| `batch(fn, options?)` | `fn: () => T`
|
|
41
|
+
| `batch(fn, options?)` | `fn: () => T` 这一批里要做的增删改 / 分组操作(内部调 `patchPoints` / `patchLines` / `updateChannel`、`removePoints` / `removeLines` / `removeChannel`、`splitChannelGroups` / `removeChannelGroup` 等都会收成一条);`options.label?: string` 给这一步历史起名 | `fn` 的返回值 |
|
|
42
42
|
| `resize()` | 无(改过祖先 `transform: scale` / 容器尺寸后手动同步一次;CSS `zoom` 会自动感知) | `this` |
|
|
43
43
|
| `refresh(options?)` | `options?: { reflow?: boolean }` 传 `false` 只重画一帧(跳过整份重解析:数据没变、只想重画时用);不传或 `true` 走整份重建 | `this` |
|
|
44
44
|
| `whenRendered()` | 等下一帧画完(Promise):兑现那一帧的载荷(`frame` 是帧序号,`type` / `changes` / `counts` 说明这一帧带上了哪几次数据变更);引擎下一次渲染结束时兑现,视图销毁时兑现 `null` | `Promise<GisViewDataRenderedPayload \| null>` |
|
|
@@ -63,10 +63,15 @@
|
|
|
63
63
|
| `flyToCamera(camera, options?)` | `camera: GisViewCameraTarget` 直接给相机目标 `{ center?, scale? }`:没写 center / scale 的那一项沿用当前相机,不经过要素解析,也不改选中与数据;`options?: GisViewFlyCameraOptions` 的 `duration` / `easing` 与 `flyTo` 同义。中心 / 比例插值、减少动态效果、用户手势取消都走同一条相机动画 | `this`(相机变化时发 `onCameraChange`;目标非法时保持当前相机) |
|
|
64
64
|
| `search(input)` | `input: string \| GisViewSearchOptions` 关键字,或 `{ keyword, scope, fields, limit }` 这类选项。`scope` 可选 `'points'` / `'lines'` / `'channels'` / `'groups'`,也认与 `focusOn` 一致的单数别名 `'point'` / `'line'` / `'channel'` / `'group'` 及数组;省略或写错时四类全搜。`limit` 对每一类分别计数。返回的 `groups` / `hits` 带分组命中(`channelIndex` / `groupId` / `groupIndex`,`item` 是轻量快照)—— **只返回结果、不动视角**,要定位就自己调 `focusOn(result.hits, …)` | `GisViewSearchResult`:`keyword` / `scope` / `points` / `lines` / `channels` / `groups` / `hits` / `total` / `truncated` / `durationMs` |
|
|
65
65
|
| `searchAsync(input)` | 同上;分组范围的当前轻量快照会随请求交给 Worker | `Promise<GisViewSearchResult>`:多一个 `worker`(是不是在 Worker 里算的)与 `stale`(回来时数据已经改过、或又搜过一次,这一份不作数了) |
|
|
66
|
-
| `setCamera(camera)` | `camera: Partial<GisViewCamera>` 要改的相机字段 `{
|
|
66
|
+
| `setCamera(camera)` | `camera: Partial<GisViewCamera>` 要改的相机字段 `{ center, scale }`(只写一个也行) | `this` |
|
|
67
67
|
| `getCamera()` | 无 | `GisViewCamera` |
|
|
68
|
+
| `getScale()` | 无 | `number`:当前比例(像素 / 世界单位),与 `getCamera().scale` 同一份读数 |
|
|
69
|
+
| `setScale(scale, origin?)` | `scale: number` 目标比例;`origin?: [number, number]` 画布 CSS 像素锚点(缺省视口中心) | `this`:立即改比例,受 `minScale` / `maxScale` 夹取 |
|
|
70
|
+
| `getCenter()` | 无 | `[number, number]`:当前视图中心,返回独立副本;改返回值不会动引擎 |
|
|
71
|
+
| `setCenter(center)` | `center: [number, number]` 新的视图中心 | `this`:只移动中心、保留当前比例,可链式调用 |
|
|
68
72
|
| `stopCameraAnimation()` | 无 | `this`:停止当前相机飞行并停在当前帧;没有飞行时是空操作 |
|
|
69
73
|
| `getCameraAnimation()` | 无 | `GisViewCameraAnimation \| null`:`{ active, progress, duration, from, to }`,`progress` 是时间进度(0 ~ 1),没有动画时 `null` |
|
|
74
|
+
| `getIdleTime()` | 无 | `number`:距创建或上一次指针 / 滚轮 / 键盘操作的毫秒数;程序化 API 调用不重置 |
|
|
70
75
|
| `getZoomBaseScale()` | 无 | `number` 缩放联动的基准比例(`pointZoomScale` / `lineZoomScale` 共用那一份;缺省是首次适应视图时的 `camera.scale`) |
|
|
71
76
|
| `setZoomBaseScale(scale?)` | `scale?: number` 新的基准比例;不传取当下相机的比例(把现在这一屏当成「原样大小」) | `this` |
|
|
72
77
|
| `getBounds()` | 无 | `GisViewBounds`:每次返回独立副本;重复调用命中数据包围盒缓存,改点 / 改线 / 追加或拖拽后下一次读数自动重建 |
|
|
@@ -154,7 +159,7 @@
|
|
|
154
159
|
| `isSelected(ref)` | `ref: GisViewFeatureRef \| GisViewFeatureKey \| GisViewSelectionRefObject` 要素定位(id / 下标 / `{ id }` / `{ index }` / `{ type, index }` / `{ item }`) | `boolean` |
|
|
155
160
|
| `getSelectionData()` | 无 | `GisViewSelectionData`:`{ ids, count, pointCount, lineCount, channelCount, points, lines, channels, items, pointIndexes, lineIndexes, bounds }`(`bounds` 是世界包围盒,空选中时 `null`;`items` 的线路不带通道字段,`channels` 是去重后的所属通道) |
|
|
156
161
|
| `getCascadeHighlight()` | 无 | `GisViewCascadeHighlightInfo \| null`:当前点击级联高亮的来源、范围与节点 / 线路读数 `{ origin, scope, points, lines, pointIndexes, lineIndexes }`,不改变选中集 |
|
|
157
|
-
| `selectInBox(box, options = {})` | `box: GisViewRect` **画布 CSS 像素**矩形 `{ x, y, width, height }`(与手动框选同一套坐标);`options?: GisViewSelectInBoxOptions`:`selectionKinds` 临时覆盖这一次保留哪几类(`'point'` / `'line'` / `'channel'`、数组、`'all'` / `true` / `false` / `null`,不写沿用全局 `selectionKinds`),`originalEvent` 原样带进 `onSelect`。空框不会选中任何要素 | `this`(每次框选都发 `onSelect`,空框为 `null`;集合变化时再发 `onSelectChange`,顺序 `onSelect → onSelectChange`,`cause` 为 `boxSelect`) |
|
|
162
|
+
| `selectInBox(box, options = {})` | `box: GisViewRect` **画布 CSS 像素**矩形 `{ x, y, width, height }`(与手动框选同一套坐标);`options?: GisViewSelectInBoxOptions`:`selectionKinds` 临时覆盖这一次保留哪几类(`'point'` / `'line'` / `'channel'` / `'lineEndpoints'` / `'channelEndpoints'`、数组、`'all'` / `true` / `false` / `null`,不写沿用全局 `selectionKinds`),`originalEvent` 原样带进 `onSelect`。空框不会选中任何要素 | `this`(每次框选都发 `onSelect`,空框为 `null`;集合变化时再发 `onSelectChange`,顺序 `onSelect → onSelectChange`,`cause` 为 `boxSelect`) |
|
|
158
163
|
| `beginCopyPoint(options = {})` | `options: GisViewCopyStartOptions`:`id` / `index` / `item` 三选一给来源,都不给就进入「下一次点选节点」模式;`coordinate` / `screen` 是落点(缺省按 `copy.offset`);`follow` 让预览跟指针;`autoCommit` 覆盖 `copy.autoCommit`;`commit: true` 出预览即落地;`via` / `originalEvent` 原样带回。必须配置 `copy`(`enabled` 不为 `false`),否则返回 `null`。预览节点插在 `points` 末尾且不带 id,不会把绑定源 id 的线路 / 通道带过去 | `GisViewPointCopyPayload \| null`:`phase: 'start'` 的预览载荷;来源认不出来时返回 `null` |
|
|
159
164
|
| `commitPointCopy()` | 无:把当前复制预览落地,先发 `commit`、落地后发 `end`;`commit` 阶段载荷里的 `cancel()` 可以拦住这次复制 | `GisViewPointCopyPayload \| null`:成功的 `end` 载荷;没有预览或已被取消时为 `null` |
|
|
160
165
|
| `cancelPointCopy()` | 无:撤掉预览并补一条 `cancel`,数据与历史不动 | `GisViewPointCopyPayload \| null`:取消载荷;没有预览时为 `null` |
|
|
@@ -168,9 +173,9 @@
|
|
|
168
173
|
| `pastePoint(options = {})` | `options: GisViewPasteOptions`:`screen` / `coordinate`(落在哪里,缺省光标位置)、`offset`(屏幕像素偏移)、`select`(粘贴后选中新节点)、`label` / `via` / `originalEvent`;单节点且快照里没有内部线路 / 通道时仍走原预览,其余走整组落地 | `GisViewCopyItem \| GisViewBatchCopyPayload \| null` |
|
|
169
174
|
| `pastePoints(options = {})` | `options` 同上;强制整组粘贴(单节点也走批量路),返回带 `count` / `indexes` / `lines` / `channels` / `revert()` 的完整载荷 | `GisViewBatchCopyPayload \| null` |
|
|
170
175
|
| `getPointClipboard()` | 无 | `GisViewClipboardItem \| null` |
|
|
171
|
-
| `mergePoints(source, target, options = {})` | `source: GisViewPointRef` 被并入的节点(并完就没了)、`target: GisViewPointRef` 接收的节点、`options?: { originalEvent?: Event \| null; item?: GisViewPoint }`:`item`
|
|
176
|
+
| `mergePoints(source, target, options = {})` | `source: GisViewPointRef` 被并入的节点(并完就没了)、`target: GisViewPointRef` 接收的节点、`options?: { originalEvent?: Event \| null; item?: GisViewPoint }`:`item` 可以给一份已经改好的业务字段结果(确认阶段改过 `payload.item` 之后就是它);未给 `item` 时只对 `merge.maxKeys` 列出的字段取双方最高值(缺省空表,全部字段取保留节点,数组 / 逗号字符串均可);最终 `id`、坐标与 `mergeInfo` 由组件维护 | `GisViewMergeOutcome`:保留节点写完整 `mergeInfo`,受影响通道写轻量 `mergeInfo` |
|
|
172
177
|
| `mergeSelectedPoints(options = {})` | `options: GisViewMergeSelectedOptions`:`target` 指定并到哪一个(不给就自动挑绑定线路最多的);`sources` 直接给来源(不依赖选中集);`item` 是最终节点补丁或 `(context) => 补丁`(上下文含 `item` / `merged` / `source` / `target` / `sourceIndex` / `targetIndex` / `merge` / `view`;坐标与 id 仍按 `target` 保留);`force: true` 越过 `mergeable: false`;`label` / `originalEvent` | `GisViewMergeSelectedOutcome` |
|
|
173
|
-
| `splitPoint(source, parts
|
|
178
|
+
| `splitPoint(source, parts?, options = {})` | `source: GisViewPointRef` 要拆的节点;`parts?: GisViewSplitPointPart[] \| null` 省略 / `null` / `[]` 且节点带 `mergeInfo` 时自动解除合并,传数组时至少两份,每份可直接写节点字段或放进 `item`,并用 `lines` / `channels` / `channelFrom` / `channelTo` 分配线路与通道端点;`options?: GisViewSplitPointOptions`:`keepSourceId`(缺省 `true`,第一份沿用来源 id)/ `label` / `select`(缺省 `false`,不选中结果且保留无关选中;`true` 选中全部结果节点)/ `autoLines?: 'first' \| 'alternate'`(缺省 `first` 跟第一份;`alternate` 按「通道成组、独立线路单条」轮流给负载最少的一份,手工拆分推荐) | `GisViewSplitPointOutcome`:`{ ok, reason, source, items, indexes, pointIds, linesChanged, removedLines, removedLineIds, removedLineIndexes, channelsChanged, removedChannels, removedChannelIds, autoLines, autoAssignedLines, lineAssignments, autoRestored, mergeSourceIds, skipped, changes }`;自动解除时 `autoRestored: true`、`mergeSourceIds` 给恢复的来源 id;`lineAssignments` 每项 `{ index, pointId, lineIds, lineCount }`;`changes` 可直接作为后端事务输入 |
|
|
174
179
|
| `getPointMerge()` | 无(载荷带 `impact`:`lineCount` / `linesChanged` / `removedLines` / `lineIds` / `removedLineIds` 与通道读数,确认前就能估算影响) | `GisViewPointMergePayload \| null` |
|
|
175
180
|
| `resolvePointMerge(confirmed, options = {})` | `confirmed?: boolean`(缺省 `true` = 确认,`false` = 取消);`options?: GisViewPointMergeConfirmOptions`:`keep` 选 `'target'`(缺省,保留碰撞目标)/ `'source'`(保留拖动的来源),`item` 是最终节点字段补丁(名称 / 分区 / 颜色 / 尺寸 / 图标 / 描边等;位置与 id 始终取保留端) | `GisViewPointMergePayload \| null` |
|
|
176
181
|
| `commitPointMerge()` | 无:收掉「已确认、数据已由使用方并好」的合并状态;`mergePoints` / `resolvePointMerge` 的正常路径由组件自己调用,只有完全自建合并落地流程时才手动调 | `boolean`:真的收掉了一个待确认合并为 `true`,没有可收的状态为 `false` |
|
|
@@ -219,6 +224,7 @@
|
|
|
219
224
|
| `commitAddChannel(input?, options?)` | `input?: GisViewChannelAddCommitInput`,只接受一个容器对象;不传 / `null` 用草稿的推荐方案。字段:`channel?`(通道对象与 `groups`)/ `line?`(独立线路对象)/ `lines?` 或 `lineData?`(成员回线表)/ `channelGroups?` 或 `group?`(分组声明)/ `lineProps?` / `linePropsByMember?` / `channelProps?` / `path?` / `routing?` / `resolution?` / `from?` / `to?` / `name?` / `id?`。`lines` 与 `lineData` 同义且 `lines` 优先,空数组沿用草稿;`channel.lineIds` 只在线路表缺省时当回线 id 种子。字段优先级:`from` / `to` = 顶层 → `channel` → `line` → `lines` 第一个对象项 → 草稿;`path` = 顶层 → `line` → `channel` → 草稿;分组 = `channelGroups` → `group` → `channel.groups`;`lineProps` = 草稿 → 顶层 → `line.lineProps` → 逐条;`channelProps` = 草稿 → `channel` 业务字段 → 顶层 `channelProps`。`resolution` 收 `'auto'` / `'newChannel'` / `'newGroup'` / `'joinGroup'` / `'newLine'` 或 `{ type, groupId?, groupIndex?, channelId? }`。旧顶层分派字段(`kind` / `circuits` / `channelId` / `groupId` / `lineId` / `lineItems` / `lineIds` / `start` / `end` 等)明确失败。`options?: { auto?: boolean; continuous?: boolean; originalEvent?: Event \| null; select?: boolean }`;`select: true` 才选中这次新建的全部回线,缺省不动选中集。调用前草稿必须 `ready`;没有草稿的程序化新增用 `addChannel` / `addLine` | `GisViewChannelAddResult` |
|
|
220
225
|
| `getChannelAddOptions(from, to, count?, kind?)` | `from` / `to` 两端节点 id;`count?: number` 回数(缺省 1);`kind?: 'channel' \| 'line'`(缺省 `'channel'`) | `GisViewChannelAddPlan \| null` |
|
|
221
226
|
| `getChannelBetween(from, to)` | `from` / `to` 两端节点 id | `GisViewChannelBetween \| null` |
|
|
227
|
+
| `getDirectConnections(pointIds)` | `pointIds: string \| number \| Array<string \| number>` 一组节点 id(单条也收);只查集合内部的直接边,两端必须能查到节点,去重后少于两个返回空表 | `GisViewDirectConnection[]`:`type` 为 `'channel'` / `'line'` 的联合;每项带 `from` / `to`(`{ id, index, item }`)与 `item`,通道项有 `channelId` / `channelIndex` / `lineIds`,线路项有 `lineId` / `lineIndex`;空结果严格为 `[]` |
|
|
222
228
|
| `addChannel(channel, lineData?, group?, options?)` | `channel: GisViewChannelAddSpec` 通道信息 `{ from, to, name?, id?, channelProps?, path?, routing?, lineData?, group? }`(后两个是第二 / 第三段写在对象上的别名);`lineData?: GisViewChannelLineData` 线路数组(`Partial<GisViewLine>` / `string` / `number` 的一条或一批,按每项 id 建 `lineIds`);`group?: GisViewChannelAddGroup \| GisViewChannelAddGroup[]` 可选分组信息 `{ id?, lineIds?, path? }`;`options?: { emit?: boolean; select?: boolean }`,缺省不选中。只新建通道:两端已有通道时整条失败;旧 `circuits` / `resolution` / `kind` / `channelId` / `lineItems` 等入参已移除。`path` 是中间拐点,通道只写骨架拐点 | `GisViewChannelAddResult`(`channelLineIds` 是落地后通道的完整成员表) |
|
|
223
229
|
| `addChannelGroupLines(channelId, lineData?, group?, options?)` | `channelId` 目标通道 id;`lineData?: GisViewChannelLineData` 这次新建的线路数组(按每项 id 建回线);`group?: GisViewChannelAddGroup` 新分组信息 `{ id?, path? }`(缺省 `${通道 id}::N`、不带拐点);`options?: { emit?: boolean; select?: boolean }` | `GisViewChannelAddResult` |
|
|
224
230
|
| `addChannelGroups(channelId, groups, options = {})` | `channelId` 目标通道 id;`groups: GisViewChannelAddGroupInput \| GisViewChannelAddGroupInput[]` 每项 `{ id?, groupId?, path?, lineData? \| lines? }`(线路数据与 `addChannel` 第二段同一份写法,`lineItems` 已移除);`options?: { emit?: boolean; label?: string; select?: boolean }`,`emit: false` 只落地不通知 | `GisViewAddChannelGroupsResult` |
|
|
@@ -269,7 +275,7 @@
|
|
|
269
275
|
| `getLabelStates(kind?)` | `kind?: 'point' \| 'line'` 只看一类(不传两类都给) | `GisViewLabelState[]` |
|
|
270
276
|
| `getLabels(kind, ref?)` | `kind: 'point' \| 'line'` 看哪一类;`ref?: GisViewFeatureRef` 看哪一个要素(不传 = 给「有标签的要素」清单) | `GisViewLabelListItem[] \| null` / `GisViewItemLabelsInfo[]` |
|
|
271
277
|
| `setLabelContent(content, options = {})` | `content: GisViewLabelContent \| GisViewLineLabelContent \| null` 新内容(模板串 `{字段}` / 函数 / `null` 回到默认);`options: GisViewSetLabelContentOptions` `kind` 缺省 `'point'`(`'line'` / `'both'`)、`labelId` 缺省 `'default'`(`'*'` 换配置里的每一条) | `this` |
|
|
272
|
-
| `updateLabel(kind, ref, patch)` | `kind` 哪一类;`ref` 哪个要素;`patch: GisViewLabelPatch` 要改的项:`labelId`(改哪一条,缺省 `'default'`)、`content` / `html` / `position` / `style`(增量合并)/ `offset` / `visibility` / `parallel` / `hidden`,写 `null` 回到默认 | `GisViewLabelState \| null` |
|
|
278
|
+
| `updateLabel(kind, ref, patch)` | `kind` 哪一类;`ref` 哪个要素;`patch: GisViewLabelPatch` 要改的项:`labelId`(改哪一条,缺省 `'default'`)、`content` / `html` / `position` / `style`(增量合并)/ `offset` / `visibility` / `parallel` / `hidden` / `zIndex` / `followNodeZIndex` / `zoomScale`,写 `null` 回到默认 | `GisViewLabelState \| null` |
|
|
273
279
|
| `addLabel(kind, ref, definition = {}, labelId?)` | `kind` / `ref` 同上;`definition: GisViewItemLabel` 一条标签的定义(与配置里同一套写法:`content` / `position` / `offset` / `style` / `html`…);`labelId?: string` 指定 id(缺省自动取 `note1` / `note2`…) | `GisViewLabelState \| null` |
|
|
274
280
|
| `removeLabel(kind, ref, labelId?)` | `kind` / `ref`;`labelId?: string` 删哪一条(缺省 `'default'`) | `GisViewRemoveLabelResult \| null` |
|
|
275
281
|
| `addLabels(kind, refs, definition = {}, options = {})` | `kind`;`refs: GisViewLabelRef \| 数组` 批量定位(单个 / 数组 / `'all'` / `'visible'` / `'selection'`,线路还认 `{ channel }` / `{ group }`);`definition` 一条定义、定义数组,或 `(item, index) => 定义`;`options: { labelId?, overwrite? }` 已有同 id 的缺省跳过、`overwrite: true` 覆盖 | `GisViewAddLabelsResult` |
|
|
@@ -307,7 +313,7 @@
|
|
|
307
313
|
|
|
308
314
|
| 方法 | 参数(名字: 类型 = 默认值) | 返回 |
|
|
309
315
|
| --- | --- | --- |
|
|
310
|
-
| `exportData(options = {})` | `options: GisViewExportDataOptions`:`scope`(`'all'` 缺省 / `'viewport'` / `'selection'`,也认 `visible` / `view` / `selected`)、`format`(`'view'` 缺省 / `'input'` / `'new'` / `'test'` / `'full'`)、`parts`(只导 `points` / `lines` / `channels` / `parallelGroups` 里的哪几份)、`points` / `lines` / `channels`(只导指定要素)、`withLines: false`(selection 不要两端都在集合里的线路)、`labels`、`extra`。`format: 'full'` / `'input'` 返回可直接回灌的数据,不夹带 `scope` / `counts` 读数 | `GisViewExportDataResult \| GisViewDocument`(`format: 'full'`) |
|
|
316
|
+
| `exportData(options = {})` | `options: GisViewExportDataOptions`:`scope`(`'all'` 缺省 / `'viewport'` / `'selection'`,也认 `visible` / `view` / `selected`)、`format`(`'view'` 缺省 / `'input'` / `'new'` / `'test'` / `'full'`)、`parts`(只导 `points` / `lines` / `channels` / `parallelGroups` 里的哪几份)、`points` / `lines` / `channels`(只导指定要素)、`selectionKinds`(仅 `viewport`,支持 `lineEndpoints` / `channelEndpoints`)、`withLines: false`(selection 不要两端都在集合里的线路)、`labels`、`extra`。`format: 'full'` / `'input'` 返回可直接回灌的数据,不夹带 `scope` / `counts` 读数 | `GisViewExportDataResult \| GisViewDocument`(`format: 'full'`) |
|
|
311
317
|
| `exportImage(options = {})` | `options?: GisViewExportImageOptions`:`type`(`'image/png'` / `'image/jpeg'` / `'image/webp'` / `'svg'`)、`quality`(JPEG / WebP 0 ~ 1)、`scale`(导出倍数;SVG 只影响宽高)、`scope`(`'viewport'` 缺省 / `'all'` 全部内容)、`padding`(`scope: 'all'` 的留白,缺省 24)、`background`(缺省带背景 / `false` 或 `'none'` 透明 / 颜色字符串换底色)、`includeLabels`(缺省 `true`)、`download`(`true` 或文件名) | `Promise<string>`(data URL) |
|
|
312
318
|
| `exportSelection(options = {})` | `options?: GisViewExportSelectionOptions`:`format` / `type` / `quality` / `scale` / `padding`(只导选中要素那一块) | `Promise<GisViewExportSelectionResult>` |
|
|
313
319
|
|
|
@@ -135,7 +135,7 @@ const frame = await view.whenRendered()
|
|
|
135
135
|
view.updateData(nextPoints, nextLines)
|
|
136
136
|
await view.whenDataRendered()
|
|
137
137
|
|
|
138
|
-
// snapshotScene(options?):一次取全画布读数 /
|
|
138
|
+
// snapshotScene(options?):一次取全画布读数 / 数据快照(矢量导出、单测都用它;raisedLines 是抬层线路)
|
|
139
139
|
const snapshot = view.snapshotScene()
|
|
140
140
|
const white = view.snapshotScene({ background: '#ffffff' })
|
|
141
141
|
|
|
@@ -201,9 +201,25 @@ const asyncHits = await view.searchAsync('甲站') // 大表走 Worker;s
|
|
|
201
201
|
|
|
202
202
|
// setCamera(camera) / getCamera():读写相机(只写一个字段也行)
|
|
203
203
|
view.setCamera({ scale: 10 })
|
|
204
|
-
view.setCamera({
|
|
204
|
+
view.setCamera({ center: [200, 120] })
|
|
205
205
|
const camera = view.getCamera()
|
|
206
206
|
|
|
207
|
+
// getCenter() / setCenter(center):只读写视图中心(setCenter 保留当前比例,返回实例)
|
|
208
|
+
const center = view.getCenter() // [x, y] 的副本
|
|
209
|
+
center[0] += 100 // 改副本不会移动视图
|
|
210
|
+
view.setCenter([116.4, 39.9])
|
|
211
|
+
|
|
212
|
+
// getScale():读当前比例(与 getCamera().scale 同一份数)
|
|
213
|
+
const scale = view.getScale()
|
|
214
|
+
|
|
215
|
+
// setScale(scale, origin?):立即改比例;origin 是画布 CSS 像素锚点,缺省视口中心
|
|
216
|
+
view.setScale(3)
|
|
217
|
+
view.setScale(3, [320, 180])
|
|
218
|
+
|
|
219
|
+
// getIdleTime():距创建或上一次指针 / 滚轮 / 键盘操作的毫秒数
|
|
220
|
+
const idleTime = view.getIdleTime()
|
|
221
|
+
view.updateOptions({ idleTimeout: 60000, onIdle: ({ idleTime }) => console.log(idleTime) })
|
|
222
|
+
|
|
207
223
|
// stopCameraAnimation() / getCameraAnimation():停止飞行 / 读当前飞行读数(没有动画时为 null)
|
|
208
224
|
const flight = view.getCameraAnimation() // { active, progress, duration, from, to }
|
|
209
225
|
view.stopCameraAnimation() // 停在当前帧,不补跳到终点
|
|
@@ -406,11 +422,13 @@ view.on('cascadeHighlight', payload => console.log(payload?.pointIndexes, payloa
|
|
|
406
422
|
// selectInBox(box, options?):用矩形框选(画布 CSS 像素,与手动框选同一套判定)
|
|
407
423
|
view.selectInBox({ x: 40, y: 40, width: 320, height: 200 })
|
|
408
424
|
view.selectInBox({ x: 40, y: 40, width: 320, height: 200 }, { selectionKinds: ['line', 'channel'] })
|
|
425
|
+
view.selectInBox({ x: 40, y: 40, width: 320, height: 200 }, { selectionKinds: ['lineEndpoints', 'channelEndpoints'] }) // 两端节点都在框内才命中
|
|
409
426
|
|
|
410
427
|
// selectionKinds:框选与 Ctrl / multiSelect 点击的类型过滤(数组任意组合;'all' / true 全开,false / null 全关)
|
|
411
428
|
view.updateOptions({ selectionKinds: ['point', 'line'] }) // 只收节点与通道外线路
|
|
412
429
|
view.updateOptions({ selectionKinds: 'channel' }) // 只收通道回线(再按 channelSelectMode 摊开)
|
|
413
430
|
view.updateOptions({ selectionKinds: ['point', 'line', 'channel'] })
|
|
431
|
+
view.updateOptions({ selectionKinds: ['lineEndpoints'] }) // 框选:两端节点都在框内的独立线路
|
|
414
432
|
|
|
415
433
|
// beginCopyPoint(options) / getPointCopy() / updateCopyPoint(patch) / commitPointCopy() / cancelPointCopy()
|
|
416
434
|
view.updateOptions({ copy: { enabled: true, autoCommit: false } }) // API 复制入口要先开 copy 配置
|
|
@@ -439,12 +457,18 @@ const clipboard = view.getPointClipboard()
|
|
|
439
457
|
// mergePoints(source, target, options?):把 source 并进 target(接口调用,不做确认)
|
|
440
458
|
const merged = view.mergePoints('a', 'b')
|
|
441
459
|
const mergedCustom = view.mergePoints('a', 'b', { item: { name: '合并结果', size: 12 } })
|
|
460
|
+
console.log(merged.item?.mergeInfo?.sourceIds) // 保留节点上的来源 id;只有 merge.maxKeys 列出的字段取最高,缺省全部取保留端
|
|
442
461
|
|
|
443
462
|
// mergeSelectedPoints(options?):框选 / 多选之后一次并完(目标缺省挑绑定线路最多的那个)
|
|
444
463
|
const mergedAll = view.mergeSelectedPoints()
|
|
445
464
|
view.mergeSelectedPoints({ target: 'b', sources: ['a', 'c'], force: true })
|
|
446
465
|
|
|
447
|
-
// splitPoint(source
|
|
466
|
+
// splitPoint(source):有 mergeInfo 时自动解除合并(省略 parts / null / [] 等价)
|
|
467
|
+
const autoRestored = view.splitPoint('b', null, { label: '解除合并(自动恢复)' })
|
|
468
|
+
console.log(autoRestored.autoRestored, autoRestored.mergeSourceIds, autoRestored.changes)
|
|
469
|
+
// 默认不选中结果;需要选中全部恢复节点时写 splitPoint('b', null, { select: true })
|
|
470
|
+
|
|
471
|
+
// splitPoint(source, parts, options?):手工拆成多份(mergePoints 的逆操作)
|
|
448
472
|
const splitResult = view.splitPoint('a', [
|
|
449
473
|
{ x: 0, y: 0, name: '甲站(主)' }, // 第一份沿用原下标 / id
|
|
450
474
|
{ x: 80, y: 40, name: '甲站(东)', lines: ['l1'] } // 显式分给第二份
|
|
@@ -744,6 +768,17 @@ if (between?.hasChannel) {
|
|
|
744
768
|
console.log(between.channelId, between.groupCount, between.groups.map(group => group.id), between.currentGroupId)
|
|
745
769
|
}
|
|
746
770
|
|
|
771
|
+
// getDirectConnections(pointIds):只取这组节点之间的直接通道 / 线路(不走中间节点;没有就是 [])
|
|
772
|
+
const directConnections = view.getDirectConnections(['a', 'b'])
|
|
773
|
+
for (const connection of directConnections) {
|
|
774
|
+
if (connection.type === 'channel') {
|
|
775
|
+
console.log('通道', connection.channelId, connection.lineIds, connection.from.id, connection.to.id)
|
|
776
|
+
}
|
|
777
|
+
else {
|
|
778
|
+
console.log('线路', connection.lineId, connection.from.id, connection.to.id)
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
747
782
|
// addChannel(spec, lineData?, group?, options?) / addChannels(input, options?)
|
|
748
783
|
// addChannelGroupLines(channelId, lineData?, group?, options?) / joinChannelGroupLines(channelId, groupId?, lineData?, options?)
|
|
749
784
|
// addChannelGroups(channelId, groups, options?) / addLine(spec, lineData?, options?):程序化新增
|
|
@@ -898,6 +933,10 @@ view.updateLabel('point', 'a', { style: { color: '#f60' } })
|
|
|
898
933
|
view.updateLabel('point', 'a', { labelId: 'volt', content: '{vn_kv} kV' })
|
|
899
934
|
view.updateLabel('line', 'l1', { labelId: 'note1', hidden: true })
|
|
900
935
|
view.updateLabel('point', 'a', { position: 'bottom', offset: [0, 6], visibility: 'always' })
|
|
936
|
+
view.updateLabel('point', 'a', { followNodeZIndex: true }) // 跟随节点样式链的 zIndex
|
|
937
|
+
view.updateLabel('point', 'a', { zIndex: 30 }) // 显式层级压过跟随
|
|
938
|
+
view.updateLabel('line', 'l1', { zIndex: 10, zoomScale: 1 }) // 线路标签层级 + 字号随地图缩放
|
|
939
|
+
view.updateLabel('point', 'a', { zIndex: null, zoomScale: null }) // 回到配置默认
|
|
901
940
|
|
|
902
941
|
// addLabel(kind, ref, definition, labelId?) / removeLabel(kind, ref, labelId?)
|
|
903
942
|
const addedLabel = view.addLabel('point', 'a', { content: '{name} 备注', position: 'bottom' })
|
|
@@ -981,6 +1020,7 @@ view.clearWebGLLayers() // 清空全部自定义层
|
|
|
981
1020
|
// exportData(options?):统一入口 —— scope 选范围(all / viewport / selection),parts 选分项,format 选口径
|
|
982
1021
|
const viewFormat = view.exportData() // 全量 + view 口径(缺省)
|
|
983
1022
|
const inViewport = view.exportData({ scope: 'viewport', margin: 24 }) // 视口内,可外扩 24 屏幕像素
|
|
1023
|
+
const endpointsOnly = view.exportData({ scope: 'viewport', selectionKinds: ['lineEndpoints', 'channelEndpoints'] }) // 两端节点都在视口内
|
|
984
1024
|
const picked = view.exportData({ scope: 'selection', parts: ['station', 'channel'], withLines: true })
|
|
985
1025
|
const fullDoc = view.exportData({ format: 'full' }) // 标准数据文档:整份喂回 createGisView / importData 就回到这一屏
|
|
986
1026
|
const testFormat = view.exportData({ format: 'test', parts: ['line', 'waypoint'] })
|
package/docs/manual/20-/346/200/247/350/203/275/344/270/216/345/244/247/346/225/260/346/215/256.md
CHANGED
|
@@ -56,6 +56,8 @@ const stats = view.getStats() // clusterCount / clusterPointCount /
|
|
|
56
56
|
10 万点 + 10 万线(含通道)在 `docs/demos/GisViewDemo.vue` 里可以直接切到,交互路径上没有按总量线性增长的循环:
|
|
57
57
|
|
|
58
58
|
- **高密度纯文本标签画布化**:强制显示档(`labelOptimize` 未开、`denseMode` 未激活)下,节点层或线路层里能画布的纯文本标签达到 **1024** 条时,默认 `labelRender: 'auto'` 会让该层改用一张 `.gis-view__label-canvas`,不再为每条标签建 `div`。要求优化档也走画布时显式写 `labelRender: 'canvas'`:不设数量阈值,`maxCount` / `when` / `scanLimit` 仍照常截断,避让、换锚点与沿线滑动直接使用画布尺寸,不创建也不测量 DOM。HTML、函数返回元素、可拖拽 / 可编辑及超出 Canvas 样式能力的标签始终留在同层 DOM,因此画布与少量 DOM 可以混排;`labelRender: 'dom'` 可强制回退逐条 DOM。画布路径另有文字测量缓存(同字体 / 样式 / 文案只量一次)、交互期 `requestAnimationFrame` 合并重绘与屏外标签裁剪,连续平移 / 缩放时不会因多次指针事件重复清画布。`selftest-labels.html` 用 1100 条纯文本验证字宽只测一次、连续 5 次缩放只重绘 1 次、显式画布在优化档遵守 `maxCount: 200`,以及线路标签 6 条全部进画布;另覆盖混入 `html: true` 时只保留那一条 DOM、切回 `dom`、再切回 `auto` 的节点回收与 SVG 导出。
|
|
59
|
+
- **标签层级、节点遮挡与缩放字号**:跟随节点层级(`followNodeZIndex`)的点标签需要知道哪些更高层节点压住了自己的盒子。覆盖层为此按需建立一张 64px 屏幕网格,只收有效 `zIndex > 0` 的视口内节点;引擎没有任何非 0 节点层时整趟扫描直接跳过。判定只在标签真正参与排版时发生,被盖住的标签不占避让网格、不计 `maxCount`;`updatePoint` / `patchPoints` 会比对被改节点的层号、屏幕半径与坐标,必要重排时被改节点自己没标签也会补一次。`zoomScale` 的字号计算每轮只问一次相机,缩放指数共用 `Math.pow` 结果,交互期按 0.1px 量化后只改变换,停手再按真实字号校正盒子与避让,避免缩放过程中反复重排整屏标签。Canvas 标签仅在同层出现倒序时才排序,已有序时直接复用上一轮顺序。
|
|
60
|
+
- **选中线路抬层**:`selectionOnTop` 没有把选中线路插进普通的逐线循环,而是把线路实例、阴影、圆头、高亮与热力光晕各自拆成「普通段 + 抬层段」;只在抬层集合真的变化时重铺线路批次,集合内容相同(只换了一份引用)不会把十万条线重算一遍。两端节点单独进抬层点集合,绘制次序因此固定为普通节点 → 抬层线路 → 抬层端点,不需要为每条线动态调整节点层号。
|
|
59
61
|
- 拾取与框选共用网格索引:点走按数据范围重建的均匀网格,线走随线段重建的 `createSegmentGrid`,每次交互只遍历光标附近的候选,耗时与总量基本脱钩,`getStats().pickMs` 是随手可读的实测值(10 万规模下热态约 0.2 ~ 0.3 ms / 次)。线段按格线步进登记进它真正穿过的格子(早期按包围盒填格,一条斜跨全图的线会占掉上万格、只好整条丢进「超长线」单,而十万条线里绝大多数都是这种,于是每次拾取都要重算十万条的距离);剩下的长线只记一条包围盒,查询时按盒子先筛一遍。10 万点 / 10 万线的合成数据里(随机配对、长线极密),500 次 `pick` 从 3530 ms 降到 164 ms(0.3 ms / 次)。
|
|
60
62
|
- 拖动时「哪些线跟着这个点走」按需建索引:`collectDragLinks` 从前每次都把全部线路的端点与组内成员逐个比一遍,10 万点 / 12 万线下这一步占总 CPU 的 27%,是拖动路径上唯一还按总量线性付费的循环。现在线路超过 `LINE_BIND_TOLERANCE_SCAN_LIMIT`(2048)条时改用一张线路归属表(按 `from` / `to` 的 id 与端点坐标建,整份换数据 / 增删线 / 改绑定才重建,只改坐标就地把那一条换掉),只对命中的候选逐字段判定 —— 十万级拖动降到 CPU 的 1% 以下,单条 `updatePoint`(改名这类不动几何的改动)55 → 3.3 ms(稳态 0.02 ms)。线路不多时保留原来的浮点容差扫描(行为与从前逐字不差);索引那条路只认 id 绑定与坐标精确相等 —— 这个量级坐标都是同一份来源算出来的,容差是给手写数据留的余量。
|
|
61
63
|
- 视口里的线路改走线段网格:线路标签排版这类「只看屏幕里这一片」的路径(`forEachLineInView`)原先要把每条线的包围盒过一遍,10 万级 + 标签的 CPU profile 里它占 47 ~ 58%。现在线路超过 `LINE_VIEW_GRID_MIN_LINES`(2048)条、且估计出来的候选线段只占总数的 1/32 以内(`LINE_VIEW_GRID_COST_SHARE`)时改查拾取用的那张线段网格,再逐条按包围盒确认;候选排回要素下标顺序,脏线与没有线段的退化线单独补一遍,访问顺序与判定口径与整份扫描逐行相同。网格脏着(正在拖线 / 改线)或线路不多时照旧整份扫描。
|
|
@@ -107,7 +109,7 @@ const stats = view.getStats() // clusterCount / clusterPointCount /
|
|
|
107
109
|
- **片元管线专用化(为什么此前「感觉没提升多少」)**:之前的优化主要落在相机排帧、聚合脏标记、整份重排与符号预烤上;10 万线交互的 CPU profile 约 **98.6% idle**、`render` 自身约 **0.1%**,说明主线程不是瓶颈。真正剩余的是每条可见线在 GPU 上重复执行虚线取模 / `smoothstep` / 光晕分支的填充成本。`shaders.js` 现在给交互期 `gl.LINES` 一条只输出颜色的 `THIN_LINE_FRAGMENT_SHADER`,并给「全实线、无光晕」的四边形批次一条 `SOLID_LINE_FRAGMENT_SHADER`:跳过虚线取模、`smoothstep` 与光晕分支,只保留颜色与(非 MSAA 帧的)边缘覆盖率;有虚线或热力光晕的批次仍走通用片元。`engine.js` 的 `drawLineBatch` 按批选择,`refreshLineThinLedger` 同时给出是否全实线;线宽、端点圆头、全分辨率与停稳后的 MSAA 静态帧都不变。实测(1280×800,无头 Chrome + ANGLE / AMD D3D11,`quality: 'high'`):10 万点 / 5 万线缩放 p50 **23.2 → 16.7 ms**、p95 **28.6 → 16.8 ~ 16.9 ms**;10 万点 / 10 万线缩放三次中位 p50 **42.6 → 18.0 ms**、p95 **46.3 → 21.4 ms**。16 ~ 18 ms 已接近 60Hz 帧节拍,剩余成本仍是 GPU 填充率;细线快路径的实际门槛是**最大半宽 ≤ 0.6 设备像素且无虚线**(dpr = 1 时约 1.2px 线宽),2px 实线不会走 `gl.LINES`,但轻量四边形片元仍把同一 10 万线场景从约 **82.4 → 63.9 ms**。要继续明显提速,方向是减少可见线段数或屏幕覆盖面积,而不是继续抠 JS。
|
|
108
110
|
|
|
109
111
|
- 框选提交(`pointerup`)只做必要的工作:选中集每次同步整份换新,抬层集合因此只比引用(没有拖动 / 合并这类额外抬层时直接引用选中集本身,空集合三处共用一份),撤销选中与「同内容再框一次」不再逐个搬 / 逐个比 3.4 万个下标;组件层的选中集读数(id 表、键集合、点 / 线 / 通道条数)在一趟循环里收好并按数组引用缓存,`getSelectionInfo()` / `selectChanged()` / `selectChange` 载荷直接取现成的;选中集的存活校验走 `isKeyAlive` 的键查表,不再为每个键造对象、投影一次;抬层欠下的整份重排记在 `raiseLayoutPending` 上、由 `flushRaiseLayout` 在下一帧渲染之前补,`pointerup` 回调里不再同步排十万级场景。实测(10 万点 / 10 万线):框住 3.4 万个节点的 `pointerup` 48.7 → 15.7 ms(框小一些的几轮 9.5 / 6.5 / 6.8 ms),提交后第一帧 19.5 ~ 24.2 → 15.6 / 6.7 ~ 9.5 ms。
|
|
110
|
-
- 整份重排(`layoutScene`)也少扫几趟十万条:点 glyph 从对象池里复用(逐字段就地改写,不再每轮造十万个对象)、圆点实例用 `writeCircleGlyph` 直写进 `
|
|
112
|
+
- 整份重排(`layoutScene`)也少扫几趟十万条:点 glyph 从对象池里复用(逐字段就地改写,不再每轮造十万个对象)、圆点实例用 `writeCircleGlyph` 直写进 `prepareInstancesForLayout` 的批次数组(不再逐条造 `circleFromGlyph` 的中间对象);没有线路装饰 / 没有跑动动画 / 没有节点阴影 / 没有逐要素状态样式时,各自的十万级空扫直接跳过(`hasLineDecorations` / `hasLineEffects` / `hasPointShadows`,节点侧另有 `hasPointStateStyles()`);细线快路径的账本只在「线宽或虚线开关真的变了」时才标脏;`zIndex` 分层只有一层(绝大多数场景)时不再重铺点顺序。同一份 10 万级的 CPU profile 里 `syncRaiseSets` 6.2 → 0 ms、`buildLineEffectGlyphs` 3.69 → 0 ms、`buildLineDecorationGlyphs` 1.66 → 0.62 ms、`thinLineBatchEligible` 2.2 → 0 ms。
|
|
111
113
|
- 定向更新的线路标签候选复用:`updatePoint` / `patchPoints` 只改节点侧(补丁没动坐标 / id、筛选也没开)时,线路标签层接着用上一轮收好的候选 —— 视口矩形、画布尺寸与「上一轮显示过的下标集合」逐项核对(定义对象是缓存键),十万条线的视口扫描整个省掉;改线路内容 / 挪节点 / 换 id / 筛选联动时判据返回 `undefined`,照旧整层重扫。10 万点 / 10 万条长线 + 两层标签(DOM 75 条)实测单次 `updatePoint` p50 **4.7 → 1.7 ms**,CPU profile 采样 531 → 226、`forEachLineInView` 从热点清单消失。
|
|
112
114
|
- 超长线段换更粗的一层网格:线段网格原来给「一层里铺不下的长线」只记一条包围盒、查询按盒子先筛,长线密布时几乎等于全量重算;现在每层格子边长 ×4,粗层同样只登记线段真正穿过的格子(跨层 stamp 去重),候选从「包围盒相交」变成「几何上真的经过光标附近」。10 万条随机长线实测一次查询的候选 11101 → **2210** 条、`pick` p50 / p95 / 平均 **0.9 / 6.2 / 1.90 → 0.3 / 1.7 / 0.53 ms**;代价是极限数据集建网格 16.3 → 41.6 ms、堆内存多约 26 MB(短线为主的数据集不变)。
|
|
113
115
|
- **补点 / 删点不再因为「场景没铺完」回落整份重建**:发散渲染(见《实现原理》15.46)欠着账时,`addPoint` / `addPoints` / `addLines` 原先一律回落整份重解析(几十毫秒),「删一条 → 立刻补一条」这种最常见的串操作因此每一轮都付整份的钱。现在补点这一趟自己把没铺完的那一轮停掉、只补末尾这几条,再按新的解析结果重开一轮;删除那一趟同理(15.89)。5 万点 / 3 万线实测:稳态 `addPoint` 0.4 ~ 1.3 ms,「删一条 → 立刻补一条」29.7 → **1.3 ~ 6.4 ms**。纯删点这一趟还整段跳过通道解析(通道声明逐条没变、没删到回线与锚点时,骨架与全部回线折线照用上一轮的),选中通道时抬层集合也改成按内容比对(内容没变就不再重铺十万条线的批次)。导出这条链顺手切了三刀(空标签表先判空、节点坐标不造中间对象、折线端点共用一个取值回调):50k 点 + 30k 线全量 `exportData()` 中位 22.1 → 21.6 ms、`exportData({ scope: 'viewport' })` 36.7 → 32.5 ms(首跑那一次 36 ~ 38 ms 是 id 表与 JIT 冷着,跑第二遍就落回 20 ms 上下)。
|
|
@@ -142,7 +142,10 @@
|
|
|
142
142
|
先分清卡的是哪一半:`getStats().frameMs` 量的是引擎自己那一趟(算变换、攒实例、写缓冲、发绘制),十万级下它常年 0.1 ~ 0.8 ms;真正花时间的是**填充率** —— 十万个节点加十几万条线铺满一屏,光栅化与浏览器合成都由 GPU(没有 GPU 时是软件光栅)扛,这一半不在 `frameMs` 里。于是按顺序看四件事:① **总覆盖量**(线的屏幕总长 × 宽度 × 条数,再算上互相重叠)—— 同样 10 万点,网格邻居线(19.9 万条、线短不叠)拖动 p50 只要 7 ms,而「每 5 个点连一条到 0 号点」的长线在圆心附近叠十几层,p50 就是 194 ~ 208 ms;② **MSAA** —— 同一份几何实测 MSAA 4× 是关掉时的近 5 倍(`antialias: false`,软件光栅下引擎已经自动关),读数看 `getStats().antialias`;交互期与动画期还有更省事的一档 `interactionNoMsaa`(缺省开:拖动 / 缩放与动画在跑的那些帧画进不带 MSAA 的后备贴图、收尾整幅贴回,停手 / 停帧后照旧走 MSAA)—— 十万级实测交互期单帧 133 → 36.6 ms、拖动 p50 130 → 16 ~ 22 ms、动画帧 212 → 53 ms,读数看 `getStats().noMsaa`;③ 交互期默认走**细线快路径**(`interactionThinLines`):最大半宽 ≤ 0.6 设备像素(dpr = 1 时约 1.2px 线宽)且没有虚线时,拖动 / 缩放期间改用 `gl.LINES` 画,实测 p50 194 ~ 208 ms → 132 ~ 139 ms、同一窗口帧数 13 → 19 ~ 24,读数看 `getStats().thinLines`;2px 实线不会走这一档,但全实线四边形另有轻量片元;④ 画质档的杠杆是**分辨率**,`fast` 档按 0.75× 渲染(画布像素少一半),同一画面实测 156 → 92 ms/帧,自动档还看整帧间隔(连续画帧时掉到 40fps 以下就逐档往下掉);高分屏 / 全屏下按 `maxCanvasPixels`(缺省 400 万像素预算)压渲染倍率、或把窗口开小,都是直接减填充量。见「画质」与「大数据量」。
|
|
143
143
|
|
|
144
144
|
**一次改很多要素,回调被刷屏、历史被撑爆?**
|
|
145
|
-
把这一段包进 `view.batch(fn, { label })`:收尾只发一条 `type: 'batch'` 的 `onDataChange`(`changes`
|
|
145
|
+
把这一段包进 `view.batch(fn, { label })`:收尾只发一条 `type: 'batch'` 的 `onDataChange`(`changes` 按顺序列出每一步),历史里也只占一步。场站 / 线路直接用 `patchPoints` / `patchLines` / `removePoints` / `removeLines`,通道与分组把逐条 `updateChannel` / `removeChannel` / `splitChannelGroups` / `removeChannelGroup` 放进同一个 `batch` 即可,见「批量更新」里的增删改配方。
|
|
146
|
+
|
|
147
|
+
**解除合并之后为什么没有默认选中恢复出来的节点?**
|
|
148
|
+
这是现在的缺省口径:`splitPoint(source, ...)` 的 `options.select` 默认为 `false`,只把来源节点本身从选中集里摘掉,恢复 / 拆分出来的节点不选中,其它无关选中也不动。旧 Demo 在调用后又手动 `selectFeatures()`,看起来像组件默认选中。需要保持「解除后继续编辑这批节点」时显式传 `select: true`,例如 `view.splitPoint('hub', null, { select: true })`;手工拆分同样支持。
|
|
146
149
|
|
|
147
150
|
**配置写了没反应,控制台也不报错?**
|
|
148
151
|
听着 `onWarning`(或 `view.on('warning', …)`):配置项的键写错、功能预设 / 画质档位拼错、订阅了不存在的事件名都会点名说一句,同一个错只提醒一次,见「配置提醒」。
|
|
@@ -187,7 +190,7 @@
|
|
|
187
190
|
| 快捷键与复制 / 合并 / 删除 | `GisViewShortcuts`、`GisViewShortcut`、`GisViewShortcutAction`、`GisViewCopyOptions`、`GisViewCopyContext`、`GisViewCopyStartOptions`、`GisViewPasteOptions`、`GisViewCopyItem`、`GisViewClipboardItem`、`GisViewMergeOptions`、`GisViewMergeContext`、`GisViewPointStyleSnapshot`、`GisViewPointRef`、`GisViewMergeResult`、`GisViewMergeFailure`、`GisViewMergeOutcome`、`GisViewRemovePointsOutcome`、`GisViewRemoveSelectedOutcome`、`GisViewRemoveOptions`、`GisViewRemoveScope`、`GisViewRemovePayload`、`GisViewRemoveResult`、`GisViewRemoveOutcome`、`GisViewRemoveFailure`、`GisViewRemoveAction`、`GisViewRemovePoint`、`GisViewRemoveLine`、`GisViewRemoveWaypoint`、`GisViewRemoveGroup`、`GisViewRemoveChannel`、`GisViewRemoveCounts`、`GisViewChannelSelectMode`、`GisViewUpdateItemsOutcome`、`GisViewUpdateItemEntry` |
|
|
188
191
|
| 相机与视图 | `GisViewCamera`、`GisViewViewport`、`GisViewFocusOptions`、`GisViewFocusTarget`、`GisViewExportImageOptions`、`GisViewExportSelectionOptions`、`GisViewExportSelectionResult` |
|
|
189
192
|
| 导出数据 | `GisViewExportScope`、`GisViewExportPart`、`GisViewExportDataOptions`、`GisViewExportDataResult`、`GisViewFeatureRef`、`GisViewExportFilterOptions`、`GisViewExportMeta`、`GisViewExportedLabel`、`GisViewStationRecord`、`GisViewPointRecord`、`GisViewLineRecord`、`GisViewChannelRecord`、`GisViewExportFormat`、`GisViewBuiltinExportFormat`、`GisViewExportFormatContext`、`GisViewExportFormatAdapter` |
|
|
190
|
-
| 开关 / 历史 / 事件 | `GisViewFeatureName`、`GisViewFeatures`、`GisViewFeatureState`、`GisViewFeaturePreset`、`GisViewFeaturesInput`、`GisViewSelectTrigger`、`FEATURE_NAMES`、`FEATURE_PRESETS`、`FEATURE_PRESET_NAMES`、`
|
|
193
|
+
| 开关 / 历史 / 事件 | `GisViewFeatureName`、`GisViewFeatures`、`GisViewFeatureState`、`GisViewFeaturePreset`、`GisViewFeaturesInput`、`GisViewSelectTrigger`、`FEATURE_NAMES`、`FEATURE_PRESETS`、`FEATURE_PRESET_NAMES`、`featureDefault`、`normalizeFeatures`、`featureOn`、`hasForcedFeatures`、`GisViewHistoryOptions`、`GisViewHistoryState`、`GisViewHistoryEntry`、`GisViewHistoryRecord`、`GisViewHistoryOp`、`GisViewHistoryOpEntry`、`GisViewHistoryRecorder`、`GisViewHistoryHost`、`GisViewHistoryPayload`、`GisViewHistoryStepResult`、`GisViewHistoryAction`、`GisViewHistoryCollection`、`createGisHistory`、`normalizeHistoryOptions`、`applyHistoryOps`、`DEFAULT_HISTORY_LIMIT`、`HISTORY_COLLECTIONS`、`GisViewEventMap`、`GisViewEventName`、`GisViewEventNameInput`、`GisViewEventWildcard`、`GisViewEventListener`、`GisViewAnyEventListener`、`GisViewEventBus`、`GisViewEventBusHost`、`createGisEventBus`、`EVENT_NAMES` |
|
|
191
194
|
| 动画效果与预热 | `GisViewLineEffect`、`GisViewLineEffectInput`、`GisViewPointEffect`、`GisViewPointEffectInput`、`GisViewEffectsOptions`、`GisViewEffectsInput`、`GisViewEffectsReadout`、`GisViewLineEffectReadout`、`GisViewPointEffectReadout`、`GisViewPrebakeOptions`、`GisViewPrebakeCombo`、`GisViewPrebakeReadout`、`GisViewSymbolCombos`、`PREBAKE_COMBO_KEYS`、`LINE_EFFECT_DEFAULTS`、`LINE_EFFECT_KEYS`、`POINT_EFFECT_DEFAULTS`、`POINT_EFFECT_KEYS`、`EFFECT_OPTION_KEYS`、`PREBAKE_OPTION_KEYS`、`normalizeLineEffect`、`normalizePointEffect`、`normalizeEffectsOptions`、`normalizePrebakeCombo`、`normalizePrebakeOptions`、`isEffectConfig`、`isEffectsExplicitlyOff`、`wrapPhase`、`phaseSeed`、`polylineLength`、`samplePolyline`、`lineEffectDistance`、`pointEffectPhase`、`sameLineEffect`、`samePointEffect` |
|
|
192
195
|
| 坐标与映射 | `GisViewGeoProjection`、`GisViewGeoMapper`、`GisViewGeoMapperOptions`、`GisViewPointerState`、`GisViewResolvedGeoJson`、`createGeoProjection`、`createGeoMapper` |
|
|
193
196
|
| 搜索 | `GisViewSearchOptions`、`GisViewSearchScope`、`GisViewSearchScopeInput`、`GisViewSearchHit`、`GisViewSearchGroupItem`、`GisViewSearchResult`、`GisViewVisiblePoint` |
|