| 116 | } |
| 117 | |
| 118 | std::string Info::FormatSubtitle(bool withTypes, bool withMainType) const |
| 119 | { |
| 120 | std::string result; |
| 121 | auto const append = [&result](std::string_view sv) |
| 122 | { |
| 123 | if (!result.empty()) |
| 124 | result += feature::kFieldsSeparator; |
| 125 | result += sv; |
| 126 | }; |
| 127 | |
| 128 | if (!withTypes) |
| 129 | return result; |
| 130 | |
| 131 | // Types |
| 132 | append(GetLocalizedAllTypes(withMainType)); |
| 133 | |
| 134 | // Flats. |
| 135 | auto const flats = GetMetadata(feature::Metadata::FMD_FLATS); |
| 136 | if (!flats.empty()) |
| 137 | append(flats); |
| 138 | |
| 139 | // Airport IATA code. |
| 140 | auto const iata = GetMetadata(feature::Metadata::FMD_AIRPORT_IATA); |
| 141 | if (!iata.empty()) |
| 142 | append(iata); |
| 143 | |
| 144 | // Road numbers/ids. |
| 145 | auto const roadShields = FormatRoadShields(); |
| 146 | if (!roadShields.empty()) |
| 147 | append(roadShields); |
| 148 | |
| 149 | // Stars. |
| 150 | auto const stars = feature::FormatStars(GetStars()); |
| 151 | if (!stars.empty()) |
| 152 | append(stars); |
| 153 | |
| 154 | // Operator. |
| 155 | auto const op = GetMetadata(feature::Metadata::FMD_OPERATOR); |
| 156 | if (!op.empty()) |
| 157 | append(op); |
| 158 | |
| 159 | // Brand. |
| 160 | auto const brand = GetMetadata(feature::Metadata::FMD_BRAND); |
| 161 | if (!brand.empty() && brand != op) |
| 162 | { |
| 163 | /// @todo May not work as expected because we store raw value from OSM, |
| 164 | /// while current localizations assume to have some string ids (like "mcdonalds"). |
| 165 | auto const locBrand = localisation::TranslatedBrand(std::string(brand)); |
| 166 | |
| 167 | // Do not duplicate for commonly used titles like McDonald's, Starbucks, etc. |
| 168 | if (m_uiTitle.find(locBrand) == std::string::npos && m_uiSecondaryTitle.find(locBrand) == std::string::npos) |
| 169 | append(locBrand); |
| 170 | } |
| 171 | |
| 172 | // Elevation. |
| 173 | auto const eleStr = feature::FormatElevation(GetMetadata(MetadataID::FMD_ELE)); |
| 174 | if (!eleStr.empty()) |
| 175 | append(eleStr); |
nothing calls this directly
no test coverage detected