mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-31 01:09:22 +02:00
Include route number in label of named route relations (#10478)
* iD#8707 Show ref in the name of route relations * Avoid combining PTv2-formatted name with ref * Pair name with other tags when labeling routes --------- Co-authored-by: Kyle Hensel <k.y.l.e@outlook.co.nz>
This commit is contained in:
@@ -386,7 +386,11 @@ export function uiSectionRawMembershipEditor(context) {
|
||||
.attr('class', 'member-entity-name')
|
||||
.classed('has-colour', d => d.relation.tags.colour && isColourValid(d.relation.tags.colour))
|
||||
.style('border-color', d => d.relation.tags.colour)
|
||||
.text(function(d) { return utilDisplayName(d.relation); });
|
||||
.html(function(d) {
|
||||
const matched = presetManager.match(d.relation, context.graph());
|
||||
// hide the network from the name if there is NSI match
|
||||
return utilDisplayName(d.relation, matched.suggestion);
|
||||
});
|
||||
|
||||
labelEnter
|
||||
.append('button')
|
||||
|
||||
@@ -177,20 +177,35 @@ export function utilGetAllNodes(ids, graph) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function utilDisplayName(entity) {
|
||||
/**
|
||||
* @param {boolean} hideNetwork If true, the `network` tag will not be used in the name to prevent
|
||||
* it being shown twice (see PR #8707#discussion_r712658175)
|
||||
*/
|
||||
export function utilDisplayName(entity, hideNetwork) {
|
||||
var localizedNameKey = 'name:' + localizer.languageCode().toLowerCase();
|
||||
var name = entity.tags[localizedNameKey] || entity.tags.name || '';
|
||||
if (name) return name;
|
||||
|
||||
var tags = {
|
||||
direction: entity.tags.direction,
|
||||
from: entity.tags.from,
|
||||
network: entity.tags.cycle_network || entity.tags.network,
|
||||
name,
|
||||
network: hideNetwork ? undefined : (entity.tags.cycle_network || entity.tags.network),
|
||||
ref: entity.tags.ref,
|
||||
to: entity.tags.to,
|
||||
via: entity.tags.via
|
||||
};
|
||||
|
||||
// A right or left-right arrow likely indicates a formulaic “name” as specified by the Public Transport v2 schema.
|
||||
// This name format already contains enough details to disambiguate the feature; avoid duplicating these details.
|
||||
if (entity.tags.route && entity.tags.name && entity.tags.name.match(/[→⇒↔⇔]|[-=]>/)) {
|
||||
return entity.tags.name;
|
||||
}
|
||||
|
||||
// Non-routes tend to be labeled in many places besides the relation lists, such as the map, where brevity is important.
|
||||
if (!entity.tags.route && name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
var keyComponents = [];
|
||||
|
||||
if (tags.network) {
|
||||
@@ -199,6 +214,9 @@ export function utilDisplayName(entity) {
|
||||
if (tags.ref) {
|
||||
keyComponents.push('ref');
|
||||
}
|
||||
if (tags.name) {
|
||||
keyComponents.push('name');
|
||||
}
|
||||
|
||||
// Routes may need more disambiguation based on direction or destination
|
||||
if (entity.tags.route) {
|
||||
|
||||
Reference in New Issue
Block a user