Skip to content

Commit 90da9fe

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 28510ce commit 90da9fe

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@ public Comparator<IRelation<?>> getRelationComparator() {
412412
private static String getRelationTypeName(IRelation<?> relation) {
413413
// see https://josm.openstreetmap.de/browser/osm/applications/editors/josm/i18n/specialmessages.java
414414
String name = trc("Relation type", relation.get("type"));
415+
if (relation.hasTag("type", "route") && relation.hasKey("route")) {
416+
String route = trc("Route type", relation.get("route"));
417+
name = route + " " + name;
418+
}
415419
if (name == null) {
416420
name = relation.hasKey("public_transport") ? tr("public transport") : null;
417421
}

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)