openstreetmap / openstreetmap-website

The Rails application that powers OpenStreetMap
https://www.openstreetmap.org/
GNU General Public License v2.0
2.2k stars 911 forks source link

Automatically generate PTv2 relations name #4033

Open Dimitar5555 opened 1 year ago

Dimitar5555 commented 1 year ago

Problem

Currently most PTv2 relations have network, ref, route, from, via and to tags. Regardless of these tags the OSM website shows only the ref of these relations. Using that information it is possible to generate a name like iD and JOSM do.

To make it easier, you can use the strings from iD's implementation (https://github.com/openstreetmap/iD/pull/8276/files):

display_name:
      direction: "{direction}"
      from_to: "from {from} to {to}"
      from_to_via: "from {from} to {to} via {via}"
      network_direction: "{network} {direction}"
      network_from_to: "{network} from {from} to {to}"
      network_from_to_via: "{network} from {from} to {to} via {via}"
      ref: "{ref}"
      ref_direction: "{ref} {direction}"
      ref_from_to: "{ref} from {from} to {to}"
      ref_from_to_via: "{ref} from {from} to {to} via {via}"
      network_ref: "{network} {ref}"
      network_ref_direction: "{network} {ref} {direction}"
      network_ref_from_to: "{network} {ref} from {from} to {to}"
      network_ref_from_to_via: "{network} {ref} from {from} to {to} via {via}"

Example elements for testing: https://www.openstreetmap.org/relation/13892501 https://www.openstreetmap.org/relation/13892502 https://www.openstreetmap.org/relation/13892503 (see members section)

Description

No response

Screenshots

image image

tomhughes commented 1 year ago

As I've explained a number of times, most recently (in a slightly different context) in #4030 I am very reluctant to keep adding more and more special cases - once we start down this route there is no end to it and everybody wants special handling for their favourite tags.

The browse view tries to be completely generic so that it can handle any object without needing to have lots of special code - it's hard to do anything else when tagging is completely open and there is no real concept of any one particular tagging scheme being official.

Dimitar5555 commented 1 year ago

I haven't seen the currently available special cases. Where can I find them?

I agree that everyone would want some special treating for their favourite tags but we are talking about ~1 million relations (route + route_master). Such change would allow mappers to drop the name tags for almost all PT, road and railway relations. It could (in theory) allow Nominatim to finally start showing route relations (https://github.com/osm-search/Nominatim/issues/413). Not to mention the fact that these names were added because iD and the OSM website couldn't show useful information to the end users. iD has resolved this issue.

tomhughes commented 1 year ago

Well https://github.com/openstreetmap/openstreetmap-website/blob/486e87301f16222aa5060b98950cf4df544db23a/app/helpers/browse_helper.rb#LL2C14-L2C14 is the current code for the name which is very simple as it only looks at name and ref tags.

Meanwhile https://github.com/openstreetmap/openstreetmap-website/blob/master/app/helpers/browse_tags_helper.rb is an example of what happened when we started handling certain tags specially to generate links, and that's just he tip of the iceberg as there are dozens of open tickets asking for other cases to be added to that.

1ec5 commented 4 months ago

For what it’s worth, the iD code looks for the same set of potential keys regardless of the element type. The set could be expanded somewhat to handle some rare edge cases, such as unsigned_ref, but it hasn’t turned out to be a very slippery slope. from, via, and to cover a lot of possibilities in practice, even if some things could have more specialized keys. (Also, iD’s labeling code happens to be used for the map view; it doesn’t make a lot of sense to label things on a map based on completely arbitrary keys.)