From 89ccee343eb1046f9c0d18963087350ae7a3cf13 Mon Sep 17 00:00:00 2001 From: "S. Kozyr" Date: Tue, 6 Jun 2023 11:30:34 +0300 Subject: [PATCH 01/17] [iOS] Show all supported coordinates at PlacePage Signed-off-by: S. Kozyr --- .../PlacePageData/Common/PlacePageInfoData.h | 3 +- .../PlacePageData/Common/PlacePageInfoData.mm | 8 +++- .../Common/PlacePagePreviewData.mm | 2 +- .../PlacePageInfoViewController.swift | 38 +++++++++---------- map/place_page_info.cpp | 38 +++++++++++++++++-- map/place_page_info.hpp | 14 ++++++- 6 files changed, 74 insertions(+), 29 deletions(-) diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h index a5da3f0f29..bac5c47163 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h @@ -23,8 +23,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly, nullable) NSString *cuisine; @property(nonatomic, readonly, nullable) NSString *ppOperator; @property(nonatomic, readonly, nullable) NSString *address; -@property(nonatomic, readonly, nullable) NSString *rawCoordinates; -@property(nonatomic, readonly, nullable) NSString *formattedCoordinates; +@property(nonatomic, readonly, nullable) NSArray *coordFormats; @property(nonatomic, readonly, nullable) NSString *wifiAvailable; @property(nonatomic, readonly, nullable) NSString *level; diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm index 22690d7f60..2d4d6adcf0 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm @@ -71,8 +71,12 @@ using namespace osm; }); _address = rawData.GetAddress().empty() ? nil : @(rawData.GetAddress().c_str()); - _rawCoordinates = @(rawData.GetFormattedCoordinate(true).c_str()); - _formattedCoordinates = @(rawData.GetFormattedCoordinate(false).c_str()); + _coordFormats = @[@(rawData.GetFormattedCoordinate(place_page::CoordinatesFormat::LatLonDMS).c_str()), + @(rawData.GetFormattedCoordinate(place_page::CoordinatesFormat::LatLonDecimal).c_str()), + @(rawData.GetFormattedCoordinate(place_page::CoordinatesFormat::OLCFull).c_str()), + @(rawData.GetFormattedCoordinate(place_page::CoordinatesFormat::OSMLink).c_str()), + @(rawData.GetFormattedCoordinate(place_page::CoordinatesFormat::UTM).c_str()), + @(rawData.GetFormattedCoordinate(place_page::CoordinatesFormat::MGRS).c_str())]; } return self; } diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.mm b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.mm index bce287318d..6e12561cb0 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.mm +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.mm @@ -91,7 +91,7 @@ static PlacePageDataHotelType convertHotelType(std::optional 0; diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift index 0120536276..36f3153d16 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift @@ -64,7 +64,7 @@ protocol PlacePageInfoViewControllerDelegate: AnyObject { class PlacePageInfoViewController: UIViewController { private struct Const { - static let coordinatesKey = "PlacePageInfoViewController_coordinatesKey" + static let coordFormatIdKey = "PlacePageInfoViewController_coordFormatIdKey" } private typealias TapHandler = InfoItemViewController.TapHandler private typealias Style = InfoItemViewController.Style @@ -95,15 +95,15 @@ class PlacePageInfoViewController: UIViewController { var placePageInfoData: PlacePageInfoData! weak var delegate: PlacePageInfoViewControllerDelegate? - var showFormattedCoordinates: Bool { + var coordinatesFormatId: Int { get { - UserDefaults.standard.bool(forKey: Const.coordinatesKey) + UserDefaults.standard.integer(forKey: Const.coordFormatIdKey) } set { - UserDefaults.standard.set(newValue, forKey: Const.coordinatesKey) + UserDefaults.standard.set(newValue, forKey: Const.coordFormatIdKey) } } - + override func viewDidLoad() { super.viewDidLoad() @@ -202,24 +202,24 @@ class PlacePageInfoViewController: UIViewController { addressView?.canShowMenu = true } - if let formattedCoordinates = placePageInfoData.formattedCoordinates, - let rawCoordinates = placePageInfoData.rawCoordinates { - let coordinates = showFormattedCoordinates ? formattedCoordinates : rawCoordinates - coordinatesView = createInfoItem(coordinates, icon: UIImage(named: "ic_placepage_coordinate")) { + var formatId = self.coordinatesFormatId + if let coordFormats = self.placePageInfoData.coordFormats as? Array { + if formatId >= coordFormats.count { + formatId = 0 + } + + coordinatesView = createInfoItem(coordFormats[formatId], icon: UIImage(named: "ic_placepage_coordinate")) { [unowned self] in - self.showFormattedCoordinates = !self.showFormattedCoordinates - let coordinates = self.showFormattedCoordinates ? formattedCoordinates : rawCoordinates + let formatId = (self.coordinatesFormatId + 1) % coordFormats.count + self.coordinatesFormatId = formatId + let coordinates:String = coordFormats[formatId] self.coordinatesView?.infoLabel.text = coordinates } - } else if let formattedCoordinates = placePageInfoData.formattedCoordinates { - coordinatesView = createInfoItem(formattedCoordinates, icon: UIImage(named: "ic_placepage_coordinate")) - } else if let rawCoordinates = placePageInfoData.rawCoordinates { - coordinatesView = createInfoItem(rawCoordinates, icon: UIImage(named: "ic_placepage_coordinate")) - } - coordinatesView?.accessoryImage.image = UIImage(named: "ic_placepage_change") - coordinatesView?.accessoryImage.isHidden = false - coordinatesView?.canShowMenu = true + coordinatesView?.accessoryImage.image = UIImage(named: "ic_placepage_change") + coordinatesView?.accessoryImage.isHidden = false + coordinatesView?.canShowMenu = true + } } // MARK: private diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp index 4491bb550a..d185e914ce 100644 --- a/map/place_page_info.cpp +++ b/map/place_page_info.cpp @@ -11,12 +11,14 @@ #include "indexer/feature_utils.hpp" #include "indexer/road_shields_parser.hpp" +#include "platform/localization.hpp" #include "platform/measurement_utils.hpp" #include "platform/preferred_languages.hpp" -#include "platform/localization.hpp" #include "base/assert.hpp" +#include "3party/open-location-code/openlocationcode.h" + #include namespace place_page @@ -284,11 +286,39 @@ std::string Info::FormatStars() const return stars; } -std::string Info::GetFormattedCoordinate(bool isDMS) const +std::string Info::GetFormattedCoordinate(CoordinatesFormat coordsFormat) const { auto const & ll = GetLatLon(); - return isDMS ? measurement_utils::FormatLatLon(ll.m_lat, ll.m_lon, true) - : measurement_utils::FormatLatLonAsDMS(ll.m_lat, ll.m_lon, false, 2); + auto const lat = ll.m_lat; + auto const lon = ll.m_lon; + switch (coordsFormat) + { + default: + case CoordinatesFormat::LatLonDMS: // DMS, comma separated + return measurement_utils::FormatLatLonAsDMS(lat, lon, false /*withComma*/, 2); + case CoordinatesFormat::LatLonDecimal: // Decimal, comma separated + return measurement_utils::FormatLatLon(lat, lon, true /* withComma */); + case CoordinatesFormat::OLCFull: // Open location code, long format + return openlocationcode::Encode({lat, lon}); + case CoordinatesFormat::OSMLink: // Link to osm.org + return measurement_utils::FormatOsmLink(lat, lon, 14); + case CoordinatesFormat::UTM: // Universal Transverse Mercator + { + std::string utmCoords = utm_mgrs_utils::FormatUTM(lat, lon); + if (utmCoords.empty()) + return "UTM: N/A"; + else + return "UTM: " + utmCoords; + } + case CoordinatesFormat::MGRS: // Military Grid Reference System + { + std::string mgrsCoords = utm_mgrs_utils::FormatMGRS(lat, lon, 5); + if (mgrsCoords.empty()) + return "MGRS: N/A"; + else + return "MGRS: " + mgrsCoords; + } + } } void Info::SetRoadType(RoadWarningMarkType type, std::string const & localizedType, std::string const & distance) diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp index 576ea588fe..232cad2061 100644 --- a/map/place_page_info.hpp +++ b/map/place_page_info.hpp @@ -16,6 +16,8 @@ #include "geometry/point2d.hpp" +#include "platform/utm_mgrs_utils.hpp" + #include #include #include @@ -32,6 +34,16 @@ enum class OpeningMode Full }; +enum class CoordinatesFormat +{ + LatLonDMS = 0, // DMS, comma separated + LatLonDecimal, // Decimal, comma separated + OLCFull, // Open location code, long format + OSMLink, // Link to osm.org + UTM, // Universal Transverse Mercator + MGRS // Military Grid Reference System +}; + struct BuildInfo { enum class Source : uint8_t @@ -129,7 +141,7 @@ public: std::string const & GetAddress() const { return m_uiAddress; } std::string const & GetDescription() const { return m_description; } /// @returns coordinate in DMS format if isDMS is true - std::string GetFormattedCoordinate(bool isDMS) const; + std::string GetFormattedCoordinate(CoordinatesFormat format) const; /// UI setters void SetCustomName(std::string const & name); -- 2.45.3 From 7c0b0c5af4498e3a82abb45c3bbd59e9e16453a6 Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Thu, 8 Jun 2023 19:41:00 -0300 Subject: [PATCH 02/17] [qt] Migrated on Qt6. Signed-off-by: Viktor Govako --- .github/workflows/linux-check.yaml | 12 ++++++++---- .github/workflows/macos-check.yaml | 2 +- CMakeLists.txt | 14 +++----------- cmake/OmimHelpers.cmake | 2 +- docs/INSTALL.md | 13 ++++++++----- drape/drape_tests/CMakeLists.txt | 2 -- .../openlr_assessment_tool/traffic_mode.cpp | 4 ++-- platform/CMakeLists.txt | 4 ++-- qt/CMakeLists.txt | 2 +- qt/build_style/build_common.cpp | 17 ++++++++++------- qt/build_style/build_common.h | 1 - qt/draw_widget.cpp | 1 - qt/mainwindow.cpp | 3 +-- qt/popup_menu_holder.hpp | 2 +- qt/qt_common/CMakeLists.txt | 8 +++++--- qt/qt_common/map_widget.cpp | 17 +++++++++++------ qt/qt_common/map_widget.hpp | 3 ++- qt/qt_common/qtoglcontext.hpp | 3 ++- qt/qt_common/qtoglcontextfactory.hpp | 1 - qt/screenshoter.hpp | 2 +- qt/search_panel.cpp | 6 +++--- qt_tstfrm/CMakeLists.txt | 4 ++-- .../assessment_tool/feature_info_dialog.cpp | 2 +- .../assessment_tool/main_view.cpp | 1 - .../assessment_tool/samples_view.cpp | 2 +- skin_generator/CMakeLists.txt | 6 +++--- skin_generator/generator.cpp | 4 ++-- skin_generator/generator.hpp | 2 -- skin_generator/main.cpp | 3 --- 29 files changed, 71 insertions(+), 72 deletions(-) diff --git a/.github/workflows/linux-check.yaml b/.github/workflows/linux-check.yaml index bc47cd7b39..18cc9584ec 100644 --- a/.github/workflows/linux-check.yaml +++ b/.github/workflows/linux-check.yaml @@ -54,8 +54,10 @@ jobs: sudo apt update -y sudo apt install -y \ ninja-build \ - qtbase5-dev \ - libqt5svg5-dev + libgl1-mesa-dev \ + libglvnd-dev \ + qt6-base-dev \ + libqt6svg6-dev - name: Configure shell: bash @@ -105,8 +107,10 @@ jobs: g++-12 \ gcc-12 \ ninja-build \ - qtbase5-dev \ - libqt5svg5-dev + libgl1-mesa-dev \ + libglvnd-dev \ + qt6-base-dev \ + libqt6svg6-dev - name: Configure shell: bash diff --git a/.github/workflows/macos-check.yaml b/.github/workflows/macos-check.yaml index cdc158389b..9fb137b210 100644 --- a/.github/workflows/macos-check.yaml +++ b/.github/workflows/macos-check.yaml @@ -49,7 +49,7 @@ jobs: - name: Install build tools and dependencies shell: bash run: | - brew install ninja qt@5 + brew install ninja qt@6 - name: Configure shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 34978954ce..67608fc50c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,18 +238,10 @@ if (NOT PLATFORM_IPHONE AND NOT PLATFORM_ANDROID) list(APPEND qt_components Widgets) endif() if (NOT SKIP_DESKTOP) - list(APPEND qt_components Gui Xml Svg) - endif() - if (DEFINED ENV{HOMEBREW_PREFIX}) - set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) - else() - set(HOMEBREW_PREFIX /opt/homebrew) - endif() - # PATHS are hard-coded hints where to look for qt5 in addition to other places. - find_package(Qt5 COMPONENTS REQUIRED ${qt_components} PATHS $ENV{QT_PATH} ${HOMEBREW_PREFIX}/opt/qt@5 /usr/local/opt/qt@5 /usr/lib/x86_64-linux-gnu/qt5) - if (Qt5_VERSION VERSION_LESS 5.5.0) - message(FATAL_ERROR "Minimum supported Qt5 version is 5.5") + list(APPEND qt_components Gui Xml Svg OpenGL OpenGLWidgets) endif() + # PATHS are hard-coded hints where to look for qt6 in addition to other places. + find_package(Qt6 COMPONENTS REQUIRED ${qt_components} PATHS $ENV{QT_PATH} /opt/homebrew/opt/qt@6 /usr/local/opt/qt@6 /usr/lib/x86_64-linux-gnu/qt6) endif() find_library(LIBZ NAMES z) diff --git a/cmake/OmimHelpers.cmake b/cmake/OmimHelpers.cmake index 91af2e6f6b..bc2f535c69 100644 --- a/cmake/OmimHelpers.cmake +++ b/cmake/OmimHelpers.cmake @@ -114,7 +114,7 @@ endfunction() function(omim_add_test_with_qt_event_loop executable) omim_add_test_impl(NO ${executable} ${ARGN}) target_compile_definitions(${executable} PRIVATE OMIM_UNIT_TEST_WITH_QT_EVENT_LOOP) - target_link_libraries(${executable} Qt5::Widgets) + target_link_libraries(${executable} Qt6::Widgets) endfunction() function(omim_add_test_no_platform_init executable) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index a2c5612cc4..951bdeff70 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -97,12 +97,13 @@ sudo apt update && sudo apt install -y \ clang \ ninja-build \ python3 \ - qtbase5-dev \ + qt6-base-dev \ libc++-dev \ libfreetype-dev \ - libglu1-mesa-dev \ + libglvnd-dev \ + libgl1-mesa-dev \ libicu-dev \ - libqt5svg5-dev \ + libqt6svg6-dev \ libsqlite3-dev \ zlib1g-dev ``` @@ -129,8 +130,10 @@ sudo dnf install -y \ freetype-devel \ libicu-devel \ libstdc++-devel \ - qt5-qtbase-devel \ - qt5-qtsvg-devel \ + libgl1-mesa-devel \ + libglvnd-devel \ + qt6-qtbase-devel \ + qt6-qtsvg-devel \ sqlite-devel ``` diff --git a/drape/drape_tests/CMakeLists.txt b/drape/drape_tests/CMakeLists.txt index d93f200b32..377426e8cd 100644 --- a/drape/drape_tests/CMakeLists.txt +++ b/drape/drape_tests/CMakeLists.txt @@ -40,6 +40,4 @@ target_link_libraries(${PROJECT_NAME} indexer # For StyleReader in static_texture_tests drape gmock - gtest - Qt5::Core ) diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp index 9020535baa..0cec12a32a 100644 --- a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp @@ -273,8 +273,8 @@ QVariant TrafficMode::headerData(int section, Qt::Orientation orientation, void TrafficMode::OnItemSelected(QItemSelection const & selected, QItemSelection const &) { - CHECK(!selected.empty(), ("The selection should not be empty. RTFM for qt5.")); - CHECK(!m_segments.empty(), ("No segments are loaded, can't select.")); + ASSERT(!selected.empty(), ()); + ASSERT(!m_segments.empty(), ()); auto const row = selected.front().top(); diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt index 20284baec6..06cc41ecb3 100644 --- a/platform/CMakeLists.txt +++ b/platform/CMakeLists.txt @@ -170,8 +170,8 @@ endif() target_link_libraries(${PROJECT_NAME} geometry # mercator::YToLat coding - $<$:Qt5::Core> - $<$:Qt5::Network> + $<$:Qt6::Core> + $<$:Qt6::Network> $<$:-framework\ Foundation -framework\ SystemConfiguration -framework\ CoreLocation -framework\ CFNetwork> ) diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 194371f976..d9a44d1f6c 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -1,6 +1,6 @@ project(desktop) -QT5_ADD_RESOURCES(RES_SOURCES res/resources.qrc) +QT6_ADD_RESOURCES(RES_SOURCES res/resources.qrc) set(SRC about.cpp diff --git a/qt/build_style/build_common.cpp b/qt/build_style/build_common.cpp index 4dd5db1a72..8ef0ad88a5 100644 --- a/qt/build_style/build_common.cpp +++ b/qt/build_style/build_common.cpp @@ -2,15 +2,17 @@ #include "platform/platform.hpp" +#include "base/file_name_utils.hpp" + #include #include #include #include #include -#include #include #include // std::quoted +#include #include QString ExecProcess(QString const & program, std::initializer_list args, QProcessEnvironment const * env) @@ -23,7 +25,7 @@ QString ExecProcess(QString const & program, std::initializer_list args QProcess p; if (nullptr != env) p.setProcessEnvironment(*env); - + p.start(program, qargs, QIODevice::ReadOnly); p.waitForFinished(-1); @@ -111,11 +113,12 @@ QString GetExternalPath(QString const & name, QString const & primaryPath, // Special case for looking for in application folder. if (!QFileInfo::exists(path) && secondaryPath.isEmpty()) { - QString const appPath = QCoreApplication::applicationDirPath(); - QRegExp rx("(/[^/]*\\.app)", Qt::CaseInsensitive); - int i = rx.indexIn(appPath); - if (i >= 0) - path = JoinPathQt({appPath.left(i), name}); + std::string const appPath = QCoreApplication::applicationDirPath().toStdString(); + + std::regex re("(/[^/]*\\.app)"); + std::smatch m; + if (std::regex_search(appPath, m, re) && m.size() > 0) + path.fromStdString(base::JoinPath(m[0], name.toStdString())); } return path; } diff --git a/qt/build_style/build_common.h b/qt/build_style/build_common.h index 474d3c3df2..a73beef8e3 100644 --- a/qt/build_style/build_common.h +++ b/qt/build_style/build_common.h @@ -6,7 +6,6 @@ #include #include -class QStringList; class QProcessEnvironment; // Returns stdout output of the program, throws std::runtime_error in case of non-zero exit code. diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index d3d245368d..42c16e44ea 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index f93ffbcdd2..e651a857ea 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -35,7 +35,6 @@ #endif // BUILD_DESIGNER #include -#include #include #include #include @@ -208,7 +207,7 @@ MainWindow::MainWindow(Framework & framework, #endif // NO_DOWNLOADER m_pDrawWidget->UpdateAfterSettingsChanged(); - + RoutingSettings::LoadSession(m_pDrawWidget->GetFramework()); } diff --git a/qt/popup_menu_holder.hpp b/qt/popup_menu_holder.hpp index f9155f1429..7ef29b7e5d 100644 --- a/qt/popup_menu_holder.hpp +++ b/qt/popup_menu_holder.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/qt/qt_common/CMakeLists.txt b/qt/qt_common/CMakeLists.txt index 5af5189912..ba4d9f199a 100644 --- a/qt/qt_common/CMakeLists.txt +++ b/qt/qt_common/CMakeLists.txt @@ -1,6 +1,6 @@ project(qt_common) -QT5_ADD_RESOURCES(RESOURCES res/resources_common.qrc) +QT6_ADD_RESOURCES(RESOURCES res/resources_common.qrc) set_property(SOURCE qrc_resources_common.cpp PROPERTY SKIP_AUTOGEN ON) @@ -33,6 +33,8 @@ target_compile_options(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} map - Qt5::Gui - Qt5::Widgets + Qt6::Gui + Qt6::Widgets + Qt6::OpenGL + Qt6::OpenGLWidgets ) diff --git a/qt/qt_common/map_widget.cpp b/qt/qt_common/map_widget.cpp index bebba3c812..bbe4b97136 100644 --- a/qt/qt_common/map_widget.cpp +++ b/qt/qt_common/map_widget.cpp @@ -15,15 +15,15 @@ #include #include +#include +#include +#include + #include #include -#include -#include +#include #include -#include -#include - namespace qt { namespace common @@ -506,7 +506,12 @@ void MapWidget::wheelEvent(QWheelEvent * e) return; QOpenGLWidget::wheelEvent(e); - m_framework.Scale(exp(e->delta() / 360.0), m2::PointD(L2D(e->x()), L2D(e->y())), false); + + QPointF const pos = e->position(); + + // https://doc-snapshots.qt.io/qt6-dev/qwheelevent.html#angleDelta, angleDelta() returns in eighths of a degree. + /// @todo Here you can tune the speed of zooming. + m_framework.Scale(exp(e->angleDelta().y() / 3.0 / 360.0), m2::PointD(L2D(pos.x()), L2D(pos.y())), false); } search::ReverseGeocoder::Address GetFeatureAddressInfo(Framework const & framework, diff --git a/qt/qt_common/map_widget.hpp b/qt/qt_common/map_widget.hpp index 537c71dfbd..c2ffd32c33 100644 --- a/qt/qt_common/map_widget.hpp +++ b/qt/qt_common/map_widget.hpp @@ -10,8 +10,9 @@ #include "indexer/feature.hpp" +#include + #include -#include #include diff --git a/qt/qt_common/qtoglcontext.hpp b/qt/qt_common/qtoglcontext.hpp index c0deeb9ac5..4186dc252b 100644 --- a/qt/qt_common/qtoglcontext.hpp +++ b/qt/qt_common/qtoglcontext.hpp @@ -2,8 +2,9 @@ #include "drape/oglcontext.hpp" +#include + #include -#include #include #include diff --git a/qt/qt_common/qtoglcontextfactory.hpp b/qt/qt_common/qtoglcontextfactory.hpp index 7c82095689..d672f09561 100644 --- a/qt/qt_common/qtoglcontextfactory.hpp +++ b/qt/qt_common/qtoglcontextfactory.hpp @@ -4,7 +4,6 @@ #include "qt/qt_common/qtoglcontext.hpp" #include -#include #include diff --git a/qt/screenshoter.hpp b/qt/screenshoter.hpp index 4a9201ac76..d61a23058c 100644 --- a/qt/screenshoter.hpp +++ b/qt/screenshoter.hpp @@ -6,7 +6,7 @@ #include "geometry/rect2d.hpp" -#include +#include #include #include diff --git a/qt/search_panel.cpp b/qt/search_panel.cpp index 0bbb898003..0675766b29 100644 --- a/qt/search_panel.cpp +++ b/qt/search_panel.cpp @@ -141,14 +141,14 @@ void SearchPanel::OnEverywhereSearchResults(uint64_t timestamp, search::Results for (size_t r = 0; r < res.GetHighlightRangesCount(); ++r) { std::pair const & range = res.GetHighlightRange(r); - strHigh.append(name.midRef(pos, range.first - pos)); + strHigh.append(name.mid(pos, range.first - pos)); strHigh.append(""); - strHigh.append(name.midRef(range.first, range.second)); + strHigh.append(name.mid(range.first, range.second)); strHigh.append(""); pos = range.first + range.second; } - strHigh.append(name.midRef(pos)); + strHigh.append(name.mid(pos)); int const rowCount = m_pTable->rowCount(); m_pTable->insertRow(rowCount); diff --git a/qt_tstfrm/CMakeLists.txt b/qt_tstfrm/CMakeLists.txt index 8a773abe65..3992c6c4d4 100644 --- a/qt_tstfrm/CMakeLists.txt +++ b/qt_tstfrm/CMakeLists.txt @@ -14,6 +14,6 @@ target_compile_options(${PROJECT_NAME} ) target_link_libraries(${PROJECT_NAME} - Qt5::Core - Qt5::Widgets + Qt6::Core + Qt6::Widgets ) diff --git a/search/search_quality/assessment_tool/feature_info_dialog.cpp b/search/search_quality/assessment_tool/feature_info_dialog.cpp index b7f5f501cd..579580fddf 100644 --- a/search/search_quality/assessment_tool/feature_info_dialog.cpp +++ b/search/search_quality/assessment_tool/feature_info_dialog.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include diff --git a/search/search_quality/assessment_tool/main_view.cpp b/search/search_quality/assessment_tool/main_view.cpp index 6f399246c4..e7de4c0d52 100644 --- a/search/search_quality/assessment_tool/main_view.cpp +++ b/search/search_quality/assessment_tool/main_view.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/search/search_quality/assessment_tool/samples_view.cpp b/search/search_quality/assessment_tool/samples_view.cpp index 8f4f3865d1..9194475794 100644 --- a/search/search_quality/assessment_tool/samples_view.cpp +++ b/search/search_quality/assessment_tool/samples_view.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/skin_generator/CMakeLists.txt b/skin_generator/CMakeLists.txt index 2b04dde9e2..adab22765d 100644 --- a/skin_generator/CMakeLists.txt +++ b/skin_generator/CMakeLists.txt @@ -11,7 +11,7 @@ omim_add_executable(${PROJECT_NAME} ${SRC}) target_link_libraries(${PROJECT_NAME} geometry gflags::gflags - Qt5::Xml - Qt5::Svg - Qt5::Widgets + Qt6::Xml + Qt6::Svg + Qt6::Widgets ) diff --git a/skin_generator/generator.cpp b/skin_generator/generator.cpp index dd65107aeb..b1bb25278c 100644 --- a/skin_generator/generator.cpp +++ b/skin_generator/generator.cpp @@ -241,8 +241,8 @@ bool SkinGenerator::WriteToFileNewStyle(std::string const &skinName) if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate)) return false; QTextStream ts(&file); - ts.setCodec("UTF-8"); + ts.setEncoding(QStringConverter::Utf8); ts << doc.toString(); return true; } -} +} // namespace tools diff --git a/skin_generator/generator.hpp b/skin_generator/generator.hpp index c8c328c79c..8bcd370f93 100644 --- a/skin_generator/generator.hpp +++ b/skin_generator/generator.hpp @@ -12,8 +12,6 @@ #include #include #include -#include -#include #include #include diff --git a/skin_generator/main.cpp b/skin_generator/main.cpp index 4e0b7d6361..89f0c1e2dc 100644 --- a/skin_generator/main.cpp +++ b/skin_generator/main.cpp @@ -8,9 +8,6 @@ #include #include -#include -#include - #include DEFINE_string(fontFileName, "../../data/01_dejavusans.ttf", "path to TrueType font file"); -- 2.45.3 From ab06075bfbb665efa9e2d22b247d5ed25b962ff2 Mon Sep 17 00:00:00 2001 From: endim8 Date: Fri, 9 Jun 2023 04:20:38 +0100 Subject: [PATCH 03/17] Update INSTALL.md, some missing qt6 strings Signed-off-by: Harry Bond --- docs/INSTALL.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 951bdeff70..6f99e547ee 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -85,7 +85,7 @@ You need a Linux or a Mac machine to build a desktop version of Organic Maps. [W Ensure that you have at least 20GB of free space. -Install Cmake (**3.22.1** minimum), Boost, Qt 5 and other dependencies. +Install Cmake (**3.22.1** minimum), Boost, Qt 6 and other dependencies. Installing *ccache* can speed up active development. @@ -140,7 +140,7 @@ sudo dnf install -y \ _macOS:_ ```bash -brew install cmake ninja qt@5 +brew install cmake ninja qt@6 ``` ### Windows @@ -148,7 +148,7 @@ brew install cmake ninja qt@5 We haven't compiled Organic Maps on Windows *natively* in a long time, though it is possible. Some files should be updated. There is a work in progress on [windows](https://github.com/organicmaps/organicmaps/tree/windows) branch. Please contribute if you have time. -You'll need to have python3, cmake, ninja, and QT5 in the PATH, and Visual Studio 2022 or Visual Studio 2022 Build Tools installed. Use [Visual Studio Developer Command Prompt](https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022) or generate Visual Studio project files with CMake to build the project. +You'll need to have python3, cmake, ninja, and QT6 in the PATH, and Visual Studio 2022 or Visual Studio 2022 Build Tools installed. Use [Visual Studio Developer Command Prompt](https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022) or generate Visual Studio project files with CMake to build the project. However, it is possible to use the WSL (Windows Subsystem for Linux) to run GUI applications. -- 2.45.3 From b269834946b2c0674e6c28f6be97849e0d01a0d5 Mon Sep 17 00:00:00 2001 From: vng Date: Sun, 28 Feb 2021 12:56:12 +0300 Subject: [PATCH 04/17] [drape] Do not draw 3D area with more than 10K vertexes. Signed-off-by: vng --- drape_frontend/area_shape.cpp | 5 ++++- drape_frontend/backend_renderer.cpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drape_frontend/area_shape.cpp b/drape_frontend/area_shape.cpp index 46c94e5cc1..ff702c0a72 100644 --- a/drape_frontend/area_shape.cpp +++ b/drape_frontend/area_shape.cpp @@ -41,7 +41,10 @@ void AreaShape::Draw(ref_ptr context, ref_ptr } if (m_params.m_is3D) - DrawArea3D(context, batcher, colorUv, outlineUv, region.GetTexture()); + { + if (m_vertexes.size() < 10000) + DrawArea3D(context, batcher, colorUv, outlineUv, region.GetTexture()); + } else if (m_params.m_hatching) DrawHatchingArea(context, batcher, colorUv, region.GetTexture(), textures->GetHatchingTexture()); else diff --git a/drape_frontend/backend_renderer.cpp b/drape_frontend/backend_renderer.cpp index 43216af1a9..6f127ce92b 100644 --- a/drape_frontend/backend_renderer.cpp +++ b/drape_frontend/backend_renderer.cpp @@ -695,7 +695,9 @@ void BackendRenderer::RenderFrame() void BackendRenderer::InitContextDependentResources() { + // Increase this value for big features. uint32_t constexpr kBatchSize = 5000; + m_batchersPool = make_unique_dp>(kReadingThreadsCount, std::bind(&BackendRenderer::FlushGeometry, this, _1, _2, _3), kBatchSize, kBatchSize); -- 2.45.3 From 2df3cb338df447c15cc86b32826b900956b4702c Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Sun, 11 Jun 2023 10:40:21 -0300 Subject: [PATCH 05/17] [routing] Service speed factor <= Tertiary speed factor. Signed-off-by: Viktor Govako --- routing/routing_integration_tests/turn_test.cpp | 14 ++++++++++++++ routing_common/car_model_coefs.hpp | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/routing/routing_integration_tests/turn_test.cpp b/routing/routing_integration_tests/turn_test.cpp index e154b210ae..a8dc973243 100644 --- a/routing/routing_integration_tests/turn_test.cpp +++ b/routing/routing_integration_tests/turn_test.cpp @@ -1296,6 +1296,20 @@ UNIT_TEST(Cyprus_A1_A5_TurnTestNextRoad) TEST_EQUAL(ri.m_destination_ref, "A5", ()); } +UNIT_TEST(Zurich_UseMainTurn) +{ + TRouteResult const routeResult = + integration::CalculateRoute(integration::GetVehicleComponents(VehicleType::Car), + mercator::FromLatLon(47.364832, 8.5656975), {0., 0.}, + mercator::FromLatLon(47.3640678, 8.56567312)); + + Route const & route = *routeResult.first; + RouterResultCode const result = routeResult.second; + TEST_EQUAL(result, RouterResultCode::NoError, ()); + integration::TestTurnCount(route, 1); + integration::TestRouteLength(route, 135.573); +} + namespace { template void TestNoTurns(ContT const & cont) diff --git a/routing_common/car_model_coefs.hpp b/routing_common/car_model_coefs.hpp index 6f4f3c1e1e..04b85014e6 100644 --- a/routing_common/car_model_coefs.hpp +++ b/routing_common/car_model_coefs.hpp @@ -35,8 +35,8 @@ HighwayBasedFactors const kHighwayBasedFactors = { // By VNG: Changed 0.3 -> 0.95 for Road and 0.3 -> 1.0 for Track. // They are already have very small speeds (10, 5 respectively). // There are no (99%) traffic lights or pedestrian crossings on this kind of roads. - {HighwayType::HighwayService, InOutCityFactor(0.80)}, - {HighwayType::HighwayRoad, InOutCityFactor(0.95)}, + {HighwayType::HighwayService, InOutCityFactor(0.70)}, + {HighwayType::HighwayRoad, InOutCityFactor(0.90)}, {HighwayType::HighwayTrack, InOutCityFactor(1.0)}, {HighwayType::ManMadePier, InOutCityFactor(0.90)}, -- 2.45.3 From 1731e17e8d73b177d08269f0312886801e7d3d2b Mon Sep 17 00:00:00 2001 From: Keith Conger Date: Mon, 12 Jun 2023 15:20:36 -0600 Subject: [PATCH 06/17] Fix backurl API argument for all scenarios Signed-off-by: Keith Conger --- android/src/app/organicmaps/intent/Factory.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/android/src/app/organicmaps/intent/Factory.java b/android/src/app/organicmaps/intent/Factory.java index 5da9d96b59..4352677c45 100644 --- a/android/src/app/organicmaps/intent/Factory.java +++ b/android/src/app/organicmaps/intent/Factory.java @@ -202,13 +202,6 @@ public class Factory { final ParsingResult result = Framework.nativeParseAndSetApiUrl(getUrl()); - // TODO: Kernel recognizes "mapsme://", "mwm://" and "mapswithme://" schemas only!!! - if (result.getUrlType() == ParsingResult.TYPE_INCORRECT) - return Map.showMapForUrl(getUrl()); - - if (!result.isSuccess()) - return false; - final Uri uri = Uri.parse(getUrl()); final String backUrl = uri.getQueryParameter("backurl"); if (!TextUtils.isEmpty(backUrl)) @@ -217,6 +210,13 @@ public class Factory if (intent != null) intent.putExtra(MwmActivity.EXTRA_BACK_URL, backUrl); } + + // TODO: Kernel recognizes "mapsme://", "mwm://" and "mapswithme://" schemas only!!! + if (result.getUrlType() == ParsingResult.TYPE_INCORRECT) + return Map.showMapForUrl(getUrl()); + + if (!result.isSuccess()) + return false; switch (result.getUrlType()) { -- 2.45.3 From 56570f9f6516c6bff28a5b8cdc876351aaa5a057 Mon Sep 17 00:00:00 2001 From: Keith Conger Date: Mon, 12 Jun 2023 15:21:34 -0600 Subject: [PATCH 07/17] Fix backurl API argument for all scenarios Signed-off-by: Keith Conger --- android/src/app/organicmaps/intent/Factory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/app/organicmaps/intent/Factory.java b/android/src/app/organicmaps/intent/Factory.java index 4352677c45..85443ed6a5 100644 --- a/android/src/app/organicmaps/intent/Factory.java +++ b/android/src/app/organicmaps/intent/Factory.java @@ -210,7 +210,7 @@ public class Factory if (intent != null) intent.putExtra(MwmActivity.EXTRA_BACK_URL, backUrl); } - + // TODO: Kernel recognizes "mapsme://", "mwm://" and "mapswithme://" schemas only!!! if (result.getUrlType() == ParsingResult.TYPE_INCORRECT) return Map.showMapForUrl(getUrl()); -- 2.45.3 From fe8b552d36ef47b03564a83fa28339530d417b6b Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Sun, 4 Jun 2023 18:18:36 -0300 Subject: [PATCH 08/17] [search] Fixed airport search with empty names. Signed-off-by: Viktor Govako --- search/ranker.cpp | 4 +-- .../search_quality_tests/real_mwm_tests.cpp | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/search/ranker.cpp b/search/ranker.cpp index f823b9f9d1..cd09b7268e 100644 --- a/search/ranker.cpp +++ b/search/ranker.cpp @@ -374,8 +374,8 @@ public: }, Delimiters()); // Factor is a number of the rest, not common matched tokens in Feature' name. Bigger is worse. - info.m_commonTokensFactor = min(3, count - int(info.m_tokenRanges[info.m_type].Size())); - ASSERT_GREATER_OR_EQUAL(info.m_commonTokensFactor, 0, ()); + // Example when count == 0: UTH airport has empty name, but "ut" is a _common_ token. + info.m_commonTokensFactor = min(3, std::max(0, count - int(info.m_tokenRanges[info.m_type].Size()))); } res.SetRankingInfo(info); diff --git a/search/search_quality/search_quality_tests/real_mwm_tests.cpp b/search/search_quality/search_quality_tests/real_mwm_tests.cpp index b4985d1cdd..7036cacb76 100644 --- a/search/search_quality/search_quality_tests/real_mwm_tests.cpp +++ b/search/search_quality/search_quality_tests/real_mwm_tests.cpp @@ -530,4 +530,33 @@ UNIT_CLASS_TEST(MwmTestsFixture, Generic_Buildings_Rank) TEST_LESS(SortedByDistance(range, center), 1000.0, ()); } } + +UNIT_CLASS_TEST(MwmTestsFixture, UTH_Airport) +{ + auto const aeroportType = classif().GetTypeByPath({"aeroway", "aerodrome", "international"}); + + // Under UTH airport. + ms::LatLon const center(17.3867863, 102.7775625); + SetViewportAndLoadMaps(center); + + // "ut" query is _common_ + auto request = MakeRequest("ut", "en"); + auto const & results = request->Results(); + + bool found = false; + // The first 5 will be cities suggestions. + for (size_t i = 0; i < 10; ++i) + { + auto const & r = results[i]; + if (r.GetResultType() == search::Result::Type::Feature && + EqualClassifType(r.GetFeatureType(), aeroportType)) + { + found = true; + break; + } + } + + TEST(found, (results)); +} + } // namespace real_mwm_tests -- 2.45.3 From 8b018de74dffb50bdc79099176943ec0cc4f2e44 Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Sun, 4 Jun 2023 18:37:21 -0300 Subject: [PATCH 09/17] [search][generator] Do not generate ranks for Transport POIs. Signed-off-by: Viktor Govako --- indexer/caching_rank_table_loader.cpp | 9 +- indexer/caching_rank_table_loader.hpp | 4 +- indexer/indexer_tests/rank_table_test.cpp | 57 +---- indexer/rank_table.cpp | 211 +++--------------- indexer/rank_table.hpp | 4 +- search/dummy_rank_table.cpp | 6 +- .../search_quality_tests/real_mwm_tests.cpp | 17 +- 7 files changed, 50 insertions(+), 258 deletions(-) diff --git a/indexer/caching_rank_table_loader.cpp b/indexer/caching_rank_table_loader.cpp index dbaa3627ba..e540c7a797 100644 --- a/indexer/caching_rank_table_loader.cpp +++ b/indexer/caching_rank_table_loader.cpp @@ -3,14 +3,7 @@ #include "search/dummy_rank_table.hpp" #include "indexer/data_source.hpp" -#include "indexer/feature.hpp" -#include "defines.hpp" - -namespace -{ -uint8_t const kNoRank = 0; -} // namespace CachingRankTableLoader::CachingRankTableLoader(DataSource const & dataSource, std::string const & sectionName) @@ -23,7 +16,7 @@ uint8_t CachingRankTableLoader::Get(FeatureID const & featureId) const auto const handle = m_dataSource.GetMwmHandleById(featureId.m_mwmId); if (!handle.IsAlive()) - return kNoRank; + return search::RankTable::kNoRank; auto it = m_deserializers.find(featureId.m_mwmId); diff --git a/indexer/caching_rank_table_loader.hpp b/indexer/caching_rank_table_loader.hpp index 2e80429ae7..c8dc5d5b40 100644 --- a/indexer/caching_rank_table_loader.hpp +++ b/indexer/caching_rank_table_loader.hpp @@ -6,7 +6,6 @@ #include "base/macros.hpp" -#include #include #include #include @@ -20,13 +19,14 @@ class CachingRankTableLoader public: CachingRankTableLoader(DataSource const & dataSource, std::string const & sectionName); + /// @return 0 if there is no rank for feature. uint8_t Get(FeatureID const & featureId) const; void OnMwmDeregistered(platform::LocalCountryFile const & localFile); private: DataSource const & m_dataSource; std::string const m_sectionName; - mutable std::map const> m_deserializers; + mutable std::map> m_deserializers; DISALLOW_COPY(CachingRankTableLoader); }; diff --git a/indexer/indexer_tests/rank_table_test.cpp b/indexer/indexer_tests/rank_table_test.cpp index 879c33dc86..07a4287011 100644 --- a/indexer/indexer_tests/rank_table_test.cpp +++ b/indexer/indexer_tests/rank_table_test.cpp @@ -85,8 +85,7 @@ UNIT_TEST(RankTableBuilder_EndToEnd) base::CopyFileX(originalMapPath, mapPath); SCOPE_GUARD(cleanup, bind(&FileWriter::DeleteFileX, mapPath)); - platform::LocalCountryFile localFile = - platform::LocalCountryFile::MakeForTesting("minsk-pass-copy"); + auto const localFile = platform::LocalCountryFile::MakeForTesting("minsk-pass-copy"); TEST(localFile.OnDisk(MapFileType::Map), ()); vector ranks; @@ -106,57 +105,3 @@ UNIT_TEST(RankTableBuilder_EndToEnd) TestTable(ranks, mapPath); } - -UNIT_TEST(RankTableBuilder_WrongEndianness) -{ - char const kTestFile[] = "test.mwm"; - SCOPE_GUARD(cleanup, bind(&FileWriter::DeleteFileX, kTestFile)); - - vector ranks = {0, 1, 2, 3, 4}; - { - FilesContainerW wcont(kTestFile); - search::RankTableBuilder::Create(ranks, wcont, SEARCH_RANKS_FILE_TAG); - } - - // Load rank table in host endianness. - unique_ptr table; - { - FilesContainerR rcont(kTestFile); - table = search::RankTable::Load(rcont, SEARCH_RANKS_FILE_TAG); - TEST(table.get(), ()); - TestTable(ranks, *table); - } - - // Serialize rank table in opposite endianness. - { - vector data; - { - MemWriter writer(data); - table->Serialize(writer, false /* preserveHostEndianness */); - } - - FilesContainerW wcont(kTestFile); - wcont.Write(data, SEARCH_RANKS_FILE_TAG); - } - - // Try to load rank table from opposite endianness. - { - FilesContainerR rcont(kTestFile); - auto table = search::RankTable::Load(rcont, SEARCH_RANKS_FILE_TAG); - TEST(table.get(), ()); - TestTable(ranks, *table); - } - - // It's impossible to map rank table from opposite endianness. - { - FilesMappingContainer mcont(kTestFile); - auto table = search::RankTable::Load(mcont, SEARCH_RANKS_FILE_TAG); - TEST(!table.get(), ()); - } - - // Try to re-create rank table in test file. - TEST(search::SearchRankTableBuilder::CreateIfNotExists(kTestFile), ()); - - // Try to load and map rank table - both methods should work now. - TestTable(ranks, kTestFile); -} diff --git a/indexer/rank_table.cpp b/indexer/rank_table.cpp index d7511fbf6e..348e05d00a 100644 --- a/indexer/rank_table.cpp +++ b/indexer/rank_table.cpp @@ -1,17 +1,10 @@ #include "indexer/rank_table.hpp" -#include "indexer/classificator.hpp" #include "indexer/data_header.hpp" -#include "indexer/feature_algo.hpp" #include "indexer/feature_impl.hpp" -#include "indexer/feature_utils.hpp" #include "indexer/features_vector.hpp" #include "indexer/ftypes_matcher.hpp" -#include "platform/local_country_file.hpp" -#include "platform/local_country_file_utils.hpp" - -#include "coding/endianness.hpp" #include "coding/files_container.hpp" #include "coding/file_writer.hpp" #include "coding/memory_region.hpp" @@ -20,54 +13,30 @@ #include "coding/succinct_mapper.hpp" #include "coding/writer.hpp" -#include "base/assert.hpp" +#include "base/exception.hpp" #include "base/logging.hpp" -#include "base/macros.hpp" -#include "base/math.hpp" #include -#include #include -#include #include "defines.hpp" -using namespace std; namespace search { +using namespace std; + namespace { -uint64_t const kVersionOffset = 0; -uint64_t const kFlagsOffset = 1; -uint64_t const kHeaderSize = 8; - -enum class CheckResult -{ - CorruptedHeader, - EndiannessMismatch, - EndiannessMatch -}; - -template -CheckResult CheckEndianness(TReader && reader) -{ - if (reader.Size() < kHeaderSize) - return CheckResult::CorruptedHeader; - uint8_t flags; - reader.Read(kFlagsOffset, &flags, sizeof(flags)); - bool const isHostBigEndian = IsBigEndianMacroBased(); - bool const isDataBigEndian = flags & 1; - if (isHostBigEndian != isDataBigEndian) - return CheckResult::EndiannessMismatch; - return CheckResult::EndiannessMatch; -} +size_t constexpr kVersionOffset = 0; +size_t constexpr kHeaderSize = 8; unique_ptr GetMemoryRegionForTag(FilesContainerR const & rcont, FilesContainerBase::Tag const & tag) { if (!rcont.IsExist(tag)) - return unique_ptr(); + return {}; + FilesContainerR::TReader reader = rcont.GetReader(tag); vector buffer(static_cast(reader.Size())); reader.Read(0, buffer.data(), buffer.size()); @@ -78,13 +47,13 @@ unique_ptr GetMemoryRegionForTag(FilesMappingContainer const FilesContainerBase::Tag const & tag) { if (!mcont.IsExist(tag)) - return unique_ptr(); + return {}; + FilesMappingContainer::Handle handle = mcont.Map(tag); return make_unique(std::move(handle)); } -// RankTable version 1, uses simple dense coding to store and access -// array of ranks. +// RankTable version 0, uses simple dense coding to store and access array of ranks. class RankTableV0 : public RankTable { public: @@ -99,7 +68,7 @@ public: // May be there is a better way to inject this code. Without this check search engine crashes here. //ASSERT_LESS(i, Size(), ()); if (i >= Size()) - return 0; + return kNoRank; return m_coding.Get(i); } @@ -107,60 +76,23 @@ public: RankTable::Version GetVersion() const override { return V0; } void Serialize(Writer & writer, bool preserveHostEndianness) override { - static uint64_t const padding = 0; - uint8_t const version = GetVersion(); - uint8_t const flags = preserveHostEndianness ? IsBigEndianMacroBased() : !IsBigEndianMacroBased(); - writer.Write(&version, sizeof(version)); - writer.Write(&flags, sizeof(flags)); - writer.Write(&padding, 6); - if (preserveHostEndianness) - Freeze(m_coding, writer, "SimpleDenseCoding"); - else - ReverseFreeze(m_coding, writer, "SimpleDenseCoding"); + size_t constexpr kVersionSize = sizeof(version); + writer.Write(&version, kVersionSize); + + uint64_t const padding = 0; + static_assert(kHeaderSize % 8 == 0); // next succinct vector should be aligned + writer.Write(&padding, kHeaderSize - kVersionSize); + + Freeze(m_coding, writer, "SimpleDenseCoding"); } // Loads RankTableV0 from a raw memory region. - static unique_ptr Load(unique_ptr && region) + template static unique_ptr Load(unique_ptr && region) { - if (!region.get()) - return unique_ptr(); - - auto const result = - CheckEndianness(MemReader(region->ImmutableData(), static_cast(region->Size()))); - if (result != CheckResult::EndiannessMatch) - return unique_ptr(); - auto table = make_unique(); - coding::Map(table->m_coding, region->ImmutableData() + kHeaderSize, "SimpleDenseCoding"); table->m_region = std::move(region); - return table; - } - - // Loads RankTableV0 from a raw memory region. Modifies region in - // the case of endianness mismatch. - static unique_ptr Load(unique_ptr && region) - { - if (!region.get()) - return unique_ptr(); - - unique_ptr table; - switch ( - CheckEndianness(MemReader(region->ImmutableData(), static_cast(region->Size())))) - { - case CheckResult::CorruptedHeader: - break; - case CheckResult::EndiannessMismatch: - table.reset(new RankTableV0()); - coding::ReverseMap(table->m_coding, region->MutableData() + kHeaderSize, "SimpleDenseCoding"); - table->m_region = std::move(region); - break; - case CheckResult::EndiannessMatch: - table.reset(new RankTableV0()); - coding::Map(table->m_coding, region->ImmutableData() + kHeaderSize, "SimpleDenseCoding"); - table->m_region = std::move(region); - break; - } + coding::Map(table->m_coding, table->m_region->ImmutableData() + kHeaderSize, "SimpleDenseCoding"); return table; } @@ -176,7 +108,6 @@ void SerializeRankTable(RankTable & table, FilesContainerW & wcont, string const { if (wcont.IsExist(sectionName)) wcont.DeleteSection(sectionName); - ASSERT(!wcont.IsExist(sectionName), ()); vector buffer; { @@ -217,77 +148,22 @@ unique_ptr LoadRankTable(unique_ptr && region) return {}; } -uint8_t CalcEventRank(FeatureType & /*ft*/) -{ - //TODO: add custom event processing, i.e. fc2018. - return 0; -} - -uint8_t CalcTransportRank(FeatureType & ft) -{ - uint8_t const kTransportRank = 2; - if (ftypes::IsRailwayStationChecker::Instance()(ft) || - ftypes::IsSubwayStationChecker::Instance()(ft) || ftypes::IsAirportChecker::Instance()(ft)) - { - return kTransportRank; - } - - return 0; -} - // Calculates search rank for a feature. uint8_t CalcSearchRank(FeatureType & ft) { - auto const eventRank = CalcEventRank(ft); - auto const transportRank = CalcTransportRank(ft); - auto const populationRank = feature::PopulationToRank(ftypes::GetPopulation(ft)); - - return base::Clamp(eventRank + transportRank + populationRank, 0, - static_cast(numeric_limits::max())); + return feature::PopulationToRank(ftypes::GetPopulation(ft)); } // Creates rank table if it does not exists in |rcont| or has wrong -// endianness. Otherwise (table exists and has correct format) returns -// null. +// endianness. Otherwise (table exists and has correct format) returns null. unique_ptr CreateSearchRankTableIfNotExists(FilesContainerR & rcont) { - unique_ptr table; - if (rcont.IsExist(SEARCH_RANKS_FILE_TAG)) - { - switch (CheckEndianness(rcont.GetReader(SEARCH_RANKS_FILE_TAG))) - { - case CheckResult::CorruptedHeader: - { - // Worst case - we need to create rank table from scratch. - break; - } - case CheckResult::EndiannessMismatch: - { - // Try to copy whole serialized data and instantiate table via - // reverse mapping. - auto region = GetMemoryRegionForTag(rcont, SEARCH_RANKS_FILE_TAG); - table = LoadRankTable(std::move(region)); - break; - } - case CheckResult::EndiannessMatch: - { - // Table exists and has proper format. Nothing to do here. - return unique_ptr(); - } - } - } + return {}; - // Table doesn't exist or has wrong format. It's better to create it - // from scratch. - if (!table) - { - vector ranks; - SearchRankTableBuilder::CalcSearchRanks(rcont, ranks); - table = make_unique(ranks); - } - - return table; + vector ranks; + SearchRankTableBuilder::CalcSearchRanks(rcont, ranks); + return make_unique(ranks); } } // namespace @@ -313,37 +189,6 @@ void SearchRankTableBuilder::CalcSearchRanks(FilesContainerR & rcont, vector table; - { - ModelReaderPtr reader = platform::GetCountryReader(localFile, MapFileType::Map); - if (!reader.GetPtr()) - return false; - - mapPath = reader.GetName(); - - FilesContainerR rcont(reader); - table = CreateSearchRankTableIfNotExists(rcont); - } - - if (table) - SerializeRankTable(*table, mapPath, SEARCH_RANKS_FILE_TAG); - - return true; - } - catch (exception & e) - { - LOG(LWARNING, ("Can' create rank table for:", localFile, ":", e.what())); - return false; - } -} - // static bool SearchRankTableBuilder::CreateIfNotExists(string const & mapPath) noexcept { @@ -360,7 +205,7 @@ bool SearchRankTableBuilder::CreateIfNotExists(string const & mapPath) noexcept return true; } - catch (exception & e) + catch (RootException const & e) { LOG(LWARNING, ("Can' create rank table for:", mapPath, ":", e.what())); return false; diff --git a/indexer/rank_table.hpp b/indexer/rank_table.hpp index 6f2a19886c..7a26a2fa86 100644 --- a/indexer/rank_table.hpp +++ b/indexer/rank_table.hpp @@ -48,7 +48,8 @@ public: virtual ~RankTable() = default; - // Returns rank of the i-th feature. + static uint8_t constexpr kNoRank = 0; + /// @return rank of the i-th feature, or kNoRank if there is no rank. virtual uint8_t Get(uint64_t i) const = 0; // Returns total number of ranks (or features, as there is a 1-1 correspondence). @@ -112,7 +113,6 @@ public: // // Return true if rank table was successfully generated and written // or already exists and has correct format. - static bool CreateIfNotExists(platform::LocalCountryFile const & localFile) noexcept; static bool CreateIfNotExists(std::string const & mapPath) noexcept; }; } // namespace search diff --git a/search/dummy_rank_table.cpp b/search/dummy_rank_table.cpp index 9d54b9f220..ec357ac588 100644 --- a/search/dummy_rank_table.cpp +++ b/search/dummy_rank_table.cpp @@ -2,16 +2,14 @@ #include "base/macros.hpp" -#include - namespace search { -uint8_t DummyRankTable::Get(uint64_t /* i */) const { return 0; } +uint8_t DummyRankTable::Get(uint64_t /* i */) const { return kNoRank; } uint64_t DummyRankTable::Size() const { NOTIMPLEMENTED(); - return std::numeric_limits::max(); + return 0; } RankTable::Version DummyRankTable::GetVersion() const diff --git a/search/search_quality/search_quality_tests/real_mwm_tests.cpp b/search/search_quality/search_quality_tests/real_mwm_tests.cpp index 7036cacb76..cddf8e9360 100644 --- a/search/search_quality/search_quality_tests/real_mwm_tests.cpp +++ b/search/search_quality/search_quality_tests/real_mwm_tests.cpp @@ -474,9 +474,9 @@ UNIT_CLASS_TEST(MwmTestsFixture, Street_BusStop) auto const & results = request->Results(); TEST_GREATER(results.size(), kTopPoiResultsCount, ()); - // Top results are Hotel and Street. - Range const range(results, 0, 3); - EqualClassifType(range, GetClassifTypes({{"tourism", "hotel"}, {"shop", "supermarket"}, {"highway"}})); + // Top results are Hotel and Street (sometimes bus stop). + Range const range(results); + EqualClassifType(range, GetClassifTypes({{"tourism", "hotel"}, {"highway", "bus_stop"}, {"highway", "residential"}})); } { @@ -500,6 +500,17 @@ UNIT_CLASS_TEST(MwmTestsFixture, Street_BusStop) EqualClassifType(range, GetClassifTypes({{"highway", "bus_stop"}})); TEST_LESS(SortedByDistance(range, center), 5000.0, ()); } + + { + auto request = MakeRequest("Juncal train", "en"); + auto const & results = request->Results(); + TEST_GREATER(results.size(), kTopPoiResultsCount, ()); + + // First result is a train station in other MWM, >200km away. + TEST(EqualClassifType(results[0].GetFeatureType(), classif().GetTypeByPath({"railway", "station"})), ()); + double const dist = ms::DistanceOnEarth(center, mercator::ToLatLon(results[0].GetFeatureCenter())); + TEST_GREATER(dist, 2.0E5, ()); + } } UNIT_CLASS_TEST(MwmTestsFixture, Generic_Buildings_Rank) -- 2.45.3 From 51b20ea661e408df3fff58b7ec25bb83c15a0110 Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Sun, 11 Jun 2023 14:52:21 -0300 Subject: [PATCH 10/17] [search] Fixed unclassified/service/road streets rank. Signed-off-by: Viktor Govako --- indexer/ftypes_matcher.cpp | 6 +++--- indexer/ftypes_matcher.hpp | 1 + search/ranking_info.cpp | 2 ++ .../search_quality_tests/real_mwm_tests.cpp | 18 +++++++++++++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index 8c065b6990..ecf1926bb2 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -346,16 +346,16 @@ IsWayChecker::IsWayChecker() {"primary", Regular}, {"primary_link", Regular}, {"residential", Residential}, - {"road", Outdoor}, + {"road", Minors}, {"secondary", Regular}, {"secondary_link",Regular}, - {"service", Residential}, + {"service", Minors}, {"tertiary", Regular}, {"tertiary_link", Regular}, {"track", Outdoor}, {"trunk", Motorway}, {"trunk_link", Motorway}, - {"unclassified", Outdoor}, + {"unclassified", Minors}, }; m_ranks.Reserve(std::size(types)); diff --git a/indexer/ftypes_matcher.hpp b/indexer/ftypes_matcher.hpp index 65eb507c9f..c4611a541b 100644 --- a/indexer/ftypes_matcher.hpp +++ b/indexer/ftypes_matcher.hpp @@ -222,6 +222,7 @@ public: Pedestrian, Cycleway, Outdoor, + Minors, Residential, Regular, Motorway, diff --git a/search/ranking_info.cpp b/search/ranking_info.cpp index 35fd65edfc..34e1ec175d 100644 --- a/search/ranking_info.cpp +++ b/search/ranking_info.cpp @@ -84,6 +84,7 @@ double constexpr kStreetType[] = { 0, // Pedestrian 0, // Cycleway 0, // Outdoor + 0.004, // Minors 0.004, // Residential 0.005, // Regular 0.006, // Motorway @@ -404,6 +405,7 @@ std::string DebugPrint(StreetType type) case StreetType::Pedestrian: return "Pedestrian"; case StreetType::Cycleway: return "Cycleway"; case StreetType::Outdoor: return "Outdoor"; + case StreetType::Minors: return "Minors"; case StreetType::Residential: return "Residential"; case StreetType::Regular: return "Regular"; case StreetType::Motorway: return "Motorway"; diff --git a/search/search_quality/search_quality_tests/real_mwm_tests.cpp b/search/search_quality/search_quality_tests/real_mwm_tests.cpp index cddf8e9360..8e8b3df0a2 100644 --- a/search/search_quality/search_quality_tests/real_mwm_tests.cpp +++ b/search/search_quality/search_quality_tests/real_mwm_tests.cpp @@ -533,7 +533,6 @@ UNIT_CLASS_TEST(MwmTestsFixture, Generic_Buildings_Rank) { auto request = MakeRequest("dia ", "en"); auto const & results = request->Results(); - LOG(LINFO, (results)); TEST_GREATER(results.size(), kTopPoiResultsCount, ()); Range const range(results); @@ -570,4 +569,21 @@ UNIT_CLASS_TEST(MwmTestsFixture, UTH_Airport) TEST(found, (results)); } +// https://github.com/organicmaps/organicmaps/issues/5186 +UNIT_CLASS_TEST(MwmTestsFixture, Milan_Streets) +{ + // Milan + ms::LatLon const center(45.46411, 9.19045); + SetViewportAndLoadMaps(center); + + auto request = MakeRequest("Via Domenichino", "it"); + auto const & results = request->Results(); + + size_t constexpr kResultsCount = 2; + TEST_GREATER(results.size(), kResultsCount, ()); + + Range const range(results, 0, kResultsCount); + TEST_LESS(SortedByDistance(range, center), 20000.0, ()); +} + } // namespace real_mwm_tests -- 2.45.3 From bdde6e6d50bd40c7e82355599d0616863935d21b Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Sun, 11 Jun 2023 15:37:38 -0300 Subject: [PATCH 11/17] [search] Added common Spanish _prefix_ misprints. Signed-off-by: Viktor Govako --- indexer/search_string_utils.cpp | 3 ++ .../processor_test.cpp | 30 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/indexer/search_string_utils.cpp b/indexer/search_string_utils.cpp index 7ded9149e9..6f32e2a950 100644 --- a/indexer/search_string_utils.cpp +++ b/indexer/search_string_utils.cpp @@ -30,6 +30,9 @@ std::vector const kAllowedMisprints = { MakeUniString("ао"), MakeUniString("еиэ"), MakeUniString("шщ"), + // Spanish + MakeUniString("jh"), // "Jose" <-> "Hose" + MakeUniString("fh"), // "Hernández" <-> "Fernández" }; std::pair const kPreprocessReplacements[] = { diff --git a/search/search_integration_tests/processor_test.cpp b/search/search_integration_tests/processor_test.cpp index 8bf5998de9..885622a04b 100644 --- a/search/search_integration_tests/processor_test.cpp +++ b/search/search_integration_tests/processor_test.cpp @@ -559,7 +559,7 @@ UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo_PureCategory) } } -UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo_ErrorsMade) +UNIT_CLASS_TEST(ProcessorTest, RankingInfo_ErrorsMade_1) { TestCity chekhov({0, 0}, "Чеховъ Антонъ Павловичъ", "ru", 100 /* rank */); @@ -605,6 +605,7 @@ UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo_ErrorsMade) checkErrors("Cafe Yesenina", ErrorsMade(0)); checkErrors("Cafe Jesenina", ErrorsMade(1)); + /// @see search_string_utils.cpp, kAllowedMisprints // We allow only Y->{E, J, I, U} misprints for the first letter. checkErrors("Cafe Esenina", ErrorsMade(2)); @@ -634,6 +635,33 @@ UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo_ErrorsMade) checkErrors("лермонтов чеховъ антон павлович", ErrorsMade(2)); } +// https://github.com/organicmaps/organicmaps/issues/5296 +UNIT_CLASS_TEST(ProcessorTest, RankingInfo_ErrorsMade_2) +{ + TestStreet hernandes({{-0.5, -0.5}, {0, 0}, {0.5, 0.5}}, "José Hernández", "es"); + + auto wonderlandId = BuildCountry("Wonderland", [&](TestMwmBuilder & builder) + { + builder.Add(hernandes); + }); + + SetViewport(m2::RectD(-1, -1, 1, 1)); + + auto checkErrors = [&](string const & query, ErrorsMade const & errorsMade) + { + auto request = MakeRequest(query, "es"); + auto const & results = request->Results(); + + Rules rules{ExactMatch(wonderlandId, hernandes)}; + TEST(ResultsMatch(results, rules), (query)); + TEST_EQUAL(results.size(), 1, (query)); + TEST_EQUAL(results[0].GetRankingInfo().m_errorsMade, errorsMade, (query)); + }; + + checkErrors("Hose", ErrorsMade(1)); + checkErrors("Fernández", ErrorsMade(1)); +} + UNIT_CLASS_TEST(ProcessorTest, TestHouseNumbers) { TestCity greenCity({0, 0}, "Зеленоград", "ru", 100 /* rank */); -- 2.45.3 From 3093c9c5484612b54336560468a9fc1dbd9cb42d Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Sun, 11 Jun 2023 15:54:33 -0300 Subject: [PATCH 12/17] [search] Added "the" as a stopword in ranking. Signed-off-by: Viktor Govako --- search/ranking_utils.cpp | 2 +- .../search_quality_tests/real_mwm_tests.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/search/ranking_utils.cpp b/search/ranking_utils.cpp index 31da4e0b5f..203406319e 100644 --- a/search/ranking_utils.cpp +++ b/search/ranking_utils.cpp @@ -112,7 +112,7 @@ bool IsStopWord(UniString const & s) // Don't want to put _full_ stopwords list, not to break current ranking. // Only 2-letters and the most common. char const * arr[] = { - "a", "s", // English + "a", "s", "the", // English "am", "im", "an", // German "d", "de", "di", "da", "la", "le", // French, Spanish, Italian "и", "я" // Cyrillic diff --git a/search/search_quality/search_quality_tests/real_mwm_tests.cpp b/search/search_quality/search_quality_tests/real_mwm_tests.cpp index 8e8b3df0a2..c5a565c893 100644 --- a/search/search_quality/search_quality_tests/real_mwm_tests.cpp +++ b/search/search_quality/search_quality_tests/real_mwm_tests.cpp @@ -586,4 +586,21 @@ UNIT_CLASS_TEST(MwmTestsFixture, Milan_Streets) TEST_LESS(SortedByDistance(range, center), 20000.0, ()); } +// https://github.com/organicmaps/organicmaps/issues/5150 +UNIT_CLASS_TEST(MwmTestsFixture, London_RedLion) +{ + // Milan + ms::LatLon const center(51.49263, -0.12877); + SetViewportAndLoadMaps(center); + + auto request = MakeRequest("Red Lion", "en"); + auto const & results = request->Results(); + + TEST_GREATER(results.size(), kPopularPoiResultsCount, ()); + + // Top first results "The Red Lion" in 5 km. + Range const range(results); + TEST_LESS(SortedByDistance(range, center), 5000.0, ()); +} + } // namespace real_mwm_tests -- 2.45.3 From 57b31173e887d99d363f5d82c03be89dd378603d Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Mon, 12 Jun 2023 09:52:06 -0300 Subject: [PATCH 13/17] [search] Fixed addr:interpolation result rank (same as building address). Signed-off-by: Viktor Govako --- search/geocoder.cpp | 13 +++++++++---- search/intersection_result.hpp | 10 ++++++++-- search/model.cpp | 8 +++++++- search/ranker.cpp | 13 +++++++++++-- .../search_quality_tests/real_mwm_tests.cpp | 17 +++++++++++++++++ 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/search/geocoder.cpp b/search/geocoder.cpp index cbd55fb746..be3f17b5ac 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -1436,8 +1436,8 @@ void Geocoder::MatchPOIsAndBuildings(BaseContext & ctx, size_t curToken, CBV con } } - // Following code creates a fake layer with buildings and - // intersects it with the streets layer. + // Following code creates a fake TYPE_BUILDING layer and intersects it with the streets layer. + // Controversial: we can emit streets like buildings here. Filtered in IsFakeBuildingButStreet(). layers.emplace_back(); SCOPE_GUARD(cleanupGuard, [&]{ layers.pop_back(); }); @@ -1445,7 +1445,8 @@ void Geocoder::MatchPOIsAndBuildings(BaseContext & ctx, size_t curToken, CBV con InitLayer(Model::TYPE_BUILDING, m_postcodes.m_tokenRange, layer); vector features; - m_postcodes.m_countryFeatures.ForEach([&features](uint64_t bit) { + m_postcodes.m_countryFeatures.ForEach([&features](uint64_t bit) + { features.push_back(base::asserted_cast(bit)); }); layer.m_sortedFeatures = &features; @@ -1683,8 +1684,12 @@ void Geocoder::FindPaths(BaseContext & ctx) return true; }; - m_finder.ForEachReachableVertex(*m_matcher, sortedLayers, [&](IntersectionResult const & result) { + m_finder.ForEachReachableVertex(*m_matcher, sortedLayers, [&](IntersectionResult const & result) + { ASSERT(result.IsValid(), ()); + if (result.IsFakeBuildingButStreet()) + return; + EmitResult(ctx, m_context->GetId(), result.InnermostResult(), innermostLayer.m_type, innermostLayer.m_tokenRange, &result, ctx.AllTokensUsed(), isExactMatch(ctx, result)); diff --git a/search/intersection_result.hpp b/search/intersection_result.hpp index 926ca297a1..509c15e035 100644 --- a/search/intersection_result.hpp +++ b/search/intersection_result.hpp @@ -16,13 +16,19 @@ struct IntersectionResult void Set(Model::Type type, uint32_t id); - // Returns the first valid feature among the [SUBPOI, COMPLEX_POI, BUILDING, - // STREET]. + // Returns the first valid feature among the [SUBPOI, COMPLEX_POI, BUILDING, STREET]. uint32_t InnermostResult() const; // Returns true when at least one valid feature exists. inline bool IsValid() const { return InnermostResult() != kInvalidId; } + // Building == Streets means that we have actual street result, but got here + // via _fake_ TYPE_BUILDING layer (see MatchPOIsAndBuildings). + inline bool IsFakeBuildingButStreet() const + { + return m_building != kInvalidId && m_building == m_street; + } + // Clears all fields to an invalid state. void Clear(); diff --git a/search/model.cpp b/search/model.cpp index 8ed1f6ca4a..c2d60b0cf2 100644 --- a/search/model.cpp +++ b/search/model.cpp @@ -111,7 +111,13 @@ public: bool operator()(FeatureType & ft) const { - return !ft.GetHouseNumber().empty() || IsBuildingChecker::Instance()(ft); + if (!ft.GetHouseNumber().empty()) + return true; + + if (ft.GetGeomType() == feature::GeomType::Line) + return IsAddressInterpolChecker::Instance()(ft); + else + return IsBuildingChecker::Instance()(ft); } }; } // namespace diff --git a/search/ranker.cpp b/search/ranker.cpp index cd09b7268e..628d0505a8 100644 --- a/search/ranker.cpp +++ b/search/ranker.cpp @@ -143,8 +143,17 @@ NameScores GetNameScores(FeatureType & ft, Geocoder::Params const & params, } if (type == Model::TYPE_BUILDING) - UpdateNameScores(ft.GetHouseNumber(), StringUtf8Multilang::kDefaultCode, sliceNoCategories, - bestScores); + { + if (ft.GetGeomType() == feature::GeomType::Line) + { + // Separate case for addr:interpolation (Building + Line). + ASSERT(!ft.GetRef().empty(), ()); + // Just assign SUBSTRING with no errors (was checked in HouseNumbersMatch). + bestScores.UpdateIfBetter(NameScores(NameScore::SUBSTRING, ErrorsMade(0), false, 4)); + } + else + UpdateNameScores(ft.GetHouseNumber(), StringUtf8Multilang::kDefaultCode, sliceNoCategories, bestScores); + } if (ftypes::IsAirportChecker::Instance()(ft)) { diff --git a/search/search_quality/search_quality_tests/real_mwm_tests.cpp b/search/search_quality/search_quality_tests/real_mwm_tests.cpp index c5a565c893..bac545317a 100644 --- a/search/search_quality/search_quality_tests/real_mwm_tests.cpp +++ b/search/search_quality/search_quality_tests/real_mwm_tests.cpp @@ -603,4 +603,21 @@ UNIT_CLASS_TEST(MwmTestsFixture, London_RedLion) TEST_LESS(SortedByDistance(range, center), 5000.0, ()); } +UNIT_CLASS_TEST(MwmTestsFixture, AddrInterpolation_Rank) +{ + // Buenos Aires (Palermo) + ms::LatLon const center(-34.57852, -58.42567); + SetViewportAndLoadMaps(center); + + auto request = MakeRequest("Sante Fe 1176", "en"); + auto const & results = request->Results(); + + TEST_GREATER(results.size(), kPopularPoiResultsCount, ()); + + // Top first address results in 50 km. + Range const range(results); + EqualClassifType(range, GetClassifTypes({{"addr:interpolation"}})); + TEST_LESS(SortedByDistance(range, center), 50000.0, ()); +} + } // namespace real_mwm_tests -- 2.45.3 From da5f13d6b30e9579f43c94bd9163ee1550ce6d43 Mon Sep 17 00:00:00 2001 From: endim8 Date: Tue, 13 Jun 2023 13:13:12 +0100 Subject: [PATCH 14/17] link to DEBUG_COMMANDS.md in debug commands section Signed-off-by: Harry Bond --- docs/INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 6f99e547ee..fb56e295df 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -268,7 +268,7 @@ To switch themes you can enter this commands: - `?vlight` - Day theme for vehicle navigation - `?vdark` - Night theme for vehicle navigation -There are also other commands for turning on/off isolines, antialiasing, etc. Check [the code](https://github.com/organicmaps/organicmaps/blob/6ae19b40c2b7a515338eb128547df05da13bdb78/map/framework.cpp#L2570-L2671) to learn about them. +There are also other commands for turning on/off isolines, antialiasing, etc. Check [DEBUG_COMMANDS.md](DEBUG_COMMANDS.md) to learn about them. ### More options -- 2.45.3 From e751ec3bc721eae12178282dd483cd9cdf19eee0 Mon Sep 17 00:00:00 2001 From: endim8 Date: Mon, 12 Jun 2023 14:54:07 +0100 Subject: [PATCH 15/17] Update INSTALL.md: fix dependency Signed-off-by: Harry Bond --- docs/INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index fb56e295df..ff8b4f3e53 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -130,7 +130,7 @@ sudo dnf install -y \ freetype-devel \ libicu-devel \ libstdc++-devel \ - libgl1-mesa-devel \ + mesa-libGL-devel \ libglvnd-devel \ qt6-qtbase-devel \ qt6-qtsvg-devel \ -- 2.45.3 From cd91d5d121807de9b88fad628f9e4a48e4fd955f Mon Sep 17 00:00:00 2001 From: Konstantin Pastbin Date: Wed, 7 Jun 2023 15:30:22 +0300 Subject: [PATCH 16/17] [doc] Add desktop-specific search commands Signed-off-by: Konstantin Pastbin --- docs/DEBUG_COMMANDS.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/DEBUG_COMMANDS.md b/docs/DEBUG_COMMANDS.md index d37d4ee060..ae8d261505 100644 --- a/docs/DEBUG_COMMANDS.md +++ b/docs/DEBUG_COMMANDS.md @@ -27,6 +27,13 @@ For more information, please see the source code at [`Framework::ParseSearchQuer - `?isolines`: Enable the isolines layer. - `?no-isolines`: Disable the isolines layer. +### 3D mode (for the Qt desktop app only) +- `?3d`: Enable 3D (perspective) mode. +- `?b3d`: Enable 3D buildings. +- `?2d`: Disable 3D mode and buildings. + +The source code is at [`SearchPanel::Try3dModeCmd`](../qt/search_panel.cpp). + ### Information - `?debug-info`: Show renderer version, zoom scale and FPS counter in the top left corner of the map. -- 2.45.3 From 40c9a53de22671f82c914eef1220c0beef37fcb4 Mon Sep 17 00:00:00 2001 From: "Black Box Embedded, LLC" <64652300+blackboxembedded@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:14:42 -0600 Subject: [PATCH 17/17] Update android/src/app/organicmaps/intent/Factory.java Co-authored-by: Alexander Borsuk <170263+biodranik@users.noreply.github.com> Signed-off-by: Keith Conger --- android/src/app/organicmaps/intent/Factory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/app/organicmaps/intent/Factory.java b/android/src/app/organicmaps/intent/Factory.java index 85443ed6a5..824ee36198 100644 --- a/android/src/app/organicmaps/intent/Factory.java +++ b/android/src/app/organicmaps/intent/Factory.java @@ -211,7 +211,7 @@ public class Factory intent.putExtra(MwmActivity.EXTRA_BACK_URL, backUrl); } - // TODO: Kernel recognizes "mapsme://", "mwm://" and "mapswithme://" schemas only!!! + // Kernel recognizes "om://", "mapsme://", "mwm://" and "mapswithme://" schemes only!!! if (result.getUrlType() == ParsingResult.TYPE_INCORRECT) return Map.showMapForUrl(getUrl()); -- 2.45.3