Skip to content

Commit b36c8ee

Browse files
add from-to as an option for display names
Some routes (in particular node networks) have no proper name of their own, but do have a from and/or to attribute set that gives at least some description of the route. Note that these routes often do have the `name` or `note` attribute set using an explicit "from-to" value, but these attributes are not really meant for that, so for example the Swiss hiking route tagging now recommends settings only `from` and `to`, not `name` or `note`. See e.g. https://wiki.openstreetmap.org/wiki/DE:Switzerland/HikingNetwork#Wanderwegenetz As an example of such a route, see https://www.openstreetmap.org/relation/13126425 For these routes, setting just `from` or just `to` is also possible (in particular for node network routes that start at an unnamed node/guidepost). In this case, the missing attribute is replaced by `?`. This commit modifies the `relation.nameOrder` preference, adding one extra special value `from-to` which is handled specially.
1 parent 0196265 commit b36c8ee

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/org/openstreetmap/josm/data/osm/DefaultNameFormatter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public static void unregisterFormatHook(NameFormatterHook hook) {
9393
private static final String[] DEFAULT_NAMING_TAGS_FOR_RELATIONS = {
9494
"name",
9595
"ref",
96+
"from-to",
9697
//
9798
"amenity",
9899
"landuse",
@@ -451,6 +452,12 @@ private static String getRelationTypeName(IRelation<?> relation) {
451452
private static String getNameTagValue(IRelation<?> relation, String nameTag) {
452453
if ("name".equals(nameTag)) {
453454
return formatLocalName(relation);
455+
} else if ("from-to".equals(nameTag)) {
456+
String from = trcLazy("from", I18n.escape(relation.get("from")));
457+
String to = trcLazy("to", I18n.escape(relation.get("to")));
458+
if (from != null || to != null)
459+
return (from != null ? from : "?") + "-" + (to != null ? to : "?");
460+
return null;
454461
} else if (":LocationCode".equals(nameTag)) {
455462
return relation.keys()
456463
.filter(m -> m.endsWith(nameTag))

0 commit comments

Comments
 (0)