Skip to content

fix(extensions): measure brushingRadius in true meters on MapView - #10668

Open
chrisgervang wants to merge 13 commits into
claude/fix-brushing-globe-GveWOfrom
claude/fix-brushing-radius-meters-GveWO
Open

chrisgervang wants to merge 13 commits into
claude/fix-brushing-globe-GveWOfrom
claude/fix-brushing-radius-meters-GveWO

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Follow up of #10661

Background

brushing_isPointInRange divides the distance by project.commonUnitsPerMeter. Below zoom 12 (PROJECTION_MODE_WEB_MERCATOR) that is the equatorial value, so brushingRadius on MapView is radius × cos(latitude) in real meters, while auto-offset mode and GlobeView already measure true meters. The same radius selects different objects across the zoom-12 boundary and between views.

Before After
brushing-source on MapView: brushingRadius: 3000 m, pointer at the canvas centre, San Francisco at zoom 11.5 before after

The 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

  • brushing shader module (GLSL and WGSL): under WEB_MERCATOR + LNGLAT without pseudo-meters, divide the distance by project_size_at_latitude() at the mean latitude of the pointer and the object, mirroring project_size()
    • Behavior change on MapView below zoom 12: the circle grows by 1/cos(latitude), 1.26x at 37.75°, 2x at 60°
    • Makes brushingRadius mean meters as documented; there is no post-9.4 upgrade guide section to note it in yet
  • brushing-source.png regenerated: the map circle now matches its globe twin (about 140 px for 3 km at zoom 11.5); other brushing goldens unchanged
  • Documentation: docs/whats-new.md notes the MapView change

Ran the render spec headless on WebGL, tsc and lint.


Note

Low Risk
Low risk bug fix updating distance calculations in the brushing shader module with no API changes.

Overview
Corrects the BrushingExtension distance calculation on MapView below zoom 12 so that brushingRadius represents 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 the cos(latitude) shrinkage at low zoom levels, ensuring consistent brushing behavior across zoom levels and parity with GlobeView.

Reviewed by Cursor Bugbot for commit a793ea7. Bugbot is set up for automated code reviews on this repo. Configure here.


Generated by Claude Code

@coveralls

coveralls commented Sep 7, 2026 •

Copy link
Copy Markdown

Coverage Status

Coverage is 84.83% — claude/fix-brushing-radius-meters-GveWO into claude/fix-brushing-globe-GveWO. No base build found for claude/fix-brushing-globe-GveWO.

@greptile-apps

greptile-apps Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the previous WebGPU mismatch fixed and no new actionable issues found.

Summary

Corrects low-zoom MapView brushing distances in both WebGL and WebGPU.

  • MapView brushing keeps its radius in true meters below zoom 12.

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

@chrisgervang
chrisgervang force-pushed the claude/fix-brushing-radius-meters-GveWO branch from 39bdfea to 54fd922 Compare September 25, 2026 17:43
@chrisgervang
chrisgervang force-pushed the claude/fix-brushing-radius-meters-GveWO branch from 2f2f1ac to fd53c93 Compare October 3, 2026 22:12
@chrisgervang
chrisgervang force-pushed the claude/fix-brushing-radius-meters-GveWO branch from fd53c93 to c9abe1f Compare October 3, 2026 22:31
@chrisgervang chrisgervang added this to the v9.4 patch releases milestone Oct 10, 2026
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
@chrisgervang
chrisgervang force-pushed the claude/fix-brushing-radius-meters-GveWO branch from c9abe1f to fd8d51c Compare October 23, 2026 00:34
@chrisgervang
chrisgervang requested a review from ibgreen November 3, 2026 00:00
chrisgervang and others added 3 commits November 2, 2026 16:01
… 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
@chrisgervang
chrisgervang added this pull request to stack #11042 November 5, 2026 00:46
… into claude/fix-brushing-radius-meters-GveWO

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

@ibgreen ibgreen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ibgreen ibgreen added the bug label Nov 21, 2026

@athomct athomct left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks correct. Optional points:

  • The correction divides by project_size_at_latitude at 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 brushingRadius by eye will see a change. A short entry in upgrade-guide.md under "Upgrading to v10" can help.
  • The same whats-new.md point 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants