Compare commits

..

8 Commits

Author SHA1 Message Date
x7z4w
1a5016f53f [ci] Update paths
Signed-off-by: x7z4w <x7z4w@noreply.codeberg.org>
2026-01-22 17:35:04 +00:00
Yannik Bloscheck
9245b2bbb8 [style] Fixed wrong icon being used for sports halls
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
2026-01-22 15:59:36 +01:00
Jean-Baptiste
76af9e01f4 [android] Fix corner radius of DialogFragment
Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
2026-01-22 14:18:47 +01:00
daxgar
2cd5a0a9df [generator] Add logic to replace OSM tag 'name' with 'name:full' for highway elements when 'name' and 'name:prefix' match with 'name:full'
Signed-off-by: daxgar <daxgar@noreply.codeberg.org>
2026-01-22 13:25:31 +01:00
Jean-Baptiste
9cd7b49f08 [docs] Update translations doc to explain how to enable new languages on Android
Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
Co-authored-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
Co-committed-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
2026-01-22 13:24:49 +01:00
Wira Abdillah S
560491f952 [generator] Add compiler flag to compile osmctools with gnu17
Signed-off-by: Wira Abdillah S <wirabdillah@gmail.com>
Co-authored-by: Wira Abdillah S <wirabdillah@gmail.com>
Co-committed-by: Wira Abdillah S <wirabdillah@gmail.com>
2026-01-22 13:11:00 +01:00
Yannik Bloscheck
86fc8a9a76 Use actual native languages for world map
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
2026-01-22 10:26:08 +01:00
Yannik Bloscheck
66a71869d2 [generator] Fixed ordering for many subtypes
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
2026-01-22 00:15:05 +01:00
48 changed files with 507 additions and 134 deletions

View File

@@ -14,22 +14,22 @@ on:
- LICENSE
- NOTICE
- README.md
- android/app/src/fdroid/**
- android/app/src/google/**
- iphone/**
- data/strings/**
- data/*-strings/**
- docs/**
- generator/**
- packaging/**
- platform/*apple*
- platform/*_ios*
- platform/*_linux*
- platform/*_mac*
- platform/*qt*
- platform/*_win*
- pyhelpers/**
- libs/platform/*apple*
- libs/platform/*_ios*
- libs/platform/*_linux*
- libs/platform/*_mac*
- libs/platform/*qt*
- libs/platform/*_win*
- libs/pyhelpers/**
- qt*/**
- skin_generator/**
- tools/**
- track_generator/**
- xcode/**
jobs:

View File

@@ -17,21 +17,19 @@ on:
- android/app/src/fdroid/**
- android/app/src/google/**
- iphone/**
- data/strings/**
- data/*-strings/**
- docs/**
- generator/**
- packaging/**
- platform/*apple*
- platform/*_ios*
- platform/*_linux*
- platform/*_mac*
- platform/*qt*
- platform/*_win*
- pyhelpers/**
- libs/platform/*apple*
- libs/platform/*_ios*
- libs/platform/*_linux*
- libs/platform/*_mac*
- libs/platform/*qt*
- libs/platform/*_win*
- libs/pyhelpers/**
- qt*/**
- skin_generator/**
- tools/**
- track_generator/**
- xcode/**
env:

View File

@@ -15,12 +15,12 @@ on:
- README.md
- docs/**
- packaging/**
- platform/*apple*
- platform/*_android*
- platform/*_ios*
- platform/*_mac*
- platform/*_win*
- pyhelpers/**
- libs/platform/*apple*
- libs/platform/*_android*
- libs/platform/*_ios*
- libs/platform/*_mac*
- libs/platform/*_win*
- libs/pyhelpers/**
- tools/**
- '!tools/python/test_server/**'
- xcode/**

View File

@@ -15,15 +15,15 @@ on:
- README.md
- android/**
- iphone/**
- data/strings/**
- data/*-strings/**
- docs/**
- packaging/**
- platform/*apple*
- platform/*_android*
- platform/*_ios*
- platform/*_mac*
- platform/*_win*
- pyhelpers/**
- libs/platform/*apple*
- libs/platform/*_android*
- libs/platform/*_ios*
- libs/platform/*_mac*
- libs/platform/*_win*
- libs/pyhelpers/**
- tools/**
- '!tools/python/test_server/**'
- xcode/**

View File

@@ -9,6 +9,7 @@ CoMaps contributors:
Bastian Greshake Tzovaras
clover sage
daxgar
Harry Bond <me@hbond.xyz>
NoelClick
thesupertechie

View File

@@ -42,7 +42,7 @@ public class ChooseBookmarkCategoryFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View root = inflater.inflate(R.layout.choose_bookmark_category_fragment, container, false);
getDialog().getWindow().setBackgroundDrawableResource(android.R.color.transparent);
getDialog().getWindow().setBackgroundDrawableResource(R.drawable.bg_transparent_dlg);
mRecycler = root.findViewById(R.id.recycler);
mRecycler.setLayoutManager(new LinearLayoutManager(requireActivity()));
return root;

View File

@@ -77,7 +77,7 @@ public class ChooseBookmarksSortingTypeFragment
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
getDialog().getWindow().setBackgroundDrawableResource(android.R.color.transparent);
getDialog().getWindow().setBackgroundDrawableResource(R.drawable.bg_transparent_dlg);
final Bundle args = getArguments();
if (args == null)

View File

@@ -61,7 +61,7 @@ public class StackedButtonsDialog extends AppCompatDialog implements View.OnClic
setCancelable(mCancelable);
setOnCancelListener(mCancelListener);
setContentView(R.layout.dialog_stacked_buttons);
getWindow().setBackgroundDrawableResource(android.R.color.transparent);
getWindow().setBackgroundDrawableResource(R.drawable.bg_transparent_dlg);
TextView title = findViewById(R.id.tv__title);
UiUtils.setTextAndHideIfEmpty(title, mTitle);

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/transparent"/>
<corners android:radius="28dp"/>
</shape>

View File

@@ -0,0 +1 @@
../../../../../data/countries_meta.txt

View File

@@ -393,9 +393,8 @@
"Germany_Baden-Wurttemberg_Regierungsbezirk Stuttgart_Stuttgart":"Stuttgart — Stuttgart",
"Germany_Baden-Wurttemberg_Regierungsbezirk Tubingen":"Tübingen",
"Germany_Berlin":"Berlin",
"Germany_Brandenburg":"Brandenburg",
"Germany_Brandenburg_North":"Potsdam",
"Germany_Brandenburg_South":"Cottbus",
"Germany_Brandenburg_North":"Brandenburg — Norden",
"Germany_Brandenburg_South":"Brandenburg — Süden",
"Germany_Free State of Bavaria":"Bayern",
"Germany_Free State of Bavaria_Lower Bavaria":"Niederbayern",
"Germany_Free State of Bavaria_Lower Franconia":"Unterfranken",
@@ -411,7 +410,7 @@
"Germany_Hesse_Regierungsbezirk Darmstadt":"Darmstadt",
"Germany_Hesse_Regierungsbezirk Giessen":"Gießen",
"Germany_Hesse_Regierungsbezirk Kassel":"Kassel",
"Germany_Lower Saxony":"Niedersachsen",
"Germany_Lower Saxony":"Niedersachsen und Bremen",
"Germany_Lower Saxony_Bremen_Bremen":"Bremen",
"Germany_Lower Saxony_Bremen_Munster":"Lüneburg",
"Germany_Lower Saxony_Hannover":"Hannover",
@@ -428,14 +427,12 @@
"Germany_North Rhine-Westphalia_Regierungsbezirk Koln_Koln":"Köln — Köln",
"Germany_North Rhine-Westphalia_Regierungsbezirk Munster_Munster":"Münster — Münster",
"Germany_North Rhine-Westphalia_Regierungsbezirk Munster_Recklinghausen":"Münster — Recklinghausen",
"Germany_Rhineland-Palatinate":"Rheinland-Pfalz",
"Germany_Rhineland-Palatinate_Koblenz":"Koblenz",
"Germany_Rhineland-Palatinate_South":"Mainz",
"Germany_Rhineland-Palatinate_Koblenz":"Rheinland-Pfalz — Koblenz",
"Germany_Rhineland-Palatinate_South":"Rheinland-Pfalz — Mainz",
"Germany_Saarland":"Saarland",
"Germany_Saxony-Anhalt":"Sachsen-Anhalt",
"Germany_Saxony":"Sachsen",
"Germany_Saxony_Dresden":"Dresden",
"Germany_Saxony_Leipzig":"Leipzig",
"Germany_Saxony_Dresden":"Sachsen — Dresden",
"Germany_Saxony_Leipzig":"Sachsen — Leipzig",
"Germany_Schleswig-Holstein":"Schleswig-Holstein",
"Germany_Thuringia":"Thüringen",
"Ghana":"Ghana",
@@ -1335,10 +1332,10 @@
"Canada_Saskatchewan_Regina":"Regina",
"Canada_Saskatchewan_Saskatoon":"Saskatoon",
"Germany_Lower Saxony_Braunschweig":"Braunschweig",
"Germany_Saxony-Anhalt_Halle":"Halle (Saale)",
"Germany_Saxony-Anhalt_Magdeburg":"Magdeburg",
"Germany_Schleswig-Holstein_Flensburg":"Flensburg",
"Germany_Schleswig-Holstein_Kiel":"Kiel",
"Germany_Saxony-Anhalt_Halle":"Sachsen-Anhalt — Halle (Saale)",
"Germany_Saxony-Anhalt_Magdeburg":"Sachsen-Anhalt — Magdeburg",
"Germany_Schleswig-Holstein_Flensburg":"Schleswig-Holstein — Flensburg",
"Germany_Schleswig-Holstein_Kiel":"Schleswig-Holstein — Kiel",
"Portugal_Porto":"Porto",
"UK_England_North West England_Lancaster":"North West England — Lancaster",
"UK_England_North West England_Manchester":"North West England — Manchester",
@@ -2503,6 +2500,8 @@
"Czech_Stredni Cechy_East Short":"Mittelböhmen (Stredni Cechy)",
"Czech_Stredni Cechy_West Short":"Mittelböhmische Region (Středočeský kraj)",
"Finland_Southern Finland_West Short":"Varsinais-Suomi",
"Germany_Brandenburg_North Short":"Brandenburg",
"Germany_Brandenburg_South Short":"Brandenburg",
"Germany_Rhineland-Palatinate_South Short":"Rheinland-Pfalz",
"Mexico_Central_East Short":"Nuevo León",
"Mexico_Central_West Short":"Nayarit",

View File

@@ -393,9 +393,8 @@
"Germany_Baden-Wurttemberg_Regierungsbezirk Stuttgart_Stuttgart":"Stuttgart — Stuttgart",
"Germany_Baden-Wurttemberg_Regierungsbezirk Tubingen":"Tübingen",
"Germany_Berlin":"Berlin",
"Germany_Brandenburg":"Brandenburg",
"Germany_Brandenburg_North":"Potsdam",
"Germany_Brandenburg_South":"Cottbus",
"Germany_Brandenburg_North":"Brandenburg — North",
"Germany_Brandenburg_South":"Brandenburg — South",
"Germany_Free State of Bavaria":"Bavaria",
"Germany_Free State of Bavaria_Lower Bavaria":"Lower Bavaria",
"Germany_Free State of Bavaria_Lower Franconia":"Lower Franconia",
@@ -428,14 +427,12 @@
"Germany_North Rhine-Westphalia_Regierungsbezirk Koln_Koln":"Cologne — Cologne",
"Germany_North Rhine-Westphalia_Regierungsbezirk Munster_Munster":"Münster — Münster",
"Germany_North Rhine-Westphalia_Regierungsbezirk Munster_Recklinghausen":"Münster — Recklinghausen",
"Germany_Rhineland-Palatinate":"Rhineland-Palatinate",
"Germany_Rhineland-Palatinate_Koblenz":"Koblenz",
"Germany_Rhineland-Palatinate_South":"Mainz",
"Germany_Rhineland-Palatinate_Koblenz":"Rhineland-Palatinate — Koblenz",
"Germany_Rhineland-Palatinate_South":"Rhineland-Palatinate — Mainz",
"Germany_Saarland":"Saarland",
"Germany_Saxony-Anhalt":"Saxony-Anhalt",
"Germany_Saxony":"Saxony",
"Germany_Saxony_Dresden":"Dresden",
"Germany_Saxony_Leipzig":"Leipzig",
"Germany_Saxony_Dresden":"Saxony — Dresden",
"Germany_Saxony_Leipzig":"Saxony — Leipzig",
"Germany_Schleswig-Holstein":"Schleswig-Holstein",
"Germany_Thuringia":"Thuringia",
"Ghana":"Ghana",
@@ -1335,10 +1332,10 @@
"Canada_Saskatchewan_Regina":"Regina",
"Canada_Saskatchewan_Saskatoon":"Saskatoon",
"Germany_Lower Saxony_Braunschweig":"Braunschweig",
"Germany_Saxony-Anhalt_Halle":"Halle",
"Germany_Saxony-Anhalt_Magdeburg":"Magdeburg",
"Germany_Schleswig-Holstein_Flensburg":"Flensburg",
"Germany_Schleswig-Holstein_Kiel":"Kiel",
"Germany_Saxony-Anhalt_Halle":"Saxony-Anhalt — Halle",
"Germany_Saxony-Anhalt_Magdeburg":"Saxony-Anhalt — Magdeburg",
"Germany_Schleswig-Holstein_Flensburg":"Schleswig-Holstein — Flensburg",
"Germany_Schleswig-Holstein_Kiel":"Schleswig-Holstein — Kiel",
"Portugal_Porto":"Porto",
"UK_England_North West England_Lancaster":"North West England — Lancaster",
"UK_England_North West England_Manchester":"North West England — Manchester",
@@ -1702,8 +1699,8 @@
"Germany_Baden-Wurttemberg_Regierungsbezirk Stuttgart_Stuttgart Description":"Stuttgart, Esslingen am Neckar, Ludwigsburg",
"Germany_Baden-Wurttemberg_Regierungsbezirk Tubingen Description":"Ulm, Reutlingen, Tübingen",
"Germany_Berlin Description":"Berlin, Falkenberg, Siedlung Grüneck",
"Germany_Brandenburg_North Description":"Potsdam, Brandenburg an der Havel, Oranienburg",
"Germany_Brandenburg_South Description":"Cottbus, Frankfurt (Oder), Königs Wusterhausen",
"Germany_Brandenburg_North Description":"Brandenburg an der Havel, Potsdam, Panketal",
"Germany_Brandenburg_South Description":"Frankfurt (Oder), Cottbus, Cottbus",
"Germany_Free State of Bavaria_Lower Bavaria Description":"Landshut, Passau, Straubing",
"Germany_Free State of Bavaria_Lower Franconia Description":"Würzburg, Aschaffenburg, Schweinfurt",
"Germany_Free State of Bavaria_Middle Franconia Description":"Nuremberg, Fürth, Erlangen",
@@ -2503,6 +2500,8 @@
"Czech_Stredni Cechy_East Short":"Central Bohemian Region",
"Czech_Stredni Cechy_West Short":"Central Bohemian Region",
"Finland_Southern Finland_West Short":"Southwest Finland",
"Germany_Brandenburg_North Short":"Brandenburg",
"Germany_Brandenburg_South Short":"Brandenburg",
"Germany_Rhineland-Palatinate_South Short":"Rhineland-Palatinate",
"Mexico_Central_East Short":"Nuevo León",
"Mexico_Central_West Short":"Nayarit",

View File

@@ -1,9 +1,9 @@
{
"World": {
"languages": ["int_name", "en", "default"]
"languages": []
},
"WorldCoasts": {
"languages": ["int_name", "en", "default"]
"languages": []
},
"Abkhazia": {
"languages": ["ab", "ru"]

View File

@@ -398,10 +398,8 @@ Germany;Q183;de;de
Germany_Baden-Wurttemberg_Regierungsbezirk Stuttgart_Stuttgart;Q8172-Q1022
Germany_Baden-Wurttemberg_Regierungsbezirk Tubingen;Q8170
Germany_Berlin;Q64
Germany_Brandenburg;Q1208
Germany_Brandenburg_North;Q1208-Q1711
Germany_Brandenburg_South;Q1208-Q3214
Germany_Lower Saxony_Bremen_Bremen;Q1209
Germany_Brandenburg_North;Q1208-North
Germany_Brandenburg_South;Q1208-South
Germany_Free State of Bavaria;Q980
Germany_Free State of Bavaria_Lower Bavaria;Q10559
Germany_Free State of Bavaria_Lower Franconia;Q10547
@@ -419,6 +417,7 @@ Germany;Q183;de;de
Germany_Hesse_Regierungsbezirk Giessen;Q7931
Germany_Hesse_Regierungsbezirk Kassel;Q7928
Germany_Lower Saxony;Q1197
Germany_Lower Saxony_Bremen_Bremen;Q1209
Germany_Lower Saxony_Bremen_Munster;Q3920
Germany_Lower Saxony_Hannover;Q1715
Germany_Lower Saxony_Braunschweig;Q2773
@@ -435,19 +434,15 @@ Germany;Q183;de;de
Germany_North Rhine-Westphalia_Regierungsbezirk Koln_Koln;Q7927-Q365
Germany_North Rhine-Westphalia_Regierungsbezirk Munster_Munster;Q7920-Q2742
Germany_North Rhine-Westphalia_Regierungsbezirk Munster_Recklinghausen;Q7920-Q3050
Germany_Rhineland-Palatinate;Q1200
Germany_Rhineland-Palatinate_Koblenz;Q1200-Q3104
Germany_Rhineland-Palatinate_South;Q1200-Q1720
Germany_Rhineland-Palatinate_Koblenz;Q1200-Q3104
Germany_Rhineland-Palatinate_South;Q1200-Q1720
Germany_Saarland;Q1201
Germany_Saxony-Anhalt;Q1206
Germany_Saxony-Anhalt_Magdeburg;Q1206-Q1733
Germany_Saxony-Anhalt_Halle;Q1206-Q2814
Germany_Saxony;Q1202
Germany_Saxony_Dresden;Q1202-Q1731
Germany_Saxony_Leipzig;Q1202-Q2079
Germany_Schleswig-Holstein;Q1194
Germany_Schleswig-Holstein_Kiel;Q1194-Q1707
Germany_Schleswig-Holstein_Flensburg;Q1194-Q3798
Germany_Saxony-Anhalt_Magdeburg;Q1206-Q1733
Germany_Saxony-Anhalt_Halle;Q1206-Q2814
Germany_Saxony_Dresden;Q1202-Q1731
Germany_Saxony_Leipzig;Q1202-Q2079
Germany_Schleswig-Holstein_Kiel;Q1194-Q1707
Germany_Schleswig-Holstein_Flensburg;Q1194-Q3798
Germany_Thuringia;Q1205
Ghana;Q117;gh;en
Gibraltar;Q1410;gi;en

View File

@@ -1293,7 +1293,7 @@ node|z17-[leisure=fitness_station]
node|z16-[leisure=sports_centre],
{icon-image: sports_centre-m.svg;icon-min-distance: 9;}
node|z17-[leisure=sports_hall]
{icon-image: sports_centre-m.svg;icon-min-distance: 10;}
{icon-image: pitch-m.svg;icon-min-distance: 10;}
node|z16-[leisure=dance]
{icon-image: dance-m.svg;icon-min-distance: 10;}
node|z16-[leisure=fitness_centre]

View File

@@ -130,6 +130,11 @@ The recommended approach for resolving conflicts is as follows:
Using these steps all existing translations can still be kept and rebased into the repo, without losing work. The important bit is that you need to ensure that all translations are in the Weblate-internal git repository before you rebase, so that they get into the _actual_ Codeberg repo.
### Add support of new language in Android app
1. Make sure Weblate has generated `strings.xml` for your language in this directory: [android/app/src/main/res/values\*/strings.xml][android_git]
2. Add the language in `localeFilters` list in [build.gradle](https://codeberg.org/comaps/comaps/src/commit/e156d21eee7debd13ce9ec775cdcb264a97aad47/android/app/build.gradle#L258) (It's necessary to add the language in this file to be sure app translations and library translations are integrated in the app).
3. Add the language in [locales_config.xml](https://codeberg.org/comaps/comaps/src/branch/main/android/app/src/main/res/xml/locales_config.xml) (It's necessary to allow users to change app language in Android settings on most recent devices).
[codeberg_translate]: https://translate.codeberg.org/projects/comaps/
[contribute]: https://docs.weblate.org/en/latest/workflows.html
[android_weblate]: https://translate.codeberg.org/projects/comaps/android/

View File

@@ -26,6 +26,7 @@ set(SRC
gen_mwm_info_tests.cpp
# hierarchy_entry_tests.cpp
# hierarchy_tests.cpp
highway_full_name_tests.cpp
intermediate_data_test.cpp
maxspeeds_tests.cpp
merge_collectors_tests.cpp

View File

@@ -0,0 +1,87 @@
#include "testing/testing.hpp"
#include "generator/generator_tests/common.hpp"
namespace highway_full_name_tests
{
UNIT_TEST(HighwayFullNameTest_NotHighway)
{
OsmElement notRoad =
MakeOsmElement(0 /* id */, {{"name", "300 East"}, {"name:prefix", "North"}, {"name:full", "North 300 East"}},
OsmElement::EntityType::Way);
TEST_EQUAL(notRoad.GetTag("name"), "300 East", ());
TEST_EQUAL(notRoad.GetTag("name:prefix"), "North", ());
TEST_EQUAL(notRoad.GetTag("name:full"), "North 300 East", ());
}
UNIT_TEST(HighwayFullNameTest_ReplaceName)
{
OsmElement road1 = MakeOsmElement(
1 /* id */,
{{"highway", "residential"}, {"name", "300 East"}, {"name:prefix", "North"}, {"name:full", "North 300 East"}},
OsmElement::EntityType::Way);
TEST_EQUAL(road1.GetTag("name"), "North 300 East", ());
}
UNIT_TEST(HighwayFullNameTest_MissingName)
{
OsmElement road2 = MakeOsmElement(
2 /* id */, {{"highway", "residential"}, {"name:prefix", "North"}, {"name:full", "North 300 East"}},
OsmElement::EntityType::Way);
TEST(!road2.HasTag("name"), ());
}
UNIT_TEST(HighwayFullNameTest_MissingNamePrefix)
{
OsmElement road3 =
MakeOsmElement(3 /* id */, {{"highway", "residential"}, {"name", "300 East"}, {"name:full", "North 300 East"}},
OsmElement::EntityType::Way);
TEST_EQUAL(road3.GetTag("name"), "300 East", ());
TEST(!road3.HasTag("name:prefix"), ());
}
UNIT_TEST(HighwayFullNameTest_MissingNameFull)
{
OsmElement road4 =
MakeOsmElement(4 /* id */, {{"highway", "residential"}, {"name", "300 East"}, {"name:prefix", "North"}},
OsmElement::EntityType::Way);
TEST_EQUAL(road4.GetTag("name"), "300 East", ());
TEST(!road4.HasTag("name:full"), ());
}
UNIT_TEST(HighwayFullNameTest_OnlyName)
{
OsmElement road5 =
MakeOsmElement(5 /* id */, {{"highway", "residential"}, {"name", "300 East"}}, OsmElement::EntityType::Way);
TEST_EQUAL(road5.GetTag("name"), "300 East", ());
TEST(!road5.HasTag("name:prefix"), ());
TEST(!road5.HasTag("name:full"), ());
}
UNIT_TEST(HighwayFullNameTest_OnlyFullName)
{
OsmElement road6 = MakeOsmElement(6 /* id */, {{"highway", "residential"}, {"name:full", "North 300 East"}},
OsmElement::EntityType::Way);
TEST_EQUAL(road6.GetTag("name:full"), "North 300 East", ());
TEST(!road6.HasTag("name"), ());
TEST(!road6.HasTag("name:prefix"), ());
}
UNIT_TEST(HighwayFullNameTest_NotMatching)
{
OsmElement road7 = MakeOsmElement(
7 /* id */,
{{"highway", "residential"}, {"name", "300 East"}, {"name:prefix", "South"}, {"name:full", "North 300 East"}},
OsmElement::EntityType::Way);
TEST_EQUAL(road7.GetTag("name"), "300 East", ());
}
} // namespace highway_full_name_tests

View File

@@ -362,9 +362,20 @@ void LeaveLongestTypes(std::vector<generator::TypeStrings> & matchedTypes)
{
// Prevents types, that either have subtypes or are subtypes, from being removed
auto subtypes = ftypes::Subtypes::Instance();
auto const hasSubtypeRelatedTypes = [subtypes](auto const & lhs, auto const & rhs)
auto const areSubtypeRelatedTypes = [subtypes](auto const & lhs, auto const & rhs)
{
return subtypes.IsPathOfTypeWithSubtypesOrSubtype(lhs) || subtypes.IsPathOfTypeWithSubtypesOrSubtype(rhs);
return subtypes.IsTypeWithSubtypesOrSubtype(lhs) && subtypes.IsTypeWithSubtypesOrSubtype(rhs);
};
auto const isBetterBecauseOfSubtypeRelation = [subtypes](auto const & lhs, auto const & rhs) -> std::optional<bool>
{
bool const lhsIsTypeWithSubtypesOrSubtype = subtypes.IsTypeWithSubtypesOrSubtype(lhs);
bool const rhsIsTypeWithSubtypesOrSubtype = subtypes.IsTypeWithSubtypesOrSubtype(rhs);
if (lhsIsTypeWithSubtypesOrSubtype && !rhsIsTypeWithSubtypesOrSubtype)
return true;
else if (!lhsIsTypeWithSubtypesOrSubtype && rhsIsTypeWithSubtypesOrSubtype)
return false;
return subtypes.ComparisonResultBasedOnTypeRelation(lhs, rhs);
};
auto const equalPrefix = [](auto const & lhs, auto const & rhs)
@@ -373,8 +384,12 @@ void LeaveLongestTypes(std::vector<generator::TypeStrings> & matchedTypes)
return equal(lhs.begin(), lhs.begin() + std::min(size_t(2), prefixSz), rhs.begin());
};
auto const isBetter = [&equalPrefix](auto const & lhs, auto const & rhs)
auto const isBetter = [&equalPrefix, &isBetterBecauseOfSubtypeRelation](auto const & lhs, auto const & rhs)
{
std::optional<bool> const isBetterBecauseOfSubtypeRelationResult = isBetterBecauseOfSubtypeRelation(lhs, rhs);
if (isBetterBecauseOfSubtypeRelationResult.has_value())
return isBetterBecauseOfSubtypeRelationResult.value();
if (equalPrefix(lhs, rhs))
{
// Longest type is better.
@@ -385,17 +400,14 @@ void LeaveLongestTypes(std::vector<generator::TypeStrings> & matchedTypes)
return lhs < rhs;
};
// `true` means it will be deleted, because being equal means it isn't unique
auto const isEqual = [&equalPrefix, &hasSubtypeRelatedTypes](auto const & lhs, auto const & rhs)
// `true` means the second one will be removed, because being equal means it isn't unique and the first one is more important
auto const isEqual = [&equalPrefix, &areSubtypeRelatedTypes](auto const & lhs, auto const & rhs)
{
if (hasSubtypeRelatedTypes(lhs, rhs))
return false;
if (equalPrefix(lhs, rhs))
{
// Keep longest type only, so return equal is true.
// Keep longest type only
if (lhs.size() != rhs.size())
return true;
return !areSubtypeRelatedTypes(lhs, rhs);
return lhs == rhs;
}

View File

@@ -52,6 +52,36 @@ void OsmElement::AddTag(std::string_view key, std::string_view value)
return;
m_tags.emplace_back(key, value);
// Determine if all of these keys are set,
// without having to repeatedly look them up in the tags list
if (key == "name")
m_setKeys |= NAME;
else if (key == "name:prefix")
m_setKeys |= NAME_PREFIX;
else if (key == "name:full")
m_setKeys |= NAME_FULL;
else if (key == "highway")
m_setKeys |= HIGHWAY;
else
return; // Only run the following code if one of the above keys was added
// If a highway has a name, a full name, and a name prefix,
// and the full name is equal to the name prefix joined with a space before the name,
// then replace the name with the full name
// See https://codeberg.org/comaps/comaps/issues/3193
if (m_setKeys & NAME && m_setKeys & NAME_PREFIX && m_setKeys & NAME_FULL && m_setKeys & HIGHWAY)
{
std::string name = GetTag("name");
std::string namePrefix = GetTag("name:prefix");
std::string nameFull = GetTag("name:full");
if ((namePrefix + " " + name) == nameFull)
UpdateTag("name", nameFull);
else
LOG(LDEBUG, ("Highway name tags don't match. name:prefix:", namePrefix, "name:", name, "name:full:", nameFull,
"in OSM Element:", m_id));
}
}
bool OsmElement::HasTag(std::string_view const & key) const

View File

@@ -21,6 +21,14 @@ struct OsmElement
Osm = 0x736F, // "os"
};
enum SetKeys
{
NAME = 0x1 << 0,
NAME_PREFIX = 0x1 << 1,
NAME_FULL = 0x1 << 2,
HIGHWAY = 0x1 << 3,
};
struct Member
{
Member() = default;
@@ -126,6 +134,7 @@ struct OsmElement
std::string GetTag(std::string const & key) const;
EntityType m_type = EntityType::Unknown;
uint8_t m_setKeys = 0;
uint64_t m_id = 0;
double m_lon = 0;
double m_lat = 0;

View File

@@ -41,6 +41,9 @@ NS_SWIFT_NAME(SettingsBridge)
+ (NSString *)mapLanguageCode;
+ (void)setMapLanguageCode:(NSString *)mapLanguageCode;
+ (BOOL)mapLanguageLimitAlternativesToLocal;
+ (void)setMapLanguageLimitAlternativesToLocal:(BOOL)mapLanguageLimitAlternativesToLocal;
+ (BOOL)transliteration;
+ (void)setTransliteration:(BOOL)transliteration;

View File

@@ -234,6 +234,20 @@ NSString * const kUDFileLoggingEnabledKey = @"FileLoggingEnabledKey";
}
}
+ (BOOL)mapLanguageLimitAlternativesToLocal
{
bool enabled = true;
UNUSED_VALUE(settings::Get(settings::kMapLanguageLimitAlternativesToLocal, enabled));
return enabled;
}
+ (void)setMapLanguageLimitAlternativesToLocal:(BOOL)mapLanguageLimitAlternativesToLocal
{
settings::Set(settings::kMapLanguageLimitAlternativesToLocal, static_cast<bool>(mapLanguageLimitAlternativesToLocal));
auto & f = GetFramework();
f.InvalidateRect(f.GetCurrentViewport());
}
+ (BOOL)transliteration { return GetFramework().LoadTransliteration(); }
+ (void)setTransliteration:(BOOL)transliteration
{

View File

@@ -1095,6 +1095,7 @@
"edit_track" = "Track bearbeiten";
"pref_mapappearance_title" = "Kartendarstellung";
"pref_maplanguage_title" = "Karten-Sprache";
"limit_map_language_alternatives_to_local" = "Alternative Sprachen auf lokale Sprachen begrenzen";
"transliteration_title_disabled_summary" = "Bei der Nutzung der lokalen Sprache für die Karte ausgeschaltet";
"pref_maplanguage_local" = "Lokale Sprache";
"existence_confirmed_time_ago" = "Existenz bestätigt %@";

View File

@@ -766,6 +766,7 @@
"traffic_data_unavailable" = "Traffic data is not available";
"enable_logging" = "Enable logging";
"log_file_size" = "Log file size: %@";
"limit_map_language_alternatives_to_local" = "Limit alternative languages to local ones";
"transliteration_title" = "Transliterate into Latin alphabet";
"transliteration_title_disabled_summary" = "Disabled when always using the local language for the map";

View File

@@ -1402,6 +1402,7 @@
"type.shop.watches" = "Watch Shop";
"type.shop.wholesale" = "Wholesale Shop";
"type.sport" = "Sport";
"type.sport.multi" = "Various Sports";
"type.sport.9pin" = "Bowling";
"type.sport.10pin" = "Bowling";
"type.sport.american_football" = "American Football";

View File

@@ -786,6 +786,7 @@
"traffic_data_unavailable" = "Traffic data is not available";
"enable_logging" = "Enable logging";
"log_file_size" = "Log file size: %@";
"limit_map_language_alternatives_to_local" = "Limit alternative languages to local ones";
"transliteration_title" = "Transliterate into Latin alphabet";
"transliteration_title_disabled_summary" = "Disabled when always using the local language for the map";

View File

@@ -12,6 +12,7 @@
165953942CB44B5600CFED7C /* symbols in Resources */ = {isa = PBXBuildFile; fileRef = 165953932CB44B3B00CFED7C /* symbols */; };
1DFA2F6A20D3B57400FB2C66 /* UIColor+PartnerColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DFA2F6920D3B57400FB2C66 /* UIColor+PartnerColor.m */; };
270C9C282E16AB6F00ABA688 /* Profile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 270C9C252E16AB6300ABA688 /* Profile.swift */; };
271186872F19467400FD7FF3 /* countries_meta.txt in Resources */ = {isa = PBXBuildFile; fileRef = 271186862F19467400FD7FF3 /* countries_meta.txt */; };
27176A862E65B0150015F25F /* Icon.icon in Resources */ = {isa = PBXBuildFile; fileRef = 27176A852E65B0150015F25F /* Icon.icon */; };
27176A8A2E65B01B0015F25F /* Debug Icon.icon in Resources */ = {isa = PBXBuildFile; fileRef = 27176A892E65B01B0015F25F /* Debug Icon.icon */; };
272CA4492F127221005A3F5B /* subtypes.csv in Resources */ = {isa = PBXBuildFile; fileRef = 272CA4482F127221005A3F5B /* subtypes.csv */; };
@@ -763,6 +764,7 @@
1DFA2F6920D3B57400FB2C66 /* UIColor+PartnerColor.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; indentWidth = 2; lineEnding = 0; path = "UIColor+PartnerColor.m"; sourceTree = "<group>"; tabWidth = 2; };
1DFA2F6E20D3CA9200FB2C66 /* UIColorRoutines.h */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = UIColorRoutines.h; sourceTree = "<group>"; tabWidth = 2; };
270C9C252E16AB6300ABA688 /* Profile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Profile.swift; sourceTree = "<group>"; };
271186862F19467400FD7FF3 /* countries_meta.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = countries_meta.txt; path = ../../data/countries_meta.txt; sourceTree = SOURCE_ROOT; };
27176A852E65B0150015F25F /* Icon.icon */ = {isa = PBXFileReference; lastKnownFileType = folder.iconcomposer.icon; path = Icon.icon; sourceTree = "<group>"; };
27176A892E65B01B0015F25F /* Debug Icon.icon */ = {isa = PBXFileReference; lastKnownFileType = folder.iconcomposer.icon; path = "Debug Icon.icon"; sourceTree = "<group>"; };
272CA4482F127221005A3F5B /* subtypes.csv */ = {isa = PBXFileReference; lastKnownFileType = text; name = subtypes.csv; path = ../../data/subtypes.csv; sourceTree = SOURCE_ROOT; };
@@ -3941,6 +3943,7 @@
452FCA3A1B6A3DF7007019AB /* colors.txt */,
97A5967E19B9CD47007A963F /* copyright.html */,
FA46DA2B12D4166E00968C36 /* countries.txt */,
271186862F19467400FD7FF3 /* countries_meta.txt */,
4A23D1561B8B4DD700D4EB6F /* drules_proto_default_light.bin */,
4A00DBDE1AB704C400113624 /* drules_proto_default_dark.bin */,
FA637ECC29A500BE00D8921A /* drules_proto_outdoors_light.bin */,
@@ -4179,6 +4182,7 @@
files = (
165953742CB1D85500CFED7C /* fonts in Resources */,
165953942CB44B5600CFED7C /* symbols in Resources */,
271186872F19467400FD7FF3 /* countries_meta.txt in Resources */,
47AEF8402231249E00D20538 /* categories_brands.txt in Resources */,
F6C3A1B221AC22810060EEC8 /* Alert 5.m4a in Resources */,
3404F49A2028A20D0090E401 /* BMCCategoryCell.xib in Resources */,

View File

@@ -167,6 +167,17 @@ import AVFoundation
}
/// If the alternative languages for the app only should be used when they are the local native language
static var shouldLimitMapLanguageAlternativesToLocal: Bool {
get {
return SettingsBridge.mapLanguageLimitAlternativesToLocal()
}
set {
SettingsBridge.setMapLanguageLimitAlternativesToLocal(newValue)
}
}
/// If the compass should be calibrated
@objc static var shouldCalibrateCompass: Bool {
get {

View File

@@ -36,6 +36,10 @@ struct SettingsView: View {
@State var selectedLanguageForMap: Settings.MapLanguage.ID? = nil
/// If the alternative languages for the app only should be used when they are the local native language
@State private var shouldLimitMapLanguageAlternativesToLocal: Bool = true
/// If names should be transliterated to Latin
@State private var shouldTransliterateToLatin: Bool = true
@@ -153,6 +157,20 @@ struct SettingsView: View {
Text("pref_maplanguage_title")
}
Toggle(isOn: $shouldLimitMapLanguageAlternativesToLocal) {
VStack(alignment: .leading) {
Text("limit_map_language_alternatives_to_local")
if selectedLanguageForMap == "default" {
Text("transliteration_title_disabled_summary")
.font(.footnote)
.foregroundStyle(.secondary)
}
}
}
.tint(.accent)
.disabled(selectedLanguageForMap == "default")
Toggle(isOn: $shouldTransliterateToLatin) {
VStack(alignment: .leading) {
Text("transliteration_title")
@@ -296,6 +314,7 @@ struct SettingsView: View {
hasAutomaticDownload = Settings.hasAutomaticDownload
hasIncreasedFontsize = Settings.hasIncreasedFontsize
selectedLanguageForMap = Settings.languageForMap
shouldLimitMapLanguageAlternativesToLocal = Settings.shouldLimitMapLanguageAlternativesToLocal
shouldTransliterateToLatin = Settings.shouldTransliterateToLatin
selectedMapAppearance = Settings.mapAppearance
selectedAppearance = Settings.appearance
@@ -328,6 +347,9 @@ struct SettingsView: View {
Settings.languageForMap = changedSelectedLanguageForMap
}
}
.onChange(of: shouldLimitMapLanguageAlternativesToLocal) { changedShouldLimitMapLanguageAlternativesToLocal in
Settings.shouldLimitMapLanguageAlternativesToLocal = changedShouldLimitMapLanguageAlternativesToLocal
}
.onChange(of: shouldTransliterateToLatin) { changedShouldTransliterateToLatin in
Settings.shouldTransliterateToLatin = changedShouldTransliterateToLatin
}

View File

@@ -72,6 +72,8 @@ set(SRC
feature_impl.hpp
feature_meta.cpp
feature_meta.hpp
feature_region_locator.cpp
feature_region_locator.hpp
feature_processor.hpp
feature_source.cpp
feature_source.hpp

View File

@@ -3,6 +3,7 @@
#include "indexer/classificator.hpp"
#include "indexer/feature_algo.hpp"
#include "indexer/feature_impl.hpp"
#include "indexer/feature_region_locator.hpp"
#include "indexer/feature_utils.hpp"
#include "indexer/map_object.hpp"
#include "indexer/shared_load_info.hpp"
@@ -825,7 +826,16 @@ void FeatureType::GetReadableName(bool allowTranslit, int8_t deviceLang, feature
ParseCommon();
feature::GetReadableName({GetNames(), mwmInfo->GetRegionData(), deviceLang, allowTranslit}, out);
auto regionData = mwmInfo->GetRegionData();
if (regionData.IsWorldLevel())
{
if (GetGeomType() == feature::GeomType::Point)
regionData.SetLanguages(RegionLocator::Instance().GetLocalLanguages(GetCenter()));
else
regionData.SetLanguages({"int_name", "en", "default"});
}
feature::GetReadableName({GetNames(), regionData, deviceLang, allowTranslit}, out);
}
string const & FeatureType::GetHouseNumber()

View File

@@ -92,17 +92,20 @@ public:
/// @return Type score, less is better.
uint8_t Score(uint32_t t) const
{
if (IsIn(0, t))
return 1;
ftype::TruncValue(t, 2);
if (IsIn(3, t))
return 4;
ftype::TruncValue(t, 1);
if (IsIn(2, t))
return 3;
ftype::TruncValue(t, 1);
if (IsIn(1, t))
return 2;
if (IsIn(0, t))
return 1;
return 0;
}
@@ -118,7 +121,7 @@ private:
{
// Fill types that will be taken into account last,
// when we have many types for POI.
base::StringIL const types1[] = {
base::StringIL const types2[] = {
// 1-arity
{"building:part"}, {"hwtag"}, {"psurface"}, {"internet_access"}, {"organic"},
{"wheelchair"}, {"cuisine"}, {"area:highway"}, {"fee"},
@@ -126,15 +129,18 @@ private:
Classificator const & c = classif();
m_types[0].push_back(c.GetTypeByPath({"building"}));
for (auto const subtype : ftypes::Subtypes::Instance().AllSubtypes())
m_types[0].push_back(subtype);
m_types[1].reserve(std::size(types1));
for (auto const & type : types1)
m_types[1].push_back(c.GetTypeByPath(type));
m_types[1].push_back(c.GetTypeByPath({"building"}));
m_types[2].reserve(std::size(types2));
for (auto const & type : types2)
m_types[2].push_back(c.GetTypeByPath(type));
// Put _most_ useless types here, that are not fit in the arity logic above.
// This change is for generator, to eliminate "lit" type first when max types count exceeded.
m_types[2].push_back(c.GetTypeByPath({"hwtag", "lit"}));
m_types[3].push_back(c.GetTypeByPath({"hwtag", "lit"}));
for (auto & v : m_types)
std::sort(v.begin(), v.end());
@@ -142,7 +148,7 @@ private:
bool IsIn(uint8_t idx, uint32_t t) const { return std::binary_search(m_types[idx].begin(), m_types[idx].end(), t); }
vector<uint32_t> m_types[3];
vector<uint32_t> m_types[4];
};
} // namespace
@@ -196,9 +202,9 @@ void TypesHolder::SortBySpec()
std::stable_sort(begin(), end(), [&checker, &getPriority, &subtypes](uint32_t t1, uint32_t t2)
{
std::optional<bool> const comaprisonResultBasedOnTypeRelation = subtypes.ComaprisonResultBasedOnTypeRelation(t1, t2);
if (comaprisonResultBasedOnTypeRelation.has_value())
return comaprisonResultBasedOnTypeRelation.value();
std::optional<bool> const comparisonResultBasedOnTypeRelation = subtypes.ComparisonResultBasedOnTypeRelation(t1, t2);
if (comparisonResultBasedOnTypeRelation.has_value())
return comparisonResultBasedOnTypeRelation.value();
int const p1 = getPriority(t1);
int const p2 = getPriority(t2);

View File

@@ -216,6 +216,11 @@ void Metadata::ClearPOIAttribs()
++i;
}
bool RegionData::IsWorldLevel() const
{
return Get(RegionData::Type::RD_LANGUAGES).empty();
}
void RegionData::SetLanguages(vector<string> const & codes)
{
string value;

View File

@@ -224,6 +224,7 @@ public:
MetadataBase::Set(type, s);
}
bool IsWorldLevel() const;
void SetLanguages(std::vector<std::string> const & codes);
void GetLanguages(std::vector<int8_t> & langs) const;
bool HasLanguage(int8_t const lang) const;

View File

@@ -0,0 +1,26 @@
#include "indexer/feature_region_locator.hpp"
#include "defines.hpp"
#include "platform/platform.hpp"
namespace feature
{
/// Constructor
RegionLocator::RegionLocator()
{
auto & platform = GetPlatform();
m_infoGetter = storage::CountryInfoReader::CreateCountryInfoGetter(platform);
auto reader = platform.GetReader(COUNTRIES_META_FILE);
string buffer;
reader->ReadAsString(buffer);
m_jsonRoot = base::Json(buffer.data());
}
/// Static instance
RegionLocator const & RegionLocator::Instance()
{
static RegionLocator instance;
return instance;
}
} // namespace feature

View File

@@ -0,0 +1,56 @@
#pragma once
#include "coding/reader.hpp"
#include "cppjansson/cppjansson.hpp"
#include "storage/storage.hpp"
#include "storage/country_info_getter.hpp"
#include <vector>
namespace feature
{
using namespace std;
class RegionLocator
{
public:
/// Static instance
static RegionLocator const & Instance();
/**
* Find the local languages codes for a given point
* @param point The point to check
* @return The local language codes
*/
vector<string> GetLocalLanguages(m2::PointD const point) const
{
auto const regionId = m_infoGetter->GetRegionCountryId(point);
vector<string> regionIdParts;
for (auto const regionIdPart : strings::Tokenize(regionId, "_")) {
regionIdParts.push_back(string(regionIdPart));
}
json_t const * jsonData = nullptr;
vector<string> languages;
while (languages.empty() && !regionIdParts.empty()) {
string regionId = strings::JoinStrings(regionIdParts, "_");
FromJSONObjectOptionalField(m_jsonRoot.get(), regionId, jsonData);
if (jsonData)
FromJSONObjectOptionalField(jsonData, "languages", languages);
regionIdParts.pop_back();
}
return languages;
}
private:
/// Constructor
RegionLocator();
/// Country info getter
unique_ptr<storage::CountryInfoGetter> m_infoGetter;
/// JSON root
base::Json m_jsonRoot;
};
} // namespace feature

View File

@@ -10,6 +10,7 @@
#include "platform/distance.hpp"
#include "platform/localization.hpp"
#include "platform/preferred_languages.hpp"
#include "platform/settings.hpp"
#include "coding/string_utf8_multilang.hpp"
#include "coding/transliteration.hpp"
@@ -118,7 +119,7 @@ bool IsNativeLang(feature::RegionData const & regionData, int8_t deviceLang)
return false;
}
int8_t DefaultLanguage(feature::RegionData const & regionData, vector<int8_t> const & langs)
int8_t DefaultLanguageFromRegionData(feature::RegionData const & regionData, vector<int8_t> const & langs)
{
for (auto const lang : langs)
{
@@ -133,18 +134,39 @@ int8_t DefaultLanguage(feature::RegionData const & regionData, vector<int8_t> co
return StrUtf8::kDefaultCode;
}
vector<int8_t> PrioritizedLanguages(vector<int8_t> const & langs, int8_t defaultLang)
vector<int8_t> PrioritizedLanguages(optional<feature::RegionData> const & regionData = {})
{
bool limitAlternativesToLocal = true;
UNUSED_VALUE(settings::Get(settings::kMapLanguageLimitAlternativesToLocal, limitAlternativesToLocal));
vector<int8_t> prioritizedLangs = {};
vector<int8_t> const langs = languages::GetPreferredLangIndexes();
int8_t defaultLang = StrUtf8::kUnsupportedLanguageCode;
if (regionData.has_value())
defaultLang = DefaultLanguageFromRegionData(regionData.value(), langs);
for (auto const lang : langs)
{
if (find(prioritizedLangs.begin(), prioritizedLangs.end(), lang) == prioritizedLangs.end())
if (!limitAlternativesToLocal &&
find(prioritizedLangs.begin(), prioritizedLangs.end(), lang) == prioritizedLangs.end())
prioritizedLangs.push_back(lang);
if (defaultLang != StrUtf8::kUnsupportedLanguageCode && defaultLang == lang)
prioritizedLangs.push_back(StrUtf8::kDefaultCode);
if (!limitAlternativesToLocal)
{
auto const similarLangs = GetSimilarLanguages(lang);
prioritizedLangs.insert(prioritizedLangs.cend(), similarLangs.cbegin(), similarLangs.cend());
}
}
if (limitAlternativesToLocal)
{
auto lang = langs.front();
prioritizedLangs.push_back(lang);
auto const similarLangs = GetSimilarLanguages(lang);
prioritizedLangs.insert(prioritizedLangs.cend(), similarLangs.cbegin(), similarLangs.cend());
}
@@ -158,8 +180,7 @@ vector<int8_t> PrioritizedLanguages(vector<int8_t> const & langs, int8_t default
void GetReadableNameImpl(NameParamsIn const & in, bool preferDefault, NameParamsOut & out)
{
auto const preferredLangs = languages::GetPreferredLangIndexes();
auto const langPriority = PrioritizedLanguages(preferredLangs, DefaultLanguage(in.regionData, preferredLangs));
auto const langPriority = PrioritizedLanguages(in.regionData);
if (GetBestName(in.src, langPriority, out.primary))
return;
@@ -362,8 +383,7 @@ void GetPreferredNames(NameParamsIn const & in, NameParamsOut & out)
if (in.IsNativeOrSimilarLang())
return GetReadableNameImpl(in, true /* preferDefault */, out);
auto const preferredLangs = languages::GetPreferredLangIndexes();
auto const primaryCodes = PrioritizedLanguages(preferredLangs, DefaultLanguage(in.regionData, preferredLangs));
auto const primaryCodes = PrioritizedLanguages(in.regionData);
if (!GetBestName(in.src, primaryCodes, out.primary) && in.allowTranslit)
GetTransliteratedName(in.regionData, in.src, out.transliterated);
@@ -428,17 +448,14 @@ int8_t GetNameForSearchOnBooking(RegionData const & regionData, StringUtf8Multil
}
*/
bool GetPreferredName(StringUtf8Multilang const & src, int8_t deviceLang, string_view & out)
bool GetPreferredName(StringUtf8Multilang const & src, string_view & out)
{
auto const preferredLangs = languages::GetPreferredLangIndexes();
auto const priorityList = PrioritizedLanguages(preferredLangs, StrUtf8::kUnsupportedLanguageCode);
return GetBestName(src, priorityList, out);
return GetBestName(src, PrioritizedLanguages(), out);
}
vector<int8_t> GetDescriptionLangPriority(RegionData const & regionData)
{
auto const preferredLangs = languages::GetPreferredLangIndexes();
return PrioritizedLanguages(preferredLangs, DefaultLanguage(regionData, preferredLangs));
return PrioritizedLanguages(regionData);
}
vector<string> GetLocalizedSubtypes(TypesHolder const & types)

View File

@@ -137,7 +137,7 @@ std::string const GetReadableAddress(std::string const & address);
// int8_t GetNameForSearchOnBooking(RegionData const & regionData, StringUtf8Multilang const & src, std::string & name);
/// Returns preferred name when only the device language is available.
bool GetPreferredName(StringUtf8Multilang const & src, int8_t deviceLang, std::string_view & out);
bool GetPreferredName(StringUtf8Multilang const & src, std::string_view & out);
/// Returns priority list of language codes for feature description,
/// the priority is the following:

View File

@@ -3,7 +3,6 @@
#include "base/assert.hpp"
#include "coding/csv_reader.hpp"
#include "coding/reader_streambuf.hpp"
#include "indexer/classificator.hpp"
#include "platform/platform.hpp"
#include "defines.hpp"

View File

@@ -1,5 +1,7 @@
#pragma once
#include "indexer/classificator.hpp"
#include <cstdint>
#include <map>
#include <optional>
@@ -18,6 +20,24 @@ public:
/// Static instance
static Subtypes const & Instance();
/**
* Lists all types with subtypes
* @return All types with subtypes
*/
unordered_set<uint32_t> AllTypesWithSubtypes() const
{
return m_types;
}
/**
* Lists all subtypes
* @return All subtypes
*/
unordered_set<uint32_t> AllSubtypes() const
{
return m_subtypes;
}
/**
* Checks if the given type is a type with subtypes or a subtype
* @param type The type to check
@@ -69,15 +89,17 @@ public:
* @param secondType The type to compare
* @return `true` if the first type is a subtype but the second one isn't, `false` if it is the other way around
*/
optional<bool> ComaprisonResultBasedOnTypeRelation(uint32_t const firstType, uint32_t const secondType) const
optional<bool> ComparisonResultBasedOnTypeRelation(uint32_t const firstType, uint32_t const secondType) const
{
bool const firstTypeIsTypeWithSubtypes = IsTypeWithSubtypes(firstType);
bool const firstTypeIsSubtype = IsSubtype(firstType);
bool const secondTypeIsTypeWithSubtypes = IsTypeWithSubtypes(secondType);
bool const secondTypeIsSubtype = IsSubtype(secondType);
if (!firstTypeIsSubtype && !secondTypeIsSubtype)
if ((!firstTypeIsTypeWithSubtypes && !firstTypeIsSubtype) || (!secondTypeIsTypeWithSubtypes && !secondTypeIsSubtype) || (firstTypeIsTypeWithSubtypes && secondTypeIsTypeWithSubtypes))
return {};
else if (firstTypeIsSubtype && !secondTypeIsSubtype)
else if (firstTypeIsSubtype && secondTypeIsTypeWithSubtypes)
return false;
else if (!firstTypeIsSubtype && secondTypeIsSubtype)
else if (firstTypeIsTypeWithSubtypes && secondTypeIsSubtype)
return true;
// If they got to here, both are subtypes. So use the order of the subtypes for the comparison.
@@ -98,12 +120,29 @@ public:
* @param typePath The type path to check
* @return `true` if it is a type with subtypes or a subtype, otherwise `false`
*/
bool IsPathOfTypeWithSubtypesOrSubtype(vector<string> const typePath) const
bool IsTypeWithSubtypesOrSubtype(vector<string> const typePath) const
{
return ranges::find(m_typesAndSubtypesPaths.begin(), m_typesAndSubtypesPaths.end(), typePath) !=
m_typesAndSubtypesPaths.end();
}
/**
* Compares to given types based on their type relation
* @param firstTypePath The first type to compare
* @param secondTypePath The type to compare
* @return `true` if the first type is a subtype but the second one isn't, `false` if it is the other way around
*/
optional<bool> ComparisonResultBasedOnTypeRelation(vector<string> const firstTypePath, vector<string> const secondTypePath) const
{
auto const & classificator = classif();
uint32_t const firstType = classificator.GetTypeByPathSafe(vector<string_view>(firstTypePath.begin(), firstTypePath.end()));
uint32_t const secondType = classificator.GetTypeByPathSafe(vector<string_view>(secondTypePath.begin(), secondTypePath.end()));
if (firstType != IndexAndTypeMapping::INVALID_TYPE && secondType != IndexAndTypeMapping::INVALID_TYPE)
return ComparisonResultBasedOnTypeRelation(firstType, secondType);
return {};
}
private:
/// Constructor
Subtypes();

View File

@@ -81,10 +81,12 @@ public:
MwmTypeT GetType() const;
// Switch to following simplified code after this pull request has been included in one release:
// feature::RegionData GetRegionData() const { return m_data; }
feature::RegionData GetRegionData() const {
auto regionData = m_data;
if (GetType() == MwmTypeT::WORLD || GetType() == MwmTypeT::COASTS) {
regionData.SetLanguages({"int_name","en","default"});
regionData.SetLanguages({});
}
return regionData;
}

View File

@@ -31,10 +31,8 @@ std::string GetPreferredBookmarkStr(LocalizableString const & name, std::string
for (auto const & pair : name)
nameMultilang.AddString(pair.first, pair.second);
auto const deviceLang = StringUtf8Multilang::GetLangIndex(languageNorm);
std::string_view preferredName;
if (feature::GetPreferredName(nameMultilang, deviceLang, preferredName))
if (feature::GetPreferredName(nameMultilang, preferredName))
return std::string(preferredName);
return {};

View File

@@ -22,6 +22,7 @@ using std::string;
std::string_view kMeasurementUnits = "Units";
std::string_view kMapLanguageCode = "MapLanguageCode";
std::string_view kMapLanguageLimitAlternativesToLocal = "MapLanguageLimitAlternativesToLocal";
std::string_view kDeveloperMode = "DeveloperMode";
std::string_view kDonateUrl = "DonateUrl";
std::string_view kNY = "NY";

View File

@@ -12,6 +12,7 @@ namespace settings
extern std::string_view kMeasurementUnits;
extern std::string_view kDeveloperMode;
extern std::string_view kMapLanguageCode;
extern std::string_view kMapLanguageLimitAlternativesToLocal;
// The following two settings are configured externally at the metaserver.
extern std::string_view kDonateUrl;
extern std::string_view kNY;

View File

@@ -115,6 +115,7 @@ copy_resources(
colors.txt
copyright.html
countries.txt
countries_meta.txt
drules_proto_default_light.bin
drules_proto_default_dark.bin
drules_proto_outdoors_light.bin

View File

@@ -137,6 +137,7 @@ OSM_TOOL_UPDATE = "osmupdate"
OSM_TOOLS_CC = "cc"
OSM_TOOLS_CC_FLAGS = [
"-O3",
"-std=gnu17",
]
# Planet and coasts:

View File

@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
2711868B2F194FF000FD7FF3 /* feature_region_locator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2711868A2F194FCF00FD7FF3 /* feature_region_locator.hpp */; };
2711868D2F194FF600FD7FF3 /* feature_region_locator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2711868C2F194FF400FD7FF3 /* feature_region_locator.cpp */; };
272CA4462F126795005A3F5B /* ftypes_subtypes.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 272CA4442F126795005A3F5B /* ftypes_subtypes.hpp */; };
272CA4472F126795005A3F5B /* ftypes_subtypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 272CA4452F126795005A3F5B /* ftypes_subtypes.cpp */; };
272CA44D2F12723B005A3F5B /* subtypes.csv in Resources */ = {isa = PBXBuildFile; fileRef = 272CA44C2F12723B005A3F5B /* subtypes.csv */; };
@@ -233,6 +235,8 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
2711868A2F194FCF00FD7FF3 /* feature_region_locator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = feature_region_locator.hpp; sourceTree = "<group>"; };
2711868C2F194FF400FD7FF3 /* feature_region_locator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = feature_region_locator.cpp; sourceTree = "<group>"; };
272CA4442F126795005A3F5B /* ftypes_subtypes.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ftypes_subtypes.hpp; sourceTree = "<group>"; };
272CA4452F126795005A3F5B /* ftypes_subtypes.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ftypes_subtypes.cpp; sourceTree = "<group>"; };
272CA44C2F12723B005A3F5B /* subtypes.csv */ = {isa = PBXFileReference; lastKnownFileType = text; name = subtypes.csv; path = ../../data/subtypes.csv; sourceTree = "<group>"; };
@@ -677,6 +681,8 @@
675340C71A3F540F00A0A8C3 /* feature_impl.hpp */,
6726C1CF1A49DAAC005EEA39 /* feature_meta.cpp */,
6726C1D01A49DAAC005EEA39 /* feature_meta.hpp */,
2711868C2F194FF400FD7FF3 /* feature_region_locator.cpp */,
2711868A2F194FCF00FD7FF3 /* feature_region_locator.hpp */,
675340CC1A3F540F00A0A8C3 /* feature_processor.hpp */,
675B562120D25C9800A521D2 /* feature_source.cpp */,
675B562220D25C9800A521D2 /* feature_source.hpp */,
@@ -794,6 +800,7 @@
6753414C1A3F540F00A0A8C3 /* tree_structure.hpp in Headers */,
F6DF5F311CD0FD9A00A87154 /* categories_index.hpp in Headers */,
40662D32236059BF006A124D /* tree_node.hpp in Headers */,
2711868B2F194FF000FD7FF3 /* feature_region_locator.hpp in Headers */,
347F337D1C454242009758CC /* succinct_trie_builder.hpp in Headers */,
675341381A3F540F00A0A8C3 /* mwm_set.hpp in Headers */,
456E1B181F90E5B7009C32E1 /* cities_boundaries_serdes.hpp in Headers */,
@@ -945,7 +952,7 @@
3496ABA31DC1FA7200C5DDBA /* editor.config in Resources */,
3496AB9D1DC1FA5200C5DDBA /* drules_proto_clear.bin in Resources */,
3496AB9E1DC1FA5200C5DDBA /* drules_proto_dark.bin in Resources */,
272CA44D2F12723B005A3F5B /* subtypes.csv in Resources */,
272CA44D2F12723B005A3F5B /* subtypes.csv in Resources */,
FA67C84F26BB36D700B33DCA /* categories_brands.txt in Resources */,
FA67C84626BB356800B33DCA /* categories_cuisines.txt in Resources */,
3496ABA11DC1FA5200C5DDBA /* drules_proto.bin in Resources */,
@@ -1041,6 +1048,7 @@
272CA4472F126795005A3F5B /* ftypes_subtypes.cpp in Sources */,
BBB7060F23E46E0100A7F29A /* isolines_info.cpp in Sources */,
408FE47724FEB95600F5D06D /* metadata_serdes.cpp in Sources */,
2711868D2F194FF600FD7FF3 /* feature_region_locator.cpp in Sources */,
34583BCB1C88552100F94664 /* map_object.cpp in Sources */,
675B562320D25C9800A521D2 /* feature_source.cpp in Sources */,
6753412E1A3F540F00A0A8C3 /* index_builder.cpp in Sources */,