Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard Shortcut idea: cycle through common footway types #1154

Closed
Bonkles opened this issue Oct 11, 2023 · 8 comments · Fixed by #1160 or #1198
Closed

Keyboard Shortcut idea: cycle through common footway types #1154

Bonkles opened this issue Oct 11, 2023 · 8 comments · Fixed by #1160 or #1198
Assignees
Labels
good first issue Good for newcomers
Milestone

Comments

@Bonkles
Copy link
Contributor

Bonkles commented Oct 11, 2023

Description

We currently have a hotkey (shift-C) that cycles through the various 'common' road types. Each time you hit the hotkey, As long as you have a highway selected, the selected way changes its tags according to this sequence:

motorway, trunk, primary, secondary, tertiary, unclassified, residential, living_street, service, track

Once you get to track, the key cycles back to the beginning of the list.

We could do a similar thing with footways, where hitting the hotkey (tbd which one) would cycle through tags if a highway=footway is selected.

What would that tag cycle look like? Something like 'When a highway=footway is selected, cycle through this list':

(In order by popularity of usage from: https://taginfo.openstreetmap.org/keys/crossing:markings#values)

  • footway=unmarked;crossing:markings=no
  • footway=marked:crossing:markings=yes
  • footway=marked;crossing:markings=zebra
  • footway=marked;crossing:markings=lines
  • footway=marked;crossing:markings=ladder
  • footway=marked;crossing:markings=dashes
  • footway=marked;crossing:markings=dots
  • 🔙 to markings:no
@Bonkles
Copy link
Contributor Author

Bonkles commented Oct 11, 2023

Further idea- we could adjust the tagging on any crossing nodes inside the way as well while cycling.

@Bonkles
Copy link
Contributor Author

Bonkles commented Oct 11, 2023

Further, even crazier idea- adjust the list of cycle tags depending on geographical area / country.

@bhousel
Copy link
Contributor

bhousel commented Oct 11, 2023

adjust the list of cycle tags depending on geographical area / country.

This part sounds terrible, but everything else seems fine.

@atiannicelli
Copy link

This is tough. If you select a footway=sidewalk or footway=path then what will happen?
Maybe you are just talking about when footway=crossing?

So the rule would be if 'footway=crossing' and you press this key then cycle between:

  • crossing=unmarked;crossing:markings=no
  • crossing=marked:crossing:markings=yes
  • crossing=marked;crossing:markings=zebra
  • crossing=marked;crossing:markings=lines
  • crossing=marked;crossing:markings=ladder
  • crossing=marked;crossing:markings=dashes
  • crossing=marked;crossing:markings=dots

I like it. But maybe there is a chance here to add something where you can define a few hotkeys to set a defined set of tags to a selected footway? For instance, if I know I'm going to be editing crossings I might assign
crossing=marked;crossing:markings=zebra to a custom hotkey.
Then when I type that hotkey when I have a feature selected it will apply those tags. Then I can click on a feature, type my hotkey, and click on the next, etc.

So basically similar to your idea, but make it very generic and extendable for power users.

@RitaDee
Copy link
Collaborator

RitaDee commented Oct 19, 2023

Can this be assigned to me?

@Bonkles
Copy link
Contributor Author

Bonkles commented Oct 20, 2023

Okay @RitaDee!

So here's more on the Shift+C Hotkey:

https://github.com/facebookmicrosites/Open-Mapping-At-Facebook/wiki#hot-keys

Try it yourself on an existing traffic road. It will cycle through a preset bunch of road types, each of which is represented by an openstreetmap 'tag'. Think of 'tags' as bits of metadata that are applied to the entities on the map- they don't affect the geometry of the feature, but they do affect its underlying meaning/representation.

Now, try it on a building or a park- you should not see any changes, because buildings and parks are not the correct type of feature for the hotkey to work on.

What we want to do is expand the key's functionality. The existing key works something like this:

flowchart LR
A[Road Selected] -->B(Type Shift+C);
B --> C{Is the Road Type appropriate?};
C -->|Yes| D[Change its tag according to the preset list];
C -->|No| E[Do nothing];
Loading

The preset list is defined in this cycle highway tag [code const array]:(https://github.com/facebook/Rapid/blob/main/modules/operations/cycle_highway_tag.js#L18C3-L25C5)

flowchart LR
A[Residential] -->B(Service);
B --> C(Track);
C --> D(Unclassified);
D --> E(Tertiary);
E --> F(no tag);
F --> A;
Loading

However! You'll also notice that there is another regular expression defined in line 13:

it has a few more tags in it than the preset cycle does. What's that about?

Well, that turns out to be the secret sauce for the first flowchart, where we ask 'is the road type appropriate'?

The Regex:

const allowPresetRegex = [
    /^highway\/(motorway|trunk|primary|secondary|tertiary|unclassified|residential|living_street|service|track)/,
    /^line$/
  ];

means that we allow any of these kinds of roads: motorway, trunk, primary, secondary, tertiary, unclassified, residential, living_street, service, track. BUT! If the road type is in this 'allowed' list, but not the 'cycle preset' list above, we change the road type to the first cycle preset. Hitting shift C repeatedly will only cycle through the existing preset list.

Let's update that second chart with what's really actually going on for the cycle presets:

flowchart LR
AA[Motorway] --> A;
BB[Trunk] --> A; 
CC(primary) --> A;
DD(secondary) --> A; 
EE(living_street) --> A; 

A[Residential] -->B(Service);
B --> C(Track);
C --> D(Unclassified);
D --> E(Tertiary);
E --> F(<no tag>);
F --> A;
Loading

You can select a road that is 'trunk', for example, but you can hit shift+C all you want, you will never get back to seeing the road be 'unclassified' again because it is not in the preset list.

@Bonkles
Copy link
Contributor Author

Bonkles commented Oct 20, 2023

Update: I have added the 'ladder:skewed' value after discussing further with @atiannicelli

So, the above explains how the existing hotkey works. What we want to do in this feature is to extend the hotkey so that it also works for certain crosswalk types.

For now, let's do this by adding another cycle preset list for crosswalks, We'll start simple and just ask that you extend the existing cycle operation to consider crosswalks:

flowchart LR
A[Road Selected] -->B(Type Shift+C);
B --> C{Is it a road, or a crosswalk?};
linkStyle 1 color:blue;
C -->|Road| D[Change its tag according to the road preset list];
C -->|Crosswalk| E[Change its tag according to the crosswalk preset list];
style E fill:#333,stroke:#ff26db,stroke-width:4px;
C -->|No| F[Do nothing];
Loading

To test 'is it a crosswalk', we just want to see if the way is marked as a crossing, specifically that it has a crossing tag of any value whatsoever.

Here's the crosswalk Preset List:

flowchart LR
AA[Start Here!] --- A;
style AA fill:#fff,color:#000,stroke-width:4px
A[Unmarked] --- B(Marked);
B --- C(Marked-Zebra);
C --- D(Marked-Lines);
D --- E(Marked-Ladder);
E --- F(Marked-Dashes);
F --- G(Marked-Dots);
G --- H(Marked-LadderSkewed);
H---A;
Loading

Here's a breakdown of the actual tag changes we would like to cycle through, given the above flowchart:

  • Unmarked: crossing=unmarked;crossing:markings=no
  • Marked: crossing=marked:crossing:markings=yes
  • Marked-Zebra: crossing=marked;crossing:markings=zebra
  • Marked-Lines: crossing=marked;crossing:markings=lines
  • Marked-Ladder: crossing=marked;crossing:markings=ladder
  • Marked-Dashes: crossing=marked;crossing:markings=dashes
  • Marked-Dots: crossing=marked;crossing:markings=dots
  • Marked-LadderSkewed: crossing=marked;crossing:markings=ladder:skewed

@RitaDee
Copy link
Collaborator

RitaDee commented Oct 20, 2023

This is clear @Bonkles. Thanks for providing me with much guidance to work with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
4 participants