MCPcopy Create free account
hub / github.com/facebook/Rapid / displayLabel

Method displayLabel

modules/core/LocalizationSystem.js:685–702  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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 /**

Callers 15

_updateTitleMethod · 0.45
lineTaggedAsAreaIssueFunction · 0.45
vertexPointIssueFunction · 0.45
otherMismatchIssueFunction · 0.45
validationFunction · 0.45
makeIssueFunction · 0.45
validationFunction · 0.45
getWayIssueIfAnyFunction · 0.45
showUpgradeMessageFunction · 0.45
showMultipolygonMessageFunction · 0.45

Calls 7

displayNameMethod · 0.95
displayTypeMethod · 0.95
matchTagsMethod · 0.80
matchMethod · 0.80
subtitleMethod · 0.80
filterMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected