Skip to content

Commit 78a0fb1

Browse files
show route type in route relation display name
This displays e.g. `hiking route ("foo-bar")` instead of just `route ("foo-bar")`, making it easier to distinguish different route relations.
1 parent 1f6a262 commit 78a0fb1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,12 @@ public Comparator<IRelation<?>> getRelationComparator() {
410410

411411
private static String getRelationTypeName(IRelation<?> relation) {
412412
// see https://josm.openstreetmap.de/browser/osm/applications/editors/josm/i18n/specialmessages.java
413-
String name = trc("Relation type", relation.get("type"));
413+
String type = relation.get("type");
414+
String name = trc("Relation type", type);
415+
String route = trc("Route type", relation.get("route"));
416+
if (type != null && type.equals("route") && route != null) {
417+
name = route + " " + name;
418+
}
414419
if (name == null) {
415420
name = relation.hasKey("public_transport") ? tr("public transport") : null;
416421
}

test/unit/org/openstreetmap/josm/data/osm/DefaultNameFormatterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void testRelationName() {
102102
getFormattedRelationName("X=Y"));
103103
assertEquals("relation (\"Foo\", 0 members)",
104104
getFormattedRelationName("name=Foo"));
105-
assertEquals("route (\"123\", 0 members)",
105+
assertEquals("tram route (\"123\", 0 members)",
106106
getFormattedRelationName("type=route route=tram ref=123"));
107107
assertEquals("multipolygon (\"building\", 0 members)",
108108
getFormattedRelationName("type=multipolygon building=yes"));

0 commit comments

Comments
 (0)