KOSMIndoorMap

localization.cpp
1/*
2 SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#include "localization.h"
7#include "localization_data.cpp"
8
9#include <KOSM/Element>
10
11using namespace KOSMIndoorMap;
12
14{
15 return hasTranslatedValue(value, amenity_map);
16}
17
19{
20 return translateValue(value, amenity_map, opt);
21}
22
24{
25 const auto types = value.split(';');
27 for (const auto &type : types) {
28 auto s = Localization::amenityType(type.trimmed().constData(), opt);
29 if (!s.isEmpty()) {
30 l.push_back(std::move(s));
31 }
32 }
33 return QLocale().createSeparatedList(l);
34}
35
37{
38 return translateValues(value, cuisine_map, opt);
39}
40
42{
44 for (const auto &gender : gender_type_map) {
45 const auto v = element.tagValue(gender.keyName);
46 if (v.isEmpty() || v == "no") {
47 continue;
48 }
49 l.push_back(gender.label.toString());
50 }
51 return QLocale().createSeparatedList(l);
52}
53
55{
56 return std::any_of(element.tagsBegin(), element.tagsEnd(), [](const auto &tag) {
57 const auto it = std::lower_bound(std::begin(gender_type_map), std::end(gender_type_map), tag.key.name(), [](const auto &lhs, auto rhs) {
58 return std::strcmp(lhs.keyName, rhs) < 0;
59 });
60 return it != std::end(gender_type_map) && std::strcmp((*it).keyName, tag.key.name()) == 0;
61 });
62}
A reference to any of OSM::Node/OSM::Way/OSM::Relation.
Definition element.h:24
QString cuisineTypes(const QByteArray &value, Localization::TranslationOption opt=Localization::ReturnUnknownKey)
Translated values of the cuisine tag (does list splitting).
QString genderSegregation(OSM::Element element)
Translated gender segregation information e.g.
bool hasGenderSegregrationKey(OSM::Element element)
Checks whether element contains a known key for gender segregation information.
QString amenityTypes(const QByteArray &value, Localization::TranslationOption opt=Localization::ReturnUnknownKey)
Translated list of amenity tag values (including list splitting).
bool hasAmenityTypeTranslation(const char *value)
Returns true if we can translate value.
QString amenityType(const char *value, Localization::TranslationOption opt=Localization::ReturnUnknownKey)
Translated name for an amenity tag value (after list splitting).
TranslationOption
Control how unknown elements get translated.
OSM-based multi-floor indoor maps for buildings.
QList< QByteArray > split(char sep) const const
void push_back(parameter_type value)
QString createSeparatedList(const QStringList &list) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.