diff --git a/android/jni/com/mapswithme/maps/SearchEngine.cpp b/android/jni/com/mapswithme/maps/SearchEngine.cpp index 3c86bbd360..edb87542d5 100644 --- a/android/jni/com/mapswithme/maps/SearchEngine.cpp +++ b/android/jni/com/mapswithme/maps/SearchEngine.cpp @@ -290,13 +290,12 @@ extern "C" } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_search_SearchEngine_nativeRunSearch( - JNIEnv * env, jclass clazz, jbyteArray bytes, jboolean isCategory, - jstring lang, jlong timestamp, jboolean hasPosition, jdouble lat, jdouble lon) + JNIEnv * env, jclass clazz, jbyteArray bytes, jstring lang, jlong timestamp, + jboolean hasPosition, jdouble lat, jdouble lon) { search::EverywhereSearchParams params; params.m_query = jni::ToNativeString(env, bytes); params.m_inputLocale = jni::ToNativeString(env, lang); - params.m_isCategory = isCategory; params.m_onResults = bind(&OnResults, _1, _2, timestamp, false, hasPosition, lat, lon); bool const searchStarted = g_framework->NativeFramework()->GetSearchAPI().SearchEverywhere(params); if (searchStarted) @@ -305,13 +304,12 @@ extern "C" } JNIEXPORT void JNICALL Java_com_mapswithme_maps_search_SearchEngine_nativeRunInteractiveSearch( - JNIEnv * env, jclass clazz, jbyteArray bytes, jboolean isCategory, - jstring lang, jlong timestamp, jboolean isMapAndTable) + JNIEnv * env, jclass clazz, jbyteArray bytes, jstring lang, jlong timestamp, + jboolean isMapAndTable) { search::ViewportSearchParams vparams; vparams.m_query = jni::ToNativeString(env, bytes); vparams.m_inputLocale = jni::ToNativeString(env, lang); - vparams.m_isCategory = isCategory; // TODO (@alexzatsepin): set up vparams.m_onCompleted here and use // HotelsClassifier for hotel queries detection. diff --git a/android/src/com/mapswithme/maps/routing/SearchWheel.java b/android/src/com/mapswithme/maps/routing/SearchWheel.java index 4085920c5c..5241234b95 100644 --- a/android/src/com/mapswithme/maps/routing/SearchWheel.java +++ b/android/src/com/mapswithme/maps/routing/SearchWheel.java @@ -280,8 +280,7 @@ class SearchWheel implements View.OnClickListener { mCurrentOption = searchOption; final String query = mFrame.getContext().getString(searchOption.mQueryId); - // Category request from navigation search wheel. - SearchEngine.INSTANCE.searchInteractive(mFrame.getContext(), query, true, System.nanoTime(), false); + SearchEngine.INSTANCE.searchInteractive(mFrame.getContext(), query, System.nanoTime(), false /* isMapAndTable */); SearchEngine.INSTANCE.setQuery(query); refreshSearchButtonImage(); toggleSearchLayout(); diff --git a/android/src/com/mapswithme/maps/search/SearchEngine.java b/android/src/com/mapswithme/maps/search/SearchEngine.java index 94078ac24f..ae2c97197a 100644 --- a/android/src/com/mapswithme/maps/search/SearchEngine.java +++ b/android/src/com/mapswithme/maps/search/SearchEngine.java @@ -127,26 +127,25 @@ public enum SearchEngine implements NativeSearchListener, * @return whether search was actually started. */ @MainThread - public boolean search(@NonNull Context context, String query, boolean isCategory, - long timestamp, boolean hasLocation, double lat, double lon) + public boolean search(@NonNull Context context, String query, long timestamp, boolean hasLocation, + double lat, double lon) { - return nativeRunSearch(query.getBytes(StandardCharsets.UTF_8), isCategory, - Language.getKeyboardLocale(context), timestamp, hasLocation, lat, lon); + return nativeRunSearch(query.getBytes(StandardCharsets.UTF_8), Language.getKeyboardLocale(context), + timestamp, hasLocation, lat, lon); } @MainThread - public void searchInteractive(@NonNull String query, boolean isCategory, @NonNull String locale, - long timestamp, boolean isMapAndTable) + public void searchInteractive(@NonNull String query, @NonNull String locale, long timestamp, + boolean isMapAndTable) { - nativeRunInteractiveSearch(query.getBytes(StandardCharsets.UTF_8), isCategory, - locale, timestamp, isMapAndTable); + nativeRunInteractiveSearch(query.getBytes(StandardCharsets.UTF_8), locale, timestamp, isMapAndTable); } @MainThread - public void searchInteractive(@NonNull Context context, @NonNull String query, boolean isCategory, - long timestamp, boolean isMapAndTable) + public void searchInteractive(@NonNull Context context, @NonNull String query, long timestamp, + boolean isMapAndTable) { - searchInteractive(query, isCategory, Language.getKeyboardLocale(context), timestamp, isMapAndTable); + searchInteractive(query, Language.getKeyboardLocale(context), timestamp, isMapAndTable); } @MainThread @@ -224,15 +223,13 @@ public enum SearchEngine implements NativeSearchListener, /** * @param bytes utf-8 formatted bytes of query. */ - private static native boolean nativeRunSearch(byte[] bytes, boolean isCategory, - String language, long timestamp, boolean hasLocation, + private static native boolean nativeRunSearch(byte[] bytes, String language, long timestamp, boolean hasLocation, double lat, double lon); /** * @param bytes utf-8 formatted query bytes */ - private static native void nativeRunInteractiveSearch(byte[] bytes, boolean isCategory, - String language, long timestamp, + private static native void nativeRunInteractiveSearch(byte[] bytes, String language, long timestamp, boolean isMapAndTable); /** diff --git a/android/src/com/mapswithme/maps/search/SearchFragment.java b/android/src/com/mapswithme/maps/search/SearchFragment.java index 7e6a0829f3..9529aed4dc 100644 --- a/android/src/com/mapswithme/maps/search/SearchFragment.java +++ b/android/src/com/mapswithme/maps/search/SearchFragment.java @@ -348,9 +348,15 @@ public class SearchFragment extends BaseMwmFragment super.onDestroy(); } - private String getQuery() { return mToolbarController.getQuery(); } - private boolean isCategory() { return mToolbarController.isCategory(); } - void setQuery(String text) { mToolbarController.setQuery(text); } + private String getQuery() + { + return mToolbarController.getQuery(); + } + + void setQuery(String text) + { + mToolbarController.setQuery(text); + } private void readArguments() { @@ -430,12 +436,12 @@ public class SearchFragment extends BaseMwmFragment mLastQueryTimestamp = System.nanoTime(); SearchEngine.INSTANCE.searchInteractive( - query, isCategory(), !TextUtils.isEmpty(mInitialLocale) + query, !TextUtils.isEmpty(mInitialLocale) ? mInitialLocale : com.mapswithme.util.Language.getKeyboardLocale(requireContext()), mLastQueryTimestamp, false /* isMapAndTable */); - SearchEngine.INSTANCE.setQuery(query); Utils.navigateToParent(getActivity()); + } private void onSearchEnd() @@ -473,13 +479,12 @@ public class SearchFragment extends BaseMwmFragment mLastQueryTimestamp = System.nanoTime(); if (isTabletSearch()) { - SearchEngine.INSTANCE.searchInteractive(requireContext(), getQuery(), isCategory(), - mLastQueryTimestamp, true /* isMapAndTable */); + SearchEngine.INSTANCE.searchInteractive(requireContext(), getQuery(), mLastQueryTimestamp, true /* isMapAndTable */); } else { - if (!SearchEngine.INSTANCE.search(requireContext(), getQuery(), isCategory(), - mLastQueryTimestamp, mLastPosition.valid, mLastPosition.lat, mLastPosition.lon)) + if (!SearchEngine.INSTANCE.search(requireContext(), getQuery(), mLastQueryTimestamp, mLastPosition.valid, + mLastPosition.lat, mLastPosition.lon)) { return; } @@ -513,7 +518,7 @@ public class SearchFragment extends BaseMwmFragment @Override public void onSearchCategorySelected(@Nullable String category) { - mToolbarController.setQuery(category, true); + mToolbarController.setQuery(category); } private void refreshSearchResults(@NonNull SearchResult[] results) diff --git a/android/src/com/mapswithme/maps/widget/SearchToolbarController.java b/android/src/com/mapswithme/maps/widget/SearchToolbarController.java index 12db4194de..90b9d164f1 100644 --- a/android/src/com/mapswithme/maps/widget/SearchToolbarController.java +++ b/android/src/com/mapswithme/maps/widget/SearchToolbarController.java @@ -31,7 +31,6 @@ public class SearchToolbarController extends ToolbarController implements View.O private final View mBack; @NonNull private final EditText mQuery; - private boolean mFromCategory = false; @NonNull private final View mProgress; @NonNull @@ -158,16 +157,13 @@ public class SearchToolbarController extends ToolbarController implements View.O { return (UiUtils.isVisible(mSearchContainer) ? mQuery.getText().toString() : ""); } - public boolean isCategory() { return mFromCategory; } - public void setQuery(CharSequence query, boolean fromCategory) + public void setQuery(CharSequence query) { - mFromCategory = fromCategory; mQuery.setText(query); if (!TextUtils.isEmpty(query)) mQuery.setSelection(query.length()); } - public void setQuery(CharSequence query) { setQuery(query, false); } public void clear() { diff --git a/base/base_tests/small_set_test.cpp b/base/base_tests/small_set_test.cpp index c67f2d4c1d..f9f863991a 100644 --- a/base/base_tests/small_set_test.cpp +++ b/base/base_tests/small_set_test.cpp @@ -121,7 +121,7 @@ UNIT_TEST(SmallMap_Benchmark1) // 3. Run unordered_map. { - base::HighResTimer timer; + base::Timer timer; for (auto i : indices) sum1 += (uMap.find(i) != uMap.end() ? 1 : 0); t1 = timer.ElapsedMilliseconds(); @@ -129,7 +129,7 @@ UNIT_TEST(SmallMap_Benchmark1) // 4. Run SmallMap. { - base::HighResTimer timer; + base::Timer timer; for (auto i : indices) sum2 += (sMap.Find(i) ? 1 : 0); t2 = timer.ElapsedMilliseconds(); @@ -193,7 +193,7 @@ UNIT_TEST(SmallMap_Benchmark2) // 3. Run unordered_map. { - base::HighResTimer timer; + base::Timer timer; for (auto i : indices) { auto const it = uMap.find(keys[i]); @@ -205,7 +205,7 @@ UNIT_TEST(SmallMap_Benchmark2) // 4. Run SmallMap. { - base::HighResTimer timer; + base::Timer timer; for (auto i : indices) { auto const * p = sMap.Find(keys[i]); @@ -242,7 +242,7 @@ UNIT_TEST(SmallMap_Benchmark3) // 3. Run unordered_map. { - base::HighResTimer timer; + base::Timer timer; for (auto i : indices) sum1 += uMap.find(keys[i])->second; t1 = timer.ElapsedMilliseconds(); @@ -250,7 +250,7 @@ UNIT_TEST(SmallMap_Benchmark3) // 4. Run SmallMap. { - base::HighResTimer timer; + base::Timer timer; for (auto i : indices) sum2 += *sMap.Find(keys[i]); t2 = timer.ElapsedMilliseconds(); @@ -258,7 +258,7 @@ UNIT_TEST(SmallMap_Benchmark3) // 5. Run SmallMapBase. { - base::HighResTimer timer; + base::Timer timer; for (auto i : indices) sum3 += *sbMap.Find(keys[i]); t3 = timer.ElapsedMilliseconds(); diff --git a/base/timer.cpp b/base/timer.cpp index 8e7c36453f..6b4a0a3e2a 100644 --- a/base/timer.cpp +++ b/base/timer.cpp @@ -19,6 +19,12 @@ namespace base { +Timer::Timer(bool start/* = true*/) +{ + if (start) + Reset(); +} + // static double Timer::LocalTime() { @@ -165,6 +171,32 @@ time_t StringToTimestamp(std::string const & s) return res; } +HighResTimer::HighResTimer(bool start/* = true*/) +{ + if (start) + Reset(); +} + +void HighResTimer::Reset() +{ + m_start = std::chrono::high_resolution_clock::now(); +} + +uint64_t HighResTimer::ElapsedNano() const +{ + return std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - m_start).count(); +} + +uint64_t HighResTimer::ElapsedMillis() const +{ + return std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - m_start).count(); +} + +double HighResTimer::ElapsedSeconds() const +{ + return std::chrono::duration_cast>(std::chrono::high_resolution_clock::now() - m_start).count(); +} + time_t SecondsSinceEpochToTimeT(uint64_t secondsSinceEpoch) { std::chrono::time_point const tpoint{std::chrono::seconds(secondsSinceEpoch)}; @@ -188,7 +220,7 @@ ScopedTimerWithLog::~ScopedTimerWithLog() { case Measure::MilliSeconds: { - LOG(LINFO, (m_name, "time:", m_timer.ElapsedMilliseconds(), "ms")); + LOG(LINFO, (m_name, "time:", m_timer.ElapsedMillis(), "ms")); return; } case Measure::Seconds: diff --git a/base/timer.hpp b/base/timer.hpp index 49499e1fad..d918265751 100644 --- a/base/timer.hpp +++ b/base/timer.hpp @@ -7,22 +7,19 @@ namespace base { -namespace impl +/// Cross platform timer +class Timer { -template class StdTimer -{ - typename ClockT::time_point m_startTime; + std::chrono::steady_clock::time_point m_startTime; public: - explicit StdTimer(bool start = true) - { - if (start) - Reset(); - } + explicit Timer(bool start = true); + + /// @return current UTC time in seconds, elapsed from 1970. + static double LocalTime(); - using DurationT = typename ClockT::duration; /// @return Elapsed time from start (@see Reset). - inline DurationT TimeElapsed() const { return ClockT::now() - m_startTime; } + inline std::chrono::steady_clock::duration TimeElapsed() const { return std::chrono::steady_clock::now() - m_startTime; } template inline Duration TimeElapsedAs() const @@ -34,21 +31,7 @@ public: inline uint64_t ElapsedMilliseconds() const { return TimeElapsedAs().count(); } inline uint64_t ElapsedNanoseconds() const { return TimeElapsedAs().count(); } - inline void Reset() { m_startTime = ClockT::now(); } -}; -} // namespace impl - - -/// Cross platform timer -class Timer : public impl::StdTimer -{ - using BaseT = impl::StdTimer; - -public: - using BaseT::BaseT; - - /// @return current UTC time in seconds, elapsed from 1970. - static double LocalTime(); + inline void Reset() { m_startTime = std::chrono::steady_clock::now(); } }; std::string FormatCurrentTime(); @@ -79,7 +62,19 @@ time_t StringToTimestamp(std::string const & s); /// High resolution timer to use in comparison tests. -using HighResTimer = impl::StdTimer; +class HighResTimer +{ + typedef std::chrono::high_resolution_clock::time_point PointT; + PointT m_start; + +public: + explicit HighResTimer(bool start = true); + + void Reset(); + uint64_t ElapsedNano() const; + uint64_t ElapsedMillis() const; + double ElapsedSeconds() const; +}; class ScopedTimerWithLog { diff --git a/data/categories.txt b/data/categories.txt index ad7106561c..ffff29efa2 100644 --- a/data/categories.txt +++ b/data/categories.txt @@ -3224,7 +3224,6 @@ ja:自転車修理 ko:자전거 수리 nl:4Fiets reparatie pt:Conserto de bicicleta|4bicicleta -pt-BR:Oficina de bicicletas|4bicicleta ru:4Велоремонт|велосипед|ремонт|ремонт велосипедов tr:4Bisiklet tamiri|4Bisiklet uk:4Велоремонт|велосипед|ремонт|ремонт велосипедів @@ -4784,7 +4783,7 @@ it:WC ja:お手洗い|便所|厠 pl:wc|ubikacja|wychodek pt:Casa de banho|WC|Sanitários|lavatório -pt-BR:toalete|wc|sanitários|lavabo|privada +pt-BR:toalete|wc|sanitários es:3Baños|aseos|3lavabo|inodoro|baño|wc eu:3Komunak|3konketa sv:WC|toalett diff --git a/data/strings/types_strings.txt b/data/strings/types_strings.txt index ed3d57d1c9..a43a65e5b1 100644 --- a/data/strings/types_strings.txt +++ b/data/strings/types_strings.txt @@ -637,7 +637,7 @@ nl = Fiets reparatie station pl = Stacja naprawy rowerów pt = Estação de conserto de bicicletas - pt-BR = Oficina de conserto de bicicletas + pt-BR = Estação de conserto de bicicletas ru = Станция ремонта велосипедов sw = Cykelreparationsstation th = สถานีซ่อมจักรยาน @@ -8295,18 +8295,15 @@ ref = type.highway.road.bridge ja = 馬道(橋) pl = Most drogowy dla koni - pt-BR = Ponte para cavaleiros [type.highway.bridleway.permissive] ref = type.highway.bridleway pl = Droga dla koni ograniczona - pt-BR = Caminho para cavaleiros permissivo [type.highway.bridleway.tunnel] ref = type.highway.road.tunnel ja = 馬道(トンネル) pl = Tunel drogowy dla koni - pt-BR = Túnel para cavaleiros [type.highway.bus_stop] en = Bus Stop @@ -8398,18 +8395,15 @@ ref = type.highway.road.bridge ja = 自転車道(橋) pl = Most drogowy dla rowerów - pt-BR = Ponte para ciclistas [type.highway.cycleway.permissive] ref = type.highway.cycleway pl = Droga rowerowa ograniczona - pt-BR = Caminho para ciclistas permissivo [type.highway.cycleway.tunnel] ref = type.highway.road.tunnel ja = 自転車道(トンネル) pl = Tunel drogowy dla rowerów - pt-BR = Túnel para ciclistas [type.highway.elevator] en = Elevator @@ -8419,7 +8413,6 @@ eu = Igogailua fr = Ascenseur mr = उद्वाहक(लिफ्ट) - pt-BR = Elevador ru = Лифт tr = Asansör uk = Ліфт @@ -8471,7 +8464,6 @@ en = Pedestrian Zone mr = पादचारी झोन pl = Obszar chodnika - pt-BR = Área de pedestres ru = Пешеходная зона tr = Yaya Alanı uk = Пішохідна зона @@ -8481,28 +8473,27 @@ en = Pedestrian Bridge mr = पादचारी पूल pl = Most dla pieszych - pt-BR = Ponte para pedestres ru = Пешеходный мост [type.highway.footway.demanding_alpine_hiking] ref = type.highway.path de = Anspruchsvoller Alpinwanderweg pt = Caminho pedonal - pt-BR = Caminho pedonal difícil + pt-BR = Caminho pedonal zh-Hans = 步行道路 [type.highway.footway.demanding_mountain_hiking] ref = type.highway.path de = Anspruchsvoller Bergwanderweg pt = Caminho pedonal - pt-BR = Caminho pedonal difícil + pt-BR = Caminho pedonal zh-Hans = 步行道路 [type.highway.footway.difficult_alpine_hiking] ref = type.highway.path de = Schwieriger Alpinwanderweg pt = Caminho pedonal - pt-BR = Caminho pedonal difícil + pt-BR = Caminho pedonal zh-Hans = 步行道路 [type.highway.footway.hiking] @@ -8528,7 +8519,6 @@ de = Fußgängertunnel mr = पादचारी बोगदा pl = Tunel dla pieszych - pt-BR = Túnel para pedestres ru = Пешеходный тоннель [type.highway.ford] @@ -8606,7 +8596,6 @@ ref = type.highway.road.tunnel de = Spielstraßentunnel pl = Tunel ulicy - pt-BR = Túnel rodoviário [type.highway.motorway] en = Motorway @@ -8648,7 +8637,6 @@ de = Autobahnbrücke mr = महामार्ग पूल pl = Most drogowy - pt-BR = Ponte rodoviária ru = Автомобильный мост [type.highway.motorway.tunnel] @@ -8657,7 +8645,6 @@ de = Autobahntunnel mr = महामार्ग बोगदा pl = Tunel drogowy - pt-BR = Túnel rodoviário ru = Автомобильный тоннель [type.highway.motorway_junction] @@ -8698,7 +8685,6 @@ de = Autobahnauffahrt mr = महामार्ग उतार pt = Ligação a autoestrada - pt-BR = Acesso a rodovia ru = Съезд с автомагистрали tr = Otoyol Rampası uk = З'їзд з автомагістралі @@ -8749,7 +8735,6 @@ ref = type.highway.path de = Alpinwanderweg pl = Ścieżka wspinaczkowa - pt-BR = Caminho pedonal [type.highway.path.bicycle] ref = type.highway.path @@ -8757,7 +8742,6 @@ de = Radweg mr = सायकल आणि पाऊलवाट pl = Ścieżka dla rowerów - pt-BR = Caminho para ciclistas ru = Велопешеходная дорожка tr = Bisiklet ve Yürüyüş Yolu uk = Велопішохідна доріжка @@ -8768,28 +8752,23 @@ [type.highway.path.demanding_alpine_hiking] ref = type.highway.path de = Anspruchsvoller Alpinwanderweg - pt-BR = Caminho pedonal difícil [type.highway.path.demanding_mountain_hiking] ref = type.highway.path de = Anspruchsvoller Bergwanderweg - pt-BR = Caminho pedonal difícil [type.highway.path.difficult_alpine_hiking] ref = type.highway.path de = Schwieriger Alpinwanderweg - pt-BR = Caminho pedonal difícil [type.highway.path.hiking] ref = type.highway.path de = Wanderweg - pt-BR = Caminho pedonal [type.highway.path.horse] ref = type.highway.path en = Bridle Path de = Reitweg - pt-BR = Caminho para cavaleiros ru = Конная тропа tr = Atlı Yolu uk = Кінна стежка @@ -8797,7 +8776,6 @@ [type.highway.path.mountain_hiking] ref = type.highway.path de = Bergwanderweg - pt-BR = Caminho pedonal [type.highway.path.permissive] ref = type.highway.path @@ -8853,7 +8831,6 @@ en = Pedestrian Bridge mr = पादचारी पूल pl = Most pasażu pieszego - pt-BR = Ponte para pedestres ru = Пешеходный мост [type.highway.pedestrian.tunnel] @@ -8862,7 +8839,6 @@ de = Fußgängertunnel mr = पादचारी बोगदा pl = Tunel pasażu pieszego - pt-BR = Túnel para pedestres ru = Пешеходный тоннель [type.highway.primary] @@ -8906,13 +8882,11 @@ ref = type.highway.road.tunnel de = Hauptstraßentunnel pl = Tunel drogowy - pt-BR = Túnel rodoviário [type.highway.primary_link] ref = type.highway.primary en = Primary Road Ramp mr = प्राथमिक मार्ग उतार - pt-BR = Saída de rodovia ru = Съезд с шоссе uk = З'їзд з шосе zh-Hans = 主要道路连接路 @@ -9001,7 +8975,6 @@ [type.highway.residential.tunnel] ref = type.highway.road.tunnel de = Wohnstraßentunnel - pt-BR = Túnel residencial [type.highway.rest_area] en = Rest Area @@ -9191,13 +9164,11 @@ ref = type.highway.road.tunnel de = Straßentunnel pl = Tunel drogowy - pt-BR = Túnel rodoviário [type.highway.secondary_link] ref = type.highway.secondary en = Secondary Road Ramp mr = दुय्यम मार्ग उतार - pt-BR = Saída de rodovia ru = Съезд с автодороги uk = З'їзд з автодороги zh-Hans = 次要道路连接路 @@ -9210,7 +9181,6 @@ ref = type.highway.road.tunnel de = Straßentunnel pl = Tunel drogowy - pt-BR = Túnel rodoviário [type.highway.service] en = Service Road @@ -9262,7 +9232,6 @@ uk = Під'їзд zh-Hans = 车道 zh-Hant = 車道 - pt-BR = Via de acesso [type.highway.service.parking_aisle] ref = type.highway.service @@ -9282,7 +9251,6 @@ ref = type.highway.road.tunnel de = Straßentunnel pl = Tunel drogowy - pt-BR = Túnel rodoviário [type.highway.services] en = Service Area @@ -9414,13 +9382,11 @@ ref = type.highway.road.tunnel de = Straßentunnel pl = Tunel drogowy - pt-BR = Túnel rodoviário [type.highway.tertiary_link] ref = type.highway.tertiary en = Tertiary Road Ramp mr = तृतीयक मार्ग उतार - pt-BR = Saída de rodovia ru = Съезд с дороги tr = Üçüncül Yol Rampası uk = З'їзд з дороги @@ -9434,7 +9400,6 @@ ref = type.highway.road.tunnel de = Straßentunnel pl = Tunel drogowy - pt-BR = Túnel rodoviário [type.highway.track] en = Track @@ -9501,7 +9466,6 @@ ref = type.highway.road.tunnel de = Straßentunnel pl = Tunel drogowy - pt-BR = Túnel rodoviário [type.highway.traffic_signals] en = Traffic Lights @@ -9577,13 +9541,11 @@ [type.highway.trunk.tunnel] ref = type.highway.road.tunnel de = Schnellstraßentunnel - pt-BR = Túnel rodoviário [type.highway.trunk_link] ref = type.highway.trunk en = National Highway Ramp mr = राष्ट्रीय महामार्ग उतार - pt-BR = Saída de rodovia ru = Съезд с трассы uk = З'їзд з траси zh-Hans = 干线道路连接路 @@ -9595,7 +9557,6 @@ [type.highway.trunk_link.tunnel] ref = type.highway.road.tunnel de = Straßentunnel - pt-BR = Túnel rodoviário [type.highway.unclassified] en = Minor Road @@ -9641,28 +9602,23 @@ ref = type.highway.road.tunnel de = Straßentunnel pl = Tunel drogowy - pt-BR = Túnel rodoviário [type.area_highway.cycleway] ref = type.highway.cycleway fi = Pyörätie - pt-BR = Caminho para ciclistas [type.area_highway.footway] ref = type.highway.footway de = Weg fi = Kävelytie - pt-BR = Caminho pedonal [type.area_highway.living_street] ref = type.highway.living_street de = Wohnstraße - pt-BR = Rua residencial [type.area_highway.motorway] ref = type.highway.motorway fi = Moottoritie - pt-BR = Rodovia [type.area_highway.path] ref = type.highway.path @@ -9670,7 +9626,6 @@ [type.area_highway.pedestrian] ref = type.highway.pedestrian fi = Kävelykatu - pt-BR = Caminho pedonal [type.area_highway.primary] ref = type.highway.primary @@ -9690,7 +9645,6 @@ [type.area_highway.steps] ref = type.highway.steps fi = Portaat - pt-BR = Travessia [type.area_highway.track] ref = type.highway.track @@ -10387,12 +10341,10 @@ comment = In most (European) countries, сemeteries are usually independent of places of worship (e.g. military cemeteries), while grave yards are usually the yard of a place of worship. ref = type.amenity.grave_yard en = Cemetery - pt-BR = Cemitério [type.landuse.cemetery.christian] ref = type.amenity.grave_yard.christian en = Christian Cemetery - pt-BR = Cemitério cristão [type.landuse.churchyard] en = Churchyard @@ -10464,7 +10416,6 @@ fr = Établissements éducatifs it = Strutture didattiche mr = शैक्षणिक सुविधा - pt-BR = Instituições educacionais ru = Образовательные учреждения uk = Освітній заклади @@ -12065,7 +12016,6 @@ be = Сілас de = Silo mr = पेव(धान्यसाठा) - pt-BR = Silo ru = Элеватор tr = Ambar uk = Силос @@ -12076,7 +12026,6 @@ de = Speichertank fr = Réservoir mr = साठवण टाकी - pt-BR = Tanque de armazenagem ru = Резервуар tr = Depolama Tankı uk = Резервуар @@ -12842,7 +12791,6 @@ nl = Reservoir pl = Zbiornik pt = Reservatório - pt-BR = Reservatório ro = Rezervor ru = Водохранилище sk = Nádrž @@ -14662,7 +14610,6 @@ de = Haltepunkt pl = Przystanek kolejowy pt = Apeadeiro - pt-BR = Ponto de parada zh-Hans = 小站 zh-Hant = 小站 diff --git a/iphone/Maps/Classes/CarPlay/MWMCarPlaySearchService.mm b/iphone/Maps/Classes/CarPlay/MWMCarPlaySearchService.mm index b8b4f83aa9..2f13ff609c 100644 --- a/iphone/Maps/Classes/CarPlay/MWMCarPlaySearchService.mm +++ b/iphone/Maps/Classes/CarPlay/MWMCarPlaySearchService.mm @@ -29,8 +29,7 @@ API_AVAILABLE(ios(12.0)) self.inputLocale = inputLocale; self.lastResults = @[]; self.completionHandler = completionHandler; - /// @todo Didn't find pure category request in CarPlay. - [MWMSearch searchQuery:text forInputLocale:inputLocale withCategory:NO]; + [MWMSearch searchQuery:text forInputLocale:inputLocale]; } - (void)saveLastQuery { diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index 74107c49a5..6dcc05838e 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -106,7 +106,7 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; return NO; self.searchManager.state = MWMSearchManagerStateTableSearch; - [self.searchManager searchText:text forInputLocale:locale withCategory:NO]; + [self.searchManager searchText:text forInputLocale:locale]; return YES; } diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/MWMNavigationInfoView.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/MWMNavigationInfoView.mm index 02f879ed97..7c1bdbe05e 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/MWMNavigationInfoView.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/MWMNavigationInfoView.mm @@ -193,8 +193,7 @@ BOOL defaultOrientation(CGSize const &size) { [MWMSearch setSearchOnMap:YES]; NSString *query = [kSearchButtonRequest.at(state) stringByAppendingString:@" "]; NSString *locale = [[AppInfo sharedInfo] languageId]; - // Category request from navigation search wheel. - [MWMSearch searchQuery:query forInputLocale:locale withCategory:YES]; + [MWMSearch searchQuery:query forInputLocale:locale]; [self setSearchState:state animated:YES]; }; diff --git a/iphone/Maps/Core/Search/MWMSearch.h b/iphone/Maps/Core/Search/MWMSearch.h index edc489da2a..3bc8ea3e0b 100644 --- a/iphone/Maps/Core/Search/MWMSearch.h +++ b/iphone/Maps/Core/Search/MWMSearch.h @@ -14,7 +14,7 @@ struct ProductInfo; + (void)removeObserver:(id)observer; + (void)saveQuery:(NSString *)query forInputLocale:(NSString *)inputLocale; -+ (void)searchQuery:(NSString *)query forInputLocale:(NSString *)inputLocale withCategory:(BOOL)isCategory; ++ (void)searchQuery:(NSString *)query forInputLocale:(NSString *)inputLocale; + (void)showResult:(search::Result const &)result; diff --git a/iphone/Maps/Core/Search/MWMSearch.mm b/iphone/Maps/Core/Search/MWMSearch.mm index b16c51382f..4b99ddb60a 100644 --- a/iphone/Maps/Core/Search/MWMSearch.mm +++ b/iphone/Maps/Core/Search/MWMSearch.mm @@ -132,7 +132,7 @@ using Observers = NSHashTable; GetFramework().GetSearchAPI().SaveSearchQuery(make_pair(locale, text)); } -+ (void)searchQuery:(NSString *)query forInputLocale:(NSString *)inputLocale withCategory:(BOOL)isCategory { ++ (void)searchQuery:(NSString *)query forInputLocale:(NSString *)inputLocale { if (!query) return; @@ -142,15 +142,11 @@ using Observers = NSHashTable; manager->m_everywhereParams.m_inputLocale = locale; manager->m_viewportParams.m_inputLocale = locale; } - manager.lastQuery = query.precomposedStringWithCompatibilityMapping; std::string const text = manager.lastQuery.UTF8String; manager->m_everywhereParams.m_query = text; manager->m_viewportParams.m_query = text; manager.textChanged = YES; - - manager->m_everywhereParams.m_isCategory = manager->m_viewportParams.m_isCategory = (isCategory == YES); - [manager update]; } diff --git a/iphone/Maps/UI/Search/MWMSearchManager.h b/iphone/Maps/UI/Search/MWMSearchManager.h index 7b5ed4346e..0018d916e6 100644 --- a/iphone/Maps/UI/Search/MWMSearchManager.h +++ b/iphone/Maps/UI/Search/MWMSearchManager.h @@ -22,7 +22,7 @@ typedef NS_ENUM(NSInteger, MWMSearchManagerRoutingTooltipSearch) { @property(nonnull, nonatomic) IBOutletCollection(UIView) NSArray *topViews; -- (void)searchText:(nonnull NSString *)text forInputLocale:(nullable NSString *)locale withCategory:(BOOL)isCategory; +- (void)searchText:(nonnull NSString *)text forInputLocale:(nullable NSString *)locale; #pragma mark - Layout diff --git a/iphone/Maps/UI/Search/MWMSearchManager.mm b/iphone/Maps/UI/Search/MWMSearchManager.mm index d78d39a872..3b8d834c18 100644 --- a/iphone/Maps/UI/Search/MWMSearchManager.mm +++ b/iphone/Maps/UI/Search/MWMSearchManager.mm @@ -97,7 +97,7 @@ using Observers = NSHashTable; NSString *text = textField.text; if (text.length > 0) { [self beginSearch]; - [MWMSearch searchQuery:text forInputLocale:textField.textInputMode.primaryLanguage withCategory:NO]; + [MWMSearch searchQuery:text forInputLocale:textField.textInputMode.primaryLanguage]; } else { [self endSearch]; } @@ -135,11 +135,11 @@ using Observers = NSHashTable; #pragma mark - MWMSearchTabbedViewProtocol -- (void)searchText:(NSString *)text forInputLocale:(NSString *)locale withCategory:(BOOL)isCategory { +- (void)searchText:(NSString *)text forInputLocale:(NSString *)locale { [self beginSearch]; self.searchTextField.text = text; NSString *inputLocale = locale ?: self.searchTextField.textInputMode.primaryLanguage; - [MWMSearch searchQuery:text forInputLocale:inputLocale withCategory:isCategory]; + [MWMSearch searchQuery:text forInputLocale:inputLocale]; } - (void)dismissKeyboard { @@ -176,7 +176,7 @@ using Observers = NSHashTable; if (self.state == MWMSearchManagerStateTableSearch || self.state == MWMSearchManagerStateMapSearch) { NSString *text = self.searchTextField.text; if (text.length != 0) - [MWMSearch searchQuery:text forInputLocale:self.searchTextField.textInputMode.primaryLanguage withCategory:NO]; + [MWMSearch searchQuery:text forInputLocale:self.searchTextField.textInputMode.primaryLanguage]; } } @@ -413,11 +413,8 @@ using Observers = NSHashTable; } } -- (void)searchTabController:(MWMSearchTabViewController *)viewController - didSearch:(NSString *)didSearch - withCategory:(BOOL)isCategory -{ - [self searchText:didSearch forInputLocale:[[AppInfo sharedInfo] languageId] withCategory:isCategory]; +- (void)searchTabController:(MWMSearchTabViewController *)viewController didSearch:(NSString *)didSearch { + [self searchText:didSearch forInputLocale:[[AppInfo sharedInfo] languageId]]; } - (MWMSearchTableViewController *)tableViewController { diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm b/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm index 0ce971bfe1..ed72af127f 100644 --- a/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm +++ b/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm @@ -129,8 +129,7 @@ NSString *GetLocalizedTypeName(search::Result const &result) { case MWMSearchItemTypeSuggestion: { auto const &suggestion = [MWMSearch resultWithContainerIndex:containerIndex]; NSString *suggestionString = @(suggestion.GetSuggestionString().c_str()); - /// @todo Pass withCategory:YES if we tap on category suggestion (not street or city)? - [delegate searchText:suggestionString forInputLocale:nil withCategory:NO]; + [delegate searchText:suggestionString forInputLocale:nil]; } } } diff --git a/iphone/Maps/UI/Search/Tabs/MWMSearchTabbedViewProtocol.h b/iphone/Maps/UI/Search/Tabs/MWMSearchTabbedViewProtocol.h index 98147899b9..aca5de9643 100644 --- a/iphone/Maps/UI/Search/Tabs/MWMSearchTabbedViewProtocol.h +++ b/iphone/Maps/UI/Search/Tabs/MWMSearchTabbedViewProtocol.h @@ -6,7 +6,7 @@ @property(nonatomic) MWMSearchManagerState state; -- (void)searchText:(NSString *)text forInputLocale:(NSString *)locale withCategory:(BOOL)isCategory; +- (void)searchText:(NSString *)text forInputLocale:(NSString *)locale; - (void)dismissKeyboard; @end diff --git a/iphone/Maps/UI/Search/Tabs/SearchTabViewController.swift b/iphone/Maps/UI/Search/Tabs/SearchTabViewController.swift index 5d60214d05..3ccb06f370 100644 --- a/iphone/Maps/UI/Search/Tabs/SearchTabViewController.swift +++ b/iphone/Maps/UI/Search/Tabs/SearchTabViewController.swift @@ -1,7 +1,6 @@ -import CoreFoundation @objc(MWMSearchTabViewControllerDelegate) protocol SearchTabViewControllerDelegate: AnyObject { - func searchTabController(_ viewContoller: SearchTabViewController, didSearch: String, withCategory: Bool) + func searchTabController(_ viewContoller: SearchTabViewController, didSearch: String) } @objc(MWMSearchTabViewController) @@ -54,13 +53,13 @@ extension SearchTabViewController: SearchCategoriesViewControllerDelegate { func categoriesViewController(_ viewController: SearchCategoriesViewController, didSelect category: String) { let query = L(category) + " " - delegate?.searchTabController(self, didSearch: query, withCategory: true) + delegate?.searchTabController(self, didSearch: query) } } extension SearchTabViewController: SearchHistoryViewControllerDelegate { func searchHistoryViewController(_ viewController: SearchHistoryViewController, didSelect query: String) { - delegate?.searchTabController(self, didSearch: query, withCategory: false) + delegate?.searchTabController(self, didSearch: query) } } diff --git a/map/everywhere_search_params.hpp b/map/everywhere_search_params.hpp index 7a98bf6a8c..d26a0a7221 100644 --- a/map/everywhere_search_params.hpp +++ b/map/everywhere_search_params.hpp @@ -21,7 +21,6 @@ struct EverywhereSearchParams std::string m_query; std::string m_inputLocale; std::optional m_timeout; - bool m_isCategory = false; OnResults m_onResults; }; diff --git a/map/search_api.cpp b/map/search_api.cpp index f11d6c5939..62ca2fbfbb 100644 --- a/map/search_api.cpp +++ b/map/search_api.cpp @@ -184,7 +184,6 @@ bool SearchAPI::SearchEverywhere(EverywhereSearchParams const & params) p.m_suggestsEnabled = true; p.m_needAddress = true; p.m_needHighlighting = true; - p.m_categorialRequest = params.m_isCategory; if (params.m_timeout) p.m_timeout = *params.m_timeout; @@ -212,7 +211,6 @@ bool SearchAPI::SearchInViewport(ViewportSearchParams const & params) p.m_suggestsEnabled = false; p.m_needAddress = false; p.m_needHighlighting = false; - p.m_categorialRequest = params.m_isCategory; if (params.m_timeout) p.m_timeout = *params.m_timeout; diff --git a/map/viewport_search_params.hpp b/map/viewport_search_params.hpp index 87b23619a1..c13c9199d4 100644 --- a/map/viewport_search_params.hpp +++ b/map/viewport_search_params.hpp @@ -17,7 +17,6 @@ struct ViewportSearchParams std::string m_query; std::string m_inputLocale; std::optional m_timeout; - bool m_isCategory = false; OnStarted m_onStarted; OnCompleted m_onCompleted; diff --git a/platform/platform_linux.cpp b/platform/platform_linux.cpp index 7912a75b7d..506d847029 100644 --- a/platform/platform_linux.cpp +++ b/platform/platform_linux.cpp @@ -107,6 +107,7 @@ Platform::Platform() JoinPath(*execDir, "..", "organicmaps", "data"), // build-omim-{debug,release} JoinPath(*execDir, "..", "share"), // installed version with packages JoinPath(*execDir, "..", "OMaps"), // installed version without packages + JoinPath(*execDir, "..", "share", "organicmaps", "data"), // flatpak-build }; for (auto const & dir : dirsToScan) { @@ -122,7 +123,12 @@ Platform::Platform() // Use ~/.local/share/OMaps if resources directory was not writable. if (!m_resourcesDir.empty() && m_writableDir.empty()) { - m_writableDir = JoinPath(*homeDir, ".local", "share", "OMaps"); + // The writableLocation does the same for AppDataLocation, AppLocalDataLocation, + // and GenericDataLocation. Provided, that test mode is not enabled, then + // first it checks ${XDG_DATA_HOME}, if empty then it falls back to ${HOME}/.local/share + m_writableDir = JoinPath(QStandardPaths::writableLocation( + QStandardPaths::AppDataLocation).toStdString(), "OMaps"); + if (!MkDirRecursively(m_writableDir)) MYTHROW(FileSystemException, ("Can't create writable directory:", m_writableDir)); } diff --git a/routing/index_graph.cpp b/routing/index_graph.cpp index 92dd7a3df4..6ab2fde34f 100644 --- a/routing/index_graph.cpp +++ b/routing/index_graph.cpp @@ -226,7 +226,7 @@ void IndexGraph::SetRestrictions(RestrictionVec && restrictions) m_restrictionsBackward[restriction.front()].emplace_back(next(restriction.begin()), restriction.end()); } - LOG(LDEBUG, ("Restrictions are loaded in:", timer.ElapsedMilliseconds(), "ms")); + LOG(LDEBUG, ("Restrictions are loaded in:", timer.ElapsedNano() / 1e6, "ms")); } void IndexGraph::SetUTurnRestrictions(vector && noUTurnRestrictions) diff --git a/routing/routes_builder/routes_builder_tool/utils.cpp b/routing/routes_builder/routes_builder_tool/utils.cpp index bfe4866753..74d3bf4184 100644 --- a/routing/routes_builder/routes_builder_tool/utils.cpp +++ b/routing/routes_builder/routes_builder_tool/utils.cpp @@ -25,11 +25,6 @@ #include #include - -namespace routing -{ -namespace routes_builder -{ using namespace routing_quality; namespace @@ -63,6 +58,10 @@ routing::VehicleType ConvertVehicleTypeFromString(std::string const & str) } } // namespace +namespace routing +{ +namespace routes_builder +{ void BuildRoutes(std::string const & routesPath, std::string const & dumpPath, uint64_t startFrom, @@ -181,9 +180,8 @@ void BuildRoutesWithApi(std::unique_ptr routingApi, size_t rps = 0; base::HighResTimer timer; - auto const getElapsedMilliSeconds = [&timer]() - { - auto const ms = timer.ElapsedMilliseconds(); + auto const getElapsedMilliSeconds = [&timer]() { + double ms = timer.ElapsedNano() / 1e6; LOG(LDEBUG, ("Elapsed:", ms, "ms")); return ms; }; @@ -193,10 +191,9 @@ void BuildRoutesWithApi(std::unique_ptr routingApi, timer.Reset(); }; - auto const sleepIfNeed = [&]() - { - // Greater than 1 second. - if (getElapsedMilliSeconds() > 1000) + auto const sleepIfNeed = [&]() { + double constexpr kMsInSecond = 1000.0; + if (getElapsedMilliSeconds() > kMsInSecond) { drop(); return; @@ -213,8 +210,7 @@ void BuildRoutesWithApi(std::unique_ptr routingApi, size_t count = 0; size_t prevDumpedNumber = 0; - auto const dump = [&]() - { + auto const dump = [&]() { for (size_t i = 0; i < count; ++i) { std::string filepath = diff --git a/search/processor.cpp b/search/processor.cpp index 3f67a94166..1da98acdaf 100644 --- a/search/processor.cpp +++ b/search/processor.cpp @@ -253,7 +253,7 @@ void Processor::SetInputLocale(string const & locale) m_inputLocaleCode = CategoriesHolder::MapLocaleToInteger(locale); } -void Processor::SetQuery(string const & query, bool categorialRequest /* = false */) +void Processor::SetQuery(string const & query) { m_query = query; m_tokens.clear(); @@ -319,23 +319,20 @@ void Processor::SetQuery(string const & query, bool categorialRequest /* = false // Get preferred types to show in results. m_preferredTypes.clear(); auto const tokenSlice = QuerySliceOnRawStrings(m_tokens, m_prefix); - - m_isCategorialRequest = categorialRequest; - - auto const locales = GetCategoryLocales(); - if (!FillCategories(tokenSlice, locales, m_categories, m_preferredTypes)) - { - // Try to match query to cuisine categories. - if (FillCategories(tokenSlice, locales, GetDefaultCuisineCategories(), m_cuisineTypes)) - { - /// @todo What if I'd like to find "Burger" street? @see "BurgerStreet" test. - m_isCategorialRequest = true; - m_preferredTypes = ftypes::IsEatChecker::Instance().GetTypes(); - } - } + m_isCategorialRequest = FillCategories(tokenSlice, GetCategoryLocales(), m_categories, m_preferredTypes); if (!m_isCategorialRequest) { + // Try to match query to cuisine categories. + bool const isCuisineRequest = FillCategories( + tokenSlice, GetCategoryLocales(), GetDefaultCuisineCategories(), m_cuisineTypes); + + if (isCuisineRequest) + { + m_isCategorialRequest = true; + m_preferredTypes = ftypes::IsEatChecker::Instance().GetTypes(); + } + // Assign tokens and prefix to scorer. m_keywordsScorer.SetKeywords(m_tokens.data(), m_tokens.size(), m_prefix); @@ -604,7 +601,7 @@ void Processor::Search(SearchParams const & params) SetInputLocale(params.m_inputLocale); - SetQuery(params.m_query, params.m_categorialRequest); + SetQuery(params.m_query); SetViewport(viewport); // Used to store the earliest available cancellation status: @@ -805,9 +802,12 @@ void Processor::InitParams(QueryParams & params) const else params.InitWithPrefix(m_tokens.begin(), m_tokens.end(), m_prefix); - Classificator const & c = classif(); - // Add names of categories (and synonyms). + Classificator const & c = classif(); + auto addCategorySynonyms = [&](size_t i, uint32_t t) { + uint32_t const index = c.GetIndexForType(t); + params.GetTypeIndices(i).push_back(index); + }; auto const tokenSlice = QuerySliceOnRawStrings(m_tokens, m_prefix); params.SetCategorialRequest(m_isCategorialRequest); if (m_isCategorialRequest) @@ -822,14 +822,11 @@ void Processor::InitParams(QueryParams & params) const else { // todo(@m, @y). Shall we match prefix tokens for categories? - ForEachCategoryTypeFuzzy(tokenSlice, [&c, ¶ms](size_t i, uint32_t t) - { - uint32_t const index = c.GetIndexForType(t); - params.GetTypeIndices(i).push_back(index); - }); + ForEachCategoryTypeFuzzy(tokenSlice, addCategorySynonyms); } - // Remove all type indices for streets, as they're considired individually. + // Remove all type indices for streets, as they're considired + // individually. for (size_t i = 0; i < params.GetNumTokens(); ++i) { auto & token = params.GetToken(i); @@ -840,10 +837,8 @@ void Processor::InitParams(QueryParams & params) const for (size_t i = 0; i < params.GetNumTokens(); ++i) base::SortUnique(params.GetTypeIndices(i)); - m_keywordsScorer.ForEachLanguage([¶ms](int8_t lang) - { - params.GetLangs().Insert(static_cast(lang)); - }); + m_keywordsScorer.ForEachLanguage( + [&](int8_t lang) { params.GetLangs().Insert(static_cast(lang)); }); } void Processor::InitGeocoder(Geocoder::Params & geocoderParams, SearchParams const & searchParams) diff --git a/search/processor.hpp b/search/processor.hpp index 5c6cea03ab..564bfbc314 100644 --- a/search/processor.hpp +++ b/search/processor.hpp @@ -70,7 +70,7 @@ public: void SetViewport(m2::RectD const & viewport); void SetPreferredLocale(std::string const & locale); void SetInputLocale(std::string const & locale); - void SetQuery(std::string const & query, bool categorialRequest = false); + void SetQuery(std::string const & query); inline std::string const & GetPivotRegion() const { return m_region; } inline bool IsEmptyQuery() const { return m_prefix.empty() && m_tokens.empty(); } diff --git a/search/search_integration_tests/processor_test.cpp b/search/search_integration_tests/processor_test.cpp index 45ce3bbbee..c9f6c0678d 100644 --- a/search/search_integration_tests/processor_test.cpp +++ b/search/search_integration_tests/processor_test.cpp @@ -848,8 +848,8 @@ UNIT_CLASS_TEST(ProcessorTest, TestCategorialSearch) { Rules const rules = {ExactMatch(wonderlandId, hotel1), ExactMatch(wonderlandId, hotel2)}; - TEST(CategoryMatch("hotel ", rules), ()); - TEST(CategoryMatch("hôTeL ", rules), ()); + TEST(ResultsMatch("hotel ", rules), ()); + TEST(ResultsMatch("hôTeL ", rules), ()); } { @@ -858,13 +858,14 @@ UNIT_CLASS_TEST(ProcessorTest, TestCategorialSearch) // A category with a rare name. The word "Entertainment" // occurs exactly once in the list of categories and starts // with a capital letter. This is a test for normalization. - TEST(CategoryMatch("entertainment ", rules), ()); + TEST(ResultsMatch("entertainment ", rules), ()); } { Rules const rules = {ExactMatch(wonderlandId, hotel1), ExactMatch(wonderlandId, hotel2)}; - TEST(CategoryMatch("гостиница ", rules, "ru"), ()); + auto request = MakeRequest("гостиница ", "ru"); + TEST(ResultsMatch(request->Results(), rules), ()); } { @@ -873,8 +874,8 @@ UNIT_CLASS_TEST(ProcessorTest, TestCategorialSearch) // Hotel unicode character: both a synonym and and emoji. uint32_t const hotelEmojiCodepoint = 0x0001F3E8; strings::UniString const hotelUniString(1, hotelEmojiCodepoint); - - TEST(CategoryMatch(ToUtf8(hotelUniString), rules), ()); + auto request = MakeRequest(ToUtf8(hotelUniString)); + TEST(ResultsMatch(request->Results(), rules), ()); } { @@ -3026,31 +3027,4 @@ UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo_MultipleOldNames) checkResult("Ленинград", "Санкт-Петербург (Ленинград)"); checkResult("Петроград", "Санкт-Петербург (Петроград)"); } - -/// @todo We are not ready for this test yet. -/* -UNIT_CLASS_TEST(ProcessorTest, BurgerStreet) -{ - string const countryName = "Wonderland"; - - TestPOI burger({1.0, 1.0}, "Dummy", "en"); - burger.SetTypes({{"amenity", "fast_food"}, {"cuisine", "burger"}}); - - TestStreet street({{2.0, 2.0}, {3.0, 3.0}}, "Burger street", "en"); - street.SetHighwayType("residential"); - - auto countryId = BuildCountry(countryName, [&](TestMwmBuilder & builder) - { - builder.Add(burger); - builder.Add(street); - }); - - SetViewport(m2::RectD(0, 0, 3, 3)); - - { - Rules rules{ExactMatch(countryId, burger), ExactMatch(countryId, street)}; - TEST(ResultsMatch("burger", rules), ()); - } -} -*/ } // namespace processor_test diff --git a/search/search_integration_tests/smoke_test.cpp b/search/search_integration_tests/smoke_test.cpp index 49d55c2247..cf187cde85 100644 --- a/search/search_integration_tests/smoke_test.cpp +++ b/search/search_integration_tests/smoke_test.cpp @@ -68,6 +68,8 @@ public: { SetTypes({{"shop", "alcohol"}}); } + + ~AlcoShop() override = default; }; class SubwayStation : public TestPOI @@ -78,6 +80,8 @@ public: { SetTypes({{"railway", "station", "subway"}}); } + + ~SubwayStation() override = default; }; class SubwayStationMoscow : public TestPOI @@ -88,6 +92,8 @@ public: { SetTypes({{"railway", "station", "subway", "moscow"}}); } + + ~SubwayStationMoscow() override = default; }; UNIT_CLASS_TEST(SmokeTest, Smoke) @@ -99,8 +105,7 @@ UNIT_CLASS_TEST(SmokeTest, Smoke) AlcoShop brandyShop(m2::PointD(0, 1), "Brandy shop", "en"); AlcoShop vodkaShop(m2::PointD(1, 1), "Russian vodka shop", "en"); - auto id = BuildMwm(kCountryName, DataHeader::MapType::Country, [&](TestMwmBuilder & builder) - { + auto id = BuildMwm(kCountryName, DataHeader::MapType::Country, [&](TestMwmBuilder & builder) { builder.Add(wineShop); builder.Add(tequilaShop); builder.Add(brandyShop); @@ -112,16 +117,18 @@ UNIT_CLASS_TEST(SmokeTest, Smoke) SetViewport(m2::RectD(m2::PointD(0, 0), m2::PointD(100, 100))); { - Rules rules = {ExactMatch(id, wineShop)}; - TEST(ResultsMatch("wine ", rules), ()); + Rules rules = {ExactMatch(id, tequilaShop)}; + /// @todo Passing "wine" will interpret request as "categorial" only + /// (see IsCategorialRequest() after adding craft-winery category). + /// Should avoid this strange logic in search core and pass "categorial" request flag via input SearchParams. + TEST(ResultsMatch("tequila ", rules), ()); } - Rules const allRule = { ExactMatch(id, wineShop), ExactMatch(id, tequilaShop), - ExactMatch(id, brandyShop), ExactMatch(id, vodkaShop) }; - - TEST(ResultsMatch("shop ", allRule), ()); - TEST(ResultsMatch("alcohol ", allRule), ()); - TEST(CategoryMatch("алкоголь", allRule, "ru"), ()); + { + Rules rules = {ExactMatch(id, wineShop), ExactMatch(id, tequilaShop), + ExactMatch(id, brandyShop), ExactMatch(id, vodkaShop)}; + TEST(ResultsMatch("shop ", rules), ()); + } } UNIT_CLASS_TEST(SmokeTest, DeepCategoryTest) @@ -225,7 +232,6 @@ UNIT_CLASS_TEST(SmokeTest, CategoriesTest) notSupportedTypes.insert(cl.GetTypeByPath(tags)); auto const & holder = GetDefaultCategories(); - auto testCategory = [&](uint32_t type, CategoriesHolder::Category const &) { if (invisibleTypes.find(type) != invisibleTypes.end()) @@ -244,10 +250,11 @@ UNIT_CLASS_TEST(SmokeTest, CategoriesTest) auto id = BuildMwm(countryName, DataHeader::MapType::Country, [&](TestMwmBuilder & builder) { builder.AddSafe(poi); }); + SetViewport(m2::RectD(m2::PointD(0.0, 0.0), m2::PointD(2.0, 2.0))); { Rules rules = {ExactMatch(id, poi)}; - auto const query = holder.GetReadableFeatureType(type, CategoriesHolder::kEnglishCode); - TEST(CategoryMatch(query, categoryIsSearchable ? rules : Rules{}), (query)); + auto const query = holder.GetReadableFeatureType(type, CategoriesHolder::kEnglishCode) + " "; + TEST(ResultsMatch(query, categoryIsSearchable ? rules : Rules{}), (query)); } DeregisterMap(countryName); }; diff --git a/search/search_params.hpp b/search/search_params.hpp index ed4cfc9560..f7070385d0 100644 --- a/search/search_params.hpp +++ b/search/search_params.hpp @@ -21,18 +21,18 @@ class Tracer; struct SearchParams { - static size_t constexpr kDefaultNumBookmarksResults = 1000; - static size_t constexpr kDefaultBatchSizeEverywhere = 10; - static size_t constexpr kDefaultNumResultsEverywhere = 30; - static size_t constexpr kDefaultNumResultsInViewport = 200; - static size_t constexpr kPreResultsCount = 200; - static double constexpr kDefaultStreetSearchRadiusM = 8e4; - static double constexpr kDefaultVillageSearchRadiusM = 2e5; - - using TimeDurationT = base::Timer::DurationT; - /// @todo Short timeouts lead to a non-working search on slow devices. Design a better solution. - static TimeDurationT constexpr kDefaultTimeout = std::chrono::seconds(8); - static TimeDurationT constexpr kDefaultDesktopTimeout = std::chrono::seconds(8); + inline static size_t const kDefaultNumBookmarksResults = 1000; + inline static size_t const kDefaultBatchSizeEverywhere = 10; + inline static size_t const kDefaultNumResultsEverywhere = 30; + inline static size_t const kDefaultNumResultsInViewport = 200; + inline static size_t const kPreResultsCount = 200; + inline static double const kDefaultStreetSearchRadiusM = 8e4; + inline static double const kDefaultVillageSearchRadiusM = 2e5; + // TODO: Short timeouts leads to a non-working search on slow devices. Design a better solution. + inline static std::chrono::steady_clock::duration const kDefaultTimeout = + std::chrono::seconds(8); + inline static std::chrono::steady_clock::duration const kDefaultDesktopTimeout = + std::chrono::seconds(8); using OnStarted = std::function; using OnResults = std::function; @@ -92,13 +92,10 @@ struct SearchParams // Needed to highlight matching parts of search result names. bool m_needHighlighting = false; - /// True if you need *pure* category results, without names/addresses/etc matching. - bool m_categorialRequest = false; - bookmarks::GroupId m_bookmarksGroupId = bookmarks::kInvalidGroupId; // Amount of time after which the search is aborted. - TimeDurationT m_timeout = kDefaultTimeout; + std::chrono::steady_clock::duration m_timeout = kDefaultTimeout; std::shared_ptr m_tracer; }; diff --git a/search/search_tests_support/helpers.cpp b/search/search_tests_support/helpers.cpp index 8f5560b5b0..d5954f3354 100644 --- a/search/search_tests_support/helpers.cpp +++ b/search/search_tests_support/helpers.cpp @@ -10,7 +10,6 @@ namespace search { using namespace std; -using namespace tests_support; SearchTest::SearchTest() : m_scopedLog(LDEBUG) @@ -26,30 +25,24 @@ void SearchTest::RegisterCountry(string const & name, m2::RectD const & rect) infoGetter.AddCountry(storage::CountryDef(name, rect)); } -bool SearchTest::ResultsMatch(string const & query, Rules const & rules) +bool SearchTest::ResultsMatch(string const & query, + vector> const & rules) { return ResultsMatch(query, "en" /* locale */, rules); } -bool SearchTest::CategoryMatch(std::string const & query, Rules const & rules, string const & locale) +bool SearchTest::ResultsMatch(string const & query, string const & locale, + vector> const & rules) { - TestSearchRequest request(m_engine, query, locale, Mode::Everywhere, m_viewport); - request.SetCategorial(); - + tests_support::TestSearchRequest request(m_engine, query, locale, Mode::Everywhere, m_viewport); request.Run(); return MatchResults(m_dataSource, rules, request.Results()); } -bool SearchTest::ResultsMatch(string const & query, string const & locale, Rules const & rules) +bool SearchTest::ResultsMatch(string const & query, Mode mode, + vector> const & rules) { - TestSearchRequest request(m_engine, query, locale, Mode::Everywhere, m_viewport); - request.Run(); - return MatchResults(m_dataSource, rules, request.Results()); -} - -bool SearchTest::ResultsMatch(string const & query, Mode mode, Rules const & rules) -{ - TestSearchRequest request(m_engine, query, "en", mode, m_viewport); + tests_support::TestSearchRequest request(m_engine, query, "en", mode, m_viewport); request.Run(); return MatchResults(m_dataSource, rules, request.Results()); } @@ -61,7 +54,7 @@ bool SearchTest::ResultsMatch(vector const & results, Rules cons bool SearchTest::ResultsMatch(SearchParams const & params, Rules const & rules) { - TestSearchRequest request(m_engine, params); + tests_support::TestSearchRequest request(m_engine, params); request.Run(); return ResultsMatch(request.Results(), rules); } @@ -73,26 +66,26 @@ bool SearchTest::ResultMatches(search::Result const & result, Rule const & rule) bool SearchTest::AlternativeMatch(string const & query, vector const & rulesList) { - TestSearchRequest request(m_engine, query, "en", Mode::Everywhere, m_viewport); + tests_support::TestSearchRequest request(m_engine, query, "en", Mode::Everywhere, m_viewport); request.Run(); return tests_support::AlternativeMatch(m_dataSource, rulesList, request.Results()); } size_t SearchTest::GetResultsNumber(string const & query, string const & locale) { - TestSearchRequest request(m_engine, query, locale, Mode::Everywhere, m_viewport); + tests_support::TestSearchRequest request(m_engine, query, locale, Mode::Everywhere, m_viewport); request.Run(); return request.Results().size(); } -unique_ptr SearchTest::MakeRequest(SearchParams params) +unique_ptr SearchTest::MakeRequest(SearchParams params) { - auto request = make_unique(m_engine, params); + auto request = make_unique(m_engine, params); request->Run(); return request; } -unique_ptr SearchTest::MakeRequest( +unique_ptr SearchTest::MakeRequest( string const & query, string const & locale /* = "en" */) { SearchParams params; @@ -102,10 +95,11 @@ unique_ptr SearchTest::MakeRequest( params.m_mode = Mode::Everywhere; params.m_needAddress = true; params.m_suggestsEnabled = false; - params.m_streetSearchRadiusM = TestSearchRequest::kDefaultTestStreetSearchRadiusM; - params.m_villageSearchRadiusM = TestSearchRequest::kDefaultTestVillageSearchRadiusM; + params.m_streetSearchRadiusM = tests_support::TestSearchRequest::kDefaultTestStreetSearchRadiusM; + params.m_villageSearchRadiusM = + tests_support::TestSearchRequest::kDefaultTestVillageSearchRadiusM; - auto request = make_unique(m_engine, params); + auto request = make_unique(m_engine, params); request->Run(); return request; } diff --git a/search/search_tests_support/helpers.hpp b/search/search_tests_support/helpers.hpp index 1dccfccbe7..81754f2631 100644 --- a/search/search_tests_support/helpers.hpp +++ b/search/search_tests_support/helpers.hpp @@ -32,7 +32,6 @@ public: inline void SetViewport(m2::RectD const & viewport) { m_viewport = viewport; } bool ResultsMatch(std::string const & query, Rules const & rules); - bool CategoryMatch(std::string const & query, Rules const & rules, std::string const & locale = "en"); bool ResultsMatch(std::string const & query, std::string const & locale, Rules const & rules); diff --git a/search/search_tests_support/test_search_engine.cpp b/search/search_tests_support/test_search_engine.cpp index f993d88144..616a655534 100644 --- a/search/search_tests_support/test_search_engine.cpp +++ b/search/search_tests_support/test_search_engine.cpp @@ -26,7 +26,7 @@ TestSearchEngine::TestSearchEngine(DataSource & dataSource, Engine::Params const { } -weak_ptr TestSearchEngine::Search(SearchParams const & params) +weak_ptr<::search::ProcessorHandle> TestSearchEngine::Search(::search::SearchParams const & params) { return m_engine.Search(params); } diff --git a/search/search_tests_support/test_search_engine.hpp b/search/search_tests_support/test_search_engine.hpp index aa76886c24..8fbfb3e05d 100644 --- a/search/search_tests_support/test_search_engine.hpp +++ b/search/search_tests_support/test_search_engine.hpp @@ -26,13 +26,13 @@ public: void LoadCitiesBoundaries() { m_engine.LoadCitiesBoundaries(); } - std::weak_ptr Search(SearchParams const & params); + std::weak_ptr Search(search::SearchParams const & params); storage::CountryInfoGetter & GetCountryInfoGetter() { return *m_infoGetter; } private: std::unique_ptr m_infoGetter; - Engine m_engine; + search::Engine m_engine; }; } // namespace tests_support } // namespace search diff --git a/search/search_tests_support/test_search_request.cpp b/search/search_tests_support/test_search_request.cpp index 676a303069..657ca7b99c 100644 --- a/search/search_tests_support/test_search_request.cpp +++ b/search/search_tests_support/test_search_request.cpp @@ -60,7 +60,7 @@ void TestSearchRequest::Run() Wait(); } -TestSearchRequest::TimeDurationT TestSearchRequest::ResponseTime() const +steady_clock::duration TestSearchRequest::ResponseTime() const { lock_guard lock(m_mu); CHECK(m_done, ("This function may be called only when request is processed.")); diff --git a/search/search_tests_support/test_search_request.hpp b/search/search_tests_support/test_search_request.hpp index bf0f9ceb47..d5a92d0b61 100644 --- a/search/search_tests_support/test_search_request.hpp +++ b/search/search_tests_support/test_search_request.hpp @@ -25,15 +25,13 @@ class TestSearchEngine; class TestSearchRequest { public: - static double constexpr kDefaultTestStreetSearchRadiusM = 2e7; - static double constexpr kDefaultTestVillageSearchRadiusM = 2e7; + inline static double const kDefaultTestStreetSearchRadiusM = 2e7; + inline static double const kDefaultTestVillageSearchRadiusM = 2e7; TestSearchRequest(TestSearchEngine & engine, std::string const & query, std::string const & locale, Mode mode, m2::RectD const & viewport); TestSearchRequest(TestSearchEngine & engine, SearchParams const & params); - void SetCategorial() { m_params.m_categorialRequest = true; } - // Initiates the search and waits for it to finish. void Run(); @@ -44,8 +42,7 @@ public: void Wait(); // Call these functions only after call to Wait(). - using TimeDurationT = base::Timer::DurationT; - TimeDurationT ResponseTime() const; + std::chrono::steady_clock::duration ResponseTime() const; std::vector const & Results() const; protected: @@ -70,7 +67,8 @@ protected: bool m_done = false; base::Timer m_timer; - TimeDurationT m_startTime, m_endTime; + std::chrono::steady_clock::duration m_startTime; + std::chrono::steady_clock::duration m_endTime; TestSearchEngine & m_engine; SearchParams m_params; diff --git a/testing/testingmain.cpp b/testing/testingmain.cpp index 8d32817eae..810f78279e 100644 --- a/testing/testingmain.cpp +++ b/testing/testingmain.cpp @@ -277,7 +277,7 @@ int main(int argc, char * argv[]) } g_lastTestOK = true; - uint64_t const elapsed = timer.ElapsedNanoseconds(); + uint64_t const elapsed = timer.ElapsedNano(); LOG(LINFO, ("Test took", elapsed / 1000000, "ms\n")); } diff --git a/tracking/tracking_tests/archival_reporter_tests.cpp b/tracking/tracking_tests/archival_reporter_tests.cpp index 824e7bc29f..ae76c71e91 100644 --- a/tracking/tracking_tests/archival_reporter_tests.cpp +++ b/tracking/tracking_tests/archival_reporter_tests.cpp @@ -66,27 +66,26 @@ UNIT_TEST(PacketCar_OperationsConsistency) location::GpsInfo point = GetStartingPoint(); traffic::SpeedGroup sg = traffic::SpeedGroup::G0; - base::HighResTimer timer; - + base::HighResTimer timerStart; for (size_t i = 0; i < kItemsForDump; ++i) { archive.Add(point, sg); UpdateLocation(point); UpdateSpeedGroup(sg); } - auto const track = archive.Extract(); - LOG(LINFO, ("Duration of dumping", timer.ElapsedMilliseconds(), "ms")); - - timer.Reset(); + base::HighResTimer timerStartSaving; std::string const fileName = "archival_reporter_car.track"; { FileWriter writer(fileName); CHECK(archive.Write(writer), ()); } - LOG(LINFO, ("Duration of serializing", timer.ElapsedMilliseconds(), "ms")); + LOG(LINFO, ("Duration of serializing", + timerStart.ElapsedMillis() - timerStartSaving.ElapsedMillis(), "ms")); + LOG(LINFO, + ("Duration of dumping", timerStart.ElapsedMillis() - timerStartSaving.ElapsedMillis(), "ms")); uint64_t sizeBytes; CHECK(GetPlatform().GetFileSizeByFullPath(fileName, sizeBytes), ());