mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
Merge pull request #8276 from openstreetmap/1ec5-display-name-direction
Label route relations with directions and waypoints
This commit is contained in:
@@ -732,6 +732,21 @@ en:
|
||||
add_fields: "Add field:"
|
||||
lock:
|
||||
suggestion: 'The "{label}" field is locked because there is a Wikidata tag. You can delete it or edit the tags in the "Tags" section.'
|
||||
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}"
|
||||
background:
|
||||
title: Background
|
||||
description: Background Settings
|
||||
|
||||
2
dist/locales/en.min.json
vendored
2
dist/locales/en.min.json
vendored
File diff suppressed because one or more lines are too long
@@ -182,15 +182,42 @@ export function utilGetAllNodes(ids, graph) {
|
||||
export function utilDisplayName(entity) {
|
||||
var localizedNameKey = 'name:' + localizer.languageCode().toLowerCase();
|
||||
var name = entity.tags[localizedNameKey] || entity.tags.name || '';
|
||||
var network = entity.tags.cycle_network || entity.tags.network;
|
||||
if (name) return name;
|
||||
|
||||
if (!name && entity.tags.ref) {
|
||||
name = entity.tags.ref;
|
||||
if (network) {
|
||||
name = network + ' ' + name;
|
||||
var tags = {
|
||||
direction: entity.tags.direction,
|
||||
from: entity.tags.from,
|
||||
network: entity.tags.cycle_network || entity.tags.network,
|
||||
ref: entity.tags.ref,
|
||||
to: entity.tags.to,
|
||||
via: entity.tags.via
|
||||
};
|
||||
var keyComponents = [];
|
||||
|
||||
if (tags.network) {
|
||||
keyComponents.push('network');
|
||||
}
|
||||
if (tags.ref) {
|
||||
keyComponents.push('ref');
|
||||
}
|
||||
|
||||
// Routes may need more disambiguation based on direction or destination
|
||||
if (entity.tags.route) {
|
||||
if (tags.direction) {
|
||||
keyComponents.push('direction');
|
||||
} else if (tags.from && tags.to) {
|
||||
keyComponents.push('from');
|
||||
keyComponents.push('to');
|
||||
if (tags.via) {
|
||||
keyComponents.push('via');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (keyComponents.length) {
|
||||
name = t('inspector.display_name.' + keyComponents.join('_'), tags);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,4 +225,31 @@ describe('iD.util', function() {
|
||||
expect(iD.utilUnicodeCharsTruncated('😎😬😆😵😴😄🙂🤔', 255)).to.eql('😎😬😆😵😴😄🙂🤔');
|
||||
});
|
||||
});
|
||||
|
||||
describe('utilDisplayName', function() {
|
||||
it('returns the name if tagged with a name', function() {
|
||||
expect(iD.utilDisplayName({tags: {name: 'East Coast Greenway'}})).to.eql('East Coast Greenway');
|
||||
});
|
||||
it('distinguishes unnamed features by ref', function() {
|
||||
expect(iD.utilDisplayName({tags: {ref: '66'}})).to.eql('66');
|
||||
});
|
||||
it('distinguishes unnamed features by network or cycle_network', function() {
|
||||
expect(iD.utilDisplayName({tags: {network: 'SORTA', ref: '3X'}})).to.eql('SORTA 3X');
|
||||
expect(iD.utilDisplayName({tags: {network: 'ncn', cycle_network: 'US:US', ref: '76'}})).to.eql('US:US 76');
|
||||
});
|
||||
it('distinguishes unnamed routes by direction', function() {
|
||||
expect(iD.utilDisplayName({tags: {network: 'US:US', ref: '66', direction: 'west'}})).to.eql('US:US 66 west');
|
||||
// Marguerite X: Counter-Clockwise
|
||||
expect(iD.utilDisplayName({tags: {network: 'Marguerite', ref: 'X', direction: 'anticlockwise'}})).to.eql('Marguerite X anticlockwise');
|
||||
});
|
||||
it('distinguishes unnamed routes by waypoints', function() {
|
||||
expect(iD.utilDisplayName({tags: {network: 'SORTA', ref: '3X', from: 'Downtown'}})).to.eql('SORTA 3X');
|
||||
expect(iD.utilDisplayName({tags: {network: 'SORTA', ref: '3X', to: 'Kings Island'}})).to.eql('SORTA 3X');
|
||||
expect(iD.utilDisplayName({tags: {network: 'SORTA', ref: '3X', via: 'Montgomery'}})).to.eql('SORTA 3X');
|
||||
// Green Line: Old Ironsides => Winchester
|
||||
expect(iD.utilDisplayName({tags: {network: 'VTA', ref: 'Green', from: 'Old Ironsides', to: 'Winchester'}})).to.eql('VTA Green from Old Ironsides to Winchester');
|
||||
// BART Yellow Line: Antioch => Pittsburg/Bay Point => SFO Airport => Millbrae
|
||||
expect(iD.utilDisplayName({tags: {network: 'BART', ref: 'Yellow', from: 'Antioch', to: 'Millbrae', via: 'Pittsburg/Bay Point;San Francisco International Airport'}})).to.eql('BART Yellow from Antioch to Millbrae via Pittsburg/Bay Point;San Francisco International Airport');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user