fix: 修复高 zoom 下经纬度投影精度偏移#2865
Conversation
🦋 Changeset detectedLatest commit: 1695ffd 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 |
There was a problem hiding this comment.
Code Review
This pull request addresses high-zoom coordinate precision issues (Issue #1578). It introduces a new validation demo, updates CoordinateSystemService to support exact center projection without rounding, and modifies projection.glsl to keep fp64 low parts in explicit branches to prevent GLSL compilers from rounding away sub-ULP values. The review feedback highlights potential memory leaks in the demo code due to uncleaned global window resize listeners and undestroyed draw tools when the scene is destroyed.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
🤔 这个变动的性质是?
🔗 相关 Issue
Fixes #1578
💡 需求背景和解决方案
在高 zoom 层级下,使用经纬度数据绘制 L7 图层时,图层渲染位置会和鼠标位置 / 底图投影位置出现像素级偏移。这个问题在
L7 Draw高层级绘制点、线、面时比较明显,表现为鼠标点击位置和最终绘制图形位置不重合。原因主要有两处:
LNGLAT_OFFSET坐标链路里,shader 中 high / low 精度拆分后的 low part 过早参与大经纬度 float 计算,在高 zoom 下容易被 float32 舍入掉,导致低位精度没有真正补偿到最终屏幕投影。setViewportCenter会触发 viewport center 更新,但旧实现使用Math.fround()后的 center 计算viewportCenterProjection,提前损失了中心点尾部精度。本次修改:
projection.glsl中新增project_offset_with_low,让 fp64 low part 在 offset 转像素贡献时独立参与计算,避免被 GLSL 编译器提前折叠到大经纬度计算中。CoordinateSystemService#setViewportCenter场景下保留 exact center projection,避免 relative coordinates 路径提前丢失中心点精度。issue1578CoordinatePrecisionbugfix demo,用于验证高 zoom 下点、线、面以及L7 Draw绘制时的坐标一致性。lngLatToContainer反投影位置的像素差。本地验证:
git diff --checkprettier --checkpnpm dev --host 127.0.0.1bugfix / issue1578CoordinatePrecision22.000point last vertex delta: dx -0.00 px, dy 0.00 px📝 更新日志
LNGLAT_OFFSET, and add a bugfix demo for point, line, polygon, and L7 Draw alignment verification.LNGLAT_OFFSET经纬度投影精度损失导致的坐标偏移问题,并新增点、线、面及 L7 Draw 对齐验证 demo。☑️ 请求合并前的自查清单