Skip to content

Add rotate action for points with direction - #12673

Open
tordans wants to merge 7 commits into
openstreetmap:developfrom
tordans:rotate-point-direction
Open

Add rotate action for points with direction#12673
tordans wants to merge 7 commits into
openstreetmap:developfrom
tordans:rotate-point-direction

Conversation

@tordans

@tordans tordans commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Testing:


This is a subset of #12104.
The PR only add the R Shortcut that we explored over there, plus some context.

The idea is: This change is a lot simpler than #12104 but it bringt us a long way to improve the UX for editing node directions.

Changes:

  • Add the R for nodes with direction tag
  • Help text on the Info-i of the field
  • Some other help texts modified
  • During rotate, the sidebar stays on the feature (and does not switch to "Search features") – this ist IMO a UX bug we had before but we did not really notice because when rotating lines and areas I look at the map, not the sidebar. But for nodes, I want to see the direction number change during rotate, so the feature needs to stay active.

Closes #12341


Aside: This idea was also adopted to GoMap where it works great, IMO


🤖 the changes are build with Cursor Models and reviewed by me.

@tordans

tordans commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Screenshots

  • regular node
    point regular
  • node with rotate
    point rotate
  • rotating in progress with info line bottom and sidebar still visible
    in progress
  • help on info-i
    help inline
  • help panel
    help panel

@tordans tordans closed this Aug 4, 2026
@tordans tordans reopened this Aug 4, 2026
@tyrasd tyrasd changed the title Add rotate action for points with capacity Add rotate action for points with direction Aug 4, 2026
@tyrasd tyrasd added the operation An editing operation / edit menu item label Aug 4, 2026

@tyrasd tyrasd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, thanks. The only thing I noticed at first while playing around with it was that the operation is using the angle relative to the mouse position at the start of the operation, instead of just snapping it to the absolute direction the mouse points to. This could be a little counterintuitive maybe (e.g. where you need to draw), but I'd say we should probably leave it like this for consistency to the rotate operation for areas and lines (where there no absolute direction really exists which the feature can be directly rotated to), but maybe we could add a modifier key like Shift which toggles the relative to absolute mode? Does not need to be done in this PR immediately, though. Just wanted to find out about what your opinion on this idea.

One additional quality of life improvement would be to be able to start setting a direction on such a vertex by pressing R even if the tag was previously absent. This could be allowed when the preset has a field for the direction tag in fields or moreFields.

During rotate, the sidebar stays on the feature

Good catch! I also never noticed it until now, but it was definitely a bug.

@tordans

This comment was marked as resolved.

Comment thread modules/modes/rotate.js Outdated
@RudyTheDev

This comment was marked as resolved.

Comment thread modules/ui/tag_reference.js Outdated
Comment thread modules/actions/rotate_point_direction.ts Outdated
tordans added a commit to tordans/iD that referenced this pull request Aug 5, 2026
Allow R to adjust camera:direction and other numeric *:direction tags,
including on way vertices and when the tag is still absent on the preset.
Point direction always follows the mouse azimuth.

Ping openstreetmap#12673

Co-authored-by: Cursor <cursoragent@cursor.com>
@tordans
tordans force-pushed the rotate-point-direction branch 2 times, most recently from 49c8cfd to 778675e Compare August 5, 2026 05:55
tordans added a commit to tordans/iD that referenced this pull request Aug 5, 2026
Allow R to adjust camera:direction and other numeric *:direction tags,
including on way vertices and when the tag is still absent on the preset.
Point direction always follows the mouse azimuth.

Ping openstreetmap#12673

Co-authored-by: Cursor <cursoragent@cursor.com>
tordans added a commit to tordans/iD that referenced this pull request Aug 5, 2026
Allow R to adjust camera:direction and other numeric *:direction tags,
including on way vertices and when the tag is still absent on the preset.
Point direction always follows the mouse azimuth.

Ping openstreetmap#12673

Co-authored-by: Cursor <cursoragent@cursor.com>
@tordans
tordans force-pushed the rotate-point-direction branch from 778675e to c9942c3 Compare August 5, 2026 06:55
* when false, match relative fields used by reverse (`forward`/`backward`).
* @returns false or the direction tag key
*/
export function utilDirectionFieldKey(

@tordans tordans Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

FYI Context:

utilDirectionFieldKey is the old supportsDirectionField helper moved out of reverse.ts and parameterized.

For reverse (numeric: false) the behavior is unchanged: same preset fields/moreFields scan, same direction / *:direction key check, same geometry filter, still only non-number (relative) fields.

numeric: true is the new path for rotate (angle fields). Key matching now goes through shared utilIsDirectionKey, which is equivalent for the reverse case.

tordans and others added 2 commits August 6, 2026 06:04
Let the existing rotate operation adjust direction=* on standalone
points so the on-map direction cone can be edited without a separate UI.

Co-authored-by: Cursor <cursoragent@cursor.com>
Pass the next mode into exit so select can skip hiding the sidebar when
entering rotate, and rotate only hides when leaving the selection.

Co-authored-by: Cursor <cursoragent@cursor.com>
tordans and others added 5 commits August 6, 2026 06:04
Surface that R adjusts numeric direction=* on the map in the field's
info panel, matching the existing comment-docs special case pattern.

Co-authored-by: Cursor <cursoragent@cursor.com>
Clarify that R adjusts numeric direction=* for points in the help
Operations text, the keyboard shortcuts panel, and the rotate tooltip.

Co-authored-by: Cursor <cursoragent@cursor.com>
Allow R to adjust camera:direction and other numeric *:direction tags,
including on way vertices and when the tag is still absent on the preset.
Point direction always follows the mouse azimuth.

Ping openstreetmap#12673

Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid advertising R on relative direction tags like forward/backward
where point-direction rotate is unavailable.

Co-authored-by: Cursor <cursoragent@cursor.com>
Match geometry rotate: a transform change should not snap the direction
tag to the current mouse bearing until the user actually moves again.

Co-authored-by: Cursor <cursoragent@cursor.com>
@tordans

tordans commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

FYI — updates since the last review (history was rebased/amended onto upstream/develop)

Addressed the review feedback and a few follow-ups:

  • Direction keys: not only direction — also *:direction (e.g. camera:direction), via a shared helper extracted from reverse’s old supportsDirectionField.
  • Vertices: R works on way-attached nodes, not only standalone points; added annotation.vertex for history.
  • Absent tags: R works when the preset has a numeric direction field even if the tag is missing.
  • Interaction: for nodes, rotate points at the mouse (absolute azimuth), not relative drag like line/area rotate. After pan/zoom, the first move does not snap the tag (same idea as geometry rotate’s zero-delta).
  • Docs/hint: updated
  • Cleanup: shared selection/key helpers; const/let only on lines we touch; no broad var churn.

Compared against the old tip ed350d56 (~25h+12h ago). Current tip is c9942c3b5 (already on origin/rotate-point-direction).

@tordans
tordans requested review from k-yle and tyrasd August 6, 2026 04:15

@k-yle k-yle 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.

very cool! sorry i have another few questions

degrees: number,
key?: TagKey
): Action {
return function(graph) {

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.

for two-sided features, pressing R will destroy the two-sidedness. for example: direction=120;300
Image

i think it should either:

  • preseve the sidedness - if there were 2 angles offset by 180degrees before rotating, then it should rotate both angles, still offset by 180degrees.
  • or; block the operation in this situation

describe('iD.utilDirectionFieldKey / iD.utilRotatePointDirectionKey', () => {
beforeEach(() => {
const cached: any = iD.fileFetcher.cache();
cached.preset_fields = {

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.

currently there is exactly 1 file that overrides preset_fields, now we have multiple files mutating a global state.

i'm not sure if this will cause a race condition because we use --no-isolate? i guess we'll find out...

});

it('finds a numeric direction field on the preset', async () => {
await (iD.presetManager as any).ensureLoaded(true);

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.

fixed in #12683, i'll update it if this PR is merged first


for (const key of Object.keys(node.tags)) {
if (!utilIsDirectionKey(key)) continue;
if (!isFinite(Number(node.tags[key]))) continue;

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.

this will reject any cardinal value (see list here).

Since #9141, the field's ⬆️/⬇️ buttons support these values, so the action should probably support it?

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

Labels

operation An editing operation / edit menu item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rotating a point should adjust its direction

4 participants