Repository navigation
fix(extensions): measure brushingRadius in true meters on MapView - #10668
chrisgervang wants to merge 13 commits into
Conversation
[Medium impact] The PR appears safe to merge, with the previous WebGPU mismatch fixed and no new actionable issues found. SummaryCorrects low-zoom
chrisgervang acknowledged the remaining large-radius approximation and accepted the difference between map distances and globe chord distances. Those earlier threads are not reopened. Reviews (15) · Last reviewed commit: "fix(extensions): scale the WebGPU brushi..." · Reviewed by Greptile |
a0038ec to
39bdfea
Compare
39bdfea to
54fd922
Compare
2f2f1ac to
fd53c93
Compare
fd53c93 to
c9abe1f
Compare
brushing_isPointInRange divided the common-space distance by project.commonUnitsPerMeter, which below the auto-offset zoom is the equatorial Web Mercator value. brushingRadius was therefore effectively radius * cos(latitude) in real meters on MapView (about 2.4 km for a 3 km radius in San Francisco), while at zoom >= 12 (auto-offset mode) and on GlobeView it already measured true meters. The same radius thus selected different objects across the zoom-12 boundary and between views. Apply project_size_at_latitude() at the pointer's latitude under PROJECTION_MODE_WEB_MERCATOR + LNGLAT + !pseudoMeters, mirroring what project_size() does for geometry sizes. Auto-offset, globe and identity modes are unchanged. The map render golden now shows the same circle as its GlobeView twin. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
…ter and object Scaling the Web Mercator distance by the pointer's latitude alone gives different effective radii north and south of the pointer for large radii. Use the mean latitude of the two endpoints, which is symmetric and exact to first order in the latitude difference, and describe the remaining approximation in the docs instead of claiming exact meters. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
… of Remarks Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
c9abe1f to
fd8d51c
Compare
… into claude/fix-brushing-radius-meters-GveWO # Conflicts: # docs/whats-new.md
… into claude/fix-brushing-radius-meters-GveWO
… into claude/fix-brushing-radius-meters-GveWO # Conflicts: # docs/whats-new.md
… into claude/fix-brushing-radius-meters-GveWO
… into claude/fix-brushing-radius-meters-GveWO
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7fcb6bb. Configure here.
… into claude/fix-brushing-radius-meters-GveWO
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9
ibgreen
left a comment
There was a problem hiding this comment.
The latitude correction is scoped to geodetic Mercator with pseudo-meters disabled. Please reconcile the shared shader changes with the globe brushing PR and verify the low-zoom result alongside the auto-offset case after rebasing.
athomct
left a comment
There was a problem hiding this comment.
The change looks correct. Optional points:
- The correction divides by
project_size_at_latitudeat the mean latitude of the pointer and the object. For a large radius at a high latitude, this is approximate (about 3% at 70° with a 1,000 km radius). Please say "approximately" in the docs, or use the exact Mercator latitude difference. - The visible circle grows by 1/cos(latitude) below zoom 12 (2x at 60°). Apps that tuned
brushingRadiusby eye will see a change. A short entry inupgrade-guide.mdunder "Upgrading to v10" can help. - The same
whats-new.mdpoint as #10661: the entry is in the v9.4 section.
Pre-existing, optional: brushing.mousePos is an absolute lng/lat, but project_position reads it in the layer's coordinate system. Layers with coordinateSystem: 'meter-offsets' or 'lnglat-offsets' therefore put the brushing center at the wrong place.

Follow up of #10661
Background
brushing_isPointInRangedivides the distance byproject.commonUnitsPerMeter. Below zoom 12 (PROJECTION_MODE_WEB_MERCATOR) that is the equatorial value, sobrushingRadiusonMapViewisradius × cos(latitude)in real meters, while auto-offset mode andGlobeViewalready measure true meters. The same radius selects different objects across the zoom-12 boundary and between views.brushing-sourceonMapView:brushingRadius: 3000m, pointer at the canvas centre, San Francisco at zoom 11.5The before image is the golden from #10661; the after image is the regenerated golden. The circle grows by 1/cos(37.75°) and now matches the extent of
brushing-source-globe.Change List
brushingshader module (GLSL and WGSL): underWEB_MERCATOR+LNGLATwithout pseudo-meters, divide the distance byproject_size_at_latitude()at the mean latitude of the pointer and the object, mirroringproject_size()MapViewbelow zoom 12: the circle grows by 1/cos(latitude), 1.26x at 37.75°, 2x at 60°brushingRadiusmean meters as documented; there is no post-9.4 upgrade guide section to note it in yetbrushing-source.pngregenerated: the map circle now matches its globe twin (about 140 px for 3 km at zoom 11.5); other brushing goldens unchangeddocs/whats-new.mdnotes the MapView changeRan the render spec headless on WebGL,
tscand lint.Note
Low Risk
Low risk bug fix updating distance calculations in the brushing shader module with no API changes.
Overview
Corrects the
BrushingExtensiondistance calculation onMapViewbelow zoom 12 so thatbrushingRadiusrepresents true meters. In both GLSL and WGSL shaders, the calculated distance is now adjusted by latitude scaling (project_size_at_latitude) evaluated at the midpoint latitude between the cursor and the candidate point. This eliminates thecos(latitude)shrinkage at low zoom levels, ensuring consistent brushing behavior across zoom levels and parity withGlobeView.Reviewed by Cursor Bugbot for commit a793ea7. Bugbot is set up for automated code reviews on this repo. Configure here.
Generated by Claude Code