Conversation
- Auto create PR when .skills directory changes - File validation (type, size, content check) - Only run on official antvis/L7 repository - Support manual trigger with force option
1. 修复蜂窝热力图 (hexagon): - 调整六边形方向为 pointy-top,与 d3-hexbin 一致 - 翻转 y 坐标方向以匹配屏幕坐标系 2. 修复网格热力图 (grid): - 改用屏幕像素坐标划分网格,与 hexagon 一致 - 修正 xOffset/yOffset 计算:正方形顶点范围是 [-√2/2, √2/2] 3. 修复 count 聚合方法: - 在 statMap 中添加 count 方法 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
主要优化: - TileLayerService: 使用 Map 存储瓦片实例,查找复杂度从 O(n) 降为 O(1) - TileLayerService: 实现分帧销毁机制,避免大量瓦片销毁阻塞渲染 - TileLayerService: 添加渲染列表缓存和脏标记,减少每帧重建 - BaseLayer: 合并多个 filter 操作,减少中间数组创建 - BaseLayer: 优化视图状态比较,使用数值比较替代字符串比较 - TilesetManager: 缓存 tiles getter,避免每次访问都排序 - TilesetManager: 使用 Set 存储当前瓦片 key,加速查找 - TilesetManager: 合并 updateTileVisible 遍历,减少迭代次数 - SourceTile: 缓存 bounds 和 bboxPolygon,避免重复计算 - TilePickService: 优化遍历,跳过未加载的瓦片 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
主要优化: - math.ts: 表达式预编译为函数,避免循环中 JSON 序列化/反序列化 - 对于 256x256 瓦片,从 65536 次序列化操作优化为 1 次编译 - 预分配 Float32Array 结果数组,避免动态扩容 - operationSchema.ts: 使用快速选择算法计算百分位 - 复杂度从 O(n log n) 降到 O(n) - 预分配 Uint8Array 数组存储 RGB 数据 - getRasterData.ts: 多波段数据并行请求 - 使用 Promise.all 并行请求,减少网络等待时间 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
主要修复: 1. 修复 UBO std140 布局问题 - vec3 只占 3 floats,之前的布局导致 u_RelativeOrigin 位置错误 2. 修复 extrude/water/ocean 图层在相对坐标模式下 UV 计算错误 3. 修复 Pipeline 缓存 key 生成不完整导致的状态不一致问题 性能优化: 1. 添加颜色解析缓存 (rgb2arr),避免重复解析相同颜色 2. 优化数据映射插件的过滤流程,减少遍历次数 3. 添加质心计算缓存 其他修复: 1. 移除地图适配器中的硬编码 API Keys 2. 修复 Scene.emit 调用错误 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- fix: 修复 citybuliding 目录名拼写错误 (citybuliding -> citybuilding) - refactor: 用自定义实现替代 lodash 依赖,优化包大小 - refactor: 将 SimpleMapCoord 移到 maps 包本地 utils - fix: 添加 getDefault 方法返回类型 - fix: 修复 merge 函数的类型参数 - fix: 添加 initCfg 方法 option 参数的条件检查 - chore: 更新 build 脚本,添加 clean-dist 步骤 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 新增 packages/source/src/utils/csv.ts 实现 csvParse 函数 - 支持 CSV 基础解析、引号处理、转义引号、各种换行符 - 移除 d3-dsv 和 @types/d3-dsv 依赖 - 添加完整的单元测试覆盖边界情况 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 在 lodash-adapter.ts 中添加 extent 函数实现 - 移除 d3-array 和 @types/d3-array 依赖 - 更新 FeatureScalePlugin 使用 lodashUtil.extent - 添加 lodash-adapter 单元测试 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 新增 packages/utils/src/color-parser.ts 实现颜色解析 - 支持 hex、rgb/rgba、hsl/hsla 和 CSS 颜色名称 - 更新 color.ts 使用自定义 parseColor 函数 - 移除 utils 和 layers 包中的 d3-color 依赖 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 在 color-parser.ts 中添加 interpolateRgbBasis 函数 - 实现分段线性颜色插值功能 - 更新 FeatureScalePlugin 使用自定义 interpolateRgbBasis - 移除 layers 包中的 d3-interpolate 依赖 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 新增 packages/source/src/utils/hexbin.ts 实现六边形分箱算法 - 使用 odd-q offset 坐标系统与 d3-hexbin 兼容 - 更新 hexagon.ts 使用自定义 hexbin 函数 - 移除 d3-hexbin 和 @types/d3-hexbin 依赖 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 将 odd-q 偏移(奇数列偏移)改为 odd-r 偏移(奇数行偏移) - 完全复制 d3-hexbin 的分箱算法逻辑 - 修复中心坐标计算方式: - x = (pi + (pj & 1) / 2) * dx - y = pj * dy - 修复访问器类型签名以支持 3 个参数 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 新增 packages/layers/src/utils/scale.ts 实现 10 种比例尺 - scaleLinear, scalePow, scaleLog: 连续比例尺 - scaleSequential, scaleDiverging: 连续颜色比例尺 - scaleQuantile, scaleQuantize, scaleThreshold: 离散比例尺 - scaleOrdinal: 枚举比例尺 - scaleTime: 时间比例尺 - 更新 FeatureScalePlugin 使用自定义比例尺 - 移除 d3-scale 和 @types/d3-scale 依赖 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 添加 sanitizeDomain 函数处理 domain 中的 undefined、null、NaN 值 - 修复当 extent 返回 [undefined, undefined] 时导致 NaN 计算的问题 - 处理 domain 只有一个值或为空的情况 - 处理 domain[0] === domain[1] 时除以零的问题 - 所有连续比例尺现在都对无效输入有容错处理 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 移除 lodash 依赖(已有自定义 lodash-adapter 实现) - 移除 layers 包中未使用的 extrude-polyline、polyline-miter-util、gl-vec2 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 使用现代浏览器原生支持的 ResizeObserver API - 移除 element-resize-detector 和 @types/element-resize-detector 依赖 - 减少第三方依赖,提升稳定性 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
主要改进: - 统一使用 Pointer Events API 处理鼠标和触摸事件,移除冗余监听 - 提取坐标转换逻辑为公共方法,减少重复代码 - 优化单击/双击检测逻辑,区分 click 和 dblclick 事件 - 修复 mousedown 监听器内存泄漏(capture 参数不匹配) - 添加容器边界缓存,优化性能 - 新增 Press 事件类型,语义更清晰 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
新增 refactor 测试分类,包含以下验证场景: - interactionTest: 交互测试(拖拽、单击、双击、长按、hover、contextmenu) - resizeObserverTest: ResizeObserver测试(容器大小变化、canvas自适应) - displayTest: 显示测试(点、线、多边形、热力图各图层渲染) - animationTest: 动画测试(波纹动画、流动线动画、数据更新动画) - eventsTest: 事件系统测试(所有InteractionEvent类型统计) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 使用 querySelector 从容器中获取 canvas 元素 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. 移除 onClick/onDoubleClick 中的 stopPropagation,允许事件冒泡到底层地图 2. 通过 Hover 事件发送 mousedown/mouseup/click/dblclick,保持向后兼容 3. 添加 vite optimizeDeps.exclude 配置,避免 esbuild 预构建本地包 4. 修复 l7-draw demo 文件中的事件监听和 API 使用问题 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. 添加 @antv/l7-draw 开发依赖用于测试 2. 升级 vite-plugin-string 到 1.2.3 3. 添加 .playwright-mcp 到 .gitignore 4. 代码格式化 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
独立添加的 Marker(通过 scene.addMarker)之前没有注册相机变化事件, 导致地图缩放/平移时 marker 位置不更新。现已在 MarkerService 中添加 camerachange/viewchange 事件监听来同步更新所有 marker 位置。 同时修复了 addMarkerLayers 方法中错误清空 unAddMarkers 的 bug。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
## 高优先级修复 - fix: 修复 Popper destroy 时未从 conflictPopperList 移除实例的内存泄漏 - fix: 删除 Marker 中未实现的遗留方法 addDragHandler 和 onUp - perf: 为 Popup 高频事件添加 RAF 节流,提升性能 ## 中优先级修复 - perf: 优化 sideEffects 配置,精确声明副作用文件以提升 tree-shaking - refactor: 新增 EventManager 工具类统一管理事件绑定/解绑 - chore: 删除源码中的构建产物 index.css,改用 less 源文件 ## 低优先级修复 - test: 恢复 marker.spec.tsx 中被注释的测试用例 - test: 新增 eventManager.spec.ts 测试文件 - test: 新增 popper.spec.ts 测试文件验证内存泄漏修复 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
修改 ILayerPopupOption 接口,trigger 参数从必填改为可选。 默认值 'hover' 在 getDefault 方法中已定义。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
当用户未指定 trigger 时,getDefault 方法中 isHoverTrigger 判断错误。 现在先获取最终 trigger 值再判断是否为 hover 模式。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
添加明确的返回类型声明,并在 trigger 为 undefined 时使用默认值 'hover'。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Jest 配置添加 .less 文件支持 - ResizeObserver mock 添加 disconnect 方法 - popup 测试添加 fake timers 处理 RAF - marker 测试添加 overflowHide: false 避免位置问题 - imageLayer/raster-tile 测试添加 afterEach 清理 scene - citybuilding 测试跳过(gl 原生模块内存问题) - source 测试更新 grid 聚合期望值 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 添加 yarn test、jest 等测试相关权限配置 - 更新集成测试快照图片 - 新增多个测试场景的快照文件 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
配置 style-loader 替代 mini-css-extract-plugin,使 umd 产物的 css 直接打包进 l7.js,用户无需单独引入 css 文件。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 将 maxError 从 0 改为 100,允许 macOS 和 Linux CI 环境之间的渲染差异 - 添加 @rollup/rollup-darwin-arm64 依赖以支持本地测试运行
🦋 Changeset detectedLatest commit: c014ac9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of ChangesHello @lzxue, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request represents a major internal overhaul of the L7 codebase, aimed at enhancing overall performance, streamlining dependencies, and updating fundamental architectural patterns. The changes span critical areas such as event handling, tile rendering, and data processing, all rigorously validated by new testing and demonstration examples. This 'Beta' release signifies a substantial step forward in the project's stability and efficiency. Highlights
Changelog
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces significant refactoring and performance optimizations across various modules. Key changes include migrating from external libraries like D3, Lodash, Hammer.js, and element-resize-detector to custom implementations or native browser APIs (e.g., ResizeObserver, Pointer Events). This reduces external dependencies and improves bundle size. Performance enhancements are evident in caching mechanisms for centroid calculations, tile data, and color parsing, as well as optimized raster band operations and parallel data fetching. The event handling system has been modernized using Pointer Events. New demo files have been added to validate the refactored functionalities. Overall, these changes contribute to a more robust, performant, and maintainable codebase.
I am having trouble creating individual review comments. Click here to see my feedback.
packages/source/src/utils/tile/getRasterData.ts (58-79)
Refactoring getMultiArrayBuffer to use Promise.all for parallel requests is a critical performance optimization. This significantly reduces the total time required to fetch multiple raster bands by performing network requests concurrently, leading to faster tile loading.
packages/source/src/utils/bandOperation/math.ts (67-133)
The introduction of compileExpressionInner to pre-compile raster band expressions is a major performance optimization. By converting the expression into an executable function once, it avoids repeated JSON parsing and dynamic evaluation within the main loop, which can be very costly for large datasets. This is a critical improvement for raster processing efficiency.
packages/utils/src/lodash-adapter.ts (1-481)
The comprehensive custom implementations of various Lodash utility functions are a major refactoring effort. This significantly reduces the external dependency footprint, which can lead to a smaller bundle size and potentially better control over performance characteristics. Ensure that these custom implementations are thoroughly tested to match the behavior of their Lodash counterparts.
packages/core/src/services/interaction/InteractionService.ts (303-305)
The comment states not to call stopPropagation() to avoid blocking native map events. This is a critical design decision for interoperability with underlying map libraries. Ensure that this behavior is consistently maintained across all event handlers to prevent unexpected issues with map interactions or other L7-draw features that might rely on native events.
packages/core/src/services/interaction/InteractionService.ts (349-351)
The comment states not to call stopPropagation() to avoid blocking native map events. This is a critical design decision for interoperability with underlying map libraries. Ensure that this behavior is consistently maintained across all event handlers to prevent unexpected issues with map interactions or other L7-draw features that might rely on native events.
packages/utils/src/tileset-manager/tileset-manager.ts (35-44)
Introducing sortedTilesCache, tilesCacheDirty, and currentTilesKeySet significantly improves the performance of tile management. Caching the sorted tile list avoids repeated sorting, and using a Set for currentTilesKeySet provides O(1) lookup for tile presence, which is crucial for efficient updates and pruning.
packages/source/src/transform/grid.ts (1-4)
The refactoring of the grid aggregation logic to use screen pixel coordinates instead of lat/lon-based grid is a significant improvement. This approach is generally more robust for ensuring grid closure and consistent visual representation across different zoom levels, especially for heatmap-like visualizations.
packages/utils/src/tileset-manager/tileset-manager.ts (157-160)
Changing the tile lookup from !this.currentTiles.includes(tile) (O(n) complexity) to !this.currentTilesKeySet.has(tile.key) (O(1) complexity) is a significant performance improvement. This is especially beneficial when dealing with a large number of tiles, as it makes the reloadAll operation much faster.
packages/layers/src/plugins/ShaderUniformPlugin.ts (122-180)
The detailed construction of the UBO data array following GLSL std140 layout rules, including explicit padding for alignment, is a critical improvement for WebGL2 performance and correctness. This ensures efficient data transfer to the GPU and avoids potential alignment issues that could lead to rendering glitches or crashes.
packages/source/src/utils/bandOperation/operationSchema.ts (55-88)
Implementing quickselect and partition for percentile calculation is a significant performance improvement. This changes the time complexity from O(n log n) (due to sorting) to O(n), which is crucial for processing large raster datasets efficiently.
packages/utils/src/tileset-manager/tileset-manager.ts (391-395)
Changing the tile lookup from !this.currentTiles.includes(tile) (O(n) complexity) to !this.currentTilesKeySet.has(tile.key) (O(1) complexity) is a significant performance improvement. This is especially beneficial when dealing with a large number of tiles, as it makes the resizeCacheTiles operation much faster.
packages/layers/src/tile/service/TileLayerService.ts (19-21)
Switching from an array (layerTiles) to a Map (layerTilesMap) for storing tile instances is a significant performance improvement. This changes tile lookup complexity from O(n) to O(1), which is crucial for applications with many tiles.
packages/layers/src/tile/service/TileLayerService.ts (24-27)
Implementing a pendingDestroyQueue with maxDestroyPerFrame for deferred tile destruction is an excellent performance optimization. This prevents UI freezes or hitches during rapid tile changes by spreading the destruction workload across multiple animation frames.
packages/layers/src/plugins/FeatureScalePlugin.ts (241-250)
Automatically setting ScaleTypes.SEQUENTIAL for color attributes when values are strings (colors) is a good heuristic for color ramps. This ensures proper interpolation. However, ensure that this automatic override doesn't conflict with explicit scale configurations where a user might intentionally want a different scale type for color with string values (though less common).
packages/utils/src/color.ts (13-15)
Introducing colorCache with COLOR_CACHE_MAX_SIZE for caching color parsing results is a good performance optimization. Repeated parsing of the same color strings can be avoided, especially in rendering loops, leading to improved efficiency. The cache eviction strategy (deleting half) is simple but effective.
packages/source/src/base-source.ts (242-244)
Adding an if (option) check before merging this.cfg with option is a good defensive programming practice. It prevents mergeWith from being called with an undefined option, which could lead to unexpected behavior or errors if mergeWith is not designed to handle undefined sources gracefully.
packages/layers/src/tile/service/TileLayerService.ts (31-33)
Introducing renderLayersCache and renderCacheDirty for caching rendered layers is a good performance optimization. This avoids redundant computations and array re-creations on every frame if the set of visible and loaded layers hasn't changed.
packages/layers/src/tile/core/BaseLayer.ts (210-216)
Combining multiple filter calls into a single filter with logical AND (&&) is a good performance optimization. It reduces the overhead of creating intermediate arrays and iterating over the data multiple times.
packages/source/src/utils/bandOperation/math.ts (150)
Pre-allocating the rasterData array with new Float32Array(length) is a good performance optimization. It avoids the overhead of dynamic array resizing (e.g., with Array.push()) within the main processing loop, leading to faster execution.
packages/source/src/utils/bandOperation/operationSchema.ts (25-27)
Pre-allocating the data array with new Uint8Array(length * 3) for RGB channels is a good performance optimization. It avoids the overhead of dynamic array resizing (e.g., with Array.push()) within the loop, leading to faster execution for color stretching.
packages/layers/src/tile/core/BaseLayer.ts (93-99)
Changing the comparison logic for lastViewStates from toString() to individual numeric comparisons is a good optimization. String conversion and comparison can be less efficient and sometimes lead to unexpected results with floating-point numbers compared to direct numeric comparison.
tests/integration/utils/generator.ts (58)
Changing maxError from 0 to 150 allows for a significant pixel difference in snapshot tests. While the comment explains this is for cross-platform rendering, a value of 150 seems quite high. Consider if a smaller, more precise maxError can be determined to still catch significant visual regressions while accounting for minor platform differences. If not, please provide more context on why such a large threshold is necessary.
packages/layers/src/tile/service/TilePickService.ts (70-71)
Adding a check if (!tile.isLoaded) continue; in updateHighLight is a good performance optimization. It avoids unnecessary processing for tiles that are not yet loaded, which can be a common scenario during map navigation.
packages/layers/src/core/shape/Path.ts (53-58)
The hexagon function now flips the y-coordinate (-p[1]) to ensure pointy-top orientation and closure with d3-hexbin. This is a specific adjustment for compatibility and visual correctness. Ensure this transformation is well-documented, especially if users might expect a flat-top orientation by default or if it affects coordinate system interpretations elsewhere.
packages/utils/src/tileset-manager/tile.ts (48-49)
Caching _bounds and _bboxPolygon properties is a good performance optimization. Calculating these values can be computationally intensive, so storing them after the first computation avoids redundant work, especially if they are accessed frequently.
packages/layers/src/core/BaseLayer.ts (1383)
The setEarthTime method is marked with a console.warn('empty fn');. This suggests it's a placeholder or not fully implemented. If this method is intended to be used, it should either have a proper implementation or be clearly documented as a no-op with a reason.
packages/component/src/popup/layerPopup.ts (24)
Making the trigger property optional in ILayerPopupOption could be a breaking change if external code relied on it being always present. While the implementation provides a default, it's good to be aware of the potential impact on consumers of this interface.
packages/utils/src/tileset-manager/tileset-manager.ts (243-245)
Clearing currentTilesKeySet, sortedTilesCache, and tilesCacheDirty in the clear method ensures that the tile manager is fully reset and no stale data or references persist. This is good practice for resource management and preventing unexpected behavior after clearing tiles.
packages/utils/src/tileset-manager/tileset-manager.ts (260-269)
Refactoring updateTileVisible to use beforeVisibleMap and iterate over a pre-collected tiles array is a good optimization. This avoids repeated calls to Array.from(this.cacheTiles.values()) and ensures that the visibility check is performed efficiently.
packages/component/src/css/index.css (1-781)
The index.css file has been removed. Ensure that all necessary styles are correctly migrated to index.less or handled by the build process to avoid any visual regressions.
skills/references/core/scene.md (290-293)
This section contains Git merge conflict markers (<<<<<<< HEAD, =======, >>>>>>> e7dae1ffc7f56320e1df47326483cc2d9dbb991e). These should be resolved to ensure the document is correctly formatted and displays the intended content.
[English Template / 英文模板]
🤔 这个变动的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
📝 更新日志
☑️ 请求合并前的自查清单