Skip to content

allow follow ways if there are already two ways sharing the same nodes - #9340

Merged
tyrasd merged 8 commits into
openstreetmap:developfrom
jguddas:feature/allow-follow-ways-if-there-are-already-two-ways-sharing-the-same-nodes
Jul 21, 2026
Merged

tyrasd merged 8 commits into
openstreetmap:developfrom
jguddas:feature/allow-follow-ways-if-there-are-already-two-ways-sharing-the-same-nodes

Conversation

@jguddas

@jguddas jguddas commented Oct 22, 2022 •

Copy link
Copy Markdown
Contributor

Resolves limitation of #8671 @k-yle

Case 1

Connect to the node that is not alongside an edge.

Given Way segments that connect the current node to more than two nodes.
When Exactly one of the next nodes is only connected using one way segment.
Then Connect the current node to the node that is only connected using one way segment.

image

Solved by:

nextNodeIds = nextNodeIds.filter((id,_,nodes) => nodes.lastIndexOf(id) === nodes.indexOf(id))
Video
Screen.Recording.2022-10-22.at.09.37.40.mov

Case 2

Connect to next note, even if there are multiple ways leading there.

Given Multiple way segments that connect the current note to two nodes.
And One of the next nodes is the previous node.
Then Connect the current node to the node that is not the previous node.

image

Solved by:

if (new Set([...nextNodeIds]).size > 1) {
Video
Screen.Recording.2022-10-22.at.09.38.49.mov

Case 3

Connect to next note if you are at the start or end of a way.

Given All ways that contain the current node are start or end of a way.
And Lead to the same next node.
Then Connect to the next node.

image

Comment thread modules/behavior/draw_way.js Resolved
return [indexOfLast ? nodes[nodes.length - 2] : nodes[1]]
}).filter((id) => id !== secondLastNodeId)

if (!nextNodeIds.length) return;

@jguddas jguddas Oct 22, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is doing nothing a good idea when there are no options?

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.

Yeah, I think there should be a flash message similar to the one below (operations.follow.error.needs_more_initial_nodes). I can fix that after this PR, though.

Btw, this is for situations where the drawn way is not connected to anything, right? Currently (iD v2.23.2), this results in the needs_more_initial_nodes message, which could be also a bit confusing in that situation. 😉

@jguddas
jguddas force-pushed the feature/allow-follow-ways-if-there-are-already-two-ways-sharing-the-same-nodes branch from e77c9d0 to b89717e Compare October 23, 2022 16:48
Comment thread modules/behavior/draw_way.js Resolved
@jguddas

jguddas commented Nov 7, 2022

Copy link
Copy Markdown
Contributor Author

@tyrasd can you take a look at this, I would love to hear what you think?

@tyrasd tyrasd added the enhancement An enhancement to make an existing feature even better label Dec 6, 2022

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

Hey. Sorry that I didn't respond earlier. These improvements look awesome!

The only thing I think we should still work on is to add back some inline documentation. As some of the parts of the code are not trivial, it wouldn't hurt to add a short explanation here and there. For example, the line nextNodeIds = nextNodeIds.filter((id,_,nodes) => nodes.lastIndexOf(id) === nodes.indexOf(id)) could be annotated with a short explanation and a link back to this PR. Similarly, the different cases for the generation of nextNodeIds could be described such that other devs can get an idea of what it does more quickly.

Comment thread modules/behavior/draw_way.js Resolved
return [indexOfLast ? nodes[nodes.length - 2] : nodes[1]]
}).filter((id) => id !== secondLastNodeId)

if (!nextNodeIds.length) return;

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.

Yeah, I think there should be a flash message similar to the one below (operations.follow.error.needs_more_initial_nodes). I can fix that after this PR, though.

Btw, this is for situations where the drawn way is not connected to anything, right? Currently (iD v2.23.2), this results in the needs_more_initial_nodes message, which could be also a bit confusing in that situation. 😉

Comment thread modules/behavior/draw_way.js Resolved
@jguddas
jguddas force-pushed the feature/allow-follow-ways-if-there-are-already-two-ways-sharing-the-same-nodes branch from 69a6cac to e84c4e0 Compare December 18, 2022 08:18
@jguddas
jguddas requested a review from tyrasd December 28, 2022 14:47
@jguddas

jguddas commented Feb 3, 2023

Copy link
Copy Markdown
Contributor Author

@tyrasd can you take a look again?

@jguddas

jguddas commented Jul 16, 2023

Copy link
Copy Markdown
Contributor Author

@tyrasd ?

@tyrasd
tyrasd merged commit 3326f04 into openstreetmap:develop Jul 21, 2026
@MapSpot

MapSpot commented Aug 11, 2026 •

Copy link
Copy Markdown

Really appreciate the progress on this! I've had similar comments on the Follow command in #11895 which have been indirectly addressed.

One last strange behavior I'm noticing is when following two overlapping ways (e.g. a nature reserve and coastline), the new Follow command will prefer to deviate from these two ways in favor of following a line with no overlap. Although this behavior is intended in Case 1, it probably isn't what the user would want or expect in such cases.

image

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

Labels

enhancement An enhancement to make an existing feature even better

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow continuing drawing using follow function if two ways/areas have the same geometry Follow operation should prefer the focused way

3 participants