* displayLabel * Returns a string suitable for display * By default returns something like name/ref, fallback to preset type, fallback to OSM type * "Main Street" or "Tertiary Road" * If `verbose=true`, include both preset name and feature name. * "Tertiary Road Main Street" *
(entity, graphOrGeometry, verbose)
| 683 | * @return {string} A name string suitable for display |
| 684 | */ |
| 685 | displayLabel(entity, graphOrGeometry, verbose) { |
| 686 | const displayName = this.displayName(entity.tags); |
| 687 | const presetSystem = this.context.systems.presets; |
| 688 | const preset = typeof graphOrGeometry === 'string' ? |
| 689 | presetSystem.matchTags(entity.tags, graphOrGeometry) : |
| 690 | presetSystem.match(entity, graphOrGeometry); |
| 691 | const presetName = preset && (preset.suggestion ? preset.subtitle() : preset.name()); |
| 692 | |
| 693 | let result; |
| 694 | if (verbose) { |
| 695 | result = [presetName, displayName].filter(Boolean).join(' '); |
| 696 | } else { |
| 697 | result = displayName || presetName; |
| 698 | } |
| 699 | |
| 700 | // Fallback to the OSM type (node/way/relation) |
| 701 | return result ?? this.displayType(entity.id); |
| 702 | } |
| 703 | |
| 704 | |
| 705 | /** |
no test coverage detected